mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
php clean-up, logon fix
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
require '/home/pi/pialert/front/php/templates/timezone.php';
|
||||
require '/home/pi/pialert/front/php/templates/skinUI.php';
|
||||
require '/home/pi/pialert/front/php/templates/language/lang.php';
|
||||
require '/home/pi/pialert/front/php/templates/security.php';
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ $lang['en_us'] = array(
|
||||
'Login_Toggle_Info' => 'Password Information',
|
||||
'Login_Toggle_Info_headline' => 'Password Information',
|
||||
'Login_Toggle_Alert_headline' => 'Password Alert!',
|
||||
'Login_Default_PWD' => 'Default password "123456" is still active.',
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Device Page
|
||||
|
||||
64
front/php/templates/security.php
Normal file
64
front/php/templates/security.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
|
||||
$isLogonPage = FALSE;
|
||||
|
||||
|
||||
if (strpos($url,'index.php') !== false) {
|
||||
$isLogonPage = TRUE;
|
||||
}
|
||||
|
||||
session_start();
|
||||
|
||||
if(array_search('action', $_REQUEST) != FALSE)
|
||||
{
|
||||
if ($_REQUEST['action'] == 'logout') {
|
||||
session_destroy();
|
||||
setcookie("PiAlert_SaveLogin", "", time() - 3600);
|
||||
header('Location: index.php');
|
||||
}
|
||||
}
|
||||
|
||||
// ##################################################
|
||||
// ## Login Processing start
|
||||
// ##################################################
|
||||
$config_file = "../config/pialert.conf";
|
||||
$config_file_lines = file($config_file);
|
||||
|
||||
// ###################################
|
||||
// ## PIALERT_WEB_PROTECTION FALSE
|
||||
// ###################################
|
||||
|
||||
$config_file_lines_bypass = array_values(preg_grep('/^PIALERT_WEB_PROTECTION.*=/', $config_file_lines));
|
||||
$protection_line = explode("=", $config_file_lines_bypass[0]);
|
||||
$Pia_WebProtection = strtolower(trim($protection_line[1]));
|
||||
|
||||
// ###################################
|
||||
// ## PIALERT_WEB_PROTECTION TRUE
|
||||
// ###################################
|
||||
|
||||
$config_file_lines = array_values(preg_grep('/^PIALERT_WEB_PASSWORD.*=/', $config_file_lines));
|
||||
$password_line = explode("'", $config_file_lines[0]);
|
||||
$Pia_Password = $password_line[1];
|
||||
|
||||
// active Session or valid cookie (cookie not extends)
|
||||
if($Pia_WebProtection == 'true')
|
||||
{
|
||||
if(isset ($_SESSION["login"]) == FALSE )
|
||||
{
|
||||
$_SESSION["login"] = 0;
|
||||
}
|
||||
|
||||
if ( ($_SESSION["login"] == 1) || $isLogonPage || (( isset($_COOKIE["PiAlert_SaveLogin"]) && $Pia_Password == $_COOKIE["PiAlert_SaveLogin"])))
|
||||
{
|
||||
//Logged in or stay on this page if we are on the index.php already
|
||||
|
||||
} else
|
||||
{
|
||||
// we need to redirect
|
||||
header('Location: index.php');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user