mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Move login form to a new page
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
$api = true;
|
||||
require_once 'scripts/pi-hole/php/FTL.php';
|
||||
require_once 'scripts/pi-hole/php/password.php';
|
||||
require_once 'scripts/pi-hole/php/FTL.php';
|
||||
require_once 'scripts/pi-hole/php/database.php';
|
||||
require_once 'scripts/pi-hole/php/auth.php';
|
||||
check_cors();
|
||||
|
||||
+2
-1
@@ -8,9 +8,10 @@
|
||||
*/
|
||||
|
||||
$api = true;
|
||||
require 'scripts/pi-hole/php/password.php';
|
||||
|
||||
header('Content-type: application/json');
|
||||
require 'scripts/pi-hole/php/database.php';
|
||||
require 'scripts/pi-hole/php/password.php';
|
||||
require 'scripts/pi-hole/php/auth.php';
|
||||
require_once 'scripts/pi-hole/php/func.php';
|
||||
check_cors();
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
<!-- Sourceing CSS colors from stylesheet to be used in JS code -->
|
||||
<span class="queries-permitted"></span>
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<!-- Sourceing CSS colors from stylesheet to be used in JS code -->
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
<!-- Title -->
|
||||
<div class="page-header">
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
<!-- Title -->
|
||||
<div class="page-header">
|
||||
|
||||
+3
-2
@@ -1,4 +1,5 @@
|
||||
<?php /*
|
||||
<?php
|
||||
/*
|
||||
* Pi-hole: A black hole for Internet advertisements
|
||||
* (c) 2019 Pi-hole, LLC (https://pi-hole.net)
|
||||
* Network-wide ad blocking via your own hardware.
|
||||
@@ -7,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
$indexpage = true;
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
require_once 'scripts/pi-hole/php/gravity.php';
|
||||
?>
|
||||
<!-- Sourceing CSS colors from stylesheet to be used in JS code -->
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/*
|
||||
* Pi-hole: A black hole for Internet advertisements
|
||||
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
* Network-wide ad blocking via your own hardware.
|
||||
*
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/password.php';
|
||||
|
||||
// Go directly to index, if authenticated.
|
||||
if ($_SESSION['auth']) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require 'scripts/pi-hole/php/theme.php';
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
?>
|
||||
<body class="hold-transition layout-boxed login-page">
|
||||
<div class="box login-box">
|
||||
<section style="padding: 15px;">
|
||||
<div class="login-logo">
|
||||
<div class="text-center">
|
||||
<img src="img/logo.svg" alt="Pi-hole logo" class="loginpage-logo">
|
||||
</div>
|
||||
<div class="panel-title text-center"><span class="logo-lg" style="font-size: 25px;">Pi-<b>hole</b></span></div>
|
||||
</div>
|
||||
<!-- /.login-logo -->
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body login-card-body">
|
||||
<div id="cookieInfo" class="panel-title text-center text-red" style="font-size: 150%" hidden>Verify that cookies are allowed for <code><?php echo $_SERVER['HTTP_HOST']; ?></code></div>
|
||||
<?php if ($wrongpassword) { ?>
|
||||
<div class="form-group has-error login-box-msg">
|
||||
<label class="control-label"><i class="fa fa-times-circle"></i> Wrong password!</label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<form action="" id="loginform" method="post">
|
||||
<div class="form-group login-options has-feedback<?php if ($wrongpassword) { ?> has-error<?php } ?>">
|
||||
<div class="pwd-field">
|
||||
<input type="password" id="loginpw" name="pw" class="form-control" placeholder="Password" autocomplete="current-password" autofocus>
|
||||
<span class="fa fa-key form-control-feedback"></span>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="logincookie" name="persistentlogin">
|
||||
<label for="logincookie">Remember me for 7 days</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary form-control"><i class="fas fa-sign-in-alt"></i> Log in</button>
|
||||
</div>
|
||||
</form>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box box-<?php if (!$wrongpassword) { ?>info collapsed-box<?php } else { ?>danger<?php }?>">
|
||||
<div class="box-header with-border pointer no-user-select" data-widget="collapse">
|
||||
<h3 class="box-title">Forgot password?</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool">
|
||||
<i class="fa <?php if ($wrongpassword) { ?>fa-minus<?php } else { ?>fa-plus<?php } ?>"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<p>After installing Pi-hole for the first time, a password is generated and displayed
|
||||
to the user. The password cannot be retrieved later on, but it is possible to set
|
||||
a new password (or explicitly disable the password by setting an empty password)
|
||||
using the command
|
||||
</p>
|
||||
<pre>sudo pihole -a -p</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.login-card-body -->
|
||||
<div class="login-footer" style="margin-top: 15px; display: flex; justify-content: space-between;">
|
||||
<a class="btn btn-default btn-sm" role="button" href="https://docs.pi-hole.net/" target="_blank"><i class="fas fa-question-circle"></i> Documentation</a>
|
||||
<a class="btn btn-default btn-sm" role="button" href="https://github.com/pi-hole/" target="_blank"><i class="fab fa-github"></i> Github</a>
|
||||
<a class="btn btn-default btn-sm" role="button" href="https://discourse.pi-hole.net/" target="_blank"><i class="fab fa-discourse"></i> Pi-hole Discourse</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="login-donate">
|
||||
<div class="text-center" style="font-size:125%">
|
||||
<strong><a href="https://pi-hole.net/donate/" rel="noopener" target="_blank"><i class="fa fa-heart text-red"></i> Donate</a></strong> if you found this useful.
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/pi-hole/js/footer.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// If the user wants to log out, we free all session variables currently registered
|
||||
// and delete any persistent cookie.
|
||||
session_start();
|
||||
session_unset();
|
||||
setcookie('persistentlogin', '', 1);
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<!-- Title -->
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
|
||||
$showing = '';
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
<!-- Title -->
|
||||
<div class="page-header">
|
||||
|
||||
@@ -256,36 +256,41 @@ $("#pihole-disable-custom").on("click", function (e) {
|
||||
});
|
||||
|
||||
// Session timer
|
||||
var sessionTimerCounter = document.getElementById("sessiontimercounter");
|
||||
var sessionvalidity = parseInt(sessionTimerCounter.textContent, 10);
|
||||
var start = new Date();
|
||||
|
||||
function updateSessionTimer() {
|
||||
start = new Date();
|
||||
start.setSeconds(start.getSeconds() + sessionvalidity);
|
||||
}
|
||||
|
||||
if (sessionvalidity > 0) {
|
||||
// setSeconds will correctly handle wrap-around cases
|
||||
updateSessionTimer();
|
||||
var sessionTimerCounter, sessionvalidity, start;
|
||||
|
||||
setInterval(function () {
|
||||
var current = new Date();
|
||||
var totalseconds = (start - current) / 1000;
|
||||
var minutes = Math.floor(totalseconds / 60);
|
||||
if (minutes < 10) {
|
||||
minutes = "0" + minutes;
|
||||
}
|
||||
var sessiontimer = document.getElementById("sessiontimer");
|
||||
if (sessiontimer) {
|
||||
sessionTimerCounter = document.getElementById("sessiontimercounter");
|
||||
sessionvalidity = parseInt(sessionTimerCounter.textContent, 10);
|
||||
start = new Date();
|
||||
|
||||
var seconds = Math.floor(totalseconds % 60);
|
||||
if (seconds < 10) {
|
||||
seconds = "0" + seconds;
|
||||
}
|
||||
if (sessionvalidity > 0) {
|
||||
// setSeconds will correctly handle wrap-around cases
|
||||
updateSessionTimer();
|
||||
|
||||
sessionTimerCounter.textContent = totalseconds > 0 ? minutes + ":" + seconds : "-- : --";
|
||||
}, 1000);
|
||||
} else {
|
||||
document.getElementById("sessiontimer").style.display = "none";
|
||||
setInterval(function () {
|
||||
var current = new Date();
|
||||
var totalseconds = (start - current) / 1000;
|
||||
var minutes = Math.floor(totalseconds / 60);
|
||||
if (minutes < 10) {
|
||||
minutes = "0" + minutes;
|
||||
}
|
||||
|
||||
var seconds = Math.floor(totalseconds % 60);
|
||||
if (seconds < 10) {
|
||||
seconds = "0" + seconds;
|
||||
}
|
||||
|
||||
sessionTimerCounter.textContent = totalseconds > 0 ? minutes + ":" + seconds : "-- : --";
|
||||
}, 1000);
|
||||
} else {
|
||||
sessiontimer.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Ctrl + Enter button on Login page
|
||||
|
||||
+27
-265
@@ -1,153 +1,19 @@
|
||||
<?php
|
||||
/* Pi-hole: A black hole for Internet advertisements
|
||||
$scriptname = basename($_SERVER['SCRIPT_FILENAME']);
|
||||
$hostname = gethostname() ? gethostname() : '';
|
||||
|
||||
// Create cache busting version
|
||||
$cacheVer = filemtime(__FILE__);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
* Pi-hole: A black hole for Internet advertisements
|
||||
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
* Network-wide ad blocking via your own hardware.
|
||||
*
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/auth.php';
|
||||
require 'scripts/pi-hole/php/password.php';
|
||||
require_once 'scripts/pi-hole/php/FTL.php';
|
||||
require_once 'scripts/pi-hole/php/func.php';
|
||||
require 'scripts/pi-hole/php/theme.php';
|
||||
$scriptname = basename($_SERVER['SCRIPT_FILENAME']);
|
||||
$hostname = gethostname() ? gethostname() : '';
|
||||
|
||||
// Return memory usage to show on status block
|
||||
function getMemUsage()
|
||||
{
|
||||
$data = explode("\n", file_get_contents('/proc/meminfo'));
|
||||
$meminfo = array();
|
||||
if (count($data) > 0) {
|
||||
foreach ($data as $line) {
|
||||
$expl = explode(':', $line);
|
||||
if (count($expl) == 2) {
|
||||
// remove " kB" from the end of the string and make it an integer
|
||||
$meminfo[$expl[0]] = intval(trim(substr($expl[1], 0, -3)));
|
||||
}
|
||||
}
|
||||
$memused = $meminfo['MemTotal'] - $meminfo['MemFree'] - $meminfo['Buffers'] - $meminfo['Cached'];
|
||||
$memusage = $memused / $meminfo['MemTotal'];
|
||||
} else {
|
||||
$memusage = -1;
|
||||
}
|
||||
|
||||
return $memusage;
|
||||
}
|
||||
|
||||
// Try to get temperature value from different places (OS dependent)
|
||||
// - return an array, containing the temperature and limit.
|
||||
function getTemperature()
|
||||
{
|
||||
global $setupVars;
|
||||
|
||||
if (file_exists('/sys/class/thermal/thermal_zone0/temp')) {
|
||||
$output = rtrim(file_get_contents('/sys/class/thermal/thermal_zone0/temp'));
|
||||
} elseif (file_exists('/sys/class/hwmon/hwmon0/temp1_input')) {
|
||||
$output = rtrim(file_get_contents('/sys/class/hwmon/hwmon0/temp1_input'));
|
||||
} else {
|
||||
$output = '';
|
||||
}
|
||||
|
||||
// Test if we succeeded in getting the temperature
|
||||
if (is_numeric($output)) {
|
||||
// $output could be either 4-5 digits or 2-3, and we only divide by 1000 if it's 4-5
|
||||
// ex. 39007 vs 39
|
||||
$celsius = intval($output);
|
||||
|
||||
// If celsius is greater than 1 degree and is in the 4-5 digit format
|
||||
if ($celsius > 1000) {
|
||||
// Use multiplication to get around the division-by-zero error
|
||||
$celsius *= 1e-3;
|
||||
}
|
||||
|
||||
// Get user-defined temperature limit if set
|
||||
if (isset($setupVars['TEMPERATURE_LIMIT'])) {
|
||||
$limit = intval($setupVars['TEMPERATURE_LIMIT']);
|
||||
} else {
|
||||
$limit = 60;
|
||||
}
|
||||
} else {
|
||||
// Nothing can be colder than -273.15 degree Celsius (= 0 Kelvin)
|
||||
// This is the minimum temperature possible (AKA absolute zero)
|
||||
$celsius = -273.16;
|
||||
// Set templimit to null if no tempsensor was found
|
||||
$limit = null;
|
||||
}
|
||||
|
||||
return array($celsius, $limit);
|
||||
}
|
||||
|
||||
check_cors();
|
||||
|
||||
// Create cache busting version
|
||||
$cacheVer = filemtime(__FILE__);
|
||||
|
||||
// Generate CSRF token
|
||||
if (empty($_SESSION['token'])) {
|
||||
$_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32));
|
||||
}
|
||||
$token = $_SESSION['token'];
|
||||
|
||||
if ($auth) {
|
||||
// For session timer
|
||||
$maxlifetime = ini_get('session.gc_maxlifetime');
|
||||
|
||||
// Generate CSRF token
|
||||
if (empty($_SESSION['token'])) {
|
||||
$_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32));
|
||||
}
|
||||
$token = $_SESSION['token'];
|
||||
}
|
||||
|
||||
// Get temperature
|
||||
list($celsius, $temperaturelimit) = getTemperature();
|
||||
|
||||
// Get CPU load
|
||||
$loaddata = sys_getloadavg();
|
||||
foreach ($loaddata as $key => $value) {
|
||||
$loaddata[$key] = round($value, 2);
|
||||
}
|
||||
|
||||
// Get number of processing units available to PHP
|
||||
// (may be less than the number of online processors)
|
||||
$nproc = shell_exec('nproc');
|
||||
if (!is_numeric($nproc)) {
|
||||
$cpuinfo = file_get_contents('/proc/cpuinfo');
|
||||
preg_match_all('/^processor/m', $cpuinfo, $matches);
|
||||
$nproc = count($matches[0]);
|
||||
}
|
||||
|
||||
// Get memory usage
|
||||
$memory_usage = getMemUsage();
|
||||
|
||||
// Retrieve layout setting from setupVars
|
||||
if (isset($setupVars['WEBUIBOXEDLAYOUT']) && !($setupVars['WEBUIBOXEDLAYOUT'] === 'boxed')) {
|
||||
$boxedlayout = false;
|
||||
} else {
|
||||
$boxedlayout = true;
|
||||
}
|
||||
|
||||
// Override layout setting if layout is changed via Settings page
|
||||
if (isset($_POST['field'])) {
|
||||
if ($_POST['field'] === 'webUI' && isset($_POST['boxedlayout'])) {
|
||||
$boxedlayout = true;
|
||||
} elseif ($_POST['field'] === 'webUI' && !isset($_POST['boxedlayout'])) {
|
||||
$boxedlayout = false;
|
||||
}
|
||||
}
|
||||
|
||||
$piholeFTLConf = piholeFTLConfig();
|
||||
?>
|
||||
<!doctype html>
|
||||
<!-- Pi-hole: A black hole for Internet advertisements
|
||||
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
* Network-wide ad blocking via your own hardware.
|
||||
*
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. -->
|
||||
-->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@@ -156,8 +22,8 @@ $piholeFTLConf = piholeFTLConfig();
|
||||
<!-- Usually browsers proactively perform domain name resolution on links that the user may choose to follow. We disable DNS prefetching here -->
|
||||
<meta http-equiv="x-dns-prefetch-control" content="off">
|
||||
<meta http-equiv="cache-control" content="max-age=60,private">
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>Pi-hole<?php echo $hostname ? ' - '.$hostname : ''; ?></title>
|
||||
|
||||
<link rel="apple-touch-icon" href="img/favicons/apple-touch-icon.png" sizes="180x180">
|
||||
@@ -168,12 +34,17 @@ $piholeFTLConf = piholeFTLConfig();
|
||||
<link rel="shortcut icon" href="img/favicons/favicon.ico">
|
||||
<meta name="msapplication-TileColor" content="#367fa9">
|
||||
<meta name="msapplication-TileImage" content="img/favicons/mstile-150x150.png">
|
||||
|
||||
<!-- Theme styles -->
|
||||
<?php if ($theme == 'default-light') { ?>
|
||||
<meta name="theme-color" content="#367fa9">
|
||||
<link rel="stylesheet" href="style/vendor/SourceSansPro/SourceSansPro.css?v=<?php echo $cacheVer; ?>">
|
||||
<?php } elseif ($theme == 'default-dark') { ?>
|
||||
<meta name="theme-color" content="#272c30">
|
||||
<link rel="stylesheet" href="style/vendor/SourceSansPro/SourceSansPro.css?v=<?php echo $cacheVer; ?>">
|
||||
<?php } elseif ($theme == 'default-darker') { ?>
|
||||
<meta name="theme-color" content="#2e6786">
|
||||
<link rel="stylesheet" href="style/vendor/SourceSansPro/SourceSansPro.css?v=<?php echo $cacheVer; ?>">
|
||||
<?php } elseif ($theme == 'lcars') { ?>
|
||||
<meta name="theme-color" content="#4488FF">
|
||||
<link rel="stylesheet" href="style/vendor/fonts/ubuntu-mono/ubuntu-mono.css?v=<?php echo $cacheVer; ?>">
|
||||
@@ -185,152 +56,43 @@ $piholeFTLConf = piholeFTLConfig();
|
||||
html { background-color: #000; }
|
||||
</style>
|
||||
<?php } ?>
|
||||
<link rel="stylesheet" href="style/vendor/SourceSansPro/SourceSansPro.css?v=<?php echo $cacheVer; ?>">
|
||||
|
||||
<!-- Common styles -->
|
||||
<link rel="stylesheet" href="style/vendor/bootstrap/css/bootstrap.min.css?v=<?php echo $cacheVer; ?>">
|
||||
<?php if ($auth) { ?>
|
||||
<link rel="stylesheet" href="style/vendor/datatables.min.css?v=<?php echo $cacheVer; ?>">
|
||||
<link rel="stylesheet" href="style/vendor/datatables_extensions.min.css?v=<?php echo $cacheVer; ?>">
|
||||
<link rel="stylesheet" href="style/vendor/daterangepicker.min.css?v=<?php echo $cacheVer; ?>">
|
||||
<?php } ?>
|
||||
<link rel="stylesheet" href="style/vendor/AdminLTE.min.css?v=<?php echo $cacheVer; ?>">
|
||||
<link rel="stylesheet" href="style/vendor/select2.min.css?v=<?php echo $cacheVer; ?>">
|
||||
|
||||
<?php if (in_array($scriptname, array('groups.php', 'groups-adlists.php', 'groups-clients.php', 'groups-domains.php'))) { ?>
|
||||
<!-- Group management styles -->
|
||||
<link rel="stylesheet" href="style/vendor/animate.min.css?v=<?php echo $cacheVer; ?>">
|
||||
<link rel="stylesheet" href="style/vendor/bootstrap-select.min.css?v=<?php echo $cacheVer; ?>">
|
||||
<link rel="stylesheet" href="style/vendor/bootstrap-toggle.min.css?v=<?php echo $cacheVer; ?>">
|
||||
<?php } ?>
|
||||
|
||||
<!-- Theme styles -->
|
||||
<link rel="stylesheet" href="style/pi-hole.css?v=<?php echo $cacheVer; ?>">
|
||||
<link rel="stylesheet" href="style/themes/<?php echo $theme; ?>.css?v=<?php echo $cacheVer; ?>">
|
||||
|
||||
<noscript><link rel="stylesheet" href="style/vendor/js-warn.css?v=<?php echo $cacheVer; ?>"></noscript>
|
||||
|
||||
<!-- scripts -->
|
||||
<script src="scripts/vendor/jquery.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<script src="style/vendor/bootstrap/js/bootstrap.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<script src="scripts/vendor/adminlte.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<script src="scripts/vendor/bootstrap-notify.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<?php if ($auth) { ?>
|
||||
<script src="scripts/vendor/select2.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<script src="scripts/vendor/datatables.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<script src="scripts/vendor/datatables.select.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<script src="scripts/vendor/datatables.buttons.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<script src="scripts/vendor/moment.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<script src="scripts/vendor/Chart.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<?php } ?>
|
||||
<script src="style/vendor/font-awesome/js/all.min.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
<script src="scripts/pi-hole/js/utils.js?v=<?php echo $cacheVer; ?>"></script>
|
||||
</head>
|
||||
<body class="hold-transition sidebar-mini<?php if ($boxedlayout) { ?> layout-boxed<?php } ?><?php if ($auth) { ?> logged-in<?php } ?>">
|
||||
<noscript>
|
||||
<!-- JS Warning -->
|
||||
<div>
|
||||
<input type="checkbox" id="js-hide">
|
||||
<div class="js-warn" id="js-warn-exit"><h1>JavaScript Is Disabled</h1><p>JavaScript is required for the site to function.</p>
|
||||
<p>To learn how to enable JavaScript click <a href="https://www.enable-javascript.com/" rel="noopener" target="_blank">here</a></p><label for="js-hide">Close</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /JS Warning -->
|
||||
</noscript>
|
||||
<?php
|
||||
if ($auth) {
|
||||
echo "<div id=\"token\" hidden>{$token}</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Send token to JS -->
|
||||
<div id="enableTimer" hidden><?php if (file_exists('../custom_disable_timer')) {
|
||||
echo file_get_contents('../custom_disable_timer');
|
||||
} ?></div>
|
||||
<div class="wrapper">
|
||||
<header class="main-header">
|
||||
<!-- Logo -->
|
||||
<a href="index.php" class="logo">
|
||||
<!-- mini logo for sidebar mini 50x50 pixels -->
|
||||
<span class="logo-mini">P<strong>h</strong></span>
|
||||
<!-- logo for regular state and mobile devices -->
|
||||
<span class="logo-lg">Pi-<strong>hole</strong></span>
|
||||
</a>
|
||||
<!-- Header Navbar: style can be found in header.less -->
|
||||
<nav class="navbar navbar-static-top">
|
||||
<!-- Sidebar toggle button-->
|
||||
<a href="#" class="sidebar-toggle-svg" data-toggle="push-menu" role="button">
|
||||
<i aria-hidden="true" class="fa fa-bars"></i>
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="warning-count hidden" id="top-warning-count"></span>
|
||||
</a>
|
||||
<div class="navbar-custom-menu">
|
||||
<ul class="nav navbar-nav">
|
||||
<li<?php echo !$hostname ? ' class="hidden"' : ''; ?>>
|
||||
<p class="navbar-text">
|
||||
<span class="hidden-xs hidden-sm">hostname:</span>
|
||||
<code><?php echo $hostname; ?></code>
|
||||
</p>
|
||||
</li>
|
||||
<li class="dropdown user user-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
||||
<img src="img/logo.svg" class="user-image" alt="Pi-hole logo" style="border-radius: 0" width="25" height="25">
|
||||
<span class="hidden-xs">Pi-hole</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<!-- User image -->
|
||||
<li class="user-header">
|
||||
<img src="img/logo.svg" alt="Pi-hole Logo" style="border: 0" width="90" height="90">
|
||||
<p>
|
||||
Open Source Ad Blocker
|
||||
<small>Designed For Raspberry Pi</small>
|
||||
</p>
|
||||
</li>
|
||||
<!-- Menu Body -->
|
||||
<li class="user-body">
|
||||
<div class="row">
|
||||
<div class="col-xs-4 text-center">
|
||||
<a class="btn-link" href="https://github.com/pi-hole" rel="noopener" target="_blank">GitHub</a>
|
||||
</div>
|
||||
<div class="col-xs-4 text-center">
|
||||
<a class="btn-link" href="https://pi-hole.net/" rel="noopener" target="_blank">Website</a>
|
||||
</div>
|
||||
<div class="col-xs-4 text-center">
|
||||
<a class="btn-link" href="https://github.com/pi-hole/pi-hole/releases" rel="noopener" target="_blank">Updates</a>
|
||||
</div>
|
||||
<div id="sessiontimer" class="col-xs-12 text-center">
|
||||
<strong>Session is valid for <span id="sessiontimercounter">
|
||||
<?php if ($auth && strlen($pwhash) > 0) {
|
||||
echo $maxlifetime;
|
||||
} else {
|
||||
echo '0';
|
||||
} ?>
|
||||
</span></strong>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<!-- Menu Footer -->
|
||||
<li class="user-footer">
|
||||
<!-- Donate Button -->
|
||||
<div class="text-center">
|
||||
<a class="btn btn-primary btn-lg donate" href="https://pi-hole.net/donate/" rel="noopener" target="_blank">
|
||||
<i class="fas fa-fw menu-icon fa-donate"></i> Donate
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<?php require 'scripts/pi-hole/php/sidebar.php'; ?>
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<div class="content-wrapper">
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
<?php
|
||||
// If password is not equal to the password set
|
||||
// in the setupVars.conf file, then we skip any
|
||||
// content and just complete the page. If no
|
||||
// password is set at all, we keep the current
|
||||
// behavior: everything is always authorized
|
||||
// and will be displayed
|
||||
//
|
||||
// If auth is required and not set, i.e. no successfully logged in,
|
||||
// we show the reduced version of the summary (index) page
|
||||
if (!$auth && (!isset($indexpage) || isset($_GET['login']))) {
|
||||
require 'scripts/pi-hole/php/loginpage.php';
|
||||
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/*
|
||||
* Pi-hole: A black hole for Internet advertisements
|
||||
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
* Network-wide ad blocking via your own hardware.
|
||||
*
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/password.php';
|
||||
if (!$auth) {
|
||||
$_SESSION['prev_url'] = $_SERVER['REQUEST_URI'];
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require 'scripts/pi-hole/php/auth.php';
|
||||
require_once 'scripts/pi-hole/php/FTL.php';
|
||||
require_once 'scripts/pi-hole/php/func.php';
|
||||
require 'scripts/pi-hole/php/theme.php';
|
||||
|
||||
// Retrieve layout setting from setupVars
|
||||
if (isset($setupVars['WEBUIBOXEDLAYOUT']) && !$setupVars['WEBUIBOXEDLAYOUT'] === 'boxed') {
|
||||
$boxedlayout = false;
|
||||
} else {
|
||||
$boxedlayout = true;
|
||||
}
|
||||
|
||||
// Override layout setting if layout is changed via Settings page
|
||||
if (isset($_POST['field'])) {
|
||||
if ($_POST['field'] === 'webUI' && isset($_POST['boxedlayout'])) {
|
||||
$boxedlayout = true;
|
||||
} elseif ($_POST['field'] === 'webUI' && !isset($_POST['boxedlayout'])) {
|
||||
$boxedlayout = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Return memory usage to show on status block
|
||||
function getMemUsage()
|
||||
{
|
||||
$data = explode("\n", file_get_contents('/proc/meminfo'));
|
||||
$meminfo = array();
|
||||
if (count($data) > 0) {
|
||||
foreach ($data as $line) {
|
||||
$expl = explode(':', $line);
|
||||
if (count($expl) == 2) {
|
||||
// remove " kB" from the end of the string and make it an integer
|
||||
$meminfo[$expl[0]] = intval(trim(substr($expl[1], 0, -3)));
|
||||
}
|
||||
}
|
||||
$memused = $meminfo['MemTotal'] - $meminfo['MemFree'] - $meminfo['Buffers'] - $meminfo['Cached'];
|
||||
$memusage = $memused / $meminfo['MemTotal'];
|
||||
} else {
|
||||
$memusage = -1;
|
||||
}
|
||||
|
||||
return $memusage;
|
||||
}
|
||||
|
||||
// Try to get temperature value from different places (OS dependent)
|
||||
// - return an array, containing the temperature and limit.
|
||||
function getTemperature()
|
||||
{
|
||||
global $setupVars;
|
||||
|
||||
if (file_exists('/sys/class/thermal/thermal_zone0/temp')) {
|
||||
$output = rtrim(file_get_contents('/sys/class/thermal/thermal_zone0/temp'));
|
||||
} elseif (file_exists('/sys/class/hwmon/hwmon0/temp1_input')) {
|
||||
$output = rtrim(file_get_contents('/sys/class/hwmon/hwmon0/temp1_input'));
|
||||
} else {
|
||||
$output = '';
|
||||
}
|
||||
|
||||
// Test if we succeeded in getting the temperature
|
||||
if (is_numeric($output)) {
|
||||
// $output could be either 4-5 digits or 2-3, and we only divide by 1000 if it's 4-5
|
||||
// ex. 39007 vs 39
|
||||
$celsius = intval($output);
|
||||
|
||||
// If celsius is greater than 1 degree and is in the 4-5 digit format
|
||||
if ($celsius > 1000) {
|
||||
// Use multiplication to get around the division-by-zero error
|
||||
$celsius *= 1e-3;
|
||||
}
|
||||
|
||||
// Get user-defined temperature limit if set
|
||||
if (isset($setupVars['TEMPERATURE_LIMIT'])) {
|
||||
$limit = intval($setupVars['TEMPERATURE_LIMIT']);
|
||||
} else {
|
||||
$limit = 60;
|
||||
}
|
||||
} else {
|
||||
// Nothing can be colder than -273.15 degree Celsius (= 0 Kelvin)
|
||||
// This is the minimum temperature possible (AKA absolute zero)
|
||||
$celsius = -273.16;
|
||||
// Set templimit to null if no tempsensor was found
|
||||
$limit = null;
|
||||
}
|
||||
|
||||
return array($celsius, $limit);
|
||||
}
|
||||
|
||||
check_cors();
|
||||
|
||||
// Generate CSRF token
|
||||
if (empty($_SESSION['token'])) {
|
||||
$_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32));
|
||||
}
|
||||
$token = $_SESSION['token'];
|
||||
|
||||
// For session timer
|
||||
$maxlifetime = ini_get('session.gc_maxlifetime');
|
||||
|
||||
// Get temperature
|
||||
list($celsius, $temperaturelimit) = getTemperature();
|
||||
|
||||
// Get CPU load
|
||||
$loaddata = sys_getloadavg();
|
||||
foreach ($loaddata as $key => $value) {
|
||||
$loaddata[$key] = round($value, 2);
|
||||
}
|
||||
|
||||
// Get number of processing units available to PHP
|
||||
// (may be less than the number of online processors)
|
||||
$nproc = shell_exec('nproc');
|
||||
if (!is_numeric($nproc)) {
|
||||
$cpuinfo = file_get_contents('/proc/cpuinfo');
|
||||
preg_match_all('/^processor/m', $cpuinfo, $matches);
|
||||
$nproc = count($matches[0]);
|
||||
}
|
||||
|
||||
// Get memory usage
|
||||
$memory_usage = getMemUsage();
|
||||
|
||||
$piholeFTLConf = piholeFTLConfig();
|
||||
|
||||
require 'header.php';
|
||||
?>
|
||||
<body class="hold-transition sidebar-mini<?php if ($boxedlayout) { ?> layout-boxed<?php } ?><?php if ($auth) { ?> logged-in<?php } ?>">
|
||||
<noscript>
|
||||
<!-- JS Warning -->
|
||||
<div>
|
||||
<input type="checkbox" id="js-hide">
|
||||
<div class="js-warn" id="js-warn-exit"><h1>JavaScript Is Disabled</h1><p>JavaScript is required for the site to function.</p>
|
||||
<p>To learn how to enable JavaScript click <a href="https://www.enable-javascript.com/" rel="noopener" target="_blank">here</a></p><label for="js-hide">Close</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /JS Warning -->
|
||||
</noscript>
|
||||
<?php
|
||||
if ($auth) {
|
||||
echo "<div id=\"token\" hidden>{$token}</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Send token to JS -->
|
||||
<div id="enableTimer" hidden><?php if (file_exists('../custom_disable_timer')) {
|
||||
echo file_get_contents('../custom_disable_timer');
|
||||
} ?></div>
|
||||
<div class="wrapper">
|
||||
<header class="main-header">
|
||||
<!-- Logo -->
|
||||
<a href="index.php" class="logo">
|
||||
<!-- mini logo for sidebar mini 50x50 pixels -->
|
||||
<span class="logo-mini">P<strong>h</strong></span>
|
||||
<!-- logo for regular state and mobile devices -->
|
||||
<span class="logo-lg">Pi-<strong>hole</strong></span>
|
||||
</a>
|
||||
<!-- Header Navbar: style can be found in header.less -->
|
||||
<nav class="navbar navbar-static-top">
|
||||
<!-- Sidebar toggle button-->
|
||||
<a href="#" class="sidebar-toggle-svg" data-toggle="push-menu" role="button">
|
||||
<i aria-hidden="true" class="fa fa-bars"></i>
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="warning-count hidden" id="top-warning-count"></span>
|
||||
</a>
|
||||
<div class="navbar-custom-menu">
|
||||
<ul class="nav navbar-nav">
|
||||
<li<?php echo !$hostname ? ' class="hidden"' : ''; ?>>
|
||||
<p class="navbar-text">
|
||||
<span class="hidden-xs hidden-sm">hostname:</span>
|
||||
<code><?php echo $hostname; ?></code>
|
||||
</p>
|
||||
</li>
|
||||
<li class="dropdown user user-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
||||
<img src="img/logo.svg" class="user-image" alt="Pi-hole logo" style="border-radius: 0" width="25" height="25">
|
||||
<span class="hidden-xs">Pi-hole</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<!-- User image -->
|
||||
<li class="user-header">
|
||||
<img src="img/logo.svg" alt="Pi-hole Logo" style="border: 0" width="90" height="90">
|
||||
<p>
|
||||
Open Source Ad Blocker
|
||||
<small>Designed For Raspberry Pi</small>
|
||||
</p>
|
||||
</li>
|
||||
<!-- Menu Body -->
|
||||
<li class="user-body">
|
||||
<div class="row">
|
||||
<div class="col-xs-4 text-center">
|
||||
<a class="btn-link" href="https://github.com/pi-hole" rel="noopener" target="_blank">GitHub</a>
|
||||
</div>
|
||||
<div class="col-xs-4 text-center">
|
||||
<a class="btn-link" href="https://pi-hole.net/" rel="noopener" target="_blank">Website</a>
|
||||
</div>
|
||||
<div class="col-xs-4 text-center">
|
||||
<a class="btn-link" href="https://github.com/pi-hole/pi-hole/releases" rel="noopener" target="_blank">Updates</a>
|
||||
</div>
|
||||
<div id="sessiontimer" class="col-xs-12 text-center">
|
||||
<strong>Session is valid for <span id="sessiontimercounter">
|
||||
<?php if ($auth && strlen($pwhash) > 0) {
|
||||
echo $maxlifetime;
|
||||
} else {
|
||||
echo '0';
|
||||
} ?>
|
||||
</span></strong>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<!-- Menu Footer -->
|
||||
<li class="user-footer">
|
||||
<!-- Donate Button -->
|
||||
<div class="text-center">
|
||||
<a class="btn btn-primary btn-lg donate" href="https://pi-hole.net/donate/" rel="noopener" target="_blank">
|
||||
<i class="fas fa-fw menu-icon fa-donate"></i> Donate
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<?php require 'scripts/pi-hole/php/sidebar.php'; ?>
|
||||
<!-- Content Wrapper. Contains page content -->
|
||||
<div class="content-wrapper">
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
@@ -9,11 +9,12 @@
|
||||
|
||||
require_once 'func.php';
|
||||
|
||||
// Start a new PHP session (or continue an existing one)
|
||||
// Prevents javascript XSS attacks aimed to steal the session ID
|
||||
ini_set('session.cookie_httponly', 1);
|
||||
// Prevent Session ID from being passed through URLs
|
||||
ini_set('session.use_only_cookies', 1);
|
||||
|
||||
// Start a new PHP session (or continue an existing one)
|
||||
session_start();
|
||||
|
||||
// Read setupVars.conf file
|
||||
@@ -25,81 +26,82 @@ if (isset($setupVars['WEBPASSWORD'])) {
|
||||
$pwhash = '';
|
||||
}
|
||||
|
||||
// If the user wants to log out, we free all session variables currently registered
|
||||
// and delete any persistent cookie.
|
||||
if (isset($_GET['logout'])) {
|
||||
session_unset();
|
||||
setcookie('persistentlogin', '', 1);
|
||||
header('Location: index.php');
|
||||
function verifyPassword($pwhash)
|
||||
{
|
||||
$validpassword = true;
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$wrongpassword = false;
|
||||
$auth = false;
|
||||
|
||||
// Test if password is set
|
||||
if (strlen($pwhash) > 0) {
|
||||
// Check for and authorize from persistent cookie
|
||||
if (isset($_COOKIE['persistentlogin'])) {
|
||||
if (hash_equals($pwhash, $_COOKIE['persistentlogin'])) {
|
||||
$auth = true;
|
||||
// Refresh cookie with new expiry
|
||||
// setcookie( $name, $value, $expire, $path, $domain, $secure, $httponly )
|
||||
setcookie('persistentlogin', $pwhash, time() + 60 * 60 * 24 * 7, null, null, null, true);
|
||||
} else {
|
||||
// Invalid cookie
|
||||
$auth = false;
|
||||
setcookie('persistentlogin', '', 1);
|
||||
}
|
||||
}
|
||||
// Compare doubly hashes password input with saved hash
|
||||
elseif (isset($_POST['pw'])) {
|
||||
$postinput = hash('sha256', hash('sha256', $_POST['pw']));
|
||||
if (hash_equals($pwhash, $postinput)) {
|
||||
// Regenerate session ID to prevent session fixation
|
||||
session_regenerate_id();
|
||||
|
||||
// Clear the old session
|
||||
$_SESSION = array();
|
||||
|
||||
// Set hash in new session
|
||||
$_SESSION['hash'] = $pwhash;
|
||||
|
||||
// Set persistent cookie if selected
|
||||
if (isset($_POST['persistentlogin'])) {
|
||||
// Test if password is set
|
||||
if (strlen($pwhash) > 0) {
|
||||
// Check for and authorize from persistent cookie
|
||||
if (isset($_COOKIE['persistentlogin'])) {
|
||||
if (hash_equals($pwhash, $_COOKIE['persistentlogin'])) {
|
||||
$_SESSION['auth'] = true;
|
||||
// Refresh cookie with new expiry
|
||||
// setcookie( $name, $value, $expire, $path, $domain, $secure, $httponly )
|
||||
setcookie('persistentlogin', $pwhash, time() + 60 * 60 * 24 * 7, null, null, null, true);
|
||||
} else {
|
||||
// Invalid cookie
|
||||
$_SESSION['auth'] = false;
|
||||
setcookie('persistentlogin', '', 1);
|
||||
}
|
||||
} elseif (isset($_POST['pw'])) {
|
||||
// Compare doubly hashes password input with saved hash
|
||||
$postinput = hash('sha256', hash('sha256', $_POST['pw']));
|
||||
|
||||
// Login successful, redirect the user to the homepage to discard the POST request
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER['QUERY_STRING'] === 'login') {
|
||||
header('Location: index.php');
|
||||
if (hash_equals($pwhash, $postinput)) {
|
||||
// Save previously accessed page, before clear the session
|
||||
$redirect_url = 'index.php';
|
||||
if (isset($_SESSION['prev_url'])) {
|
||||
$redirect_url = $_SESSION['prev_url'];
|
||||
}
|
||||
|
||||
exit;
|
||||
// Regenerate session ID to prevent session fixation
|
||||
session_regenerate_id();
|
||||
|
||||
// Clear the old session
|
||||
$_SESSION = array();
|
||||
|
||||
// Set hash in new session
|
||||
$_SESSION['hash'] = $pwhash;
|
||||
|
||||
// Set persistent cookie if selected
|
||||
if (isset($_POST['persistentlogin'])) {
|
||||
// setcookie( $name, $value, $expire, $path, $domain, $secure, $httponly )
|
||||
setcookie('persistentlogin', $pwhash, time() + 60 * 60 * 24 * 7, null, null, null, true);
|
||||
}
|
||||
|
||||
$_SESSION['auth'] = true;
|
||||
|
||||
// Login successful, redirect the user to the original requested page
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER['SCRIPT_NAME'] === '/admin/login.php') {
|
||||
header('Location: '.$redirect_url);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$_SESSION['auth'] = false;
|
||||
$validpassword = false;
|
||||
}
|
||||
} elseif (isset($_SESSION['hash'])) {
|
||||
// Compare auth hash with saved hash
|
||||
if (hash_equals($pwhash, $_SESSION['hash'])) {
|
||||
$_SESSION['auth'] = true;
|
||||
}
|
||||
} elseif (isset($api) && isset($_GET['auth'])) {
|
||||
// API can use the hash to get data without logging in via plain-text password
|
||||
if (hash_equals($pwhash, $_GET['auth'])) {
|
||||
$_SESSION['auth'] = true;
|
||||
}
|
||||
|
||||
$auth = true;
|
||||
} else {
|
||||
$wrongpassword = true;
|
||||
}
|
||||
}
|
||||
// Compare auth hash with saved hash
|
||||
elseif (isset($_SESSION['hash'])) {
|
||||
if (hash_equals($pwhash, $_SESSION['hash'])) {
|
||||
$auth = true;
|
||||
}
|
||||
}
|
||||
// API can use the hash to get data without logging in via plain-text password
|
||||
elseif (isset($api, $_GET['auth'])) {
|
||||
if (hash_equals($pwhash, $_GET['auth'])) {
|
||||
$auth = true;
|
||||
// Password or hash wrong
|
||||
$_SESSION['auth'] = false;
|
||||
}
|
||||
} else {
|
||||
// Password or hash wrong
|
||||
$auth = false;
|
||||
// No password set
|
||||
$_SESSION['auth'] = true;
|
||||
}
|
||||
} else {
|
||||
// No password set
|
||||
$auth = true;
|
||||
|
||||
return $validpassword;
|
||||
}
|
||||
|
||||
$wrongpassword = !verifyPassword($pwhash);
|
||||
$auth = $_SESSION['auth'];
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
if (strlen($pwhash) > 0 && $auth) {
|
||||
?>
|
||||
<li>
|
||||
<a href="?logout">
|
||||
<a href="logout.php">
|
||||
<i class="fa fa-fw menu-icon fa-sign-out-alt"></i> <span>Logout</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
require 'scripts/pi-hole/php/savesettings.php';
|
||||
require_once 'scripts/pi-hole/php/FTL.php';
|
||||
|
||||
|
||||
+33
-23
@@ -496,16 +496,34 @@ td.details-control {
|
||||
}
|
||||
}
|
||||
|
||||
/*** Login form ***/
|
||||
/*** Login page ***/
|
||||
.login-page {
|
||||
padding: 15px;
|
||||
min-height: 100vh !important;
|
||||
height: auto !important;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.login-box {
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
padding: 5px;
|
||||
width: 480px;
|
||||
max-width: 100%;
|
||||
flex: 0 1 auto;
|
||||
align-self: center;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.form-control-feedback {
|
||||
right: 12px;
|
||||
}
|
||||
|
||||
.loginpage-logo {
|
||||
width: 30%;
|
||||
}
|
||||
.layout-boxed .loginpage-logo {
|
||||
width: 50%;
|
||||
width: 140px;
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
.login-options {
|
||||
@@ -530,27 +548,19 @@ td.details-control {
|
||||
flex: 1 0 auto;
|
||||
}
|
||||
|
||||
.login-help {
|
||||
padding: 6px;
|
||||
background: rgba(127, 127, 127, 0.05);
|
||||
.login-footer a {
|
||||
text-align: center;
|
||||
min-width: 28%;
|
||||
}
|
||||
@media screen and (max-width: 420px) {
|
||||
.login-footer a {
|
||||
min-width: auto;
|
||||
padding: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.login-help p {
|
||||
margin: 0;
|
||||
font-size: clamp(11px, (100vw - 400px) / 45, 15px);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
.layout-boxed:not(.sidebar-collapse) .login-help p {
|
||||
font-size: clamp(11px, (min(100vw, 1250px) - 380px) / 47, 15px);
|
||||
}
|
||||
|
||||
/* hide warning icon only when logged in and menu is not collapsed */
|
||||
.logged-in:not(.sidebar-collapse) #top-warning-count {
|
||||
display: none;
|
||||
}
|
||||
.login-donate {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
/*** Warning icon and count ***/
|
||||
|
||||
@@ -596,6 +596,10 @@ input[type="password"]::-webkit-caps-lock-indicator {
|
||||
color: #383838;
|
||||
}
|
||||
|
||||
.login-page {
|
||||
background-image: linear-gradient(#0006, #0006), url("../../img/boxed-bg-dark.png");
|
||||
}
|
||||
|
||||
/*** Fix login input visual misalignment ***/
|
||||
#loginform,
|
||||
#loginform input {
|
||||
|
||||
@@ -3634,7 +3634,6 @@ a:focus {
|
||||
.login-page,
|
||||
.register-page {
|
||||
background-color: rgb(46, 50, 52);
|
||||
background-image: none;
|
||||
}
|
||||
.login-box-body,
|
||||
.register-box-body {
|
||||
|
||||
@@ -158,6 +158,10 @@
|
||||
background-color: #3b8ab8;
|
||||
}
|
||||
|
||||
.login-box {
|
||||
background: #f0f2f4;
|
||||
}
|
||||
|
||||
.not-used {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
+22
-48
@@ -337,39 +337,35 @@ p.login-box-msg,
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.form-group.has-error.login-box-msg::before {
|
||||
.has-error.login-box-msg::before,
|
||||
.has-error.login-box-msg::after {
|
||||
content: "ACCESS DENIED";
|
||||
margin: -20px -20px 20px;
|
||||
padding: calc(45px + 0.7em) 0 0;
|
||||
padding: calc(176px - 0.5em) 0 0;
|
||||
position: absolute;
|
||||
inset: 0 0 0 0;
|
||||
color: #630030;
|
||||
font-size: 3.825em;
|
||||
font-size: calc((100vw - var(--sidebar-width) - 60px) / 12);
|
||||
font-size: clamp(40px, calc((100vw - 60px) / 6), 90px);
|
||||
line-height: 1;
|
||||
background: rgba(0, 0, 0, 0.88);
|
||||
height: calc(176px + 2em);
|
||||
}
|
||||
|
||||
.form-group.has-error.login-box-msg::before {
|
||||
color: #600;
|
||||
background-image: linear-gradient(
|
||||
rgba(0, 0, 0, 0),
|
||||
rgba(0, 0, 0, 0.7) 10%,
|
||||
rgba(0, 0, 0, 0.7) 70%,
|
||||
rgba(0, 0, 0, 0)
|
||||
);
|
||||
text-shadow: 0 0 0.25em #000;
|
||||
}
|
||||
|
||||
.form-group.has-error.login-box-msg::after {
|
||||
content: "ACCESS DENIED";
|
||||
margin: -20px -20px 20px;
|
||||
padding: calc(45px + 0.7em) 0 0;
|
||||
position: absolute;
|
||||
inset: 0 0 0 0;
|
||||
color: #e33100;
|
||||
font-size: 3.825em;
|
||||
font-size: calc((100vw - var(--sidebar-width) - 60px) / 12);
|
||||
line-height: 1;
|
||||
text-shadow: 0 0 5px #e33100;
|
||||
color: #e30;
|
||||
animation: 3s infinite Pulse steps(30);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.layout-boxed .form-group.has-error.login-box-msg::before,
|
||||
.layout-boxed .form-group.has-error.login-box-msg::after {
|
||||
padding: calc(50% - 0.5em) 0 0;
|
||||
}
|
||||
|
||||
#loginform .has-error + .row .btn {
|
||||
background: #d43;
|
||||
}
|
||||
@@ -383,10 +379,6 @@ p.login-box-msg,
|
||||
background: #f00;
|
||||
}
|
||||
|
||||
.login-help p {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.input-group .input-group-addon {
|
||||
border-radius: 8px 0 0 8px;
|
||||
border-right: none;
|
||||
@@ -1100,6 +1092,11 @@ table.table-bordered.dataTable td {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.login-box {
|
||||
margin-bottom: 0;
|
||||
background: #181818;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
border: none;
|
||||
}
|
||||
@@ -1552,13 +1549,6 @@ table.dataTable {
|
||||
/*** MEDIA QUERIES ***/
|
||||
|
||||
/*--- Media - max-width ---*/
|
||||
@media (max-width: 991px) {
|
||||
.form-group.has-error.login-box-msg::before,
|
||||
.form-group.has-error.login-box-msg::after {
|
||||
font-size: calc((100vw - var(--sidebar-width) - 60px) / 9);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.sidebar-collapse {
|
||||
--sidebar-width: 230px;
|
||||
@@ -1645,10 +1635,6 @@ table.dataTable {
|
||||
.main-footer {
|
||||
margin-left: 0;
|
||||
}
|
||||
.form-group.has-error.login-box-msg::before,
|
||||
.form-group.has-error.login-box-msg::after {
|
||||
font-size: calc((100vw - 60px) / 6);
|
||||
}
|
||||
}
|
||||
|
||||
/*--- Media - min-width ---*/
|
||||
@@ -1716,19 +1702,7 @@ table.dataTable {
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1320px) {
|
||||
.layout-boxed .form-group.has-error.login-box-msg::before,
|
||||
.layout-boxed .form-group.has-error.login-box-msg::after {
|
||||
font-size: calc((1320px - var(--sidebar-width) - 60px) / 12);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1960px) {
|
||||
.layout-boxed .form-group.has-error.login-box-msg::before,
|
||||
.layout-boxed .form-group.has-error.login-box-msg::after {
|
||||
font-size: calc((1920px - var(--sidebar-width) - 60px) / 12);
|
||||
}
|
||||
|
||||
.layout-boxed .wrapper {
|
||||
box-shadow: none;
|
||||
max-width: 1920px;
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
<!-- Title -->
|
||||
<div class="page-header">
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Please see LICENSE file for your rights under this license.
|
||||
*/
|
||||
|
||||
require 'scripts/pi-hole/php/header.php';
|
||||
require 'scripts/pi-hole/php/header_authenticated.php';
|
||||
?>
|
||||
<!-- Title -->
|
||||
<div class="page-header">
|
||||
|
||||
Reference in New Issue
Block a user