77ca026fbf9071f1a8b2d6d1df31c1e198a86ca1
1 <?php
3 function check_schema_version($description, $version)
4 {
5 $desc= preg_replace("/^.* DESC\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $description);
7 return preg_match("/\(v$version\)/", $desc);
8 }
11 function view_schema_check($table)
12 {
13 $message="<table summary=\"\" class=\"check\">";
15 foreach ($table as $key => $values){
16 $msg = $values['msg'];
17 $message.= "<tr><td class=\"check\">$msg";
19 if($values['status']) {
20 $message.="</td><td style='text-align:center' >
21 <img src=images/true.png alt='true' /></td></tr>";
22 } else {
23 $message.="</td><td style='text-align:center' >
24 <img src=images/button_cancel.png alt='false' /></td></tr>";
25 }
26 }
27 $message.="</table>";
29 return $message;
30 }
33 function is_schema_readable($server, $admin, $password)
34 {
35 $ds= ldap_connect ($server);
36 if (!$ds) {
37 return (false);
38 }
39 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
40 $r= ldap_bind ($ds, $admin, $password);
42 /* Get base to look for schema */
43 $sr = @ldap_read ($ds, NULL, "objectClass=*", array("subschemaSubentry"));
44 $attr= @ldap_get_entries($ds,$sr);
45 if (!isset($attr[0]['subschemasubentry'][0])){
46 return (false);
47 }
49 $nb= $attr[0]['subschemasubentry'][0];
50 $objectclasses= array();
51 $sr= ldap_read ($ds, $nb, "objectClass=*", array("objectclasses"));
52 $attrs= ldap_get_entries($ds,$sr);
53 if (!isset($attrs[0])){
54 return (false);
55 }
56 return(true);
57 }
59 function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false)
60 {
61 global $config;
63 $messages= array();
64 $required_classes= array(
65 "gosaObject" => array("version" => "2.4"),
66 "gosaAccount" => array("version" => "2.4"),
67 "gosaLockEntry" => array("version" => "2.4"),
68 "gosaCacheEntry" => array("version" => "2.4"),
69 "gosaDepartment" => array("version" => "2.4"),
71 "goFaxAccount" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
72 "goFaxSBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
73 "goFaxRBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
75 "gosaUserTemplate" => array("version" => "2.4", "class" => "posixAccount","file" => "nis.schema"),
76 "gosaMailAccount" => array("version" => "2.4", "class" => "mailAccount","file" => "gosa+samba3.schema"),
77 "gosaProxyAccount" => array("version" => "2.4", "class" => "proxyAccount","file" => "gosa+samba3.schema"),
78 "gosaApplication" => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
79 "gosaApplicationGroup" => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
81 "GOhard" => array("version" => "2.5", "class" => "terminals","file" => "goto.schema"),
82 "gotoTerminal" => array("version" => "2.5", "class" => "terminals","file" => "goto.schema"),
83 "goServer" => array("version" => "2.4","class" => "server","file" => "goserver.schema"),
84 "goTerminalServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
85 "goShareServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
86 "goNtpServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
87 "goSyslogServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
88 "goLdapServer" => array("version" => "2.4"),
89 "goCupsServer" => array("version" => "2.4", "class" => array("posixAccount", "terminals"),),
90 "goImapServer" => array("version" => "2.4", "class" => array("mailAccount", "mailgroup"),"file" => "gosa+samba3.schema"),
91 "goKrbServer" => array("version" => "2.4"),
92 "goFaxServer" => array("version" => "2.4", "class" => "gofaxAccount","file" => "gofax.schema"),
93 );
95 /* Build LDAP connection */
96 $ds= ldap_connect ($server);
97 if (!$ds) {
98 return (array(array("msg" => _("Can't bind to LDAP. No schema check possible!"), "status" => FALSE)));
99 }
100 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
101 $r= ldap_bind ($ds, $admin, $password);
103 /* Get base to look for schema */
104 $sr = @ldap_read ($ds, NULL, "objectClass=*", array("subschemaSubentry"));
105 $attr= @ldap_get_entries($ds,$sr);
106 if (!isset($attr[0]['subschemasubentry'][0])){
107 return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE)));
108 }
110 /* Get list of objectclasses */
111 $nb= $attr[0]['subschemasubentry'][0];
112 $objectclasses= array();
113 $sr= ldap_read ($ds, $nb, "objectClass=*", array("objectclasses"));
114 $attrs= ldap_get_entries($ds,$sr);
115 if (!isset($attrs[0])){
116 return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE)));
117 }
118 foreach ($attrs[0]['objectclasses'] as $val){
119 $name= preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $val);
120 if ($name != $val){
121 $objectclasses[$name]= $val;
122 }
123 }
124 /* Walk through objectclasses and check if they are needed or not */
125 foreach ($required_classes as $key => $value){
126 if (isset($value['class'])){
127 if (!is_array($value['class'])){
128 $classes= array($value['class']);
129 } else {
130 $classes= $value['class'];
131 }
133 /* Check if we are using the class that requires */
134 foreach($classes as $class){
135 if (!isset($objectclasses[$key])){
136 $messages[$key]['msg']= sprintf(_("Optional objectclass '%s' required by plugin '%s' is not present in LDAP setup"), $key, $class);
137 $messages[$key]['status'] = FALSE;
138 } else {
139 if (!check_schema_version($objectclasses[$key], $value['version'])){
140 $messages[$key]['msg']= sprintf(_("Optional objectclass '%s' required by plugin '%s' does not have version %s"), $key, $class, $value['version']);
141 $messages[$key]['needonstartup'] = TRUE;
142 $messages[$key]['status'] =FALSE;
143 }else {
144 if(!isset($affich2[$class])){
145 $affich2[$class]['msg'] = sprintf(_("Support for '%s' enabled"), $class)."<td class=\"check\"> ".$value['file']."</td>";
146 $affich2[$class]['status']= TRUE;
147 }
148 }
149 }
151 }
152 } else {
153 /* Required class */
154 if (!isset($objectclasses[$key])){
155 $messages[$key]['msg']= sprintf(_("Required objectclass '%s' is not present in LDAP setup"), $key);
156 $messages[$key]['status'] = FALSE;
157 } else {
158 if (!check_schema_version($objectclasses[$key], $value['version'])){
159 $messages[$key]['msg']= sprintf(_("Required objectclass '%s' does not have version %s"), $key, $value['version']);
160 $messages[$key]['status'] = FALSE;
161 $messages[$key]['needonstartup'] = TRUE;
162 }
164 }
165 }
166 }
168 /* Check for correct samba parameters */
169 if (!isset($objectclasses['sambaSamAccount'])){
170 $messages['samba3']['msg']= _("SAMBA 3 support disabled, no schema seems to be installed");
171 $affich['samba3']['msg']= $messages['samba3']['msg']."<td class=\"check\">gosa+samba3.schema</td>";
172 $messages['samba3']['status']= FALSE;
173 $affich['samba3']['status']= FALSE;
174 }else{
175 $affich['samba3']['msg']= _("SAMBA 3 support enabled")."<td class=\"check\">gosa+samba3.schema</td>";
176 $affich['samba3']['status']= TRUE;
177 }
179 if (!isset($objectclasses['sambaAccount'])){
180 $messages['samba2']['msg']= _("SAMBA 2 support disabled, no schema seems to be installed");
181 $affich['samba2']['msg']= $messages['samba2']['msg']."<td class=\"check\">samba.schema</td>";
182 $messages['samba2']['status']= FALSE;
183 $affich['samba2']['status']= FALSE;
184 }else{
185 $affich['samba2']['msg']= _("SAMBA 2 support enabled")."<td class=\"check\">samba.schema</td>";
186 $affich['samba2']['status']= TRUE;
187 }
189 /* Check pureftp/dns/ */
190 if (!isset($objectclasses['PureFTPdUser'])){
191 $messages['pureftp']['msg']= _("Support for pureftp disabled, no schema seems to be installed");
192 $affich['pureftp']['msg']= $messages['pureftp']['msg']."<td class=\"check\">pureftpd.schema</td>";
193 $messages['pureftp']['status']= FALSE;
194 $affich['pureftp']['status']= FALSE;
195 }else{
196 $affich['pureftp']['msg']= _("Support for pureftp enabled")."<td class=\"check\">pureftpd.schema</td>";
197 $affich['pureftp']['status']= TRUE;
198 }
200 if (!isset($objectclasses['gosaWebdavAccount'])){
201 $messages['webdav']['msg']= _("Support for WebDAV disabled, no schema seems to be installed");
202 $affich['webdav']['msg']= $messages['webdav']['msg']."<td class=\"check\"></td>";
203 $messages['webdav']['status']= FALSE;
204 $affich['webdav']['status']= FALSE;
205 }else{
206 $affich['webdav']['msg']=_("Support for WebDAV enabled")."<td class=\"check\">gosa+samba3.schema</td>";
207 $affich['webdav']['status']= TRUE;
208 }
210 if (!isset($objectclasses['phpgwAccount'])){
211 $messages['phpgroupware']['msg']= _("Support for phpgroupware disabled, no schema seems to be installed");
212 $affich['phpgroupware']['msg']= $messages['phpgroupware']['msg']."<td class=\"check\">phpgwaccount.schema</td>";
213 $messages['phpgroupware']['status']= FALSE;
214 $affich['phpgroupware']['status']= FALSE;
215 }else{
216 $affich['phpgroupware']['msg']= _("Support for phpgroupware enabled")."<td class=\"check\">phpgwaccount.schema</td>";
217 $affich['phpgroupware']['status']= TRUE;
218 }
220 if (!isset($objectclasses['trustAccount'])){
221 $messages['trustAccount']['msg']= _("Support for trustAccount disabled, no schema seems to be installed");
222 $affich['trustAccount']['msg']= $messages['trustAccount']['msg']."<td class=\"check\">trust.schema</td>";
223 $messages['trustAccount']['status']= FALSE;
224 $affich['trustAccount']['status']= FALSE;
225 }else{
226 $affich['trustAccount']['msg']= _("Support for trustAccount enabled")."<td class=\"check\">trust.schema</td>";
227 $affich['trustAccount']['status']= TRUE;
228 }
230 if (!isset($objectclasses['goFonAccount'])){
231 $messages['phoneaccount']['msg']= _("Support for gofon disabled, no schema seems to be installed");
232 $affich['phoneaccount']['msg']= $messages['phoneaccount']['msg']."<td class=\"check\">gofon.schema</td>";
233 $messages['phoneaccount']['status']= FALSE;
234 $affich['phoneaccount']['status']= FALSE;
235 }else{
236 $affich['phoneaccount']['msg']= _("Support for gofon enabled")."<td class=\"check\">gofon.schema</td>";
237 $affich['phoneaccount']['status']= true;
238 }
240 if (!isset($objectclasses['nagiosContact'])){
241 $messages['nagioscontact']['msg']= _("Support for nagios disabled, no schema seems to be installed");
242 $affich['nagioscontact']['msg']= $messages['nagioscontact']['msg']."<td class=\"check\">nagios.schema</td>";
243 $messages['nagioscontact']['status']= FALSE;
244 $affich['nagioscontact']['status']= FALSE;
245 }else{
246 $affich['nagioscontact']['msg']= _("Support for nagios enabled")."<td class=\"check\">nagios.schema</td>";
247 $affich['nagioscontact']['status']= true;
248 }
250 if ((!isset($objectclasses['apple-user'])) || (!isset($objectclasses['mount'])) ){
251 $messages['netatalk']['msg']= _("Support for netatalk disabled, no schema seems to be installed");
252 $affich['netatalk']['msg']= $messages['netatalk']['msg']."<td class=\"check\">apple.schema</td>";
253 $messages['netatalk']['status']= FALSE;
254 $affich['netatalk']['status']= FALSE;
255 }else{
256 $affich['netatalk']['msg']= _("Support for netatalk enabled")."<td class=\"check\">apple.schema</td>";
257 $affich['netatalk']['status']= true;
258 }
260 /* Fix for PHP Fehler "Undefined index: ldapconf"
261 * Ablaufverfolgung[1]: Funktion schema_check Datei: /home/hickert/gosa/include/functions_setup.inc (Zeile 230)
262 */
263 if((isset($_SESSION['ldapconf']['mail_methods']))&&(isset($_SESSION['ldapconf']))){
264 if(($_SESSION['ldapconf']['mail_methods'][$_SESSION['ldapconf']['mail']] == "kolab")&&(!$CalledByIndexPhP)){
265 if(!isset($objectclasses['kolabInetOrgPerson'])) {
266 $messages['kolab']['msg']= _("Support for Kolab disabled, no schema seems to be installed, setting mail-method to cyrus");
267 $affich['kolab']['msg']=$messages['kolab']['msg']."<td class=\"check\">kolab2.schema</td>";
268 $tmp= array_flip($_SESSION['ldapconf']['mail_methods']);
269 $_SESSION['ldapconf']['mail']=$tmp['cyrus'];
270 $messages['kolab']['status']= FALSE;
271 $affich['kolab']['status']= FALSE;
272 }else{
273 $affich['kolab']['msg']=_("Support for Kolab enabled")."<td class=\"check\">gofon.schema</td>";
274 $affich['kolab']['status']= TRUE;
275 }
276 }
277 }
278 if($aff==0){
279 return ($messages);
280 } else {
281 return(array_merge($affich,$affich2));
282 }
283 }
286 function check(&$faults, $message, $description, $test, $required= TRUE)
287 {
288 $msg= "<table summary=\"\" class='check'><tr><td class='check' style='font-size:14px;'>$message</td>
289 <td rowspan=2 style='vertical-align:middle; text-align:center;width:45px;'>";
290 if ($test){
291 $msg.= _("OK")."<br>";
292 } else {
293 if (!$required){
294 $msg.="<font color=red>"._("Ignored")."</font><br>";
295 } else {
296 $msg.="<font color=red>"._("Failed")."</font><br>";
297 $faults++;
298 }
299 }
300 $msg.= "</td></tr><tr><td class='check' style='padding-left:20px;".
301 "background-color:#F0F0F0;'>$description</td></tr></table><br>";
303 return $msg;
304 }
306 function perform_php_checks(&$faults)
307 {
308 global $check_globals;
310 $faults= 0;
311 $msg= "";
313 $msg.= "<h1>"._("PHP setup inspection")."</h1>";
314 $msg.= check ( $faults, _("Checking for PHP version (>=4.1.0)"),
315 _("PHP must be of version 4.1.0 or above for some functions and known bugs in PHP language."),
316 version_compare(phpversion(), "4.1.0")>=0);
318 $msg.= check ( $faults, _("Checking if register_globals is set to 'off'"),
319 _("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."),
320 $check_globals == 0, FALSE);
322 $msg.= check ( $faults, _("Checking for ldap module"),
323 _("This is the main module used by GOsa and therefore really required."),
324 is_callable('ldap_bind'));
326 $msg.= check ( $faults, _("Checking for XML functions"),
327 _("XML functions are required to parse the configuration file."),
328 is_callable('xml_parser_create'));
330 $msg.= check ( $faults, _("Checking for gettext support"),
331 _("Gettext support is required for internationalized GOsa."),
332 is_callable('bindtextdomain'));
334 $msg.= check ( $faults, _("Checking for iconv support"),
335 _("This module is used by GOsa to convert samba munged dial informations and is therefore required."),
336 is_callable('iconv'));
338 $msg.= check ( $faults, _("Checking for mhash module"),
339 _("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."),
340 is_callable('mhash'), FALSE);
342 $msg.= check ( $faults, _("Checking for imap module"),
343 _("The IMAP module is needed to communicate with the IMAP server. It gets status informations, creates and deletes mail users."),
344 is_callable('imap_open'));
346 $msg.= check ( $faults, _("Checking for getacl in imap"),
347 _("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."),
348 is_callable('imap_getacl'), FALSE);
350 $msg.= check ( $faults, _("Checking for mysql module"),
351 _("MySQL support is needed for reading GOfax reports from databases."),
352 is_callable('mysql_query'), FALSE);
354 $msg.= check ( $faults, _("Checking for cups module"),
355 _("In order to read available printers from IPP protocol instead of printcap files, you've to install the CUPS module."),
356 is_callable('cups_get_dest_list'), FALSE);
358 $msg.= check ( $faults, _("Checking for kadm5 module"),
359 _("Managing users in kerberos requires the kadm5 module which is downloadable via PEAR network."),
360 is_callable('kadm5_init_with_password'), FALSE);
362 $msg.= check ( $faults, _("Checking for snmp Module"),
363 _("Simple Network Management Protocol (SNMP) is required for client monitoring."),
364 is_callable('snmpget'), FALSE);
366 return ($msg);
367 }
369 function get_link($function_name) {
370 $result= "<a href='http://de.php.net/manual/en/function.";
372 /* Replace all underscores with hyphens (phpdoc convention) */
373 $function_name= str_replace("_", "-", $function_name);
375 /* Append to base URL */
376 $result.= $function_name.".php'>$function_name</a>";
378 return $result;
379 }
381 function perform_additional_function_checks(&$faults) {
382 global $check_globals;
384 $faults= 0;
385 $msg= "";
386 $functions= array();
388 $functions_list= '../include/functions_list.inc';
390 /* Make sure that we can read the file */
391 if(is_readable($functions_list)) {
392 /* Open filehandle */
393 $fh= fopen($functions_list,'rb');
394 if($fh!=null) {
395 $functions= eval(fread($fh,filesize($functions_list)));
396 }
397 }
399 $msg.= "<h1>"._("PHP detailed function inspection")."</h1>";
400 /* Only print message, if function is not callable */
401 foreach($functions as $key => $fn_name) {
402 if(!is_callable($fn_name)) {
403 $msg.= check ($faults, sprintf(_("Checking for function %s"), "<b>".get_link($fn_name)."</b>"),
404 sprintf(_("The function %s is used by GOsa. There is no information if it's optional or required yet."), "<b>".get_link($fn_name)."</b>"),
405 is_callable($fn_name), false);
406 }
407 }
408 return $msg;
409 }
411 function perform_additional_checks(&$faults)
412 {
413 $ret = NULL;
414 /* Programm check */
415 $msg= "<h1>"._("Checking for some additional programms")."</h1>";
417 /* Image Magick */
418 $query= "LC_ALL=C LANG=C convert -help";
419 $output= shell_exec ($query);
420 if ($output != ""){
421 $lines= split ("\n", $output);
422 $version= preg_replace ("/^Version:.+Magick ([^\s]+).*/", "\\1", $lines[0]);
423 list($major, $minor)= split("\.", $version);
424 $msg.= check ( $faults, _("Checking for ImageMagick (>=5.4.0)"),
425 _("ImageMagick is used to convert user supplied images to fit the suggested size and the unified JPEG format."),
426 ($major > 5 || ($major == 5 && $minor >= 4)));
427 } else {
428 $msg.= check ( $faults, _("Checking imagick module for PHP"),
429 _("Imagick is used to convert user supplied images to fit the suggested size and the unified JPEG format from PHP script."), function_exists('imagick_blob2image'), TRUE);
430 }
432 /* Check for fping */
433 $query= "LC_ALL=C LANG=C fping -v 2>&1";
434 $output= shell_exec ($query);
435 $have_fping= preg_match("/^fping:/", $output);
436 $msg.= check ( $faults, _("Checking for fping utility"),
437 _("The fping utility is only used if you've got a thin client based terminal environment running."),
438 $have_fping, FALSE);
440 /* Check for smb hash generation tool */
441 $query= "mkntpwd 2>&1";
442 $output= shell_exec ($query);
443 $have_mkntpwd= preg_match("/^Usage: mkntpwd /", $output);
444 $alt = 0;
446 if (!$have_mkntpwd){
447 $query= "LC_ALL=C LANG=C perl -MCrypt::SmbHash -e 'ntlmgen \"PASSWD\", \$lm, \$nt; print \"\${lm}:\${nt}\\n\";' &>/dev/null";
448 system ($query, $ret);
449 $alt= ($ret == 0);
450 }
452 $msg.= check ( $faults, _("Checking for a way to generate LM/NT password hashes"),
453 _("In order to use SAMBA 2/3, you've to install some additional packages to generate password hashes."),
454 ($have_mkntpwd || $alt));
456 /* seesio.auto_start should be off, in order to without trouble*/
457 $session_auto_start = ini_get('session.auto_start');
458 $implicit_flush = ini_get('implicit_flush');
459 $max_execution_time = ini_get('max_execution_time');
460 $memory_limit = ini_get('memory_limit');
461 $expose_php = ini_get('expose_php');
462 $magic_quotes_gpc = ini_get('magic_quotes_gpc');
463 $register_globals = ini_get('register_globals');
465 /* auto_register */
466 $msg.= check ( $faults, _("php.ini check -> session.auto_register"),
467 _("In Order to use GOsa without any trouble, the session.auto_register option in your php.ini must be set to 'Off'."), (!$session_auto_start['local_value']));
469 /* implicit_flush */
470 $msg.= check ( $faults, _("php.ini check -> implicit_flush"),
471 _("This option influences the Output handling. Turn this Option off, to increase performance."),
472 !$implicit_flush['local_value'],0,false);
474 /* max_execution_time */
475 if($max_execution_time['local_value'] < 30 ){
476 $max_execution_time['local_value']=false;
477 }
478 $msg.= check ( $faults, _("php.ini check -> max_execution_time"),
479 _("The Execution time should be at least 30 seconds, because some actions may consume more time."),
480 $max_execution_time['local_value'],0,false);
482 /* memory_limit */
483 if($memory_limit['local_value'] < 16 ){
484 $memory_limit['local_value']=false;
485 }
486 $msg.= check ( $faults, _("php.ini check -> memory_limit"),
487 _("GOsa needs at least 16MB of memory, less will cause unpredictable errors! Increase it for larger setups."),
488 !$implicit_flush['local_value'],0,false);
490 /* expose_php */
491 $msg.= check ( $faults, _("php.ini check -> expose_php"),
492 _("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."),
493 !$implicit_flush['local_value'],0,false);
495 /* magic_quotes_gpc */
496 $msg.= check ( $faults, _("php.ini check -> magic_quotes_gpc"),
497 _("Increase your server security by setting magic_quotes_gpc to 'on'. PHP will escape all quotes in strings in this case."),
498 $magic_quotes_gpc['local_value'],0,false);
500 return $msg;
501 }
504 function parse_contrib_conf()
505 {
507 $str = "";
508 $used_samba_version = 0;
509 $query = "";
510 $fp = false;
511 $output = "";
512 $needridbase_sid = false;
513 $pwdhash = "";
514 $replacements = array();
515 $ldapconf = $_SESSION['ldapconf']; // The Installation information
516 $classes = $_SESSION['classes']; // Class information needed to define which features are enabled
517 $possible_plugins = array();
519 /* Which samba version do we use? */
520 if(isset($classes['samba3'])){
521 $used_samba_version = 2;
522 } else {
523 $used_samba_version = 3;
524 }
526 /* Look for samba password generation method */
527 if(file_exists("/usr/bin/mkntpasswd")){
528 $pwdhash = "/usr/bin/mkntpasswd";
529 } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){
530 $pwdhash= "mkntpwd";
531 } else {
532 $pwdhash=('perl -MCrypt::SmbHash -e "ntlmgen \"\$ARGV[0]\", \$lm, \$nt; print \"\${lm}:\${nt}\n\";" $1');
533 }
536 /* Define which variables will be replaced */
537 $replacements['{LOCATIONNAME}'] = $ldapconf['location'];
538 $replacements['{SAMBAVERSION}'] = $used_samba_version;
539 $replacements['{LDAPBASE}'] = $ldapconf['base'];
540 $replacements['{LDAPADMIN}'] = $ldapconf['admin'];
541 $replacements['{UIDBASE}'] = $ldapconf['uidbase'];
542 $replacements['{DNMODE}'] = $ldapconf['peopledn'];
543 $replacements['{LDAPHOST}'] = $ldapconf['uri'];
544 $replacements['{PASSWORD}'] = $ldapconf['password'];
545 $replacements['{CRYPT}'] = $ldapconf['arr_cryptkeys'][$ldapconf['arr_crypts']];
546 $replacements['{SID}'] = "";
547 $replacements['{RIDBASE}'] = "";
548 if($ldapconf['mail'] != "disabled"){
549 $replacements['{MAILMETHOD}'] = $ldapconf['mail_methods'][$ldapconf['mail']];
550 }
551 $replacements['{SMBHASH}'] = $pwdhash;
552 $replacements['{GOVERNMENTMODE}']= "false";
553 $replacements['{kolabAccount}'] = "";
554 $replacements['{servKolab}'] = "";
555 $replacements['{errorlvl}'] = $ldapconf['errorlvl'];
557 /* This array contains all preg_replace syntax to delete all unused plugins
558 THE kEY MUST BE THE CLASSNAME so we can check it with $ldapconf['classes'] */
560 $possible_plugins['fonreport'][] = "'\n.*<plugin.*fonreport+.*\n.*>.*\n'i";
561 $possible_plugins['phoneaccount'][]= "'\n.*<tab.*phoneAccount.*>.*\n'i";
562 $possible_plugins['logview'][] = "'\n.*<plugin.*logview+.*\n.*>.*\n'i";
563 $possible_plugins['pureftp'][] = "'\n.*<tab.*pureftp.*>.*\n'i";
564 $possible_plugins['webdav'][] = "'\n.*<tab.*webdav.*>.*\n'i";
565 $possible_plugins['phpgroupware'][]= "'\n.*<tab.*phpgroupware.*>.*\n'i";
566 $possible_plugins['netatalk'][0] = "'\n.*<plugin.*netatalk+.*\n.*>.*\n'i";
567 $possible_plugins['netatalk'][1] = "'\n.*<tab.*netatalk.*>.*\n'i";
569 /*Header information
570 Needed to send the generated gosa.conf to the browser */
571 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
572 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
573 header("Cache-Control: no-cache");
574 header("Pragma: no-cache");
575 header("Cache-Control: post-check=0, pre-check=0");
576 header("Content-type: text/plain");
578 if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) ||
579 preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){
580 header('Content-Disposition: filename="gosa.conf"');
581 } else {
582 header('Content-Disposition: attachment; filename="gosa.conf"');
583 }
585 if(!$fp=fopen(CONFIG_TEMPLATE_DIR."/gosa.conf","r")) {
586 echo "Can't open file ".CONFIG_TEMPLATE_DIR."/gosa.conf";
587 } else {
588 while(!feof($fp)) {
589 $str.= fread($fp,512);
590 }
592 if($ldapconf['mail_methods'][$ldapconf['mail']]=="kolab") {
593 $replacements['{kolabAccount}'] ="<tab class=\"kolabAccount\" />\n ";
594 $replacements['{servKolab}'] ="<tab class=\"servkolab\" name=\"Kolab\" />";
595 }
597 if($used_samba_version == 2) {
598 /* Do nothing for samba 2... */
599 } else {
600 /* Create LDAP connection, to check if there's a domain
601 object defined in the LDAP schema */
602 $ldap= new LDAP($ldapconf['admin'], $ldapconf['password'], $ldapconf['uri']);
604 /* Try to find a Samba Domain Objekt */
605 $ldap->search("(objectClass=sambaDomain)");
607 /* Something found ??? so we need to define ridbase an SID by ourselfs */
608 if($ldap->count()< 1) {
609 $replacements['{SID}']= "sid=\"123412-11\"";
610 $replacements['{RIDBASE}']= "ridbase=\"1000\"";
611 }
612 }
614 /* Data readed, types replaced, samba version detected and checked if
615 we need to add SID and RIDBASE. Check if there is an ivbbentry in
616 the LDAP tree, in this case we will set the governmentmode to true.
617 Create LDAP connection, to check if theres a domain Objekt definen
618 in the LDAP schema. */
619 if(!isset($ldap)){
620 $ldap= new LDAP($ldapconf['admin'], $ldapconf['password'], $ldapconf['uri']);
621 }
623 /* Try to find a Samba Domain Objekt */
624 $ldap->search("(objectClass=ivbbentry)");
626 /* Something found ??? so we need to define ridbase an SID by ourselfs */
627 if($ldap->count()> 0) {
628 $replacements['{GOVERNMENTMODE}']= "true";
629 }
631 /* Replace all colleted information with placeholder */
632 foreach($replacements as $key => $val) {
633 $str = preg_replace("/".$key."/",$val,$str);
634 }
636 if($ldapconf['mail'] == "disabled"){
637 $str = str_replace("mailMethod=\"{MAILMETHOD}\"","",$str);
638 }
640 /* Remove all unused plugins */
641 foreach(array_keys($possible_plugins) as $akey) {
642 if(array_key_exists($akey,$classes)) {
643 foreach($possible_plugins[$akey] as $key=>$val) {
644 $str = preg_replace($val,"\n",$str);
645 }
646 }
647 }
648 }
650 return ((($str)));
651 }
654 /* Show setup_page 1 */
655 function show_setup_page1($withoutput = true)
656 {
657 $faults = array();
658 $smarty = get_smarty();
659 $smarty->assign ("content", get_template_path('setup_introduction.tpl'));
660 $smarty->assign ("tests", perform_php_checks($faults));
661 $smarty->assign ("detailed_tests", perform_additional_function_checks($faults));
663 /* This var is true if anything went wrong */
664 if ($faults){
665 $smarty->assign("mode", "disabled");
666 }
668 /* This line displays the template only if (withoutput is set) */
669 if($withoutput){
670 $smarty->display (get_template_path('headers.tpl'));
671 }
673 if (isset($_SESSION['errors'])){
674 $smarty->assign("errors", $_SESSION['errors']);
675 }
677 if($withoutput){
678 $smarty->display (get_template_path('setup.tpl'));
679 }
681 return (!$faults);
682 }
685 /* Show setup_page 2 */
686 function show_setup_page2($withoutput = true)
687 {
688 $faults = array();
689 $smarty = get_smarty();
690 $smarty->assign ("content", get_template_path('setup_step2.tpl'));
691 $smarty->assign ("tests", perform_additional_checks($faults));
693 if ($faults) {
694 $smarty->assign("mode", "disabled");
695 }
696 if($withoutput){
697 $smarty->display (get_template_path('headers.tpl'));
698 }
699 if (isset($_SESSION['errors'])) {
700 $smarty->assign("errors", $_SESSION['errors']);
701 }
702 if($withoutput){
703 $smarty->display (get_template_path('setup.tpl'));
704 }
706 return (!$faults);
707 }
710 function show_setup_page3($withoutput = true)
711 {
712 $ds = NULL;
713 $smarty = get_smarty();
715 /* Take the Post oder the Sessioin saved data */
716 if(isset($_POST['uri'])){
717 $uri = $_POST['uri'];
718 } elseif(isset($_SESSION['ldapconf']['uri'])){
719 $uri = $_SESSION['ldapconf']['uri'];
720 }
722 /* If Page called first time, field is empty */
723 if((!isset($uri))||(empty($uri))){
724 $uri = "ldap://localhost:389";
725 }
727 /* if isset $uri save it to session */
728 if(isset($uri)) {
729 $_SESSION['ldapconf']['uri'] = $uri;
730 $smarty->assign ("uri", validate($uri));
731 }
733 /* No error till now */
734 $fault = false;
736 /* If we pushed the Button continue */
737 if(isset($_POST['continue3'])){
738 if(!isset($uri)) {
739 $fault = true;
741 /* Output the Error */
742 if($withoutput) {
743 print_red (_("You've to specify an ldap server before continuing!"));
744 $smarty->assign ("content", get_template_path('setup_step3.tpl'));
745 }
746 }
747 } elseif (!$ds = @ldap_connect (validate($uri))) {
748 $fault =true;
750 /* Output the Error */
751 if($withoutput) {
752 print_red (_("Can't connect to the specified LDAP server! Please make sure that is reachable for GOsa."));
753 $smarty->assign ("uri", validate($uri));
754 $smarty->assign ("content", get_template_path('setup_step3.tpl'));
755 }
756 } else {
757 /* Try to bind the connection */
758 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
760 /* if we can't bind , print error */
761 if (!$r = @ldap_bind ($ds)) {
762 $fault = true;
764 /* Output the Error */
765 if($withoutput) {
766 print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
767 $smarty->assign ("content", get_template_path('setup_step3.tpl'));
768 $smarty->assign ("uri", validate($uri));
769 }
770 } else {
771 $fault = false;
772 }
773 }
775 $smarty->assign ("content", get_template_path('setup_step3.tpl'));
777 /* Load Header */
778 if($withoutput){
779 $smarty->display (get_template_path('headers.tpl'));
780 }
782 /* Set Errors to Smarty */
783 if (isset($_SESSION['errors'])) {
784 $smarty->assign("errors", $_SESSION['errors']);
785 }
787 /* Print out Template */
788 if($withoutput){
789 $smarty->display (get_template_path('setup.tpl'));
790 }
792 return (!$fault);
793 }
796 function show_setup_page4($withoutput = true)
797 {
798 $smarty= get_smarty();
800 // ?
801 if(!isset($_SESSION['ldapconf']['base'])){
802 $_SESSION['ldapconf']['base']= $base;
803 }
805 if(!isset($_SESSION['ldapconf']['base'])){
806 $_SESSION['ldapconf']['base']= $base;
807 }
808 require_once("class_password-methods.inc");
810 $fault = false;
811 $uri = $_SESSION['ldapconf']['uri'];
812 $ldapconf = $_SESSION['ldapconf'];
813 $arr_crypts= array();
814 $temp = "";
815 $checkvars = array("location", "admin", "password", "peopleou", "base",
816 "peopledn", "arr_crypts", "mail", "uidbase","errorlvl");
818 if(!isset($_SESSION['ldapconf']['arr_cryptkeys'])) {
819 require_once("class_password-methods.inc");
820 $tmp= passwordMethod::get_available_methods_if_not_loaded();
821 $_SESSION['ldapconf']['arr_cryptkeys']= $tmp['name'];
822 }
824 if(!isset($_SESSION['ldapconf']['mail_methods'])) {
825 $_SESSION['ldapconf']['mail_methods']=array();
826 $temp = get_available_mail_classes();
827 $_SESSION['ldapconf']['mail_methods']= $temp['name'];
828 }
830 /* If there are some empty vars in ldapconnect -
831 these values also represent out default values */
832 if(!$ds = @ldap_connect (validate($uri))){
833 $fault = true;
834 if($withoutput){
835 print_red (_("Can't connect to the specified LDAP server! Please make sure that is reachable for GOsa."));
836 }
837 } elseif(!@ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)){
838 $fault = true;
839 if($withoutput){
840 print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
841 }
842 } elseif(!$r= @ldap_bind ($ds)){
843 $fault = true;
844 if($withoutput){
845 print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
846 }
847 } else {
848 $sr= @ldap_search ($ds, NULL, "objectClass=*", array("namingContexts"));
849 $attr= @ldap_get_entries($ds,$sr);
851 if((empty($attr))) {
852 $base= "dc=example,dc=net";
854 if($withoutput){
855 print_red(_("Bind to server successful, but the server seems to be completly empty, please check all information twice"));
856 }
858 } else {
859 $base= $attr[0]['dn'];
860 }
861 }
863 if(!isset($_SESSION['ldapconf']['base'])){
864 $_SESSION['ldapconf']['base']= $base;
865 }
866 if(!isset($_SESSION['ldapconf']['admin'])){
867 $_SESSION['ldapconf']['admin']= "cn=ldapadmin,".$base;
868 }
869 if(!isset($_SESSION['ldapconf']['peopleou'])){
870 $_SESSION['ldapconf']['peopleou']= "ou=people";
871 }
872 if(!isset($_SESSION['ldapconf']['groupou'])){
873 $_SESSION['ldapconf']['groupou']= "ou=groups";
874 }
875 if(!isset($_SESSION['ldapconf']['peopledn'])){
876 $_SESSION['ldapconf']['peopledn']= "cn";
877 }
878 if(!isset($_SESSION['ldapconf']['password'])){
879 $_SESSION['ldapconf']['password']= "";
880 }
881 if(!isset($_SESSION['ldapconf']['location'])){
882 $_SESSION['ldapconf']['location']= "Example";
883 }
884 if(!isset($_SESSION['ldapconf']['uidbase'])){
885 $_SESSION['ldapconf']['uidbase']= "1000";
886 }
887 if(!isset($_SESSION['ldapconf']['mail'])){
888 $_SESSION['ldapconf']['mail']= 0;
889 }
890 $tmp= array_flip($_SESSION['ldapconf']['arr_cryptkeys']);
891 if(!isset($_SESSION['ldapconf']['arr_crypts'])){
892 $_SESSION['ldapconf']['arr_crypts'] = $tmp['md5'];
893 }
895 /* check POST data */
896 if(isset($_POST['check'])) {
898 /* Check if all needed vars are submitted */
899 foreach($checkvars as $key) {
900 if($key == "peopleou"){
901 continue;
902 }
903 if($key == "groupou"){
904 continue;
905 }
907 if((isset($_POST[$key]))&&($_POST[$key]!="")) {
908 $_SESSION['ldapconf'][$key] = $_POST[$key];
909 } else {
910 if($withoutput) {
911 print_red(sprintf(_("You're missing the required attribute '%s' from this formular. Please complete!"), $key));
912 }
913 $fault = true;
914 }
915 }
916 }
918 /* Transfer base */
919 if(isset($_POST['base'])){
920 $_SESSION['ldapconf']['base']= $_POST['base'];
921 }
923 $smarty->assign("arr_cryptkeys",$_SESSION['ldapconf']['arr_cryptkeys']);
924 $smarty->assign("mail_methods", $_SESSION['ldapconf']['mail_methods']);
926 foreach($_SESSION['ldapconf'] as $key => $val) {
927 $smarty->assign($key,$val);
928 }
930 if(isset($_POST['check'])) {
931 $ldap= new LDAP($_SESSION['ldapconf']['admin'],
932 $_SESSION['ldapconf']['password'],
933 $_SESSION['ldapconf']['uri']);
935 $m= schema_check($_SESSION['ldapconf']['uri'],
936 $_SESSION['ldapconf']['admin'],
937 $_SESSION['ldapconf']['password']);
938 $_SESSION['classes']= $m;
940 if(!is_schema_readable($ldapconf['uri'],$ldapconf['admin'],$ldapconf['password'])){
941 if($withoutput){
942 print_red(_("Can't read schema informations, GOsa needs to know your schema setup. Please verify that it is readable for GOsa"));
943 }
944 $fault=true;
945 }
949 if ($ldap->error != "Success") {
950 if($withoutput) {
951 print_red(sprintf(_("Can't log into LDAP server. Reason was: %s."), $ldap->get_error()));
952 }
953 $fault = true;
954 }
955 }
957 /* Set smarty output */
958 $smarty->assign ("content", get_template_path('setup_step4.tpl'));
959 $smarty->assign ("peopledns", array("cn", "uid"));
960 if($withoutput){
961 $smarty->display (get_template_path('headers.tpl'));
962 }
963 if(isset($_SESSION['errors'])) {
964 $smarty->assign("errors", $_SESSION['errors']);
965 }
966 if($withoutput){
967 $smarty->display (get_template_path('setup.tpl'));
968 }
969 return (!$fault);
970 }
973 function show_setup_page5($withoutput=true)
974 {
975 /* Get ldapconf */
976 $ldapconf= $_SESSION['ldapconf'];
978 /* get smarty */
979 $smarty = get_smarty();
981 if(isset($_SESSION['classes'])){
982 $classes = $_SESSION['classes'];
983 }
985 $info= posix_getgrgid(posix_getgid());
986 $smarty->assign("webgroup", $info['name']);
987 $smarty->assign("path", CONFIG_DIR);
988 $message= "<table summary=\"\" class=\"check\">";
989 $m= schema_check($ldapconf['uri'], $ldapconf['admin'], $ldapconf['password'],1);
991 if($withoutput) {
992 $smarty->assign ("schemas", view_schema_check($m));
993 $smarty->assign ("content", get_template_path('setup_finish.tpl'));
994 }
996 /* Output templates... */
997 if($withoutput){
998 $smarty->display (get_template_path('headers.tpl'));
999 }
1000 if (isset($_SESSION['errors'])) {
1001 $smarty->assign("errors", $_SESSION['errors']);
1002 }
1003 if($withoutput){
1004 $smarty->display (get_template_path('setup.tpl'));
1005 }
1007 return(true);
1008 }
1011 function create_user_for_setup($withoutput=true)
1012 {
1013 global $samba;
1015 $ldapconf = $_SESSION['ldapconf'];
1016 $smarty = get_smarty();
1018 $need_to_create_group = false;
1019 $need_to_create_user = false;
1021 $str_there="";
1023 if(isset($_SESSION['classes'])){
1024 $classes= $_SESSION['classes'];
1025 }
1027 /* Everything runns perfect ...
1028 So we do a last test on this page
1029 is there a user with ACLs :all which will be able to adminsitrate GOsa
1030 We check that, if this user or group is missing we ask for creating them */
1031 $ldap= new LDAP($_SESSION['ldapconf']['admin'], $_SESSION['ldapconf']['password'], $_SESSION['ldapconf']['uri']);
1033 /*
1034 Now we are testing for a group, with the rights :all
1035 */
1037 $ldap->cd($ldapconf['base']);
1038 $ldap->search("(&(objectClass=gosaObject)(gosaSubtreeACL=:all))");
1040 $group_cnt = $ldap->count();
1041 $data = $ldap->fetch();
1043 // $str_there = "Searching for Aminitrative users <br><br>";
1045 /*
1046 We need to create administrative user and group because theres no group found
1047 */
1048 if($group_cnt < 1) {
1050 /*
1051 Set var to create user
1052 */
1053 // $str_there = "no group found<br>";
1055 $need_to_create_group = true;
1056 $need_to_create_user = true;
1059 /* Output error */
1060 if(($withoutput)&&(!isset($_POST['new_admin']))){
1061 print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!"));
1062 }
1063 } else {
1065 // $str_there = "Group found <br>".$data['dn'];
1067 $need_to_create_group = false;
1069 $ldap->clearResult();
1071 /* We found an Administrative Group, is there a user, too */
1072 if(isset($data['memberUid'][0])) {
1073 $str = "uid=".$data['memberUid']['0'];
1074 $ldap->search("(&(objectClass=gosaAccount)(objectClass=person)(".$str."))");
1075 $data2 = $ldap->fetch();
1077 /* We must create a user */
1078 if (($ldap->count() < 1)||(!isset($data2))) {
1079 // $str_there.="Missing user";
1081 $need_to_create_user = true;
1083 if(($withoutput)&&(!isset($_POST['new_admin']))){
1084 print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!"));
1085 }
1086 }else {
1087 // $str_there.="<br>User found <br>".$data2['dn'];
1088 $need_to_create_user = false;
1089 }
1090 } else {
1091 $need_to_create_user=true;
1092 if(($withoutput)&&(!isset($_POST['new_admin']))){
1093 print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!"));
1094 }
1095 // $str_there.="<br>No User found <br>";
1096 }
1097 }
1099 if(!($need_to_create_user&&$need_to_create_group))
1100 return(true);
1102 /* We need to create a new user with group */
1103 if(isset($_POST['new_admin']))
1104 {
1106 /* Adjust password attributes according to the samba version */
1107 if (isset($classes['samba3'])) {
1108 $samba= "2";
1109 $lmPassword = "lmPassword";
1110 $ntPassword = "ntPassword";
1111 } else {
1112 $samba= "3";
1113 $lmPassword = "sambaLMPassword";
1114 $ntPassword = "sambaNtPassword";
1115 }
1117 /* Nothing submitted */
1118 if(((empty($_POST['admin_name']))||(empty($_POST['admin_pass'])))) {
1119 return(true);
1120 }
1122 if($need_to_create_user) {
1123 /* We have the order to create an Admin */
1124 /* Define the user we are going to create */
1125 $dn= "cn=".$_POST['admin_name'].",".$ldapconf['peopleou'].",".$ldapconf['base'];
1126 $arr['objectClass'][0] ="person";
1127 $arr['objectClass'][1] ="organizationalPerson";
1128 $arr['objectClass'][2] ="inetOrgPerson";
1129 $arr['objectClass'][3] ="gosaAccount";
1130 $arr['uid'] = $_POST['admin_name'];
1131 $arr['cn'] = $_POST['admin_name'];
1132 $arr['sn'] = $_POST['admin_name'];
1133 $arr['givenName'] = "GOsa main administrator";
1134 $arr[$lmPassword] = "10974C6EFC0AEE1917306D272A9441BB";
1135 $arr[$ntPassword] = "38F3951141D0F71A039CFA9D1EC06378";
1136 $arr['userPassword'] = crypt_single($_POST['admin_pass'],"md5");
1139 if(!$ldap->dn_exists($dn)){
1140 $ldap->cd($dn);
1141 $ldap->create_missing_trees($dn);
1142 $ldap->cd($dn);
1143 $ldap->add($arr);
1144 if($ldap->error!="Success"){
1145 print_red($ldap->error);
1146 print_red("Can't create user, and / or Group, possibly this problem depends on an empty LDAP server. Check your configuration and try again!");
1147 }
1148 }
1149 }
1151 /* There's already a group for administrator, so we only need to add the user */
1152 if(!$need_to_create_group) {
1153 if(!isset($data['memberUid'])) {
1154 $arrr['memberUid']= $_POST['admin_name'];
1155 } else {
1156 $data['memberUid'][$data['memberUid']['count']]=$_POST['admin_name'];
1157 $arrr['memberUid'] = $data['memberUid'];
1158 unset($arrr['memberUid']['count']);
1160 $tmp = array_reverse($arrr['memberUid']);
1161 foreach($tmp as $tt){
1162 $tmp2[]=$tt;
1163 }
1164 $arrr['memberUid']= $tmp2;
1165 // $str_there="Group found<br>".$data['dn'];
1166 }
1168 $ldap->cd($data['dn']);
1169 $ldap->modify($arrr);
1171 } else {
1172 $dn = "cn=administrators,".$ldapconf['groupou'].",".$ldapconf['base'];
1173 $arrr['objectClass'][0]= "gosaObject";
1174 $arrr['objectClass'][1]= "posixGroup";
1175 $arrr['gosaSubtreeACL']= ":all";
1176 $arrr['cn'] = "administrators";
1177 $arrr['gidNumber'] = "999";
1178 $arrr['memberUid'] = $_POST['admin_name'];
1180 $ldap->cd($dn);
1181 $ldap->create_missing_trees($dn);
1182 $ldap->cd($dn);
1184 $ldap->add($arrr);
1185 }
1186 return(true);
1187 } else {
1189 if((!isset($create_user))||(!($create_user))) {
1190 $smarty->assign ("content", get_template_path('setup_useradmin.tpl'));
1191 $smarty->assign("exists",true);
1192 } else {
1193 $smarty->assign ("content", get_template_path('setup_useradmin.tpl'));
1194 $smarty->assign("exists",false);
1195 }
1197 }
1199 /* Smarty output */
1200 if($withoutput){
1201 $smarty->display (get_template_path('headers.tpl'));
1202 }
1203 if (isset($_SESSION['errors'])) {
1204 $smarty->assign("errors", $_SESSION['errors']);
1205 }
1206 $smarty->assign("str_there",$str_there);
1207 if($withoutput){
1208 $smarty->display (get_template_path('setup.tpl'));
1209 }
1210 return(false);
1211 }
1214 /* Returns the classnames auf the mail classes */
1215 function get_available_mail_classes()
1216 {
1217 $dir = opendir( "../include");
1218 $methods = array();
1219 $suffix = "class_mail-methods-";
1220 $lensuf = strlen($suffix);
1221 $prefix = ".inc";
1222 $lenpre = strlen($prefix);
1224 $i = 0;
1225 while (($file = readdir($dir)) !== false){
1227 if(stristr($file,$suffix)) {
1228 $lenfile = strlen($file);
1229 $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
1230 $methods['file'][$i] = $file;
1231 $methods[$i]['file'] = $file;
1232 $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
1233 $i++;
1234 }
1236 }
1238 return($methods);
1239 }
1241 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1242 ?>