[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 init_sanitize.php

Zen Cart 源代码 init_sanitize.php




下载文件

文件名: init_sanitize.php
文件类型: PHP文件
文件大小: 4.51 KiB
MD5: 814a8f50e369f3f0086a2d1f6b512f58

init_sanitize.php - 关闭高亮
  1. <?php
  2. /**
  3.  * sanitize the GET parameters
  4.  * see {@link  http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem wikitutorials} for more details.
  5.  *
  6.  * @package initSystem
  7.  * @copyright Copyright 2003-2010 Zen Cart Development Team
  8.  * @copyright Portions Copyright 2003 osCommerce
  9.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  10.  * @version $Id: init_sanitize.php 17600 2010-09-22 00:45:20Z drbyte $
  11.  * @todo move the array process to security class
  12.  */
  13.  
  14.   if (!defined('IS_ADMIN_FLAG')) {
  15.     die('Illegal Access');
  16.   }
  17.   if (isset($_GET['typefilter'])) $_GET['typefilter'] = preg_replace('/[^0-9a-zA-Z_-]/', '', $_GET['typefilter']);
  18.   if (isset($_GET['products_id'])) $_GET['products_id'] = preg_replace('/[^0-9a-f:]/', '', $_GET['products_id']);
  19.   if (isset($_GET['manufacturers_id'])) $_GET['manufacturers_id'] = preg_replace('/[^0-9]/', '', $_GET['manufacturers_id']);
  20.   if (isset($_GET['categories_id'])) $_GET['categories_id'] = preg_replace('/[^0-9]/', '', $_GET['categories_id']);
  21.   if (isset($_GET['cPath'])) $_GET['cPath'] = preg_replace('/[^0-9_]/', '', $_GET['cPath']);
  22.   if (isset($_GET['main_page'])) $_GET['main_page'] = preg_replace('/[^0-9a-zA-Z_]/', '', $_GET['main_page']);
  23.   if (isset($_GET['sort'])) $_GET['sort'] = preg_replace('/[^0-9a-zA-Z]/', '', $_GET['sort']);
  24. /**
  25.  * process all $_GET terms
  26.  */
  27.   $strictReplace = '[<>\']';
  28.  $unStrictReplace = '[<>]';
  29.  if (isset($_GET) && count($_GET) > 0) {
  30.    foreach($_GET as $key=>$value){
  31.      if(is_array($value)){
  32.        foreach($value as $key2 => $val2){
  33.          if ($key2 == 'keyword') {
  34.            $_GET[$key][$key2] = preg_replace('/'.$unStrictReplace.'/', '', $val2);
  35.          } else {
  36.            $_GET[$key][$key2] = preg_replace('/'.$strictReplace.'/', '', $val2);
  37.          }
  38.          unset($GLOBALS[$key]);
  39.        }
  40.      } else {
  41.        if ($key == 'keyword') {
  42.          $_GET[$key] = preg_replace('/'.$unStrictReplace.'/', '', $value);
  43.        } else {
  44.          $_GET[$key] = preg_replace('/'.$strictReplace.'/', '', $value);
  45.        }
  46.        unset($GLOBALS[$key]);
  47.      }
  48.    }
  49.  }
  50. /**
  51. * process all $_POST terms
  52. * @todo move the array process to security class
  53. */
  54.  if (isset($_POST) && count($_POST) > 0) {
  55.    foreach($_POST as $key=>$value){
  56.      if(is_array($value)){
  57.        foreach($value as $key2 => $val2){
  58.          unset($GLOBALS[$key]);
  59.        }
  60.      } else {
  61.        unset($GLOBALS[$key]);
  62.      }
  63.    }
  64.  }
  65. /**
  66. * process all $_COOKIE terms
  67. */
  68.  if (isset($_COOKIE) && count($_COOKIE) > 0) {
  69.    foreach($_COOKIE as $key=>$value){
  70.      if(is_array($value)){
  71.        foreach($value as $key2 => $val2){
  72.          unset($GLOBALS[$key]);
  73.        }
  74.      } else {
  75.        unset($GLOBALS[$key]);
  76.      }
  77.    }
  78.  }
  79. /**
  80. * process all $_SESSION terms
  81. */
  82.  if (isset($_SESSION) && count($_SESSION) > 0) {
  83.    foreach($_SESSION as $key=>$value){
  84.      if(is_array($value)){
  85.        foreach($value as $key2 => $val2){
  86.          unset($GLOBALS[$key]);
  87.        }
  88.      } else {
  89.        unset($GLOBALS[$key]);
  90.      }
  91.    }
  92.  }
  93. /**
  94. * sanitize $_SERVER vars
  95. */
  96.  $_SERVER['REMOTE_ADDR'] = preg_replace('/[^0-9.%]/', '', $_SERVER['REMOTE_ADDR']);
  97.  
  98.  
  99. /**
  100. * validate products_id for search engines and bookmarks, etc.
  101. */
  102.  if (isset($_GET['products_id']) && isset($_SESSION['check_valid']) &&  $_SESSION['check_valid'] != 'false') {
  103.    $check_valid = zen_products_id_valid($_GET['products_id']);
  104.    if (!$check_valid) {
  105.      $_GET['main_page'] = zen_get_info_page($_GET['products_id']);
  106.      /**
  107.       * do not recheck redirect
  108.       */
  109.      $_SESSION['check_valid'] = 'false';
  110.      zen_redirect(zen_href_link($_GET['main_page'], 'products_id=' . $_GET['products_id']));
  111.    }
  112.  } else {
  113.    $_SESSION['check_valid'] = 'true';
  114.  }
  115. /**
  116. * We do some checks here to ensure $_GET['main_page'] has a sane value
  117. */
  118.  if (!isset($_GET['main_page']) || !zen_not_null($_GET['main_page'])) $_GET['main_page'] = 'index';
  119.  
  120.  if (!is_dir(DIR_WS_MODULES .  'pages/' . $_GET['main_page'])) {
  121.    if (MISSING_PAGE_CHECK == 'On' || MISSING_PAGE_CHECK == 'true') {
  122.      $_GET['main_page'] = 'index';
  123.    } elseif (MISSING_PAGE_CHECK == 'Page Not Found') {
  124.      header('HTTP/1.1 404 Not Found');
  125.      $_GET['main_page'] = 'page_not_found';
  126.    }
  127.  }
  128.  $current_page = $_GET['main_page'];
  129.  $current_page_base = $current_page;
  130.  $code_page_directory = DIR_WS_MODULES . 'pages/' . $current_page_base;
  131.  $page_directory = $code_page_directory;
  132.  
  133.