Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
AzureMarker committed Mar 24, 2016
2 parents 4f20cc6 + 991d273 commit a5e2008
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 751 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ 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)
![Pi-hole Web interface](http://i.imgur.com/FweAo36.png)
![Fully responsive](http://i.imgur.com/fHuWR6E.png)

## API
A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON:
A read-only API can be accessed at `/admin/api.php`. With either no parameters or `api.php?summary` it returns the following JSON:
```JSON
{
"domains_being_blocked": "136708",
"dns_queries_today": "18108",
"ads_blocked_today": "14648",
"ads_percentage_today": 80.892423238348
"domains_being_blocked": "136,708",
"dns_queries_today": "18,108",
"ads_blocked_today": "14,648",
"ads_percentage_today": "80.9"
}
```

There are many more parameters, such as `summaryRaw`, `overTimeData`, `topItems`, `recentItems`, `getQueryTypes`, `getForwardDestinations`, `getQuerySources`, and finally `getAllQueries`.
54 changes: 54 additions & 0 deletions css/js-warn.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* Made by Verpz https://github.com/Verpz/ Licensed Under Apache License 2.0 Details On GitHub */
.js-warn {
background: #EEE;
color: #555;
display: block;
width: 30%;
right: 0;
left: 0;
margin-right: auto;
margin-left: auto;
margin-top: 50px;
border-radius: 10px;
box-shadow: 0px 10px 70px;
text-align: center;
position: fixed;
font-family: sans-serif, serif;
font-weight: 300;
z-index: 9999;
}
.js-warn h1 {
font-family: sans-serif, serif;
font-weight: 300;
padding: 10px 10px 0 10px;
}
.js-warn p {
padding: 0 10px 10px 10px;
}
.js-warn a {
color: #355980;
text-decoration: none;
transition: all 0.2s linear;
}
.js-warn a:hover {
color: #000;
}
#js-hide:checked ~ #js-warn-exit {
display: none;
}
#js-hide {
position: fixed;
left: 100%;
}
#js-warn-exit {
padding: 1em;
overflow: auto;
}
#js-warn-exit label {
background: #355980;
color: white;
padding: 0.5em 0.75em;
cursor: pointer;
border-radius: 3px;
float: right;
}
31 changes: 24 additions & 7 deletions data.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function getSummaryData() {

$ads_blocked_today = count(getBlockedQueries($log));

$ads_percentage_today = $ads_blocked_today / $dns_queries_today * 100;
$ads_percentage_today = $dns_queries_today > 0 ? ($ads_blocked_today / $dns_queries_today * 100) : 0;

return array(
'domains_being_blocked' => $domains_being_blocked,
Expand Down Expand Up @@ -121,19 +121,36 @@ function getAllQueries() {
$allQueries = array("data" => array());
$log = readInLog();
$dns_queries = getDnsQueries($log);


$fileName = '/etc/pihole/gravity.list';
//Turn gravity.list into an array
$lines = explode("\n", file_get_contents($fileName));

//Create a new array and set domain name as index instead of value, with value as 1
foreach(array_values($lines) as $v){
$new_lines[trim(strstr($v, ' '))] = 1;
}

foreach ($dns_queries as $query) {
$time = date_create(substr($query, 0, 16));

$exploded = explode(" ", trim($query));

//Is index of the domain name set?
if (isset($new_lines[$exploded[count($exploded)-3]])){
$extra = "Pi-holed";
}
else
{
$extra = "OK";
}
array_push($allQueries['data'], array(
$time->format('Y-m-d\TH:i:s'),
substr($exploded[5], 6, -1),
$exploded[6],
$exploded[8],
substr($exploded[count($exploded)-4], 6, -1),
$exploded[count($exploded)-3],
$exploded[count($exploded)-1],
$extra,
));
}

return $allQueries;
}

Expand Down
19 changes: 14 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<?php
require "header.html";
?>

<!-- JS Warning -->
<div>
<link rel="stylesheet" type="text/css" href="css/js-warn.css">
<input type="checkbox" id="js-hide" />
<div class="js-warn" id="js-warn-exit"><h1>Javascript Is Disabled</h1><p>Javascript seems to be disabled. This will break some site features.</p>
<p>To enable Javascript click <a href="http://www.enable-javascript.com/" target="_blank">here</a></p><label for="js-hide">Close</label></div>
<script>var jswarn = document.getElementById("js-warn-exit"); jswarn.parentNode.removeChild(jswarn);</script>
</div>
<!-- /JS Warning -->
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
Expand Down Expand Up @@ -208,12 +216,13 @@
label: "All Queries",
fillColor: "rgba(220,220,220,0.5)",
strokeColor: "rgba(0, 166, 90,.8)",
pointColor: "rgba(0, 166, 90,.8)"
},
{
label: "Ad Queries",
fillColor: "rgba(243,156,18,0.5)",
strokeColor: "rgba(243,156,18,1)",
pointColor: "rgba(243,156,18,1)",
fillColor: "rgba(0,192,239,0.5)",
strokeColor: "rgba(0,192,239,1)",
pointColor: "rgba(0,192,239,1)"
}
]
};
Expand Down Expand Up @@ -338,7 +347,7 @@ function updateQueryTypes() {
queryTypeChart.addData({
value: value,
color: colors.shift(),
label: key
label: key.substr(6,key.length - 7)
});
});
$('#query-types .overlay').remove();
Expand Down
Loading

0 comments on commit a5e2008

Please sign in to comment.