Welcome to WebmasterWorld Guest from 54.226.67.166

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

ISAPI mode question...

     

madcat

5:53 pm on Nov 27, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A while ago I posted that $ip = getenv("REMOTE_ADDR") returns nothing- I have to use $ip = $_SERVER["REMOTE_ADDR"] to get the IP.

[webmasterworld.com...]

--> Hopefully this is easy enough. How do I check to see if I'm in ISAPI mode- how do I change it if I am?

Thanks for any ideas-

toadhall

6:33 pm on Nov 27, 2002 (gmt 0)

10+ Year Member



Hi madcat,

AFAIK the best way to tell if you're in ISAPI "mode" is to look at what server you're using. If you're using a Microsoft server (IIS or PWS) you'll undoubtedly have the ISAPI module installed. So the only way to change it would be to switch servers. If, that is, I read your question correctly.

You can gain some information using php_sapi_name()... it will return the "type of interface between web server and PHP" [php.net].

...and the environment variable GATEWAY_INTERFACE will return "what revision of the CGI specification the server is using; i.e. 'CGI/1.1'." [php.net].

I imagine you've checked the php installation using php_info() to see if register_globals is 'on' or 'off'.

If you don't have control over your php installation (access to the php.ini file) there are work-arounds. BUT, read and take to heart the reasons why register_globals now defaults to "off". Get both here [php.net].

Hope this helps.

toadhall

6:54 pm on Nov 27, 2002 (gmt 0)

10+ Year Member



I'm sorry madcat, I mislead you. You wouldn't have to "switch servers" to change from ISAPI to CGI. But you would have to re-install the server to reset the option. Somewhat the same. More here [php.net].

T

madcat

7:25 pm on Nov 27, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the info- I'm using Apache and it's all local. Is it better or worse to extract env variable values using getenv(); or $_SERVER[]; -- $_SERVER works and I'm tempted to use it when getting these variables unless that's a bad way to move? Any thoughts?

toadhall

8:33 pm on Nov 27, 2002 (gmt 0)

10+ Year Member



The book you're using was written before the release of PHP 4.2, and it seems you're using an up-to-date installation of PHP. So either adjust the sample code in your book to reflect a setting of register_globals=off, or change the setting in your php.ini file to register_globals=on.

Used locally you don't have the security concerns of a networked situation but bear in mind that if you have any notion of using your code online you may have to rewrite it to suit the host's setup and your clients' needs/desires.

>better or worse?

In the long run it's best to go with the flow and get used to writing scripts with register_globals "off".

madcat

12:20 am on Nov 28, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, the book was written after version 4.2. I want to keep register globals off for sure, but I want to make sure that I'm not incorrectly using:

$_SERVER['REMOTE_ADDR'];

to attain the IP address rather than:

getenv("REMOTE_ADDR");

this is what php.net suggests.

In httpd.conf:
LoadModule php4_module c:/php/sapi/php4apache.dll

Would this suggest I'm running in ISAPI - how would I change that if it's the case > I could be in leftfield but doesn't hurt to ask;0

andreasfriedrich

1:22 am on Nov 28, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are two ways the PHP engine may run: as a standalone executable that is called whenever a PHP script needs to be executed or as module within the server process. In the former case server and the PHP binary communicate via the Common Gateway Interface. In the latter case they communicat via the server api.

You simply need to decide which way you want to set up your server. Using mod_php is the recommended way. BTW you might not want to refer to ISAPI, which is the Internet Server Application Programming Interface when you are talking about the Apache webserver.

In PHP 4.1 and later the recommended way to access predefined variables is by using the autoglobal associative arrays. I see no need to use getenv() anymore.

Andreas

 

Featured Threads

Hot Threads This Week

Hot Threads This Month