« Home « Chủ đề các framework phổ biến

Chủ đề : các framework phổ biến


Có 40+ tài liệu thuộc chủ đề "các framework phổ biến"

Secure PHP Development- P20

tailieu.vn

Each intranet application you develop must be able to authenticate and autho- rize different types of users. So far, our intranet application framework has the following requirements:. When a user attempts to access an intranet application without logging in first, the application should automatically redirect the user to the login application. Employee access to an intranet application will vary.. Because...

Secure PHP Development- P21

tailieu.vn

Also note that the database abstraction uses DB.php from the PEAR.. Here, we will cre- ate a class called class.DBI.php that will implement a database abstraction layer for our application framework. Listing 4-1 shows class.DBI.php , which implements the database abstraction using PEAR DB.. See http://pear.php.net/manual/en/core.db.php for details on PEAR DB, a unified API for accessing SQL-databases.. Listing 4-1: class.DBI.php....

Secure PHP Development- P22

tailieu.vn

echo “<pre>”;. echo “</pre>”;. The result of the query is stored in a result object called $result . If the query is successful, it returns the result object. The result object can be used to fetch rows. If the result of query is NULL then show. echo “Database error. echo “<pre>ID\tNAME<br>”;. The result is tested first for null. If the...

Secure PHP Development- P23

tailieu.vn

Every application needs to display error messages. In the old days, error messages were usually hard-coded in the executable programs and were very difficult to understand, let alone modify!. Error messages written in English are just not friendly enough for the world in this Internet age. So applications that have internationalizable error message support will have broader reach.. Listing 4-2...

Secure PHP Development- P24

tailieu.vn

