<?php include "config.php"; session_start(); openRailwayCore::initialisation(); openRailwayCore::dbConnect(); Authentication::blockPageToVisitors(); // Process login info section $ipAddr = $_SESSION['user_ip']; $loginTime = date('l jS F Y H:i:s T', $_SESSION['log_in_time']); use phpbrowscap\Browscap; $bc = new Browscap(FROOT . "cache"); // $browser = $bc->getBrowser(); COMMENTED OUT AS XAMPP DOES NOT SUPPORT openRailwayCore::pageHeader("Your dashboard"); $template = new Template(); $template->set_custom_template("theme/" . STYLE, 'default'); $template->assign_var('IP_ADDR', $ipAddr); $template->assign_var('LOGTIME', $loginTime); if (isset($browser['parent']) && isset($browser['platform'])) { $template->assign_var('BRWSR', $browser['parent'] . " on " . $browser['platform']); } $template->set_filenames(array('body' => 'home.html')); $template->display('body'); openRailwayCore::pageFooter();
/** * Locks page to non-authenticated browsers * */ public static function blockPageToVisitors() { openRailwayCore::dbConnect(); if (isset($_SESSION['session_id'])) { $result = openRailwayCore::dbQuery("SELECT `session_id` FROM " . SESSIONS_TABLE . " WHERE `session_id` = '" . $_SESSION['session_id'] . "'"); if (mysql_num_rows($result) == 0) { goto login; } } if (!isset($_SESSION['session_id'])) { login: openRailwayCore::pageHeader("Access not authorised"); $template = new Template(); $template->set_custom_template(FROOT . 'theme/' . STYLE, 'default'); if (isset($_GET['l']) && $_GET['l'] == 'fail') { $template->assign_block_vars('if_login_failed', array()); } if (isset($_GET['l']) && $_GET['l'] == "logout") { $template->assign_block_vars('if_logged_out', array()); } if (isset($_GET['l']) && $_GET['l'] == "flogout") { $template->assign_block_vars('if_force_logged_out', array()); } if (isset($_GET['l']) && $_GET['l'] == 'reauth') { $template->assign_block_vars('if_reauth', array()); } else { $template->assign_block_vars('if_not_reauth', array()); } $template->assign_var('ROOT', ROOT); $template->set_filenames(array('body' => 'login.html')); $template->display('body'); openRailwayCore::pageFooter(); die; } // Check to see if user agent has changed since login, if so log out if ($_SESSION['user_agent'] != $_SERVER['HTTP_USER_AGENT']) { $interaction = openRailwayCore::createInteractionIdentifier(); openRailwayCore::logEvent(time(), $interaction, $_SESSION['user_id'], 5, 1, "User agent (UID: " . $_SESSION['user_id'] . ") change detected"); Authentication::suspendUser($_SESSION['user_id'], $interaction, 1); } }