Header

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Header as PDF for free.

More details

  • Words: 482
  • Pages: 3
* @version $Id:$ */ // set error reporting error_reporting(E_ALL ^ E_NOTICE); /** * Including the configuration file */ include('ncdLib/config.inc.php'); include('classes/DBMysql.class.php'); include('classes/Config.class.php'); include('classes/Utils.class.php'); /** * Creating instance of database class * @var db * @access public */ $db =& DBMysql::getInstance(); /** * Creating instance of config class * @var config * @access public */ $config =& Config::getInstance(); $config->populate(); /** * Creating new smarty class instance * @var sy * @access public */ $sy = new Smarty; /** * Set all the important properties */ $sy->template_dir = "templates/"; $sy->compile_dir = SMARTY_DIR."/templates_c/"; $sy->compile_check = true; $sy->debugging = false; $sy->force_compile = true; $auth = ncd_Auth::getInstance(); $auth->start(); if ($auth->auth['perm'] != 'Admin') { echo ("You don't have permissions to access this page"); exit;

} else { define('ADMIN_MODE',1); } // Check if we have a record for this session in db //$query = "SELECT id FROM {$config->conf['TABLE_SESSIONS']} WHERE sessionId = '{$auth->auth['sessionId']}'"; // Check if a cookie for activity is set if (isset($_COOKIE['ncd_session'])) { $session_id = $_COOKIE['ncd_session']; $query = "UPDATE {$config->conf['TABLE_SESSIONS']} SET lastAccess = NOW() WHERE sessionId = '$session_id'"; $db->query($query); // Update the cookie expiry time by again setting it with a expiry of 15 mins from now setcookie('ncd_session', $session_id, time() + (15 * 60)); } else { // Generate a unique session id $session_id = md5(uniqid(time())); // Set a cookie with value of this session id that will expire after 15 mins setcookie('ncd_session', $session_id, time() + (15 * 60)); // Insert a record for this session $query = "INSERT INTO {$config->conf['TABLE_SESSIONS']} SET sessionId = '$session_id', userId = '{$auth->auth['uid']}', userNic = '{$auth->auth['nic']}', loginTime = NOW(), lastAccess = NOW() "; $db->query($query); } /* $db->query($query); // If we get the record then update the lastAccess of that record with current time if ($db->nf()) { $session = $db->fetchRow(); // Fire the update query $query = "UPDATE {$config->conf['TABLE_SESSIONS']} SET lastAccess = NOW() WHERE id = '{$session['id']}'"; $db->query($query); } else { // We will store this session and login time $query = "INSERT INTO {$config->conf['TABLE_SESSIONS']} SET sessionId = '{$auth->auth['sessionId']}', userId = '{$auth->auth['uid']}', userNic = '{$auth->auth['nic']}', loginTime = NOW(), lastAccess = NOW() "; $db->query($query); }

*/ /** * Get the country list from countries table */ $query = "SELECT * FROM {$config->conf['TABLE_COUNTRIES']} ORDER BY name"; $db->query($query); while ($record = $db->fetchRow()) { $countries[$record['id']] = $record; } $sy->assign('countries', $countries); if (!$auth->auth['country']) { $auth->auth['country'] = 2; } if (isset($_GET['countryId'])) { $auth->auth['country'] = (int)$_GET['countryId']; } $selectedCountry = $countries[$auth->auth['country']]; $sy->assign('selectedCountry', $selectedCountry); function getUniqueFileName($matches, $destDir) { // Create a unique name for the file to be uploaded $nr = 0; $uniqueName = $matches[1] . '.' . $matches[2]; while (file_exists($destDir . $uniqueName)) { $uniqueName = $matches[1] . '~' . $nr++ . '.' . $matches[2]; } return $uniqueName; } /** * Function to convert any date string to mysql format YYYY-mm-dd */ function dateToSql($date) { return date('Y-m-d', strtotime($date)); } ?>

Related Documents

Header
April 2020 17
Header
October 2019 21
Header
October 2019 23
Header
October 2019 23
Tei Header
May 2020 9
Running Header
October 2019 23