//header("location:index.html");
ob_start();
session_start();
require_once('library/template.inc.php');
$template = new Template();
$index = new Index();
$auth = new Auth();
//---------------------------Security Inspection-------------------------------
if (isset($_GET['login']) && ($_POST['username'] != '')) $auth->doLogin($_POST['username'], $_POST['password']);
if (isset($_GET['logout'])) $auth->doLogout();
if ($auth->isValidUser() && $auth->is_logged_in()) $auth->doCheckSession();
if (isset($_GET['template']) && $_GET['template'] == '0'){
$template->printHeader();
}else{
($auth->isValidUser() && $auth->is_logged_in()) ? $template->printBackEndHTML() : $template->printFrontEndHTML();
}
//---------------------------Class Initialization------------------------------
if (isset($_POST['submit']) && strstr($_SERVER['HTTP_REFERER'], $_SERVER['PHP_SELF'])){
$data = $index->cleanPostVals();
//-------------Adding/Editing/Deleteing information in database---------------------------------------------------
$index->process($_POST['module!!'], $_POST['fn'], $data);
}else{
$_GET['apps'] = (isset($_GET['apps'])) ? $_GET['apps'] : "";
$index->run($_GET['apps']);
}
(isset($_GET['template']) && $_GET['template'] == '0') ? "" : $template->printFooter();
unset($auth);
unset($index);
unset($template);
ob_end_flush();
?>