83 lines
2.2 KiB
PHP
83 lines
2.2 KiB
PHP
<?php
|
|
session_start();
|
|
require '../vendor/autoload.php';
|
|
|
|
use Symfony\Component\Yaml\Yaml;
|
|
use KTH\App;
|
|
use KTH\HTMLGenerator\HTMLGenerator;
|
|
use Login\Login;
|
|
|
|
$defConfig['title'] = 'KT-HomePage';
|
|
$defConfig['desc'] = 'Dashboard de Knah Tsaeb';
|
|
$defConfig['favicon'] = 'favicon.png';
|
|
$defConfig['noAuth'] = ['128.0.0.1'];
|
|
$defConfig['public'] = false;
|
|
$defConfig['colorScheme'] = 'dark';
|
|
$defConfig['view'] = 'full';
|
|
|
|
$breadcrumbs = '';
|
|
|
|
$KTH = new App();
|
|
$config = $KTH->getConfig($defConfig);
|
|
|
|
if (isset($_GET['logout'])) {
|
|
$logout = Login::logOut();
|
|
exit();
|
|
}
|
|
|
|
if ($config['public'] === false) {
|
|
if (!$KTH->canByPassAuth($defConfig['noAuth'])) {
|
|
if (!Login::isLogged()) {
|
|
if (file_exists('../data/users.yaml')) {
|
|
require('../template/default/login.php');
|
|
} else {
|
|
require('../template/default/register.php');
|
|
}
|
|
exit();
|
|
}
|
|
}
|
|
}
|
|
|
|
if (isset($_GET['settings'])) {
|
|
require('../template/default/settings.php');
|
|
exit();
|
|
}
|
|
|
|
if (isset($_POST['settings'])) {
|
|
$KTH->saveUserConfig();
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
if ($KTH->cacheExist()) {
|
|
echo file_get_contents('index.html');
|
|
} else {
|
|
if (file_exists('../data/services.yaml')) {
|
|
$services = Yaml::parseFile('../data/services.yaml');
|
|
} else {
|
|
$services = [0 => [
|
|
'title' => 'Wikipedia',
|
|
'screenshot' => 'wikipedia.png',
|
|
'favicon' => 'wikipedia.png',
|
|
'link' => 'https://en.wikipedia.org/wiki/Dashboard_(computing)',
|
|
'appHome' => 'https://www.mediawiki.org/wiki/MediaWiki',
|
|
'location' => 'web',
|
|
'desc' => 'Wikipedia, the free encyclopedia',
|
|
'type' => 'webapp'
|
|
]];
|
|
}
|
|
$generator = new HTMLGenerator($services);
|
|
$userDoc = $generator->genUserDoc();
|
|
$menuData = $KTH->makeMenu($services);
|
|
|
|
ob_start();
|
|
|
|
require('../template/default/header.php');
|
|
require('../template/default/titleBar.php');
|
|
require('../template/default/nav.php');
|
|
require('../template/default/content.php');
|
|
require('../template/default/footer.php');
|
|
|
|
$out = ob_get_contents();
|
|
file_put_contents('index.html', $out);
|
|
}
|