From fac61531ddd2fa687d9d0ce96c9316943274dcf9 Mon Sep 17 00:00:00 2001
From: Miraty
Date: Tue, 31 May 2022 19:12:14 +0200
Subject: [PATCH] Create fn/ directory
---
common/init.php | 36 +++++++-----------------------------
auth.php => fn/auth.php | 0
fn/common.php | 24 ++++++++++++++++++++++++
dns.php => fn/dns.php | 0
ht.php => fn/ht.php | 0
ns.php => fn/ns.php | 0
reg.php => fn/reg.php | 0
7 files changed, 31 insertions(+), 29 deletions(-)
rename auth.php => fn/auth.php (100%)
create mode 100644 fn/common.php
rename dns.php => fn/dns.php (100%)
rename ht.php => fn/ht.php (100%)
rename ns.php => fn/ns.php (100%)
rename reg.php => fn/reg.php (100%)
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