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