mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Add blocking version of pihole.log tailing
This commit is contained in:
@@ -353,6 +353,12 @@
|
||||
<i class="fa fa-search"></i> <span>Query adlists</span>
|
||||
</a>
|
||||
</li>
|
||||
<!-- Query adlists -->
|
||||
<li>
|
||||
<a href="taillog.php">
|
||||
<i class="fa fa-list-ul"></i> <span>Tail pihole.log</span>
|
||||
</a>
|
||||
</li>
|
||||
<!-- Toggle -->
|
||||
<?php
|
||||
if ($pistatus == "1") {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
var source;
|
||||
function eventsource() {
|
||||
var ta = $("#output");
|
||||
source = new EventSource("php/taillog.php");
|
||||
|
||||
ta.html("");
|
||||
ta.show();
|
||||
|
||||
source.addEventListener("message", function(e) {
|
||||
if(e.data.indexOf("Ctrl-C") === -1)
|
||||
{
|
||||
// Hide the "Press Ctrl-C to exit" message
|
||||
ta.append(e.data);
|
||||
}
|
||||
|
||||
}, false);
|
||||
|
||||
// Will be called when script has finished
|
||||
source.addEventListener("error", function(e) {
|
||||
source.close();
|
||||
}, false);
|
||||
}
|
||||
|
||||
$(function(){
|
||||
eventsource();
|
||||
});
|
||||
|
||||
$(window).unload(function(){
|
||||
source.close();
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
require "password.php";
|
||||
if(!$auth) die("Not authorized");
|
||||
|
||||
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 -t", 'r');
|
||||
while (!feof($proc)) {
|
||||
echoEvent(fread($proc, 4096));
|
||||
}
|
||||
|
||||
// echoEvent("***END***");
|
||||
?>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
require "header.php";
|
||||
?>
|
||||
<!-- Title -->
|
||||
<div class="page-header">
|
||||
<h1>Output the last lines of the pihole.log file (live)</h1>
|
||||
</div>
|
||||
|
||||
<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre>
|
||||
|
||||
<?php
|
||||
require "footer.php";
|
||||
?>
|
||||
|
||||
|
||||
<script src="js/pihole/taillog.js"></script>
|
||||
Reference in New Issue
Block a user