summaryrefslogtreecommitdiff
path: root/web/index.php
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-03-30 12:14:42 -0400
committerFreya Murphy <freya@freyacat.org>2024-03-30 12:14:42 -0400
commit1f04b83be337cc91a3fabcf4e574e2306f3d2eaa (patch)
tree74d7d65a7047e60d1877384e3c7b0d70c7b0e49a /web/index.php
parentstart database (user and post), and initial barebones home page (diff)
downloadxssbook2-1f04b83be337cc91a3fabcf4e574e2306f3d2eaa.tar.gz
xssbook2-1f04b83be337cc91a3fabcf4e574e2306f3d2eaa.tar.bz2
xssbook2-1f04b83be337cc91a3fabcf4e574e2306f3d2eaa.zip
refactor
Diffstat (limited to '')
-rw-r--r--web/index.php116
1 files changed, 13 insertions, 103 deletions
diff --git a/web/index.php b/web/index.php
index 1032b7f..9c2d239 100644
--- a/web/index.php
+++ b/web/index.php
@@ -2,114 +2,26 @@
session_start();
-$lang = array();
-$__vars = array();
$webroot = dirname(__FILE__);
-function error_page($code, $msg) {
- $root = $GLOBALS['webroot'];
- error_reporting(E_ERROR | E_PARSE);
- http_response_code($code);
- require($root . '/core/error.php');
- die();
-}
+// load all the helper files
+require($webroot . '/helper/error.php');
+require($webroot . '/helper/lang.php');
-function lang($key, $default = NULL, $sub = NULL) {
- $lang = $GLOBALS['lang'];
- if(array_key_exists($key, $lang)) {
- if ($sub) {
- return sprintf($lang[$key], ...$sub);
- } else {
- return $lang[$key];
- }
- } else if ($default !== NULL) {
- return $default;
- } else {
- return $key;
- }
-}
+// load all the config files
+require($webroot . '/config/aesthetic.php');
+require($webroot . '/config/routes.php');
-function ilang($key,
- $class = NULL,
- $id = NULL,
- $href = NULL,
- $click = NULL,
- $attrs = array(),
- $sub = NULL,
- $button = FALSE,
-) {
- $text = lang($key . "_text", FALSE, sub: $sub);
- $tip = lang($key . "_tip", FALSE);
- $icon = lang($key . "_icon", FALSE);
- $content = lang($key . "_content", FALSE);
-
- if ($click || $button) {
- echo '<button ';
- } else {
- echo '<a ';
- }
- if ($tip) {
- echo 'title="' . $tip . '" ';
- echo 'aria-label="' . $tip . '" ';
- }
- if ($class) {
- echo 'class="' . $class . '" ';
- }
- if ($id) {
- echo 'id="' . $id . '" ';
- }
- if ($click) {
- echo 'onclick="' . $click . '" ';
- }
- if ($href) {
- echo 'href="' . $href . '" ';
- }
- foreach ($attrs as $key => $attr) {
- echo $key . '="' . $attr . '" ';
- }
- echo '> ';
- if ($icon) {
- echo '<i class="' . $icon . '">';
- if ($content) {
- echo $content;
- }
- echo '</i>';
- }
- if ($text) {
- echo '<span';
- if ($icon) {
- echo ' class="ml-sm"';
- }
- echo '>' . $text . '</span>';
- }
- if ($click) {
- echo '</button>';
- } else {
- echo '</a>';
- }
-}
+// load all core files
+require($webroot . '/core/_controller.php');
+require($webroot . '/core/_model.php');
+require($webroot . '/core/database.php');
+require($webroot . '/core/loader.php');
+require($webroot . '/core/router.php');
function __init() {
-
- $root = $GLOBALS['webroot'];
-
- // load all core files
- require($root . '/core/database.php');
- require($root . '/core/aesthetic.php');
- require($root . '/core/controller.php');
- require($root . '/core/model.php');
- require($root . '/core/loader.php');
- require($root . '/core/main.php');
- require($root . '/core/router.php');
-
- $main = new MainModel();
$load = new Loader();
- $router = new Router($main, $load);
-
- $GLOBALS['__vars']['main'] = $main;
- $GLOBALS['__vars']['load'] = $load;
- $GLOBALS['__vars']['router'] = $router;
-
+ $router = new Router($load);
$router->handle_request();
};
@@ -118,5 +30,3 @@ if (!file_exists('/status/ready')) {
}
__init();
-
-?>