DeltaCMS/router.php
Florian Bouillon bc8fba19d4 too manu changes (will list by files)
.gitignore
ignores some launch files

changelog.md, readme.md
added end file line

public.php
moved
started the work on it

router.php
added require to functions & moved the function in the file
set an ini value to show errors
defied some constants
moved the public page management to public/public.php

exampleModule -> headGenerator.php
started working on module management

*.json
reworked files

function.php
added this file to manages cores functions

website.php
the Website Object for theme & modules

page.php
created a test theme
2019-02-17 00:12:50 +01:00

47 lines
1.1 KiB
PHP

<?php
/**
* this file initialize some variables and do the first part of the routing (between public pages & admin pages)
*/
require_once "admin/system/functions.php";
ini_set('display_errors', 'On');
$url = strtolower(endsWith($_SERVER["REQUEST_URI"], "/") ? $_SERVER["REQUEST_URI"] . "index" : $_SERVER["REQUEST_URI"]);
define("URL", $url);
define("ROOT", __DIR__);
define("SETTINGS", loadJSON(ROOT . "/admin/settings/admin.json"));
// $website = new Website();
// var_dump(__DIR__);
$_SERVER = null;
if($url == "/test") {
require_once "test.php";
die;
}
$fileURI = "./pages" . $url . ".json";
if(in_array(explode("/", $url)[1], ["login", "admin"])) echo ("this is the login/admin page");
elseif (file_exists($fileURI)) {
require_once "public/public.php";
} else echo "404";
/*
verify if the page to load exist
if page is login/admin then continue;
elif the page is a file in /pages/pagename.json then continue
else return 404 error
verify if user is logged in
if the user is logged in & the page is login return to /admin
elif the user is not logged in & the page is admin return to /login
else start the process to load the page
*/
?>