intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Secure PHP Development- P26

Chia sẻ: Cong Thanh | Ngày: | Loại File: PDF | Số trang:5

69
lượt xem
5
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Secure PHP Development- P26: Welcome to Secure PHP Development: Building 50 Practical Applications. PHP has come a long way since its first incarnation as a Perl script. Now PHP is a powerful Web scripting language with object-oriented programming support. Slowly but steadily it has entered the non-Web scripting arena often reserved for Perl and other shell scripting languages. Arguably, PHP is one of the most popular Web platforms.

Chủ đề:
Lưu

Nội dung Text: Secure PHP Development- P26

  1. 96 Part II: Developing Intranet Solutions Listing 4-4 (Continued) $this->server = sprintf(“%s://%s%s”, $protocol, $this->getEnvironment(‘HTTP_HOST’), $port); $this->self_url = sprintf(“%s://%s%s%s”, $protocol, $this->getEnvironment(‘HTTP_HOST’), $port, $this->getEnvironment(‘REQUEST_URI’)); } function getServer() { return $this->server; } function terminate() { if (isset($this->dbi)) { if ($this->dbi->connected) { $this->dbi->disconnect(); } } //Asif Changed session_destroy(); exit; } function authorize($username = null) { // override this method return FALSE; } function set_error_handler() { // create error handler if (defined(“ERROR_HANDLER_LOADED”)) $this->errHandler = new ErrorHandler(
  2. Chapter 4: Architecture of an Intranet Application 97 array (‘name’ => $this->app_name)); } function getErrorMessage($code) { return $this->errHandler->error_message[$code]; } function show_popup($code) { return $this->errHandler->alert($code, 0); } function getMessage($code = null, $hash = null) { $msg = $this->messages[$this->language][$code]; if (! empty($hash)) { foreach ($hash as $key => $value) { $key = ‘/{‘ . $key . ‘}/’; $msg = preg_replace($key, $value, $msg); } } return $msg; } function alert($code = null, $flag = null) { return (defined(“ERROR_HANDLER_LOADED”)) ? $this->errHandler->alert($code, $flag) : false; } function buffer_debugging() { global $ON; if (defined(“DEBUGGER_LOADED”) && $this->debug_mode == $ON) { $this->debugger->set_buffer(); } } Continued
  3. 98 Part II: Developing Intranet Solutions Listing 4-4 (Continued) function dump_debuginfo() { global $ON; if (defined(“DEBUGGER_LOADED”) && $this->debug_mode == $ON) { $this->debugger->flush_buffer(); } } function debug($msg) { global $ON; if ($this->debug_mode == $ON) { $this->debugger->write($msg); } } function run() { // run the application $this->writeln(“You need to override this method.”); } function connect($db_url = null) { if (empty($db_url)) { $db_url = $this->app_db_url; } if (defined(‘DBI_LOADED’) && ! empty($this->app_db_url)) { $this->dbi = new DBI($db_url); return $this->dbi->connected; } return FALSE; } function disconnect() { $this->dbi->disconnect(); $this->dbi->connected = FALSE;
  4. Chapter 4: Architecture of an Intranet Application 99 return $this->dbi->connected; } function get_error_message($code = null) { return $this->errHandler->get_error_message($code); } function show_debugger_banner() { global $ON; if ($this->debug_mode == $ON) { $this->debugger->print_banner(); } } function get_version() { // return version return $this->app_version; } function get_name() { // return name return $this->app_name; } function get_type() { // return type return $this->app_type; } function set_error($err = null) { // set error condition if (isset($err)) { array_push($this->error, $err); $this->has_error = TRUE; Continued
  5. 100 Part II: Developing Intranet Solutions Listing 4-4 (Continued) return 1; } else { return 0; } } function has_error() { return $this->has_error; } function reset_error() { $this->has_error = FALSE; } function get_error() { // return error condition return array_pop($this->error); } function get_error_array() { return $this->error; } function dump_array($a) { if (strstr($this->get_type(), ‘WEB’)) { echo ‘’; print_r($a); echo ‘’; } else { print_r($a); } } function dump() { if (strstr($this->get_type(), ‘WEB’))
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2