This repository has been archived by the owner on Jan 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
executable file
·120 lines (108 loc) · 3.33 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
//Check if installed
if (file_exists('config/config.yml'))
{
//Require Libs
require_once 'vendor/autoload.php';
require_once 'inc/config.php';
require_once 'inc/libs/functions.php';
require_once 'inc/page.php';
require_once 'inc/apps.php';
//Under Construction?
if (file_exists('content/.system/construction.txt'))
{
echo file_get_contents('content/.system/construction.txt');
} else
{
//Page
$page = new page();
$page->caching = false;
$page->error_reporting = E_ALL & ~E_NOTICE;
//Set Url
$url = str_replace_first($MCONF['home_uri'], '', $_SERVER['REQUEST_URI']);
$page->setUrl($url);
$base = explode('/', $url);
$page->setBaseUrl('/');
if (count($base) > 1)
{
$page->setBaseUrl($base[0] . '/');
}
$page->setResponseCode(404);
$apps = new apps();
//Search apps and execute them if necessary
foreach ($apps->getApps() as $app => $appconf)
{
$appUri = 'apps/' . $appconf['app_path'] . '/';
//Check App dependencies
if($apps->checkDependencies($appconf['app_name']))
{
//If the App should run from one domain only
if ((isset($appconf['domain']) && $page->getDomain() == $appconf['domain']) || !isset($appconf['domain']) || (isset($appconf['domain']) && $appconf['domain'] === ''))
{
//If we have an alias which equals the current url, execute it
if (isset($appconf['alias']))
{
if (array_key_exists($page->getUrl(), $appconf['alias']))
{
require $appUri . $appconf['alias'][$page->getUrl()];
}
}
//If we have a type
if (isset($appconf['type']))
{
//Page for (more or less) dynamic content
if ($appconf['type'] == 'page')
{
//If we have a base_url_file and the current url equals base_url, execute base_url_file
if (isset($appconf['base_url_file']))
{
if ($appconf['base_url'] == $page->getUrl())
{
require $appUri . $appconf['base_url_file'];
}
}
//if we have a base_url and a base_file which exists and the current baseUrl equals base_url, execute base_file
if (isset($appconf['base_url']) && file_exists($appUri . '/' . $appconf['base_file']))
{
if ($appconf['base_url'] == $page->getBaseUrl())
{
require $appUri . $appconf['base_file'];
}
}
}
//Static
if ($appconf['type'] == 'static' && isset($appconf['base_file']) && file_exists($appUri . '/' . $appconf['base_file']))
{
require $appUri . $appconf['base_file'];
}
}
}
}
$appconf = [];
}
if ($page->getResponseCode() == 404)
{
$page->setTitle('404');
$page->setContent(file_get_contents('content/.system/404.txt'));
}
//Build Copyright
$founded = date('Y', filemtime('config/config.yml'));
$copy = $founded;
if ($founded != date('Y'))
{
$copy = $founded . ' - ' . date('Y');
}
$page->assign('copyright', $copy);
//Finally render everything
http_response_code($page->getResponseCode());
$page->assign('page_title', $page->getTitle());
$page->assign($MCONF['tpl_title'], $page->getTitle() . ' | ' . $MCONF['title']);
$page->assign($MCONF['tpl_content'], $page->getContent());
$page->assign($MCONF['tpl_webUri'], $MCONF['web_uri']);
$page->assign('template', $page->getTemplate());
$page->display($MCONF['template']);
}
} else
{
header('Location: admin/install.php');
}