diff --git a/README.md b/README.md index 0c6ed044..653824e2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![](http://i.imgur.com/xeKD93p.png) # `$ raspap-webgui` [![Release 1.2.1](https://img.shields.io/badge/Release-1.2.1-green.svg)](https://github.com/billz/raspap-webgui/releases) -A simple, responsive web interface t:o control wifi, hostapd and related services on the Raspberry Pi. +A simple, responsive web interface to control wifi, hostapd and related services on the Raspberry Pi. This project was inspired by a [**blog post**](http://sirlagz.net/2013/02/06/script-web-configuration-page-for-raspberry-pi/) by SirLagz about using a web page rather than ssh to configure wifi and hostapd settings on the Raspberry Pi. I mostly just prettified the UI by wrapping it in [**SB Admin 2**](https://github.com/BlackrockDigital/startbootstrap-sb-admin-2), a Bootstrap based admin theme. diff --git a/dist/css/custom.css b/dist/css/custom.css index c4994797..17126ae5 100644 --- a/dist/css/custom.css +++ b/dist/css/custom.css @@ -48,3 +48,8 @@ height:100%; min-height:500px; } + +.logoutput { + width:100%; + height:300px; +} diff --git a/dist/css/hackernews.css b/dist/css/hackernews.css index d6bb7b4d..19836947 100644 --- a/dist/css/hackernews.css +++ b/dist/css/hackernews.css @@ -76,3 +76,8 @@ h4 { width: 140px; float: left; } + +.logoutput { + width: 100%; + height: 300px; +} diff --git a/dist/css/terminal.css b/dist/css/terminal.css index d7896dd8..f3d04fbf 100644 --- a/dist/css/terminal.css +++ b/dist/css/terminal.css @@ -196,4 +196,9 @@ a:focus, a:hover { float: left; } - +.logoutput { + width: 100%; + height: 300px; + background-color: #000; + border-color: #33ff00; +} diff --git a/includes/functions.php b/includes/functions.php index f391e461..ebcb8791 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -1,4 +1,52 @@ $val) { + if(is_array($val)) { + $res[] = "[$key]"; + foreach($val as $skey => $sval) $res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"'); + } + else $res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"'); + } + if(safefilerewrite($file, implode("\r\n", $res))) { + return true; + } else { + return false; + } +} + +function safefilerewrite($fileName, $dataToSave) { + if ($fp = fopen($fileName, 'w')) { + $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)); + + //file was locked so now we can store information + if ($canWrite) { + fwrite($fp, $dataToSave); + flock($fp, LOCK_UN); + } + fclose($fp); + return true; + } else { + return false; + } +} + + /** * diff --git a/includes/hostapd.php b/includes/hostapd.php index 38a64b4e..87520f06 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -10,6 +10,8 @@ function DisplayHostAPDConfig(){ $status = new StatusMessages(); + $arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini'); + $arrConfig = array(); $arrChannel = array('a','b','g'); $arrSecurity = array( 1 => 'WPA', 2 => 'WPA2',3=> 'WPA+WPA2'); @@ -74,6 +76,7 @@ function DisplayHostAPDConfig(){