Code

579ce622688083a4465bd8a7b6e8da1b23446777
[gosa.git] / setup / class_setupStep_Finish.inc
1 <?php
3 /*
4    This code is part of GOsa (https://gosa.gonicus.de)
5    Copyright (C) 2007 Fabian Hickert
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
23 class Step_Finish extends setup_step
24 {
25   var $gosa_conf_contrib   = "/gosa.conf";
26   var $cfg_file_written = FALSE;
27   var $header_image= 'images/ldapserver.png';
29   function Step_Finish()
30   {
31     $this->update_strings();
32   }
34   
35   function update_strings()
36   {
37     $this->s_title      = _("Finish");
38     $this->s_info       = _("Write configuration file");
39     $this->s_title_long = _("Finish - write the configuration file");
40   }
43   function get_conf_data()
44   {
45     $smarty = get_smarty();
46     $smarty->assign("cv",$this->parent->captured_values);
47     $str =  $smarty->fetch(CONFIG_TEMPLATE_DIR.$this->gosa_conf_contrib);
48     return($str);
49   }  
52   function execute()
53   {
55     $info= posix_getgrgid(posix_getgid());
56     $webgroup = $info['name'];
57       
58     
59     /* Check if there is currently an active gosa.conf 
60      */
61     $exists = file_exists(CONFIG_DIR."/".CONFIG_FILE); 
63     /* Redirect to GOsa login */
64     if(isset($_POST['next']) && $exists){
65       session_destroy();
66       header("Location: index.php");
67       exit();
68     }
70     /* Downlaod config */
71     if(isset($_POST['getconf'])){
73       header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
74       header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
75       header("Cache-Control: no-cache");
76       header("Pragma: no-cache");
77       header("Cache-Control: post-check=0, pre-check=0");
78       header("Content-type: text/plain");
79      
80       if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) ||
81           preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){
82         header('Content-Disposition: filename="'.CONFIG_FILE.'"');
83       } else {
84         header('Content-Disposition: attachment; filename="'.CONFIG_FILE.'"');
85       }
87       $str = $this->get_conf_data();
88       $str = preg_replace("/\n[ ]*\n/","",$str);
90       echo $this->get_conf_data();
91       exit();
92     }
93    
94     $err_msg= "";
95     
96     if($exists && $this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){
97       $err_msg = _("Your configuration file is currently world readable. This is a big security risk. Please updated the file permissions!");
98     }
100     $smarty = get_smarty();
101     $smarty->assign("err_msg",$err_msg);
102     $smarty->assign("webgroup", $webgroup);
103     $smarty->assign("CONFIG_DIR",CONFIG_DIR);
104     $smarty->assign("CONFIG_FILE" , CONFIG_FILE);
106     $smarty->assign("msg2", sprintf(_("After downloading and placing the file under %s, please make sure that the user the webserver is running with is able to read %s, while other users shouldn't. You may want to execute these commands to achieve this requirement:"),CONFIG_DIR,CONFIG_FILE));
108     $smarty->assign("cv",$this->parent->captured_values);
109     return($smarty -> fetch (get_template_path("../setup/setup_finish.tpl")));
110   }
113   /* check if given file is world readable */
114   function is_world_readable($file)
115   {
116     clearstatcache();
117     $p = fileperms($file);
118     $w_r = (decbin($p & 4) == TRUE);
119     return($w_r);
120   }
123   function save_object()
124   {
125     if(isset($_POST['step8_posted'])){
127       /* Get attributes */
128       foreach($this->attributes as $attr){
129         if(isset($_POST[$attr])){
130           $this->$attr = validate($_POST[$attr]);
131         }
132       }
133     }
134   }
137 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
138 ?>