From 8479530c67738a005b4707f6f2eb04387723d8f4 Mon Sep 17 00:00:00 2001 From: Brice Johnson Date: Sat, 9 Jan 2016 20:04:24 -0600 Subject: [PATCH 1/6] Added basic read-only api --- api.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 api.php diff --git a/api.php b/api.php new file mode 100644 index 00000000..0611d835 --- /dev/null +++ b/api.php @@ -0,0 +1,15 @@ + $domains_being_blocked, + 'dns_queries_today' => $dns_queries_today, + 'ads_blocked_today' => $ads_blocked_today, + 'ads_percentage_today' => $ads_percentage_today + ); + + header('Content-type: application/json'); + echo json_encode($arr); +?> From fc339659069f52b74f951e3090ee47533cae0480 Mon Sep 17 00:00:00 2001 From: Brice Johnson Date: Sat, 9 Jan 2016 20:10:02 -0600 Subject: [PATCH 2/6] Added documentation for API --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e50c8356..7f782af9 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,15 @@ 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/x2iMfoc.png) -![Fully responsive](http://i.imgur.com/NyAIXm8.png) \ No newline at end of file +![Fully responsive](http://i.imgur.com/NyAIXm8.png) + +## API +A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON: +```JSON +{ + "domains_being_blocked": "136708", + "dns_queries_today": "18108", + "ads_blocked_today": "14648", + "ads_percentage_today": 80.892423238348 +} +``` From e36ced86d42c8520020916f3020ef45fbaa9ced4 Mon Sep 17 00:00:00 2001 From: Jacob Salmela Date: Sun, 10 Jan 2016 21:58:33 -0600 Subject: [PATCH 3/6] fixes #8 --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index 4b6bcf40..0113a6d9 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ Date: Mon, 18 Jan 2016 12:55:21 -0500 Subject: [PATCH 4/6] Update index.php --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index 0113a6d9..b5000fe0 100644 --- a/index.php +++ b/index.php @@ -185,7 +185,7 @@
Donate if you found this useful.
From 46a7bac6e48f1ad2518b45ec2bfb3d6c41e4ad9d Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 18 Jan 2016 23:04:03 +0000 Subject: [PATCH 5/6] Update api.php Consume JSON output of chronometer.sh Relies on [this pull](https://github.com/jacobsalmela/pi-hole/pull/193) being merged. --- api.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/api.php b/api.php index 0611d835..6ad9845d 100644 --- a/api.php +++ b/api.php @@ -1,15 +1,3 @@ - $domains_being_blocked, - 'dns_queries_today' => $dns_queries_today, - 'ads_blocked_today' => $ads_blocked_today, - 'ads_percentage_today' => $ads_percentage_today - ); - - header('Content-type: application/json'); - echo json_encode($arr); + From 6685d7bde04ee5dfd94173ac842d6017bd4ad060 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 18 Jan 2016 23:04:37 +0000 Subject: [PATCH 6/6] Update index.php Consume JSON output of chronometer.sh Relies on [this pull](jacobsalmela/pi-hole#193) being merged. --- index.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 0113a6d9..a67b1037 100644 --- a/index.php +++ b/index.php @@ -1,8 +1,10 @@ domains_being_blocked; + $dns_queries_today = $outj->dns_queries_today; + $ads_blocked_today = $outj->ads_blocked_today; + $ads_percentage_today = $outj->ads_percentage_today; ?>