Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
| 2 | // Core of the application |
| 3 | |
| 4 | const INTERNAL_CLASS_NAMESPACE = "Internal\\"; |
| 5 | |
| 6 | // Classes autoload |
| 7 | spl_autoload_register(function($className) { |
| 8 | if ($className == "lbuchs\WebAuthn\Binary\ByteBuffer") { |
| 9 | include_once(__DIR__."/lib/WebAuthn/Binary/ByteBuffer.php"); |
| 10 | return; |
| 11 | } |
| 12 | |
| 13 | |
| 14 | include_once(__DIR__."/inc/".$className.".php"); |
| 15 | }); |
| 16 | |
| 17 | // Getting configuration |
| 18 | require_once(__DIR__."/config.php"); |
| 19 | |
| 20 | // Setting timezone and locale accordingly |
| 21 | date_default_timezone_set("Europe/Madrid"); |
| 22 | setlocale(LC_TIME, 'es_ES.UTF-8', 'es_ES', 'es'); |
| 23 | |
| 24 | // Database settings |
| 25 | $con = @mysqli_connect($conf["db"]["server"], $conf["db"]["user"], $conf["db"]["password"], $conf["db"]["database"]) or die("There was an error connecting to the database.\n"); |
| 26 | mysqli_set_charset($con, "utf8mb4"); |
| 27 | |
| 28 | // Session settings |
| 29 | session_set_cookie_params([ |
| 30 | "lifetime" => 0, |
| 31 | "path" => $conf["path"], |
| 32 | "httponly" => true |
| 33 | ]); |
| 34 | session_start(); |
| 35 | |
| 36 | // Check if app has been installed |
| 37 | if (db::needsSetUp()) { |
| 38 | security::logout(); |
| 39 | die("Please, run install.php from the command line to install the app before using it."); |
| 40 | } |