472,958 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Register_globals ON --> OFF

All,
I have some code that works just fine when register_globals is on, however,
for obvious reasons, I am trying to rework the code so that I can disable
register_globals.

I have set my error_reporting to E_ALL, and am logging it to a file so that
I can review it.
Are there any "steps" to take in successfully updating the code ? Or do I
just run each and every page looking for errors ?

Any pointers would be appreciated.
Thanks.
Jul 17 '05 #1
1 1534
Here's an utterly insane way of fixing globals:

<?

function fix_globals($errno, $errstr, $errfile, $errline) {
$code = file($errfile);
$line = $code[$errline - 1];
if(preg_match('/Undefined variable:\s+(\w+)/', $errstr, $matches)) {
$varname =$matches[1];
if(array_key_exists($varname, $_GET)) {
$new_line = preg_replace("/\\\$$varname/", "\$_GET['$varname']", $line);
}
else if(array_key_exists($varname, $_POST)) {
$new_line = preg_replace("/\\\$$varname(?!\w)/", "\$_POST['$varname']",
$line);
}
else if(array_key_exists($varname, $_SERVER)) {
$new_line = preg_replace("/\\\$$varname(?!\w)/", "\$_SERVER['$varname']",
$line);
}
}
if($new_line) {
$code[$errline - 1] = $new_line;
if($f = fopen($errfile, "w")) {
fwrite($f, implode('', $code));
fclose($f);
header("HTTP/1.0 307 Temporary Redirect");
header("Location:
http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
exit(0);
}
}
}

ob_start();
set_error_handler('fix_globals');

.....

?>

Yup, the code fixes itself!

Uzytkownik "News" <ne**@news.com> napisal w wiadomosci
news:10*************@corp.supernews.com...
All,
I have some code that works just fine when register_globals is on, however, for obvious reasons, I am trying to rework the code so that I can disable
register_globals.

I have set my error_reporting to E_ALL, and am logging it to a file so that I can review it.
Are there any "steps" to take in successfully updating the code ? Or do I
just run each and every page looking for errors ?

Any pointers would be appreciated.
Thanks.

Jul 17 '05 #2

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

Similar topics

1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
0
by: Arne Schirmacher | last post by:
I want to display a MySQL database field that can contain HTML markup. If I use <esql:get-string> then I get all of the database field, but all tags are escaped which is not what I want. If I use...
34
by: Mark Moore | last post by:
It looks like there's a pretty serious CSS bug in IE6 (v6.0.2800.1106). The HTML below is validated STRICT HTML 4.01 and renders as I would expect in Opera, FrontPage, and Netscape. For some...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
2
by: bissatch | last post by:
Hi, I am currently writing a simple PHP program that uses an XML file to output rows for a 'Whats New' page. Once written, I will only require updating the XML file and any pages that use the...
0
by: vdex42 | last post by:
Apologies if this has been asked before, but I haven't been able to find the answer to this yet: My problem is that .NET will not allow me to insert escaped '>' characters (i.e. &gt;) within the...
2
by: santaji | last post by:
I am getting xml string in request attribute in following format &lt;files&gt; &lt;file&gt; &lt;filename&gt;somefile.ext&lt;/filename&gt; &lt;/file&gt; &lt;files&gt; the above string I want to convert to tags. expected...
1
by: VaidehiPawar | last post by:
I am a beginner level in xml..my output page does not convert &gt &lt it shows something like this " &lt;b&gt;Location.&lt;/b&gt;&lt;br /&gt; &lt;UL&gt;&lt;LI&gt;Park Central New York " can anyone help? here is my code ...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.