Code

Updated stats handling.
[gosa.git] / 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("core","language") == ""){
49   $lang= get_browser_language();
50 } else {
51   $lang= $config->get_cfg_value("core","language");
52 }
54 // Try to keep track of logouts, this will fail if our session has already expired. 
55 // Nothing will be logged if config isn't present anymore.
56 stats::log('global', 'global', array(),  $action = 'logout', $amount = 1, 0);
58 putenv("LANGUAGE=");
59 putenv("LANG=$lang");
60 setlocale(LC_ALL, $lang);
61 $GLOBALS['t_language']= $lang;
62 $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/';
64 /* Set the text domain as 'messages' */
65 $domain = 'messages';
66 bindtextdomain($domain, LOCALE_DIR);
67 textdomain($domain);
69 /* Create smarty & Set template compile directory */
70 $smarty= new smarty();
71 if (isset($config)){
72         $smarty->compile_dir= $config->get_cfg_value("core","templateCompileDirectory");
73 } else {
74         $smarty->compile_dir= '/var/spool/gosa/';
75 }
77 if(!is_writeable($smarty->compile_dir)){
79     header('location: index.php');
80     exit();
81 }
83 $smarty->assign ("title","GOsa");
84     
85 /* If GET request is posted, the logout was forced by pressing the link */
86 if (isset($_POST['forcedlogout']) || isset($_GET['forcedlogout'])){
87   
88   /* destroy old session */
89   session::destroy ();
90   
91   /* If we're not using htaccess authentication, just redirect... */
92   if (isset($config) && $config->get_cfg_value("core","htaccessAuthentication") == "true"){
94     /* Else notice that the user has to close the browser... */
95     $smarty->display (get_template_path('headers.tpl'));
96     $smarty->display (get_template_path('logout-close.tpl'));
97     exit;
98   }
100   header ("Location: index.php");
101   exit();
103 }else{  // The logout wasn't forced, so the session is invalid 
104   
106   $smarty->display (get_template_path('headers.tpl'));
107   $smarty->display (get_template_path('logout.tpl'));
108   exit;
110 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
111 ?>
112 </html>