function setpassphrase($wifi_uid, $dev) { $phyp = XNODE_getpathbytarget("", "phyinf", "uid", $wifi_uid, 0); $wifi1 = XNODE_getpathbytarget("/wifi", "entry", "uid", query($phyp . "/wifi"), 0); $psk = query($wifi1 . "/nwkey/psk/key"); $i = 0; $idx = 0; $len = strlen($psk); $sub_str = $psk; while ($i < $len) { if (charcodeat($sub_str, $i) == "\\" || charcodeat($sub_str, $i) == "\"" || charcodeat($sub_str, $i) == "\$" || charcodeat($sub_str, $i) == "`") { $string = $string . substr($sub_str, $idx, $i - $idx); $string = $string . "\\" . charcodeat($sub_str, $i); $idx = $i + 1; } $i++; } if ($idx == 0) { $string = $sub_str; } else { if ($idx != $len) { $string = $string . substr($sub_str, $idx, $len - $idx); } } fwrite("a", $_GLOBALS["START"], 'iwpriv ' . $dev . ' set_mib passphrase=' . '\\"' . $string . '\\"' . '\\n'); }
function get_valid_mac($value) { $mac_len = strlen($value); $mac_idx = 0; $valid_mac = ""; $char = ""; $delimiter = ":"; while ($mac_idx < $mac_len) { $valid_mac = $valid_mac . substr($value, $mac_idx, 2); $mac_idx = $mac_idx + 2; $char = charcodeat($value, $mac_idx); if ($char != "") { if ($char == $delimiter) { $mac_idx++; } $valid_mac = $valid_mac . $delimiter; } } return $valid_mac; }