FTP -> GIT (SYNC)

This commit is contained in:
JonatanRek 2019-09-19 14:48:31 +02:00
parent ad3118799f
commit 8f709bfb30
85 changed files with 310 additions and 173 deletions

40
api.php
View File

@ -3,12 +3,33 @@
include_once('./config.php'); include_once('./config.php');
//Autoloader //Autoloader
foreach (["class", "views"] as $dir) {
$files = scandir('./'.$dir.'/'); $files = scandir('./app/class/');
$files = array_diff($files, array('.', '..'));
$files = array_diff($files, array(
'.',
'..',
'app',
'ChartJS.php',
'ChartJS_Line.php',
'ChartManager.php',
'DashboardManager.php',
'Partial.php',
'Form.php',
'Route.php',
'Template.php',
'Ajax.php',
));
foreach($files as $file) { foreach($files as $file) {
include_once './'.$dir.'/'. $file; include './app/class/'. $file;
} }
//Allow acces only wia Curl, Ajax ETC
$restAcess = 'XMLHttpRequest' == ( $_SERVER['HTTP_X_REQUESTED_WITH'] ?? '' );
if (!$restAcess){
header('Location: ./');
} }
//Log //Log
@ -21,17 +42,16 @@ Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
$json = file_get_contents('php://input'); $json = file_get_contents('php://input');
$obj = json_decode($json, true); $obj = json_decode($json, true);
//zabespecit proti Ddosu //zabespecit proti Ddosu
if (isset($obj['user']) && $obj['user'] != ''){ if (isset($obj['user']) && $obj['user'] != ''){
//user at home //user at home
$user = UserManager::getUser($obj['user']); $user = UserManager::getUser($obj['user']);
if (!empty($user)) { if (!empty($user)) {
$userId = $user['user_id']; $userId = $user['user_id'];
$atHome = boolval ($obj['atHome']); $atHome = $obj['atHome'];
UserManager::atHome($userId, $atHome ? 'true' : 'false'); UserManager::atHome($userId, $atHome);
echo 'Saved'; $logManager->write("[Record] user " . $userId . "changet his home state to " . $atHome . RECORDTIMOUT , LogRecordType::WARNING);
echo 'Saved: ' . $atHome;
header("HTTP/1.1 200 OK"); header("HTTP/1.1 200 OK");
die(); die();
} }
@ -114,7 +134,7 @@ if ($values != null || $values != "") {
SubDeviceManager::create($deviceId, $key, UNITS[$key]); SubDeviceManager::create($deviceId, $key, UNITS[$key]);
} }
RecordManager::create($deviceId, $key, round($value['value'],2)); RecordManager::create($deviceId, $key, round($value['value'],2));
$logManager->write("[API] Device_ID " . $deviceId . " writed value " . $key . $value['value'], LogRecordType::INFO); $logManager->write("[API] Device_ID " . $deviceId . " writed value " . $key . ' ' . $value['value'], LogRecordType::INFO);
} }
$hostname = strtolower($device['name']); $hostname = strtolower($device['name']);

121
app/class/Form.php Normal file
View File