if ($this->banner_printed. $out = “<br><br><font color=’$this->myTextColor’>”. “<strong>Debugger started for $this->prefix</strong>”. “</font><br><hr>”;. if ($this->buffer. $this->buffer_str. $this->banner_printed = TRUE;. $out = sprintf(“<font color=’%s’>%03d &nbsp;</font>”. “<font color=%s>%s</font><br>\n”,. $this->myTextColor,. $this->line++,. $this->color,. $this->write(“$k = $v”);. $this->buffer = TRUE;. $this->buffer = FALSE;. $this->buffer_str = null;. $this->print_banner();. echo $this->buffer_str;. ‘color’ =>. ‘prefix’ =>. ‘buffer’ =>. This function sets the buffering of debug messages.. This function resets the...

Secure PHP Development- P25

tailieu.vn

will be printed after the “This will print before debug messages.. $this->app_name = $this->setDefault($param[‘app_name. $this->app_version = $this->setDefault($param[‘app_version. $this->app_type = $this->setDefault($param[‘app_type. $this->app_db_url = $this->setDefault($param[‘app_db_url. $this->debug_mode= $this->setDefault($param[‘app_debugger. $this->auto_connect = $this->setDefault($param[‘app_auto_connect. $this->auto_chk_session = $this-. >setDefault($param[‘app_auto_chk_session. $this->auto_authorize = $this-. >setDefault($param[‘app_auto_authorize. $this->session_ok = $this-. $this->error = array();. $this->authorized= FALSE;. $this->language = $DEFAULT_LANGUAGE;. $this->base_url = sprintf(“%s%s”, $this->get_server(),. $this->app_path = $REL_APP_PATH;. $this->template_dir = $TEMPLATE_DIR;. $this->messages = $MESSAGES;....

Secure PHP Development- P26

tailieu.vn

$this->server = sprintf(“%s://%s%s”,. $this->getEnvironment(‘HTTP_HOST’),. $this->self_url = sprintf(“%s://%s%s%s”, $protocol,. $this->getEnvironment(‘REQUEST_URI’));. return $this->server;. $this->dbi->disconnect();. $this->errHandler = new ErrorHandler(. return $this->errHandler->error_message[$code];. return $this->errHandler->alert($code, 0);. $msg = $this->messages[$this->language][$code];. $this->errHandler->alert($code, $flag. $this->debug_mode. $this->debugger->set_buffer();. $this->debugger->flush_buffer();. if ($this->debug_mode. $this->debugger->write($msg);. $this->writeln(“You need to override this method.”);. $db_url = $this->app_db_url;. $this->dbi = new DBI($db_url);. return $this->dbi->connected;. function get_error_message($code = null). return $this->errHandler->get_error_message($code);. $this->debugger->print_banner();. return $this->app_version;. return $this->app_name;. return $this->app_type;....

Secure PHP Development- P27

tailieu.vn

$ok = $this->$func($fieldData[$field]);. $this->alert($errorCode{$field});. $this->debugger->debug_array($hash);. echo $msg ,(strstr($this->app_type, ‘WEB. $appPath = sprintf(“%s/%s”, $this->app_path, $returnURL);. $template->set_var(‘RETURN_URL’, $appPath);. $template->set_var(‘BASE_URL’, $this->base_url);. return $this->escapedVarHash{$key};. $this->user_id = $uid;. return $this->user_id;. return $this->user_name;. $this->alert($errCode);

Secure PHP Development- P28

tailieu.vn

$this->doCommonTemplateWork($menuTemplate, $templateFile, $app_name);. $status = $this->$func($menuTemplate);. return $this->outputTemplate($menuTemplate);. $t->set_file(‘fh’, $templateFile);. $t->set_block(‘fh’,’mainBlock’, ‘main’);. $t->set_var(array(. ‘APP_PATH’ =>. $this->getAppPath(),. ‘APP_NAME’ =>. ‘BASE_URL’ =>. $this->getBaseURL(). $themeObj = new Theme($this->dbi, null,’home’);. $this->themeObj = $themeObj;. $this->theme = $themeObj->getUserTheme($this->getUID());. $themeTemplate->set_file(‘fh’, $THEME_TEMPLATE[$this->theme]);. $themeTemplate->set_block(‘fh’, ‘mmainBlock’, ‘mmblock’);. $themeTemplate->set_block(‘mmainBlock’, ‘contentBlock’, ‘cnblock’);. $themeTemplate->set_block(‘mmainBlock’, ‘printBlock’, ‘prnblock’);. $themeTemplate->set_var(‘printBlock’, ‘&nbsp;’);. $themeTemplate->parse(‘prnblock’, ‘printBlock’,false);. $themeTemplate->set_block(‘mmainBlock’, ‘pageBlock’, ‘pblock’);. $themeTemplate->set_var(‘pblock’, null);. $photoFile = sprintf(“%s/photo%003d.jpg”,$PHOTO_DIR, $this->getUID());. $userPhoto = sprintf(“%s/photo%003d.jpg”,$REL_PHOTO_DIR,$this->getUID());. $themeTemplate->set_var(‘PHOTO’,...

Secure PHP Development- P29

tailieu.vn

number() Returns 1 if the parameter is a number or a number array. name() Returns 1 if the parameter is not empty and not a number. email() Returns 1 if the parameter is an e-mail address;. currency() Returns 1 if the parameter is a currency number;. month() Returns 1 if the parameter is a number between 1 and 12. day()...

Secure PHP Development- P30

tailieu.vn

If the sample appli- cation is to be used in a different language region, say in Spain, then this file can be modified to create the ES (shorthand for Spanish) language-specific errors by replacing US as ES and also translating the actual error messages.. The sample application then loads the sample.messages file, which is shown in Listing 4-8.. The sample.conf...

Secure PHP Development- P31

tailieu.vn

Central Authentication System. A CENTRAL AUTHENTICATION SYSTEM consists of two applications: login and logout.. The login application allows users to login and the logout application is used to ter- minate the login session. When such an application starts up, it checks to see if the user is already authen- ticated. If such a user session is found, the user is...

Secure PHP Development- P32

tailieu.vn

$this->status = TRUE;. $this->user_id = $row->USER_ID;. $this->status = FALSE;. return $this->status;. return $this->user_id;. (The authentication system uses e-mail address as the username and, therefore, it is a required item in the user-supplied credential.) The password para- meter is stored in the password variable.. If the user account has been deactivated ( ACTIVE = 0. and if the user account is...

Secure PHP Development- P33

tailieu.vn

global $AUTH_DB_URL;. ‘app_name’ =>. ‘app_version’ =>. ‘app_type’ =>. ‘app_db_url’ =>. $AUTH_DB_URL,. ‘app_auto_authorize’ =>. ‘app_auto_chk_session’ =>. ‘app_auto_connect’ =>. ‘app_debugger’ =>. Figure 5-5 shows the flow diagram of login.php . When the login application is run, it goes through the following steps:. It determines if the user is already authenticated. ticated() method to determine if the user has a session already. If...

Secure PHP Development- P34

tailieu.vn

All the error messages that the login.php application generates are taken from the login.errors file shown in Listing 5-4.. Listing 5-4: login.errors. The login.php application displays the login menu using the login.ihtml file, which is shown in Listing 5-5. The $LOGIN_TEMPLATE is set to point to. login.ihtml in the login.conf file.. Listing 5-5: login.ihtml. <td bgcolor=”#cccccc” colspan=2>Login</td>. <td>Email</td>. <td><input type=text...

Secure PHP Development- P35

tailieu.vn

$this->debug(“User failed authentication.”);. $this->display_login();. $_SESSION[“SESSION_ATTEMPTS”]. $this->getSessionField(“SESSION_ATTEMPTS. $this->debug(“Came to warn the user $WARNING_URL”);. $url = $this->getRequestField(‘url’);. if ($this->getSessionField(“SESSION_ATTEMPTS”) >. $this->warn();. $this->debug(“Display login dialog box”);. $template->set_file(‘fh’, $LOGIN_TEMPLATE);. $template->set_block(‘fh’, “mainBlock”);. $template->set_var(‘SELF_PATH’, $PHP_SELF);. $template->set_var(‘ATTEMPT’,. $this->getSessionField(“SESSION_ATTEMPTS”));. $template->set_var(‘TODAY’, date(“M-d-Y h:i:s a”));. $template->set_var(‘TODAY_TS’, time());. $template->set_var(‘USERNAME’, $email);. $template->set_var(‘REDIRECT_URL’, $url);. $template->set_var(‘FORGOTTEN_PASSWORD_APP’, $FORGOTTEN_PASSWORD_APP);. $template->parse(“fh”, “mainBlock”);. $template->set_var(‘BASE_URL’, sprintf(“%s”,$this->base_url));. $template->pparse(“output”, “fh”);. $this->debug(“Setting user id to $uid”);. $this->setUID($uid);. ‘app_name’ =>. ‘app_version’ =>. ‘app_type’...

Secure PHP Development- P36

tailieu.vn

Before you can use the login and logout applications, you need to create the central authentication database and then add a user to it. $AUTH_DB_TYPE = ‘mysql’;. $AUTH_DB_HOST = ‘localhost’;. $AUTH_DB_NAME = ‘auth’;. $AUTH_DB_TBL = ‘users’;. $AUTH_DB_USERNAME = ‘root’;. $AUTH_DB_PASSWD = ‘foobar’;. For our example, I assume that you’re using the given sample values for $AUTH_DB_TYPE , $AUTH_DB_HOST. $AUTH_DB_NAME ,...

Secure PHP Development- P37

tailieu.vn

Listing 5-12 shows libsession_handler.php which implements all these functions.. Listing 5-12: lib.session_handler.php. require_once(‘constants.php’);. require_once(‘class.DBI.php’);. require_once ‘DB.php’;. $SESS_LIFE = get_cfg_var(“session.gc_maxlifetime”);. function sess_close. function sess_read($key). sess_gc() methods use a DBI object from our class.DBI.php class to implement database-based session management. Place the lib.session_handler.php in the framework directory. For example, if you’re keeping the class.PHPApplication.php in the. lib.session_handler.ph p in the same directory.....

Secure PHP Development- P38

tailieu.vn

Central User Management System. Designing a user management system for the central authentication system. Implementing a user management system. Using the applications developed in this chapter you will be able to manage user accounts that are stored in the central authentication database created in the previous chapter.. First, let’s define the functionality requirements for the user management system.. The user...

Secure PHP Development- P39

tailieu.vn

$this->user_tbl = $AUTH_DB_TBL;. $this->user_activity_log = $ACTIVITY_LOG_TBL;. $this->dbi = $dbi;. $this->minmum_username_size = $MIN_USERNAME_SIZE;. $this->minmum_pasword_size = $MIN_PASSWORD_SIZE;. $this->USER_ID = $uid;. //$this->debugger = $debugger;. $this->user_tbl_fields = array(‘EMAIL’ =>. $this->is_user = $this->getUserInfo();. $this->is_user = FALSE;. return $this->is_user;. return $this->USER_ID;. $stmt = “SELECT USER_ID FROM $this->user_tbl WHERE EMAIL = ‘$name’”;. $result = $this->dbi->query($stmt);. return $row->USER_ID;. return (isset($this->USER_ID. $this->USER_ID : NULL;. return (isset($this->EMAIL. $this->EMAIL : NULL;....