Example #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 to_0_9_7()
 {
     $const_dbpath = costant::database_path();
     $db = new PDO("sqlite:{$const_dbpath}");
     $db->exec("ALTER TABLE New_Transaction RENAME TO New_Transaction_Old");
     db_function::db_create();
     $db->exec("INSERT INTO New_Transaction (Date, Status, Type, Account, ToAccount, Payee, Category, SubCategory, Amount, Notes)\r\n                            SELECT Date, Status, Type, Account, ToAccount, Payee, 'None', 'None', Amount, Notes FROM New_Transaction_Old");
     $db->exec("DROP TABLE New_Transaction_Old");
     $db->exec("UPDATE Parameters SET Value = '0.9.7' WHERE Parameter = 'Version';");
     $db = null;
 }