2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 02/28/2009 *
4 * =================== Last change: 02/28/2009 *
6 * -------------------------------------------------------------------- *
7 * File : session-functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Session-relevant functions *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Sitzungsrelevante Funktionen *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
45 // Unset/set session variables
46 function setSession ($var, $value) {
47 // Abort in CSS mode here
48 if (getOutputMode() == 1) return true;
50 // Trim value and session variable
51 $var = trim(secureString($var)); $value = trim($value);
53 // Is the session variable set?
54 if (('' . $value . '' == '') && (isSessionVariableSet($var))) {
56 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UNSET:' . $var . '=' . getSession($var));
57 unset($GLOBALS['_SESSION'][$var]);
58 if (phpversion() >= '5.3.1') {
59 // session_unregister() is deprecated as of 5.3.1
62 // PHP version < 5.3.1
63 return session_unregister($var);
65 } elseif (('' . $value . '' != '') && (!isSessionVariableSet($var))) {
67 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SET:' . $var . '=' . $value);
68 $GLOBALS['_SESSION'][$var] = $value;
69 if (phpversion() >= '5.3.1') {
70 // session_unregister() is deprecated as of 5.3.1
73 // PHP version < 5.3.1
74 return session_register($var);
76 } elseif (!empty($value)) {
78 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UPDATE:' . $var . '=' . $value);
79 $GLOBALS['_SESSION'][$var] = $value;
83 // Ignored (but valid)
84 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'IGNORED:' . $var . '=' . $value);
88 // Check wether a session variable is set
89 function isSessionVariableSet ($var) {
90 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "var={$var}");
91 return (isset($GLOBALS['_SESSION'][$var]));
94 // Returns wether the value of the session variable or NULL if not set
95 function getSession ($var) {
96 // Default is not found! ;-)
99 // Is the variable there?
100 if (isSessionVariableSet($var)) {
101 // Then get it secured!
102 $value = SQL_ESCAPE($GLOBALS['_SESSION'][$var]);
106 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $var . '=' . $value);
110 // Destroy user session
111 function destroyMemberSession () {
115 // Remove all user data from session
116 return ((setSession('userid', '')) && (setSession('u_hash', '')));
119 // Destroys the admin session
120 function destroyAdminSession ($destroy = true) {
121 // Kill maybe existing session variables including array elements
122 setSession('admin_login', '');
123 setSession('admin_md5' , '');
124 setSession('admin_last' , '');
126 // Destroy session and return status
128 return session_destroy();
131 // All fine if we shall not really destroy the session