1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Fixed up a whole bunch of undefined variable warnings. Added a check to make sure raspap.auth exists before trying to include it.

This commit is contained in:
Lawrence 2017-10-02 03:10:04 +08:00
parent a6b1d85013
commit 61d450d1c7
5 changed files with 23 additions and 13 deletions

View File

@ -29,19 +29,19 @@ function DisplayDashboard(){
$strRxBytes = $result[1];
preg_match( '/TX Bytes:(\d+ \(\d+.\d+ [K|M|G]iB\))/i',$strWlan0,$result ) || $result[1] = 'No Data';
$strTxBytes = $result[1];
preg_match( '/ESSID:\"([a-zA-Z0-9\s]+)\"/i',$strWlan0,$result );
preg_match( '/ESSID:\"([a-zA-Z0-9\s]+)\"/i',$strWlan0,$result ) || $result[1] = 'Not connected';
$strSSID = str_replace( '"','',$result[1] );
preg_match( '/Access Point: ([0-9a-f:]+)/i',$strWlan0,$result );
preg_match( '/Access Point: ([0-9a-f:]+)/i',$strWlan0,$result ) || $result[1] = '';
$strBSSID = $result[1];
preg_match( '/Bit Rate=([0-9\.]+ Mb\/s)/i',$strWlan0,$result );
preg_match( '/Bit Rate=([0-9\.]+ Mb\/s)/i',$strWlan0,$result ) || $result[1] = '';
$strBitrate = $result[1];
preg_match( '/Tx-Power=([0-9]+ dBm)/i',$strWlan0,$result );
preg_match( '/Tx-Power=([0-9]+ dBm)/i',$strWlan0,$result ) || $result[1] = '';
$strTxPower = $result[1];
preg_match( '/Link Quality=([0-9]+)/i',$strWlan0,$result );
preg_match( '/Link Quality=([0-9]+)/i',$strWlan0,$result ) || $result[1] = '';
$strLinkQuality = $result[1];
preg_match( '/Signal level=(-?[0-9]+ dBm)/i',$strWlan0,$result );
preg_match( '/Signal level=(-?[0-9]+ dBm)/i',$strWlan0,$result ) || $result[1] = '';
$strSignalLevel = $result[1];
preg_match('/Frequency:(\d+.\d+ GHz)/i',$strWlan0,$result);
preg_match('/Frequency:(\d+.\d+ GHz)/i',$strWlan0,$result) || $result[1] = '';
$strFrequency = $result[1];
if(strpos( $strWlan0, "UP" ) !== false && strpos( $strWlan0, "RUNNING" ) !== false ) {

View File

@ -78,6 +78,10 @@ function DisplayDHCPConfig() {
$RangeMask = $arrRange[2];
preg_match( '/([0-9]*)([a-z])/i', $arrRange[3], $arrRangeLeaseTime );
$hselected = '';
$mselected = '';
$dselected = '';
switch( $arrRangeLeaseTime[2] ) {
case "h":
$hselected = " selected";

View File

@ -65,6 +65,7 @@ function DisplaySystem(){
if ($minutes != 0) { $uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' '); }
// mem used
$memused_status = "primary";
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"; }

View File

@ -19,7 +19,11 @@
*/
define('RASPI_CONFIG', '/etc/raspap');
define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth');
if(file_exists(RASPI_CONFIG.'/raspap.auth')) {
define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth');
} else {
define('RASPI_ADMIN_DETAILS','');
}
// Constants for configuration file paths.
// These are typical for default RPi installs. Modify if needed.

View File

@ -5,10 +5,11 @@ $config = array(
'admin_pass' => '$2y$10$YKIyWAmnQLtiJAy6QgHQ.eCpY4m.HCEbiHaTgN6.acNC6bDElzt.i'
);
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);
}
}
?>