PHP_SMART_HOME_V3/index.php

80 lines
2.0 KiB
PHP
Raw Normal View History

2019-08-23 11:39:42 +00:00
<?php
//Config
include_once './config.php';
//setup
ini_set ('session.cookie_httponly', 1);
session_start ();
mb_internal_encoding ("UTF-8");
//Autoloader
foreach (["class", "views"] as $dir) {
2019-09-19 12:48:31 +00:00
$files = scandir('./app/'.$dir.'/');
$files = array_diff($files, array('.', '..', 'app'));
2019-08-23 11:39:42 +00:00
foreach($files as $file) {
2019-09-19 12:48:31 +00:00
include './app/'.$dir.'/'. $file;
2019-08-23 11:39:42 +00:00
}
}
/** Language **/
$langTag = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if (DEBUGMOD == 1) {
/*echo '<div class="col-md-9 main-body">';
echo '<pre>';
echo 'Language SLUG: ' . $langTag;
echo '</pre>';
echo '<pre>';
print_r(get_defined_constants());
echo '</pre>';
echo '<pre>';
print_r(get_defined_vars());
echo '</pre>';
echo '</dev>';*/
}
2019-09-19 12:48:31 +00:00
require_once './app/lang/' . $langTag . '.php';
2019-08-23 11:39:42 +00:00
//DB Conector
Db::connect (DBHOST, DBUSER, DBPASS, DBNAME);
//TODO: Přesunout do Login Pohledu
$userManager = new UserManager();
if (isset($_POST['username']) && isset($_POST['password']) ) {
$userManager->login($_POST['username'], $_POST['password'], $_POST['remember']);
}
2019-09-01 13:55:33 +00:00
$logManager = new LogManager();
2019-08-23 11:39:42 +00:00
/*
$form = new Form('name','1','POST','');
$form->addInput(InputTypes::TEXT,'nadpis','','Label','');
$form->addInput(InputTypes::BUTTON,'nadpis','','Label','test');
$form->addInput(InputTypes::TEXT,'nadpis','','Label','');
$form->addInput(InputTypes::TEXT,'nadpis','','Label','', false);
$form->addInput(InputTypes::TEXT,'nadpis','','Label','');
$form->addInput(InputTypes::CHECK,'nadpis','','Label','');
$form->addInput(InputTypes::TEXT,'nadpis','','Label','');
$arg = array(
2019-09-19 12:48:31 +00:00
'test_v' => 'test',
'test_v2' => 'test',
2019-08-23 11:39:42 +00:00
);
$form->addSelect('1', '1', '1', $arg, false);
$form->render();
die();
*/
$route = new Route();
$route->add('/', 'Home');
$route->add('/login', 'Login');
$route->add('/logout', 'Logout');
$route->add('/automation', 'Automation');
$route->add('/dashboard', 'Dashboard');
$route->add('/setting', 'Setting');
$route->add('/scene', 'Scene');
$route->add('/ajax', 'Ajax');
2019-09-01 13:55:33 +00:00
$route->add('/log', 'Log');
2019-08-23 11:39:42 +00:00
$route->add('/rooms', 'Rooms');
$route->submit();