473,387 Members | 1,520 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,387 software developers and data experts.

When $GLOBALS fails..?? help

[PHP]
// CLIENT GLOBAL FUNCTION TO PARSE $_SESSION IF 'tempIDArray' IS SET
function parseTempIDArraySession() {
$tempIDArray = $_SESSION['tempIDArray'];
$_GET = $_SESSION[$_GET['tempID']]; // RESET $_GET WITH SESSION ARRAY
get_to_post(); // $_POST = $_GET
foreach ($tempIDArray as $tempID) unset($_SESSION[$tempID]);
print_r("POST: "); print_r($_POST); print_r("<P>");
extract($_POST, EXTR_SKIP);
foreach ($_POST as $key => $val) $GLOBALS[$key] = $val;
unset($_SESSION['tempIDArray']);
}
[/PHP]

This function will take everything out of $_SESSION[$tempID] and put
it into $_GET and then into $_POST. Then it will take everything out
of $_POST and make everything global whether register_globals is on or
off.

It doesn't work, surprise surprise.

In fact, all that doesn't work is the part whereby everything that
eventually winds up in $_POST is never global. Once you leave the
function all the variables vanish.

I am having to do this elaborate methodology because I have a
requirement to do a file/database action upon a query string while
keeping the query string secure; therefore, the key=val pairs normally
found in the query string are in a $_SESSION variable. So ultimately
I have to extract everything from that session variable and put it to
an autoglobal that my server-side validation and action classes can
use: $_POST (it *only* uses $_POST and no other autoglobal!). I can
actually get it so that it reads $_POST, but I need to get the global
value for each key in $_POST available once again because of the fact
that a class method must have at least one value: $refAction, and
$GLOBALS['refAction'] does not even work!

Phil
Jul 17 '05 #1
3 1707
Phil Powell wrote:
[PHP]
// CLIENT GLOBAL FUNCTION TO PARSE $_SESSION IF 'tempIDArray' IS SET
function parseTempIDArraySession() {
$tempIDArray = $_SESSION['tempIDArray'];
$_GET = $_SESSION[$_GET['tempID']]; // RESET $_GET WITH SESSION ARRAY
get_to_post(); // $_POST = $_GET
foreach ($tempIDArray as $tempID) unset($_SESSION[$tempID]);
print_r("POST: "); print_r($_POST); print_r("<P>");
extract($_POST, EXTR_SKIP);
foreach ($_POST as $key => $val) $GLOBALS[$key] = $val;
unset($_SESSION['tempIDArray']);
}
[/PHP]


I am not even going to try to guess why you are doing this. Have a
look at the 'import_request_variables'
(http://www.php.net/manual/en/functio...-variables.php)
function.

/Marcin
Jul 17 '05 #2
solved it by the simplest means possible. Just added
"refAction=$refAction" to the query string and that was it.

Never knew about import_request_variables() but that is a good
function to study.

Thanx
Phil

Marcin Dobrucki <Ma*************@TAKETHISAWAY.nokia.com> wrote in message news:<cp*******************@news2.nokia.com>...
Phil Powell wrote:
[PHP]
// CLIENT GLOBAL FUNCTION TO PARSE $_SESSION IF 'tempIDArray' IS SET
function parseTempIDArraySession() {
$tempIDArray = $_SESSION['tempIDArray'];
$_GET = $_SESSION[$_GET['tempID']]; // RESET $_GET WITH SESSION ARRAY
get_to_post(); // $_POST = $_GET
foreach ($tempIDArray as $tempID) unset($_SESSION[$tempID]);
print_r("POST: "); print_r($_POST); print_r("<P>");
extract($_POST, EXTR_SKIP);
foreach ($_POST as $key => $val) $GLOBALS[$key] = $val;
unset($_SESSION['tempIDArray']);
}
[/PHP]


I am not even going to try to guess why you are doing this. Have a
look at the 'import_request_variables'
(http://www.php.net/manual/en/functio...-variables.php)
function.

/Marcin

Jul 17 '05 #3
Phil Powell wrote:
solved it by the simplest means possible. Just added
"refAction=$refAction" to the query string and that was it.

Never knew about import_request_variables() but that is a good
function to study.


You may also want to take a look at this:
http://www.koivi.com/manual-php-globals/

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #4

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...
0
by: Berteun Damman | last post by:
Hello, First I was trying to get PyOSD, but as soon as I did `import pyosd' Python received a SIGABRT. Then I wrote my own module, which looks like: #include <Python.h> static PyMethodDef...
1
by: Craig Ringer | last post by:
Hi folks I'm a bit of a newbie here, though I've tried to appropriately research this issue before posting. I've found a lot of questions, a few answers that don't really answer quite what I'm...
8
by: Michael Wild | last post by:
Hi all I'm not quite new to PHP, but also not very proficient in its use, so please excuse me if my question is a FAQ. Perhaps I didn't know the right terms, but google wasn't my friend this...
15
by: Dilip | last post by:
The subject is a bit misleading because I really can't figure out what the following code snippet is doing and would appreciate any help in deciphering it. I mean I can understand code-wise what...
2
by: xml0x1a | last post by:
How do I use exec? Python 2.4.3 ---- from math import * G = 1 def d(): L = 1 exec "def f(x): return L + log(G) " in globals(), locals() f(1)
1
by: joeedh | last post by:
Hi I'm getting extremely odd behavior. First of all, why isn't PyEval_EvalCode documented anywhere? Anyway, I'm working on blender's python integration (it embeds python, as opposed to python...
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: Gordon Fraser | last post by:
Hi, Am Dienstag, den 07.10.2008, 15:30 +0100 schrieb Orestis Markou: That seems to work, thanks. Still trying to make sense of the manual for eval, as it says if the passed globals dict lacks...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.