mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 04:38:28 +00:00
Added online debug log creator
This commit is contained in:
17
debug.php
Normal file
17
debug.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
require "scripts/pi-hole/php/header.php";
|
||||||
|
?>
|
||||||
|
<!-- Title -->
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>Generate debug log</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="btn btn-lg btn-primary btn-block" id="debugBtn">Generate debug log</button>
|
||||||
|
<pre id="output" style="width: 100%; height: 100%;" hidden="true"></pre>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require "scripts/pi-hole/php/footer.php";
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<script src="scripts/pi-hole/js/debug.js"></script>
|
||||||
64
scripts/pi-hole/js/debug.js
Normal file
64
scripts/pi-hole/js/debug.js
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
// Credit: http://stackoverflow.com/a/10642418/2087442
|
||||||
|
function httpGet(ta,quiet,theUrl)
|
||||||
|
{
|
||||||
|
var xmlhttp;
|
||||||
|
if (window.XMLHttpRequest)
|
||||||
|
{
|
||||||
|
// code for IE7+
|
||||||
|
xmlhttp = new XMLHttpRequest();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// code for IE6, IE5
|
||||||
|
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||||
|
}
|
||||||
|
xmlhttp.onreadystatechange=function()
|
||||||
|
{
|
||||||
|
if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
|
||||||
|
{
|
||||||
|
ta.show();
|
||||||
|
ta.empty();
|
||||||
|
if(!quiet)
|
||||||
|
{
|
||||||
|
ta.append(xmlhttp.responseText);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
quietfilter(ta,xmlhttp.responseText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xmlhttp.open("GET", theUrl, false);
|
||||||
|
xmlhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function eventsource() {
|
||||||
|
var ta = $("#output");
|
||||||
|
|
||||||
|
// IE does not support EventSource - load whole content at once
|
||||||
|
if (typeof EventSource !== "function") {
|
||||||
|
httpGet(ta,quiet,"/admin/scripts/pi-hole/php/debug.php");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var host = window.location.host;
|
||||||
|
var source = new EventSource("/admin/scripts/pi-hole/php/debug.php");
|
||||||
|
|
||||||
|
// Reset and show field
|
||||||
|
ta.empty();
|
||||||
|
ta.show();
|
||||||
|
|
||||||
|
source.addEventListener("message", function(e) {
|
||||||
|
ta.append(e.data);
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
// Will be called when script has finished
|
||||||
|
source.addEventListener("error", function(e) {
|
||||||
|
source.close();
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#debugBtn").on("click", function(){
|
||||||
|
$("#debugBtn").attr("disabled", true);
|
||||||
|
eventsource();
|
||||||
|
});
|
||||||
19
scripts/pi-hole/php/debug.php
Normal file
19
scripts/pi-hole/php/debug.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?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) {
|
||||||
|
if(!isset($_GET["IE"]))
|
||||||
|
echo "data: ".implode("\ndata: ", explode("\n", $datatext))."\n\n";
|
||||||
|
else
|
||||||
|
echo $datatext;
|
||||||
|
}
|
||||||
|
|
||||||
|
$proc = popen("sudo pihole -d -a", "r");
|
||||||
|
while (!feof($proc)) {
|
||||||
|
echoEvent(fread($proc, 4096));
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -405,7 +405,7 @@
|
|||||||
<a href="#"><i class="fa fa-play"></i> <span>Enable</span> <span id="flip-status-enable"></span></a>
|
<a href="#"><i class="fa fa-play"></i> <span>Enable</span> <span id="flip-status-enable"></span></a>
|
||||||
</li>
|
</li>
|
||||||
<!-- Tools -->
|
<!-- Tools -->
|
||||||
<li class="treeview <?php if($scriptname === "gravity.php" || $scriptname === "queryads.php"){ ?>active<?php } ?>">
|
<li class="treeview <?php if($scriptname === "gravity.php" || $scriptname === "queryads.php" || $scriptname === "debug.php"){ ?>active<?php } ?>">
|
||||||
<a href="#">
|
<a href="#">
|
||||||
<i class="fa fa-folder"></i> <span>Tools</span>
|
<i class="fa fa-folder"></i> <span>Tools</span>
|
||||||
<span class="pull-right-container">
|
<span class="pull-right-container">
|
||||||
@@ -431,6 +431,12 @@
|
|||||||
<i class="fa fa-list-ul"></i> <span>Tail pihole.log</span>
|
<i class="fa fa-list-ul"></i> <span>Tail pihole.log</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<!-- Generate debug log -->
|
||||||
|
<li<?php if($scriptname === "debug.php"){ ?> class="active"<?php } ?>>
|
||||||
|
<a href="debug.php">
|
||||||
|
<i class="fa fa-ambulance"></i> <span>Generate debug log</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
|
|||||||
Reference in New Issue
Block a user