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 if(session::is_set('ui')){
31 /* Get config & ui informations */
32 $ui= session::get("ui");
34 /* config used for del_user_locks & some lines below to detect the language */
35 $config= session::get("config");
37 /* Remove all locks of this user */
38 del_user_locks($ui->dn);
40 /* Write something to log */
41 new log("security","logout","",array(),"User \"".$ui->username."\" logged out") ;
42 }
44 /* Language setup */
45 if ((!isset($config))||(empty($config->data['MAIN']['LANG']))){
46 $lang= get_browser_language();
47 } else {
48 $lang= $config->data['MAIN']['LANG'];
49 }
51 $lang.=".UTF-8";
52 putenv("LANGUAGE=");
53 putenv("LANG=$lang");
54 setlocale(LC_ALL, $lang);
55 $GLOBALS['t_language']= $lang;
56 $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/';
58 /* Set the text domain as 'messages' */
59 $domain = 'messages';
60 bindtextdomain($domain, LOCALE_DIR);
61 textdomain($domain);
63 /* Create smarty & Set template compile directory */
64 $smarty= new smarty();
65 if (isset ($config->data['MAIN']['COMPILE'])){
66 $smarty->compile_dir= $config->data['MAIN']['COMPILE'];
67 } else {
68 $smarty->compile_dir= '/var/spool/gosa/';
69 }
72 /* If GET request is posted, the logout was forced by pressing the link */
73 if (isset($_GET['request'])){
75 /* destroy old session */
76 session::destroy ();
78 /* If we're not using htaccess authentication, just redirect... */
79 if (isset($config->data['MAIN']['HTACCESS_AUTH']) && preg_match('/^(true|yes)$/i', $config->data['MAIN']['HTACCESS_AUTH'])){
81 /* Else notice that the user has to close the browser... */
82 $smarty->display (get_template_path('headers.tpl'));
83 $smarty->display (get_template_path('logout-close.tpl'));
84 exit;
85 }
87 header ("Location: index.php");
88 exit();
90 }else{ // The logout wasn't forced, so the session is invalid
92 $smarty->display (get_template_path('headers.tpl'));
93 $smarty->display (get_template_path('logout.tpl'));
94 exit;
95 }
96 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
97 ?>
98 </html>