@ -0,0 +1,121 @@
<?php
/**
* [InputTypes datatype for input types]
*/
class InputTypes
{
const TEXT = 'text';
const NUMBER = 'number';
const COLOR = 'color';
const CHECK = 'checkbox';
const BUTTON = 'button';
const DATE = 'date';
const DATETIME = 'datetime';
const SUBMIT = 'submit';
const HIDEN = 'hidden';
const EMAIL = 'email';
}
/**
* [Form Form Generator Class]
*/
class Form {
public $formContent = "";
private $formName;
private $formId;
private $method;
private $action;
/**
* [__construct description]
* @param String $name [description]
* @param String $id [description]
* @param String $method [description]
* @param String $action [description]
*/
function __construct(String $name, String $id, String $method, String $action) {
if ($name != "") {
$this->formName = 'name="'.$name.'"';
}
if ($id != "") {
$this->formId = 'id="'.$id.'"';
}
if ($method != "") {
$this->method = 'method="'.$method.'"';
}
if ($action != "") {
$this->$action = 'action="'.$action.'"';
}
}
/**
* [addInput description]
* @param String $type Type of input element (text, number, color,checkbox, button, date, datetime, submit)
* @param String $name name of element
* @param String $id id of element
* @param String $label label of element
* @param String $value value of element
* @param boolean $require require selector toggle
* @param boolean $enabled enable selector toggle
*/
function addInput(String $type, String $name, String $id, String $label, String $value, Bool $require = false, Bool $enabled = true){
$this->formContent .= '<div class="field">';
if ($label != "") {
$this->formContent .= '<div class="label">'.$label.'</div>';
}
$this->formContent .= '<input class="input" type="'.$type.'" name="'.$name.'" value="'.$value.'" ' . ($enabled ? '' : 'disabled') . ($require ? '' : 'required') .'>';
$this->formContent .= '</div>';
}
//TODO: add Group support
/**
* [addSelect description]
* @param String $name name of element
* @param String $id id of element
* @param String $label label of element
* @param Array $data array of options [value => valueName]
* @param boolean $multiple multiple selector toggle
* @param boolean $enabled enable selector toggle
*/
function addSelect(String $name, String $id, String $label, Array $data, Bool $multiple = false, Bool $require = false, Bool $enabled = true){
$this->formContent .= '<div class="field">';
if ($label != "") {
$this->formContent .= '<div class="label">'.$label.'</div>';
}
$this->formContent .= '<select class="input"' . ($multiple ? '' : 'multiple') . ($enabled ? '' : 'disabled') . ($require ? '' : 'required') .'>';
foreach ($data as $value => $text) {
$this->formContent .= '<option value="' . $value . '">' . $text . '</option>';
}
$this->formContent .= '</select>';
$this->formContent .= '</div>';
}
/**
* [addTextarea description]
* @param String $name name of element
* @param String $id id of element
* @param String $label label of element
* @param String $value value of element
* @param boolean $enabled enable selector toggle
*/
function addTextarea(String $name, String $id, String $label, Array $value, Bool $require = false, Bool $enabled = true){
$this->formContent .= '<div class="field">';
if ($label != "") {
$this->formContent .= '<div class="label">'.$label.'</div>';
}
$this->formContent .= '<textarea class="input"' . ($enabled ? '' : 'disabled') . ($require ? '' : 'required') .'>';
$this->formContent .= $value;
$this->formContent .= '</textarea>';
$this->formContent .= '</div>';
}
/**
* [render function whitch dysplay generated form]
*/
function render(){
self::addInput(InputTypes::SUBMIT, 'formSubmit', '', 'Submit', 'Submit');
$form = '<form '.$this->formName.$this->formId.$this->method.$this->action.'">';
$form .= $this->formContent;
$form .= '</form>';
echo $form;
}
}

View File

@ -16,17 +16,18 @@ class LogManager
function __construct($fileName = "") function __construct($fileName = "")
{ {
if ($fileName == ""){ if ($fileName == ""){
$fileName = './logs/'. date("Y-m-d").'.log'; $fileName = './app/logs/'. date("Y-m-d").'.log';
} }
if(!is_dir("./logs/")) if(!is_dir("./app/logs/"))
{ {
mkdir("./logs/"); mkdir("./app/logs/");
} }
$this->logFile = fopen($fileName, "a") or die("Unable to open file!"); $this->logFile = fopen($fileName, "a") or die("Unable to open file!");
} }
function write($value, $type = LogRecordType::ERROR){ function write($value, $type = LogRecordType::ERROR){
$record = "[".date("H:m:s")."][".$type."]" . $value . "\n"; $record = "[".date("H:m:s")."][".$type."]" . $value . "\n";
$record = Utilities::stringInsert($record,"\n",65);
fwrite($this->logFile, $record); fwrite($this->logFile, $record);
} }

View File

