From ec4f08afcc828d856afa16ffa0f8abca1d02c4da Mon Sep 17 00:00:00 2001 From: Xuefer Date: Wed, 20 Jun 2007 02:24:41 +0000 Subject: [PATCH] fixed #104, magic quotes compatibility git-svn-id: svn://svn.lighttpd.net/xcache/trunk@418 c26eb9a1-5813-0410-bd6c-c2e55f420ca7 --- admin/common.php | 21 +++++++++++++++++++++ coverager/common.php | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/admin/common.php b/admin/common.php index cc077bd..127f8ac 100644 --- a/admin/common.php +++ b/admin/common.php @@ -74,10 +74,31 @@ function _T($str) return $str; } +function stripaddslashes_array($value, $mqs = false) +{ + if (is_array($value)) { + foreach($value as $k => $v) { + $value[$k] = stripaddslashes_array($v, $mqs); + } + } + else if(is_string($value)) { + $value = $mqs ? str_replace('\'\'', '\'', $value) : stripslashes($value); + } + return $value; +} + error_reporting(E_ALL); ini_set('display_errors', 'On'); define('REQUEST_TIME', time()); +if (get_magic_quotes_gpc()) { + $mqs = (bool) ini_get('magic_quotes_sybase'); + $_GET = stripaddslashes_array($_GET, $mqs); + $_POST = stripaddslashes_array($_POST, $mqs); + $_REQUEST = stripaddslashes_array($_REQUEST, $mqs); +} +ini_set('magic_quotes_runtime', '0'); + $charset = "UTF-8"; if (file_exists("./config.php")) { include("./config.php"); diff --git a/coverager/common.php b/coverager/common.php index cc077bd..127f8ac 100644 --- a/coverager/common.php +++ b/coverager/common.php @@ -74,10 +74,31 @@ function _T($str) return $str; } +function stripaddslashes_array($value, $mqs = false) +{ + if (is_array($value)) { + foreach($value as $k => $v) { + $value[$k] = stripaddslashes_array($v, $mqs); + } + } + else if(is_string($value)) { + $value = $mqs ? str_replace('\'\'', '\'', $value) : stripslashes($value); + } + return $value; +} + error_reporting(E_ALL); ini_set('display_errors', 'On'); define('REQUEST_TIME', time()); +if (get_magic_quotes_gpc()) { + $mqs = (bool) ini_get('magic_quotes_sybase'); + $_GET = stripaddslashes_array($_GET, $mqs); + $_POST = stripaddslashes_array($_POST, $mqs); + $_REQUEST = stripaddslashes_array($_REQUEST, $mqs); +} +ini_set('magic_quotes_runtime', '0'); + $charset = "UTF-8"; if (file_exists("./config.php")) { include("./config.php");