Fixed up users page a little, still need editing...

This commit is contained in:
Josh North 2015-02-19 10:56:49 -05:00
parent 1dc1badd8c
commit fe4d056591

View File

@ -1,42 +1,53 @@
<?php <?php
//********** PLEASE EDIT THE FOLLOWING **********// //********** PLEASE EDIT THE FOLLOWING **********//
// Paths and directories must include a trailing slash!!! // Paths and directories must include a trailing slash!!!
$yaptc_dirpath = '/usr/share/nginx/html/yaptc/'; // Absolute directory path to the root of this program $yaptc_dirpath = '/usr/share/nginx/html/yaptc/'; // Absolute directory path to the root of this program
$yaptc_webpath = 'http://server-ip/yaptc/'; // Absolute URL to the root of this program $yaptc_webpath = 'http://server-ip/yaptc/'; // Absolute URL to the root of this program
$yaptc_appname = 'Timecard System'; // Program name to display in title bar $yaptc_appname = 'Timecard System'; // Program name to display in title bar
$yaptc_company = 'Widgets, Inc.'; // Your company name $yaptc_company = 'Widgets, Inc.'; // Your company name
$sql = new PDO('mysql:host=localhost;dbname=your_database;', 'your_user', 'your_password'); // Database connection string $sql = new PDO('mysql:host=localhost;dbname=your_database;', 'your_user', 'your_password'); // Database connection string
$adminmessage = ''; // Message will display on all pages! $adminmessage = ''; // Message will display on all pages!
//********** NO NEED TO EDIT PAST HERE **********// //********** NO NEED TO EDIT PAST HERE **********//
$_SESSION['yaptc_dir'] = $yaptc_dirpath; $_SESSION['yaptc_dir'] = $yaptc_dirpath;
$_SESSION['yaptc_url'] = $yaptc_webpath; $_SESSION['yaptc_url'] = $yaptc_webpath;
$yaptc_inc = $yaptc_dirpath . 'includes/'; $yaptc_inc = $yaptc_dirpath . 'includes/';
$yaptc_incweb = $yaptc_webpath . 'includes/'; $yaptc_incweb = $yaptc_webpath . 'includes/';
$yaptc_lib = $yaptc_dirpath . 'lib/'; $yaptc_lib = $yaptc_dirpath . 'lib/';
$yaptc_libweb = $yaptc_webpath . 'lib/'; $yaptc_libweb = $yaptc_webpath . 'lib/';
function getSessionStatus(){ // Get login status - returns true or false
if (!isset($_SESSION['user_id']) || !isset($_SESSION['signature']) || !isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] != true || $_SESSION['signature'] != md5($_SESSION['user_id'] . $_SERVER['HTTP_USER_AGENT'])) function getSessionStatus()
{ {
return false; if (!isset($_SESSION['user_id']) || !isset($_SESSION['signature']) || !isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] != true || $_SESSION['signature'] != md5($_SESSION['user_id'] . $_SERVER['HTTP_USER_AGENT'])) {
} else { return false;
return true; } else {
} return true;
}
} }
function getSessionAccess($sql){ // Kick user and go to login
if (isset($_SESSION['user_id'])) function killSession()
{ {
$query3 = "SELECT users.id as userid, usertypes.typename AS usertype FROM users, usertypes WHERE users.id = :id"; session_unset();
$stmt3 = $sql->prepare($query3); session_destroy();
$stmt3->execute(array(':id' => $_SESSION['user_id'])); session_write_close();
$user3 = $stmt3->fetchObject(); header("Location: login.php");
return $user3->usertype;
}
} }
// Get user access level. Call with $sql passed or it will not work correctly
function getSessionAccess($sql)
{
if (isset($_SESSION['user_id'])) {
$query3 = "SELECT users.id as userid, usertypes.typename AS usertype FROM users, usertypes WHERE users.id = :id";
$stmt3 = $sql->prepare($query3);
$stmt3->execute(array(
':id' => $_SESSION['user_id']
));
$user3 = $stmt3->fetchObject();
return $user3->usertype;
}
}
?> ?>