@ -7,7 +7,7 @@ class Partial{
function __construct($path = "", $debug = false) { function __construct($path = "", $debug = false) {
$this->debug = $debug; $this->debug = $debug;
if (!empty('templates/part/' . $path . '.phtml') && file_exists('templates/part/' . $path . '.phtml')) { if (!empty('app/templates/part/' . $path . '.phtml') && file_exists('app/templates/part/' . $path . '.phtml')) {
$this->path = $path; $this->path = $path;
} else { } else {
echo '<pre>'; echo '<pre>';
@ -29,6 +29,6 @@ class Partial{
extract($this->assignedValues); extract($this->assignedValues);
} }
require('templates/part/' . $this->path . '.phtml'); require('app/templates/part/' . $this->path . '.phtml');
} }
} }

View File

@ -7,7 +7,7 @@ class Template extends Partial{
function __construct($path = "", $debug = false) { function __construct($path = "", $debug = false) {
$this->debug = $debug; $this->debug = $debug;
if (!empty('templates/' . $path . '.phtml') && file_exists('templates/' . $path . '.phtml')) { if (!empty('app/templates/' . $path . '.phtml') && file_exists('app/templates/' . $path . '.phtml')) {
$this->path = $path; $this->path = $path;
} else { } else {
echo '<pre>'; echo '<pre>';
@ -26,9 +26,9 @@ class Template extends Partial{
function render() { function render() {
extract($this->assignedValues); extract($this->assignedValues);
if (!empty('controls/' . $this->path . '.php') && file_exists('controls/' . $this->path . '.php')) { if (!empty('app/controls/' . $this->path . '.php') && file_exists('app/controls/' . $this->path . '.php')) {
require_once('controls/' . $this->path . '.php'); require_once('app/controls/' . $this->path . '.php');
} }
require_once('templates/' . $this->path . '.phtml'); require_once('app/templates/' . $this->path . '.phtml');
} }
} }

View File

@ -35,4 +35,10 @@ class Utilities
); );
return preg_replace(array_keys($utf8), array_values($utf8), $text); return preg_replace(array_keys($utf8), array_values($utf8), $text);
} }
function stringInsert($str,$insertstr,$pos)
{
$str = substr($str, 0, $pos) . $insertstr . substr($str, $pos);
return $str;
}
} }

View File

