From 8f709bfb30d228e4d24a128cc371c465274c7d88 Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Thu, 19 Sep 2019 14:48:31 +0200 Subject: [PATCH] FTP -> GIT (SYNC) --- api.php | 46 +++++-- {class => app/class}/AutomationManager.php | 0 {class => app/class}/ChartJS.php | 0 {class => app/class}/ChartJS_Line.php | 0 {class => app/class}/ChartManager.php | 0 {class => app/class}/DB.php | 0 {class => app/class}/DashboardManager.php | 0 {class => app/class}/DeviceManager.php | 0 app/class/Form.php | 121 ++++++++++++++++++ {class => app/class}/LogManager.php | 9 +- {class => app/class}/Partial.php | 4 +- {class => app/class}/RecordManager.php | 0 {class => app/class}/RoomManager.php | 0 {class => app/class}/Route.php | 0 {class => app/class}/SceneManager.php | 0 {class => app/class}/SubDeviceManager.php | 0 {class => app/class}/Template.php | 8 +- {class => app/class}/UserManager.php | 0 {class => app/class}/Utilities.php | 6 + {controls => app/controls}/automation.php | 0 {controls => app/controls}/dashboard.php | 0 {controls => app/controls}/home.php | 0 {controls => app/controls}/scene.php | 0 {lang => app/lang}/cs.php | 2 + {lang => app/lang}/en.php | 2 + app/logs/.gitkeep | 0 .../Elementum/scss/elements/_buttons.scss | 0 {templates => app/templates}/automation.phtml | 23 +--- .../templates}/css/font-awesome.min.css | 0 {templates => app/templates}/css/loading.css | 0 {templates => app/templates}/css/main.css | 0 {templates => app/templates}/css/main.css.map | 0 {templates => app/templates}/css/modal.css | 0 {templates => app/templates}/css/pre.css | 0 {templates => app/templates}/dashboard.phtml | 23 +--- .../templates}/fonts/FontAwesome.otf | Bin .../templates}/fonts/Metropolis-Medium.otf | Bin .../templates}/fonts/Metropolis-Regular.otf | Bin .../templates}/fonts/Metropolis-SemiBold.otf | Bin .../templates}/fonts/fontawesome-webfont.eot | Bin .../templates}/fonts/fontawesome-webfont.svg | 0 .../templates}/fonts/fontawesome-webfont.ttf | Bin .../templates}/fonts/fontawesome-webfont.woff | Bin .../fonts/fontawesome-webfont.woff2 | Bin {templates => app/templates}/home.phtml | 33 ++--- .../templates}/images/icon-192x192.png | Bin .../templates}/images/icon-512x512.png | Bin {templates => app/templates}/js/jquery.js | 0 .../templates}/js/jquery.redirect.js | 0 {templates => app/templates}/js/post.js | 0 {templates => app/templates}/js/script.js | 0 {templates => app/templates}/loading.css | 0 {templates => app/templates}/log.phtml | 41 +++--- {templates => app/templates}/login.phtml | 0 .../templates}/part/automationButton.phtml | 0 .../templates}/part/automationCreate.phtml | 0 .../part/automationCreateFinal.phtml | 0 .../templates}/part/automationEdit.phtml | 0 .../templates}/part/dashboardButton.phtml | 0 .../templates}/part/deviceButton.phtml | 0 .../templates}/part/deviceDetail.phtml | 0 .../templates}/part/deviceEdit.phtml | 0 .../templates}/part/footer.phtml | 0 {templates => app/templates}/part/head.phtml | 0 app/templates/part/menu.phtml | 46 +++++++ .../templates}/part/sceneButton.phtml | 0 .../templates}/part/sceneCreate.phtml | 0 .../templates}/part/sceneCreateOptions.phtml | 0 .../templates}/part/sceneEdit.phtml | 0 {templates => app/templates}/part/test.phtml | 0 {templates => app/templates}/rooms.phtml | 23 +--- {templates => app/templates}/scene.phtml | 23 +--- {templates => app/templates}/setting.phtml | 28 ++-- {views => app/views}/Ajax.php | 4 +- {views => app/views}/Automation.php | 4 +- {views => app/views}/Dashboard.php | 0 {views => app/views}/Home.php | 21 ++- {views => app/views}/Log.php | 2 +- {views => app/views}/Login.php | 0 {views => app/views}/Logout.php | 0 {views => app/views}/Rooms.php | 0 {views => app/views}/Scene.php | 0 {views => app/views}/Setting.php | 0 class/Form.php | 1 - index.php | 13 +- 85 files changed, 310 insertions(+), 173 deletions(-) rename {class => app/class}/AutomationManager.php (100%) rename {class => app/class}/ChartJS.php (100%) rename {class => app/class}/ChartJS_Line.php (100%) rename {class => app/class}/ChartManager.php (100%) rename {class => app/class}/DB.php (100%) rename {class => app/class}/DashboardManager.php (100%) rename {class => app/class}/DeviceManager.php (100%) create mode 100644 app/class/Form.php rename {class => app/class}/LogManager.php (68%) rename {class => app/class}/Partial.php (78%) rename {class => app/class}/RecordManager.php (100%) rename {class => app/class}/RoomManager.php (100%) rename {class => app/class}/Route.php (100%) rename {class => app/class}/SceneManager.php (100%) rename {class => app/class}/SubDeviceManager.php (100%) rename {class => app/class}/Template.php (64%) rename {class => app/class}/UserManager.php (100%) rename {class => app/class}/Utilities.php (89%) rename {controls => app/controls}/automation.php (100%) rename {controls => app/controls}/dashboard.php (100%) rename {controls => app/controls}/home.php (100%) rename {controls => app/controls}/scene.php (100%) rename {lang => app/lang}/cs.php (97%) rename {lang => app/lang}/en.php (97%) create mode 100644 app/logs/.gitkeep rename {templates => app/templates}/Elementum/scss/elements/_buttons.scss (100%) rename {templates => app/templates}/automation.phtml (65%) rename {templates => app/templates}/css/font-awesome.min.css (100%) rename {templates => app/templates}/css/loading.css (100%) rename {templates => app/templates}/css/main.css (100%) rename {templates => app/templates}/css/main.css.map (100%) rename {templates => app/templates}/css/modal.css (100%) rename {templates => app/templates}/css/pre.css (100%) rename {templates => app/templates}/dashboard.phtml (67%) rename {templates => app/templates}/fonts/FontAwesome.otf (100%) rename {templates => app/templates}/fonts/Metropolis-Medium.otf (100%) rename {templates => app/templates}/fonts/Metropolis-Regular.otf (100%) rename {templates => app/templates}/fonts/Metropolis-SemiBold.otf (100%) rename {templates => app/templates}/fonts/fontawesome-webfont.eot (100%) rename {templates => app/templates}/fonts/fontawesome-webfont.svg (100%) rename {templates => app/templates}/fonts/fontawesome-webfont.ttf (100%) rename {templates => app/templates}/fonts/fontawesome-webfont.woff (100%) rename {templates => app/templates}/fonts/fontawesome-webfont.woff2 (100%) rename {templates => app/templates}/home.phtml (68%) rename {templates => app/templates}/images/icon-192x192.png (100%) rename {templates => app/templates}/images/icon-512x512.png (100%) rename {templates => app/templates}/js/jquery.js (100%) rename {templates => app/templates}/js/jquery.redirect.js (100%) rename {templates => app/templates}/js/post.js (100%) rename {templates => app/templates}/js/script.js (100%) rename {templates => app/templates}/loading.css (100%) rename {templates => app/templates}/log.phtml (54%) rename {templates => app/templates}/login.phtml (100%) rename {templates => app/templates}/part/automationButton.phtml (100%) rename {templates => app/templates}/part/automationCreate.phtml (100%) rename {templates => app/templates}/part/automationCreateFinal.phtml (100%) rename {templates => app/templates}/part/automationEdit.phtml (100%) rename {templates => app/templates}/part/dashboardButton.phtml (100%) rename {templates => app/templates}/part/deviceButton.phtml (100%) rename {templates => app/templates}/part/deviceDetail.phtml (100%) rename {templates => app/templates}/part/deviceEdit.phtml (100%) rename {templates => app/templates}/part/footer.phtml (100%) rename {templates => app/templates}/part/head.phtml (100%) create mode 100644 app/templates/part/menu.phtml rename {templates => app/templates}/part/sceneButton.phtml (100%) rename {templates => app/templates}/part/sceneCreate.phtml (100%) rename {templates => app/templates}/part/sceneCreateOptions.phtml (100%) rename {templates => app/templates}/part/sceneEdit.phtml (100%) rename {templates => app/templates}/part/test.phtml (100%) rename {templates => app/templates}/rooms.phtml (83%) rename {templates => app/templates}/scene.phtml (67%) rename {templates => app/templates}/setting.phtml (68%) rename {views => app/views}/Ajax.php (98%) rename {views => app/views}/Automation.php (96%) rename {views => app/views}/Dashboard.php (100%) rename {views => app/views}/Home.php (93%) rename {views => app/views}/Log.php (93%) rename {views => app/views}/Login.php (100%) rename {views => app/views}/Logout.php (100%) rename {views => app/views}/Rooms.php (100%) rename {views => app/views}/Scene.php (100%) rename {views => app/views}/Setting.php (100%) delete mode 120000 class/Form.php diff --git a/api.php b/api.php index 204cc80..f7dc0df 100644 --- a/api.php +++ b/api.php @@ -3,12 +3,33 @@ include_once('./config.php'); //Autoloader -foreach (["class", "views"] as $dir) { - $files = scandir('./'.$dir.'/'); - $files = array_diff($files, array('.', '..')); - foreach ($files as $file) { - include_once './'.$dir.'/'. $file; - } + +$files = scandir('./app/class/'); + +$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) { + include './app/class/'. $file; +} + + +//Allow acces only wia Curl, Ajax ETC +$restAcess = 'XMLHttpRequest' == ( $_SERVER['HTTP_X_REQUESTED_WITH'] ?? '' ); +if (!$restAcess){ + header('Location: ./'); } //Log @@ -21,17 +42,16 @@ Db::connect (DBHOST, DBUSER, DBPASS, DBNAME); $json = file_get_contents('php://input'); $obj = json_decode($json, true); - //zabespecit proti Ddosu if (isset($obj['user']) && $obj['user'] != ''){ //user at home - $user = UserManager::getUser($obj['user']); if (!empty($user)) { $userId = $user['user_id']; - $atHome = boolval ($obj['atHome']); - UserManager::atHome($userId, $atHome ? 'true' : 'false'); - echo 'Saved'; + $atHome = $obj['atHome']; + UserManager::atHome($userId, $atHome); + $logManager->write("[Record] user " . $userId . "changet his home state to " . $atHome . RECORDTIMOUT , LogRecordType::WARNING); + echo 'Saved: ' . $atHome; header("HTTP/1.1 200 OK"); die(); } @@ -61,7 +81,7 @@ try { try { RecordManager::clean(RECORDTIMOUT); } catch (\Exception $e) { - $logManager->write("[Record] cleaning record older that" . RECORDTIMOUT , LogRecordType::ERROR); + $logManager->write("[Record] cleaning record older that " . RECORDTIMOUT , LogRecordType::ERROR); } //Variables @@ -114,7 +134,7 @@ if ($values != null || $values != "") { SubDeviceManager::create($deviceId, $key, UNITS[$key]); } 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']); diff --git a/class/AutomationManager.php b/app/class/AutomationManager.php similarity index 100% rename from class/AutomationManager.php rename to app/class/AutomationManager.php diff --git a/class/ChartJS.php b/app/class/ChartJS.php similarity index 100% rename from class/ChartJS.php rename to app/class/ChartJS.php diff --git a/class/ChartJS_Line.php b/app/class/ChartJS_Line.php similarity index 100% rename from class/ChartJS_Line.php rename to app/class/ChartJS_Line.php diff --git a/class/ChartManager.php b/app/class/ChartManager.php similarity index 100% rename from class/ChartManager.php rename to app/class/ChartManager.php diff --git a/class/DB.php b/app/class/DB.php similarity index 100% rename from class/DB.php rename to app/class/DB.php diff --git a/class/DashboardManager.php b/app/class/DashboardManager.php similarity index 100% rename from class/DashboardManager.php rename to app/class/DashboardManager.php diff --git a/class/DeviceManager.php b/app/class/DeviceManager.php similarity index 100% rename from class/DeviceManager.php rename to app/class/DeviceManager.php diff --git a/app/class/Form.php b/app/class/Form.php new file mode 100644 index 0000000..0dfbaa9 --- /dev/null +++ b/app/class/Form.php @@ -0,0 +1,121 @@ +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 .= '
'; + if ($label != "") { + $this->formContent .= '
'.$label.'
'; + } + $this->formContent .= ''; + $this->formContent .= '
'; + } + + //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 .= '
'; + if ($label != "") { + $this->formContent .= '
'.$label.'
'; + } + $this->formContent .= ''; + $this->formContent .= '
'; + } + + /** + * [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 .= '
'; + if ($label != "") { + $this->formContent .= '
'.$label.'
'; + } + $this->formContent .= ''; + $this->formContent .= '
'; + } + + /** + * [render function whitch dysplay generated form] + */ + function render(){ + self::addInput(InputTypes::SUBMIT, 'formSubmit', '', 'Submit', 'Submit'); + $form = '
formName.$this->formId.$this->method.$this->action.'">'; + $form .= $this->formContent; + $form .= '
'; + echo $form; + } +} diff --git a/class/LogManager.php b/app/class/LogManager.php similarity index 68% rename from class/LogManager.php rename to app/class/LogManager.php index 678524d..5d2d984 100644 --- a/class/LogManager.php +++ b/app/class/LogManager.php @@ -16,17 +16,18 @@ class LogManager function __construct($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!"); } 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); } diff --git a/class/Partial.php b/app/class/Partial.php similarity index 78% rename from class/Partial.php rename to app/class/Partial.php index 69510ed..f7e672d 100644 --- a/class/Partial.php +++ b/app/class/Partial.php @@ -7,7 +7,7 @@ class Partial{ function __construct($path = "", $debug = false) { $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; } else { echo '
';
@@ -29,6 +29,6 @@ class Partial{
 			extract($this->assignedValues);
 		}
 
