diff --git a/includes/dhcp.php b/includes/dhcp.php
index a4fd107a..60793029 100755
--- a/includes/dhcp.php
+++ b/includes/dhcp.php
@@ -1,139 +1,140 @@
= IFNAMSIZ) {
- $errors .= _('Invalid interface name.').'
'.PHP_EOL;
- }
-
- if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeStart']) &&
- !empty($_POST['RangeStart'])) { // allow ''/null ?
- $errors .= _('Invalid DHCP range start.').'
'.PHP_EOL;
- }
-
- if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeEnd']) &&
- !empty($_POST['RangeEnd'])) { // allow ''/null ?
- $errors .= _('Invalid DHCP range end.').'
'.PHP_EOL;
- }
-
- if (!ctype_digit($_POST['RangeLeaseTime']) && $_POST['RangeLeaseTimeUnits'] !== 'infinite') {
- $errors .= _('Invalid DHCP lease time, not a number.').'
'.PHP_EOL;
- }
-
- if (!in_array($_POST['RangeLeaseTimeUnits'], array('m', 'h', 'd', 'infinite'))) {
- $errors .= _('Unknown DHCP lease time unit.').'
'.PHP_EOL;
- }
-
- $return = 1;
- if (empty($errors)) {
- $config = 'interface='.$_POST['interface'].PHP_EOL.
- 'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd'].
- ',255.255.255.0,';
- if ($_POST['RangeLeaseTimeUnits'] !== 'infinite') {
- $config .= $_POST['RangeLeaseTime'];
+ $errors .= _('Invalid interface name.').'
'.PHP_EOL;
}
- $config .= $_POST['RangeLeaseTimeUnits'];
- exec('echo "'.$config.'" > /tmp/dhcpddata', $temp);
- system('sudo cp /tmp/dhcpddata '.RASPI_DNSMASQ_CONFIG, $return);
- } else {
- $status->addMessage($errors, 'danger');
- }
+ if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeStart']) &&
+ !empty($_POST['RangeStart'])) { // allow ''/null ?
+ $errors .= _('Invalid DHCP range start.').'
'.PHP_EOL;
+ }
- if ($return == 0) {
- $status->addMessage('Dnsmasq configuration updated successfully', 'success');
+ if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeEnd']) &&
+ !empty($_POST['RangeEnd'])) { // allow ''/null ?
+ $errors .= _('Invalid DHCP range end.').'
'.PHP_EOL;
+ }
+
+ if (!ctype_digit($_POST['RangeLeaseTime']) && $_POST['RangeLeaseTimeUnits'] !== 'infinite') {
+ $errors .= _('Invalid DHCP lease time, not a number.').'
'.PHP_EOL;
+ }
+
+ if (!in_array($_POST['RangeLeaseTimeUnits'], array('m', 'h', 'd', 'infinite'))) {
+ $errors .= _('Unknown DHCP lease time unit.').'
'.PHP_EOL;
+ }
+
+ $return = 1;
+ if (empty($errors)) {
+ $config = 'interface='.$_POST['interface'].PHP_EOL.
+ 'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd'].
+ ',255.255.255.0,';
+ if ($_POST['RangeLeaseTimeUnits'] !== 'infinite') {
+ $config .= $_POST['RangeLeaseTime'];
+ }
+
+ $config .= $_POST['RangeLeaseTimeUnits'];
+ exec('echo "'.$config.'" > /tmp/dhcpddata', $temp);
+ system('sudo cp /tmp/dhcpddata '.RASPI_DNSMASQ_CONFIG, $return);
+ } else {
+ $status->addMessage($errors, 'danger');
+ }
+
+ if ($return == 0) {
+ $status->addMessage('Dnsmasq configuration updated successfully', 'success');
+ } else {
+ $status->addMessage('Dnsmasq configuration failed to be updated.', 'danger');
+ }
} else {
- $status->addMessage('Dnsmasq configuration failed to be updated.', 'danger');
+ error_log('CSRF violation');
+ }
+ }
+
+ exec('pidof dnsmasq | wc -l', $dnsmasq);
+ $dnsmasq_state = ($dnsmasq[0] > 0);
+
+ if (isset($_POST['startdhcpd'])) {
+ if (CSRFValidate()) {
+ if ($dnsmasq_state) {
+ $status->addMessage('dnsmasq already running', 'info');
+ } else {
+ exec('sudo /etc/init.d/dnsmasq start', $dnsmasq, $return);
+ if ($return == 0) {
+ $status->addMessage('Successfully started dnsmasq', 'success');
+ $dnsmasq_state = true;
+ } else {
+ $status->addMessage('Failed to start dnsmasq', 'danger');
+ }
+ }
+ } else {
+ error_log('CSRF violation');
+ }
+ } elseif (isset($_POST['stopdhcpd'])) {
+ if (CSRFValidate()) {
+ if ($dnsmasq_state) {
+ exec('sudo /etc/init.d/dnsmasq stop', $dnsmasq, $return);
+ if ($return == 0) {
+ $status->addMessage('Successfully stopped dnsmasq', 'success');
+ $dnsmasq_state = false;
+ } else {
+ $status->addMessage('Failed to stop dnsmasq', 'danger');
+ }
+ } else {
+ $status->addMessage('dnsmasq already stopped', 'info');
+ }
+ } else {
+ error_log('CSRF violation');
}
} else {
- error_log('CSRF violation');
- }
- }
-
- exec( 'pidof dnsmasq | wc -l',$dnsmasq );
- $dnsmasq_state = ($dnsmasq[0] > 0);
-
- if( isset( $_POST['startdhcpd'] ) ) {
- if (CSRFValidate()) {
- if ($dnsmasq_state) {
- $status->addMessage('dnsmasq already running', 'info');
- } else {
- exec('sudo /etc/init.d/dnsmasq start', $dnsmasq, $return);
- if ($return == 0) {
- $status->addMessage('Successfully started dnsmasq', 'success');
- $dnsmasq_state = true;
+ if ($dnsmasq_state) {
+ $status->addMessage('Dnsmasq is running', 'success');
} else {
- $status->addMessage('Failed to start dnsmasq', 'danger');
+ $status->addMessage('Dnsmasq is not running', 'warning');
}
- }
- } else {
- error_log('CSRF violation');
}
- } elseif( isset($_POST['stopdhcpd'] ) ) {
- if (CSRFValidate()) {
- if ($dnsmasq_state) {
- exec('sudo /etc/init.d/dnsmasq stop', $dnsmasq, $return);
- if ($return == 0) {
- $status->addMessage('Successfully stopped dnsmasq', 'success');
- $dnsmasq_state = false;
- } else {
- $status->addMessage('Failed to stop dnsmasq', 'danger');
+
+ exec('cat '. RASPI_DNSMASQ_CONFIG, $return);
+ $conf = ParseConfig($return);
+ $arrRange = explode(",", $conf['dhcp-range']);
+ $RangeStart = $arrRange[0];
+ $RangeEnd = $arrRange[1];
+ $RangeMask = $arrRange[2];
+ $leaseTime = $arrRange[3];
+
+ $hselected = '';
+ $mselected = '';
+ $dselected = '';
+ $infiniteselected = '';
+ preg_match('/([0-9]*)([a-z])/i', $leaseTime, $arrRangeLeaseTime);
+ if ($leaseTime === 'infinite') {
+ $infiniteselected = ' selected="selected"';
+ } else {
+ switch ($arrRangeLeaseTime[2]) {
+ case 'h':
+ $hselected = ' selected="selected"';
+ break;
+ case 'm':
+ $mselected = ' selected="selected"';
+ break;
+ case 'd':
+ $dselected = ' selected="selected"';
+ break;
}
- } else {
- $status->addMessage('dnsmasq already stopped', 'info');
- }
- } else {
- error_log('CSRF violation');
}
- } else {
- if( $dnsmasq_state ) {
- $status->addMessage('Dnsmasq is running', 'success');
- } else {
- $status->addMessage('Dnsmasq is not running', 'warning');
- }
- }
-
- exec( 'cat '. RASPI_DNSMASQ_CONFIG, $return );
- $conf = ParseConfig($return);
- $arrRange = explode( ",", $conf['dhcp-range'] );
- $RangeStart = $arrRange[0];
- $RangeEnd = $arrRange[1];
- $RangeMask = $arrRange[2];
- $leaseTime = $arrRange[3];
-
- $hselected = '';
- $mselected = '';
- $dselected = '';
- $infiniteselected = '';
- preg_match( '/([0-9]*)([a-z])/i', $leaseTime, $arrRangeLeaseTime );
- if ($leaseTime === 'infinite') {
- $infiniteselected = ' selected="selected"';
- } else {
- switch( $arrRangeLeaseTime[2] ) {
- case 'h':
- $hselected = ' selected="selected"';
- break;
- case 'm':
- $mselected = ' selected="selected"';
- break;
- case 'd':
- $dselected = ' selected="selected"';
- break;
- }
- }
?>
@@ -238,11 +239,11 @@ function DisplayDHCPConfig() {
'.PHP_EOL;
$lease_items = explode(' ', $lease);
- foreach( $lease_items as $lease_item ) {
+ foreach ($lease_items as $lease_item) {
echo ' '.htmlspecialchars($lease_item, ENT_QUOTES).' | '.PHP_EOL;
}
echo ' '.PHP_EOL;
diff --git a/includes/functions.php b/includes/functions.php
index 8e4050f5..035a8848 100755
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -1,38 +1,46 @@
$val) {
- if(is_array($val)) {
+ foreach ($array as $key => $val) {
+ if (is_array($val)) {
$res[] = "[$key]";
- foreach($val as $skey => $sval) $res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"');
+ foreach ($val as $skey => $sval) {
+ $res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"');
+ }
+ } else {
+ $res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"');
}
- else $res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"');
}
- if(safefilerewrite($file, implode("\r\n", $res))) {
+ if (safefilerewrite($file, implode("\r\n", $res))) {
return true;
} else {
return false;
}
}
-function safefilerewrite($fileName, $dataToSave) {
+function safefilerewrite($fileName, $dataToSave)
+{
if ($fp = fopen($fileName, 'w')) {
- $startTime = microtime(TRUE);
+ $startTime = microtime(true);
do {
$canWrite = flock($fp, LOCK_EX);
// If lock not obtained sleep for 0 - 100 milliseconds, to avoid collision and CPU load
- if(!$canWrite) usleep(round(rand(0, 100)*1000));
- } while ((!$canWrite)and((microtime(TRUE)-$startTime) < 5));
+ if (!$canWrite) {
+ usleep(round(rand(0, 100)*1000));
+ }
+ } while ((!$canWrite)and((microtime(true)-$startTime) < 5));
//file was locked so now we can store information
if ($canWrite) {
@@ -46,16 +54,16 @@ function safefilerewrite($fileName, $dataToSave) {
}
}
-
-
/**
*
* Add CSRF Token to form
*
*/
-function CSRFToken() {
+function CSRFToken()
+{
?>
-
+
' , PHP_EOL;
- foreach ( $options as $opt => $label) {
- $select = '';
- $key = isAssoc($options) ? $opt : $label;
- if( $key == $selected ) {
- $select = ' selected="selected"';
+function SelectorOptions($name, $options, $selected = null, $id = null)
+{
+ echo '' , PHP_EOL;
+ echo '' , PHP_EOL;
+ }
+
+ echo '' , PHP_EOL;
}
/**
@@ -118,9 +129,10 @@ function SelectorOptions($name, $options, $selected = null, $id = null) {
* @param string $separator
* @return $string
*/
-function GetDistString( $input,$string,$offset,$separator ) {
- $string = substr( $input,strpos( $input,$string )+$offset,strpos( substr( $input,strpos( $input,$string )+$offset ), $separator ) );
- return $string;
+function GetDistString($input, $string, $offset, $separator)
+{
+ $string = substr($input, strpos($input, $string)+$offset, strpos(substr($input, strpos($input, $string)+$offset), $separator));
+ return $string;
}
/**
@@ -128,16 +140,17 @@ function GetDistString( $input,$string,$offset,$separator ) {
* @param array $arrConfig
* @return $config
*/
-function ParseConfig( $arrConfig ) {
- $config = array();
- foreach( $arrConfig as $line ) {
- $line = trim($line);
- if( $line != "" && $line[0] != "#" ) {
- $arrLine = explode( "=",$line );
- $config[$arrLine[0]] = ( count($arrLine) > 1 ? $arrLine[1] : true );
- }
- }
- return $config;
+function ParseConfig($arrConfig)
+{
+ $config = array();
+ foreach ($arrConfig as $line) {
+ $line = trim($line);
+ if ($line != "" && $line[0] != "#") {
+ $arrLine = explode("=", $line);
+ $config[$arrLine[0]] = ( count($arrLine) > 1 ? $arrLine[1] : true );
+ }
+ }
+ return $config;
}
/**
@@ -145,21 +158,22 @@ function ParseConfig( $arrConfig ) {
* @param string $freq
* @return $channel
*/
-function ConvertToChannel( $freq ) {
- if ($freq >= 2412 && $freq <= 2484) {
- $channel = ($freq - 2407)/5;
- } elseif ($freq >= 4915 && $freq <= 4980) {
- $channel = ($freq - 4910)/5 + 182;
- } elseif ($freq >= 5035 && $freq <= 5865) {
- $channel = ($freq - 5030)/5 + 6;
- } else {
- $channel = -1;
- }
- if ($channel >= 1 && $channel <= 196) {
- return $channel;
- } else {
- return 'Invalid Channel';
- }
+function ConvertToChannel($freq)
+{
+ if ($freq >= 2412 && $freq <= 2484) {
+ $channel = ($freq - 2407)/5;
+ } elseif ($freq >= 4915 && $freq <= 4980) {
+ $channel = ($freq - 4910)/5 + 182;
+ } elseif ($freq >= 5035 && $freq <= 5865) {
+ $channel = ($freq - 5030)/5 + 6;
+ } else {
+ $channel = -1;
+ }
+ if ($channel >= 1 && $channel <= 196) {
+ return $channel;
+ } else {
+ return 'Invalid Channel';
+ }
}
/**
@@ -167,154 +181,156 @@ function ConvertToChannel( $freq ) {
* @param string $security
* @return string
*/
-function ConvertToSecurity( $security ) {
- $options = array();
- preg_match_all('/\[([^\]]+)\]/s', $security, $matches);
- foreach($matches[1] as $match) {
- if (preg_match('/^(WPA\d?)/', $match, $protocol_match)) {
- $protocol = $protocol_match[1];
- $matchArr = explode('-', $match);
- if (count($matchArr) > 2) {
- $options[] = htmlspecialchars($protocol . ' ('. $matchArr[2] .')', ENT_QUOTES);
- } else {
- $options[] = htmlspecialchars($protocol, ENT_QUOTES);
- }
+function ConvertToSecurity($security)
+{
+ $options = array();
+ preg_match_all('/\[([^\]]+)\]/s', $security, $matches);
+ foreach ($matches[1] as $match) {
+ if (preg_match('/^(WPA\d?)/', $match, $protocol_match)) {
+ $protocol = $protocol_match[1];
+ $matchArr = explode('-', $match);
+ if (count($matchArr) > 2) {
+ $options[] = htmlspecialchars($protocol . ' ('. $matchArr[2] .')', ENT_QUOTES);
+ } else {
+ $options[] = htmlspecialchars($protocol, ENT_QUOTES);
+ }
+ }
}
- }
- if (count($options) === 0) {
- // This could also be WEP but wpa_supplicant doesn't have a way to determine
- // this.
- // And you shouldn't be using WEP these days anyway.
- return 'Open';
- } else {
- return implode('
', $options);
- }
+ if (count($options) === 0) {
+ // This could also be WEP but wpa_supplicant doesn't have a way to determine
+ // this.
+ // And you shouldn't be using WEP these days anyway.
+ return 'Open';
+ } else {
+ return implode('
', $options);
+ }
}
/**
*
*
*/
-function DisplayOpenVPNConfig() {
+function DisplayOpenVPNConfig()
+{
- exec( 'cat '. RASPI_OPENVPN_CLIENT_CONFIG, $returnClient );
- exec( 'cat '. RASPI_OPENVPN_SERVER_CONFIG, $returnServer );
- exec( 'pidof openvpn | wc -l', $openvpnstatus);
+ exec('cat '. RASPI_OPENVPN_CLIENT_CONFIG, $returnClient);
+ exec('cat '. RASPI_OPENVPN_SERVER_CONFIG, $returnServer);
+ exec('pidof openvpn | wc -l', $openvpnstatus);
- if( $openvpnstatus[0] == 0 ) {
- $status = 'OpenVPN is not running
+ if ($openvpnstatus[0] == 0) {
+ $status = '
OpenVPN is not running
';
- } else {
- $status = '
OpenVPN is 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 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
-
-
-
-
-
-
-
-
+ // parse server settings
+ foreach ($returnServer as $a) {
+ if ($a[0] != "#") {
+ $arrLine = explode(" ", $a) ;
+ $arrServerConfig[$arrLine[0]]=$arrLine[1];
+ }
+ }
+ ?>
+
+
+
+
Configure OpenVPN
+
+
+
+
+
+
+
+
-
-
Server settings
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ' , PHP_EOL;
- } else {
- echo '
' , PHP_EOL;
- }
+
+
+
+
+
+
+
+
+
+
Server settings
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ' , PHP_EOL;
+ } else {
+ echo '
' , PHP_EOL;
+ }
?>
-
-
-
-
+
+
+
+
TOR is not running
+ if ($torproxystatus[0] == 0) {
+ $status = '
TOR is not running
';
- } else {
- $status = '
TOR is running
+ } else {
+ $status = '
TOR is running
';
- }
+ }
- $arrConfig = array();
- foreach( $return as $a ) {
- if( $a[0] != "#" ) {
- $arrLine = explode( " ",$a) ;
- $arrConfig[$arrLine[0]]=$arrLine[1];
- }
- }
+ $arrConfig = array();
+ foreach ($return as $a) {
+ if ($a[0] != "#") {
+ $arrLine = explode(" ", $a) ;
+ $arrConfig[$arrLine[0]]=$arrLine[1];
+ }
+ }
?>
-
-
-
-
Configure TOR proxy
+
+
+
+
Configure TOR proxy
-
+
- Basic
@@ -361,140 +378,141 @@ function DisplayTorProxyConfig(){
-
-
+
+
-
-
-
Relay settings
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
Relay settings
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- ' , PHP_EOL;
- } else {
- echo '
' , PHP_EOL;
- };
- ?>
-
-
-
-
+
+ ' , PHP_EOL;
+ } else {
+ echo '
' , PHP_EOL;
+ };
+ ?>
+
+
+
+
-' , PHP_EOL;
+function SaveTORAndVPNConfig()
+{
+ if (isset($_POST['SaveOpenVPNSettings'])) {
+ // TODO
+ } elseif (isset($_POST['SaveTORProxySettings'])) {
+ // TODO
+ } elseif (isset($_POST['StartOpenVPN'])) {
+ echo "Attempting to start openvpn";
+ exec('sudo /etc/init.d/openvpn start', $return);
+ foreach ($return as $line) {
+ echo htmlspecialchars($line, ENT_QUOTES).'
' , PHP_EOL;
+ }
+ } elseif (isset($_POST['StopOpenVPN'])) {
+ echo "Attempting to stop openvpn";
+ exec('sudo /etc/init.d/openvpn stop', $return);
+ foreach ($return as $line) {
+ echo htmlspecialchars($line, ENT_QUOTES).'
' , PHP_EOL;
+ }
+ } elseif (isset($_POST['StartTOR'])) {
+ echo "Attempting to start TOR";
+ exec('sudo /etc/init.d/tor start', $return);
+ foreach ($return as $line) {
+ echo htmlspecialchars($line, ENT_QUOTES).'
' , PHP_EOL;
+ }
+ } elseif (isset($_POST['StopTOR'])) {
+ echo "Attempting to stop TOR";
+ exec('sudo /etc/init.d/tor stop', $return);
+ foreach ($return as $line) {
+ echo htmlspecialchars($line, ENT_QUOTES).'
' , PHP_EOL;
+ }
}
- } elseif( isset($_POST['StopOpenVPN']) ) {
- echo "Attempting to stop openvpn";
- exec( 'sudo /etc/init.d/openvpn stop', $return );
- foreach( $return as $line ) {
- echo htmlspecialchars($line, ENT_QUOTES).'
' , PHP_EOL;
- }
- } elseif( isset($_POST['StartTOR']) ) {
- echo "Attempting to start TOR";
- exec( 'sudo /etc/init.d/tor start', $return );
- foreach( $return as $line ) {
- echo htmlspecialchars($line, ENT_QUOTES).'
' , PHP_EOL;
- }
- } elseif( isset($_POST['StopTOR']) ) {
- echo "Attempting to stop TOR";
- exec( 'sudo /etc/init.d/tor stop', $return );
- foreach( $return as $line ) {
- echo htmlspecialchars($line, ENT_QUOTES).'
' , PHP_EOL;
- }
- }
}
diff --git a/includes/hostapd.php b/includes/hostapd.php
index 92192165..84d84cb4 100755
--- a/includes/hostapd.php
+++ b/includes/hostapd.php
@@ -1,6 +1,6 @@
'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
+ $arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
+ exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
- $arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
+ if (isset($_POST['SaveHostAPDSettings'])) {
+ if (CSRFValidate()) {
+ SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status);
+ } else {
+ error_log('CSRF violation');
+ }
+ } elseif (isset($_POST['StartHotspot'])) {
+ if (CSRFValidate()) {
+ $status->addMessage('Attempting to start hotspot', 'info');
+ if ($arrHostapdConf['WifiAPEnable'] == 1) {
+ exec('sudo /etc/raspap/hostapd/servicestart.sh --interface uap0 --seconds 5', $return);
+ } else {
+ exec('sudo /etc/raspap/hostapd/servicestart.sh --seconds 5', $return);
+ }
+ foreach ($return as $line) {
+ $status->addMessage($line, 'info');
+ }
+ } else {
+ error_log('CSRF violation');
+ }
+ } elseif (isset($_POST['StopHotspot'])) {
+ if (CSRFValidate()) {
+ $status->addMessage('Attempting to stop hotspot', 'info');
+ exec('sudo /etc/init.d/hostapd stop', $return);
+ foreach ($return as $line) {
+ $status->addMessage($line, 'info');
+ }
+ } else {
+ error_log('CSRF violation');
+ }
+ }
- $arrConfig = array();
- $arr80211Standard = array('a','b','g','n');
- $arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
- $arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
- exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
+ exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
+ exec('pidof hostapd | wc -l', $hostapdstatus);
- if( isset($_POST['SaveHostAPDSettings']) ) {
- if (CSRFValidate()) {
- SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status);
+ if ($hostapdstatus[0] == 0) {
+ $status->addMessage('HostAPD is not running', 'warning');
} else {
- error_log('CSRF violation');
- }
- } elseif( isset($_POST['StartHotspot']) ) {
- if (CSRFValidate()) {
- $status->addMessage('Attempting to start hotspot', 'info');
- if ($arrHostapdConf['WifiAPEnable'] == 1) {
- exec('sudo /etc/raspap/hostapd/servicestart.sh --interface uap0 --seconds 5', $return );
- } else {
- exec( 'sudo /etc/raspap/hostapd/servicestart.sh --seconds 5', $return );
- }
- foreach( $return as $line ) {
- $status->addMessage($line, 'info');
- }
- } else {
- error_log('CSRF violation');
- }
- } elseif( isset($_POST['StopHotspot']) ) {
- if (CSRFValidate()) {
- $status->addMessage('Attempting to stop hotspot', 'info');
- exec( 'sudo /etc/init.d/hostapd stop', $return );
- foreach( $return as $line ) {
- $status->addMessage($line, 'info');
- }
- } else {
- error_log('CSRF violation');
- }
- }
-
- exec( 'cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig );
- exec( 'pidof hostapd | wc -l', $hostapdstatus);
-
- if( $hostapdstatus[0] == 0 ) {
- $status->addMessage('HostAPD is not running', 'warning');
- } else {
- $status->addMessage('HostAPD is running', 'success');
- }
-
- foreach( $hostapdconfig as $hostapdconfigline ) {
- if (strlen($hostapdconfigline) === 0) {
- continue;
+ $status->addMessage('HostAPD is running', 'success');
}
- if ($hostapdconfigline[0] != "#" ) {
- $arrLine = explode("=", $hostapdconfigline) ;
- $arrConfig[$arrLine[0]]=$arrLine[1];
- }
- };
+ foreach ($hostapdconfig as $hostapdconfigline) {
+ if (strlen($hostapdconfigline) === 0) {
+ continue;
+ }
+
+ if ($hostapdconfigline[0] != "#") {
+ $arrLine = explode("=", $hostapdconfigline) ;
+ $arrConfig[$arrLine[0]]=$arrLine[1];
+ }
+ };
?>
@@ -77,7 +75,7 @@ function DisplayHostAPDConfig()
-
showMessages(); ?>
+
showMessages(); ?>
@@ -169,61 +167,61 @@ if (in_array($arrConfig['country_code'], $countries_max11channels)) {
-
+
- ';
- } else {
- echo "
Logfile output not enabled";
- }
- ?>
+ ';
+ } else {
+ echo "
Logfile output not enabled";
+ }
+ ?>
- 14) {
- error_log("Attempting to set channel to '".$_POST['channel']."'");
- return false;
- }
+ if (intval($_POST['channel']) < 1 || intval($_POST['channel']) > 14) {
+ error_log("Attempting to set channel to '".$_POST['channel']."'");
+ return false;
+ }
- $good_input = true;
+ $good_input = true;
- // Check for WiFi client AP mode checkbox
- $wifiAPEnable = 0;
- if($arrHostapdConf['WifiAPEnable'] == 0) {
- if(isset($_POST['wifiAPEnable'])) {
- $wifiAPEnable = 1;
- }
- } else {
- if(isset($_POST['wifiAPEnable'])) {
- $wifiAPEnable = 1;
- }
- }
+ // Check for WiFi client AP mode checkbox
+ $wifiAPEnable = 0;
+ if ($arrHostapdConf['WifiAPEnable'] == 0) {
+ if (isset($_POST['wifiAPEnable'])) {
+ $wifiAPEnable = 1;
+ }
+ } else {
+ if (isset($_POST['wifiAPEnable'])) {
+ $wifiAPEnable = 1;
+ }
+ }
- // Check for Logfile output checkbox
- $logEnable = 0;
- if($arrHostapdConf['LogEnable'] == 0) {
- if(isset($_POST['logEnable'])) {
- $logEnable = 1;
- exec('sudo /etc/raspap/hostapd/enablelog.sh');
- } else {
- exec('sudo /etc/raspap/hostapd/disablelog.sh');
- }
- } else {
- if(isset($_POST['logEnable'])) {
- $logEnable = 1;
- exec('sudo /etc/raspap/hostapd/enablelog.sh');
- } else {
- exec('sudo /etc/raspap/hostapd/disablelog.sh');
- }
- }
- $cfg = [];
- $cfg['LogEnable'] = $logEnable;
- $cfg['WifiAPEnable'] = $wifiAPEnable;
- write_php_ini($cfg,'/etc/raspap/hostapd.ini');
+ // Check for Logfile output checkbox
+ $logEnable = 0;
+ if ($arrHostapdConf['LogEnable'] == 0) {
+ if (isset($_POST['logEnable'])) {
+ $logEnable = 1;
+ exec('sudo /etc/raspap/hostapd/enablelog.sh');
+ } else {
+ exec('sudo /etc/raspap/hostapd/disablelog.sh');
+ }
+ } else {
+ if (isset($_POST['logEnable'])) {
+ $logEnable = 1;
+ exec('sudo /etc/raspap/hostapd/enablelog.sh');
+ } else {
+ exec('sudo /etc/raspap/hostapd/disablelog.sh');
+ }
+ }
+ $cfg = [];
+ $cfg['LogEnable'] = $logEnable;
+ $cfg['WifiAPEnable'] = $wifiAPEnable;
+ write_php_ini($cfg, '/etc/raspap/hostapd.ini');
- // Verify input
- if (empty($_POST['ssid']) || strlen($_POST['ssid']) > 32) {
- // Not sure of all the restrictions of SSID
- $status->addMessage('SSID must be between 1 and 32 characters', 'danger');
- $good_input = false;
- }
+ // Verify input
+ if (empty($_POST['ssid']) || strlen($_POST['ssid']) > 32) {
+ // Not sure of all the restrictions of SSID
+ $status->addMessage('SSID must be between 1 and 32 characters', 'danger');
+ $good_input = false;
+ }
- if ($_POST['wpa'] !== 'none' &&
+ if ($_POST['wpa'] !== 'none' &&
(strlen($_POST['wpa_passphrase']) < 8 || strlen($_POST['wpa_passphrase']) > 63)) {
- $status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');
- $good_input = false;
- }
+ $status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');
+ $good_input = false;
+ }
- if (isset($_POST['hiddenSSID'])) {
- if (!is_int((int)$_POST['hiddenSSID'])) {
- $status->addMessage('Parameter hiddenSSID not a number.', 'danger');
- $good_input = false;
- } elseif ((int)$_POST['hiddenSSID'] < 0 || (int)$_POST['hiddenSSID'] >= 3) {
- $status->addMessage('Parameter hiddenSSID contains invalid configuratie value.', 'danger');
- $good_input = false;
+ if (isset($_POST['hiddenSSID'])) {
+ if (!is_int((int)$_POST['hiddenSSID'])) {
+ $status->addMessage('Parameter hiddenSSID not a number.', 'danger');
+ $good_input = false;
+ } elseif ((int)$_POST['hiddenSSID'] < 0 || (int)$_POST['hiddenSSID'] >= 3) {
+ $status->addMessage('Parameter hiddenSSID contains invalid configuratie value.', 'danger');
+ $good_input = false;
+ } else {
+ $ignore_broadcast_ssid = $_POST['hiddenSSID'];
+ }
} else {
- $ignore_broadcast_ssid = $_POST['hiddenSSID'];
+ $ignore_broadcast_ssid = '0';
}
- } else {
- $ignore_broadcast_ssid = '0';
- }
- if (! in_array($_POST['interface'], $interfaces)) {
- // The user is probably up to something here but it may also be a
- // genuine error.
- $status->addMessage('Unknown interface '.htmlspecialchars($_POST['interface'], ENT_QUOTES), 'danger');
- $good_input = false;
- }
+ if (! in_array($_POST['interface'], $interfaces)) {
+ // The user is probably up to something here but it may also be a
+ // genuine error.
+ $status->addMessage('Unknown interface '.htmlspecialchars($_POST['interface'], ENT_QUOTES), 'danger');
+ $good_input = false;
+ }
- if (strlen($_POST['country_code']) !== 0 && strlen($_POST['country_code']) != 2) {
- $status->addMessage('Country code must be blank or two characters', 'danger');
- $good_input = false;
- }
+ if (strlen($_POST['country_code']) !== 0 && strlen($_POST['country_code']) != 2) {
+ $status->addMessage('Country code must be blank or two characters', 'danger');
+ $good_input = false;
+ }
- if ($good_input) {
- // Fixed values
- $config = 'driver=nl80211'.PHP_EOL;
- $config.= 'ctrl_interface='.RASPI_HOSTAPD_CTRL_INTERFACE.PHP_EOL;
- $config.= 'ctrl_interface_group=0'.PHP_EOL;
- $config.= 'auth_algs=1'.PHP_EOL;
- $config.= 'wpa_key_mgmt=WPA-PSK'.PHP_EOL;
- $config.= 'beacon_int=100'.PHP_EOL;
- $config.= 'ssid='.$_POST['ssid'].PHP_EOL;
- $config.= 'channel='.$_POST['channel'].PHP_EOL;
- if ($_POST['hw_mode'] === 'n') {
- $config.= 'hw_mode=g'.PHP_EOL;
- $config.= 'ieee80211n=1'.PHP_EOL;
- // Enable basic Quality of service
- $config.= 'wme_enabled=1'.PHP_EOL;
+ if ($good_input) {
+ // Fixed values
+ $config = 'driver=nl80211'.PHP_EOL;
+ $config.= 'ctrl_interface='.RASPI_HOSTAPD_CTRL_INTERFACE.PHP_EOL;
+ $config.= 'ctrl_interface_group=0'.PHP_EOL;
+ $config.= 'auth_algs=1'.PHP_EOL;
+ $config.= 'wpa_key_mgmt=WPA-PSK'.PHP_EOL;
+ $config.= 'beacon_int=100'.PHP_EOL;
+ $config.= 'ssid='.$_POST['ssid'].PHP_EOL;
+ $config.= 'channel='.$_POST['channel'].PHP_EOL;
+ if ($_POST['hw_mode'] === 'n') {
+ $config.= 'hw_mode=g'.PHP_EOL;
+ $config.= 'ieee80211n=1'.PHP_EOL;
+ // Enable basic Quality of service
+ $config.= 'wme_enabled=1'.PHP_EOL;
+ } else {
+ $config.= 'hw_mode='.$_POST['hw_mode'].PHP_EOL;
+ $config.= 'ieee80211n=0'.PHP_EOL;
+ }
+ $config.= 'wpa_passphrase='.$_POST['wpa_passphrase'].PHP_EOL;
+ if ($wifiAPEnable == 1) {
+ $config.= 'interface=uap0'.PHP_EOL;
+ } else {
+ $config.= 'interface='.$_POST['interface'].PHP_EOL;
+ }
+ $config.= 'wpa='.$_POST['wpa'].PHP_EOL;
+ $config.= 'wpa_pairwise='.$_POST['wpa_pairwise'].PHP_EOL;
+ $config.= 'country_code='.$_POST['country_code'].PHP_EOL;
+ $config.= 'ignore_broadcast_ssid='.$ignore_broadcast_ssid.PHP_EOL;
+
+ exec('echo "'.$config.'" > /tmp/hostapddata', $temp);
+ system("sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $return);
+
+ if ($wifiAPEnable == 1) {
+ // Enable uap0 configuration in dnsmasq for Wifi client AP mode
+ $config = 'interface=lo,uap0 # Enable uap0 interface for wireless client AP mode'.PHP_EOL;
+ $config.= 'bind-interfaces # Bind to the interfaces'.PHP_EOL;
+ $config.= 'server=8.8.8.8 # Forward DNS requests to Google DNS'.PHP_EOL;
+ $config.= 'domain-needed # Don\'t forward short names'.PHP_EOL;
+ $config.= 'bogus-priv # Never forward addresses in the non-routed address spaces'.PHP_EOL;
+ $config.= 'dhcp-range=192.168.50.50,192.168.50.150,12h'.PHP_EOL;
+ } else {
+ // Fallback to default config
+ $config = 'domain-needed'.PHP_EOL;
+ $config.= 'interface='.$_POST['interface'].PHP_EOL;
+ $config.= 'dhcp-range=10.3.141.50,10.3.141.255,255.255.255.0,12h'.PHP_EOL;
+ }
+ exec('echo "'.$config.'" > /tmp/dhcpddata', $temp);
+ system('sudo cp /tmp/dhcpddata '.RASPI_DNSMASQ_CONFIG, $return);
+
+ if ($wifiAPEnable == 1) {
+ // Enable uap0 configuration in dhcpcd for Wifi client AP mode
+ $config = PHP_EOL.'# RaspAP uap0 configuration'.PHP_EOL;
+ $config.= 'interface uap0'.PHP_EOL;
+ $config.= 'static ip_address=192.168.50.1/24'.PHP_EOL;
+ $config.= 'nohook wpa_supplicant'.PHP_EOL;
+ } else {
+ // Default config
+ $config = '# RaspAP wlan0 configuration'.PHP_EOL;
+ $config.= 'hostname'.PHP_EOL;
+ $config.= 'clientid'.PHP_EOL;
+ $config.= 'persistent'.PHP_EOL;
+ $config.= 'option rapid_commit'.PHP_EOL;
+ $config.= 'option domain_name_servers, domain_name, domain_search, host_name'.PHP_EOL;
+ $config.= 'option classless_static_routes'.PHP_EOL;
+ $config.= 'option ntp_servers'.PHP_EOL;
+ $config.= 'require dhcp_server_identifier'.PHP_EOL;
+ $config.= 'slaac private'.PHP_EOL;
+ $config.= 'nohook lookup-hostname'.PHP_EOL;
+ $config.= 'interface '.RASPI_WIFI_CLIENT_INTERFACE.PHP_EOL;
+ $config.= 'static ip_address=10.3.141.1/24'.PHP_EOL;
+ $config.= 'static routers=10.3.141.1'.PHP_EOL;
+ $config.= 'static domain_name_server=1.1.1.1 8.8.8.8'.PHP_EOL;
+ }
+ exec('echo "'.$config.'" > /tmp/dhcpddata', $temp);
+ system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return);
+
+
+ if ($return == 0) {
+ $status->addMessage('Wifi Hotspot settings saved', 'success');
+ } else {
+ $status->addMessage('Unable to save wifi hotspot settings', 'danger');
+ }
} else {
- $config.= 'hw_mode='.$_POST['hw_mode'].PHP_EOL;
- $config.= 'ieee80211n=0'.PHP_EOL;
+ $status->addMessage('Unable to save wifi hotspot settings', 'danger');
+ return false;
}
- $config.= 'wpa_passphrase='.$_POST['wpa_passphrase'].PHP_EOL;
- if ($wifiAPEnable == 1) {
- $config.= 'interface=uap0'.PHP_EOL;
- } else {
- $config.= 'interface='.$_POST['interface'].PHP_EOL;
- }
- $config.= 'wpa='.$_POST['wpa'].PHP_EOL;
- $config.= 'wpa_pairwise='.$_POST['wpa_pairwise'].PHP_EOL;
- $config.= 'country_code='.$_POST['country_code'].PHP_EOL;
- $config.= 'ignore_broadcast_ssid='.$ignore_broadcast_ssid.PHP_EOL;
- exec('echo "'.$config.'" > /tmp/hostapddata', $temp);
- system( "sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $return );
-
- if ($wifiAPEnable == 1) {
- // Enable uap0 configuration in dnsmasq for Wifi client AP mode
- $config = 'interface=lo,uap0 # Enable uap0 interface for wireless client AP mode'.PHP_EOL;
- $config.= 'bind-interfaces # Bind to the interfaces'.PHP_EOL;
- $config.= 'server=8.8.8.8 # Forward DNS requests to Google DNS'.PHP_EOL;
- $config.= 'domain-needed # Don\'t forward short names'.PHP_EOL;
- $config.= 'bogus-priv # Never forward addresses in the non-routed address spaces'.PHP_EOL;
- $config.= 'dhcp-range=192.168.50.50,192.168.50.150,12h'.PHP_EOL;
- } else {
- // Fallback to default config
- $config = 'domain-needed'.PHP_EOL;
- $config.= 'interface='.$_POST['interface'].PHP_EOL;
- $config.= 'dhcp-range=10.3.141.50,10.3.141.255,255.255.255.0,12h'.PHP_EOL;
- }
- exec('echo "'.$config.'" > /tmp/dhcpddata', $temp);
- system('sudo cp /tmp/dhcpddata '.RASPI_DNSMASQ_CONFIG, $return);
-
- if ($wifiAPEnable == 1) {
- // Enable uap0 configuration in dhcpcd for Wifi client AP mode
- $config = PHP_EOL.'# RaspAP uap0 configuration'.PHP_EOL;
- $config.= 'interface uap0'.PHP_EOL;
- $config.= 'static ip_address=192.168.50.1/24'.PHP_EOL;
- $config.= 'nohook wpa_supplicant'.PHP_EOL;
- } else {
- // Default config
- $config = '# RaspAP wlan0 configuration'.PHP_EOL;
- $config.= 'hostname'.PHP_EOL;
- $config.= 'clientid'.PHP_EOL;
- $config.= 'persistent'.PHP_EOL;
- $config.= 'option rapid_commit'.PHP_EOL;
- $config.= 'option domain_name_servers, domain_name, domain_search, host_name'.PHP_EOL;
- $config.= 'option classless_static_routes'.PHP_EOL;
- $config.= 'option ntp_servers'.PHP_EOL;
- $config.= 'require dhcp_server_identifier'.PHP_EOL;
- $config.= 'slaac private'.PHP_EOL;
- $config.= 'nohook lookup-hostname'.PHP_EOL;
- $config.= 'interface '.RASPI_WIFI_CLIENT_INTERFACE.PHP_EOL;
- $config.= 'static ip_address=10.3.141.1/24'.PHP_EOL;
- $config.= 'static routers=10.3.141.1'.PHP_EOL;
- $config.= 'static domain_name_server=1.1.1.1 8.8.8.8'.PHP_EOL;
- }
- exec('echo "'.$config.'" > /tmp/dhcpddata', $temp);
- system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return);
-
-
- if( $return == 0 ) {
- $status->addMessage('Wifi Hotspot settings saved', 'success');
- } else {
- $status->addMessage('Unable to save wifi hotspot settings', 'danger');
- }
- } else {
- $status->addMessage('Unable to save wifi hotspot settings', 'danger');
- return false;
- }
-
- return true;
+ return true;
}
diff --git a/includes/locale.php b/includes/locale.php
index 4efe07ac..ac07f8da 100755
--- a/includes/locale.php
+++ b/includes/locale.php
@@ -1,64 +1,62 @@
= 2) {
- $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
- switch ($lang){
- case "de":
- $locale = "de_DE.UTF-8";
- break;
- case "fr":
- $locale = "fr_FR.UTF-8";
- break;
- case "it":
- $locale = "it_IT.UTF-8";
- break;
- case "pt":
- $locale = "pt_BR.UTF-8";
- break;
- case "sv":
- $locale = "sv_SE.UTF-8";
- break;
- case "nl":
- $locale = "nl_NL.UTF-8";
- break;
- case "zh":
- $locale = "zh_CN.UTF-8";
- break;
- case "cs":
- $locale = "cs_CZ.UTF-8";
- break;
- case "ru":
- $locale = "ru_RU.UTF-8";
- break;
- case "es":
- $locale = "es_MX.UTF-8";
- break;
- case "fi":
- $locale = "fi_FI.UTF-8";
- break;
- case "si":
- $locale = "si_LK.UTF-8";
- break;
- default:
- $locale = "en_GB.UTF-8";
- break;
- }
+ $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
+ switch ($lang) {
+ case "de":
+ $locale = "de_DE.UTF-8";
+ break;
+ case "fr":
+ $locale = "fr_FR.UTF-8";
+ break;
+ case "it":
+ $locale = "it_IT.UTF-8";
+ break;
+ case "pt":
+ $locale = "pt_BR.UTF-8";
+ break;
+ case "sv":
+ $locale = "sv_SE.UTF-8";
+ break;
+ case "nl":
+ $locale = "nl_NL.UTF-8";
+ break;
+ case "zh":
+ $locale = "zh_CN.UTF-8";
+ break;
+ case "cs":
+ $locale = "cs_CZ.UTF-8";
+ break;
+ case "ru":
+ $locale = "ru_RU.UTF-8";
+ break;
+ case "es":
+ $locale = "es_MX.UTF-8";
+ break;
+ case "fi":
+ $locale = "fi_FI.UTF-8";
+ break;
+ case "si":
+ $locale = "si_LK.UTF-8";
+ break;
+ default:
+ $locale = "en_GB.UTF-8";
+ break;
+ }
- $_SESSION['locale'] = $locale;
+ $_SESSION['locale'] = $locale;
}
// Note: the associated locale must be installed on the RPi
@@ -72,4 +70,3 @@ bindtextdomain(LOCALE_DOMAIN, LOCALE_ROOT);
bind_textdomain_codeset(LOCALE_DOMAIN, 'UTF-8');
textdomain(LOCALE_DOMAIN);
-
diff --git a/includes/networking.php b/includes/networking.php
index 25a40542..364e3e35 100755
--- a/includes/networking.php
+++ b/includes/networking.php
@@ -1,63 +1,64 @@
-
+
-
+
'.htmlspecialchars($interface, ENT_QUOTES).'
';
}
- ?>
+ ?>
@@ -110,11 +111,11 @@ function DisplayNetworkingConfig(){
';
- }
+}
?>
-
+
diff --git a/includes/status_messages.php b/includes/status_messages.php
index 5452baf9..8f639699 100755
--- a/includes/status_messages.php
+++ b/includes/status_messages.php
@@ -1,22 +1,30 @@
'. _($message);
- if ($dismissable) $status .= '
';
- $status .= '
';
+ public function addMessage($message, $level = 'success', $dismissable = true)
+ {
+ $status = '
'. _($message);
+ if ($dismissable) {
+ $status .= '';
+ }
+ $status .= '
';
- array_push($this->messages, $status);
- }
-
- public function showMessages($clear = true) {
- foreach($this->messages as $message) {
- echo $message;
+ array_push($this->messages, $status);
+ }
+
+ public function showMessages($clear = true)
+ {
+ foreach ($this->messages as $message) {
+ echo $message;
+ }
+ if ($clear) {
+ $this->messages = array();
+ }
}
- if ( $clear ) $this->messages = array();
- }
}
-?>
diff --git a/includes/system.php b/includes/system.php
index f5b23eca..0f4f0c2c 100755
--- a/includes/system.php
+++ b/includes/system.php
@@ -1,6 +1,6 @@
'Model B Revision 1.0',
'0003' => 'Model B Revision 1.0 + ECN0001',
'0004' => 'Model B Revision 2.0 (256 MB)',
@@ -40,39 +41,40 @@ function RPiVersion() {
'a220a0' => 'Compute Module 3',
'a020a0' => 'Compute Module 3',
'a02100' => 'Compute Module 3+',
- );
+ );
- $cpuinfo_array = '';
- exec('cat /proc/cpuinfo', $cpuinfo_array);
- $rev = trim(array_pop(explode(':',array_pop(preg_grep("/^Revision/", $cpuinfo_array)))));
- if (array_key_exists($rev, $revisions)) {
- return $revisions[$rev];
- } else {
- return 'Unknown Pi';
- }
+ $cpuinfo_array = '';
+ exec('cat /proc/cpuinfo', $cpuinfo_array);
+ $rev = trim(array_pop(explode(':', array_pop(preg_grep("/^Revision/", $cpuinfo_array)))));
+ if (array_key_exists($rev, $revisions)) {
+ return $revisions[$rev];
+ } else {
+ return 'Unknown Pi';
+ }
}
/**
*
*
*/
-function DisplaySystem(){
+function DisplaySystem()
+{
- $status = new StatusMessages();
+ $status = new StatusMessages();
- if( isset($_POST['SaveLanguage']) ) {
- if (CSRFValidate()) {
- if(isset($_POST['locale'])) {
- $_SESSION['locale'] = $_POST['locale'];
- $status->addMessage('Language setting saved', 'success');
- }
- } else {
- error_log('CSRF violation');
+ if (isset($_POST['SaveLanguage'])) {
+ if (CSRFValidate()) {
+ if (isset($_POST['locale'])) {
+ $_SESSION['locale'] = $_POST['locale'];
+ $status->addMessage('Language setting saved', 'success');
+ }
+ } else {
+ error_log('CSRF violation');
+ }
}
- }
- // define locales
- $arrLocales = array(
+ // define locales
+ $arrLocales = array(
'en_GB.UTF-8' => 'English',
'de_DE.UTF-8' => 'Deutsch',
'fr_FR.UTF-8' => 'Français',
@@ -86,40 +88,54 @@ function DisplaySystem(){
'es_MX.UTF-8' => 'Español',
'fi_FI.UTF-8' => 'Finnish',
'si_LK.UTF-8' => 'Sinhala'
- );
+ );
- // hostname
- exec("hostname -f", $hostarray);
- $hostname = $hostarray[0];
+ // hostname
+ exec("hostname -f", $hostarray);
+ $hostname = $hostarray[0];
- // uptime
- $uparray = explode(" ", exec("cat /proc/uptime"));
- $seconds = round($uparray[0], 0);
- $minutes = $seconds / 60;
- $hours = $minutes / 60;
- $days = floor($hours / 24);
- $hours = floor($hours - ($days * 24));
- $minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60));
- $uptime= '';
- if ($days != 0) { $uptime .= $days . ' day' . (($days > 1)? 's ':' '); }
- if ($hours != 0) { $uptime .= $hours . ' hour' . (($hours > 1)? 's ':' '); }
- if ($minutes != 0) { $uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' '); }
+ // uptime
+ $uparray = explode(" ", exec("cat /proc/uptime"));
+ $seconds = round($uparray[0], 0);
+ $minutes = $seconds / 60;
+ $hours = $minutes / 60;
+ $days = floor($hours / 24);
+ $hours = floor($hours - ($days * 24));
+ $minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60));
+ $uptime= '';
+ if ($days != 0) {
+ $uptime .= $days . ' day' . (($days > 1)? 's ':' ');
+ }
+ if ($hours != 0) {
+ $uptime .= $hours . ' hour' . (($hours > 1)? 's ':' ');
+ }
+ if ($minutes != 0) {
+ $uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' ');
+ }
- // mem used
- $memused_status = "primary";
- exec("free -m | awk '/Mem:/ { total=$2 ; 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"; }
+ // mem used
+ $memused_status = "primary";
+ exec("free -m | awk '/Mem:/ { total=$2 ; 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"; }
+ // 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";
+ }
?>
@@ -129,14 +145,14 @@ function DisplaySystem(){
' . _("System Rebooting Now!") . '
';
$result = shell_exec("sudo /sbin/reboot");
- }
- if (isset($_POST['system_shutdown'])) {
+}
+if (isset($_POST['system_shutdown'])) {
echo '
' . _("System Shutting Down Now!") . '
';
$result = shell_exec("sudo /sbin/shutdown -h now");
- }
+}
?>
@@ -187,7 +203,7 @@ function DisplaySystem(){
-
+
@@ -122,51 +122,51 @@ $theme_url = 'dist/css/'.htmlspecialchars($theme, ENT_QUOTES);
-
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -189,51 +189,51 @@ $theme_url = 'dist/css/'.htmlspecialchars($theme, ENT_QUOTES);
-
diff --git a/raspap.php b/raspap.php
index 3ec743da..9487720c 100755
--- a/raspap.php
+++ b/raspap.php
@@ -1,15 +1,14 @@
'admin',
- 'admin_pass' => '$2y$10$YKIyWAmnQLtiJAy6QgHQ.eCpY4m.HCEbiHaTgN6.acNC6bDElzt.i'
+ 'admin_user' => 'admin',
+ 'admin_pass' => '$2y$10$YKIyWAmnQLtiJAy6QgHQ.eCpY4m.HCEbiHaTgN6.acNC6bDElzt.i'
);
-if(file_exists(RASPI_CONFIG.'/raspap.auth')) {
- if ( $auth_details = fopen(RASPI_CONFIG.'/raspap.auth', 'r') ) {
- $config['admin_user'] = trim(fgets($auth_details));
- $config['admin_pass'] = trim(fgets($auth_details));
- fclose($auth_details);
+if (file_exists(RASPI_CONFIG.'/raspap.auth')) {
+ if ($auth_details = fopen(RASPI_CONFIG.'/raspap.auth', 'r')) {
+ $config['admin_user'] = trim(fgets($auth_details));
+ $config['admin_pass'] = trim(fgets($auth_details));
+ fclose($auth_details);
}
}
-?>