Code

W3C Fixes
[gosa.git] / html / setup.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 // Starting the Session to save Form Information 
22 session_start();
23 $_SESSION['DEBUGLEVEL']= 1;
25 /* Load required includes */
26 require_once ("../include/php_setup.inc");
27 require_once ("functions.inc");
28 require_once ("functions_setup.inc");
30 // Save the Post Data (back and forward button)
31 foreach ($_POST as $key => $val){
32   $_SESSION['ldapconf'][$key] = $val;
33 }
35 /* Don't call setup if gosa.conf exists */
36 if (file_exists(CONFIG_DIR."/gosa.conf")){      
37   header("location:index.php"); 
38   exit();
39 }
41 // Check if theres the example
42 if (!file_exists(CONFIG_TEMPLATE_DIR."/gosa.conf")){
43         echo "error example of gosa.conf not present!";
44 }
46 // No Errors occured yet
47 $_SESSION['errors']= "";
49 // Print out gosa.conf 
50 //if(isset($_SESSION['classes'])) print "\$_SESSION['classes']=ok";
51 //if(isset($_SESSION['ldapconf'])) print "\$_SESSION['ldapconf']=ok";
52 //if(isset($_POST['getconf']))  print "\$_POST['getconf']=ok";
54 if ((
55     isset($_SESSION['classes']) &&  
56     isset($_SESSION['ldapconf']) && 
57       (
58       isset($_POST['getconf']) || isset($_GET['getconfig']) ))){
59   echo parse_contrib_conf();
60   exit;
61 }
63 /* Set detected samba version */
64 if (isset($classes['samba2'])) {
65   $samba= "3";
66 } else {
67   $samba= "2";
68 }
70 /* Set template compile directory */
71 $smarty->compile_dir= '/var/spool/gosa';
73 /* Check for compile directory */
74 if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))){
75   print_red(_("Directory '%s' specified as smarty compile directory is not accessable, check existence and rigths of this directory!"), $smarty->compile_dir);
76   echo $_SESSION['errors'];
77   exit();
78 }
80 /* Language setup */
81 $lang= get_browser_language();
82 header("Content-type: text/html; charset=UTF-8");
83 $lang.=".UTF-8";
84 putenv("LANGUAGE=");
85 putenv("LANG=$lang");
86 setlocale(LC_ALL, $lang);
87 $GLOBALS['t_language']= $lang;
88 $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/';
90 /* Set the text domain as 'messages' */
91 $domain = 'messages';
92 bindtextdomain($domain, "$BASE_DIR/locale");
93 textdomain($domain);
95 if ($_SERVER["REQUEST_METHOD"] != "POST"){
96         // @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to");
97 }
99 /* Fill template with required values */
100 $smarty->assign ('date', gmdate("D, d M Y H:i:s"));
102 if(isset ($_POST['next'])){
103   $next = $_POST['next'];
104 } else {
105   $next = 1;
108 if(isset($_POST['back'])) {
109   $next = $next -2 ;     
112 if($next < 1){
113   $next = 1;
116 // How this works
118 // Every functioon called below, has two modes
119 // If the parameter is false, we only test if this function 
120 //  is called witout an error
121 // Is the return value = false, then there was an error
122 //  and we call this func again, to output the error
124 // I hope this will work fine ^^
125 if((!show_setup_page1(false))||($next == 1)) {
126   show_setup_page1();  
127 } elseif((!show_setup_page2(false))||($next==2)) {
128   show_setup_page2();
129 } elseif((!show_setup_page3(false))||($next==3)) {
130   show_setup_page3();
131 } elseif((!show_setup_page4(false))||($next==4)) {
132   show_setup_page4();
134 // This is called to test if we have an administrative Group with a User in it
135 elseif((!create_user_for_setup(false))) {
136   create_user_for_setup();
138 // this is the last Page which shows the downloadable conf file
139 else {
140   show_setup_page5();
143 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
144 ?>
145 </body>
146 </html>