1. Trang chủ
  2. » Công Nghệ Thông Tin

Secure PHP Development- P26 pps

5 199 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

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( 96 Part II: Developing Intranet Solutions 07 549669 ch04.qxd 4/4/03 9:24 AM Page 96 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 Chapter 4: Architecture of an Intranet Application 97 07 549669 ch04.qxd 4/4/03 9:24 AM Page 97 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; 98 Part II: Developing Intranet Solutions 07 549669 ch04.qxd 4/4/03 9:24 AM Page 98 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 Chapter 4: Architecture of an Intranet Application 99 07 549669 ch04.qxd 4/4/03 9:24 AM Page 99 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 ‘<pre>’; print_r($a); echo ‘</pre>’; } else { print_r($a); } } function dump() { if (strstr($this->get_type(), ‘WEB’)) 100 Part II: Developing Intranet Solutions 07 549669 ch04.qxd 4/4/03 9:24 AM Page 100

Ngày đăng: 07/07/2014, 07:20

Xem thêm: Secure PHP Development- P26 pps

Mục lục

    Is This Book for You?

    How This Book Is Organized

    Tell Us What You Think

    Contents at a Glance

    Chapter 1: Features of Practical PHP Applications

    Features of a Practical PHP Application

    Employing the Features in Applications

    Chapter 2: Understanding and Avoiding Security Risks

    Identifying the Sources of Risk

    Not Revealing Sensitive Information

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN