Page 1 of 1

How to get the machine code of my computer in php?

Posted: Mon Nov 18, 2002 5:28 am
by villas
Hi guys,

Can i get the machine code of my computer by a function of PHP, or in other methods in php?

Plz give me a hand~~~

Thanks in advance~~~

Posted: Mon Nov 18, 2002 5:31 am
by m3mn0n
machine code? hmmm, if you mean IP address it's:

Code: Select all

<?php
$REMOTE_ADDR
or
$REMOTE_HOST
?>
make a blank .php page and type in only phpinfo(); you should get more from there

Posted: Mon Nov 18, 2002 5:41 am
by twigletmac
It may be that $REMOTE_ADDR nor $REMOTE_HOST appear to be unavailable to you - if so then try:

Code: Select all

$_SERVERї'REMOTE_ADDR'] 
// or 
$_SERVERї'REMOTE_HOST']
if you have PHP 4.1 or above, or

Code: Select all

$HTTP_SERVER_VARSї'REMOTE_ADDR']
// or 
$HTTP_SERVER_VARSї'REMOTE_HOST']
if you have PHP 4.0.6 or below.

Mac

Posted: Mon Nov 18, 2002 5:45 am
by villas
Dear Oromian,

Thanks first~~~

The machine code is the unique symbol of a computer, but not a IP address...

I didn't have any lights in phpinfo() functions,
Do you have an idea to get it in PHP?
Thanks a lot~~~

Posted: Tue Nov 19, 2002 1:25 am
by villas
please give a hand~~~

Thanks in advance!

Posted: Tue Nov 19, 2002 2:26 am
by volka
afaik there is no php function to retrieve that kind of information.
But you may use external programs.
with winnt/2k/xp ships a program called ipconfig. ipconfig /all will show all mac addresses of all adapters.
linux/unix systems usually have ifconfig. ifconfig eth0 e.g. shows all infos of adapter eth0.
you can fetch the ouput via exec() and filter it.
e.g.

Code: Select all

ifconfig eth0 | grep "HWaddr" | sed -e 's/.*HWaddr \(.*\)/\1/g'
catches the mac of eth0 at my linux box at bash command line