From 508110a9c0e4763e54e6b7b9c88f908e8e91c11e Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 6 Oct 2017 23:08:06 +0000 Subject: [PATCH 1/9] Support for themes --- dist/css/hackernews.css | 78 +++++++++++++++++++ dist/css/terminal.css | 168 ++++++++++++++++++++++++++++++++++++++++ dist/js/sb-admin-2.js | 28 ++++++- includes/themes.php | 47 +++++++++++ index.php | 15 +++- 5 files changed, 332 insertions(+), 4 deletions(-) create mode 100644 dist/css/hackernews.css create mode 100644 dist/css/terminal.css create mode 100644 includes/themes.php diff --git a/dist/css/hackernews.css b/dist/css/hackernews.css new file mode 100644 index 00000000..d6bb7b4d --- /dev/null +++ b/dist/css/hackernews.css @@ -0,0 +1,78 @@ +html * { + font-family: Verdana, Geneva, sans-serif; + font-size: 10pt; + color: #828282; +} + +.nav>li>a { + font-size: 12pt; +} + +a:focus, a:hover { + color: #666; +} + +h4 { + font-size: 18px; +} + +.panel { + border-radius: 1px; +} + +.panel-primary { + border-color: #ff6600; +} + +.panel-primary>.panel-heading { + border-color: #ff6600; + background-color: #ff6600; + color: #000; + font-size: 14pt; + font-weight: bold; +} + +.panel-heading { + border-top-left-radius: 1px; + border-top-right-radius: 1px; +} + +.panel-primary>.panel-heading .fa { + color: #fff; +} + +.page-header { + font-size: 26pt; + margin: 10px 0 20px; +} + +#wrapper,#page-wrapper,.panel-body,.nav>li>a,.navbar-default { + background-color: #f6f6ef; +} + +.panel-footer { + background-color: #eee; +} + +.btn-primary.btn-outline { + color: #c61931; + border-color: #c61931; +} + +.btn-primary:hover { + background-color: #c61931; + border-color: #c61931; +} + +.progress { + background-color: #eee; +} + +.progress-bar { + color: #eee; +} + +.info-item { + width: 140px; + float: left; +} diff --git a/dist/css/terminal.css b/dist/css/terminal.css new file mode 100644 index 00000000..ae6f35c4 --- /dev/null +++ b/dist/css/terminal.css @@ -0,0 +1,168 @@ +html * { + font-family: Courier New, Andale Mono, monospace; + font-size: 10pt; + color: #33ff00; +} + +#page-wrapper { + padding: 0 20px; + border-left: 1px solid #33ff00; +} + +.nav>li>a { + font-size: 10pt; +} + +.nav>li>a:focus, .nav>li>a:hover { + background-color: #000; +} + +.nav-tabs>li.active>a, .nav-tabs>li.active>a:focus, .nav-tabs>li.active>a:hover { + color: #33ff00; + cursor: default; + background-color: #000; + border: 1px solid #33ff00; + border-bottom-color: #33ff00; +} + +.nav-tabs>li>a,.nav-tabs>li>a:hover { + border: 1px solid #33ff00; +} + +.nav-tabs { + border-bottom: 1px solid #33ff00; +} + +.navbar-default { + border-color: #33ff00; +} + +.navbar-default .navbar-brand, .navbar-default .navbar-brand:hover { + color: #33ff00; +} + +.logo { + visibility: collapse; + width: 0px; +} + +a:focus, a:hover { + color: #33ff00; +} + +.panel-primary { + border-color: #33ff00; +} + +.panel-primary>.panel-heading { + border-color: #33ff00; + background-color: #33ff00; + color: #000; + font-size: 12pt; +} + +.panel-primary>.panel-heading .fa { + color: #000; +} + +.panel { + margin-bottom: 20px; + border: 1px solid #33ff00; + border-radius: 0px; +} + +.page-header { + font-size: 24pt; + margin: 10px 0 20px; + border-bottom: 1px solid #33ff00; +} + +#wrapper,#page-wrapper,.panel-body,.nav>li>a,.navbar-default { + background-color: #000; +} + +.panel-footer { + background-color: #000; + border-top: 1px solid #33ff00; +} + +.sidebar ul li a.active,.sidebar ul li a.hover { + background-color: #000; +} + +.sidebar ul li { + border-bottom: 1px solid #33ff00; +} + +.btn-primary.btn-outline,.btn-warning { + color: #33ff00; + border-color: #33ff00; +} + +.btn-primary:hover,.btn-primary:focus,.btn-warning:hover,.btn-warning:focus,.btn-primary:active { + color: #33ff00; + background-color: #000; + border-color: #33ff00; +} + +.btn-primary.btn-outline:hover,.btn-success, .btn-success.btn-outline:hover, .btn-info.btn-outline:hover, .btn-warning.btn-outline:hover, .btn-danger.btn-outline:hover { + color: #33ff00; +} + +.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th { + background-color: #000; + border-top: 1px solid #000; +} + +.btn-info, .btn-info:hover, .btn-info[disabled], .btn-danger.disabled, .btn-danger.disabled.active, .btn-danger.disabled.focus, .btn-danger.disabled:active, .btn-danger.disabled:focus, .btn-danger.disabled:hover, .btn-danger[disabled], .btn-danger[disabled].active, .btn-danger[disabled].focus, .btn-danger[disabled]:active, .btn-danger[disabled]:focus, .btn-danger[disabled]:hover, fieldset[disabled] .btn-danger, fieldset[disabled] .btn-danger.active, fieldset[disabled] .btn-danger.focus, fieldset[disabled] .btn-danger:active, fieldset[disabled] .btn-danger:focus, fieldset[disabled] .btn-danger:hover, .btn-info:hover { + background-color: #000; + border-color: #33ff00; + color: #33ff00; +} + +.btn { + background-color: #000; + border-radius: 0px; +} + +.alert { + border-radius: 0px; +} + +.alert-success,.alert-warning,.alert-ifo,.alert-dismissable { + color: #33ff00; + background-color: #000; + border-color: #33ff00; + border: 1px dashed; +} + +.close { + font-size: 18px; + font-weight: normal; + text-shadow: 0 0px 0 #000; + opacity: 1; +} + +.form-control, .form-control:focus { + color: #33ff00; + background-color: #000; + border: 1px solid #33ff00; + border-radius: 0px; + transition: unset; +} + +.progress { + background-color: #000; + border-radius: 0px; +} + +.progress-bar { + color: #000; +} + +.info-item { + width: 140px; + float: left; +} + + diff --git a/dist/js/sb-admin-2.js b/dist/js/sb-admin-2.js index 5be2c883..3bbc30da 100755 --- a/dist/js/sb-admin-2.js +++ b/dist/js/sb-admin-2.js @@ -1,9 +1,30 @@ $(function() { - - $('#side-menu').metisMenu(); - + $('#theme-select').change(function() { + var theme = themes[$( "#theme-select" ).val() ]; + set_theme(theme); + }); }); +function set_theme(theme) { + $('link[title="main"]').attr('href', theme); + + // persist selected theme in cookie + setCookie('theme',theme,90); +} + +function setCookie(cname, cvalue, exdays) { + var d = new Date(); + d.setTime(d.getTime() + (exdays*24*60*60*1000)); + var expires = "expires="+ d.toUTCString(); + document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; +} + +var themes = { + "default": "dist/css/custom.css", + "hackernews" : "dist/css/hackernews.css", + "terminal" : "dist/css/terminal.css", +} + //Loads the correct sidebar on window load, //collapses the sidebar on window resize. // Sets the min-height of #page-wrapper to window size @@ -34,3 +55,4 @@ $(function() { element.addClass('active'); } }); + diff --git a/includes/themes.php b/includes/themes.php new file mode 100644 index 00000000..0b502341 --- /dev/null +++ b/includes/themes.php @@ -0,0 +1,47 @@ + +
+
+
+
Change Theme
+
+
+
+
+
+

Theme settings

+ +
+
+ + +
+
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ + diff --git a/index.php b/index.php index ac9af9f8..f11a2956 100755 --- a/index.php +++ b/index.php @@ -50,6 +50,7 @@ include_once( 'includes/dhcp.php' ); include_once( 'includes/hostapd.php' ); include_once( 'includes/system.php' ); include_once( 'includes/configure_client.php' ); +include_once( 'includes/themes.php' ); $output = $return = 0; $page = $_GET['page']; @@ -63,6 +64,12 @@ if (empty($_SESSION['csrf_token'])) { } } $csrf_token = $_SESSION['csrf_token']; + +if(!isset($_COOKIE['theme'])) { + $theme_url = "dist/css/custom.css"; +} else { + $theme_url = $_COOKIE['theme']; +} ?> @@ -95,7 +102,7 @@ $csrf_token = $_SESSION['csrf_token']; - + @@ -150,6 +157,9 @@ $csrf_token = $_SESSION['csrf_token'];
  • Configure Auth
  • +
  • + Change Theme +
  • System
  • @@ -196,6 +206,9 @@ $csrf_token = $_SESSION['csrf_token']; case "save_hostapd_conf": SaveTORAndVPNConfig(); break; + case "theme_conf": + DisplayThemeConfig(); + break; case "system_info": DisplaySystem(); break; From 63dc84764fed778900144f626d3e881b0c2d525d Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 6 Oct 2017 23:18:42 +0000 Subject: [PATCH 2/9] Removed inline style --- includes/hostapd.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/hostapd.php b/includes/hostapd.php index 98a1d31d..ece1a83d 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -136,7 +136,7 @@ function DisplayHostAPDConfig(){
    - From faeaa99a144c042622976544392e61686e7157b8 Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 6 Oct 2017 23:22:04 +0000 Subject: [PATCH 3/9] Updated for minor version release --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dcb6f49a..0c6ed044 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![](http://i.imgur.com/xeKD93p.png) -# `$ raspap-webgui` [![Release 1.2.0](https://img.shields.io/badge/Release-1.2.0-green.svg)](https://github.com/billz/raspap-webgui/releases) -A simple, responsive web interface to control wifi, hostapd and related services on the Raspberry Pi. +# `$ 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. 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. From 557a0b6ce0419d133d03e4c6432e3532eb2e5fbb Mon Sep 17 00:00:00 2001 From: billz Date: Fri, 6 Oct 2017 23:46:58 +0000 Subject: [PATCH 4/9] Added VT100 scan line effect --- dist/css/terminal.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dist/css/terminal.css b/dist/css/terminal.css index ae6f35c4..c5c8a8ab 100644 --- a/dist/css/terminal.css +++ b/dist/css/terminal.css @@ -86,6 +86,20 @@ a:focus, a:hover { border-top: 1px solid #33ff00; } +.panel-primary>.panel-heading::before, .navbar-default::before { + content: " "; + display: block; + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06)); + z-index: 2; + background-size: 100% 2px, 3px 100%; + pointer-events: none; +} + .sidebar ul li a.active,.sidebar ul li a.hover { background-color: #000; } From f6c983d8fff2a8b5ca1fbf039e64aa10b12a3136 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 9 Oct 2017 08:49:12 +0000 Subject: [PATCH 5/9] Applied missing style to th element --- dist/css/terminal.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dist/css/terminal.css b/dist/css/terminal.css index c5c8a8ab..75454e6b 100644 --- a/dist/css/terminal.css +++ b/dist/css/terminal.css @@ -128,6 +128,11 @@ a:focus, a:hover { border-top: 1px solid #000; } +.table>thead>tr>th { + vertical-align: bottom; + border-bottom: 1px solid #33ff00; +} + .btn-info, .btn-info:hover, .btn-info[disabled], .btn-danger.disabled, .btn-danger.disabled.active, .btn-danger.disabled.focus, .btn-danger.disabled:active, .btn-danger.disabled:focus, .btn-danger.disabled:hover, .btn-danger[disabled], .btn-danger[disabled].active, .btn-danger[disabled].focus, .btn-danger[disabled]:active, .btn-danger[disabled]:focus, .btn-danger[disabled]:hover, fieldset[disabled] .btn-danger, fieldset[disabled] .btn-danger.active, fieldset[disabled] .btn-danger.focus, fieldset[disabled] .btn-danger:active, fieldset[disabled] .btn-danger:focus, fieldset[disabled] .btn-danger:hover, .btn-info:hover { background-color: #000; border-color: #33ff00; From 8a501c075f3c28089ea9622e700ffce3ef70ac0a Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 9 Oct 2017 14:04:59 +0000 Subject: [PATCH 6/9] Persist selected theme in dropdown --- dist/js/sb-admin-2.js | 8 ++++---- includes/themes.php | 24 ++++++++++++++++++++---- index.php | 5 +++-- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/dist/js/sb-admin-2.js b/dist/js/sb-admin-2.js index 3bbc30da..ce024e24 100755 --- a/dist/js/sb-admin-2.js +++ b/dist/js/sb-admin-2.js @@ -6,7 +6,7 @@ $(function() { }); function set_theme(theme) { - $('link[title="main"]').attr('href', theme); + $('link[title="main"]').attr('href', 'dist/css/' + theme); // persist selected theme in cookie setCookie('theme',theme,90); @@ -20,9 +20,9 @@ function setCookie(cname, cvalue, exdays) { } var themes = { - "default": "dist/css/custom.css", - "hackernews" : "dist/css/hackernews.css", - "terminal" : "dist/css/terminal.css", + "default": "custom.css", + "hackernews" : "hackernews.css", + "terminal" : "terminal.css", } //Loads the correct sidebar on window load, diff --git a/includes/themes.php b/includes/themes.php index 0b502341..44af3511 100644 --- a/includes/themes.php +++ b/includes/themes.php @@ -5,6 +5,22 @@ */ function DisplayThemeConfig(){ + $cselected = ''; + $hselected = ''; + $tselected = ''; + + switch( $_COOKIE['theme'] ) { + case "custom.css": + $cselected = "selected"; + break; + case "hackernews.css": + $hselected = "selected"; + break; + case "terminal.css": + $tselected = "selected"; + break; + } + ?>
    @@ -20,10 +36,10 @@ function DisplayThemeConfig(){
    - Select a Theme + + +
    diff --git a/index.php b/index.php index f11a2956..5ed8a06b 100755 --- a/index.php +++ b/index.php @@ -66,10 +66,11 @@ if (empty($_SESSION['csrf_token'])) { $csrf_token = $_SESSION['csrf_token']; if(!isset($_COOKIE['theme'])) { - $theme_url = "dist/css/custom.css"; + $theme = "custom.css"; } else { - $theme_url = $_COOKIE['theme']; + $theme = $_COOKIE['theme']; } +$theme_url = 'dist/css/' . $theme; ?> From 822136bf03dc53780ba1de8ef896694de709c9e0 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 9 Oct 2017 22:26:21 +0000 Subject: [PATCH 7/9] Applied style to navbar toggle --- dist/css/terminal.css | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dist/css/terminal.css b/dist/css/terminal.css index 75454e6b..d7896dd8 100644 --- a/dist/css/terminal.css +++ b/dist/css/terminal.css @@ -41,6 +41,18 @@ html * { color: #33ff00; } +.navbar-default .navbar-toggle { + border-color: #33ff00; +} + +.navbar-default .navbar-toggle .icon-bar { + background-color: #33ff00; +} + +.navbar-default .navbar-toggle:focus, .navbar-default .navbar-toggle:hover { + background-color: #000; +} + .logo { visibility: collapse; width: 0px; From a24d3d8f86dbc7d80645808888bf3afb035a246b Mon Sep 17 00:00:00 2001 From: Lawrence Date: Sat, 14 Oct 2017 11:36:42 +0800 Subject: [PATCH 8/9] Moved RASPI_ADMIN_DETAILS file check to the admin.php page which will now create the file if it doesn't exist - to resolve #116. Commented out check on index.php --- includes/admin.php | 4 ++++ index.php | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 9bf19620..ea2ede1f 100755 --- a/includes/admin.php +++ b/includes/admin.php @@ -13,6 +13,10 @@ function DisplayAuthConfig($username, $password){ } else if ($new_username == '') { $status->addMessage('Username must not be empty', 'danger'); } else { + if (!file_exists(RASPI_ADMIN_DETAILS)) { + $tmpauth = fopen(RASPI_ADMIN_DETAILS, 'w'); + fclose($tmpauth); + } if ($auth_file = fopen(RASPI_ADMIN_DETAILS, 'w')) { fwrite($auth_file, $new_username.PHP_EOL); fwrite($auth_file, password_hash($_POST['newpass'], PASSWORD_BCRYPT).PHP_EOL); diff --git a/index.php b/index.php index 5ed8a06b..15994036 100755 --- a/index.php +++ b/index.php @@ -19,11 +19,13 @@ */ define('RASPI_CONFIG', '/etc/raspap'); -if(file_exists(RASPI_CONFIG.'/raspap.auth')) { - define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth'); -} else { - define('RASPI_ADMIN_DETAILS',''); -} +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. From a0a4f842b4d3606008d47e64f196f9eefa8b2995 Mon Sep 17 00:00:00 2001 From: Lawrence Date: Sun, 22 Oct 2017 19:46:52 +0800 Subject: [PATCH 9/9] Updating install script and removing unneeded configuration file --- config/rc.local | 24 ------------------------ installers/common.sh | 1 - 2 files changed, 25 deletions(-) delete mode 100755 config/rc.local diff --git a/config/rc.local b/config/rc.local deleted file mode 100755 index 9abe1ac9..00000000 --- a/config/rc.local +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -e -# -# rc.local -# -# This script is executed at the end of each multiuser runlevel. -# Make sure that the script will "exit 0" on success or any other -# value on error. -# -# In order to enable or disable this script just change the execution -# bits. -# -# By default this script does nothing. - -# Print the IP address -_IP=$(hostname -I) || true -if [ "$_IP" ]; then - printf "My IP address is %s\n" "$_IP" -fi - -# Set up IP forwarding and NAT routing -echo 1 > /proc/sys/net/ipv4/ip_forward -iptables -t nat -A POSTROUTING -j MASQUERADE - -exit 0 diff --git a/installers/common.sh b/installers/common.sh index 009c63fc..f1eb7004 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -160,7 +160,6 @@ function default_configuration() { sudo mv $webroot_dir/config/hostapd.conf /etc/hostapd/hostapd.conf || install_error "Unable to move hostapd configuration file" sudo mv $webroot_dir/config/dnsmasq.conf /etc/dnsmasq.conf || install_error "Unable to move dnsmasq configuration file" sudo mv $webroot_dir/config/dhcpcd.conf /etc/dhcpcd.conf || install_error "Unable to move dhcpcd configuration file" - #sudo mv $webroot_dir/config/rc.local /etc/rc.local || install_error "Unable to move rc.local file" # Generate required lines for Rasp AP to place into rc.local file. # #RASPAP is for removal script