Code

Moved from "1" to "true"
[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;
26 if (!isset($_GET['js']) && !isset($_SESSION['js'])){
27   echo '<script language="JavaScript" type="text/javascript">';
28   echo '  location = "index.php?js=true";';
29   echo '</script>';
31   $_SESSION['js']= FALSE;
32 } else {
33   $_SESSION['js']= TRUE;
34 }
36 /* Load required includes */
37 require_once ("../include/php_setup.inc");
38 require_once ("functions.inc");
39 require_once ("functions_setup.inc");
41 // Save the Post Data (back and forward button)
42 foreach ($_POST as $key => $val){
43   $_SESSION['ldapconf'][$key] = $val;
44 }
46 /* Don't call setup if gosa.conf exists */
47 if (file_exists(CONFIG_DIR."/gosa.conf")){      
48   header("location:index.php"); 
49   exit();
50 }
52 // Check if theres the example
53 if (!file_exists(CONFIG_TEMPLATE_DIR."/gosa.conf")){
54         echo "error example of gosa.conf not present!";
55 }
57 // No Errors occured yet
58 $_SESSION['errors']= "";
60 // Print out gosa.conf 
61 //if(isset($_SESSION['classes'])) print "\$_SESSION['classes']=ok";
62 //if(isset($_SESSION['ldapconf'])) print "\$_SESSION['ldapconf']=ok";
63 //if(isset($_POST['getconf']))  print "\$_POST['getconf']=ok";
65 if ((
66     isset($_SESSION['classes']) &&  
67     isset($_SESSION['ldapconf']) && 
68       (
69       isset($_POST['getconf']) || isset($_GET['getconfig']) ))){
70   echo parse_contrib_conf();
71   exit;
72 }
74 /* Set detected samba version */
75 if (isset($classes['samba2'])) {
76   $samba= "3";
77 } else {
78   $samba= "2";
79 }
81 /* Set template compile directory */
82 $smarty->compile_dir= '/var/spool/gosa';
84 /* Check for compile directory */
85 if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))){
86   print_red(_("Directory '%s' specified as smarty compile directory is not accessible, please check existence and rights of this directory!"), $smarty->compile_dir);
87   echo $_SESSION['errors'];
88   exit();
89 }
91 /* Language setup */
92 $lang= get_browser_language();
93 header("Content-type: text/html; charset=UTF-8");
94 $lang.=".UTF-8";
95 putenv("LANGUAGE=");
96 putenv("LANG=$lang");
97 setlocale(LC_ALL, $lang);
98 $GLOBALS['t_language']= $lang;
99 $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/';
101 /* Set the text domain as 'messages' */
102 $domain = 'messages';
103 bindtextdomain($domain, "$BASE_DIR/locale");
104 textdomain($domain);
106 if ($_SERVER["REQUEST_METHOD"] != "POST"){
107         // @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to");
110 /* Fill template with required values */
111 $smarty->assign ('date', gmdate("D, d M Y H:i:s"));
113 if(isset ($_POST['next'])){
114   $next = $_POST['next'];
115 } else {
116   $next = 1;
119 if(isset($_POST['back'])) {
120   $next = $next -2 ;     
123 if($next < 1){
124   $next = 1;
127 // How this works
129 // Every functioon called below, has two modes
130 // If the parameter is false, we only test if this function 
131 //  is called witout an error
132 // Is the return value = false, then there was an error
133 //  and we call this func again, to output the error
135 // I hope this will work fine ^^
136 if((!show_setup_page1(false))||($next == 1)) {
137   show_setup_page1();  
138 } elseif((!show_setup_page2(false))||($next==2)) {
139   show_setup_page2();
140 } elseif((!show_setup_page3(false))||($next==3)) {
141   show_setup_page3();
142 } elseif((!show_setup_page4(false))||($next==4)) {
143   show_setup_page4();
145 // This is called to test if we have an administrative Group with a User in it
146 elseif((!create_user_for_setup(false))) {
147   create_user_for_setup();
149 // this is the last Page which shows the downloadable conf file
150 else {
151   show_setup_page5();
154 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
155 ?>
156 </body>
157 </html>