Merge pull request #113 from pi-hole/devel

Devel Next release
This commit is contained in:
Mcat12
2016-08-19 20:33:46 -04:00
committed by GitHub
21 changed files with 195 additions and 102 deletions
+2
View File
@@ -13,3 +13,5 @@ test.html
*.ipr
*.iws
# vim
*.swp
+3 -3
View File
@@ -6,10 +6,10 @@
<div class="pull-right hidden-xs">
<?php
$piholeVersion = exec("cd /etc/.pihole/ && git describe --tags --abbrev=0");
$webVersion = exec("cd /var/www/html/admin/ && git describe --tags --abbrev=0");
$webVersion = exec("git describe --tags --abbrev=0");
?>
<b>Pi-hole Version </b> <div id="piholeVersion" style="display: inline"><?php echo $piholeVersion; ?></div>
<b>Web Interface Version </b> <div id="webVersion" style="display: inline"><?php echo $webVersion; ?></div>
<b>Pi-hole Version </b> <span id="piholeVersion"><?php echo $piholeVersion; ?></span>
<b>Web Interface Version </b> <span id="webVersion"><?php echo $webVersion; ?></span>
</div>
<i class="fa fa-github"></i> <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=3J2L3Z4DHW9UY">Donate</a></strong> if you found this useful.
</footer>
+27 -14
View File
@@ -1,3 +1,9 @@
<?php
$cmd = "echo $((`cat /sys/class/thermal/thermal_zone0/temp|cut -c1-2`)).$((`cat /sys/class/thermal/thermal_zone0/temp|cut -c3-4`))";
$output = shell_exec($cmd);
$output = str_replace(["\r\n","\r","\n"],"", $output);
?>
<!DOCTYPE html>
<html>
<head>
@@ -6,27 +12,27 @@
<title>Pi-hole Admin Console</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="img/favicon.png" type="image/x-icon" />
<meta name="theme-color" content="#367fa9">
<link rel="apple-touch-icon" sizes="180x180" href="img/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="img/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="96x96" href="img/favicon-96x96.png">
<link rel="apple-touch-icon" sizes="180x180" href="img/logo.svg">
<link rel="icon" type="image/png" sizes="192x192" href="img/logo.svg">
<link rel="icon" type="image/png" sizes="96x96" href="img/logo.svg">
<meta name="msapplication-TileColor" content="#367fa9">
<meta name="msapplication-TileImage" content="img/ms-icon-144x144.png">
<meta name="msapplication-TileImage" content="img/logo.svg">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/font-awesome-4.5.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="css/ionicons-2.0.1/css/ionicons.min.css" rel="stylesheet" type="text/css" />
<link href="css/dataTables.bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/AdminLTE.min.css" rel="stylesheet" type="text/css" />
<link href="css/skin-blue.min.css" rel="stylesheet" type="text/css" />
<link rel="icon" type="image/png" href="img/pihole-160x160.jpg" />
<link rel="icon" type="image/png" sizes="160x160" href="img/logo.svg" />
<style type="text/css">
.glow { text-shadow: 0px 0px 5px #fff; }
h3 { transition-duration: 500ms }
</style>
<!--[if lt IE 9]>
<script src="js/other/html5shiv.min.js"></script>
<script src="js/other/respond.min.js"></script>
@@ -62,13 +68,13 @@
<!-- User Account: style can be found in dropdown.less -->
<li id="dropdown-menu" class="dropdown user user-menu">
<a href="#" class="dropdown-toggle">
<img src="img/pihole-160x160.jpg" class="user-image" alt="Pi-hole logo" />
<img src="img/logo.svg" class="user-image" style="border-radius: initial" sizes="160x160" alt="Pi-hole logo" />
<span class="hidden-xs">Pi-hole</span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<li class="user-header">
<img src="./img/pihole-160x160.jpg" alt="User Image" />
<img src="img/logo.svg" sizes="160x160" alt="User Image" />
<p>
Open Source Ad Blocker
<small>Designed For Raspberry Pi</small>
@@ -95,7 +101,7 @@
<div id="alWebUpdate" class="alert alert-info alert-dismissible fade in" role="alert" hidden>
<a class="alert-link" href="https://github.com/pi-hole/AdminLTE/releases">There's an update available for this Web Interface!</a>
</div>
<!-- PayPal -->
<div>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
@@ -118,17 +124,24 @@
<!-- Sidebar user panel -->
<div class="user-panel">
<div class="pull-left image">
<img src="img/pihole-160x160.jpg" class="img-circle" alt="Pi-hole logo" />
<img src="img/logo.svg" sizes="160x160" alt="Pi-hole logo" />
</div>
<div class="pull-left info">
<p>Status</p>
<?php
<?php
$pistatus = exec('pgrep dnsmasq | wc -l');
if ($pistatus > "0") {
echo '<a href="#"><i class="fa fa-circle" style="color:#7FFF00"></i> Active</a>';
} else {
echo '<a href="#"><i class="fa fa-circle" style="color:#FF0000"></i> Offline</a>';
}
// CPU Temp
if ($output > "45") {
echo '<a href="#"><i class="fa fa-fire" style="color:#FF0000"></i> Temp: ' . $output . '</a>';
} else {
echo '<a href="#"><i class="fa fa-fire" style="color:#3366FF"></i> Temp: ' . $output . '</a>';
}
?>
</div>
</div>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 88.34 130.66"><defs><style>.cls-1{fill:url(#New_Gradient_Swatch_3);}.cls-2{fill:url(#New_Gradient_Swatch_5);}.cls-3{fill:url(#New_Gradient_Swatch_5-2);}.cls-4{fill:url(#New_Gradient_Swatch_5-3);}.cls-5{fill:url(#New_Gradient_Swatch_5-4);}.cls-6{fill:url(#linear-gradient);}</style><radialGradient id="New_Gradient_Swatch_3" cx="44.36" cy="84.3" r="25.18" gradientTransform="translate(0 0.72) scale(1 1.02)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#fff"/><stop offset="0.08" stop-color="#99c"/><stop offset="0.27" stop-color="#4d4d59"/><stop offset="0.67" stop-color="#300"/><stop offset="1" stop-color="red"/></radialGradient><linearGradient id="New_Gradient_Swatch_5" x1="-249.81" y1="-104.86" x2="-249.81" y2="-161.68" gradientTransform="translate(-179.33 -57.26) rotate(180)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#ff0020"/><stop offset="0.15" stop-color="#fa001f"/><stop offset="0.33" stop-color="#eb001e"/><stop offset="0.52" stop-color="#d3001b"/><stop offset="0.72" stop-color="#b10018"/><stop offset="0.92" stop-color="#860013"/><stop offset="1" stop-color="#740011"/></linearGradient><linearGradient id="New_Gradient_Swatch_5-2" x1="5.6" y1="59.11" x2="62.74" y2="59.11" gradientTransform="matrix(1, 0, 0, 1, 0, 0)" xlink:href="#New_Gradient_Swatch_5"/><linearGradient id="New_Gradient_Swatch_5-3" x1="17.88" y1="124.81" x2="17.88" y2="67.73" gradientTransform="matrix(1, 0, 0, 1, 0, 0)" xlink:href="#New_Gradient_Swatch_5"/><linearGradient id="New_Gradient_Swatch_5-4" x1="-262.91" y1="-170.09" x2="-205.39" y2="-170.09" xlink:href="#New_Gradient_Swatch_5"/><linearGradient id="linear-gradient" x1="3.88" y1="20.04" x2="70.94" y2="20.04" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#12b212"/><stop offset="1" stop-color="lime"/></linearGradient></defs><title>Asset 5</title><g id="Layer_2" data-name="Layer 2"><g id="Home_Logo" data-name="Home Logo"><rect class="cls-1" x="16.88" y="63.33" width="54.95" height="46" rx="12" ry="12"/><path class="cls-2" d="M58.3,47.62c-.55-.48,10.38,9.71-.3,25.16-4.76,6.89-6.6,13.7-4.57,19.82,2.43,7.37,9.77,11.58,15.83,11.79,15.81.56,26.26-17.68,13.12-32.1Z"/><path class="cls-3" d="M5.6,72.74a16.06,16.06,0,0,1,6.65-4c6.37-2.1,13-.28,18.69,2.93,6.68,3.79,14.61,7.44,22.1,3.62A18.13,18.13,0,0,0,62.74,60a18.49,18.49,0,0,0-6.94-14.8A18.2,18.2,0,0,0,39.75,42a23.32,23.32,0,0,0-10.4,6.44l-7.54,7.72L5.92,72.41Z"/><path class="cls-4" d="M30.77,124.72c.91,1.33-10.3-12-.43-25.36,5-6.74,6.6-13.7,4.57-19.82C32.48,72.17,25.15,68,19.09,67.74,3.27,67.18-7.18,85.42,6,99.84Z"/><path class="cls-5" d="M83.58,98.68s-9.68,10.87-25.72,1.62C50.6,96.12,44.16,93.7,38,95.73a18.14,18.14,0,0,0-12,15.89c-.56,15.81,17.86,26.21,32.27,13.06Z"/><path id="Leaf_Path" data-name="Leaf Path" class="cls-6" d="M37.72,39.93m0,0C21.5,38.2,5.17,25.94,3.88,0,29,0,42.5,14.9,43.8,38.51c4.76-28.32,27.07-25,27.07-25C71.94,29.55,58.75,39.28,43.8,40.09,39.6,31.25,14.44,9.54,14.44,9.54a.07.07,0,0,0-.11.08S38.61,30.77,37.72,39.93"/></g></g></svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

+34 -24
View File
@@ -1,5 +1,5 @@
<?php
require "header.html";
require "header.php";
?>
<!-- Small boxes (Stat box) -->
<div class="row">
@@ -119,13 +119,17 @@
</div>
<!-- /.box-header -->
<div class="box-body">
<table class="table table-bordered">
<tbody><tr>
<th>Domain</th>
<th>Hits</th>
<th>Frequency</th>
</tr>
</tbody></table>
<div class="table-responsive">
<table class="table table-bordered">
<tbody>
<tr>
<th>Domain</th>
<th>Hits</th>
<th>Frequency</th>
</tr>
</tbody>
</table>
</div>
</div>
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
@@ -142,15 +146,17 @@
</div>
<!-- /.box-header -->
<div class="box-body">
<table class="table table-bordered">
<tbody>
<tr>
<th>Domain</th>
<th>Hits</th>
<th>Frequency</th>
</tr>
</tbody>
</table>
<div class="table-responsive">
<table class="table table-bordered">
<tbody>
<tr>
<th>Domain</th>
<th>Hits</th>
<th>Frequency</th>
</tr>
</tbody>
</table>
</div>
</div>
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
@@ -167,13 +173,17 @@
</div>
<!-- /.box-header -->
<div class="box-body">
<table class="table table-bordered">
<tbody><tr>
<th>Client</th>
<th>Requests</th>
<th>Frequency</th>
</tr>
</tbody></table>
<div class="table-responsive">
<table class="table table-bordered">
<tbody>
<tr>
<th>Client</th>
<th>Requests</th>
<th>Frequency</th>
</tr>
</tbody>
</table>
</div>
</div>
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
+6 -4
View File
@@ -33,7 +33,8 @@ function versionCompare(left, right) {
// Update check
$.getJSON("https://api.github.com/repos/pi-hole/pi-hole/releases/latest", function(json) {
if(versionCompare(piholeVersion, json.tag_name.slice(1)) < 0) {
// Skip if on dev
if(piholeVersion !== "vDev" && versionCompare(piholeVersion, json.tag_name.slice(1)) < 0) {
// Alert user
$("#alPiholeUpdate").show();
if(!$("#dropdown-menu").hasClass("open")) {
@@ -42,7 +43,8 @@ $.getJSON("https://api.github.com/repos/pi-hole/pi-hole/releases/latest", functi
}
});
$.getJSON("https://api.github.com/repos/pi-hole/AdminLTE/releases/latest", function(json) {
if(versionCompare(webVersion, json.tag_name.slice(1)) < 0) {
// Skip if on dev
if(webVersion !== "vDev" && versionCompare(webVersion, json.tag_name.slice(1)) < 0) {
// Alert user
$("#alWebUpdate").show();
if(!$("#dropdown-menu").hasClass("open")) {
@@ -53,7 +55,7 @@ $.getJSON("https://api.github.com/repos/pi-hole/AdminLTE/releases/latest", funct
/*
* Make sure that Pi-hole is updated to at least v2.7, since that is needed to use the sudo
* features of the interface
* features of the interface. Skip if on dev
*/
if(versionCompare(piholeVersion, "v2.7") < 0)
if(piholeVersion !== "vDev" && versionCompare(piholeVersion, "v2.7") < 0)
alert("Pi-hole needs to be updated to at least v2.7 before you can use features such as whitelisting/blacklisting from this web interface!")
+2 -1
View File
@@ -85,7 +85,8 @@ function add() {
method: "post",
data: {"domain":domain.val(), "list":list_type, "token":token},
success: function(response) {
if (response.indexOf("not a valid argument")>=0) {
if (response.indexOf("not a valid argument") >= 0 ||
response.indexOf("is not a valid domain") >= 0) {
alFailure.show();
alFailure.delay(1000).fadeOut(2000, function() {
alFailure.hide();
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
session_start();
require "header.html";
require "header.php";
$list = $_GET['l'];
+4 -17
View File
@@ -1,26 +1,13 @@
<?php
if(!isset($_POST['domain'], $_POST['list'], $_POST['token']))
die("Missing POST variables");
// Check CORS
if($_SERVER['HTTP_ORIGIN'] == "http://pi.hole" || $_SERVER['HTTP_ORIGIN'] == "http://${_SERVER['SERVER_ADDR']}")
header("Access-Control-Allow-Origin: ${_SERVER['HTTP_ORIGIN']}");
else if($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR'] || $_SERVER['HTTP_HOST'] == "pi.hole")
header("Access-Control-Allow-Origin: ${_SERVER['HTTP_HOST']}");
else
die("Failed CORS");
session_start();
// Check CSRF token
if(!hash_equals($_SESSION['token'], $_POST['token']))
die("Wrong token");
require('auth.php');
switch($_POST['list']) {
case "white":
case "white":
echo exec("sudo pihole -w -q ${_POST['domain']}");
break;
case "black":
echo exec("sudo pihole -b -q ${_POST['domain']}");
break;
}
?>
+60
View File
@@ -0,0 +1,60 @@
<?php
require('func.php');
$ERRORLOG = getenv('PHP_ERROR_LOG');
if (empty($ERRORLOG)) {
$ERRORLOG = '/var/log/lighttpd/error.log';
}
function pi_log($message) {
error_log(date('Y-m-d H:i:s') . ': ' . $message . "\n", 3, $GLOBALS['ERRORLOG']);
}
function log_and_die($message) {
pi_log($message);
die($message);
}
if(!isset($_POST['domain'], $_POST['list'], $_POST['token'])) {
log_and_die("Missing POST variables");
}
$AUTHORIZED_HOSTNAMES = [
'http://' . $_SERVER['SERVER_ADDR'],
'http://pi.hole',
'http://localhost'
];
# Allow user set virtual hostnames
$virtual_host = getenv('VIRTUAL_HOST');
if (! empty($virtual_host))
array_push($AUTHORIZED_HOSTNAMES, 'http://' . $virtual_host);
// Check CORS
if(isset($_SERVER['HTTP_ORIGIN'])) {
if(in_array($_SERVER['HTTP_ORIGIN'], $AUTHORIZED_HOSTNAMES)) {
$CORS_ALLOW_ORIGIN = $_SERVER['HTTP_ORIGIN'];
} else {
log_and_die("Failed CORS: " . $_SERVER['HTTP_ORIGIN'] .' vs '. join(',', $AUTHORIZED_HOSTNAMES));
}
header("Access-Control-Allow-Origin: $CORS_ALLOW_ORIGIN");
} else {
pi_log("CORS skipped, unknown HTTP_ORIGIN");
//pi_log("CORS allowed: " . join(',', $AUTHORIZED_HOSTNAMES));
}
// Otherwise probably same origin... out of the scope of CORS
session_start();
// Check CSRF token
if(!isset($_SESSION['token'], $_POST['token']) || !hash_equals($_SESSION['token'], $_POST['token'])) {
log_and_die("Wrong token");
}
if(isset($_POST['domain'])){
$validDomain = is_valid_domain_name($_POST['domain']);
if(!$validDomain){
log_and_die($_POST['domain']. ' is not a valid domain');
}
}
?>
+10
View File
@@ -0,0 +1,10 @@
<?php
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
preg_match("/^.{1,253}$/", $domain_name) && //overall length check
preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name)); //length of each label
}
?>
+19 -1
View File
@@ -3,6 +3,10 @@ if(!isset($_GET['list']))
die();
$type = $_GET['list'];
if($type !== "white" && $type !== "black")
die("Invalid list parameter");
$rawList = file_get_contents("/etc/pihole/${type}list.txt");
$list = explode("\n", $rawList);
@@ -12,4 +16,18 @@ for($i = sizeof($list)-1; $i >= 0; $i--) {
unset($list[$i]);
}
echo json_encode(array_values($list));
function filterArray(&$a) {
$sanArray = array();
foreach ($a as $k=>$v) {
if (is_array($v)) {
$sanArray[htmlspecialchars($k)] = filterArray($v);
} else {
$sanArray[htmlspecialchars($k)] = htmlspecialchars($v);
}
}
return $sanArray;
}
// Protect against XSS attacks
$list = filterArray($list);
echo json_encode(array_values($list));
+3 -16
View File
@@ -1,20 +1,5 @@
<?php
if(!isset($_POST['domain'], $_POST['list'], $_POST['token']))
die("Missing POST variables");
// Check CORS
if($_SERVER['HTTP_ORIGIN'] == "http://pi.hole" || $_SERVER['HTTP_ORIGIN'] == "http://${_SERVER['SERVER_ADDR']}")
header("Access-Control-Allow-Origin: ${_SERVER['HTTP_ORIGIN']}");
else if($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR'] || $_SERVER['HTTP_HOST'] == "pi.hole")
header("Access-Control-Allow-Origin: ${_SERVER['HTTP_HOST']}");
else
die("Failed CORS");
session_start();
// Check CSRF token
if(!hash_equals($_SESSION['token'], $_POST['token']))
die("Wrong token");
require('auth.php');
switch($_POST['list']) {
case "white":
@@ -24,3 +9,5 @@ switch($_POST['list']) {
exec("sudo pihole -b -q -d ${_POST['domain']}");
break;
}
?>
+23 -21
View File
@@ -1,5 +1,5 @@
<?php
require "header.html";
require "header.php";
?>
<!--
@@ -17,26 +17,28 @@
</div>
<!-- /.box-header -->
<div class="box-body">
<table id="all-queries" class="display table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Time</th>
<th>Type</th>
<th>Domain</th>
<th>Client</th>
<th>Status</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Time</th>
<th>Type</th>
<th>Domain</th>
<th>Client</th>
<th>Status</th>
</tr>
</tfoot>
</table>
<div class="table-responsive">
<table id="all-queries" class="display table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Time</th>
<th>Type</th>
<th>Domain</th>
<th>Client</th>
<th>Status</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Time</th>
<th>Type</th>
<th>Domain</th>
<th>Client</th>
<th>Status</th>
</tr>
</tfoot>
</table>
</div>
</div>
<!-- /.box-body -->
</div>