Code

Created trunk inside of 2.6-lhm
[gosa.git] / trunk / gosa-core / html / logout.php
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::global_is_set('ui')){
33   
34   /* Get config & ui informations */
35   $ui= session::global_get("ui");
36   
37   /* config used for del_user_locks & some lines below to detect the language */  
38   $config= session::global_get("config");
40   /* Remove all locks of this user */
41   del_user_locks($ui->dn);
42   
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("language") == ""){
49   $lang= get_browser_language();
50 } else {
51   $lang= $config->get_cfg_value("language");
52 }
54 putenv("LANGUAGE=");
55 putenv("LANG=$lang");
56 setlocale(LC_ALL, $lang);
57 $GLOBALS['t_language']= $lang;
58 $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/';
60 /* Set the text domain as 'messages' */
61 $domain = 'messages';
62 bindtextdomain($domain, LOCALE_DIR);
63 textdomain($domain);
65 /* Create smarty & Set template compile directory */
66 $smarty= new smarty();
67 if (isset($config)){
68         $smarty->compile_dir= $config->get_cfg_value("compile", '/var/spool/gosa/');
69 } else {
70         $smarty->compile_dir= '/var/spool/gosa/';
71 }
72     
73 /* If GET request is posted, the logout was forced by pressing the link */
74 if (isset($_GET['request'])){
75   
76   /* destroy old session */
77   session::destroy ();
78   
79   /* If we're not using htaccess authentication, just redirect... */
80   if (isset($config) && $config->get_cfg_value("htaccessAuthentication") == "true"){
82     /* Else notice that the user has to close the browser... */
83     $smarty->assign("iePngWorkaround", FALSE);
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 
93   
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>