473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

import_request_variables isn't importing my changes to my globals

The server I'm running my PHP on has "magic_quotes" turned on, so all
the input I get (from GET, POST, and cookies) is escaped with
backslashes. I don't want this (I handle my own escaping, and I need to
be able to work with unescaped strings), but I'm not allowed to change
the setting on the server, so I need to figure out a way to "undo"
magic quotes.

This code itself works...

function stripslashes_array($v) {
return is_array($v) ? array_map('stripslashes_array', $v) :
stripslashes($v);
}
if (get_magic_quotes_gpc()) {
foreach (array('POST', 'GET', 'REQUEST', 'COOKIE') as $gpc)
$GLOBALS["_$gpc"] = array_map('stripslashes_array',
$GLOBALS["_$gpc"]);
}

But my problem is that I then want to use import_request_variables to
bring any form data into the global variable space, and that's not
reflecting the changes I just made to the globals... in other words, if
after that code I say:

$foo = "GLOBALS["_GET"]["test"];
import_request_variables("gp", "in_");
$bar = $in_test;

and I submit the page with "test" set to a'b'c, then $foo will be a'b'c
while $bar will be a\'b\'c.

How do I get the stripslashed values into my global variables without
having to stripslash each one individually?

Jul 17 '05 #1
2 1918
The only way I know of that you *might* be able to turn off the
magic_quotes_gpc option (temporarily) would be to use the ini_set()
function. Or are you not allowed to use ini_set()? I'll just hope not.

If you can use it, at the start of the script simply put
ini_set('magic_quotes_gpc', '0')
and that should turn off magic_quotes for the purpose of processing
that page.

Hopefully that will work, if not then it seems like you'll have to do
it all the tedious way and stripslash each one.

Jul 17 '05 #2
ini_set doesn't work with magic_quotes, because by the time PHP starts
executing my script and sees that ini_set statement, it's already done
magic quotes on the input.

It's looking like this might be a bug in import_request_variables,
where it gets its data from some place other than $_GET and $_POST and
$_COOKIE.

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Frostillicus | last post by:
I'm trying to use array_multisort to sort by one of the dimensions of an array stored in $GLOBALS like this: array_multisort($GLOBALS, SORT_STRING, SORT_DESC); Each "row" in $GLOBALS contains...
1
by: Nathan Koren | last post by:
Greetings, I am trying to write a bit of secure code, and am having a lot of trouble with it. I'm using PHP 5 with register_globals turned off, and want to acquire some variables from a form. ...
0
by: OKB (not okblacke) | last post by:
I'm fooling around with some MUD server code, and I want to add a "reload" command that will let MUD wizards reload the server modules, so that changes to the MUD parser and such can be effected...
0
by: Mark English | last post by:
Basic problem: If there is a C-extension module in a package and it tries to import another python module in the same package without using the fully qualified path, the import fails. Config:...
4
by: jean-marc | last post by:
As an application programmer, I'm not well versed in the material aspects of computing (memory, cpu, bus and all). My understanding of imports in Python is such: the __main__ program is the center...
29
by: Natan | last post by:
When you create and aspx page, this is generated by default: using System; using System.Collections; using System.Collections.Specialized; using System.Configuration; using System.Text; using...
14
by: T. Crane | last post by:
Hi, When troubleshooting code that's saved in a text file, I often find that I want to make a change to it, re-save it, then reimport it. However, just typing import myTestCode doesn't...
1
by: cokofreedom | last post by:
if __name__ == '__main__': print "Globals (For Loop):" try: for i in globals(): print "\t%s" % i except RuntimeError: print "Only some globals() printed\n" else: print "All globals()...
0
by: norseman | last post by:
mercado mercado wrote: =================================== I started to import a module using its path and now see what you mean. Python is missing the concept: Programmer dictates what machine...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.