Jump to content

ini_set not seeming to work on gpc


Ninjakreborn

Recommended Posts

I wanted to always make those damn magic quote's off I did this in my config file,
ini_set("magic_quotes_gpc", 0);
that has been there, but I just noticed, it was running addslashes for some reason.  I didn't even use mysql real escape string but it was addingslashes to it anyway, and I am having to stripslashes, I was just wanting to remove those but it's not working
ini_set("magic_quotes_gpc", 0); that is what I used?
Link to comment
https://forums.phpfreaks.com/topic/25825-ini_set-not-seeming-to-work-on-gpc/
Share on other sites

I don't think you can do that inside PHP, but you can do this: [code]<?php
if(get_magic_quotes_gpc() == true)
{
foreach(array("_POST","_GET","_COOKIE","_SESSION","_REQUEST") as $var)
{
$GLOBALS[$var] = array_map("stripslashes",$GLOBALS[$var]);
}
}
?>[/code]
You cannot use ini_set to turn off magic_quotes_gpc

magic_quotes_gpc can only be turned off in either of the following:
php.ini
.htaccess
httpd.conf

ini_set can only be used to change certain settings values in the php.ini. It cannot change every setting in the php.ini

You can only disable magic_quotes_runtime in your PHP scripta using set_magic_quotes_runtime(0). However magic_quotes_runtime is not the same as magic_quotes_gpc. magaic_quotes_gpc escapes quotes in GET/POST/Cookie data. magic_quotes_runtime escapes data from external sources such as databases, text files, functions etc.

If you cannot use .htaccess file then you'll need to test for magic_quotes_gpc and if its enabled you'll have to skip the part where you addslashes, or you could use stripslashes and then do whatever you do for example:
[code=php:0]function makeSafe($data)
{
    if(get_magic_quotes_gpc())
    {
        // magic_quotes_gpc is enabled
        $data = stripslashes($data);
    }

    // now you do whatever you do to escape quotes/make data safe

  return $data;
}[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.