Code

Removed option in flavor of case handling flag 'L' stronger than flag 'D'.
[gosa.git] / html / main.php
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 /* This will be removed... */
22 function raiseError($errno, $errstr, $errfile, $errline)
23 {
24   gosa_log ("PHP error: $errstr ($errfile, line $errline)");
25 }
27 //set_error_handler('raiseError');
28 /* This will be removed */
30 /* Basic setup, remove eventually registered sessions */
31 $timing= array();
32 require_once ("../include/php_setup.inc");
33 require_once ("functions.inc");
34 header("Content-type: text/html; charset=UTF-8");
36 /* Find all class files and include them */
37 get_dir_list("$BASE_DIR/plugins");
39 /* Set the text domain as 'messages' */
40 $domain = 'messages';
41 bindtextdomain($domain, "$BASE_DIR/locale");
42 textdomain($domain);
45 /* Remember everything we did after the last click */
46 session_start ();
47 if ($_SERVER["REQUEST_METHOD"] == "POST"){
48   @DEBUG (DEBUG_POST, __LINE__, __FUNCTION__, __FILE__, $_POST, "_POST");
49 }
50 @DEBUG (DEBUG_POST, __LINE__, __FUNCTION__, __FILE__, $_SESSION, "_SESSION");
52 /* Logged in? Simple security check */
53 if (!isset($_SESSION['config'])){
54   gosa_log ("main.php called without session");
55   header ("Location: index.php");
56   exit;
57
59 /* Reset errors */
60 $_SESSION['errors']= "";
62 /* Check for uniqe ip address */
63 $ui= $_SESSION["ui"];
64 if ($_SERVER['REMOTE_ADDR'] != $ui->ip){
65   gosa_log ("main.php called with session which has a changed IP address.", 3);
66   header ("Location: logout.php");
67   exit;
68 }
69 $config= $_SESSION['config'];
70 @DEBUG (DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config");
72 /* Set template compile directory */
73 if (isset ($config->data['MAIN']['COMPILE'])){
74   $smarty->compile_dir= $config->data['MAIN']['COMPILE'];
75 } else {
76   $smarty->compile_dir= '/var/spool/gosa/';
77 }
79 /* Language setup */
80 if ($config->data['MAIN']['LANG'] == ""){
81   $lang= get_browser_language();
82 } else {
83   $lang= $config->data['MAIN']['LANG'];
84 }
85 $lang.=".UTF-8";
86 putenv("LANGUAGE=");
87 putenv("LANG=$lang");
88 setlocale(LC_ALL, $lang);
89 $GLOBALS['t_language']= $lang;
90 $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/';
92 /* Set the text domain as 'messages' */
93 $domain = 'messages';
94 bindtextdomain($domain, "$BASE_DIR/locale");
95 textdomain($domain);
96 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to");
98 /* Prepare plugin list */
99 if (!isset($_SESSION['plist'])){
100   $_SESSION['plist']= new pluglist($config, $ui);
102 $plist= $_SESSION['plist'];
104 /* Check for register globals */
105 if (isset($global_check) && $config->data['MAIN']['FORCEGLOBALS'] == 'true'){
106   print_red (_("Register globals is on. GOsa will refuse to login unless this is fixed by an administrator."));
107   echo $_SESSION['errors'];
108   gosa_log ("Register globals is on. For security reasons, this should be turned off.");
109   session_destroy ();
110   exit ();
113 /* Check Plugin variable */
114 if (isset($_SESSION['plugin_dir'])){
115   $old_plugin_dir= $_SESSION['plugin_dir'];
116 } else {
117   $old_plugin_dir= "";
119 if (isset($_GET['plug'])){
120   $plug= validate($_GET['plug']);
121   $plugin_dir= $plist->get_path($plug);
122   $_SESSION['plugin_dir']= $plugin_dir;
123   if ($plugin_dir == ""){
124     gosa_log ("main.php called with invalid plug parameter \"$plug\"", 3);
125     header ("Location: logout.php");
126     exit;
127   }
128 } else {
129   /* set to welcome page as default plugin */
130   $_SESSION['plugin_dir']= "welcome";
131   $plugin_dir= "$BASE_DIR/plugins/generic/welcome";
134 /* Check if we need to delete a lock */
135 if ($old_plugin_dir != $plugin_dir){
136   if (is_file("$old_plugin_dir/main.inc")){
137     $remove_lock= true;
138     require_once ("$old_plugin_dir/main.inc");
139   }
141 $remove_lock= false;
143 /* Check for sizelimits */
144 eval_sizelimit();
146 /* Check for memory */
147 if (function_exists("memory_get_usage")){
148   if (memory_get_usage() > (to_byte(ini_get('memory_limit')) - 1024000 )){
149     print_red(_("Warning: memory is getting low - please increase the memory_limit!"));
150   }
153 /* Redirect on back event */
154 if ($_SERVER["REQUEST_METHOD"] == "POST"){
156   /* Look for button events that match /^back[0-9]+$/,
157      extract the number and step the correct plugin. */
158   foreach ($_POST as $key => $value){
159     if (preg_match("/^back[0-9]+$/", $key)){
160       $back= substr($key, 4);
161       header ("Location: main.php?plug=$back");
162       exit;
163     }
164   }
167 /* Redirect on password back event */
168 if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['password_back'])){
169   header ("Location: main.php");
170   exit;
173 /* Check for multiple windows logout */
174 if ($_SERVER["REQUEST_METHOD"] == "POST"){
175   if (isset($_POST['reset_session'])){
176     header ("Location: logout.php");
177     exit;
178   }
180   if (isset($_POST['cancel_lock'])){
181     unset ($_SESSION['dn']);
182   }
186 /* Load department list when plugin has changed. That is some kind of
187    compromise between speed and beeing up to date */
188 if (isset($_GET['reset'])){
189   $config->departments= get_departments();
190   $config->make_idepartments ();
191   if (isset($_SESSION['objectinfo'])){
192     unset ($_SESSION['objectinfo']);
193   }
196 /* Install eGOsa hooks, convert _POST to _SESSION['POST'] */
197 if(isset($_GET['explorer'])){
198   $_SESSION{'eGosa'}=1;
200 if(isset($_SESSION['POST'])){
201   $_SERVER["REQUEST_METHOD"] = "POST";
202   foreach ($_SESSION['POST'] as $key => $dummy){
203     $_POST[$key]=$_SESSION['POST'][$key];
204   }
205   unset($_SESSION['POST']);
208 /* show web frontend */
209 $smarty->assign ("date", date("l, dS F Y H:i:s O"));
210 $smarty->assign ("must", "<font class=\"must\">*</font>");
211 if ($_SESSION['js']==FALSE){
212   $smarty->assign("javascript", "false");
213 } else {
214   $smarty->assign("javascript", "true");
216 $smarty->assign ("username", $ui->username);
217 $smarty->assign ("go_logo", get_template_path('images/go_logo.png'));
218 $smarty->assign ("go_base", get_template_path('images/dtree.png'));
219 $smarty->assign ("go_home", get_template_path('images/gohome.png'));
220 $smarty->assign ("go_out", get_template_path('images/stop.png'));
221 $smarty->assign ("go_top", get_template_path('images/go_top.png'));
222 $smarty->assign ("go_corner", get_template_path('images/go_corner.png'));
223 $smarty->assign ("go_left", get_template_path('images/go_left.png'));
224 $smarty->assign ("go_help", get_template_path('images/help.png'));
225 $plist->gen_menu();
226 $smarty->assign ("menu", $plist->menu);
227 if (isset($plug)){
228   $smarty->assign ("plug", "?plug=$plug");
229 } else {
230   $smarty->assign ("plug", "");
232 $smarty->display(get_template_path('headers.tpl'));
234 /* React on clicks */
235 if ($_SERVER["REQUEST_METHOD"] == "POST"){
237   /* 'delete_lock' is set by the lock removal dialog. We should remove the
238      lock at this point globally. Plugins do not need to remove it. */
239   if (isset($_POST['delete_lock']) && isset($_SESSION['dn'])){
240     del_lock ($_SESSION['dn']);
241     sess_del ('dn');
242   }
245   /* I don't want multiple browser windows open. One way to check it is
246      to count a hidden field and warn the user if SESSION and INPUT count
247      differ. */
248   if (isset($_POST['session_cnt'])){
249     if ($_POST['session_cnt'] != $_SESSION['session_cnt']){
250       $smarty->display(get_template_path('conflict.tpl'));
251       exit ();
252     }
253     $_SESSION['session_cnt']= $_SESSION['session_cnt'] + 1;
254     $_SESSION['post_cnt']= validate($_POST['session_cnt']) + 1;
255   }
258 /* Only generate hidden click counter, if post_cnt is defined */
259 if (isset ($_SESSION['post_cnt'])){
260   echo "<input type=\"hidden\" name=\"session_cnt\" value=\"".$_SESSION['post_cnt']."\">\n";
263 /* Load plugin */
264 if (is_file("$plugin_dir/main.inc")){
265   require_once ("$plugin_dir/main.inc");
266 } else {
267   print_red(sprintf(_("Can't find any plugin definitions for plugin '%s'!"), $plug));
268   echo $_SESSION['errors'];
269   exit();
272 /* Close div/tables */
273 $smarty->assign("contents", $display);
274 if (isset($_SESSION['errors'])){
275   $smarty->assign("errors", $_SESSION['errors']);
277 $smarty->display(get_template_path('framework.tpl'));
278 $_SESSION['plist']= $plist;
280 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
281 ?>