1
0
mirror of https://gitlab.com/JKANetwork/CheckServer.git synced 2026-03-04 17:49:55 +01:00

Change connect to load and fix code

This commit is contained in:
2018-01-09 23:27:59 +01:00
parent 42583d198e
commit 5e33adbbaf
10 changed files with 105 additions and 115 deletions

38
load.php Normal file
View File

@@ -0,0 +1,38 @@
<?php
require_once 'functions.php'; //Preloads functions
require_once 'lib/dbwrapper.php';
define('VERSION','0.9.2');
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");
}