Skip to content

Commit 61cc6a0

Browse files
authored
Merge pull request #245 from pi-hole/devel
Pi-Hole Web Admin Release v2.0
2 parents 3e6955d + fa1642d commit 61cc6a0

File tree

1,426 files changed

+4725
-57862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,426 files changed

+4725
-57862
lines changed

.pullapprove.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ groups:
2525
- devel
2626
required: 2
2727
teams:
28-
- dashboard
28+
- approvers
2929

3030
master:
3131
approve_by_comment:
3232
enabled: true
3333
conditions:
3434
branches:
3535
- master
36-
required: 3
36+
required: -1
3737
teams:
38-
- dashboard
38+
- admin

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ A read-only API can be accessed at `/admin/api.php`. With either no parameters o
2323
```
2424

2525
There are many more parameters, such as `summaryRaw`, `overTimeData`, `topItems`, `recentItems`, `getQueryTypes`, `getForwardDestinations`, `getQuerySources`, and finally `getAllQueries`.
26+
27+
`getAllQueries` can optionally be set with one of these values to return JSON hash ordered as value implies: `orderByClientDomainTime`, `orderByClientTimeDomain`, `orderByTimeClientDomain`, `orderByTimeDomainClient`, `orderByDomainClientTime` or `orderByDomainTimeClient`.

api.php

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
<?php
2+
$api = true;
3+
require "php/password.php";
4+
require "php/auth.php";
5+
6+
check_cors();
7+
28
include('data.php');
39
header('Content-type: application/json');
410

511
$data = array();
612

13+
// Non-Auth
14+
715
if (isset($_GET['summaryRaw'])) {
816
$data = array_merge($data, getSummaryData());
917
}
@@ -21,44 +29,77 @@
2129
$data = array_merge($data, getOverTimeData());
2230
}
2331

24-
if (isset($_GET['topItems'])) {
32+
if (isset($_GET['overTimeData10mins'])) {
33+
$data = array_merge($data, getOverTimeData10mins());
34+
}
35+
36+
// Auth Required
37+
38+
if (isset($_GET['topItems']) && $auth) {
2539
$data = array_merge($data, getTopItems());
2640
}
2741

28-
if (isset($_GET['recentItems'])) {
42+
if (isset($_GET['recentItems']) && $auth) {
2943
if (is_numeric($_GET['recentItems'])) {
3044
$data = array_merge($data, getRecentItems($_GET['recentItems']));
3145
}
3246
}
3347

34-
if (isset($_GET['getQueryTypes'])) {
48+
if (isset($_GET['getQueryTypes']) && $auth) {
3549
$data = array_merge($data, getIpvType());
3650
}
3751

38-
if (isset($_GET['getForwardDestinations'])) {
52+
if (isset($_GET['getForwardDestinations']) && $auth) {
3953
$data = array_merge($data, getForwardDestinations());
4054
}
4155

42-
if (isset($_GET['getQuerySources'])) {
56+
if (isset($_GET['getQuerySources']) && $auth) {
4357
$data = array_merge($data, getQuerySources());
4458
}
4559

46-
if (isset($_GET['getAllQueries'])) {
47-
$data = array_merge($data, getAllQueries());
60+
if (isset($_GET['getAllQueries']) && $auth) {
61+
$data = array_merge($data, getAllQueries($_GET['getAllQueries']));
4862
}
4963

50-
function filterArray(&$a) {
51-
$sanArray = array();
52-
foreach ($a as $k=>$v) {
53-
if (is_array($v)) {
54-
$sanArray[htmlspecialchars($k)] = filterArray($v);
64+
if (isset($_GET['enable'], $_GET['token']) && $auth) {
65+
check_csrf($_GET['token']);
66+
exec('sudo pihole enable');
67+
$data = array_merge($data, Array(
68+
"status" => "enabled"
69+
));
70+
}
71+
elseif (isset($_GET['disable'], $_GET['token']) && $auth) {
72+
check_csrf($_GET['token']);
73+
exec('sudo pihole disable');
74+
$data = array_merge($data, Array(
75+
"status" => "disabled"
76+
));
77+
}
78+
79+
if (isset($_GET['getGravityDomains'])) {
80+
$data = array_merge($data, getGravity());
81+
}
82+
83+
function filterArray(&$inArray) {
84+
$outArray = array();
85+
foreach ($inArray as $key=>$value) {
86+
if (is_array($value)) {
87+
$outArray[htmlspecialchars($key)] = filterArray($value);
5588
} else {
56-
$sanArray[htmlspecialchars($k)] = htmlspecialchars($v);
89+
$outArray[htmlspecialchars($key)] = htmlspecialchars($value);
5790
}
5891
}
59-
return $sanArray;
92+
return $outArray;
6093
}
61-
94+
6295
$data = filterArray($data);
63-
echo json_encode($data);
96+
97+
if(isset($_GET["jsonForceObject"]))
98+
{
99+
echo json_encode($data, JSON_FORCE_OBJECT);
100+
}
101+
else
102+
{
103+
echo json_encode($data);
104+
}
64105
?>

css/font-awesome-4.5.0/HELP-US-OUT.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)