server name on Windows XP

 
Post new topic   Reply to topic    Aprelium Forum Index -> Networking Issues
View previous topic :: View next topic  
Author Message
dormant
-


Joined: 23 Aug 2007
Posts: 6

PostPosted: Thu Aug 23, 2007 8:13 pm    Post subject: server name on Windows XP Reply with quote

Where does Abyss/php pick up the server name in Windows XP? The machine I am using has a name and a workgroup as is normal for Windows XP.

When I run a php script, I get nothing back for $_SERVER['SERVER_NAME'].

I recall a message when I installed Abyss, about it not being able to establish the server name.

Strangely, I can get it in perl, using `hostname`.
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Aug 23, 2007 8:17 pm    Post subject: Reply with quote

Try this:

Code:
<?php
// Prints out localhost, if requested from localhost
echo $_SERVER['SERVER_NAME'];
?>
Back to top View user's profile Send private message Visit poster's website
dormant
-


Joined: 23 Aug 2007
Posts: 6

PostPosted: Fri Aug 24, 2007 7:00 pm    Post subject: I did try that Reply with quote

Thanks for the suggestion - that is exactly what I had been using with incorrect results.

I was misleading in my original post.

$_SERVER['SERVER_NAME'] returns the ip address of the machine.
$_SERVER['SERVER_ADDR'] returns nothing.
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Fri Aug 24, 2007 7:17 pm    Post subject: Reply with quote

The first variable listed returns the same value as the HTTP_HOST variable or the name of the server. In Abyss's case, the Hostname.
The second variable is not available in Abyss Web Server because of Hostname lookups not being supported. You can get the Server's IP Address, using a simple function.

Code:
<?php
// Recreate the $_SERVER['SERVER_ADDR'] variable, using the gethostbyname() function.
$_SERVER['SERVER_ADDR'] = gethostbyname($_SERVER['HTTP_HOST']);

// Now we will output the Server's IP Address:
echo $_SERVER['SERVER_ADDR'];
?>
Back to top View user's profile Send private message Visit poster's website
dormant
-


Joined: 23 Aug 2007
Posts: 6

PostPosted: Mon Aug 27, 2007 3:52 pm    Post subject: Still confused Reply with quote

My problem is that these variables do not return what they are meant to return.

$_SERVER['SERVER_NAME'] returns the IP address.

$_SERVER['HTTP_HOST'] returns an empty string

So my tentative conclusion is that Abyss doesn't have the hostname. Why not? Where can I look for it, or change it?
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Mon Aug 27, 2007 4:18 pm    Post subject: Reply with quote

You're probably accessing your website using a cloaked web address. Are you sure your domain is directly pointing to your IP Address and not hiding in a frame? To check, view the page source of your website. Your IP will only show as the Hostname if your domain isn't properly setup, using an A or CNAME record.

It would help if you just posted the domain address.
Back to top View user's profile Send private message Visit poster's website
dormant
-


Joined: 23 Aug 2007
Posts: 6

PostPosted: Mon Aug 27, 2007 4:56 pm    Post subject: As usual, I never give the full info Reply with quote

I am accessing the webserver only over the LAN using the ip address or localhost, so no domain is involved, or any cloaking of any kind.

The machine has a name that is used in the Windows networking, and I was assuming that name could be picked up by the SERVER_NAME variable. Maybe I'm wrong.
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Mon Aug 27, 2007 10:14 pm    Post subject: Reply with quote

I don't know how it could not be working. What version of PHP are you using? It may also help you posted the PHP script.
Back to top View user's profile Send private message Visit poster's website
dormant
-


Joined: 23 Aug 2007
Posts: 6

PostPosted: Tue Aug 28, 2007 3:55 pm    Post subject: Script and outpur Reply with quote

I am using php5, the version provided with the Abyss web server.

The script is very simple:

Code:

<html>
<title>
<?php
   echo $_SERVER['SERVER_ADDR'];
   echo ' - ';
   echo $_SERVER['SERVER_NAME'];
?>
</title>
<body>

<h2>
<?php
   print $_SERVER['SERVER_ADDR'];
   print ' - ';
   print $_SERVER['SERVER_NAME'];
   print ' - ';
   print $_SERVER['HTTP_HOST'];
?>
</h2>

...lots of html


And the output:

Code:

<html>
<title>
 - 192.168.254.250</title>
<body>

<h2>
 - 192.168.254.250 - 192.168.254.250</h2>

...lots of html
Back to top View user's profile Send private message
ric
-


Joined: 20 May 2004
Posts: 15
Location: UK

PostPosted: Wed Aug 29, 2007 2:35 am    Post subject: Reply with quote

If you are after the machine name then you could use $_SERVER['COMPUTERNAME']
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Thu Aug 30, 2007 4:31 pm    Post subject: Re: server name on Windows XP Reply with quote

dormant,

SERVER_NAME is filled with the domain name/IP you have used in the URL when accessing the site.

So if you accessed your site using http://192.168.1.100:8000/page1.html, SERVER_NAME will contain 192.168.1.100.

If you accessed it using http://www.mysite.com/page1.html, SERVER_NAME will contain www.mysite.com.

SERVER_ADDR is not filled in Abyss Web Server as it does not perform DNS lookups. But you can easily get that value using SERVER_NAME (or a DNS lookup if of its value if it is not an IP).
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
dormant
-


Joined: 23 Aug 2007
Posts: 6

PostPosted: Tue Sep 04, 2007 1:08 pm    Post subject: Thanks Reply with quote

Thanks for the help and info - I now understand what is going on.
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Networking Issues All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group