diff options
author | Freya Murphy <freya@freyacat.org> | 2024-03-29 22:29:56 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-03-29 22:29:56 -0400 |
commit | 944b6b0526032ad8c1b4a2612d6723bec75e0e4c (patch) | |
tree | d3da5584df33a7878c087622b4fc2ec2883cf880 /web/core/loader.php | |
download | xssbook2-944b6b0526032ad8c1b4a2612d6723bec75e0e4c.tar.gz xssbook2-944b6b0526032ad8c1b4a2612d6723bec75e0e4c.tar.bz2 xssbook2-944b6b0526032ad8c1b4a2612d6723bec75e0e4c.zip |
start database (user and post), and initial barebones home page
Diffstat (limited to '')
-rw-r--r-- | web/core/loader.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/web/core/loader.php b/web/core/loader.php new file mode 100644 index 0000000..4d4526c --- /dev/null +++ b/web/core/loader.php @@ -0,0 +1,38 @@ +<?php /* Copyright (c) 2024 Freya Murphy */ +class Loader { + + /** + * Loads the given common lang + * @param lang_code - the language code + */ + public function lang($lang_code) { + $dir = $GLOBALS['webroot'] . '/lang/' . $lang_code . '/'; + $lang = $GLOBALS['lang']; + if ($handle = opendir($dir)) { + while (false !== ($entry = readdir($handle))) { + if ($entry === '.' || $entry === '..' || $entry === 'routes') { + continue; + } + $path = $dir . $entry; + require($path); + } + } + $GLOBALS['lang'] = $lang; + } + + /** + * Loads a given route specific lang + * @param lang_coed - the language code + * #param name - the name of the route + */ + public function route_lang($lang_code, $name) { + $dir = $GLOBALS['webroot'] . '/lang/' . $lang_code . '/routes/'; + $file = $dir . $name . '.php'; + if (file_exists($file)) { + $lang = $GLOBALS['lang']; + require($dir . $name . '.php'); + $GLOBALS['lang'] = $lang; + } + } + +} |