Code

Moved to trunk/branches/tags structure
[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 ("setup_checks.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']) &&  isset($_SESSION['ldapconf']) && (isset($_POST['getconf']) || isset($_GET['getconfig']) ))){
51   echo parse_contrib_conf();
52   exit;
53 }
55 /* Set detected samba version */
56 if (isset($classes['samba2'])) {
57   $samba= "3";
58 } else {
59   $samba= "2";
60 }
62 /* Set template compile directory */
63 $smarty->compile_dir= '/var/spool/gosa';
65 /* Check for compile directory */
66 if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))){
67   print_red(_("Directory '%s' specified as smarty compile directory is not accessable, check existence and rigths of this directory!"), $smarty->compile_dir);
68   echo $_SESSION['errors'];
69   exit();
70 }
72 /* Language setup */
73 $lang= get_browser_language();
74 header("Content-type: text/html; charset=UTF-8");
75 $lang.=".UTF-8";
76 putenv("LANGUAGE=");
77 putenv("LANG=$lang");
78 setlocale(LC_ALL, $lang);
79 $GLOBALS['t_language']= $lang;
80 $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/';
82 /* Set the text domain as 'messages' */
83 $domain = 'messages';
84 bindtextdomain($domain, "$BASE_DIR/locale");
85 textdomain($domain);
87 if ($_SERVER["REQUEST_METHOD"] != "POST"){
88         // @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to");
89 }
91 /* Fill template with required values */
92 $smarty->assign ('date', gmdate("D, d M Y H:i:s"));
94 if(isset ($_POST['next'])){
95   $next = $_POST['next'];
96 } else {
97   $next = 1;
98 }
100 if(isset($_POST['back'])) {
101   $next = $next -2 ;     
104 if($next < 1){
105   $next = 1;
108 // How this works
110 // Every functioon called below, has two modes
111 // If the parameter is false, we only test if this function 
112 //  is called witout an error
113 // Is the return value = false, then there was an error
114 //  and we call this func again, to output the error
116 // I hope this will work fine ^^
117 if((!show_setup_page1(false))||($next == 1)) {
118   show_setup_page1();  
119 } elseif((!show_setup_page2(false))||($next==2)) {
120   show_setup_page2();
121 } elseif((!show_setup_page3(false))||($next==3)) {
122   show_setup_page3();
123 } elseif((!show_setup_page4(false))||($next==4)) {
124   show_setup_page4();
126 // This is called to test if we have an administrative Group with a User in it
127 elseif((!create_user_for_setup(false))) {
128   create_user_for_setup();
130 // this is the last Page which shows the downloadable conf file
131 else {
132   show_setup_page5();
135 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
136 ?>
137 </body>
138 </html>