[ciapug] php SuperGlobals issue
Tony Bibbs
tony at tonybibbs.com
Tue Mar 7 10:29:30 CST 2006
I haven't researched as to why this is but I've noticed that the
available supergloabls be different on different setups. I've
particularly noticed this when developing code that needs to run on both
*nix and Winders. I've even seen difference between two different
Winders boxes. I'm sure this is explained on php.net somewhere but my
experience is that if you depend on a superglobal being set you need to
rely on the phpinfo() output.
--Tony
vanish at dreamscapevisionery.com wrote:
> phpinfo() shows the server ip address under REMOTE_ADDR. I am hosting the
> server, and this code had worked previously, however during construction
> the
> HDDs were popped out while live and the server had to be rebuilt. It has
> not
> worked since.
>
> Is there some system level or apache level setting I'm missing that
> allows this
> to function properly?
>
> Chris VC
>
> Quoting "Ron Mutchler, ZCE" <qsecofr at gmail.com>:
>
>> I've used REMOTE_ADDR in my scripts before without seeing what you are
>> explaining.
>>
>> function get_ipaddy() {
>> $ipaddy = getenv ("REMOTE_ADDR");
>> return $ipaddy;
>> }
>>
>> Have you tried looking at phpinfo to see what it says?
>>
>> If you are hosting with a company, they could have configured it not
>> to return that particular variable. I have a host that refuses to
>> return PATH_INFO. I ended up having to look at ORIG_PATH_INFO in that
>> case.
>>
>>
>> On 3/7/06, vanish at dreamscapevisionery.com
>> <vanish at dreamscapevisionery.com> wrote:
>>> I'm hoping someone out there can figure out how I've screwed this up...
>>>
>>> In an include file, I have the following code:
>>>
>>> $sec_ip = $_SERVER['REMOTE_ADDR'];
>>>
>>> Which should set the variable to the IP address of the visitor's PC.
>>> In my
>>> setup, however, it displays the server's IP instead. I tried
>>> replacing that
>>> with:
>>>
>>> $sec_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
>>>
>>> to see if the problem was a proxy issue, but alas no ip is shown.
>>> (Yes, I tried
>>> the getenv method as well and the $ENV method also. All return the
>>> same result)
>>>
>>> Setting the variable form the original code page has the same effect
>>> so it's not
>>> some funky problem caused by being in an include file.
>>>
>>> Any ideas? Anyone? Bueller? Bueller?
>>>
>>> Chris VC
>>> _______________________________________________
>>> ciapug mailing list
>>> ciapug at cialug.org
>>> http://cialug.org/mailman/listinfo/ciapug
>>>
>> _______________________________________________
>> ciapug mailing list
>> ciapug at cialug.org
>> http://cialug.org/mailman/listinfo/ciapug
>>
>
>
>
> _______________________________________________
> ciapug mailing list
> ciapug at cialug.org
> http://cialug.org/mailman/listinfo/ciapug
More information about the ciapug
mailing list