@ -6,6 +6,7 @@ $lang = [
'm_settings' => 'Nastavení', 'm_settings' => 'Nastavení',
'm_automatization' => 'Automatizace', 'm_automatization' => 'Automatizace',
'm_scenes' => 'Scény', 'm_scenes' => 'Scény',
'm_log' => 'Log',
//Buttons //Buttons
'b_year' => 'Rok', 'b_year' => 'Rok',
@ -42,6 +43,7 @@ $lang = [
'l_permission' => 'Oprávmnění', 'l_permission' => 'Oprávmnění',
'l_inMinutes' => 'v minutách', 'l_inMinutes' => 'v minutách',
'l_sleepTime' => 'Doba spánku zařízení', 'l_sleepTime' => 'Doba spánku zařízení',
'l_atHome' => 'Doma Jsou',
//Title //Title
't_createScene' => 'Vytvořit scénu', 't_createScene' => 'Vytvořit scénu',

View File

@ -6,6 +6,7 @@ $lang = [
'm_settings' => 'Setting', 'm_settings' => 'Setting',
'm_automatization' => 'Automatization', 'm_automatization' => 'Automatization',
'm_scenes' => 'Scenes', 'm_scenes' => 'Scenes',
'm_log' => 'Log',
//Buttons //Buttons
'b_year' => 'Year', 'b_year' => 'Year',
@ -42,6 +43,7 @@ $lang = [
'l_permission' => 'Permission', 'l_permission' => 'Permission',
'l_inMinutes' => 'in minutes', 'l_inMinutes' => 'in minutes',
'l_sleepTime' => 'Device sleep Time', 'l_sleepTime' => 'Device sleep Time',
'l_atHome' => 'At home',
//Title //Title
't_createScene' => 'Create Scene', 't_createScene' => 'Create Scene',

0
app/logs/.gitkeep Normal file
View File

View File

@ -11,23 +11,12 @@
<div class="row no-gutters main"> <div class="row no-gutters main">
<div class="col-md-3 d-sm-none"></div> <div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container"> <div class="col-md-3 nav-container">
<div class="nav"> <?php
<div class="nav-item"> $partial = new Partial('menu');
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a> $partial->prepare('item','automation');
</div> $partial->prepare('lang',$LANG);
<div class="nav-item"> $partial->render();
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a> ?>
</div>
<div class="nav-item">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item is-active">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div> </div>
<div class="col-md-9 main-body"> <div class="col-md-9 main-body">
<a class="button is-primary m-1" onClick="$('#modal').removeClass('modal-container-hiden').show();"><?php echo $LANG['t_createAutomation'];?></a> <a class="button is-primary m-1" onClick="$('#modal').removeClass('modal-container-hiden').show();"><?php echo $LANG['t_createAutomation'];?></a>

View File

@ -11,23 +11,12 @@
<div class="row no-gutters main"> <div class="row no-gutters main">
<div class="col-md-3 d-sm-none"></div> <div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container"> <div class="col-md-3 nav-container">
<div class="nav"> <?php
<div class="nav-item"> $partial = new Partial('menu');
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a> $partial->prepare('item', 'dashboard');
</div> $partial->prepare('lang',$LANG);
<div class="nav-item is-active"> $partial->render();
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a> ?>
</div>
<div class="nav-item">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div> </div>
<div class="col-md-9 main-body"> <div class="col-md-9 main-body">
<a onClick="$('#modal').removeClass('modal-container-hiden').show();" class="button is-primary m-1">Add Device</a> <a onClick="$('#modal').removeClass('modal-container-hiden').show();" class="button is-primary m-1">Add Device</a>

View File

Before

Width:  |  Height:  |  Size: 434 KiB

After

Width:  |  Height:  |  Size: 434 KiB

View File

@ -11,23 +11,12 @@
<div class="row no-gutters main"> <div class="row no-gutters main">
<div class="col-md-3 d-sm-none"></div> <div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container"> <div class="col-md-3 nav-container">
<div class="nav"> <?php
<div class="nav-item is-active"> $partial = new Partial('menu');
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a> $partial->prepare('item', 'home');
</div> $partial->prepare('lang',$LANG);
<div class="nav-item"> $partial->render();
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a> ?>
</div>
<div class="nav-item">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div> </div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.bundle.min.js"></script>
@ -35,14 +24,8 @@
<div class="col-md-9 main-body"> <div class="col-md-9 main-body">
<div class="label m-1"> <div class="label m-1">
<?php <?php
$usersAtHome = ''; if ($USERSATHOME != "") {
foreach ($USERS as $user) { echo $LANG['l_atHome'] . ': ' . $USERSATHOME;
if ($user['at_home'] == 'true') {
$usersAtHome .= $user['username'] . ' ';
}
}
if ($usersAtHome != "") {
echo 'doma jsou:' . $usersAtHome;
} }
?> ?>
</div> </div>

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -11,23 +11,12 @@
<div class="row no-gutters main"> <div class="row no-gutters main">
<div class="col-md-3 d-sm-none"></div> <div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container"> <div class="col-md-3 nav-container">
<div class="nav"> <?php
<div class="nav-item"> $partial = new Partial('menu');
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a> $partial->prepare('item', 'log');
</div> $partial->prepare('lang',$LANG);
<div class="nav-item"> $partial->render();
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a> ?>
</div>
<div class="nav-item is-active">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div> </div>
<div class="col-md-9 main-body"> <div class="col-md-9 main-body">
<div class="col-12 col-sm-9 mx-auto mt-4"> <div class="col-12 col-sm-9 mx-auto mt-4">
@ -42,15 +31,17 @@
<input type="submit" class="button" name="selectFile" value="file"/> <input type="submit" class="button" name="selectFile" value="file"/>
</div> </div>
</form> </form>
<?php <?php
if (isset($_POST['LogFile'])) { if (isset($_POST['LogFile'])) {
$file_lines = file('./logs/' . $_POST['LogFile']); $file_lines = file('./app/logs/' . $_POST['LogFile']);
echo '<pre>';
foreach ($file_lines as $line) { foreach ($file_lines as $line) {
echo $line . '</br>'; echo $line;
} }
echo '</pre>';
} }
?> ?>
</pre>
</div> </div>
</div> </div>

View File

@ -0,0 +1,46 @@
<div class="nav">
<?php
$menuItems = [
'fa-home' => [
'slug' => 'home',
'lngKey' => 'home',
'path' => './',
],
'fa-tachometer' => [
'slug' => 'dashboard',
'lngKey' => 'dashboard',
'path' => 'dashboard',
],
'fa-wrench' => [
'slug' => 'setting',
'lngKey' => 'settings',
'path' => 'setting',
],
'fa-calendar-o' => [
'slug' => 'automation',
'lngKey' => 'automatization',
'path' => 'automation',
],
'fa-terminal' => [
'slug' => 'scene',
'lngKey' => 'scenes',
'path' => 'scene',
],
'fa-bug' =>[
'slug' => 'log',
'lngKey' => 'log',
'path' => 'log',
],
];
foreach ( $menuItems as $key => $value) { ?>
<div class="nav-item <?php echo ($ITEM == $value ? 'is-active' : ''); ?>">
<a href="<?php echo $value['path']?>">
<i class="fa <?php echo $key ?>"></i>
<span>
<?php echo $LANG['m_'.$value['lngKey']]; ?>
</span>
</a>
</div>
<?php }?>
</div>

View File

@ -11,23 +11,12 @@
<div class="row no-gutters main"> <div class="row no-gutters main">
<div class="col-md-3 d-sm-none"></div> <div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container"> <div class="col-md-3 nav-container">
<div class="nav"> <?php
<div class="nav-item is-active"> $partial = new Partial('menu');
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a> $partial->prepare('item', 'rooms');
</div> $partial->prepare('lang',$LANG);
<div class="nav-item"> $partial->render();
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a> ?>
</div>
<div class="nav-item">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div> </div>

View File

@ -11,23 +11,12 @@
<div class="row no-gutters main"> <div class="row no-gutters main">
<div class="col-md-3 d-sm-none"></div> <div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container"> <div class="col-md-3 nav-container">
<div class="nav"> <?php
<div class="nav-item"> $partial = new Partial('menu');
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a> $partial->prepare('item', 'scene');
</div> $partial->prepare('lang',$LANG);
<div class="nav-item"> $partial->render();
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a> ?>
</div>
<div class="nav-item">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item is-active">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div> </div>
<div class="col-md-9 main-body"> <div class="col-md-9 main-body">
<a class="button is-primary m-1" onClick="$('#modal').removeClass('modal-container-hiden').show();"><?php echo $LANG['t_createScene'];?></a> <a class="button is-primary m-1" onClick="$('#modal').removeClass('modal-container-hiden').show();"><?php echo $LANG['t_createScene'];?></a>

View File

@ -11,23 +11,12 @@
<div class="row no-gutters main"> <div class="row no-gutters main">
<div class="col-md-3 d-sm-none"></div> <div class="col-md-3 d-sm-none"></div>
<div class="col-md-3 nav-container"> <div class="col-md-3 nav-container">
<div class="nav"> <?php
<div class="nav-item"> $partial = new Partial('menu');
<a href="./"><i class="fa fa-home"></i><span><?php echo $LANG['m_home']?></span></a> $partial->prepare('item', 'setting');
</div> $partial->prepare('lang',$LANG);
<div class="nav-item"> $partial->render();
<a href="dashboard"><i class="fa fa-tachometer" aria-hidden="true"></i><span><?php echo $LANG['m_dashboard']?></span></a> ?>
</div>
<div class="nav-item is-active">
<a href="setting"><i class="fa fa-wrench" aria-hidden="true"></i></i><span><?php echo $LANG['m_settings']?></span></a>
</div>
<div class="nav-item">
<a href="automation"><i class="fa fa-calendar-o" aria-hidden="true"></i><span><?php echo $LANG['m_automatization']?></span></a>
</div>
<div class="nav-item">
<a href="scene"><i class="fa fa-terminal" aria-hidden="true"></i><span><?php echo $LANG['m_scenes']?></span></a>
</div>
</div>
</div> </div>
<div class="col-md-9 main-body"> <div class="col-md-9 main-body">
<div class="col-12 col-sm-9 mx-auto mt-4"> <div class="col-12 col-sm-9 mx-auto mt-4">
@ -55,6 +44,11 @@
<a href="rooms" class="button">ROOMS</a> <a href="rooms" class="button">ROOMS</a>
</div> </div>
</div> </div>
<div class="col-12 col-sm-9 mx-auto mt-4">
<div class="field">
<a href="log" class="button">Logs</a>
</div>
</div>
</div> </div>

View File

@ -1,8 +1,8 @@
<?php <?php
$files = scandir('class/'); $files = scandir('app/class/');
$files = array_diff($files, array('.', '..')); $files = array_diff($files, array('.', '..'));
foreach($files as $file) { foreach($files as $file) {
include_once 'class/'. $file; include_once 'app/class/'. $file;
} }
class Ajax extends Template class Ajax extends Template

View File

@ -1,8 +1,8 @@
<?php <?php
$files = scandir('class/'); $files = scandir('app/class/');
$files = array_diff($files, array('.', '..')); $files = array_diff($files, array('.', '..'));
foreach($files as $file) { foreach($files as $file) {
include_once 'class/'. $file; include_once 'app/class/'. $file;
} }
class Automation extends Template class Automation extends Template

View File

@ -14,6 +14,24 @@ class Home extends Template
$template = new Template('home'); $template = new Template('home');
//users instantialize
$users = UserManager::getUsers();
$template->prepare('users', $users);
//Users at home Info
$usersAtHome = '';
$i = 0;
foreach ($users as $user) {
$i++;
if ($user['at_home'] == 'true') {
$usersAtHome .= $user['username'];
if ($usersAtHome != "" && isset($users[$i + 1])){
$usersAtHome .= ', ';
}
}
}
$template->prepare('usersAtHome', $usersAtHome);
$roomsItems = []; $roomsItems = [];
$roomsData = RoomManager::getAllRooms(); $roomsData = RoomManager::getAllRooms();
foreach ($roomsData as $roomKey => $roomsData) { foreach ($roomsData as $roomKey => $roomsData) {
@ -124,9 +142,6 @@ class Home extends Template
]; ];
} }
$users = UserManager::getUsers();
$template->prepare('users', $users);
$rooms = RoomManager::getAllRooms(); $rooms = RoomManager::getAllRooms();
$template->prepare('rooms', $rooms); $template->prepare('rooms', $rooms);
$template->prepare('title', 'Home'); $template->prepare('title', 'Home');

View File

@ -16,7 +16,7 @@ class Log extends Template
$template->prepare('title', 'Log'); $template->prepare('title', 'Log');
$result = array(); $result = array();
$cdir = scandir('./logs/'); $cdir = scandir('./app/logs/');
foreach ($cdir as $key => $value) foreach ($cdir as $key => $value)
{ {
if (!in_array($value,array(".",".."))) if (!in_array($value,array(".","..")))

View File

@ -1 +0,0 @@
C:/Users/spaninger/Documents/git/PHP_FORM_GENERATOR/Form.php

View File

@ -11,10 +11,11 @@ mb_internal_encoding ("UTF-8");
//Autoloader //Autoloader
foreach (["class", "views"] as $dir) { foreach (["class", "views"] as $dir) {
$files = scandir('./'.$dir.'/'); $files = scandir('./app/'.$dir.'/');
$files = array_diff($files, array('.', '..')); $files = array_diff($files, array('.', '..', 'app'));
foreach($files as $file) { foreach($files as $file) {
include_once './'.$dir.'/'. $file; include './app/'.$dir.'/'. $file;
} }
} }
@ -33,7 +34,7 @@ if (DEBUGMOD == 1) {
echo '</pre>'; echo '</pre>';
echo '</dev>';*/ echo '</dev>';*/
} }
require_once './lang/' . $langTag . '.php'; require_once './app/lang/' . $langTag . '.php';
//DB Conector //DB Conector
Db::connect (DBHOST, DBUSER, DBPASS, DBNAME); Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);