servnest/common/init.php

27 lines
922 B
PHP
Raw Normal View History

2022-05-19 14:59:32 +00:00
<?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));
2022-05-19 14:59:32 +00:00
define("PAGE", basename($_SERVER['PHP_SELF'], '.php'));
define("DB_PATH", CONF['common']['root_path'] . "/db/niver.db"); // Niver's SQLite database
2022-05-19 14:59:32 +00:00
// Service-specific functions and constants
if (SERVICE === "reg" OR SERVICE === "ns")
require CONF['common']['root_path'] . "/dns.php";
2022-05-19 14:59:32 +00:00
if (SERVICE !== "")
require CONF['common']['root_path'] . "/" . SERVICE . ".php";
2022-05-19 14:59:32 +00:00
// Page titles definition
require "pages.php";
function userError($msg) {
http_response_code(422);
2022-05-20 00:21:38 +00:00
exit("<strong>User error</strong>: The server refused to process this request: <em>" . $msg . "</em>");
}
function serverError($msg) {
http_response_code(500);
2022-05-20 00:21:38 +00:00
exit("<strong>Server error</strong>: The server encountered an error: <em>" . $msg . "</em>");
}