diff --git a/common/init.php b/common/init.php index 2368761..93fb94e 100644 --- a/common/init.php +++ b/common/init.php @@ -6,39 +6,17 @@ define("SERVICE", substr(dirname($_SERVER['PHP_SELF']), strlen(CONF['common']['p define("PAGE", basename($_SERVER['PHP_SELF'], '.php')); define("DB_PATH", CONF['common']['root_path'] . "/db/niver.db"); // Niver's SQLite database -// Service-specific functions and constants -if (SERVICE === "reg" OR SERVICE === "ns") - require CONF['common']['root_path'] . "/dns.php"; -if (SERVICE !== "") - require CONF['common']['root_path'] . "/" . SERVICE . ".php"; - // Page titles definition require "pages.php"; +require CONF['common']['root_path'] . "/fn/common.php"; +// Service-specific functions and constants +if (SERVICE === "reg" OR SERVICE === "ns") + require CONF['common']['root_path'] . "/fn/dns.php"; +if (SERVICE !== "") + require CONF['common']['root_path'] . "/fn/" . SERVICE . ".php"; + function success($msg) { echo "
Succès : " . $msg . "
"; closeHTML(); } - -// When the user requests something unexpected -function userError($msg) { - http_response_code(403); - echo "Erreur utilisataire : " . $msg . "
"; - closeHTML(); -} - -// When the system did something unexpected -function serverError($msg) { - http_response_code(500); - error_log("Niver internal error: " . strip_tags($msg)); - echo "Server error: The server encountered an error: " . $msg . "
"; - closeHTML(); -} - -// For use in pages that first display a form and then process it -function switchToFormProcess($requireLogin = true) { - if (empty($_POST)) - closeHTML(); - if ($requireLogin AND !isset($_SESSION['username'])) - userError("Vous devez être connecté·e pour effectuer cette action."); -} diff --git a/auth.php b/fn/auth.php similarity index 100% rename from auth.php rename to fn/auth.php diff --git a/fn/common.php b/fn/common.php new file mode 100644 index 0000000..04a2f21 --- /dev/null +++ b/fn/common.php @@ -0,0 +1,24 @@ +Erreur utilisataire : " . $msg . ""; + closeHTML(); +} + +// When the system did something unexpected +function serverError($msg) { + http_response_code(500); + error_log("Niver internal error: " . strip_tags($msg)); + echo "Server error: The server encountered an error: " . $msg . "
"; + closeHTML(); +} + +// For use in pages that first display a form and then process it +function switchToFormProcess($requireLogin = true) { + if (empty($_POST)) + closeHTML(); + if ($requireLogin AND !isset($_SESSION['username'])) + userError("Vous devez être connecté·e pour effectuer cette action."); +} diff --git a/dns.php b/fn/dns.php similarity index 100% rename from dns.php rename to fn/dns.php diff --git a/ht.php b/fn/ht.php similarity index 100% rename from ht.php rename to fn/ht.php diff --git a/ns.php b/fn/ns.php similarity index 100% rename from ns.php rename to fn/ns.php diff --git a/reg.php b/fn/reg.php similarity index 100% rename from reg.php rename to fn/reg.php