Skip to content

Instantly share code, notes, and snippets.

@mgng
Created April 19, 2012 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgng/2417664 to your computer and use it in GitHub Desktop.
Save mgng/2417664 to your computer and use it in GitHub Desktop.
AtpagesInit.php
<?php
// AtpagesInit
class AtpagesInit {
public static function run() {
$_GET = self::_sanitizeNullChar($_GET);
$_POST = self::_sanitizeNullChar($_POST);
$_COOKIE = self::_sanitizeNullChar($_COOKIE);
if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() === 1 ) {
$_GET = self::_stripslashes($_GET);
$_POST = self::_stripslashes($_POST);
$_COOKIE = self::_stripslashes($_COOKIE);
}
return true;
}
// ヌルバイト削除
private static function _sanitizeNullChar($p) {
if ( is_array($p) ) {
return array_map( array(__CLASS__, '_sanitizeNullChar'), $p );
}
return str_replace(pack('x'),'',$p);
}
// magic_quotes_gpc ON 対策
private static function _stripslashes($p) {
if ( is_array($p) ) {
return array_map( array(__CLASS__, '_stripslashes'), $p );
}
return stripslashes($p);
}
}
AtpagesInit::run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment