Created
April 19, 2012 01:02
-
-
Save mgng/2417664 to your computer and use it in GitHub Desktop.
AtpagesInit.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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