Merge branch 'devel' into auth

This commit is contained in:
DL6ER
2016-11-20 14:47:25 +01:00
5 changed files with 89 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
require "header.php";
?>
<!-- Title -->
<div class="page-header">
<h1>Update list of ad-serving domains</h1>
</div>
<!-- Alerts -->
<div id="alInfo" class="alert alert-info alert-dismissible fade in" role="alert" hidden="true">
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Updating...
</div>
<div id="alSuccess" class="alert alert-success alert-dismissible fade in" role="alert" hidden="true">
<button type="button" class="close" data-hide="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Success!
</div>
<pre id="output" style="width: 100%; height: 100%;"></pre>
<?php
require "footer.php";
?>
<script src="js/pihole/gravity.js"></script>
+6
View File
@@ -240,6 +240,12 @@
<i class="fa fa-ban"></i> <span>Blacklist</span>
</a>
</li>
<!-- Run gravity.sh -->
<li>
<a href="gravity.php">
<i class="fa fa-arrow-circle-down"></i> <span>Update lists</span>
</a>
</li>
<!-- Toggle -->
<?php
if ($pistatus == "1") {
+36
View File
@@ -0,0 +1,36 @@
function eventsourcetest() {
var alInfo = $("#alInfo");
var alSuccess = $("#alSuccess");
var ta = document.getElementById("output");
var source = new EventSource("php/gravity.sh.php");
alInfo.show();
alSuccess.hide();
source.addEventListener("message", function(e) {
if(e.data.indexOf("Pi-hole blocking is") !== -1)
{
alSuccess.show();
}
ta.innerHTML += e.data;
}, false);
// Will be called when script has finished
source.addEventListener("error", function(e) {
alInfo.delay(1000).fadeOut(2000, function() { alInfo.hide(); });
source.close();
}, false);
}
$(function(){
eventsourcetest();
});
// Handle hiding of alerts
$(function(){
$("[data-hide]").on("click", function(){
$(this).closest("." + $(this).attr("data-hide")).hide();
});
});
+1
View File
@@ -27,6 +27,7 @@ $(document).ready(function() {
{ "width" : "10%" },
{ "width" : "10%" },
],
"lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"columnDefs": [ {
"targets": -1,
"data": null,
+20
View File
@@ -0,0 +1,20 @@
<?php
ob_end_flush();
ini_set("output_buffering", "0");
ob_implicit_flush(true);
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
function echoEvent($datatext) {
echo "data: ".implode("\ndata: ", explode("\n", $datatext))."\n\n";
}
// echoEvent("***START***");
$proc = popen("sudo pihole -g", 'r');
while (!feof($proc)) {
echoEvent(fread($proc, 4096));
}
// echoEvent("***END***");
?>