Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Баг проявляется при включенном magic_quotes_gpc
class MagicWrapper extends ArrayObject {
protected $data = array();
public function __construct(&$data) {
if(get_magic_quotes_gpc()) {
$this->data = $data;
$data = $this;
}
}
public function offsetGet($name) {
return $this->strip($this->data[$name]);
}
public function strip($data) {
if(is_array($data)) {
return array_map(array($this, 'strip'), $data);
} elseif(is_string($data)) {
return stripslashes($data);
} else {
return $data;
}
}
}
new MagicWrapper($_GET);
new MagicWrapper($_POST);
$this->data = $data;
parent::__construct($data);
return $this->data[$name];
$this->strip(parent::offsetGet($name));
function noMagic()
{
if (get_magic_quotes_gpc())
{
if (!empty($_GET)) $_GET = stripMagicQuotes($_GET);
if (!empty($_POST)) $_POST = stripMagicQuotes($_POST);
if (!empty($_REQUEST)) $_REQUEST = stripMagicQuotes($_REQUEST);
if (!empty($_COOKIE)) $_COOKIE = stripMagicQuotes($_COOKIE);
}
}
function stripMagicQuotes($arr)
{
foreach ($arr as $k => $v) {
$arr[$k] = is_array($v) ? stripMagicQuotes($v) : stripslashes($v);
}
return $arr;
}
noMagic();
Прекращено распространение PHP 5.2.7