-		require('templates/part/' . $this->path . '.phtml');
+		require('app/templates/part/' . $this->path . '.phtml');
 	}
 }
diff --git a/class/RecordManager.php b/app/class/RecordManager.php
similarity index 100%
rename from class/RecordManager.php
rename to app/class/RecordManager.php
diff --git a/class/RoomManager.php b/app/class/RoomManager.php
similarity index 100%
rename from class/RoomManager.php
rename to app/class/RoomManager.php
diff --git a/class/Route.php b/app/class/Route.php
similarity index 100%
rename from class/Route.php
rename to app/class/Route.php
diff --git a/class/SceneManager.php b/app/class/SceneManager.php
similarity index 100%
rename from class/SceneManager.php
rename to app/class/SceneManager.php
diff --git a/class/SubDeviceManager.php b/app/class/SubDeviceManager.php
similarity index 100%
rename from class/SubDeviceManager.php
rename to app/class/SubDeviceManager.php
diff --git a/class/Template.php b/app/class/Template.php
similarity index 64%
rename from class/Template.php
rename to app/class/Template.php
index d64d42c..4d99dab 100644
--- a/class/Template.php
+++ b/app/class/Template.php
@@ -7,7 +7,7 @@ class Template extends Partial{
 
 	function __construct($path = "", $debug = false) {
 		$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;
 		} else {
 			echo '
';
@@ -26,9 +26,9 @@ class Template extends Partial{
 
 	function render() {
 		extract($this->assignedValues);
-		if (!empty('controls/' . $this->path . '.php') && file_exists('controls/' . $this->path . '.php')) {
-			require_once('controls/' . $this->path . '.php');
+		if (!empty('app/controls/' . $this->path . '.php') && file_exists('app/controls/' . $this->path . '.php')) {
+			require_once('app/controls/' . $this->path . '.php');
 		}
-		require_once('templates/' . $this->path . '.phtml');
+		require_once('app/templates/' . $this->path . '.phtml');
 	}
 }
diff --git a/class/UserManager.php b/app/class/UserManager.php
similarity index 100%
rename from class/UserManager.php
rename to app/class/UserManager.php
diff --git a/class/Utilities.php b/app/class/Utilities.php
similarity index 89%
rename from class/Utilities.php
rename to app/class/Utilities.php
index 39d9052..87767bb 100644
--- a/class/Utilities.php
+++ b/app/class/Utilities.php
@@ -35,4 +35,10 @@ class Utilities
 		);
 		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;
+	}
 }
