1 ? $arrLine[1] : true ); } } return $config; } /** * * @param string $freq * @return $channel */ function ConvertToChannel( $freq ) { $base = 2412; $channel = 1; for( $x = 0; $x < 13; $x++ ) { if( $freq != $base ) { $base = $base + 5; $channel++; } else { return $channel; } } return "Invalid Channel"; } /** * Converts WPA security string to readable format * @param string $security * @return string */ function ConvertToSecurity( $security ) { switch( $security ) { case "[WPA2-PSK-CCMP][ESS]": return "WPA2-PSK (AES)"; break; case "[WPA2-PSK-TKIP][ESS]": return "WPA2-PSK (TKIP)"; break; case "[WPA2-PSK-CCMP][WPS][ESS]": return "WPA/WPA2-PSK (TKIP/AES)"; break; case "[WPA2-PSK-TKIP+CCMP][WPS][ESS]": return "WPA2-PSK (TKIP/AES) with WPS"; break; case "[WPA-PSK-TKIP+CCMP][WPS][ESS]": return "WPA-PSK (TKIP/AES) with WPS"; break; case "[WPA-PSK-TKIP][WPA2-PSK-CCMP][WPS][ESS]": return "WPA/WPA2-PSK (TKIP/AES)"; break; case "[WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][ESS]": return "WPA/WPA2-PSK (TKIP/AES)"; break; case "[WPA-PSK-TKIP][ESS]": return "WPA-PSK (TKIP)"; break; case "[WEP][ESS]": return "WEP"; break; } } /** * * */ function DisplayDashboard(){ exec( 'ifconfig wlan0', $return ); exec( 'iwconfig wlan0', $return ); $strWlan0 = implode( " ", $return ); $strWlan0 = preg_replace( '/\s\s+/', ' ', $strWlan0 ); // Parse results from ifconfig/iwconfig 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+ [K|M|G]iB\))/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]+)/i',$strWlan0,$result ); $strLinkQuality = $result[1]; preg_match( '/Signal Level=([0-9]+)/i',$strWlan0,$result ); $strSignalLevel = $result[1]; preg_match('/Frequency:(\d+.\d+ GHz)/i',$strWlan0,$result); $strFrequency = $result[1]; if(strpos( $strWlan0, "UP" ) !== false && strpos( $strWlan0, "RUNNING" ) !== false ) { $status = '
Interface is up
'; $wlan0up = true; } else { $status = '
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'; } } ?>
Dashboard

Interface Information

Interface Name
wlan0
IP Address

Subnet Mask

Mac Address


Interface Statistics

Received Packets

Received Bytes


Transferred Packets

Transferred Bytes

Wireless Information

Connected To

AP Mac Address

Bitrate

Transmit Power

Frequency


Link Quality
%
Signal Level
%
'; } else { echo ''; } ?>
Configure client

Client settings

2 ) { exec( 'wpa_passphrase '.$ssid. ' ' . $psk,$network ); foreach($network as $b) { $config .= "$b "; } } } exec( "echo '$config' > /tmp/wifidata", $return ); system( 'sudo cp /tmp/wifidata ' . RASPI_WPA_SUPPLICANT_CONFIG, $returnval ); if( $returnval == 0 ) { echo '
Wifi settings updated successfully
'; } else { echo '
Wifi settings failed to be updated
'; } // scan networks } elseif( isset($_POST['Scan']) ) { $return = ''; exec( 'sudo wpa_cli scan',$return ); sleep(3); exec( 'sudo wpa_cli scan_results',$return ); for( $shift = 0; $shift < 4; $shift++ ) { array_shift($return); } // display output echo '
'; echo '
'; echo '

Networks found

'; echo ''; 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 '"; } echo '
SSIDChannelSignalSecurity
' . $ssid . " " . $channel . "" . $signal . "". ConvertToSecurity($security) ."
'; } else { // default action, output configured network(s) exec(' sudo cat ' . RASPI_WPA_SUPPLICANT_CONFIG, $return); $ssid = array(); $psk = array(); foreach($return as $a) { if(preg_match('/SSID/i',$a)) { $arrssid = explode("=",$a); $ssid[] = str_replace('"','',$arrssid[1]); } if(preg_match('/psk/i',$a)) { $arrpsk = explode("=",$a); $psk[] = str_replace('"','',$arrpsk[1]); } } $numSSIDs = count($ssid); $output = '
'; if ( $numSSIDs > 0 ) { for( $ssids = 0; $ssids < $numSSIDs; $ssids++ ) { $output .= '
'; } $output .= '
'; } else { $status = '
Not connected
'; } $output .= '
'; $output .= ''; echo $output; } ?>
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]; } }; ?>
Configure hotspot

