1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2003 Cajus Pollmeier
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
21 /* Basic setup, remove eventually registered sessions */
22 require_once ("../include/php_setup.inc");
23 require_once ("functions.inc");
24 header("Content-type: text/html; charset=UTF-8");
26 /* try to start session, so we can remove userlocks,
27 if the old session is still available */
28 @session::start();
29 session::set('errorsAlreadyPosted',array());
30 if(session::is_set('ui')){
32 /* Get config & ui informations */
33 $ui= session::get("ui");
35 /* config used for del_user_locks & some lines below to detect the language */
36 $config= session::get("config");
38 /* Remove all locks of this user */
39 del_user_locks($ui->dn);
41 /* Write something to log */
42 new log("security","logout","",array(),"User \"".$ui->username."\" logged out") ;
43 }
45 /* Language setup */
46 if ((!isset($config))||(empty($config->data['MAIN']['LANG']))){
47 $lang= get_browser_language();
48 } else {
49 $lang= $config->data['MAIN']['LANG'];
50 }
52 $lang.=".UTF-8";
53 putenv("LANGUAGE=");
54 putenv("LANG=$lang");
55 setlocale(LC_ALL, $lang);
56 $GLOBALS['t_language']= $lang;
57 $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/';
59 /* Set the text domain as 'messages' */
60 $domain = 'messages';
61 bindtextdomain($domain, LOCALE_DIR);
62 textdomain($domain);
64 /* Create smarty & Set template compile directory */
65 $smarty= new smarty();
66 if (isset ($config->data['MAIN']['COMPILE'])){
67 $smarty->compile_dir= $config->data['MAIN']['COMPILE'];
68 } else {
69 $smarty->compile_dir= '/var/spool/gosa/';
70 }
73 /* If GET request is posted, the logout was forced by pressing the link */
74 if (isset($_GET['request'])){
76 /* destroy old session */
77 session::destroy ();
79 /* If we're not using htaccess authentication, just redirect... */
80 if (isset($config->data['MAIN']['HTACCESS_AUTH']) && preg_match('/^(true|yes)$/i', $config->data['MAIN']['HTACCESS_AUTH'])){
82 /* Else notice that the user has to close the browser... */
83 $smarty->display (get_template_path('headers.tpl'));
84 $smarty->display (get_template_path('logout-close.tpl'));
85 exit;
86 }
88 header ("Location: index.php");
89 exit();
91 }else{ // The logout wasn't forced, so the session is invalid
93 $smarty->display (get_template_path('headers.tpl'));
94 $smarty->display (get_template_path('logout.tpl'));
95 exit;
96 }
97 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
98 ?>
99 </html>