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 /* Get standard functions */
24 require_once ("../include/php_setup.inc");
25 require_once ("functions.inc");
27 // Do not use the GOsa default error handler.
28 // To do so we require a valid config object - and at this point
29 // we doesn't have one.
30 restore_error_handler();
32 require_once("../setup/class_setup.inc");
33 require_once("../setup/class_setupStep.inc");
34 require_once("../setup/class_setupStep_Welcome.inc");
35 require_once("../setup/class_setupStep_Language.inc");
36 require_once("../setup/class_setupStep_Checks.inc");
37 require_once("../setup/class_setupStep_License.inc");
38 require_once("../setup/class_setupStep_Ldap.inc");
39 require_once("../setup/class_setupStep_Schema.inc");
40 require_once("../setup/class_setupStep_Migrate.inc");
41 require_once("../setup/class_setupStep_Feedback.inc");
42 require_once("../setup/class_setupStep_Finish.inc");
45 /* Set header */
46 header("Content-type: text/html; charset=UTF-8");
48 /* Set cookie lifetime to one day (The parameter is in seconds ) */
49 session_set_cookie_params(24*60*60);
50 session_cache_expire(60*24); // default is 180
51 ini_set("session.gc_maxlifetime",24*60*60);
53 /* Start session */
54 session::start();
55 session::global_set('debugLevel',1);
56 session::set('errorsAlreadyPosted',array());
58 /* Attribute initialization, reset errors */
59 session::set('errors',"");
60 session::set('errorsAlreadyPosted',array());
61 session::set('LastError',"");
63 /* Set template compile directory */
64 if(!session::is_set("SETUP_COMPILE_DIR")){
65 session::set('SETUP_COMPILE_DIR', '/var/spool/gosa/');
66 }
67 if(isset($_POST['compile_dir']) && isset($_POST['useCompileDir'])){
68 session::set('SETUP_COMPILE_DIR', get_post('compile_dir'));
69 }
71 $smarty->compile_dir= session::get('SETUP_COMPILE_DIR');
73 /* Check for compile directory */
74 if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))){
75 echo "<form action='?' method='POST'>".
76 " <h2>".
77 " "._("Please specify a writeable directory for GOsa to create temporary files.").
78 " </h2>".
79 " ".sprintf(_("GOsa requires a writeable directory temporary store generated templates."), $smarty->compile_dir).
80 "<input name='compile_dir' type='text' value=\"".htmlentities(session::get('SETUP_COMPILE_DIR'), ENT_QUOTES, 'UTF-8')."\"> ".
81 "<button name='useCompileDir'>".msgPool::okButton()."</button></form>";
82 exit();
83 }
85 /* Get posted language */
86 if(!session::global_is_set('lang')){
87 session::global_set('lang',get_browser_language());
88 }
89 if(isset($_POST['lang_selected'])){
90 if($_POST['lang_selected'] != ""){
91 session::global_set('lang',$_POST['lang_selected']);
92 }else{
93 session::global_set('lang',get_browser_language());
94 }
95 }
97 /* Check for js */
98 if (!isset($_GET['js']) && !session::global_is_set('js')){
99 echo '<script language="JavaScript" type="text/javascript">';
100 echo ' location = "setup.php?js=true";';
101 echo '</script>';
103 session::global_set('js',FALSE);
104 } elseif(isset($_GET['js'])) {
105 session::global_set('js',TRUE);
106 }
109 $lang = session::global_get('lang');
110 /* Append .UTF-8 to language string if necessary */
111 if(!preg_match("/utf(-)8$/i",$lang)){
112 $lang .= ".UTF-8";
113 }
114 putenv("LANGUAGE=");
115 putenv("LANG=$lang");
116 setlocale(LC_ALL, $lang);
117 $GLOBALS['t_language']= $lang;
118 $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/';
120 /* Set the text domain as 'messages' */
121 $domain = 'messages';
122 bindtextdomain($domain, LOCALE_DIR);
123 textdomain($domain);
126 /* Call setup */
127 $display = "";
128 require_once("../setup/main.inc");
130 $smarty->assign ("title","GOsa");
131 $smarty->assign("date", date("l, dS F Y H:i:s O"));
132 $header= "<!-- headers.tpl-->".$smarty->fetch(get_template_path('setup_headers.tpl'));
136 /* Set focus to the error button if we've an error message */
137 $focus= "";
138 if (session::is_set('errors') && session::get('errors') != ""){
139 $focus= '<script language="JavaScript" type="text/javascript">';
140 $focus.= 'document.forms[0].error_accept.focus();';
141 $focus.= '</script>';
142 }
144 $focus= '<script language="JavaScript" type="text/javascript">';
145 $focus.= 'next_msg_dialog();';
146 $focus.= '</script>';
148 /* show web frontend */
149 $setup = session::global_get('setup');
150 $smarty->assign("contents" , $display);
151 $smarty->assign("navigation", $setup->get_navigation_html());
152 $smarty->assign("header", $setup->get_header_html());
153 $smarty->assign("bottom", $focus.$setup->get_bottom_html());
154 $smarty->assign("msg_dialogs", msg_dialog::get_dialogs());
156 if ($error_collector != ""){
157 $smarty->assign("php_errors", preg_replace("/%BUGBODY%/",$error_collector_mailto,$error_collector)."</div>");
158 } else {
159 $smarty->assign("php_errors", "");
160 }
161 if(function_exists("get_gosa_version")){
162 $smarty->assign("version",get_gosa_version());
163 }else{
164 $smarty->assign("version","");
165 }
167 echo $header.$smarty->fetch("../setup/setup_frame.tpl");
168 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
169 ?>