Can PHP get the computer name ?
Moderator: General Moderators
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java
Can PHP get the computer name ?
Hello folks,
Does anybody know if PHP could get the computer name and other information about the user's computer ?
I am developing a web-based form and my boss wants me to get all the computer name where the data came from.
Thanks a lot,
Chris
Does anybody know if PHP could get the computer name and other information about the user's computer ?
I am developing a web-based form and my boss wants me to get all the computer name where the data came from.
Thanks a lot,
Chris
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
This will work. Well, I say work, I mean "will work in a very limited set of circumstances". The user has to be accessing the script with IE, and it has to be set to a very low security level. And even then it'll prompt them to ask if they want to run it.
Code: Select all
<script>
try
{
var ax = new ActiveXObject("WScript.Network");
document.write('User: ' + ax.UserName + '<br />');
document.write('Computer: ' + ax.ComputerName + '<br />');
}
catch (e)
{
document.write('Permission to access computer name is denied' + '<br />');
}
</script>- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
In my linux machine output was :onion2k wrote:This will work. Well, I say work, I mean "will work in a very limited set of circumstances". The user has to be accessing the script with IE, and it has to be set to a very low security level. And even then it'll prompt them to ask if they want to run it.
Code: Select all
<script> try { var ax = new ActiveXObject("WScript.Network"); document.write('User: ' + ax.UserName + '<br />'); document.write('Computer: ' + ax.ComputerName + '<br />'); } catch (e) { document.write('Permission to access computer name is denied' + '<br />'); } </script>
Code: Select all
Permission to access computer name is denied- ambivalent
- Forum Contributor
- Posts: 173
- Joined: Thu Apr 14, 2005 8:58 pm
- Location: Toronto, ON
In this case, it doesn't matter what the host is running since the ActiveXObject is running client side - naturally, it won't work on a client running any flavor of Linux or even Windows with Firefox, et al.dibyendrah wrote:ActiveXObject works with Windows only and most of the hosting company use linux.
gethostbyaddr() will work, given the IP, but it's really only reliable on Windows clients.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
gethostbyaddr() fetches the DNS level name of the IP (if possible.) It works on far more reliably than just Windows boxes. 
Not very suprising considering I wrote "The user has to be accessing the script with IE".dibyendrah wrote:In my linux machine output was :
Code: Select all
Permission to access computer name is denied
Re: Can PHP get the computer name ?
First question: WTF is the name of a computer? My machines don't have a name. And since i'm connecting via 3 proxies all your webserver (and the php script that runs on it) gets to see is the connection information from the proxy that is making the actual request... All i'm trying to say is that you will have to narrow down your requirements.christian_phpbeginner wrote:Does anybody know if PHP could get the computer name and other information about the user's computer ?
If we were talking about a windows-only LAN, preferably all authenticated (against AD) workstations you could configure IIS to require windows authentication...
Re: Can PHP get the computer name ?
Just out of curiosity: What OS is you computer running?timvw wrote:First question: WTF is the name of a computer? My machines don't have a name.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
He might mean the netbios name - all Windows computers have one. You'll never get this info over the web, it would be a major security breach.
If you're on the same local network (LAN), you could run a batch file through shell_exec() to get the netbios name from the IP address, which $_SERVER will give you.
If you're on the same local network (LAN), you could run a batch file through shell_exec() to get the netbios name from the IP address, which $_SERVER will give you.
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact: