Code

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