servnest/common/init.php

30 lines
946 B
PHP

<?php
define("CONF", parse_ini_file(__DIR__ . "/../config.ini", true, INI_SCANNER_TYPED));
define("SERVICE", substr(dirname($_SERVER['PHP_SELF']), strlen(CONF['common']['prefix']) + 1));
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";
function userError($msg) {
http_response_code(403);
echo "<p><strong>Erreur utilisataire</strong> : <em>" . $msg . "</em></p>";
closeHTML();
exit();
}
function serverError($msg) {
http_response_code(500);
echo "<p><strong>Server error</strong>: The server encountered an error: <em>" . $msg . "</em></p>";
closeHTML();
exit();
}