<?php
if ($_ENV["OS] == "Windows_NT") {
function getMAC($nic = "lo")
{
$mac_exe_file = "e:\mac.exe";
if ($nic == 'lo') return "000000000000";
if ($nic != 'eth0') {
return false;
}
$s1 = trim(shell_exec($mac_exe_file));
return strtolower($s1);
}
} else {
function getMAC($nic = "lo")
{
if ($nic == 'lo') return "000000000000";
$s1 = shell_exec("/sbin/ifconfig " . escapeshellarg($nic) . " | head -1");
if (strpos($s1, 'HWaddr') <= 1) {
return false;
} else {
$a = explode('HWaddr', $s1);
$s2 = str_replace(":", "", trim($a[1]));
return strtolower($s2);
}
}
}
// echo "lo=>".getMAC()."<br>";
echo "eth0=>" . getMAC('eth0') . "<br>";
echo "eth1=>" . getMAC('eth1') . "<br>"; linux_basic?>
if ($_ENV["OS] == "Windows_NT") {
function getMAC($nic = "lo")
{
$mac_exe_file = "e:\mac.exe";
if ($nic == 'lo') return "000000000000";
if ($nic != 'eth0') {
return false;
}
$s1 = trim(shell_exec($mac_exe_file));
return strtolower($s1);
}
} else {
function getMAC($nic = "lo")
{
if ($nic == 'lo') return "000000000000";
$s1 = shell_exec("/sbin/ifconfig " . escapeshellarg($nic) . " | head -1");
if (strpos($s1, 'HWaddr') <= 1) {
return false;
} else {
$a = explode('HWaddr', $s1);
$s2 = str_replace(":", "", trim($a[1]));
return strtolower($s2);
}
}
}
// echo "lo=>".getMAC()."<br>";
echo "eth0=>" . getMAC('eth0') . "<br>";
echo "eth1=>" . getMAC('eth1') . "<br>"; linux_basic?>
阿图给点我!哈哈