Home >php教程 >php手册 >php 有效安全过滤get,posd,cookie

php 有效安全过滤get,posd,cookie

WBOY
WBOYOriginal
2016-06-13 09:54:371047browse

php 有效安全过滤get,posd,cookie

php 有效安全过滤get,posd,cookie
session_set_cookie_params(0, COOKIE_PATH, COOKIE_DOMAIN);

if($_REQUEST)
{
 if(MAGIC_QUOTES_GPC)
 {
  $_REQUEST = new_stripslashes($_REQUEST);
  if($_COOKIE) $_COOKIE = new_stripslashes($_COOKIE);
 }
 else
 {
  $_POST = new_addslashes($_POST);
  $_GET = new_addslashes($_GET);
  $_COOKIE = new_addslashes($_COOKIE);
  @extract($_POST);
  @extract($_GET);
  @extract($_COOKIE);
 }
 if(!defined('IN_ADMIN')) $_REQUEST = filter_xss($_REQUEST, ALLOWED_HTMLTAGS);
 extract($db->escape($_REQUEST), EXTR_SKIP);
 if($_COOKIE) $db->escape($_COOKIE);
}
if(QUERY_STRING && strpos(QUERY_STRING, '=') === false && preg_match("/^(.*).(htm|html|shtm|shtml)$/", QUERY_STRING, $urlvar))
{
 parse_str(str_replace(array('/', '-', ' '), array('&', '=', ''), $urlvar[1]));
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn