Jump to content

Archived

This topic is now archived and is closed to further replies.

bfisher

Server IP on IIS

Recommended Posts

Hello all.

I need to obtain the server's IP address, but since I'm on IIS, I can't use the $SERVER_ADDR global variable.  Can anyone suggest another course of action?  By the way I'm new to PHP, so I apologize in advance if I use incorrect terminology.

Share this post


Link to post
Share on other sites
$_SERVER['SERVERIP'] // the ip of the server

$_SERVER['SERVER_ADDR'] // the vhost ip, if your using more than one ip on the server

If there not found in the SERVER array, then they will be found in the $_ENV array, it depends on the PHP version you are using (CGI/ISAPI)...

Just do this, to see where it is!

[code]<?php

echo '<pre>' . print_r ( $_SERVER ) . '</pre>';
echo '<pre>' . print_r ( $_ENV ) . '</pre>';

?>[/code]


me!

Share this post


Link to post
Share on other sites
[quote author=bfisher link=topic=111907.msg453803#msg453803 date=1161182085]
but since I'm on IIS, I can't use the $SERVER_ADDR global variable.
[/quote]

I'm assuming you mean [code=php:0]$_SERVER['SERVER_ADDR']
[/code]

Why can't you use that?

Regards
Huggie

Share this post


Link to post
Share on other sites
Thank you both for your quick replies.

When I loop through all the variables in $_SERVER with ...

[code]
<?php
while (list($var,$value) = each($_SERVER)){
echo "$var => $value <br>";
}
?>
[/code]

... I get the following, but no SERVER_ADDR.

ALL_HTTP => HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* HTTP_ACCEPT_LANGUAGE:en-us HTTP_CONNECTION:Keep-Alive HTTP_HOST:localhost HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) HTTP_UA_CPU:x86 HTTP_ACCEPT_ENCODING:gzip, deflate
HTTPS => off
SCRIPT_NAME => /globals.php
HTTP_COOKIE =>
AUTH_PASSWORD =>
AUTH_TYPE =>
AUTH_USER =>
CONTENT_LENGTH => 0
CONTENT_TYPE =>
PATH_TRANSLATED => c:\inetpub\wwwroot
QUERY_STRING =>
REMOTE_ADDR => 127.0.0.1
REMOTE_HOST => 127.0.0.1
REMOTE_USER =>
REQUEST_METHOD => GET
SERVER_NAME => localhost
SERVER_PORT => 80
SERVER_PROTOCOL => HTTP/1.1
SERVER_SOFTWARE => Microsoft-IIS/5.1
APPL_MD_PATH => /LM/W3SVC/1/ROOT
APPL_PHYSICAL_PATH => c:\inetpub\wwwroot\
INSTANCE_ID => 1
INSTANCE_META_PATH => /LM/W3SVC/1
LOGON_USER =>
REQUEST_URI => /globals.php
URL => /globals.php
SCRIPT_FILENAME => C:\Inetpub\wwwroot/globals.php
ORIG_PATH_INFO => /globals.php
PATH_INFO =>
ORIG_PATH_TRANSLATED => c:\inetpub\wwwroot\globals.php
DOCUMENT_ROOT => c:\inetpub\wwwroot
PHP_SELF => /globals.php
HTTP_ACCEPT => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
HTTP_ACCEPT_LANGUAGE => en-us
HTTP_CONNECTION => Keep-Alive
HTTP_HOST => localhost
HTTP_USER_AGENT => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
HTTP_UA_CPU => x86
HTTP_ACCEPT_ENCODING => gzip, deflate
REQUEST_TIME => 1161183243

I used the same loop code to loop through $_ENV, but I don't get anything at all.

-Bfisher

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.