Status : '.$status.'
Client list
'; exec('cat /var/lib/misc/dnsmasq.leases',$leases); foreach($leases as $lease) { echo $lease; } if(isset($_POST['savedhcpdsettings'])) { $config = 'interface='.$_POST['interface'].' dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd'].',255.255.255.0,'.$_POST['RangeLeaseTime'].''.$_POST['RangeLeaseTimeUnits']; exec('echo "'.$config.'" > /tmp/dhcpddata',$temp); system('sudo cp /tmp/dhcpddata /etc/dnsmasq.conf',$return); if($return == 0) { echo "dnsmasq configuration updated successfully"; } else { echo "Dnsmasq configuration failed to be updated"; } } if(isset($_POST['startdhcpd'])) { $line = system('sudo /etc/init.d/dnsmasq start',$return); echo "Attempting to start dnsmasq"; } if(isset($_POST['stopdhcpd'])) { $line = system('sudo /etc/init.d/dnsmasq stop',$return); echo "Stopping dnsmasq"; } break; case "wlan0_info": exec('ifconfig wlan0',$return); exec('iwconfig wlan0',$return); $strWlan0 = implode(" ",$return); $strWlan0 = preg_replace('/\s\s+/', ' ', $strWlan0); preg_match('/HWaddr ([0-9a-f:]+)/i',$strWlan0,$result); $strHWAddress = $result[1]; preg_match('/inet addr:([0-9.]+)/i',$strWlan0,$result); $strIPAddress = $result[1]; preg_match('/Mask:([0-9.]+)/i',$strWlan0,$result); $strNetMask = $result[1]; preg_match('/RX packets:(\d+)/',$strWlan0,$result); $strRxPackets = $result[1]; preg_match('/TX packets:(\d+)/',$strWlan0,$result); $strTxPackets = $result[1]; preg_match('/RX Bytes:(\d+ \(\d+.\d+ MiB\))/i',$strWlan0,$result); $strRxBytes = $result[1]; preg_match('/TX Bytes:(\d+ \(\d+.\d+ [K|M|G]iB\))/i',$strWlan0,$result); $strTxBytes = $result[1]; preg_match('/ESSID:\"([a-zA-Z0-9\s]+)\"/i',$strWlan0,$result); $strSSID = str_replace('"','',$result[1]); preg_match('/Access Point: ([0-9a-f:]+)/i',$strWlan0,$result); $strBSSID = $result[1]; preg_match('/Bit Rate=([0-9]+ Mb\/s)/i',$strWlan0,$result); $strBitrate = $result[1]; preg_match('/Tx-Power=([0-9]+ dBm)/i',$strWlan0,$result); $strTxPower = $result[1]; preg_match('/Link Quality=([0-9]+\/[0-9]+)/i',$strWlan0,$result); $strLinkQuality = $result[1]; preg_match('/Signal Level=(-[0-9]+ dBm)/i',$strWlan0,$result); $strSignalLevel = $result[1]; if(strpos($strWlan0, "UP") !== false && strpos($strWlan0, "RUNNING") !== false) { $strStatus = 'Interface is up'; } else { $strStatus = 'Interface is down'; } if(isset($_POST['ifdown_wlan0'])) { exec('ifconfig wlan0 | grep -i running | wc -l',$test); if($test[0] == 1) { exec('sudo ifdown wlan0',$return); } else { echo 'Interface already down'; } } elseif(isset($_POST['ifup_wlan0'])) { exec('ifconfig wlan0 | grep -i running | wc -l',$test); if($test[0] == 0) { exec('sudo ifup wlan0',$return); } else { echo 'Interface already up'; } } echo '
Wireless Information and Statistics
Interface Information
Interface Name : wlan0Interface Status : ' . $strStatus . '
IP Address : ' . $strIPAddress . '
Subnet Mask : ' . $strNetMask . '
Mac Address : ' . $strHWAddress . '
Interface Statistics
Received Packets : ' . $strRxPackets . 'Received Bytes : ' . $strRxBytes . '
Transferred Packets : ' . $strTxPackets . '
Transferred Bytes : ' . $strTxBytes . '
Wireless Information
Connected To : ' . $strSSID . 'AP Mac Address : ' . $strBSSID . '
Bitrate : ' . $strBitrate . '
Transmit Power : ' . $strTxPower .'
Link Quality : ' . $strLinkQuality . '
Signal Level : ' . $strSignalLevel . '
"; foreach($return as $network) { $arrNetwork = preg_split("/[\t]+/",$network); $bssid = $arrNetwork[0]; $channel = ConvertToChannel($arrNetwork[1]); $signal = $arrNetwork[2] . " dBm"; $security = $arrNetwork[3]; $ssid = $arrNetwork[4]; echo '' . $ssid . " on channel " . $channel . " with " . $signal . "(".ConvertToSecurity($security)." Security)
"; } } break; case "hostapd_conf": exec('cat /etc/hostapd/hostapd.conf',$return); exec('pidof hostapd | wc -l',$hostapdstatus); if($hostapdstatus[0] == 0) { $status = 'hostapd is not running'; } else { $status = 'hostapd is running'; } $arrConfig = array(); $arrChannel = array('a','b','g'); $arrSecurity = array( 1 => 'WPA', 2 => 'WPA2',3=> 'WPA+WPA2'); $arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP'); foreach($return as $a) { if($a[0] != "#") { $arrLine = explode("=",$a); $arrConfig[$arrLine[0]]=$arrLine[1]; } } echo ''; break; case "save_hostapd_conf": if(isset($_POST['SaveHostAPDSettings'])) { $config = 'driver=nl80211 ctrl_interface=/var/run/hostapd ctrl_interface_group=0 beacon_int=100 auth_algs=1 wpa_key_mgmt=WPA-PSK '; $config .= "interface=".$_POST['interface']." "; $config .= "ssid=".$_POST['ssid']." "; $config .= "hw_mode=".$_POST['hw_mode']." "; $config .= "channel=".$_POST['channel']." "; $config .= "wpa=".$_POST['wpa']." "; $config .='wpa_passphrase='.$_POST['wpa_passphrase'].' '; $config .="wpa_pairwise=".$_POST['wpa_pairwise']." "; $config .="country_code=".$_POST['country_code']; exec("echo '$config' > /tmp/hostapddata",$return); system("sudo cp /tmp/hostapddata /etc/hostapd/hostapd.conf",$return); if($return == 0) { echo "Wifi Hotspot settings saved"; } else { echo "Wifi Hotspot settings failed to be saved"; } } elseif(isset($_POST['StartHotspot'])) { echo "Attempting to start hotspot"; exec('sudo /etc/init.d/hostapd start',$return); foreach($return as $line) { echo $line."
"; } } elseif(isset($_POST['StopHotspot'])) { echo "Attempting to stop hotspot"; exec('sudo /etc/init.d/hostapd stop',$return); foreach($return as $line) { echo $line."
"; } } break; } echo '