session_functions.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:39k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: session_functions.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.45 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Session handling functions
- // +-------------------------------------------------------------+
- error_reporting(E_ALL ^ E_NOTICE);
- /*****************************************************
- function delete_cookies
- -----DESCRIPTION: -----------------------------------
- - delete all cookies for user/admin/tech zone
- *****************************************************/
- function delete_cookies() {
- if (defined('USERZONE')) {
- dp_setcookie("dp_user_sessionid", "", -1);
- dp_setcookie("dp_user_userid", "", -1);
- dp_setcookie("dp_user_password", "", -1);
- } elseif (defined('ADMINZONE')) {
- dp_setcookie("dp_admin_sessionid", "", -1);
- dp_setcookie("dp_admin_userid", "", -1);
- dp_setcookie("dp_admin_password", "", -1);
- } elseif (defined('TECHZONE')) {
- dp_setcookie("dp_tech_sessionid", "", -1);
- dp_setcookie("dp_tech_userid", "", -1);
- dp_setcookie("dp_tech_password", "", -1);
- }
- }
- /*****************************************************
- function update_cookies
- -----DESCRIPTION: -----------------------------------
- - deletes the session from the db
- - sets an empty cookie
- -----ARGUMENTS: -------------------------------------
- sessionid : the users sessionid
- -----RETURNS:----------------------------------------
- returns the full, updated session array
- *****************************************************/
- function update_cookies($zone = NULL) {
-
- global $_COOKIE;
- if (defined('USERZONE')) {
- $check = 'dp_admin_remember';
- } elseif (defined('ADMINZONE')) {
- $check = 'dp_tech_remember';
- } elseif (defined('TECHZONE')) {
- $check = 'dp_user_remember';
- }
- if ($_COOKIE[$check]) {
- $ever = 'ever';
- } else {
- $ever = NULL;
- }
- if ($zone == "admin") {
- dp_setcookie('dp_admin_remember', $_COOKIE['dp_admin_remember'], $ever);
- dp_setcookie('dp_admin_sessionid', $_COOKIE['dp_admin_sessionid'], $ever);
- dp_setcookie('dp_admin_userid', $_COOKIE['dp_admin_userid'], $ever);
- dp_setcookie('dp_admin_password', $_COOKIE['dp_admin_password'], $ever);
- } elseif ($zone == "tech") {
- dp_setcookie('dp_tech_remember', $_COOKIE['dp_tech_remember'], $ever);
- dp_setcookie('dp_tech_sessionid', $_COOKIE['dp_tech_sessionid'], $ever);
- dp_setcookie('dp_tech_userid', $_COOKIE['dp_tech_userid'], $ever);
- dp_setcookie('dp_tech_password', $_COOKIE['dp_tech_password'], $ever);
- } else {
- dp_setcookie('dp_user_remember', $_COOKIE['dp_user_remember'], $ever);
- dp_setcookie('dp_user_sessionid', $_COOKIE['dp_user_sessionid'], $ever);
- dp_setcookie('dp_user_userid', $_COOKIE['dp_user_userid'], $ever);
- dp_setcookie('dp_user_password', $_COOKIE['dp_user_password'], $ever);
- }
- }
- /*****************************************************
- function logout_tech_session
- ----- DESCRIPTION: -----------------------------------
- - Delete tech session, log session timeout in tech_timelog
- ----- ARGUMENTS: -------------------------------------
- sessionid: The session ID
- techid: The technician's ID
- ----- RETURNS:----------------------------------------
- - Nothing
- *****************************************************/
- function logout_tech_session($sessionid, $techid) {
-
- global $db;
- $time = mktime() - $settings['session_adjust'];
- $db->query("INSERT INTO tech_timelog (techid, activity, stamp) VALUES ('$techid', 'Logged out -- session expired', '$time')");
- $db->query("DELETE FROM tech_session WHERE sessionid = '$sessionid'");
- delete_cookies();
- return;
- }
- /*****************************************************
- function delete_session
- -----DESCRIPTION: -----------------------------------
- - deletes the session from the db
- - deletes cookies
- -----ARGUMENTS: -------------------------------------
- sessionid : the users sessionid
- -----RETURNS:----------------------------------------
- returns the full, updated session array
- *****************************************************/
- function delete_session($sessionid='') {
- global $db;
- if (!$sessionid) {
- global $session;
- $sessionid = $session[sessionid];
- }
- if (defined('USERZONE')) {
- $table = 'user_session';
- } elseif (defined('ADMINZONE')) {
- $table = 'tech_session';
- } elseif (defined('TECHZONE')) {
- $table = 'tech_session';
- }
- $db->query("DELETE FROM $table WHERE sessionid = '" . mysql_escape_string($sessionid) . "'");
- delete_cookies();
-
- return;
- }
- /*****************************************************
- function update_session
- -----DESCRIPTION: -----------------------------------
- - updates a specific session variable
- -----ARGUMENTS: -------------------------------------
- action : the session variable we are updating
- value : the new value for the session variable
- -----RETURNS:----------------------------------------
- returns the full, updated session array
- *****************************************************/
- function update_session($action, $value) {
- global $db, $session;
- // in case there is no session
- if (!is_array($session)) {
- $session = make_session($value);
- }
- if (defined('USERZONE')) {
- $table = 'user_session';
- $type = 'user';
- } else {
- $table = 'tech_session';
- $type = 'tech';
- }
- if ($action == "user") {
- if ($session[userid] != $value) {
- $db->query("UPDATE $table SET ".$type."id = '" . mysql_escape_string($value) . "' WHERE sessionid = '$session[sessionid]'");
- $session[userid] = $value;
- }
- }
- if ($action == "language") {
- if ($session[language] != $value) {
- $db->query("UPDATE $table SET language = '" . mysql_escape_string($value) . "' WHERE sessionid = '$session[sessionid]'");
- $session[language] = $value;
- }
- }
- $session[user_type] = 'user';
- return $session;
- }
- /*****************************************************
- function prune_sessions
- ----- DESCRIPTION: -----------------------------------
- - Expire old sessions
- ----- ARGUMENTS: -------------------------------------
- - None
- ----- RETURNS:----------------------------------------
- - Nothing
- *****************************************************/
- function prune_sessions () {
- // We only actually do this on a one-in-ten chance, because it's pointless
- // to trim down the DB on every page load, but it needs to be done fairly
- // often.
- if (!rand(0,9)) {
- global $db, $settings;
- if ($settings['cookie_lifespan'] > $settings['session_length']) {
- $time = mktime() - $settings['cookie_lifespan'];
- } else {
- $time = mktime() - $settings['session_length'];
- }
- // Expire user sessions
- $db->query("DELETE FROM user_session WHERE lastactivity <= '$time'");
- // Fetch tech sessions
- $db->query("SELECT sessionid, techid FROM tech_session WHERE lastactivity <= '$time'");
- while ($res = $db->row_array()) {
- logout_tech_session($res['sessionid'], $res['techid']);
- }
- }
- }
- /*****************************************************
- function validate_session
- ----- DESCRIPTION: -----------------------------------
- - checks if a session is still valid
- ----- ARGUMENTS: -------------------------------------
- sessionid : the users sessionid
- userid (opt) : [optional] userid
- ----- RETURNS:----------------------------------------
- null if the session is invalud
- the full session array if the session is valid
- *****************************************************/
- function validate_session($sessionid='', $userid='') {
- global $db, $settings, $_REQUEST, $_COOKIE, $_POST, $_GET;
- // cookies / tables based on where we are
- if (defined('USERZONE')) {
- $table = 'user';
- $session_table = 'user_session';
- } elseif (defined('ADMINZONE')) {
- $table = 'admin';
- $session_table = 'tech_session';
- } elseif (defined('TECHZONE')) {
- $table = 'tech';
- $session_table = 'tech_session';
- }
- /* SESSION ID SOURCE PREFERENCE:
- Session ID is always taken from the first of the sources in this list
- (checked in listed order), ignoring others if present.
- 1) Sessionid sent in function definition
- 2) Posted session value (a POST method, i.e. submitted form)
- 3) URL Variable (GET method, as in file.php?s=sessionidstring)
- 4) Cookie (client-side cookie data) */
- if (!$sessionid) {
- if ($_POST['s']) {
- $sessionid = $_POST['s'];
- } elseif ($_GET['s']) {
- $sessionid = $_GET['s'];
- } elseif ($_COOKIE['dp_' . $table. '_sessionid']) {
- $sessionid = $_COOKIE['dp_' . $table . '_sessionid'];
- }
- }
- // Check we have a session
- if (strlen($sessionid) != 32) {
- return null;
- }
- // different time lengths for validation because sessions are less secure than cookies
- if ($_COOKIE[dp_sessionid] OR $_COOKIE['dp_' . $table . 'userid'] OR $_COOKIE['dp_' . $table . '_password']) {
- $time = mktime() - $settings[cookie_lifespan];
- } else {
- $time = mktime() - $settings[session_length];
- }
- // validate session
- // note we check the HTTP_USER_AGENT as well to provide some extra security with url sessions
-
- $session = $db->query_return("
- SELECT * FROM $session_table
- WHERE sessionid = '" . mysql_escape_string($sessionid) . "'
- AND lastactivity > '$time'
- AND useragent = '" . mysql_escape_string($_SERVER['HTTP_USER_AGENT']) . "'
- ");
- // failed validation
- if (!$db->num_rows()) {
- return null;
- }
- // update last activity and do activity log
- if ($location = find_location($session)) {
- if (!stristr($_SERVER['PHP_SELF'], '/tech/home/footer')) {
-
- $db->query("
- UPDATE $session_table SET
- lastactivity = '" . mktime() . "',
- location = '" . mysql_escape_string($location) . "'
- WHERE sessionid = '$sessionid'
- ");
- // If a technician/admin update, also log the activity.
- if (defined('ADMINZONE') OR defined('TECHZONE')) {
- $db->query("
- INSERT INTO tech_timelog
- (techid, activity, stamp)
- VALUES ('$session[techid]', '" . mysql_escape_string($location) . "', '" . time() . "')
- ");
- }
- }
- }
- if (stristr($_SERVER['PHP_SELF'], 'autoload.php')) {
- $db->query("UPDATE $session_table SET lastactivity = '" . mktime() . "' WHERE sessionid = '$sessionid'");
- }
- return $session;
- }
- /*****************************************************
- function make_session
- ----- DESCRIPTION: -----------------------------------
- - creates a session, deleting the given user's other
- sessions (if any)
- ----- ARGUMENTS: -------------------------------------
- userid : the userid
- language (opt) : language choice
- ----- RETURNS:----------------------------------------
- the full session array
- *****************************************************/
- function make_session($userid='', $language='') {
- global $db;
- if (defined('USERZONE')) {
- $table = 'user_session';
- $type = 'user';
- } else {
- $table = 'tech_session';
- $type = 'tech';
- }
- $time = mktime();
- $sessionid = md5(uniqid(rand(),1));
- if (defined('TECHZONE')) {
- $tech = 1;
- } elseif (defined('ADMINZONE')) {
- $tech = 0;
- }
- $db->query("INSERT INTO $table SET
- sessionid = '" . mysql_escape_string($sessionid) . "',
- lastactivity = '$time',
- location = 'Logging in',
- useragent = '" . mysql_escape_string($_SERVER['HTTP_USER_AGENT']) . "',
- ".$type."id = '" . mysql_escape_string($userid) . "'"
- . iff($type == 'tech', ", techzone = '$tech'")
- );
- // need to delete any other sessions set for this user
- if ($userid) {
- $db->query("
- DELETE FROM $table
- WHERE ".$type."id = '" . mysql_escape_string($userid) . "'
- AND sessionid != '" . mysql_escape_string($sessionid) . "'"
- . iff($type == 'tech', "AND techzone = '$tech'")
- );
- }
- $location = find_location($session);
- return array(
- 'user_type' => $type,
- 'sessionid' => $sessionid,
- 'language' => $language,
- 'lastactivity' => $time,
- 'location' => $location,
- 'userid' => $userid
- );
- }
- /*****************************************************
- function find_location
- ----- DESCRIPTION: -----------------------------------
- - if tech/admin we find where we are; pass in
- $session array
- ----- RETURNS:----------------------------------------
- the location
- *****************************************************/
- function find_location($session) {
- global $db;
- if ($session[user_type] == 'tech') {
- if (stristr($_SERVER['PHP_SELF'], '/admin/backup.php')) {
- $location = "Admin::Backup";
- } elseif (stristr($_SERVER['PHP_SELF'], '/admin/ban.php')) {
- switch ($_REQUEST['do']) {
- case 'update_email':
- $location = 'Admin::Bans::Adding/Editing E-mail';
- break;
- case 'update_ip':
- $location = 'Admin::Bans::Adding/Editing IP Address';
- break;
- case 'email':
- $location = 'Admin::Bans::Add E-mail Form';
- break;
- case 'ip':
- $location = 'Admin::Bans::Add/Edit IP Form';
- break;
- case 'ip':
- $location = 'Admin::Bans::Add/Edit IP Form';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], '/admin/category.php')) {
- switch ($_REQUEST['do']) {
- case 'settings':
- $location = 'Admin::Categories::View Category Settings';
- break;
- case 'cat_orders':
- $location = 'Admin::Categories::Updating Category Ordering';
- break;
- case 'delete':
- $location = 'Admin::Categories::Delete Category Form';
- break;
- case 'delete2':
- $location = 'Admin::Categories::Deleting Category';
- break;
- case 'add':
- $location = 'Admin::Categories::Add Category Form';
- break;
- case 'edit':
- $location = 'Admin::Categories::Edit Category Form';
- break;
- case 'add2':
- $location = 'Admin::Categories::Adding Category';
- break;
- case 'edit2':
- $location = 'Admin::Categories::Editing Category';
- break;
- case 'edit2':
- $location = 'Admin::Categories::Viewing Categories';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], '/admin/chat.php')) {
- switch ($_REQUEST['do']) {
- case 'update':
- $location = 'Admin::Chat::Update Settings Form';
- break;
- case 'list':
- $location = 'Admin::Chat::Viewing Chat Room Settings';
- break;
- case 'add':
- $location = 'Admin::Chat::Add Chat Room Form';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], '/admin/cron.php')) {
- switch ($_REQUEST['do']) {
- case 'list':
- case 'view':
- $location = 'Admin::Cron::Viewing Scheduled Tasks';
- break;
- case 'update':
- case 'update2':
- $location = 'Admin::Cron::Updating Task(s)';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/diagnose.php')) {
- switch ($_REQUEST['do']) {
- case 'mysql_vars':
- $location = 'Admin::Sanity Check::MySQL Vars';
- break;
- case 'mysql_status':
- $location = 'Admin::Sanity Check::MySQL Status';
- break;
- case 'table_status':
- $location = 'Admin::Sanity Check::Table Status';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/email.php')) {
- switch ($_REQUEST['do']) {
- case 'update':
- $location = 'Admin::E-mail Gateway::Updating Settings';
- break;
- case 'list':
- case 'view':
- $location = 'Admin::E-mail Gateway::Listing Gateway Accounts';
- break;
- case 'config':
- $location = 'Admin::E-mail Gateway::Viewing Settings';
- break;
- case 'add2':
- $location = 'Admin::E-mail Gateway::Adding Gateway Account';
- break;
- case 'delete':
- $location = 'Admin::E-mail Gateway::Deleting Gateway Account';
- break;
- case 'add':
- case 'edit':
- $location = 'Admin::E-mail Gateway::Add/Edit Gateway Account Form';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/emailtemplates.php')) {
- switch ($_REQUEST['do']) {
- case 'view':
- $location = 'Admin::E-mail Gateway::Viewing Templates';
- break;
- case 'edit2':
- $location = 'Admin::E-mail Gateway::Editing Template';
- break;
- case 'newcustom2':
- $location = 'Admin::E-mail Gateway::Adding Custom Template';
- break;
- case 'editcustom':
- $location = 'Admin::E-mail Gateway::Edit Custom Template Form';
- break;
- case 'newcustom':
- $location = 'Admin::E-mail Gateway::New Custom Template Form';
- break;
- case 'delete':
- $location = 'Admin::E-mail Gateway::Deleting Custom Template';
- break;
- case 'delete_all':
- $location = 'Admin::E-mail Gateway::Deleting ALL Custom Templates';
- break;
- case 'restore':
- $location = 'Admin::E-mail Gateway::Restoring Custom Template from Backup';
- break;
- case 'preg_replace':
- $location = 'Admin::E-mail Gateway::Search/Replace Form';
- break;
- case 'xhtml':
- $location = 'Admin::E-mail Gateway::XHTML Redirection';
- break;
- case 'xhtml2':
- $location = 'Admin::E-mail Gateway::XHTML Update';
- break;
- case 'preg_replace2':
- $location = 'Admin::E-mail Gateway::Search/Replace Execution';
- break;
- case 'find':
- $location = 'Admin::E-mail Gateway::Search Form';
- break;
- case 'find2':
- $location = 'Admin::E-mail Gateway::Search Execution';
- break;
- case 'translate2':
- $location = 'Admin::E-mail Gateway::Translation Execution';
- break;
- case 'translate':
- $location = 'Admin::E-mail Gateway::Translation Form';
- break;
- case 'export':
- $location = 'Admin::E-mail Gateway::Exporting Template';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/errors.php')) {
- switch ($_REQUEST['do']) {
- case '':
- $location = 'Admin::E-mail Gateway::Viewing Errors';
- break;
- case 'source':
- $location = 'Admin::E-mail Gateway::Viewing Error Details';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/escalate.php')) {
- switch ($_REQUEST['do']) {
- case 'delete':
- $location = 'Admin::Escalations::Deleting Escalation';
- break;
- case 'new2':
- $location = 'Admin::Escalations::Adding New Escalation';
- break;
- case 'edit2':
- $location = 'Admin::Escalations::Editing Escalation';
- break;
- case 'new':
- case 'edit':
- $location = 'Admin::Escalations::Add/Edit Escalation Form';
- break;
- case 'view':
- $location = 'Admin::Escalations::Viewing Escalations';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/filters.php')) {
- switch ($_REQUEST['do']) {
- default:
- $location = 'Admin::Filters::Other';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/help.php')) {
- $location = 'Admin::Help::Viewing Help Topic';
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/index.php')) {
- $location = 'Admin::Main Page';
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/languages.php')) {
- switch ($_REQUEST['do']) {
- case 'update':
- $location = 'Admin::Languages::Updating Language';
- break;
- case 'add':
- $location = 'Admin::Languages::Add Language Form';
- break;
- case 'new2':
- $location = 'Admin::Languages::Adding Language';
- break;
- case 'delete':
- $location = 'Admin::Languages::Deleting Language';
- break;
- case 'view':
- $location = 'Admin::Languages::Viewing Languages';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/payment.php')) {
- switch ($_REQUEST['do']) {
- default:
- $location = 'Admin::Payments';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/priority.php')) {
- switch ($_REQUEST['do']) {
- case 'settings':
- $location = 'Admin::Priorities::Viewing Priority Settings';
- break;
- case 'pri_orders':
- $location = 'Admin::Priorities::Re-Ordering Priorities';
- break;
- case 'delete':
- $location = 'Admin::Priorities::Delete Priority Form';
- break;
- case 'delete2':
- $location = 'Admin::Priorities::Deleting Priority';
- break;
- case 'add':
- case 'edit':
- $location = 'Admin::Priorities::Add/Edit Priority Form';
- break;
- case 'edit2':
- $location = 'Admin::Priorities::Editing Priority';
- break;
- case 'add2':
- $location = 'Admin::Priorities::Adding Priority';
- break;
- case 'view':
- $location = 'Admin::Priorities::Viewing Priorities';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/replace.php')) {
- switch ($_REQUEST['do']) {
- case 'add':
- $location = 'Admin::Replacement Variables::Add Form';
- break;
- case 'add2':
- $location = 'Admin::Replacement Variables::Adding';
- break;
- case 'delete':
- $location = 'Admin::Replacement Variables::Deleting';
- break;
- case 'view':
- $location = 'Admin::Replacement Variables::Viewing';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/reports.php')) {
- switch ($_REQUEST['do']) {
- case 'viewreports':
- $location = 'Admin::Reports::Listing Reports';
- break;
- case 'deletereports':
- $location = 'Admin::Reports::Deleting Report';
- break;
- case 'viewstats':
- $location = 'Admin::Reports::Listing Statistics';
- break;
- case 'editreport':
- case 'newreport':
- $location = 'Admin::Reports::Add/Edit Report Form';
- break;
- case 'newreport2':
- case 'editreport2':
- $location = 'Admin::Reports::Adding/Editing Report';
- break;
- case 'newstat2':
- case 'editstat2':
- $location = 'Admin::Reports::Adding/Editing Statistic';
- break;
- case 'editstat':
- case 'newstat':
- $location = 'Admin::Reports::Add/Edit Statistic';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/runreport.php')) {
- $location = 'Admin::Reports::Running Report';
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/settings.php')) {
- switch ($_REQUEST['do']) {
- case 'update':
- $location = 'Admin::Settings::Updating Setting';
- break;
- case 'list':
- $location = 'Admin::Settings::Listing Settings';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/spam.php')) {
- switch ($_REQUEST['do']) {
- case 'delete2':
- $location = 'Admin::Spam::Deleting Spam Entry';
- break;
- case 'edit':
- case 'add':
- $location = 'Admin::Spam::Add/Edit Spam Entry';
- break;
- case 'edit2':
- $location = 'Admin::Spam::Editing Spam Entry';
- break;
- case 'add2':
- $location = 'Admin::Spam::Adding Spam Entry';
- break;
- case 'view':
- $location = 'Admin::Spam::Viewing Spam Entries';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/stats.php')) {
- $location = 'Admin::Stats::Viewing Ticket Statistics';
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/online.php')) {
- $location = 'Admin::Stats::Viewing Technician Activity Log';
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/tech.php')) {
- switch ($_REQUEST['do']) {
- case 'email':
- $location = 'Admin::Spam::E-mail Techs Form';
- break;
- case 'email2':
- $location = 'Admin::Spam::E-mailing Techs';
- break;
- case 'add':
- $location = 'Admin::Spam::Add Tech Form';
- break;
- case 'submit':
- case 'update':
- $location = 'Admin::Spam::Adding/Editing Tech';
- break;
- case 'add2':
- case 'edit':
- case 'redo':
- $location = 'Admin::Spam::Add/Edit Tech Form';
- break;
- case 'delete':
- $location = 'Admin::Spam::Deleting Tech';
- break;
- case 'disable':
- $location = 'Admin::Spam::Disabling Tech';
- break;
- case 'enable':
- $location = 'Admin::Spam::Enabling Tech';
- break;
- case 'view':
- $location = 'Admin::Spam::Viewing Tech';
- break;
- case 'cats':
- $location = 'Admin::Spam::Viewing Technician Category Assignments';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/techemail.php')) {
- switch ($_REQUEST['do']) {
- case 'settings':
- $location = 'Admin::Technician E-mail::Updating Settings';
- break;
- default:
- $location = 'Admin::Technician E-mail::Viewing Settings';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/templates.php')) {
- switch ($_REQUEST['do']) {
- case 'view':
- $location = 'Admin::Templates::Viewing Templates';
- break;
- case 'editcustom2':
- $location = 'Admin::Templates::Editing Custom Template';
- break;
- case 'edit2':
- $location = 'Admin::Templates::Editing Template';
- break;
- case 'add':
- $location = 'Admin::Templates::Add Template Form';
- break;
- case 'add2':
- $location = 'Admin::Templates::Adding Template';
- break;
- case 'edit':
- $location = 'Admin::Templates::Edit Template Form';
- break;
- case 'editcustom':
- $location = 'Admin::Templates::Edit Custom Template Form';
- break;
- case 'delete':
- $location = 'Admin::Templates::Deleting Custom Template';
- break;
- case 'restore':
- $location = 'Admin::Templates::Restoring Template From Backup';
- break;
- case 'preg_replace':
- $location = 'Admin::Templates::Search/Replace Template Form';
- break;
- case 'xhtml':
- $location = 'Admin::Templates::XHTML Redirect';
- break;
- case 'xhtml2':
- $location = 'Admin::Templates::XHTML Update';
- break;
- case 'preg_replace2':
- $location = 'Admin::Templates::Search/Replace Execution';
- break;
- case 'find':
- $location = 'Admin::Templates::Search Form';
- break;
- case 'find2':
- $location = 'Admin::Templates::Search Execution';
- break;
- case 'export':
- $location = 'Admin::Templates::Export Form';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/ticket_fields.php')) {
- switch ($_REQUEST['do']) {
- case 'new3':
- case 'update':
- $location = 'Admin::Ticket Fields::Adding/Editing Field';
- break;
- case 'edit':
- case 'new2':
- $location = 'Admin::Ticket Fields::Add/Edit Field Form';
- break;
- case 'add':
- $location = 'Admin::Ticket Fields::Add Field Form';
- break;
- case 'delete':
- $location = 'Admin::Ticket Fields::Deleting Field';
- break;
- case 'view':
- $location = 'Admin::Ticket Fields::Viewing Fields';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/user_fields.php')) {
- switch ($_REQUEST['do']) {
- case 'new3':
- case 'update':
- $location = 'Admin::User Fields::Adding/Editing Field';
- break;
- case 'edit':
- case 'new2':
- $location = 'Admin::User Fields::Add/Edit Field Form';
- break;
- case 'add':
- $location = 'Admin::User Fields::Add Field Form';
- break;
- case 'delete':
- $location = 'Admin::User Fields::Deleting Field';
- break;
- case 'view':
- $location = 'Admin::User Fields::Viewing Fields';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'admin/user_fields.php')) {
- switch ($_REQUEST['do']) {
- case 'update':
- $location = 'Admin::Words::Updating Word';
- break;
- case 'view':
- $location = 'Admin::Words::Viewing Words';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/calendar/edit.php')) {
- $location = "Tech::Calendar::Editing Event <A HREF="../tech/calendar/viewtask.php?id=$_REQUEST[id]">$_REQUEST[id]</A>";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/calendar/index.php')) {
- $location = "Tech::Calendar::Viewing Calendar";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/calendar/new.php')) {
- $location = "Tech::Calendar::Creating New Event";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/calendar/search.php')) {
- $location = "Tech::Calendar::Searching Events";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/calendar/viewtask.php')) {
- $location = "Tech::Calendar::Viewing Event <A HREF="../tech/calendar/viewtask.php?id=$_REQUEST[id]">$_REQUEST[id]</A>";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/email/index.php')) {
- switch ($_REQUEST['do']) {
- case 'send':
- $location = 'Tech::E-mails::Send E-mail Form';
- break;
- case 'send2':
- $location = 'Tech::E-mails::Sending E-mail';
- break;
- case 'mark_read':
- case 'mark_unread':
- $location = 'Tech::E-mails::Setting Read/Unread State';
- break;
- case 'delete':
- case 'delete2':
- $location = 'Tech::E-mails::Deleting E-Mail';
- break;
- case 'view':
- $location = "Tech::E-mails::Viewing E-Mail <A HREF="../tech/email/index.php?do=view&id=$_REQUEST[id]">$_REQUEST[id]</A>";
- break;
- case 'reply':
- $location = 'Tech::E-mails::Composing Response';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/faq/actions.php')) {
- $location = "Tech::FAQ::Updating/Maintaining Entry";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/faq/add.php')) {
- $location = "Tech::FAQ::Adding Category";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/faq/category.php')) {
- $location = "Tech::FAQ::Maintaining Categories";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/faq/category.php')) {
- $location = "Tech::FAQ::Maintaining Categories";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/faq/index.php')) {
- switch ($_REQUEST['do']) {
- case 'pdf':
- $location = 'Tech::FAQ::Generating PDF';
- break;
- case 'edit_categories':
- $location = 'Tech::FAQ::Editing Categories';
- break;
- case 'edit_articles':
- $location = 'Tech::FAQ::Editing Article(s)';
- break;
- case 'navigate':
- $location = 'Tech::FAQ::Viewing Categories';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/faq/view.php')) {
- $location = "Tech::FAQ::Viewing/Maintaining Articles";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/home/index.php')) {
- $location = "Tech::Home Page";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/home/reports.php')) {
- $location = "Tech::Viewing Own Stats";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/news/technews.php')) {
- switch ($_REQUEST['do']) {
- case 'new2':
- case 'new':
- $location = 'Tech::News::Adding Tech News Item';
- break;
- case 'edit2':
- case 'edit':
- $location = 'Tech::News::Editing Tech News Item';
- break;
- case 'delete2':
- case 'delete':
- $location = 'Tech::News::Deleting Tech News Item';
- break;
- case 'list':
- $location = 'Tech::News::Viewing Tech News Items';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/news/usernews.php')) {
- switch ($_REQUEST['do']) {
- case 'new2':
- case 'new':
- $location = 'Tech::News::Adding Tech News Item';
- break;
- case 'edit2':
- case 'edit':
- $location = 'Tech::News::Editing Tech News Item';
- break;
- case 'delete2':
- case 'delete':
- $location = 'Tech::News::Deleting Tech News Item';
- break;
- case 'list':
- $location = 'Tech::News::Viewing Tech News Items';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/settings')) {
- $location = 'Tech::Personal Settings';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/teamwork/index.php')) {
- $location = 'Tech::Private Messaging::Viewing Messages';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/teamwork/pms.php')) {
- switch ($_REQUEST['do']) {
- case 'actions':
- $location = 'Tech::Private Messaging::Updating Messages';
- break;
- case 'read':
- $location = 'Tech::Private Messaging::Reading Message';
- break;
- case 'add':
- case 'send':
- $location = 'Tech::Private Messaging::Sending Message';
- break;
- case 'view':
- $location = 'Tech::Private Messaging::Viewing Message List';
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/tickets/addattachments.php')) {
- $location = 'Tech::Tickets::Adding Attachment';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/tickets/index.php')) {
- $location = 'Tech::Tickets::Index Page';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/tickets/load_results.php')) {
- $location = 'Tech::Tickets::Viewing Search Results';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/tickets/new.php')) {
- $location = 'Tech::Tickets::Creating New Ticket';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/tickets/new.php')) {
- $location = 'Tech::Tickets::Creating New Ticket';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/tickets/quick_reply.php')) {
- $location = 'Tech::Tickets::Managing Quick Replies';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/tickets/ticketactions.php')) {
- switch ($_REQUEST['do']) {
- case 'process':
- $location = 'Tech::Tickets::Mass-Updating Tickets';
- break;
- case 'store':
- case 'unstore':
- $location = "Tech::Tickets::Updating Saved Tickets List (Ticket #$_REQUEST[id])";
- break;
- case 'lock':
- case 'unlock':
- $location = "Tech::Tickets::Updating Ticket Lock Status (Ticket #$_REQUEST[id])";
- break;
- case 'awaiting_tech':
- case 'awaiting_user':
- $location = "Tech::Tickets::Updating Ticket Awaiting Response Status (Ticket #$_REQUEST[id])";
- break;
- case 'remove_ownership':
- $location = "Tech::Tickets::Removing Ownership (Ticket #$_REQUEST[id])";
- break;
- case 'close':
- $location = "Tech::Tickets::Closing (Ticket #$_REQUEST[id])";
- break;
- case 'open':
- $location = "Tech::Tickets::Re-opening (Ticket #$_REQUEST[id])";
- break;
- case 'delete':
- $location = "Tech::Tickets::Deleting (Ticket #$_REQUEST[id])";
- break;
- case 'merge':
- $location = 'Tech::Tickets::Merging ticket #' . htmlspecialchars($_REQUEST['fromticket']) . 'into ticket #' . htmlspecialchars($_REQUEST['toticket']) .
- '(Ticket #' . htmlspecialchars($_REQUEST['ticket_stay']['id']) . ')';
- break;
- case 'delete':
- $location = "Tech::Tickets::Deleting (Ticket #$_REQUEST[id])";
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/ticket/ticketedit.php')) {
- $location = "Tech::Tickets::Editing Ticket Metadata (ticket #$_REQUEST[id])";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/ticket/ticketreply.php')) {
- $location = "Tech::Tickets::Replying (or Noting) Ticket (ticket #$_REQUEST[id])";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/tickets/ticketsearch.php')) {
- $location = 'Tech::Tickets::Searching Tickets';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/tickets/ticketview.php')) {
- $location = "Tech::Tickets::Viewing Ticket (ticket #<A HREF="../tech/tickets/ticketview.php?id=$_REQUEST[id]">$_REQUEST[id]</A>)";
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/users/actions.php')) {
- switch ($_REQUEST['do']) {
- case 'update_fields':
- $location = "Tech::Users::Updating User $_REQUEST[id]";
- break;
- case 'delete':
- $location = "Tech::Users::Deleting User $_REQUEST[id]";
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/users/index.php')) {
- switch ($_REQUEST['do']) {
- case 'approve':
- $location = "Tech::Users::Approving User $_REQUEST[id]";
- break;
- case 'delete':
- $location = "Tech::Users::Deleting User $_REQUEST[id]";
- break;
- default:
- $location = "Tech::Users::Viewing Unapproved Users";
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/users/new.php')) {
- switch ($_REQUEST['do']) {
- case 'new2':
- case 'new':
- $location = "Tech::Users::Adding New User";
- break;
- case 'massadd2':
- case 'massadd':
- $location = "Tech::Users::Mass Adding New Users";
- break;
- case 'edit':
- $location = "Editing User $_REQUEST[id]";
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/users/notes.php')) {
- switch ($_REQUEST['do']) {
- case 'add':
- case 'add2':
- $location = "Tech::Users::Adding New Note to User $user[id]";
- break;
- case 'edit2':
- case 'edit':
- $location = "Tech::Users::Editing Note $_REQUEST[id]";
- break;
- case 'delete':
- $location = "Tech::Users::Deleting Note $_REQUEST[id]";
- break;
- }
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/users/online.php')) {
- $location = 'Tech::Tickets::Viewing Online Users';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/users/quickfind.php')) {
- $location = 'Tech::Tickets::Searching Users';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/users/search.php')) {
- $location = 'Tech::Tickets::Searching Users';
- } elseif (stristr($_SERVER['PHP_SELF'], 'tech/users/view.php')) {
- $location = "Tech::Tickets::Viewing User $_REQUEST[id]";
- } else {
- $location = substr($_SERVER['REQUEST_URI'], 255);
- }
- } else {
-
- $session[user_type] = 'user';
- switch (basename($_SERVER['PHP_SELF'], '.php')) {
- case 'index':
- $location = 'Home page';
- break;
- case 'ticketlist':
- $location = 'Viewing tickets list';
- break;
- case 'view':
- if ($_REQUEST['ticketref']) {
- $data = $_REQUEST['ticketref'];
- } else {
- $data = $_REQUEST['id'];
- }
- $location = "Viewing ticket #$data";
- break;
- case 'newticket':
- $location = 'Creating a new ticket';
- break;
- case 'faq':
- switch ($_REQUEST['do']) {
- case 'search':
- $location = "Viewing FAQ (searching)";
- break;
- case 'subscriptions':
- $location = "Viewing FAQ (subscriptions)";
- break;
- case 'new':
- $location = "Drafting new FAQ article";
- break;
- default:
- $location = "Viewing FAQ";
- break;
- }
- break;
- case 'profile':
- $location = 'Viewing profile/settings';
- break;
- default:
- $location = 'Logged in';
- break;
- }
- }
- return $location;
- }