Beispiel #1
0
<?php

require_once "functions.php";
$error = db_function::db_create();
if ($error !== "ok") {
    echo $error;
} else {
    $upgrade_result = db_upgrade::upgrade_db();
    if ($upgrade_result == "update_done") {
        various::send_alert_and_redirect("Database succesfully updated to version " . costant::app_version(), "index.php");
    }
}
$username = null;
$password = null;
$const_username = costant::login_username();
$const_password = costant::login_password();
$const_disable_authentication = costant::disable_authentication();
if ($const_disable_authentication == "True") {
    header("Location: landing.php");
}
if ($const_disable_authentication !== "True" && (!isset($const_username) or !isset($const_password))) {
    header("Location: settings.php");
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (!empty($_POST["Username"]) && !empty($_POST["Password"])) {
        $username = $_POST["Username"];
        $password = hash("sha512", $_POST["Password"]);
        if ($username == $const_username && $password == $const_password) {
            session_start();
            $user_browser = $_SERVER['HTTP_USER_AGENT'];
            $_SESSION["username"] = $username;
 public static function upgrade_db()
 {
     $start_db_version = db_function::db_version();
     $app_version = costant::app_version();
     while (db_function::db_version() !== $app_version) {
         switch (db_function::db_version()) {
             case "0.9.2":
                 db_upgrade::to_0_9_3();
                 break;
             case "0.9.3":
                 db_upgrade::upgrade_version("0.9.4");
                 break;
             case "0.9.4":
                 db_upgrade::upgrade_version("0.9.5");
                 break;
             case "0.9.5":
                 db_upgrade::upgrade_version("0.9.6");
                 break;
             case "0.9.6":
                 db_upgrade::to_0_9_7();
                 break;
             case "0.9.7":
                 db_upgrade::upgrade_version("0.9.8");
                 break;
             case "0.9.8":
                 db_upgrade::to_0_9_9();
                 break;
             case "0.9.9":
                 db_upgrade::upgrade_version("1.0.0");
                 break;
             case "1.0.0":
                 db_upgrade::upgrade_version("1.0.1");
                 break;
             case "1.0.1":
                 db_upgrade::upgrade_version("1.0.2");
                 break;
             case $app_version:
                 break;
             default:
                 various::send_alert_and_redirect("Database version not compliant: DB Version = " . db_function::db_version() . " - APP Version = {$app_version}", "error.php");
                 break 2;
         }
     }
     if ($start_db_version !== $app_version && db_function::db_version() == $app_version) {
         return "update_done";
     } else {
         return "update_not_need";
     }
 }