配置 magic_quotes_gpc = off 无效的解决方法
2013-08-07 18:33
344 查看
1.修改PHP配置文件
通过 php.ini 文件把这些选项设为 Off 。
; Magic quotes
;
; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = Off
; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off
; Use Sybase-style magic quotes (escape ‘ with ” instead of ’).
magic_quotes_sybase = Off
2.APACHE的设置文件
修改网站目录下的 .htaccess
php_flag magic_quotes_gpc Off
有些主机空间可能修改 .htaccess
没有效果,但是能修改php.ini
却也不能生效。比如我用的这个国外空间就是,空间商给每个空间都分配了一个 php.ini
和 .htaccess 而上述方式修改都无效,后来网络查了下,修改
php.ini 后再用 .htaccess
引入目录下的 php.ini
即可,代码(在哪??)如下,绝对路径是
php.ini 所在的路径
suPHP_ConfigPath 绝对路径
3.PHP全局过滤代码
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map(’stripslashes_deep’, $value) :
stripslashes($value);
return $value;
}
$_POST = array_map(’stripslashes_deep’, $_POST);
$_GET = array_map(’stripslashes_deep’, $_GET);
$_COOKIE = array_map(’stripslashes_deep’, $_COOKIE);
}
代码就是这样。最好使用,前2种这样能能提升程序效率,实在不行再考虑最后一种
最后一种可移植性好,但效率较低
通过 php.ini 文件把这些选项设为 Off 。
; Magic quotes
;
; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = Off
; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off
; Use Sybase-style magic quotes (escape ‘ with ” instead of ’).
magic_quotes_sybase = Off
2.APACHE的设置文件
修改网站目录下的 .htaccess
php_flag magic_quotes_gpc Off
有些主机空间可能修改 .htaccess
没有效果,但是能修改php.ini
却也不能生效。比如我用的这个国外空间就是,空间商给每个空间都分配了一个 php.ini
和 .htaccess 而上述方式修改都无效,后来网络查了下,修改
php.ini 后再用 .htaccess
引入目录下的 php.ini
即可,代码(在哪??)如下,绝对路径是
php.ini 所在的路径
suPHP_ConfigPath 绝对路径
3.PHP全局过滤代码
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map(’stripslashes_deep’, $value) :
stripslashes($value);
return $value;
}
$_POST = array_map(’stripslashes_deep’, $_POST);
$_GET = array_map(’stripslashes_deep’, $_GET);
$_COOKIE = array_map(’stripslashes_deep’, $_COOKIE);
}
代码就是这样。最好使用,前2种这样能能提升程序效率,实在不行再考虑最后一种
最后一种可移植性好,但效率较低
相关文章推荐
- joomla3.1安装不通过Magic Quotes GPC解决方法
- wordpress 安装(亲身经历)& 出现“Fatal error: Call to undefined function get_magic_quotes_gpc()”之后的解决方法
- Linux:Linux下网卡配置无效的解决方法
- 关于php的register_globals和magic_quotes_gpc参数配置
- php中magic_quotes_gpc的作用 解决日文数据提交后多出来反斜杠的问题
- php set_magic_quotes_runtime() 函数过时解决方法
- form 表单字段 autocomplete 设置为off 后仍然无效的解决方法
- Struts2拦截器属性excludeMethods、includeMethods配置无效之解决方法
- 解决Function get_magic_quotes_gpc() is deprecated
- PHP magic_quotes_gpc的详细使用方法
- magic_quotes_gpc,magic_quotes_runtime,magic_quotes_sybase 三个方法的区别
- 用PHP函数解决SQL injection(magic_quotes_gpc/addslashes)
- 服务器magic_quotes_gpc的方法
- Response.Redirect无效的解决方法(ajax配置文件)
- ubuntu配置全局环境变量后开新shell变量无效的解决方法
- PHP magic_quotes_gpc的详细使用方法
- PHP中magic_quotes_gpc动态关闭无效的问题
- PHP magic_quotes_gpc的详细使用方法
- PHP magic_quotes_gpc的详细使用方法
- PHP magic_quotes_gpc的详细使用方法