Final Fixes And Clean Up

This commit is contained in:
JonatanRek 2020-04-28 11:52:14 +02:00
parent a3d911d3ec
commit e0bbc09389
18 changed files with 29 additions and 35 deletions

View File

@ -32,7 +32,7 @@ if (isset($_POST) && !empty($_POST)){
AutomationManager::create($_POST['name'], $onDays, $doCode, $ifCode);
header('Location: ' . BASEDIR . strtolower(basename(__FILE__, '.php')));
header('Location: ' . BASEURL . strtolower(basename(__FILE__, '.php')));
die();
} else if (isset($_POST['modalFinal']) && $_POST['action'] == "edit") {
$doCode = json_encode($_POST['device'], JSON_PRETTY_PRINT);
@ -70,7 +70,7 @@ if (isset($_POST) && !empty($_POST)){
AutomationManager::create($_POST['name'], $onDays, $doCode, $ifCode, (isset ($_POST['automation_id']) ? $_POST['automation_id'] : ""));
header('Location: ' . BASEDIR . strtolower(basename(__FILE__, '.php')));
header('Location: ' . BASEURL . strtolower(basename(__FILE__, '.php')));
die();
}
}

View File

@ -7,7 +7,7 @@ if (isset($_POST) && !empty($_POST)){
DashboardManager::Add($subDeviceId);
}
}
header('Location: ' . BASEDIR . strtolower(basename(__FILE__, '.php')));
header('Location: ' . BASEURL . strtolower(basename(__FILE__, '.php')));
die();
}
?>

View File

@ -78,10 +78,10 @@ if (isset($_POST) && !empty($_POST)){
echo '<pre>';
var_dump($POST);
echo '</pre>';
echo '<a href="' . BASEDIR . '">CONTINUE</a>';
echo '<a href="' . BASEURL . '">CONTINUE</a>';
die();
}
header('Location: ' . BASEDIR );
header('Location: ' . BASEURL );
die();
}
?>

View File

