From 4c67f54c99c6f38476538835c9c636ca4d1446ab Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sat, 2 Apr 2016 13:22:13 -0400 Subject: [PATCH 01/15] Added Gitter badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cf2e1bc2..9a4841f3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ Pi-hole Admin Dashboard ============ +[![Join the chat at https://gitter.im/pi-hole/AdminLTE](https://badges.gitter.im/pi-hole/AdminLTE.svg)](https://gitter.im/pi-hole/AdminLTE?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") Using **[AdminLTE](https://almsaeedstudio.com)**, this project will create a Web interface for the ad-blocking Pi-hole: **a black hole for Internet advertisements**. From 25bc98348feae0b6ae3d43518043ea526d6ca3c1 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 17 Apr 2016 20:44:07 +0100 Subject: [PATCH 02/15] Update README.md Update main page screenshot. (It was still showing white/blacklist links!) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a4841f3..640bcbca 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Using **[AdminLTE](https://almsaeedstudio.com)**, this project will create a Web From this interface, you will be able to see stats on how well your Pi-hole is performing. You will also be able to update the lists used to block ads. -![Pi-hole Web interface](http://i.imgur.com/FweAo36.png) +![Pi-hole Web interface](http://i.imgur.com/5lLAUGo.png) ![Fully responsive](http://i.imgur.com/fHuWR6E.png) ## API From b4938b0a73652471ad57df4f13c75ea60ba1d941 Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 16 Jun 2016 22:47:22 -0500 Subject: [PATCH 03/15] Added SERVER_NAME var check for CORS and refactor --- php/add.php | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/php/add.php b/php/add.php index d8bfe925..dbff2489 100644 --- a/php/add.php +++ b/php/add.php @@ -1,20 +1,42 @@ From 8ce2c289198db25c5eae331a458b112e549670f2 Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 16 Jun 2016 22:49:29 -0500 Subject: [PATCH 04/15] same changes to sub as last add commit --- php/sub.php | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/php/sub.php b/php/sub.php index cee19723..36082ac2 100644 --- a/php/sub.php +++ b/php/sub.php @@ -1,26 +1,50 @@ From 5d0a399796338d3e3f86d21535056ec452566b72 Mon Sep 17 00:00:00 2001 From: diginc Date: Tue, 28 Jun 2016 12:13:03 -0500 Subject: [PATCH 05/15] Remove SERVER_NAME var because of lighttpd bug lighttpd suffers from the same same bug/feature apache does, it fills SERVER_NAME in with the requested URL if connonical names and server side server name is not configured. No thanks. Nginx seems to have secure defaults. --- php/add.php | 1 - php/sub.php | 1 - 2 files changed, 2 deletions(-) diff --git a/php/add.php b/php/add.php index dbff2489..9ebea424 100644 --- a/php/add.php +++ b/php/add.php @@ -14,7 +14,6 @@ if(!isset($_POST['domain'], $_POST['list'], $_POST['token'])) { $SERVER_SIDE_IDS = [ $_SERVER['SERVER_ADDR'], - $_SERVER['SERVER_NAME'], 'pi.hole' ]; diff --git a/php/sub.php b/php/sub.php index 36082ac2..df12dedd 100644 --- a/php/sub.php +++ b/php/sub.php @@ -14,7 +14,6 @@ if(!isset($_POST['domain'], $_POST['list'], $_POST['token'])) { $SERVER_SIDE_IDS = [ $_SERVER['SERVER_ADDR'], - $_SERVER['SERVER_NAME'], 'pi.hole' ]; From fb18e6b535fb13b7825952e91e6afee04eb740be Mon Sep 17 00:00:00 2001 From: diginc Date: Tue, 28 Jun 2016 12:22:10 -0500 Subject: [PATCH 06/15] whitespace begone --- php/add.php | 4 ++-- php/sub.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/php/add.php b/php/add.php index 9ebea424..775f3d6c 100644 --- a/php/add.php +++ b/php/add.php @@ -24,7 +24,7 @@ if(in_array($_SERVER['HTTP_ORIGIN'], $SERVER_SIDE_IDS)) { } else if(in_array($_SERVER['HTTP_HOST'], $SERVER_SIDE_IDS)) { $CORS_ALLOW_ORIGIN = $_SERVER['HTTP_HOST']; } - + if (!$CORS_ALLOW_ORIGIN) die_and_log("Failed CORS"); @@ -38,7 +38,7 @@ if(!hash_equals($_SESSION['token'], $_POST['token'])) switch($_POST['list']) { - case "white": + case "white": echo exec("sudo pihole -w -q ${_POST['domain']}"); break; case "black": diff --git a/php/sub.php b/php/sub.php index df12dedd..9931bbe6 100644 --- a/php/sub.php +++ b/php/sub.php @@ -24,7 +24,7 @@ if(in_array($_SERVER['HTTP_ORIGIN'], $SERVER_SIDE_IDS)) { } else if(in_array($_SERVER['HTTP_HOST'], $SERVER_SIDE_IDS)) { $CORS_ALLOW_ORIGIN = $_SERVER['HTTP_HOST']; } - + if (!$CORS_ALLOW_ORIGIN) die_and_log("Failed CORS"); @@ -38,7 +38,7 @@ if(!hash_equals($_SESSION['token'], $_POST['token'])) switch($_POST['list']) { - case "white": + case "white": exec("sudo pihole -w -q ${_POST['domain']}"); break; case "black": From 435ba91d1802398f1ce84bd8779b2839718ed6a8 Mon Sep 17 00:00:00 2001 From: diginc Date: Tue, 28 Jun 2016 12:27:44 -0500 Subject: [PATCH 07/15] thought of a better variable name --- php/add.php | 6 +++--- php/sub.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/php/add.php b/php/add.php index 775f3d6c..2396214e 100644 --- a/php/add.php +++ b/php/add.php @@ -12,16 +12,16 @@ if(!isset($_POST['domain'], $_POST['list'], $_POST['token'])) { die_and_log("Missing POST variables"); } -$SERVER_SIDE_IDS = [ +$AUTHORIZED_HOSTNAMES = [ $_SERVER['SERVER_ADDR'], 'pi.hole' ]; // Check CORS $CORS_ALLOW_ORIGIN = false; -if(in_array($_SERVER['HTTP_ORIGIN'], $SERVER_SIDE_IDS)) { +if(in_array($_SERVER['HTTP_ORIGIN'], $AUTHORIZED_HOSTNAMES)) { $CORS_ALLOW_ORIGIN = $_SERVER['HTTP_ORIGIN']; -} else if(in_array($_SERVER['HTTP_HOST'], $SERVER_SIDE_IDS)) { +} else if(in_array($_SERVER['HTTP_HOST'], $AUTHORIZED_HOSTNAMES)) { $CORS_ALLOW_ORIGIN = $_SERVER['HTTP_HOST']; } diff --git a/php/sub.php b/php/sub.php index 9931bbe6..0bc82a2b 100644 --- a/php/sub.php +++ b/php/sub.php @@ -12,16 +12,16 @@ if(!isset($_POST['domain'], $_POST['list'], $_POST['token'])) { die_and_log("Missing POST variables"); } -$SERVER_SIDE_IDS = [ +$AUTHORIZED_HOSTNAMES = [ $_SERVER['SERVER_ADDR'], 'pi.hole' ]; // Check CORS $CORS_ALLOW_ORIGIN = false; -if(in_array($_SERVER['HTTP_ORIGIN'], $SERVER_SIDE_IDS)) { +if(in_array($_SERVER['HTTP_ORIGIN'], $AUTHORIZED_HOSTNAMES)) { $CORS_ALLOW_ORIGIN = $_SERVER['HTTP_ORIGIN']; -} else if(in_array($_SERVER['HTTP_HOST'], $SERVER_SIDE_IDS)) { +} else if(in_array($_SERVER['HTTP_HOST'], $AUTHORIZED_HOSTNAMES)) { $CORS_ALLOW_ORIGIN = $_SERVER['HTTP_HOST']; } From 9f8060f108c6b61d192333a84fb56127b31a6120 Mon Sep 17 00:00:00 2001 From: diginc Date: Tue, 28 Jun 2016 13:28:26 -0500 Subject: [PATCH 08/15] re-add -d flag that got lost somehow --- php/sub.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/sub.php b/php/sub.php index 0bc82a2b..7e6a0447 100644 --- a/php/sub.php +++ b/php/sub.php @@ -39,10 +39,10 @@ if(!hash_equals($_SESSION['token'], $_POST['token'])) switch($_POST['list']) { case "white": - exec("sudo pihole -w -q ${_POST['domain']}"); + exec("sudo pihole -w -q -d ${_POST['domain']}"); break; case "black": - exec("sudo pihole -b -q ${_POST['domain']}"); + exec("sudo pihole -b -q -d ${_POST['domain']}"); break; } From 77395a3e72b9b20adf16f89c8ad035a09ed9393f Mon Sep 17 00:00:00 2001 From: diginc Date: Tue, 5 Jul 2016 23:36:02 -0500 Subject: [PATCH 09/15] gitignore vim swap files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 97f0d215..a4c3ecb8 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ test.html *.ipr *.iws +# vim +*.swp From 657fb7badc23410a81d8946064ace3391c431c6d Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 7 Jul 2016 00:12:35 -0500 Subject: [PATCH 10/15] Fixes and refactoring WL/BL files more * CORS was required to auth (bug) - fixed * Logging defaults to the default lighttpd error log * Overridable error log location to support alpine/nginx container or power users * Put the repeated code into a include for sub/add, auth.php * Error logs say what failed much better now * VIRTUAL_HOST should theoretically allow custom hostnames for CORS --- php/add.php | 40 +--------------------------------------- php/auth.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ php/sub.php | 41 +---------------------------------------- 3 files changed, 51 insertions(+), 79 deletions(-) create mode 100644 php/auth.php diff --git a/php/add.php b/php/add.php index 592f61c8..ae7da1a1 100644 --- a/php/add.php +++ b/php/add.php @@ -1,43 +1,5 @@ diff --git a/php/sub.php b/php/sub.php index d9d94814..e4f02918 100644 --- a/php/sub.php +++ b/php/sub.php @@ -1,44 +1,5 @@ Date: Thu, 7 Jul 2016 23:30:58 -0500 Subject: [PATCH 11/15] cleanup and tested on alpine/debian --- php/auth.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/php/auth.php b/php/auth.php index 845ddcb3..621e2f3d 100644 --- a/php/auth.php +++ b/php/auth.php @@ -1,10 +1,8 @@ - From 246599a0ba46f2f63659ba231341b03472ecf9ea Mon Sep 17 00:00:00 2001 From: diginc Date: Fri, 8 Jul 2016 08:23:12 -0500 Subject: [PATCH 12/15] Don't need docker server IP in here anymore --- php/auth.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/php/auth.php b/php/auth.php index 621e2f3d..6dc8388d 100644 --- a/php/auth.php +++ b/php/auth.php @@ -25,11 +25,6 @@ $virtual_host = getenv('VIRTUAL_HOST'); if (! empty($virtual_host)) array_push($AUTHORIZED_HOSTNAMES, 'http://' . $virtual_host); -# For docker container's host IP, SERVER_ADDR will be docker0 interface ip -$server_ip = getenv('ServerIP'); -if (! empty($server_ip)) - array_push($AUTHORIZED_HOSTNAMES, 'http://' . $server_ip); - // Check CORS if(isset($_SERVER['HTTP_ORIGIN'])) { if(in_array($_SERVER['HTTP_ORIGIN'], $AUTHORIZED_HOSTNAMES)) { From b6e177de6c1f4ed6457e90d03a009515a527891c Mon Sep 17 00:00:00 2001 From: diginc Date: Mon, 18 Jul 2016 21:04:17 -0500 Subject: [PATCH 13/15] Set a default error log when empty --- php/auth.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/php/auth.php b/php/auth.php index 6dc8388d..442ccdb3 100644 --- a/php/auth.php +++ b/php/auth.php @@ -1,5 +1,8 @@ Date: Mon, 18 Jul 2016 21:38:48 -0500 Subject: [PATCH 14/15] semicolon because php --- php/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/auth.php b/php/auth.php index 442ccdb3..1447296f 100644 --- a/php/auth.php +++ b/php/auth.php @@ -1,7 +1,7 @@ Date: Wed, 20 Jul 2016 13:34:53 +0100 Subject: [PATCH 15/15] Devel out of sync with master (#117) * Added Gitter badge * Update README.md Update main page screenshot. (It was still showing white/blacklist links!) --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf2e1bc2..640bcbca 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ Pi-hole Admin Dashboard ============ +[![Join the chat at https://gitter.im/pi-hole/AdminLTE](https://badges.gitter.im/pi-hole/AdminLTE.svg)](https://gitter.im/pi-hole/AdminLTE?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif "AdminLTE Presentation")](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate") Using **[AdminLTE](https://almsaeedstudio.com)**, this project will create a Web interface for the ad-blocking Pi-hole: **a black hole for Internet advertisements**. From this interface, you will be able to see stats on how well your Pi-hole is performing. You will also be able to update the lists used to block ads. -![Pi-hole Web interface](http://i.imgur.com/FweAo36.png) +![Pi-hole Web interface](http://i.imgur.com/5lLAUGo.png) ![Fully responsive](http://i.imgur.com/fHuWR6E.png) ## API