473,779 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding errors due to register globals?

I don't suppose anyone knows of a script/program to try and identify
where variables are used assuming register_global s is on? I'm trying to
fix an application and would rather not turn it on as there are several
applications on the server.

I'm thinking of something which can identify use of variables (right
hand side of assignments) before definition (left hand side of assignments).

Any pointers?
Jul 17 '05 #1
4 1861
Kevin Thorpe wrote:
I don't suppose anyone knows of a script/program to try and identify
where variables are used assuming register_global s is on? I'm trying to
fix an application and would rather not turn it on as there are several
applications on the server.

I'm thinking of something which can identify use of variables (right
hand side of assignments) before definition (left hand side of assignments).

Any pointers?


http://www.php.net/error_reporting

--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Jul 17 '05 #2
Pedro Graca wrote:
Kevin Thorpe wrote:
I don't suppose anyone knows of a script/program to try and identify
where variables are used assuming register_global s is on? I'm trying to
fix an application and would rather not turn it on as there are several
application s on the server.

I'm thinking of something which can identify use of variables (right
hand side of assignments) before definition (left hand side of assignments).

Any pointers?

http://www.php.net/error_reporting

Unfortunately that's only at runtime. I don't rely on default values for
variables and have turned on all the error checking but I still need to
read every line of code or perform a comprehensive test to execute every
line.

I was hoping someone had a script to assist. If php was compiled then
these errors would be caught at compile time.
Jul 17 '05 #3
Kevin Thorpe wrote:
Pedro Graca wrote:
Kevin Thorpe wrote:
Any pointers?


http://www.php.net/error_reporting


Unfortunately that's only at runtime. ...


There's no saying where a uninitialized variable can be used ...
It can be on the right side of an assignment; as a parameter to a
function call; on the left side of a test; ...

Good luck in finding a script that finds them all :)

You might want to try installing the scripts in a test directory and set
auto_prepend_fi le in that directory to a script that sets error_handler
to a function that logs all notices to a file (or database, or ...).

Make a few test runs, examine the log, and (manually) correct the
errors.
Skeleton auto_prepend_fi le

<?php
function Notice_Handler( $n, $d, $f, $l) {
if ($n == 8) {
// log $d, $f, and $l somewhere
}
}

set_error_handl er('Notice_Hand ler');
?>

--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Jul 17 '05 #4
> There's no saying where a uninitialized variable can be used ...
It can be on the right side of an assignment; as a parameter to a
function call; on the left side of a test; ...

Good luck in finding a script that finds them all :)
I know. Looking into it requires writing a full parser. I can do that
but is it really worth my time? php syntax is pretty complex with
embedded variables and such so it's a lot of work. Maybe I should do it
and make it GPL, but I'm not sure I have the time.
You might want to try installing the scripts in a test directory and set
auto_prepend_fi le in that directory to a script that sets error_handler
to a function that logs all notices to a file (or database, or ...).


That still requires a test script (or me) to exercise all the code. Lots
of work for a one-off intranet app.

People keep hitting this problem, it's a FAQ. I was just wishfully
thinking that it had been addressed. Are there any zend people listening?
Jul 17 '05 #5

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

Similar topics

1
4323
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would be better to promote better programming than rely on PHP to compensate for lazy programming?
7
3960
by: Paul Liversidge | last post by:
I'd like your opinions as to why I don't use something like this... A function that iterates through $_GET, $_POST, $_COOKIES and $_SESSION arrays and turn them back into conventional variables. I already have chunks of code at the top of some pages, particularly large forms that look something like this... $id = isset ($_GET) ? $_GET : ""; ....one line after another pulling the variable back from the array and
1
4580
by: Manu J | last post by:
Hi, i have a login script which makes use of sessions. Login script *********** session_start() ..... ..... ....
3
6169
by: Jeremy Shovan | last post by:
Does any one know if there is a way to check if register globals is on or off in a program. Thanks, Jeremy
3
6126
by: Jason | last post by:
hello, i am new to PHP, so go easy. I am using the examples in the book: PHP: Your Visual Blueprint For Creating Open Source, Server Side Content In the section where they talk about getting values from a form submission, the book says:
12
2684
by: kevin bailey | last post by:
this old script was written when register globals was 'on'. now i need to convert it to run on a server with a php 4.3.6 - do i just convert the relevant variables from $posted_variable to $_POST i realise that many of the variables are internal to the scrit so will not
1
1815
by: yawnmoth | last post by:
even though register globals is disabled by default, i'm currious as to how it and magic quotes interact. consider the following code: <? // assuming $_GET='"test"' and register globals enabled echo $var; ?> will the output be "test" or \"test\"?
21
1765
by: André | last post by:
Short version of what I am looking for: Given a class "public_class" which is instantiated a few times e.g. a = public_class() b = public_class() c = public_class() I would like to find out the name of the instances so that I could create a list of them e.g.
2
2594
by: Kavitha Rao | last post by:
Hi, I am getting the following errors while trying to run this snippet in Microsoft Visual C++.Can't seem to print the crc value stored. /* +++Date last modified: 05-Jul-1997 */ /* Crc - 32 BIT ANSI X3.66 CRC checksum files */ #include <stdio.h> #include "crc.h"
0
9636
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10139
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.