function bstripslashes($string) { if (empty($string)) { return $string; } if (is_array($string)) { foreach ($string as $key => $val) { $string[$key] = bstripslashes($val); } } else { $string = stripslashes($string); } return $string; }
private function _init_input() { if (isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_COOKIE['GLOBALS']) || isset($_FILES['GLOBALS'])) { jam_error::system_error('您当前的访问请求当中含有非法字符'); } if (MAGIC_QUOTES_GPC) { $_GET = bstripslashes($_GET); $_POST = bstripslashes($_POST); $_COOKIE = bstripslashes($_COOKIE); } $prelength = strlen($this->config['cookie']['cookiepre']); foreach ($_COOKIE as $key => $val) { //cookie 前缀相等说明是本站的cookie if (substr($key, 0, $prelength) == $this->config['cookie']['cookiepre']) { $this->b['cookie'][substr($key, $prelength)] = $val; } } if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST)) { //合并 get 和 post数据好读取 $_GET = array_merge($_GET, $_POST); } if (isset($_GET['page'])) { //若设置页数 $_GET['page'] = rawurlencode($_GET['page']); //rawurlencode 空格是 '%20', //urlencode 空格是 '+' } foreach ($_GET as $k => $v) { $this->b[$k] = baddslashes($v); } $this->b['ajax'] = $_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' || $_SERVER['REQUEST_METHOD'] == 'POST' ? 1 : 0; $this->b['page'] = empty($_GET['page']) ? 1 : max(1, intval($_GET['page'])); }