Re: Sistema de Autentificacion
| From: | Vicente | Date: | Tue, 15 Jun 2004 17:15:12 +0000 |
| Subject: | Re: Sistema de Autentificacion | ||
| References: | 1 2 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-49404@lists.php.net to get a copy of this message | ||
informacion escribió:
i> La pregunta es clara, existe algun dato que sea unico en cada computadora y
i> yo pueda obtener desde un navegador.
Si lo que quieres es dar acceso a determinados usuarios en particular
que ya conoces, una manera en extremo sencilla es añadiendo una cadena
"hjh43hjds8" a la configuración del navegador en donde aparece su
identificación. En Windows está en el registro.
Esto puede ser filtrado por las variables de entorno de apache
directamente, de manera que puedes filtrar visitas sin un sistema de
login.
La opción de usar la dirección de MAC es mucho mejor y también es
viable pero según como, Por ejemplo esta función de abajo hace una
consulta de shell con 'which arp' así que depende del entorno en donde
se aplica; intranet, etc..
Una opción mejor copn esto es pegarle un ojo a las librerías de PECL
http://pecl.php.net/packages.php?catpid=16&catname=Networking
en la de netools tienes una función que de te devuelve el MAC address.
salud,
-----------------
<?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;
}
?>
--
Salud,