diff --git a/controls/automation.php b/app/controls/automation.php
similarity index 100%
rename from controls/automation.php
rename to app/controls/automation.php
diff --git a/controls/dashboard.php b/app/controls/dashboard.php
similarity index 100%
rename from controls/dashboard.php
rename to app/controls/dashboard.php
diff --git a/controls/home.php b/app/controls/home.php
similarity index 100%
rename from controls/home.php
rename to app/controls/home.php
diff --git a/controls/scene.php b/app/controls/scene.php
similarity index 100%
rename from controls/scene.php
rename to app/controls/scene.php
diff --git a/lang/cs.php b/app/lang/cs.php
similarity index 97%
rename from lang/cs.php
rename to app/lang/cs.php
index 885c641..d5090a9 100644
--- a/lang/cs.php
+++ b/app/lang/cs.php
@@ -6,6 +6,7 @@ $lang = [
 	'm_settings' => 'Nastavení',
 	'm_automatization' => 'Automatizace',
 	'm_scenes' => 'Scény',
+	'm_log' => 'Log',
 
 	//Buttons
 	'b_year' => 'Rok',
@@ -42,6 +43,7 @@ $lang = [
 	'l_permission' => 'Oprávmnění',
 	'l_inMinutes' => 'v minutách',
 	'l_sleepTime' => 'Doba spánku zařízení',
+	'l_atHome' => 'Doma Jsou',
 
 	//Title
 	't_createScene' => 'Vytvořit scénu',
diff --git a/lang/en.php b/app/lang/en.php
similarity index 97%
rename from lang/en.php
rename to app/lang/en.php
index b237341..e6952e8 100644
--- a/lang/en.php
+++ b/app/lang/en.php
@@ -6,6 +6,7 @@ $lang = [
 	'm_settings' => 'Setting',
 	'm_automatization' => 'Automatization',
 	'm_scenes' => 'Scenes',
+	'm_log' => 'Log',
 
 	//Buttons
 	'b_year' => 'Year',
@@ -42,6 +43,7 @@ $lang = [
 	'l_permission' => 'Permission',
 	'l_inMinutes' => 'in minutes',
 	'l_sleepTime' => 'Device sleep Time',
+	'l_atHome' => 'At home',
 
 	//Title
 	't_createScene' => 'Create Scene',
diff --git a/app/logs/.gitkeep b/app/logs/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/templates/Elementum/scss/elements/_buttons.scss b/app/templates/Elementum/scss/elements/_buttons.scss
similarity index 100%
rename from templates/Elementum/scss/elements/_buttons.scss
rename to app/templates/Elementum/scss/elements/_buttons.scss
diff --git a/templates/automation.phtml b/app/templates/automation.phtml
similarity index 65%
rename from templates/automation.phtml
rename to app/templates/automation.phtml
index e7739a9..4d1b50a 100644
--- a/templates/automation.phtml
+++ b/app/templates/automation.phtml
@@ -11,23 +11,12 @@
 	
diff --git a/templates/css/font-awesome.min.css b/app/templates/css/font-awesome.min.css similarity index 100% rename from templates/css/font-awesome.min.css rename to app/templates/css/font-awesome.min.css diff --git a/templates/css/loading.css b/app/templates/css/loading.css similarity index 100% rename from templates/css/loading.css rename to app/templates/css/loading.css diff --git a/templates/css/main.css b/app/templates/css/main.css similarity index 100% rename from templates/css/main.css rename to app/templates/css/main.css diff --git a/templates/css/main.css.map b/app/templates/css/main.css.map similarity index 100% rename from templates/css/main.css.map rename to app/templates/css/main.css.map diff --git a/templates/css/modal.css b/app/templates/css/modal.css similarity index 100% rename from templates/css/modal.css rename to app/templates/css/modal.css diff --git a/templates/css/pre.css b/app/templates/css/pre.css similarity index 100% rename from templates/css/pre.css rename to app/templates/css/pre.css diff --git a/templates/dashboard.phtml b/app/templates/dashboard.phtml similarity index 67% rename from templates/dashboard.phtml rename to app/templates/dashboard.phtml index 747e310..5df6ff0 100644 --- a/templates/dashboard.phtml +++ b/app/templates/dashboard.phtml @@ -11,23 +11,12 @@
Add Device diff --git a/templates/fonts/FontAwesome.otf b/app/templates/fonts/FontAwesome.otf similarity index 100% rename from templates/fonts/FontAwesome.otf rename to app/templates/fonts/FontAwesome.otf diff --git a/templates/fonts/Metropolis-Medium.otf b/app/templates/fonts/Metropolis-Medium.otf similarity index 100% rename from templates/fonts/Metropolis-Medium.otf rename to app/templates/fonts/Metropolis-Medium.otf diff --git a/templates/fonts/Metropolis-Regular.otf b/app/templates/fonts/Metropolis-Regular.otf similarity index 100% rename from templates/fonts/Metropolis-Regular.otf rename to app/templates/fonts/Metropolis-Regular.otf diff --git a/templates/fonts/Metropolis-SemiBold.otf b/app/templates/fonts/Metropolis-SemiBold.otf similarity index 100% rename from templates/fonts/Metropolis-SemiBold.otf rename to app/templates/fonts/Metropolis-SemiBold.otf diff --git a/templates/fonts/fontawesome-webfont.eot b/app/templates/fonts/fontawesome-webfont.eot similarity index 100% rename from templates/fonts/fontawesome-webfont.eot rename to app/templates/fonts/fontawesome-webfont.eot diff --git a/templates/fonts/fontawesome-webfont.svg b/app/templates/fonts/fontawesome-webfont.svg similarity index 100% rename from templates/fonts/fontawesome-webfont.svg rename to app/templates/fonts/fontawesome-webfont.svg diff --git a/templates/fonts/fontawesome-webfont.ttf b/app/templates/fonts/fontawesome-webfont.ttf similarity index 100% rename from templates/fonts/fontawesome-webfont.ttf rename to app/templates/fonts/fontawesome-webfont.ttf diff --git a/templates/fonts/fontawesome-webfont.woff b/app/templates/fonts/fontawesome-webfont.woff similarity index 100% rename from templates/fonts/fontawesome-webfont.woff rename to app/templates/fonts/fontawesome-webfont.woff diff --git a/templates/fonts/fontawesome-webfont.woff2 b/app/templates/fonts/fontawesome-webfont.woff2 similarity index 100% rename from templates/fonts/fontawesome-webfont.woff2 rename to app/templates/fonts/fontawesome-webfont.woff2 diff --git a/templates/home.phtml b/app/templates/home.phtml similarity index 68% rename from templates/home.phtml rename to app/templates/home.phtml index 51c3bbe..d265683 100644 --- a/templates/home.phtml +++ b/app/templates/home.phtml @@ -11,23 +11,12 @@
@@ -35,14 +24,8 @@
diff --git a/templates/images/icon-192x192.png b/app/templates/images/icon-192x192.png similarity index 100% rename from templates/images/icon-192x192.png rename to app/templates/images/icon-192x192.png diff --git a/templates/images/icon-512x512.png b/app/templates/images/icon-512x512.png similarity index 100% rename from templates/images/icon-512x512.png rename to app/templates/images/icon-512x512.png diff --git a/templates/js/jquery.js b/app/templates/js/jquery.js similarity index 100% rename from templates/js/jquery.js rename to app/templates/js/jquery.js diff --git a/templates/js/jquery.redirect.js b/app/templates/js/jquery.redirect.js similarity index 100% rename from templates/js/jquery.redirect.js rename to app/templates/js/jquery.redirect.js diff --git a/templates/js/post.js b/app/templates/js/post.js similarity index 100% rename from templates/js/post.js rename to app/templates/js/post.js diff --git a/templates/js/script.js b/app/templates/js/script.js similarity index 100% rename from templates/js/script.js rename to app/templates/js/script.js diff --git a/templates/loading.css b/app/templates/loading.css similarity index 100% rename from templates/loading.css rename to app/templates/loading.css diff --git a/templates/log.phtml b/app/templates/log.phtml similarity index 54% rename from templates/log.phtml rename to app/templates/log.phtml index 9059726..f446e17 100644 --- a/templates/log.phtml +++ b/app/templates/log.phtml @@ -11,23 +11,12 @@
@@ -42,15 +31,17 @@
- - '; + '; + foreach ($file_lines as $line) { + echo $line; + } + echo '
'; } - } - ?> + ?> +
diff --git a/templates/login.phtml b/app/templates/login.phtml similarity index 100% rename from templates/login.phtml rename to app/templates/login.phtml diff --git a/templates/part/automationButton.phtml b/app/templates/part/automationButton.phtml similarity index 100% rename from templates/part/automationButton.phtml rename to app/templates/part/automationButton.phtml diff --git a/templates/part/automationCreate.phtml b/app/templates/part/automationCreate.phtml similarity index 100% rename from templates/part/automationCreate.phtml rename to app/templates/part/automationCreate.phtml diff --git a/templates/part/automationCreateFinal.phtml b/app/templates/part/automationCreateFinal.phtml similarity index 100% rename from templates/part/automationCreateFinal.phtml rename to app/templates/part/automationCreateFinal.phtml diff --git a/templates/part/automationEdit.phtml b/app/templates/part/automationEdit.phtml similarity index 100% rename from templates/part/automationEdit.phtml rename to app/templates/part/automationEdit.phtml diff --git a/templates/part/dashboardButton.phtml b/app/templates/part/dashboardButton.phtml similarity index 100% rename from templates/part/dashboardButton.phtml rename to app/templates/part/dashboardButton.phtml diff --git a/templates/part/deviceButton.phtml b/app/templates/part/deviceButton.phtml similarity index 100% rename from templates/part/deviceButton.phtml rename to app/templates/part/deviceButton.phtml diff --git a/templates/part/deviceDetail.phtml b/app/templates/part/deviceDetail.phtml similarity index 100% rename from templates/part/deviceDetail.phtml rename to app/templates/part/deviceDetail.phtml diff --git a/templates/part/deviceEdit.phtml b/app/templates/part/deviceEdit.phtml similarity index 100% rename from templates/part/deviceEdit.phtml rename to app/templates/part/deviceEdit.phtml diff --git a/templates/part/footer.phtml b/app/templates/part/footer.phtml similarity index 100% rename from templates/part/footer.phtml rename to app/templates/part/footer.phtml diff --git a/templates/part/head.phtml b/app/templates/part/head.phtml similarity index 100% rename from templates/part/head.phtml rename to app/templates/part/head.phtml diff --git a/app/templates/part/menu.phtml b/app/templates/part/menu.phtml new file mode 100644 index 0000000..b87d80b --- /dev/null +++ b/app/templates/part/menu.phtml @@ -0,0 +1,46 @@ + \ No newline at end of file diff --git a/templates/part/sceneButton.phtml b/app/templates/part/sceneButton.phtml similarity index 100% rename from templates/part/sceneButton.phtml rename to app/templates/part/sceneButton.phtml diff --git a/templates/part/sceneCreate.phtml b/app/templates/part/sceneCreate.phtml similarity index 100% rename from templates/part/sceneCreate.phtml rename to app/templates/part/sceneCreate.phtml diff --git a/templates/part/sceneCreateOptions.phtml b/app/templates/part/sceneCreateOptions.phtml similarity index 100% rename from templates/part/sceneCreateOptions.phtml rename to app/templates/part/sceneCreateOptions.phtml diff --git a/templates/part/sceneEdit.phtml b/app/templates/part/sceneEdit.phtml similarity index 100% rename from templates/part/sceneEdit.phtml rename to app/templates/part/sceneEdit.phtml diff --git a/templates/part/test.phtml b/app/templates/part/test.phtml similarity index 100% rename from templates/part/test.phtml rename to app/templates/part/test.phtml diff --git a/templates/rooms.phtml b/app/templates/rooms.phtml similarity index 83% rename from templates/rooms.phtml rename to app/templates/rooms.phtml index 88ddd49..77b120a 100644 --- a/templates/rooms.phtml +++ b/app/templates/rooms.phtml @@ -11,23 +11,12 @@
diff --git a/templates/scene.phtml b/app/templates/scene.phtml similarity index 67% rename from templates/scene.phtml rename to app/templates/scene.phtml index f0b96ab..6b3d3b4 100644 --- a/templates/scene.phtml +++ b/app/templates/scene.phtml @@ -11,23 +11,12 @@
diff --git a/templates/setting.phtml b/app/templates/setting.phtml similarity index 68% rename from templates/setting.phtml rename to app/templates/setting.phtml index a604415..593ad91 100644 --- a/templates/setting.phtml +++ b/app/templates/setting.phtml @@ -11,23 +11,12 @@
@@ -55,6 +44,11 @@ ROOMS
+
+
+ Logs +
+
diff --git a/views/Ajax.php b/app/views/Ajax.php similarity index 98% rename from views/Ajax.php rename to app/views/Ajax.php index efb16f7..94caaa9 100644 --- a/views/Ajax.php +++ b/app/views/Ajax.php @@ -1,8 +1,8 @@ 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 = []; $roomsData = RoomManager::getAllRooms(); foreach ($roomsData as $roomKey => $roomsData) { @@ -124,9 +142,6 @@ class Home extends Template ]; } - $users = UserManager::getUsers(); - $template->prepare('users', $users); - $rooms = RoomManager::getAllRooms(); $template->prepare('rooms', $rooms); $template->prepare('title', 'Home'); diff --git a/views/Log.php b/app/views/Log.php similarity index 93% rename from views/Log.php rename to app/views/Log.php index f8e671f..af2646e 100644 --- a/views/Log.php +++ b/app/views/Log.php @@ -16,7 +16,7 @@ class Log extends Template $template->prepare('title', 'Log'); $result = array(); - $cdir = scandir('./logs/'); + $cdir = scandir('./app/logs/'); foreach ($cdir as $key => $value) { if (!in_array($value,array(".",".."))) diff --git a/views/Login.php b/app/views/Login.php similarity index 100% rename from views/Login.php rename to app/views/Login.php diff --git a/views/Logout.php b/app/views/Logout.php similarity index 100% rename from views/Logout.php rename to app/views/Logout.php diff --git a/views/Rooms.php b/app/views/Rooms.php similarity index 100% rename from views/Rooms.php rename to app/views/Rooms.php diff --git a/views/Scene.php b/app/views/Scene.php similarity index 100% rename from views/Scene.php rename to app/views/Scene.php diff --git a/views/Setting.php b/app/views/Setting.php similarity index 100% rename from views/Setting.php rename to app/views/Setting.php diff --git a/class/Form.php b/class/Form.php deleted file mode 120000 index 7fa7c6a..0000000 --- a/class/Form.php +++ /dev/null @@ -1 +0,0 @@ -C:/Users/spaninger/Documents/git/PHP_FORM_GENERATOR/Form.php \ No newline at end of file diff --git a/index.php b/index.php index 545a7f7..a1ecd6c 100644 --- a/index.php +++ b/index.php @@ -11,10 +11,11 @@ mb_internal_encoding ("UTF-8"); //Autoloader foreach (["class", "views"] as $dir) { - $files = scandir('./'.$dir.'/'); - $files = array_diff($files, array('.', '..')); + $files = scandir('./app/'.$dir.'/'); + $files = array_diff($files, array('.', '..', 'app')); + foreach($files as $file) { - include_once './'.$dir.'/'. $file; + include './app/'.$dir.'/'. $file; } } @@ -33,7 +34,7 @@ if (DEBUGMOD == 1) { echo ''; echo '';*/ } -require_once './lang/' . $langTag . '.php'; +require_once './app/lang/' . $langTag . '.php'; //DB Conector Db::connect (DBHOST, DBUSER, DBPASS, DBNAME); @@ -55,8 +56,8 @@ $form->addInput(InputTypes::TEXT,'nadpis','','Label',''); $form->addInput(InputTypes::CHECK,'nadpis','','Label',''); $form->addInput(InputTypes::TEXT,'nadpis','','Label',''); $arg = array( - 'test_v' => 'test', - 'test_v2' => 'test', +'test_v' => 'test', +'test_v2' => 'test', ); $form->addSelect('1', '1', '1', $arg, false); $form->render();