@ -15,7 +15,7 @@ if (
$ota = $userManager->haveOtaEnabled($userName);
if ($ota == "") {
$landingPage = $userManager->login($userName, $userPassword, $rememberMe);
header('Location: ' . BASEDIR . $landingPage);
header('Location: ' . BASEURL . $landingPage);
die();
}
@ -40,7 +40,7 @@ if (
$checkResult = $ga->verifyCode($otaSecret, $otaCode, 2); // 2 = 2*30sec clock tolerance
if ($checkResult) {
$landingPage = $userManager->login($userName, $userPassword, $rememberMe);
header('Location: ' . BASEDIR . $landingPage);
header('Location: ' . BASEURL . $landingPage);
echo 'OK';
} else {
echo 'FAILED';

View File

@ -3,7 +3,7 @@
if (isset($_POST) && !empty($_POST)){
if (isset($_POST['submitFinal']) && $_POST['submitFinal'] != "") {
SceneManager::create($_POST['sceneIcon'], $_POST['sceneName'], json_encode($_POST['devices']));
header('Location: ' . BASEDIR . strtolower(basename(__FILE__, '.php')));
header('Location: ' . BASEURL . strtolower(basename(__FILE__, '.php')));
die();
}
@ -12,7 +12,7 @@ if (isset($_POST) && !empty($_POST)){
echo '<pre>';
var_dump($_POST);
echo '</pre>';
echo '<a href="/' . BASEDIR . strtolower(basename(__FILE__, '.php')).'">CONTINUE</a>';
echo '<a href="/' . BASEURL . strtolower(basename(__FILE__, '.php')).'">CONTINUE</a>';
die();
}
}

View File

@ -5,13 +5,13 @@ if (isset($_POST) && !empty($_POST)){
$newPassword = $_POST['newPassword1'];
$newPassword2 = $_POST['newPassword2'];
UserManager::changePassword($oldPassword, $newPassword, $newPassword2);
header('Location: ' . BASEDIR . 'logout');
header('Location: ' . BASEURL . 'logout');
die();
} else if (isset($_POST['submitCreateUser']) && $_POST['submitCreateUser'] != "") {
$userName = $_POST['userName'];
$password = $_POST['userPassword'];
UserManager::createUser($userName, $password);
header('Location: ' . BASEDIR . 'setting');
header('Location: ' . BASEURL . 'setting');
die();
} else if (isset($_POST['submitEnableOta']) && $_POST['submitEnableOta'] != "") {
echo $otaCode = $_POST['otaCode'];
@ -23,7 +23,7 @@ if (isset($_POST) && !empty($_POST)){
if ($checkResult) {
UserManager::setOta($otaCode, $otaSecret);
}
header('Location: ' . BASEDIR . 'setting');
header('Location: ' . BASEURL . 'setting');
die();
}
}

View File

@ -15,14 +15,14 @@ class LogKeeper
$todayFileName = date("Y-m-d").'.log';
$seconds = $days * 86400;
$logFiles = scandir('../app/logs/');
$logFiles = scandir('../logs/');
foreach ($logFiles as $key => $file) {
if (in_array($file,array(".","..", ".gitkeep", $todayFileName)))
{
continue;
}
if (filemtime($file) > $seconds) {
unlink('../app/logs/'.$file);
unlink('../logs/'.$file);
}
}
}
@ -35,11 +35,11 @@ class LogManager
function __construct($fileName = "")
{
if ($fileName == ""){
$fileName = '../app/logs/'. date("Y-m-d").'.log';
$fileName = '../logs/'. date("Y-m-d").'.log';
}
if(!is_dir("../app/logs/"))
if(!is_dir("../logs/"))
{
mkdir("../app/logs/");
mkdir("../logs/");
}
$this->logFile = fopen($fileName, "a") or die("Unable to open file!");
}

View File

@ -8,12 +8,12 @@ class Ajax extends Template
global $lang;
if (!$userManager->isLogin()){
header('Location: ' . BASEDIR);
header('Location: ' . BASEURL);
}
$is_ajax = 'XMLHttpRequest' == ( $_SERVER['HTTP_X_REQUESTED_WITH'] ?? '' );
if (!$is_ajax){
header('Location: ' . BASEDIR);
header('Location: ' . BASEURL);
}
if (

View File

@ -1,10 +1,4 @@
<?php
$files = scandir('app/class/');
$files = array_diff($files, array('.', '..'));
foreach($files as $file) {
include_once 'app/class/'. $file;
}
class Automation extends Template
{
function __construct()
@ -13,7 +7,7 @@ class Automation extends Template
global $langMng;
if (!$userManager->isLogin()){
header('Location: ' . BASEDIR . 'login');
header('Location: ' . BASEURL . 'login');
}
$automations = [];

View File

@ -7,7 +7,7 @@ class Dashboard extends Template
global $langMng;
if (!$userManager->isLogin()){
header('Location: ' . BASEDIR . 'login');
header('Location: ' . BASEURL . 'login');
}
$template = new Template('dashboard');

View File

@ -9,7 +9,7 @@ class Home extends Template
global $langMng;
if (!$userManager->isLogin()){
header('Location: ' . BASEDIR . 'login');
header('Location: ' . BASEURL . 'login');
}
$template = new Template('home');

View File

@ -9,14 +9,14 @@ class Log extends Template
global $langMng;
if (!$userManager->isLogin()){
header('Location: ' . BASEDIR . 'login');
header('Location: ' . BASEURL . 'login');
}
$template = new Template('log');
$template->prepare('title', 'Log');
$result = array();
$cdir = scandir('./app/logs/');
$cdir = scandir('../logs/');
foreach ($cdir as $key => $value)
{
if (!in_array($value,array(".","..", ".gitkeep")))

View File

@ -7,7 +7,7 @@ class Login extends Template
global $lang;
if ($userManager->isLogin()){
header('Location: ' . BASEDIR);
header('Location: ' . BASEURL);
}
$template = new Template('login');

View File

@ -5,7 +5,7 @@ class Logout extends Template
{
global $userManager;
$userManager->logout();
header('Location: ' . BASEDIR . 'login');
header('Location: ' . BASEURL . 'login');
die();
}
}

View File

@ -9,7 +9,7 @@ class Rooms extends Template
global $langMng;
if (!$userManager->isLogin()){
header('Location: ' . BASEDIR . 'login');
header('Location: ' . BASEURL . 'login');
}
$template = new Template('rooms');

View File

@ -7,7 +7,7 @@ class Scene extends Template
global $langMng;
if (!$userManager->isLogin()){
header('Location: ' . BASEDIR . 'login');
header('Location: ' . BASEURL . 'login');
}
$template = new Template('scene');

View File

@ -8,7 +8,7 @@ class Setting extends Template
global $langMng;
if (!$userManager->isLogin()){
header('Location: ' . BASEDIR . 'login');
header('Location: ' . BASEURL . 'login');
}
$automations = [];