load.php 1.16 KB
Newer Older
1 2 3
<?php
require_once 'functions.php'; //Preloads functions
require_once 'lib/dbwrapper.php';
Kevin Puertas Ruiz's avatar
Kevin Puertas Ruiz committed
4
define('VERSION','0.9.4');
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
session_start(); //Session in all page
//Preload file
//This function loads all things needed, with optional db things if needed

function getconn(){
	$db_file = __DIR__."/sqlite.db3";
	if (!is_file($db_file)){ //Go to install if not.
		header("Location: install.php");
		die();
	}
	return dbw_connect("sqlite",$db_file); //Database
}

$db_conn = getconn();

/** Check if user SessionID exists, if not, delete Cookie */
if (isset($_SESSION['UserID'])){
		$data = dbw_query_fetch_array($db_conn, "SELECT * FROM USERS WHERE ID_U='$_SESSION[UserID]'");
	if ($data['ID_U'] != $_SESSION['UserID']){
		session_destroy();
		header("Location: index.php");
	}

	$you['ID_U'] = $data['ID_U'];
	$you['nick'] = $data['nick'];
	$you['fullRights'] = $data['fullRights'];
	$you['webRoot'] = webRoot();
}
define('LANG', getSystemOpt('lang'));

if (getSystemOpt('version') != VERSION){
	die("<p>Please run updater.php to update before using page");
}
38 39 40
if (getSystemOpt('maintenance') == '1'){
	die("<p>CheckStatus is in maintenance mode, wait for admin to disable maintenance mode</p>");
}
41