function getInfo() { $info = WifiBo::sendCommand("cat /etc/hostapd/hostapd.conf"); $lines = explode("\n", $info); $infos = array(); $infos["disabled"] = $this->isActive() ? 0 : 1; $infos["encryption"] = "none"; foreach ($lines as $line) { if (strlen($line) > 0 && substr($line, 0, 1) == "#") { continue; } $explLine = explode("=", trim($line), 2); if (count($explLine) < 2) { continue; } else { $value = $explLine[1]; } switch ($explLine[0]) { case "channel": $infos["channel"] = $value; break; case "ssid": $infos["ssid"] = $value; break; case "wpa_passphrase": $infos["key"] = $value; break; case "wpa_key_mgmt": $infos["wpa_key_mgmt"] = $value; break; case "wpa": $infos["wpa"] = $value; break; case "wpa_pairwise": $infos["wpa_pairwise"] = $value; break; case "rsn_pairwise": $infos["rsn_pairwise"] = $value; break; } } if (isset($infos["key"]) && $infos["key"] && isset($infos["wpa"])) { if ($infos["wpa"] == 1) { $infos["encryption"] = "psk"; } else { if ($infos["wpa"] == 2) { $infos["encryption"] = "psk2"; if ($infos["wpa_pairwise"] == "TKIP") { $infos["encryption"] = "psk-mixed"; } } } } return $infos; }
function setPower($txpower) { WifiBo::sendCommand("uci set wireless.radio0.txpower='{$txpower}'; uci commit wireless; wifi"); }
function setKey($key) { WifiBo::sendCommand("uci set wireless.@wifi-iface[0].key='{$key}'; uci commit wireless; wifi"); }