Hello.
I am puzzled with a string comparison I'm making and which I find is not working. Please take a look, maybe I'm missing something:
I'm getting a mac address from a client pc or cpe radio and comparing it to the one in registered in our database...
I get the mac client address like this:
$mac = sudo arp -i eth1 $ip | grep : | awk '{print $3}';
and get: 00:12:0e:a1:82:7dthen I strip the : off by doing this: str_replace(":","",$mac)
now $mac = 00120ea1827d
$query = "select mac from radios where cust_id = " . $id_row["id"];
$radio = new DB($query, 'optimum');
$r = mysql_fetch_array( $radio->result );
Here I get the mac from our database:
and $r['mac'] = 00120EA1827D; // notice this is capital letters
if( $radio->__CountRows__() > 0 ){
if( strtoupper(getDbMac($r['mac'])) != strtoupper(getDbMac($mac)) ){
$location = "http://172.16.0.1:8080/optimum/accessdenied.php? radMac=" .
strtoupper(getDbMac($r['mac'])) . "&recMac=" . strtoupper(getDbMac($mac));
header("Location: $location" );
exit;
}
}
So if I'm not mistaken th statements after comparing the two macs should NOT be executed and it's being executed... users are always redirected to the accessdenied.php page even though the two macs are the same.
What exactly is wrong with my if statement or what am I doing wrong?
Thanks in advanced for your help.