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 setup_step_2 extends setup_step
24 {
25 var $basic_checks = array();
26 var $config_checks= array();
28 function setup_step_2()
29 {
30 $this->s_title = _("Installation check");
31 $this->s_title_long = _("Basic installation checks");
32 $this->s_info = _("Some basic checks for PHP version, ldap extension...");
33 }
36 /* Execute and display template */
37 function execute()
38 {
39 $this->run_checks();
40 $smarty = get_smarty();
41 $smarty->assign("basic" ,$this->basic_checks);
42 $smarty->assign("config",$this->config_checks);
43 return($smarty->fetch(get_template_path("setup_step2.tpl",TRUE,dirname(__FILE__))));
44 }
47 /* Execute all checks */
48 function run_checks()
49 {
50 $i =0;
51 $this->basic_checks = array();
52 $this->config_checks = array();
54 /* PHP version check */
55 $i ++;
56 $this->basic_checks[$i]['NAME'] = _("Checking PHP version");
57 $this->basic_checks[$i]['DESC'] = sprintf(_("PHP must be of version %s or %s or above for some functions."),"4.3.10","5.2.0");
58 $this->basic_checks[$i]['RESULT']= $this->check_php_version();
60 /* Checking imap extension */
61 $i ++;
62 $this->basic_checks[$i]['NAME'] = _("Checking for ldap module");
63 $this->basic_checks[$i]['DESC'] = _("This is the main module used by GOsa and therefore really required.");
64 $this->basic_checks[$i]['RESULT']= is_callable("ldap_bind");
66 /* Checking for XML functions */
67 $i ++;
68 $this->basic_checks[$i]['NAME'] = _("Checking for XML functions");
69 $this->basic_checks[$i]['DESC'] = _("XML functions are required to parse the configuration file.");
70 $this->basic_checks[$i]['RESULT']= is_callable("xml_parser_create");
72 /* Check for gettext support */
73 $i ++;
74 $this->basic_checks[$i]['NAME'] = _("Checking for gettext support");
75 $this->basic_checks[$i]['DESC'] = _("Gettext support is required for internationalized GOsa.");
76 $this->basic_checks[$i]['RESULT']= is_callable("bindtextdomain");
78 /* iconv */
79 $i ++;
80 $this->basic_checks[$i]['NAME'] = _("Checking for iconv support");
81 $this->basic_checks[$i]['DESC'] = _("This module is used by GOsa to convert samba munged dial informations and is therefore required.");
82 $this->basic_checks[$i]['RESULT']= is_callable("iconv");
84 /**/
85 $i ++;
86 $this->basic_checks[$i]['NAME'] = _("Checking for mhash module");
87 $this->basic_checks[$i]['DESC'] = _("To use SSHA encryption, you'll need this module. If you are just using crypt or md5 encryption, ignore this message. GOsa will run without it.");
88 $this->basic_checks[$i]['RESULT']= is_callable("mhash");
90 /**/
91 $i ++;
92 $this->basic_checks[$i]['NAME'] = _("Checking for imap module");
93 $this->basic_checks[$i]['DESC'] = _("The IMAP module is needed to communicate with the IMAP server. It gets status informations, creates and deletes mail users. ");
94 $this->basic_checks[$i]['RESULT']= is_callable("imap_open");
96 /**/
97 $i ++;
98 $this->basic_checks[$i]['NAME'] = _("Checking for getacl in imap");
99 $this->basic_checks[$i]['DESC'] = _("The getacl support is needed for shared folder permissions. The standard IMAP module is not capable of reading acl's. You need a recend PHP version for this feature.");
100 $this->basic_checks[$i]['RESULT']= is_callable("imap_getacl");
102 /**/
103 $i ++;
104 $this->basic_checks[$i]['NAME'] = _("Checking for mysql module");
105 $this->basic_checks[$i]['DESC'] = _("MySQL support is needed for reading GOfax reports from databases.");
106 $this->basic_checks[$i]['RESULT']= is_callable("mysql_query");
108 /**/
109 $i ++;
110 $this->basic_checks[$i]['NAME'] = _("Checking for kadm5 module");
111 $this->basic_checks[$i]['DESC'] = _("Managing users in kerberos requires the kadm5 module which is downloadable via PEAR network.");
112 $this->basic_checks[$i]['RESULT']= is_callable("kadm5_init_with_password");
114 /**/
115 $i ++;
116 $this->basic_checks[$i]['NAME'] = _("Checking for snmp Module");
117 $this->basic_checks[$i]['DESC'] = _("Simple Network Management Protocol (SNMP) is required for client monitoring.");
118 $this->basic_checks[$i]['RESULT']= is_callable("snmpget");
120 /* Checking for Cups module */
121 $i ++;
122 $this->basic_checks[$i]['NAME'] = _("Checking for cups module");
123 $this->basic_checks[$i]['DESC'] = _("In order to read available printers from IPP protocol instead of printcap files, you've to install the CUPS module.");
124 $this->basic_checks[$i]['RESULT']= is_callable("cups_get_dest_list");
126 /* Checking for F ping utility */
127 $i ++;
128 $query= "LC_ALL=C LANG=C fping -v 2>&1";
129 $output= shell_exec ($query);
130 $this->basic_checks[$i]['NAME'] = _("Checking for fping utility");
131 $this->basic_checks[$i]['DESC'] = _("The fping utility is only used if you've got a thin client based terminal environment running.");
132 $this->basic_checks[$i]['RESULT']= preg_match("/^fping:/", $output);;
134 /* Checking generate LM/NT password hashes */
135 $i ++;
136 $query= "mkntpwd 2>&1";
137 $output= shell_exec ($query);
138 $have_mkntpwd= preg_match("/^Usage: mkntpwd /", $output);
139 if (!$have_mkntpwd){
140 $query= 'LC_ALL=C LANG=C perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen $ARGV[0]), $/;" &>/dev/null';
141 system ($query, $ret);
142 $have_mkntpwd |= ($ret == 0);
143 }
145 $this->basic_checks[$i]['NAME'] = _("Password hashes");
146 $this->basic_checks[$i]['DESC'] = _("In order to use SAMBA 2/3, you've to install some additional packages to generate password hashes.");
147 $this->basic_checks[$i]['RESULT']= $have_mkntpwd;
151 /* PHP Configuration checks
152 */
154 /* Register_globals off */
155 $i = 0;
156 $this->config_checks[$i]['NAME'] = _("register_globals"." "."<b>"._("Off")."</b>");
157 $this->config_checks[$i]['DESC'] = _("register_globals is a PHP mechanism to register all global varibales to be accessible from scripts without changing the scope. This may be a security risk. GOsa will run in both modes.");
158 $this->config_checks[$i]['RESULT']= ini_get("register_globals") == 0;
160 $i ++;
161 $this->config_checks[$i]['NAME'] = _("session.gc_maxlifetime"." "."<b> >= 86400</b>");
162 $this->config_checks[$i]['DESC'] = _("PHP uses this value for the garbage collector to delete old sessions, setting this value to one day will prevent loosing session and cookie before they really timeout.");
163 $this->config_checks[$i]['RESULT']= ini_get("session.gc_maxlifetime") >= 86400;
165 $i ++;
166 $session_auto_start = ini_get('session.auto_start');
167 $this->config_checks[$i]['NAME'] = _("session.auto_start"." "."<b>"._("Off")."</b>");
168 $this->config_checks[$i]['DESC'] = _("In Order to use GOsa without any trouble, the session.auto_register option in your php.ini must be set to 'Off'.");
169 $this->config_checks[$i]['RESULT']= !$session_auto_start['local_value'];
171 $i ++;
172 $this->config_checks[$i]['NAME'] = _("memory_limit")." "."<b> >= 32</b>";
173 $this->config_checks[$i]['DESC'] = _("GOsa needs at least 32MB of memory, less will cause unpredictable errors! Increase it for larger setups.");
174 $this->config_checks[$i]['RESULT']= ini_get('memory_limit') >= 32 ;
177 $i ++;
178 $this->config_checks[$i]['NAME'] = _("implicit_flush")." "."<b>"._("Off")."</b>";
179 $this->config_checks[$i]['DESC'] = _("This option influences the Output handling. Turn this Option off, to increase performance.");
180 $this->config_checks[$i]['RESULT']= !ini_get('implicit_flush');
182 $i ++;
183 $this->config_checks[$i]['NAME'] = _("max_execution_time")." "."<b> >= 30</b>";
184 $this->config_checks[$i]['DESC'] = _("The Execution time should be at least 30 seconds, because some actions may consume more time.");
185 $this->config_checks[$i]['RESULT']= ini_get("max_execution_time") >= 30 ;
187 $i ++;
188 $this->config_checks[$i]['NAME'] = _("expose_php")." <b>"._("Off")."</b>";
189 $this->config_checks[$i]['DESC'] = _("Increase the server security by setting expose_php to 'off'. PHP won't send any Information about the server you are running in this case.");
190 $this->config_checks[$i]['RESULT']= !ini_get("expose_php");
193 $i ++;
194 $this->config_checks[$i]['NAME'] = _("magic_quotes_gpc")." <b>"._("On")."</b>";
195 $this->config_checks[$i]['DESC'] = _("Increase your server security by setting magic_quotes_gpc to 'on'. PHP will escape all quotes in strings in this case.");
196 $this->config_checks[$i]['RESULT']= ini_get('magic_quotes_gpc');
197 }
200 /* Check if current PHP version is compatible
201 with the current version of GOsa */
202 function check_php_version()
203 {
204 if(preg_match("/^5/",phpversion())){
205 return(version_compare(phpversion(),"5.2.0",">="));
206 }else{
207 return(version_compare(phpversion(),"4.3.10",">="));
208 }
209 }
210 }
212 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
213 ?>