function PHYINF_validmacaddr($macaddr) { if (cut_count($macaddr, ":") == 6) { $delimiter = ":"; } else { return 0; } $i = 0; while ($i < 6) { $v = cut($macaddr, $i, $delimiter); if (strlen($v) != 2 || isxdigit($v) != 1) { return 0; } if ($i == 0) { //hendry : check for multicast mac $val = strtoul($v, 16); $ismulti = $val % 2; if ($ismulti == 1) { return 0; } } $i++; } if (toupper($macaddr) == "FF:FF:FF:FF:FF:FF" || $macaddr == "01:11:11:11:11:11" || $macaddr == "00:00:00:00:00:00") { return 0; } return 1; }
function check_key_type_and_valid($key_type, $key) { $ret = 2; //invalid if ($key != "") { if ($key_type == "WEP") { if (strlen($key) == 10 || strlen($key) == 26) { if (isxdigit($key) == 1) { $ret = 0; } else { $ret = 2; } //invalid } else { if (strlen($key) == 5 || strlen($key) == 13) { $ret = 1; } } } else { //wpa range 64 for hex 8~63 for ascii if (strlen($key) == 64) { if (isxdigit($key) == 1) { $ret = 0; } //hex } else { if (strlen($key) > 7 && strlen($key) < 64) { $ret = 1; //legal } } } } return $ret; }