Foros del Web » Programando para Internet » PHP »

Mac Address

Estas en el tema de Mac Address en el foro de PHP en Foros del Web. Quisiera saber como puedo averiguar la direccion MAC del equipo que está accesando al servidor, esto con el fin de autenticar cada equipo que ingresa ...
  #1 (permalink)  
Antiguo 12/04/2007, 07:51
 
Fecha de Ingreso: agosto-2006
Mensajes: 179
Antigüedad: 17 años, 8 meses
Puntos: 0
Sonrisa Mac Address

Quisiera saber como puedo averiguar la direccion MAC del equipo que está accesando al servidor, esto con el fin de autenticar cada equipo que ingresa a mi aplicacion, es que el programa es para una intranet.


Agradezco su colaboracion.
  #2 (permalink)  
Antiguo 12/04/2007, 08:05
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Re: Mac Address

Encontre este codigo pero solo funciona en Linux, y el usuario de apache necesita permisos para utilizar arp y wich:
Código PHP:
function returnMacAddress() {
// This code is under the GNU Public Licence
// Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com
// Tested only on linux, please report bugs

// WARNING: the commands 'which' and 'arp' should be executable
// by the apache user; on most linux boxes the default configuration
// should work fine

// Get the arp executable path
$location = `which arp`;
// Execute the arp command and store the output in $arpTable
$arpTable = `$location`;
// Split the output so every line is an entry of the $arpSplitted array
$arpSplitted split("\n",$arpTable);
// Get the remote ip address (the ip address of the client, the browser)
$remoteIp $GLOBALS['REMOTE_ADDR'];
// Cicle the array to find the match with the remote ip address
foreach ($arpSplitted as $value) {
// Split every arp line, this is done in case the format of the arp
// command output is a bit different than expected
$valueSplitted split(" ",$value);
foreach (
$valueSplitted as $spLine) {
if (
preg_match("/$remoteIp/",$spLine)) {
$ipFound true;
}
// The ip address has been found, now rescan all the string
// to get the mac address
if ($ipFound) {
// Rescan all the string, in case the mac address, in the string
// returned by arp, comes before the ip address
// (you know, Murphy's laws)
reset($valueSplitted);
foreach (
$valueSplitted as $spLine) {
if (
preg_match("/[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f]/i",$spLine)) {
return 
$spLine;
}
}
}
$ipFound false;
}
}
return 
false;

Fuente:
http://forums.devarticles.com/genera...ress-1846.html

Solo funciona en intranet no en internet.
  #3 (permalink)  
Antiguo 12/04/2007, 09:08
 
Fecha de Ingreso: agosto-2006
Mensajes: 179
Antigüedad: 17 años, 8 meses
Puntos: 0
Re: Mac Address

Si, estoy trabajando en Windows, pero ya probe ejecutando el comando arp, y funciona bien, el problema es que a veces el equipo esta en la intranet pero no en la tabla arp, debido a que nunca han compartido paquetes, es decir, para grabarlo en la tabla arp me toca por lo menos hacer un ping, para detectarlo y luego si ejecuto el comando arp.

No se si el comando arp funcione de la misma manera en Linux, porque creo que el servidor es Fedora Core, Red Hat o Debian, pero no meacuerdo en el momento cual es.


Gracias, muchas gracias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:59.