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 return session_unregister($var);
59 } elseif (('' . $value . '' != '') && (!isSessionVariableSet($var))) {
61 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SET:' . $var . '=' . $value);
62 $GLOBALS['_SESSION'][$var] = $value;
63 return session_register($var);
64 } elseif (!empty($value)) {
66 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UPDATE:' . $var . '=' . $value);
67 $GLOBALS['_SESSION'][$var] = $value;
71 // Ignored (but valid)
72 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'IGNORED:' . $var . '=' . $value);
76 // Check wether a session variable is set
77 function isSessionVariableSet ($var) {
78 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "var={$var}");
79 return (isset($GLOBALS['_SESSION'][$var]));
82 // Returns wether the value of the session variable or NULL if not set
83 function getSession ($var) {
84 // Default is not found! ;-)
87 // Is the variable there?
88 if (isSessionVariableSet($var)) {
89 // Then get it secured!
90 $value = SQL_ESCAPE($GLOBALS['_SESSION'][$var]);
94 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $var . '=' . $value);
98 // Destroy user session
99 function destroyMemberSession () {
103 // Remove all user data from session
104 return ((setSession('userid', '')) && (setSession('u_hash', '')));
107 // Destroys the admin session
108 function destroyAdminSession ($destroy = true) {
109 // Kill maybe existing session variables including array elements
110 setSession('admin_login', '');
111 setSession('admin_md5' , '');
112 setSession('admin_last' , '');
114 // Destroy session and return status
116 return session_destroy();
119 // All fine if we shall not really destroy the session