Merge branch 'devel' into tweak/Teleporter_v2.0

This commit is contained in:
DL6ER
2017-10-06 20:26:21 +02:00
20 changed files with 157 additions and 65 deletions

View File

@@ -119,7 +119,7 @@ function check_csrf($token) {
function check_domain() {
if(isset($_POST['domain'])){
$domains = explode(" ",$_POST['domain']);
$domains = preg_split('\s+', $_POST['domain']);
foreach($domains as $domain)
{
$validDomain = is_valid_domain_name($domain);
@@ -146,7 +146,7 @@ function list_verify($type) {
require("password.php");
if(strlen($pwhash) == 0)
{
log_and_die("No password set - ".htmlspecialchars($type)."listing with password not supported");
log_and_die("No password set - ".htmlspecialchars($type)."listing without password not supported");
}
elseif($wrongpassword)
{

View File

@@ -11,17 +11,16 @@
</div>
<!-- Modal for custom disable time -->
<div class="modal fade" id="customDisableModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Custom disable timeout</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-3"><input id="customTimeout" class="form-control" type="number" value="60"></div>
<div class="col-sm-9">
<div class="btn-group" data-toggle="buttons">
<div class="input-group">
<input id="customTimeout" class="form-control" type="number" value="60">
<div class="input-group-btn" data-toggle="buttons">
<label class="btn btn-default">
<input type="radio"/> Secs
</label>
@@ -29,7 +28,6 @@
<input type="radio" /> Mins
</label>
</div>
</div>
</div>
</div>
<div class="modal-footer">

View File

@@ -16,15 +16,22 @@ header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
function echoEvent($datatext) {
echo "data: ".implode("\ndata: ", explode("\n", $datatext))."\n\n";
// Detect ${OVER} and replace it with something we can safely transmit
$datatext = str_replace("\r","<------",$datatext);
$pos = strpos($datatext,"<------");
// Detect if the ${OVER} line is within this line, e.g.
// "Pending: String to replace${OVER}Done: String has been replaced"
// If this is the case, we have to remove everything before ${OVER}
// and return only the text thereafter
if($pos !== false && $pos !== 0)
{
$datatext = substr($datatext, $pos);
}
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***");
?>

View File

@@ -353,7 +353,7 @@ if($auth) {
?>
<br/>
<?php
echo "<a><i class=\"fa fa-circle\" style=\"color:";
echo "<a title=\"Detected $nproc cores\"><i class=\"fa fa-circle\" style=\"color:";
if ($loaddata[0] > $nproc) {
echo "#FF0000";
}
@@ -361,7 +361,7 @@ if($auth) {
{
echo "#7FFF00";
}
echo "\" title=\"Detected $nproc cores\"></i> Load:&nbsp;&nbsp;" . $loaddata[0] . "&nbsp;&nbsp;" . $loaddata[1] . "&nbsp;&nbsp;". $loaddata[2] . "</a>";
echo "\"></i> Load:&nbsp;&nbsp;" . $loaddata[0] . "&nbsp;&nbsp;" . $loaddata[1] . "&nbsp;&nbsp;". $loaddata[2] . "</a>";
?>
<br/>
<?php
@@ -420,10 +420,10 @@ if($auth) {
</li>
<li class="treeview<?php if($scriptname === "db_queries.php" || $scriptname === "db_lists.php" || $scriptname === "db_graph.php"){ ?> active<?php } ?>">
<a href="#">
<i class="fa fa-clock-o"></i> <span>Long term data</span>
<span class="pull-right-container">
<i class="fa fa-angle-down pull-right" style="padding-right: 5px;"></i>
</span>
<i class="fa fa-clock-o"></i> <span>Long term data</span>
</a>
<ul class="treeview-menu">
<li<?php if($scriptname === "db_graph.php"){ ?> class="active"<?php } ?>>
@@ -459,10 +459,10 @@ if($auth) {
<li id="pihole-disable" class="treeview"<?php if ($pistatus == "0") { ?> hidden="true"<?php } ?>>
<a href="#">
<i class="fa fa-stop"></i> <span>Disable</span>&nbsp;&nbsp;&nbsp;<span id="flip-status-disable"></span>
<span class="pull-right-container">
<i class="fa fa-angle-down pull-right" style="padding-right: 5px;"></i>
</span>
<i class="fa fa-stop"></i> <span>Disable</span>&nbsp;&nbsp;&nbsp;<span id="flip-status-disable"></span>
</a>
<ul class="treeview-menu">
<li>
@@ -499,10 +499,10 @@ if($auth) {
<!-- Tools -->
<li class="treeview <?php if(in_array($scriptname, array("gravity.php", "queryads.php", "auditlog.php", "taillog.php", "taillog-FTL.php", "debug.php"))){ ?>active<?php } ?>">
<a href="#">
<i class="fa fa-folder"></i> <span>Tools</span>
<span class="pull-right-container">
<i class="fa fa-angle-down pull-right" style="padding-right: 5px;"></i>
</span>
<i class="fa fa-folder"></i> <span>Tools</span>
</a>
<ul class="treeview-menu">
<!-- Run gravity.sh -->

View File

@@ -20,6 +20,7 @@ function echoEvent($datatext) {
}
// Credit: http://stackoverflow.com/a/4694816/2087442
ini_set("pcre.recursion_limit", 1500);
function is_valid_domain_name($domain_name)
{
return (preg_match("/^((-|_)*[a-z\d]((-|_)*[a-z\d])*(-|_)*)(\.(-|_)*([a-z\d]((-|_)*[a-z\d])*))*$/i", $domain_name) // Valid chars check
@@ -48,6 +49,10 @@ if(isset($_GET["exact"]))
{
$exact = "-exact";
}
elseif(isset($_GET["bp"]))
{
$exact = "-bp";
}
else
{
$exact = "";

View File

@@ -46,7 +46,7 @@ function validDomain($domain_name)
function validDomainWildcard($domain_name)
{
// There has to be either no or at most one "*" at the beginning of a line
$validChars = preg_match("/^((\*)?[_a-z\d](-*[_a-z\d])*)(\.([_a-z\d](-*[a-z\d])*))*(\.([a-z\d])*)*$/i", $domain_name);
$validChars = preg_match("/^((\*.)?[_a-z\d](-*[_a-z\d])*)(\.([_a-z\d](-*[a-z\d])*))*(\.([a-z\d])*)*$/i", $domain_name);
$lengthCheck = preg_match("/^.{1,253}$/", $domain_name);
$labelLengthCheck = preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name);
return ( $validChars && $lengthCheck && $labelLengthCheck ); //length of each label
@@ -420,6 +420,11 @@ function readAdlists()
$success .= "The webUI settings have been updated";
break;
case "poweroff":
exec("sudo pihole -a poweroff");
$success = "The system will poweroff in 5 seconds...";
break;
case "reboot":
exec("sudo pihole -a reboot");
$success = "The system will reboot in 5 seconds...";

View File

@@ -42,14 +42,14 @@ $FTL_current = exec("pihole-FTL version");
$versionfile = "../versions";
$check_version = false;
$date = date_create();
$timestamp = date_timestamp_get($date);
// Check version if version buffer file does not exist
if(is_readable($versionfile))
{
// Obtain latest time stamp from buffer file
$versions = explode(",",file_get_contents($versionfile));
$date = date_create();
$timestamp = date_timestamp_get($date);
// Is last check for updates older than 30 minutes?
if($timestamp >= intval($versions[0]) + 1800)