Basic settings

Security settings

Advanced settings

'; } else { echo ''; }; ?>
OpenVPN is not running
'; } else { $status = '
OpenVPN is running
'; } // parse client settings foreach( $returnClient as $a ) { if( $a[0] != "#" ) { $arrLine = explode( " ",$a) ; $arrClientConfig[$arrLine[0]]=$arrLine[1]; } } // parse server settings foreach( $returnServer as $a ) { if( $a[0] != "#" ) { $arrLine = explode( " ",$a) ; $arrServerConfig[$arrLine[0]]=$arrLine[1]; } } ?>
Configure OpenVPN

Client settings

Server settings

'; } else { echo ''; } ?>
TOR is not running
'; } else { $status = '
TOR is running
'; } foreach( $return as $a ) { if( $a[0] != "#" ) { $arrLine = explode( " ",$a) ; $arrConfig[$arrLine[0]]=$arrLine[1]; } } ?>
Configure TOR proxy

Basic settings

Relay settings

'; } else { echo ''; }; ?>
1)? 's ':' '); } if ($hours != 0) { $uptime .= $hours . ' hour' . (($hours > 1)? 's ':' '); } if ($minutes != 0) { $uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' '); } // mem used exec("free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { print used/total*100}'", $memarray); $memused = floor($memarray[0]); if ($memused > 90) { $memused_status = "danger"; } elseif ($memused > 75) { $memused_status = "warning"; } elseif ($memused > 0) { $memused_status = "success"; } // cpu load $cores = exec("grep -c ^processor /proc/cpuinfo"); $loadavg = exec("awk '{print $1}' /proc/loadavg"); $cpuload = floor(($loadavg * 100) / $cores); if ($cpuload > 90) { $cpuload_status = "danger"; } elseif ($cpuload > 75) { $cpuload_status = "warning"; } elseif ($cpuload > 0) { $cpuload_status = "success"; } ?>
System
System Rebooting Now!
'; $result = shell_exec("sudo /sbin/reboot"); } if (isset($_POST['system_shutdown'])) { echo '
System Shutting Down Now!
'; $result = shell_exec("sudo /sbin/shutdown -h now"); } ?>

System Information

Hostname

Uptime


Memory Used
%
CPU Load
%
/tmp/hostapddata", $return ); system( "sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $return ); if( $return == 0 ) { echo "Wifi Hotspot settings saved"; } else { echo "Wifi Hotspot settings failed to be saved"; } } elseif( isset($_POST['SaveOpenVPNSettings']) ) { // TODO } elseif( isset($_POST['SaveTORProxySettings']) ) { // TODO } 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."
"; } } elseif( isset($_POST['StartOpenVPN']) ) { echo "Attempting to start openvpn"; exec( 'sudo /etc/init.d/openvpn start', $return ); foreach( $return as $line ) { echo $line."
"; } } elseif( isset($_POST['StopOpenVPN']) ) { echo "Attempting to stop openvpn"; exec( 'sudo /etc/init.d/openvpn stop', $return ); foreach( $return as $line ) { echo $line."
"; } } elseif( isset($_POST['StartTOR']) ) { echo "Attempting to start TOR"; exec( 'sudo /etc/init.d/tor start', $return ); foreach( $return as $line ) { echo $line."
"; } } elseif( isset($_POST['StopTOR']) ) { echo "Attempting to stop TOR"; exec( 'sudo /etc/init.d/tor stop', $return ); foreach( $return as $line ) { echo $line."
"; } } } ?>