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

Secure PHP Development- P27 pps

5 205 0

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

THÔNG TIN TÀI LIỆU

{ echo ‘<pre>’; print_r($this); echo ‘</pre>’; } else { print_r($this); } } function checkRequiredFields($fieldType = null, $fieldData = null, $errorCode = null) { $err = array(); while(list($field, $func) = each ($fieldType)) { $ok = $this->$func($fieldData[$field]); if (! $ok ) { $this->alert($errorCode{$field}); } } return $err; } function number($num = null) { if (is_array($num)) { foreach ($num as $i) { if (! is_numeric($i)) { return 0; } } return 1; Continued Chapter 4: Architecture of an Intranet Application 101 07 549669 ch04.qxd 4/4/03 9:24 AM Page 101 Listing 4-4 (Continued) } else if (is_numeric($num)) { return 1; } else { return 0; } } function name($name = null) { if (!strlen($name) || is_numeric($name)) { return 0; } else { return 1; } } function email($email = null) { if (strlen($email) < 5 || ! strpos($email,’’)) { return 0; } else { return 1; } } function currency($amount = null) { return 1; } function month($mm = null) { if ($mm >=1 && $mm <=12) { return 1; } else { return 0; } } 102 Part II: Developing Intranet Solutions 07 549669 ch04.qxd 4/4/03 9:24 AM Page 102 // ASIF what is thie method doing in this class??? function comboOption($optVal = null) { if ($optVal != 0) { return 1; }else { return 0; } } function day($day = null) { if ($day >=1 && $day <=31) { return 1; } else { return 0; } } function year($year = null) { return ($this->number($year)); } function one_zero_flag($flag = null) { if ($flag == 1 || $flag == 0) { return 1; } else { return 1; } } function plain_text($text = null) { return 1; } Continued Chapter 4: Architecture of an Intranet Application 103 07 549669 ch04.qxd 4/4/03 9:24 AM Page 103 Listing 4-4 (Continued) function debug_array($hash = null) { $this->debugger->debug_array($hash); } function writeln($msg) { // print global $WWW_NEWLINE; global $NEWLINE; echo $msg ,(strstr($this->app_type, ‘WEB’)) ? $WWW_NEWLINE : $NEWLINE; } function show_status($msg = null,$returnURL = null) { global $STATUS_TEMPLATE; $template = new Template($this->template_dir); $template->set_file(‘fh’, $STATUS_TEMPLATE); $template->set_block(‘fh’, ‘mainBlock’, ‘mblock’); $template->set_var(‘STATUS_MESSAGE’, $msg); if (!preg_match(‘/^http:/’, $returnURL) && (!preg_match(‘/^\//’, $returnURL))) { $appPath = sprintf(“%s/%s”, $this->app_path, $returnURL); } else { $appPath = $returnURL; } $template->set_var(‘RETURN_URL’, $appPath); $template->set_var(‘BASE_URL’, $this->base_url); $template->parse(‘mblock’, ‘mainBlock’); $template->pparse(‘output’, ‘fh’); } function set_escapedVar($hash) { while(list($key, $value) = each ($hash)) { 104 Part II: Developing Intranet Solutions 07 549669 ch04.qxd 4/4/03 9:24 AM Page 104 $this->escapedVarHash{$key} = preg_replace(“/\s/”,”+”,$value); } } function get_escapedVar($key) { return $this->escapedVarHash{$key}; } function setUID($uid = null) { $this->user_id = $uid; } function getUID() { return $this->user_id; } //To Kabir: I added this Asif function getUserName() { return $this->user_name; } function emptyError($field, $errCode) { if (empty($field)) { $this->alert($errCode); } } function getRequestField($field, $default = null) { return (! empty($_REQUEST[$field] )) ? $_REQUEST[$field] : $default; } function getSessionField($field, $default = null) { return (! empty($_SESSION[$field] )) ? $_SESSION[$field] : $default; } Continued Chapter 4: Architecture of an Intranet Application 105 07 549669 ch04.qxd 4/4/03 9:24 AM Page 105

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

Xem thêm: Secure PHP Development- P27 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