Code

Added German Translation.
[gosa.git] / include / functions_setup.inc
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, $follow_referrals=FALSE, $tls=FALSE)
34 {
35   $ldap = new LDAP($admin, $password, $server, $follow_referrals, $tls);
36   $tmp = $ldap->get_objectclasses();
38   if(count($tmp)){
39     return(true);
40   }
41   return(false);
42
44 function schema_check($server, $admin, $password, $follow_referrals=FALSE, $tls=FALSE, $aff=0, $CalledByIndexPhP=false)
45 {
46   global $config;
48   $messages= array();
49   $required_classes= array(
50       "gosaObject"            => array("version" => "2.4"),
51       "gosaAccount"           => array("version" => "2.4"),
52       "gosaLockEntry"         => array("version" => "2.4"),
53       "gosaCacheEntry"        => array("version" => "2.4"),
54       "gosaDepartment"        => array("version" => "2.4"),
56       "goFaxAccount"          => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
57       "goFaxSBlock"           => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
58       "goFaxRBlock"           => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"),
60       "gosaUserTemplate"      => array("version" => "2.4", "class" => "posixAccount","file" => "nis.schema"),
61       "gosaMailAccount"       => array("version" => "2.4", "class" => "mailAccount","file" => "gosa+samba3.schema"),
62       "gosaProxyAccount"      => array("version" => "2.4", "class" => "proxyAccount","file" => "gosa+samba3.schema"),
63       "gosaApplication"       => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
64       "gosaApplicationGroup"  => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
66       "GOhard"                => array("version" => "2.5", "class" => "terminals","file" => "goto.schema"),
67       "gotoTerminal"          => array("version" => "2.5", "class" => "terminals","file" => "goto.schema"),
68       "goServer"              => array("version" => "2.4","class" => "server","file" => "goserver.schema"),
69       "goTerminalServer"      => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
70       "goShareServer"           => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
71       "goNtpServer"           => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
72       "goSyslogServer"        => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
73       "goLdapServer"          => array("version" => "2.4"),
74       "goCupsServer"          => array("version" => "2.4", "class" => array("posixAccount", "terminals"),),
75       "goImapServer"          => array("version" => "2.4", "class" => array("mailAccount", "mailgroup"),"file" => "gosa+samba3.schema"),
76       "goKrbServer"           => array("version" => "2.4"),
77       "goFaxServer"           => array("version" => "2.4", "class" => "gofaxAccount","file" => "gofax.schema"),
78       );
80   /* Get objectclasses */
81   $ldap = new LDAP($admin,$password, $server, $follow_referrals, $tls);
82   $objectclasses = $ldap->get_objectclasses(); 
83   if(count($objectclasses) == 0){
84     return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE)));
85   }
87   /* Walk through objectclasses and check if they are needed or not */
88   foreach ($required_classes as $key => $value){
89     if (isset($value['class'])){
90       if (!is_array($value['class'])){
91         $classes= array($value['class']);
92       } else {
93         $classes= $value['class'];
94       }
96       /* Check if we are using the class that requires */
97       foreach($classes as $class){
98         if (!isset($objectclasses[$key])){
99           $messages[$key]['msg']= sprintf(_("Optional objectclass '%s' required by plugin '%s' is not present in LDAP setup"), $key, $class);
100           $messages[$key]['status'] = FALSE;
101         } else {
102           if (!check_schema_version($objectclasses[$key], $value['version'])){
103             $messages[$key]['msg']= sprintf(_("Optional objectclass '%s' required by plugin '%s' does not have version %s"), $key, $class, $value['version']);
104             $messages[$key]['needonstartup'] = TRUE;
105             $messages[$key]['status'] =FALSE;
106           }else {
107             if(!isset($affich2[$class])){
108               $affich2[$class]['msg']   = sprintf(_("Support for '%s' enabled"), $class)."<td class=\"check\"> ".$value['file']."</td>";
109               $affich2[$class]['status']= TRUE; 
110             }
111           }
112         }
114       }
115     } else {
116       /* Required class */
117       if (!isset($objectclasses[$key])){
118         $messages[$key]['msg']= sprintf(_("Required objectclass '%s' is not present in LDAP setup"), $key);
119         $messages[$key]['status'] = FALSE;  
120       } else {
121         if (!check_schema_version($objectclasses[$key], $value['version'])){
122           $messages[$key]['msg']= sprintf(_("Required objectclass '%s' does not have version %s"), $key, $value['version']);
123           $messages[$key]['status'] = FALSE;  
124           $messages[$key]['needonstartup'] = TRUE;
125         }
126     
127       }
128     }
129   }
131   /* Check for correct samba parameters */
132   if (!isset($objectclasses['sambaSamAccount'])){
133     $messages['samba3']['msg']= _("SAMBA 3 support disabled, no schema seems to be installed");
134     $affich['samba3']['msg']= $messages['samba3']['msg']."<td class=\"check\">gosa+samba3.schema</td>";
135     $messages['samba3']['status']= FALSE;
136     $affich['samba3']['status']= FALSE;
137   }else{
138     $affich['samba3']['msg']= _("SAMBA 3 support enabled")."<td class=\"check\">gosa+samba3.schema</td>";
139     $affich['samba3']['status']= TRUE;
140   }
142   if (!isset($objectclasses['sambaAccount'])){
143     $messages['samba2']['msg']= _("SAMBA 2 support disabled, no schema seems to be installed");
144     $affich['samba2']['msg']= $messages['samba2']['msg']."<td class=\"check\">samba.schema</td>";
145     $messages['samba2']['status']= FALSE;
146     $affich['samba2']['status']= FALSE;
147   }else{
148     $affich['samba2']['msg']= _("SAMBA 2 support enabled")."<td class=\"check\">samba.schema</td>";
149     $affich['samba2']['status']= TRUE;
150   }
152   /* Check pureftp/dns/ */
153   if (!isset($objectclasses['PureFTPdUser'])){
154     $messages['pureftp']['msg']= _("Support for pureftp disabled, no schema seems to be installed");
155     $affich['pureftp']['msg']= $messages['pureftp']['msg']."<td class=\"check\">pureftpd.schema</td>";
156     $messages['pureftp']['status']= FALSE;
157     $affich['pureftp']['status']= FALSE;
158   }else{
159     $affich['pureftp']['msg']= _("Support for pureftp enabled")."<td class=\"check\">pureftpd.schema</td>";
160     $affich['pureftp']['status']= TRUE;
161   }
163   if (!isset($objectclasses['gosaWebdavAccount'])){
164     $messages['webdav']['msg']= _("Support for WebDAV disabled, no schema seems to be installed");
165     $affich['webdav']['msg']= $messages['webdav']['msg']."<td class=\"check\"></td>";
166     $messages['webdav']['status']= FALSE;
167     $affich['webdav']['status']= FALSE;
168   }else{
169     $affich['webdav']['msg']=_("Support for WebDAV enabled")."<td class=\"check\">gosa+samba3.schema</td>";
170     $affich['webdav']['status']= TRUE;
171   }
173   if (!isset($objectclasses['phpgwAccount'])){
174     $messages['phpgroupware']['msg']= _("Support for phpgroupware disabled, no schema seems to be installed");
175     $affich['phpgroupware']['msg']= $messages['phpgroupware']['msg']."<td class=\"check\">phpgwaccount.schema</td>";
176     $messages['phpgroupware']['status']= FALSE;
177     $affich['phpgroupware']['status']= FALSE;
178   }else{
179     $affich['phpgroupware']['msg']= _("Support for phpgroupware enabled")."<td class=\"check\">phpgwaccount.schema</td>";
180     $affich['phpgroupware']['status']= TRUE;
181   }
182   
183   if (!isset($objectclasses['trustAccount'])){
184     $messages['trustAccount']['msg']= _("Support for trustAccount disabled, no schema seems to be installed");
185     $affich['trustAccount']['msg']= $messages['trustAccount']['msg']."<td class=\"check\">trust.schema</td>";
186     $messages['trustAccount']['status']= FALSE;
187     $affich['trustAccount']['status']= FALSE;
188   }else{
189     $affich['trustAccount']['msg']= _("Support for trustAccount enabled")."<td class=\"check\">trust.schema</td>";
190     $affich['trustAccount']['status']= TRUE;
191   }
193   if (!isset($objectclasses['goFonAccount'])){
194     $messages['phoneaccount']['msg']= _("Support for gofon disabled, no schema seems to be installed");
195     $affich['phoneaccount']['msg']= $messages['phoneaccount']['msg']."<td class=\"check\">gofon.schema</td>";
196     $messages['phoneaccount']['status']= FALSE;
197     $affich['phoneaccount']['status']= FALSE;
198   }else{
199     $affich['phoneaccount']['msg']= _("Support for gofon enabled")."<td class=\"check\">gofon.schema</td>";
200     $affich['phoneaccount']['status']= true;
201   }
203   if (!isset($objectclasses['nagiosContact'])){
204     $messages['nagioscontact']['msg']= _("Support for nagios disabled, no schema seems to be installed");
205     $affich['nagioscontact']['msg']= $messages['nagioscontact']['msg']."<td class=\"check\">nagios.schema</td>";
206     $messages['nagioscontact']['status']= FALSE;
207     $affich['nagioscontact']['status']= FALSE;
208   }else{
209     $affich['nagioscontact']['msg']= _("Support for nagios enabled")."<td class=\"check\">nagios.schema</td>";
210     $affich['nagioscontact']['status']= true;
211   }
212   
213   if ((!isset($objectclasses['apple-user'])) || (!isset($objectclasses['mount'])) ){
214     $messages['netatalk']['msg']= _("Support for netatalk disabled, no schema seems to be installed");
215     $affich['netatalk']['msg']= $messages['netatalk']['msg']."<td class=\"check\">apple.schema</td>";
216     $messages['netatalk']['status']= FALSE;
217     $affich['netatalk']['status']= FALSE;
218   }else{
219     $affich['netatalk']['msg']= _("Support for netatalk enabled")."<td class=\"check\">apple.schema</td>";
220     $affich['netatalk']['status']= true;
221   }
222   
223   /* Fix for PHP Fehler "Undefined index: ldapconf"
224    * Ablaufverfolgung[1]: Funktion schema_check Datei: /home/hickert/gosa/include/functions_setup.inc (Zeile 230)
225    */
226   if((isset($_SESSION['ldapconf']['mail_methods']))&&(isset($_SESSION['ldapconf']))){
227         if(($_SESSION['ldapconf']['mail_methods'][$_SESSION['ldapconf']['mail']] == "kolab")&&(!$CalledByIndexPhP)){
228           if(!isset($objectclasses['kolabInetOrgPerson']))  {
229             $messages['kolab']['msg']= _("Support for Kolab disabled, no schema seems to be installed, setting mail-method to cyrus");
230             $affich['kolab']['msg']=$messages['kolab']['msg']."<td class=\"check\">kolab2.schema</td>";
231             $tmp= array_flip($_SESSION['ldapconf']['mail_methods']);
232             $_SESSION['ldapconf']['mail']=$tmp['cyrus'];
233             $messages['kolab']['status']= FALSE;
234             $affich['kolab']['status']= FALSE;
235           }else{
236             $affich['kolab']['msg']=_("Support for Kolab enabled")."<td class=\"check\">gofon.schema</td>";
237             $affich['kolab']['status']= TRUE;
238           }
239         }
240   }
241   if($aff==0){
242     return ($messages);
243   } else {
244     return(array_merge($affich,$affich2));
245   }
249 function check(&$faults, $message, $description, $test, $required= TRUE)
251   $msg= "<table summary=\"\" class='check'><tr><td class='check' style='font-size:14px;'>$message</td>
252     <td rowspan=2 style='vertical-align:middle; text-align:center;width:45px;'>";
253   if ($test){
254     $msg.= _("OK")."<br>";
255   } else {
256     if (!$required){
257       $msg.="<font color=red>"._("Ignored")."</font><br>";
258     } else {
259       $msg.="<font color=red>"._("Failed")."</font><br>";
260       $faults++;
261     }
262   }
263   $msg.= "</td></tr><tr><td class='check' style='padding-left:20px;".
264     "background-color:#F0F0F0;'>$description</td></tr></table><br>";
266   return $msg;
269 function perform_php_checks(&$faults)
271   global $check_globals;
273   $faults= 0;
274   $msg= "";
276   $msg.= "<h1>"._("PHP setup inspection")."</h1>";
278   $msg.= check (        $faults, _("Checking for PHP version (>=4.1.0)"),
279       _("PHP must be of version 4.1.0 or above for some functions and known bugs in PHP language."),
280       version_compare(phpversion(), "4.1.0")>=0);
282   $msg.= check (        $faults, _("Checking if register_globals is set to 'off'"),
283       _("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."),
284       $check_globals == 0, FALSE);
285   
286   $msg.= check (  $faults, _("PHP session.gc_maxlifetime (>= 86400 seconds)."),
287       _("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."),
288       ini_get("session.gc_maxlifetime") >= 86400,FALSE);
290   $msg.= check (        $faults, _("Checking for ldap module"),
291       _("This is the main module used by GOsa and therefore really required."),
292       is_callable('ldap_bind'));
294   $msg.= check (  $faults, _("Checking for XML functions"),
295       _("XML functions are required to parse the configuration file."),
296       is_callable('xml_parser_create'));
298   $msg.= check (        $faults, _("Checking for gettext support"),
299       _("Gettext support is required for internationalized GOsa."),
300       is_callable('bindtextdomain'));
302   $msg.= check (        $faults, _("Checking for iconv support"),
303       _("This module is used by GOsa to convert samba munged dial informations and is therefore required."),
304       is_callable('iconv'));
306   $msg.= check (        $faults, _("Checking for mhash module"),
307       _("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."),
308       is_callable('mhash'), FALSE);
310   $msg.= check (        $faults, _("Checking for imap module"),
311       _("The IMAP module is needed to communicate with the IMAP server. It gets status informations, creates and deletes mail users."),
312       is_callable('imap_open'));
314   $msg.= check (        $faults, _("Checking for getacl in imap"),
315       _("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."),
316       is_callable('imap_getacl'), FALSE);
318   $msg.= check (        $faults, _("Checking for mysql module"),
319       _("MySQL support is needed for reading GOfax reports from databases."),
320       is_callable('mysql_query'), FALSE);
322   $msg.= check (        $faults, _("Checking for cups module"),
323       _("In order to read available printers from IPP protocol instead of printcap files, you've to install the CUPS module."),
324       is_callable('cups_get_dest_list'), FALSE);
326   $msg.= check (        $faults, _("Checking for kadm5 module"),
327       _("Managing users in kerberos requires the kadm5 module which is downloadable via PEAR network."),
328       is_callable('kadm5_init_with_password'), FALSE);
330   $msg.= check (  $faults, _("Checking for snmp Module"),
331       _("Simple Network Management Protocol (SNMP) is required for client monitoring."),
332       is_callable('snmpget'), FALSE);
334   return ($msg);
337 function get_link($function_name) {
338   $result= "<a href='http://de.php.net/manual/en/function.";
340   /* Replace all underscores with hyphens (phpdoc convention) */
341   /* hjb: added alternative check for GraphicsMagick >= 1.1.2 */
342   $function_name= str_replace("_", "-", $function_name);
344   /* Append to base URL */
345   $result.= $function_name.".php'>$function_name</a>";
347   return $result;
350 function perform_additional_function_checks(&$faults) {
351   global $check_globals;
353   $faults= 0;
354   $msg= "";
355   $functions= array();
356   
357   $functions_list= '../include/functions_list.inc';
359   /* Make sure that we can read the file */
360   if(is_readable($functions_list)) {
361     /* Open filehandle */
362     $fh= fopen($functions_list,'rb');
363     if($fh!=null) {
364       $functions= eval(fread($fh,filesize($functions_list)));
365     }
366   }
368   $msg.= "<h1>"._("PHP detailed function inspection")."</h1>";
369   /* Only print message, if function is not callable */
370   foreach($functions as $key => $fn_name) {
371     if(!is_callable($fn_name)) {
372       $msg.= check ($faults, sprintf(_("Checking for function %s"), "<b>".get_link($fn_name)."</b>"),
373         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>"),
374         is_callable($fn_name), false);
375     }
376   }
377   return $msg;
380 function perform_additional_checks(&$faults)
382   $ret = NULL;
383   /* Programm check */
384   $msg= "<h1>"._("Checking for some additional programms")."</h1>";
386   /* Image Magick */
387   $query= "LC_ALL=C LANG=C convert -help";
388   $output= shell_exec ($query);
389   if ($output != ""){
390     $lines= split ("\n", $output);
391     $version= preg_replace ("/^Version: (.+Magick) ([^\s]+).*/", "\\1 \\2", $lines[0]);
392     list($prog, $version) = split(" ", $version);
393     list($major, $minor,$minor2)= split("\.", $version);
394     if (preg_match('/GraphicsMagick/', $prog)) {
395       $msg.= check (    $faults, _("Checking for GraphicsMagick (>=1.1.2)"),
396           _("GraphicsMagick is used to convert user supplied images to fit the suggested size and the unified JPEG format."),
397           ($major > 1 || ($major == 1 && $minor >= 1) || ($major == 1 && $minor == 1 && $minor2 >= 2) ) );
398     } else {
399       $msg.= check (    $faults, _("Checking for ImageMagick (>=5.4.0)"),
400           _("ImageMagick is used to convert user supplied images to fit the suggested size and the unified JPEG format."),
401           ($major > 5 || ($major == 5 && $minor >= 4)));
402         }
403   } else {
404     $msg.= check (      $faults, _("Checking imagick module for PHP"),
405         _("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);
406   }
408   /* Check for fping */
409   $query= "LC_ALL=C LANG=C fping -v 2>&1";
410   $output= shell_exec ($query);
411   $have_fping= preg_match("/^fping:/", $output);
412   $msg.= check (        $faults, _("Checking for fping utility"),
413       _("The fping utility is only used if you've got a thin client based terminal environment running."),
414       $have_fping, FALSE);
416   /* Check for smb hash generation tool */
417   $query= "mkntpwd 2>&1";
418   $output= shell_exec ($query);
419   $have_mkntpwd= preg_match("/^Usage: mkntpwd /", $output);
420   $alt = 0;
422   if (!$have_mkntpwd){
423     $query= 'LC_ALL=C LANG=C perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen \$ARGV[0]), $/;" &>/dev/null';
424     system ($query, $ret);
425     $alt= ($ret == 0);
426   }
428   $msg.= check (        $faults, _("Checking for a way to generate LM/NT password hashes"),
429       _("In order to use SAMBA 2/3, you've to install some additional packages to generate password hashes."),
430       ($have_mkntpwd || $alt));
432   /* seesio.auto_start should be off, in order to without trouble*/
433   $session_auto_start = ini_get('session.auto_start');
434   $implicit_flush     = ini_get('implicit_flush');
435   $max_execution_time = ini_get('max_execution_time');
436   $memory_limit       = ini_get('memory_limit');
437   $expose_php         = ini_get('expose_php');
438   $magic_quotes_gpc   = ini_get('magic_quotes_gpc');
439   $register_globals   = ini_get('register_globals');
441   /* auto_register */
442   $msg.= check (  $faults, _("php.ini check -> session.auto_register"),
443       _("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']));
445   /* implicit_flush */
446   $msg.= check (  $faults, _("php.ini check -> implicit_flush"),
447       _("This option influences the Output handling. Turn this Option off, to increase performance."),
448       !$implicit_flush['local_value'],0,false);
450   /* max_execution_time */
451   if($max_execution_time['local_value'] < 30 ){
452     $max_execution_time['local_value']=false;
453   }
454   $msg.= check (  $faults, _("php.ini check -> max_execution_time"),
455       _("The Execution time should be at least 30 seconds, because some actions may consume more time."),
456       $max_execution_time['local_value'],0,false);
458   /* memory_limit */
459   if($memory_limit['local_value'] < 16 ){
460     $memory_limit['local_value']=false;
461   }
462   $msg.= check (  $faults, _("php.ini check -> memory_limit"),
463       _("GOsa needs at least 16MB of memory, less will cause unpredictable errors! Increase it for larger setups."),
464       !$implicit_flush['local_value'],0,false);
466   /* expose_php */
467   $msg.= check (  $faults, _("php.ini check -> expose_php"),
468       _("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."),
469       !$implicit_flush['local_value'],0,false);
471   /* magic_quotes_gpc */
472   $msg.= check (  $faults, _("php.ini check -> magic_quotes_gpc"),
473       _("Increase your server security by setting magic_quotes_gpc to 'on'. PHP will escape all quotes in strings in this case."),
474       $magic_quotes_gpc['local_value'],0,false);
476   return $msg;
480 function parse_contrib_conf()
483   $str                = "";
484   $used_samba_version = 0;
485   $query              = ""; 
486   $fp                 = false;
487   $output             = "";
488   $needridbase_sid    = false;
489   $pwdhash            = "";
490   $replacements       = array();
491   $ldapconf           = $_SESSION['ldapconf']; // The Installation information
492   $classes            = $_SESSION['classes'];  // Class information needed to define which features are enabled
493   $possible_plugins   = array();
495   /* Which samba version do we use? */
496   if(isset($classes['samba3'])){
497     $used_samba_version = 2;
498   } else {
499     $used_samba_version = 3;
500   }
502   /* Look for samba password generation method */
503   if(file_exists("/usr/bin/mkntpasswd")){
504     $pwdhash  = "/usr/bin/mkntpasswd";
505   } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){
506     $pwdhash= "mkntpwd";
507   } else {
508     $pwdhash= 'perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen \$ARGV[0]), $/;"';
509   }
512   /* Define which variables will be replaced */
513   $replacements['{LOCATIONNAME}']  = $ldapconf['location'];
514   $replacements['{SAMBAVERSION}']  = $used_samba_version;
515   $replacements['{LDAPBASE}']      = $ldapconf['base'];
516   $replacements['{LDAPADMIN}']     = $ldapconf['admin'];
517   $replacements['{UIDBASE}']       = $ldapconf['uidbase'];
518   $replacements['{DNMODE}']        = $ldapconf['peopledn'];
519   $replacements['{LDAPHOST}']      = $ldapconf['uri'];
520   $replacements['{PASSWORD}']      = $ldapconf['password'];
521   $replacements['{CRYPT}']         = $ldapconf['arr_cryptkeys'][$ldapconf['arr_crypts']];
522   $replacements['{SID}']         = "";
523   $replacements['{RIDBASE}']     = "";
524   if($ldapconf['mail'] != "disabled"){
525     $replacements['{MAILMETHOD}']    = $ldapconf['mail_methods'][$ldapconf['mail']];
526   }   
527   $replacements['{SMBHASH}']       = $pwdhash;
528   $replacements['{GOVERNMENTMODE}']= "false"; 
529   $replacements['{kolabAccount}']  = "";
530   $replacements['{servKolab}']     = "";
531   $replacements['{errorlvl}']     = $ldapconf['errorlvl'];
533   /* This array contains all preg_replace syntax to delete all unused plugins
534      THE kEY MUST BE THE CLASSNAME so we can check it with $ldapconf['classes'] */
536   $possible_plugins['fonreport'][]   = "'\n.*<plugin.*fonreport+.*\n.*>.*\n'i";
537   $possible_plugins['phoneaccount'][]= "'\n.*<tab.*phoneAccount.*>.*\n'i";
538   $possible_plugins['logview'][]     = "'\n.*<plugin.*logview+.*\n.*>.*\n'i";
539   $possible_plugins['pureftp'][]     = "'\n.*<tab.*pureftp.*>.*\n'i";
540   $possible_plugins['webdav'][]      = "'\n.*<tab.*webdav.*>.*\n'i";
541   $possible_plugins['phpgroupware'][]= "'\n.*<tab.*phpgroupware.*>.*\n'i";
542   $possible_plugins['netatalk'][0]    = "'\n.*<plugin.*netatalk+.*\n.*>.*\n'i";
543   $possible_plugins['netatalk'][1]    = "'\n.*<tab.*netatalk.*>.*\n'i";
545   /*Header information
546      Needed to send the generated gosa.conf to the browser */
547   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
548   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
549   header("Cache-Control: no-cache");
550   header("Pragma: no-cache");
551   header("Cache-Control: post-check=0, pre-check=0");
552   header("Content-type: text/plain");
554   if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) ||
555       preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){
556     header('Content-Disposition: filename="gosa.conf"');
557   } else {
558     header('Content-Disposition: attachment; filename="gosa.conf"');
559   }
561   if(!$fp=fopen(CONFIG_TEMPLATE_DIR."/gosa.conf","r")) {
562     echo "Can't open file ".CONFIG_TEMPLATE_DIR."/gosa.conf";
563   } else {
564     while(!feof($fp)) {
565       $str.= fread($fp,512);
566     }
568     if($ldapconf['mail_methods'][$ldapconf['mail']]=="kolab") {
569       $replacements['{kolabAccount}']  ="<tab class=\"kolabAccount\" />\n     ";
570       $replacements['{servKolab}']     ="<tab class=\"servkolab\" name=\"Kolab\" />";
571     }
573     if($used_samba_version == 2) {
574       /* Do nothing for samba 2... */
575     } else {
576       /* Create LDAP connection, to check if there's a domain
577          object defined in the LDAP schema */
578       $ldap= new LDAP($ldapconf['admin'], $ldapconf['password'], $ldapconf['uri']);
580       /* Try to find a Samba Domain Objekt */
581       $ldap->search("(objectClass=sambaDomain)");
582     
583       /* Something found ??? so we need to define ridbase an SID by ourselfs */
584       if($ldap->count()< 1) {
585         $replacements['{SID}']= "sid=\"123412-11\"";
586         $replacements['{RIDBASE}']= "ridbase=\"1000\"";  
587       } 
588     }
590     /* Data readed, types replaced, samba version detected and checked if
591        we need to add SID and RIDBASE. Check if there is an ivbbentry in
592        the LDAP tree, in this case we will set the governmentmode to true.
593        Create LDAP connection, to check if theres a domain Objekt definen
594        in the LDAP schema. */
595     if(!isset($ldap)){
596       $ldap= new LDAP($ldapconf['admin'], $ldapconf['password'], $ldapconf['uri']);
597     }
599     /* Try to find a Samba Domain Objekt */
600     $ldap->search("(objectClass=ivbbentry)");
602     /* Something found ??? so we need to define ridbase an SID by ourselfs */
603     if($ldap->count()> 0) {
604       $replacements['{GOVERNMENTMODE}']= "true";
605     }
607     /* Replace all colleted information with placeholder */
608     foreach($replacements as $key => $val) {
609       $str = preg_replace("/".$key."/",$val,$str);
610     }    
612     if($ldapconf['mail'] == "disabled"){
613       $str = str_replace("mailMethod=\"{MAILMETHOD}\"","",$str);
614     }
616     /* Remove all unused plugins */
617     foreach(array_keys($possible_plugins) as $akey) {
618       if(array_key_exists($akey,$classes)) {
619         foreach($possible_plugins[$akey] as $key=>$val) {
620           $str = preg_replace($val,"\n",$str);
621         }
622       }
623     }
624   }
626   return ((($str)));
630 /* Show setup_page 1 */
631 function show_setup_page1($withoutput = true)
633   $faults   = false;
634   $faults2  = false;
635   $smarty = get_smarty();  
636   $smarty->assign ("content", get_template_path('setup_introduction.tpl'));
637   $smarty->assign ("tests", perform_php_checks($faults));
638   $smarty->assign ("detailed_tests", perform_additional_function_checks($faults2));
640   $faults = $faults || $faults2;
642   /* This var is true if anything went wrong */
643   if ($faults){
644     $smarty->assign("mode", "disabled");
645   }
647   /* This line displays the template only if (withoutput is set) */
648   if($withoutput){
649     $smarty->display (get_template_path('headers.tpl'));
650   }
652   if (isset($_SESSION['errors'])){
653     $smarty->assign("errors", $_SESSION['errors']);
654   }
656   if($withoutput){
657     $smarty->display (get_template_path('setup.tpl'));
658   }
660   return ($faults);
664 /* Show setup_page 2 */
665 function show_setup_page2($withoutput = true)
667   $faults = false;
668   $smarty = get_smarty();
669   $smarty->assign ("content", get_template_path('setup_step2.tpl'));
670   $smarty->assign ("tests", perform_additional_checks($faults));
672   if ($faults) {
673     $smarty->assign("mode", "disabled");
674   }
675   if($withoutput){
676     $smarty->display (get_template_path('headers.tpl'));
677   }
678   if (isset($_SESSION['errors']))  {
679     $smarty->assign("errors", $_SESSION['errors']);
680   }
681   if($withoutput){
682     $smarty->display (get_template_path('setup.tpl'));
683   }
685   return ($faults);                               
689 function show_setup_page3($withoutput = true)
691   $ds = NULL;
692   $smarty = get_smarty();
694   /* Take the Post oder the Sessioin saved data */
695   if(isset($_POST['uri'])){
696     $uri = $_POST['uri'];
697   } elseif(isset($_SESSION['ldapconf']['uri'])){
698     $uri = $_SESSION['ldapconf']['uri'];
699   }
701   /* If Page called first time, field is empty */
702   if((!isset($uri))||(empty($uri))){
703     $uri = "ldap://localhost:389";
704   }
706   /* if isset $uri save it to session */
707   if(isset($uri)) {
708     $_SESSION['ldapconf']['uri'] = $uri;
709     $smarty->assign ("uri", validate($uri));
710   }
712   /* No error till now */
713   $fault = false;
715   if (!$ds = @ldap_connect (validate($uri))) {
716     $fault =true;
718     /* Output the Error */
719     if($withoutput) {
720       print_red (_("Can't connect to the specified LDAP server! Please make sure that is reachable for GOsa."));
721       $smarty->assign ("uri", validate($uri));
722       $smarty->assign ("content", get_template_path('setup_step3.tpl'));
723     }
724   } else {
725     /* Try to bind the connection */    
726     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
728     /* if we can't bind , print error */
729     if (!$r  =  @ldap_bind ($ds)) {
730       $fault = true;
732       /* Output the Error */
733       if($withoutput) {
734         print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
735         $smarty->assign ("content", get_template_path('setup_step3.tpl'));
736         $smarty->assign ("uri", validate($uri));
737       }
738     } else {
739       $fault = false;
740     }
741   }
743   $smarty->assign ("content", get_template_path('setup_step3.tpl'));
745   /* Load Header */
746   if($withoutput){
747     $smarty->display (get_template_path('headers.tpl'));
748   }
750   /* Set Errors to Smarty */
751   if (isset($_SESSION['errors'])) {
752     $smarty->assign("errors", $_SESSION['errors']);
753   }
755   /* Print out Template */ 
756   if($withoutput){
757     $smarty->display (get_template_path('setup.tpl'));
758   }
760   return ($fault);                             
764 function show_setup_page4($withoutput = true)
766   $smarty= get_smarty();      
767   $checkvars = array("location", "admin", "password", "peopleou", "base",
768       "peopledn", "arr_crypts", "uidbase","errorlvl");
770   $fault     = false;              
771   $uri       = $_SESSION['ldapconf']['uri'];
772   $ldapconf  = $_SESSION['ldapconf'];
773   $arr_crypts= array();
774   $temp      = "";
776   /* check POST data */
777   if(isset($_POST['check'])) {
779     /* Check if all needed vars are submitted */
780     foreach($checkvars as $key) {
781       if($key == "peopleou"){
782         continue;
783       }
784       if($key == "groupou"){
785         continue;
786       }
788       if((isset($_POST[$key]))&&(!empty($_POST[$key]))) {
789         $_SESSION['ldapconf'][$key] = $_POST[$key];
790       } else {
791         if($withoutput) {
792           print_red(sprintf(_("You're missing the required attribute '%s' from this formular. Please complete!"), $key));
793         }
794         $fault = true;
795       }
796     }
797   }
799   /* Transfer base */
800   if(isset($_POST['base'])){
801     $_SESSION['ldapconf']['base']= $_POST['base'];
802   }
804         // ?
805   if(!isset($_SESSION['ldapconf']['base'])){
806     $_SESSION['ldapconf']['base']= $base;
807   }
809   if(!isset($_SESSION['ldapconf']['base'])){
810     $_SESSION['ldapconf']['base']= $base;
811   }
812   require_once("class_password-methods.inc");
814   if(!isset($_SESSION['ldapconf']['arr_cryptkeys'])) {
815     require_once("class_password-methods.inc");
816     $tmp= passwordMethod::get_available_methods_if_not_loaded();
817     $_SESSION['ldapconf']['arr_cryptkeys']= $tmp['name'];
818   }
820   if(!isset($_SESSION['ldapconf']['mail_methods'])) {
821     $_SESSION['ldapconf']['mail_methods']=array();
822     $temp = get_available_mail_classes();
823     $_SESSION['ldapconf']['mail_methods']= $temp['name'];
824   }
826   /* If there are some empty vars in ldapconnect -
827      these values also represent out default values */
828   if(!$ds =  @ldap_connect (validate($uri))){
829     $fault = true;
830     if($withoutput){
831       print_red (_("Can't connect to the specified LDAP server! Please make sure that is reachable for GOsa."));
832     }
833   } elseif(!@ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)){
834     $fault = true;
835     if($withoutput){
836       print_red (_("Can't set ldap protocol version 3."));
837     }
838   } elseif(!$r= @ldap_bind ($ds)){
839     $fault = true;
840     if($withoutput){
841       print_red (_("Could not bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
842     }
843   } else {
844     $sr=   @ldap_search ($r, NULL, "objectClass=*", array("namingContexts"));
845     $attr= @ldap_get_entries($ds,$sr);
847     if((empty($attr))) {
849       if($withoutput){
850 #        print_red(_("Bind to server successful, but the server seems to be completly empty, please check all information twice"));
851       }
853     } else {
854       $base= $attr[0]['dn'];
855     }
856   }
858   if(!isset($_SESSION['ldapconf']['base'])){
859     $_SESSION['ldapconf']['base']= $base;
860   }
861   if(!isset($_SESSION['ldapconf']['admin'])){
862     $_SESSION['ldapconf']['admin']= "cn=ldapadmin,".$base;
863   }
864   if(!isset($_SESSION['ldapconf']['peopleou'])){
865     $_SESSION['ldapconf']['peopleou']= "ou=people";
866   }
867   if(!isset($_SESSION['ldapconf']['groupou'])){
868     $_SESSION['ldapconf']['groupou']= "ou=groups";
869   }
870   if(!isset($_SESSION['ldapconf']['peopledn'])){
871     $_SESSION['ldapconf']['peopledn']= "cn";
872   }
873   if(!isset($_SESSION['ldapconf']['password'])){
874     $_SESSION['ldapconf']['password']= "";
875   }
876   if(!isset($_SESSION['ldapconf']['location'])){
877     $_SESSION['ldapconf']['location']= "Example";
878   }
879   if(!isset($_SESSION['ldapconf']['uidbase'])){
880     $_SESSION['ldapconf']['uidbase']= "1000";
881   }
882   if(!isset($_SESSION['ldapconf']['mail'])){
883     $_SESSION['ldapconf']['mail']= 0;
884   }
885   if(!isset($_SESSION['ldapconf']['follow_referrals'])){
886     $_SESSION['ldapconf']['follow_referrals']= FALSE;
887   }
888   if(!isset($_SESSION['ldapconf']['tls'])){
889     $_SESSION['ldapconf']['tls']= FALSE;
890   }
892   $tmp= array_flip($_SESSION['ldapconf']['arr_cryptkeys']);
893   if(!isset($_SESSION['ldapconf']['arr_crypts'])){
894     $_SESSION['ldapconf']['arr_crypts']   = $tmp['md5'];
895   }
897   $smarty->assign("arr_cryptkeys",$_SESSION['ldapconf']['arr_cryptkeys']);
898   $smarty->assign("mail_methods", $_SESSION['ldapconf']['mail_methods']);
900   foreach($_SESSION['ldapconf'] as $key => $val) {
901     $smarty->assign($key,$val);
902   }
904   if(isset($_POST['check']) || (isset($_POST['admin'])) && isset($_POST['password'])) {
905     $ldap= new LDAP($_SESSION['ldapconf']['admin'],
906         $_SESSION['ldapconf']['password'],
907         $_SESSION['ldapconf']['uri'],
908         $_SESSION['ldapconf']['follow_referrals'],
909         $_SESSION['ldapconf']['tls']);
911     $m= schema_check($_SESSION['ldapconf']['uri'],
912         $_SESSION['ldapconf']['admin'],
913         $_SESSION['ldapconf']['password'],
914         $_SESSION['ldapconf']['follow_referrals'],
915         $_SESSION['ldapconf']['tls']);
917     $_SESSION['classes']= $m;
919     //TODO: Ask user for referrals and TLS config options during setup. They are initialized to false at the moment:
920     $ldapconf['follow_referrals'] = false;
921     $ldapconf['tls'] = false;
922     if(!is_schema_readable($ldapconf['uri'], $ldapconf['admin'], $ldapconf['password'], $ldapconf['follow_referrals'], $ldapconf['tls'])){
923       if($withoutput){
924         print_red(_("Can't read schema informations, GOsa needs to know your schema setup. Please verify that it is readable for GOsa"));
925       }
926       $fault=true;
927     }
931     if ($ldap->error != "Success") {
932       if($withoutput) {
933         print_red(sprintf(_("Can't log into LDAP server. Reason was: %s."), $ldap->get_error()));
934       }
935       $fault = true;
936     }
937   }
939   /* Set smarty output */
940   $smarty->assign ("content", get_template_path('setup_step4.tpl'));
941   $smarty->assign ("peopledns", array("cn", "uid"));
942   if($withoutput){
943     $smarty->display (get_template_path('headers.tpl'));
944   }
945   if(isset($_SESSION['errors'])) {
946     $smarty->assign("errors", $_SESSION['errors']);
947   }
948   if($withoutput){
949     $smarty->display (get_template_path('setup.tpl'));
950   }
952   return ($fault);
956 function show_setup_page5($withoutput=true)
958   /* Get ldapconf */
959   $ldapconf= $_SESSION['ldapconf'];
961   /* get smarty */
962   $smarty = get_smarty();
964   if(isset($_SESSION['classes'])){
965     $classes = $_SESSION['classes'];
966   }
968   $info= posix_getgrgid(posix_getgid());
969   $smarty->assign("webgroup", $info['name']);
970   $smarty->assign("path", CONFIG_DIR);
971   $message= "<table summary=\"\" class=\"check\">";
973   //TODO:Ask user for referral and TLS config options during setup. They are initialized to false at the moment:
974   $ldapconf['follow_referrals'] = false;
975   $ldapconf['tls'] = false;
977   $m= schema_check($ldapconf['uri'], $ldapconf['admin'], $ldapconf['password'], $ldapconf['follow_referrals'], $ldapconf['tls'], 1);
979   if($withoutput) {
980     $smarty->assign ("schemas", view_schema_check($m));
981     $smarty->assign ("content", get_template_path('setup_finish.tpl'));
982   }
984   /* Output templates... */
985   if($withoutput){
986     $smarty->display (get_template_path('headers.tpl'));
987   }
988   if (isset($_SESSION['errors'])) {
989     $smarty->assign("errors", $_SESSION['errors']);
990   }
991   if($withoutput){
992     $smarty->display (get_template_path('setup.tpl'));
993   }
995   return(true);
999 function create_user_for_setup($withoutput=true)
1001   global $samba;
1003   $ldapconf = $_SESSION['ldapconf'];
1004   $smarty = get_smarty();
1005   
1006   $need_to_create_group = false;
1007   $need_to_create_user  = false;
1009   $str_there="";
1011   if(isset($_SESSION['classes'])){
1012     $classes= $_SESSION['classes'];
1013   }
1015   /* Everything runns perfect ...
1016      So we do a last test on this page
1017      is there a user with ACLs :all which will be able to adminsitrate GOsa
1018      We check that, if this user or group is missing we ask for creating them */
1019   $ldap= new LDAP($_SESSION['ldapconf']['admin'],    $_SESSION['ldapconf']['password'],   $_SESSION['ldapconf']['uri']);
1021   /* Now we are testing for a group, with the rights :all  */
1022   $ldap->cd($ldapconf['base']);
1023   $ldap->search("(&(objectClass=gosaObject)(gosaSubtreeACL=:all))");
1025   $group_cnt  = $ldap->count();
1026   $data       = $ldap->fetch();
1028   /* We need to create administrative user and group  because there was no group found */
1029   if($group_cnt < 1) {
1030     
1031     $need_to_create_group = true;
1032     $need_to_create_user  = true;
1034     /* Output error */
1035 #    if(($withoutput)&&(!isset($_POST['new_admin']))){
1036 #      print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!"));
1037 #    }
1038   } else {
1039     
1040     $need_to_create_group = false;
1041     $ldap->clearResult();
1042    
1043     /* We found an Administrative Group, is there a user too ? */
1044     if(isset($data['memberUid'][0])) {
1045       $str      = "uid=".$data['memberUid']['0'];
1046       $ldap->search("(&(objectClass=gosaAccount)(objectClass=person)(".$str."))");
1047       $data2    = $ldap->fetch();
1048   
1049       /* We must create a user */
1050       if (($ldap->count() < 1)||(!isset($data2))) {
1051         $need_to_create_user = true;
1052 #        if(($withoutput)&&(!isset($_POST['new_admin']))){
1053 #          print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!"));
1054 #        }
1055       }else {
1056         $need_to_create_user = false;
1057       }
1058     } else {
1059       $need_to_create_user=true;
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     }
1064   }
1066   if(!($need_to_create_user&&$need_to_create_group))
1067     return(true);
1069   /* We need to create a new user with group */
1070   if(isset($_POST['new_admin']))
1071   {
1072   
1073     /* Adjust password attributes according to the samba version */
1074     if (isset($classes['samba3'])) {
1075       $samba= "2";
1076       $lmPassword = "lmPassword";
1077       $ntPassword = "ntPassword";
1078     } else {
1079       $samba= "3";
1080       $lmPassword = "sambaLMPassword";
1081       $ntPassword = "sambaNtPassword";
1082     }
1084     /* Nothing submitted */
1085     if(((empty($_POST['admin_name']))||(empty($_POST['admin_pass'])))) {
1086       return(true);
1087     }
1089     if($need_to_create_user) {
1090       /* We have the order to create an Admin */
1091       /* Define the user we are going to create */
1092       $dn= "cn=".$_POST['admin_name'].",".$ldapconf['peopleou'].",".$ldapconf['base'];
1093       $arr['objectClass'][0] ="person";
1094       $arr['objectClass'][1] ="organizationalPerson";
1095       $arr['objectClass'][2] ="inetOrgPerson";
1096       $arr['objectClass'][3] ="gosaAccount";
1097       $arr['uid']            = $_POST['admin_name'];
1098       $arr['cn']             = $_POST['admin_name'];
1099       $arr['sn']             = $_POST['admin_name'];
1100       $arr['givenName']      = "GOsa main administrator";
1101       $arr[$lmPassword]      = "10974C6EFC0AEE1917306D272A9441BB";
1102       $arr[$ntPassword]      = "38F3951141D0F71A039CFA9D1EC06378";
1103       $arr['userPassword']   = crypt_single($_POST['admin_pass'],"md5");
1104     
1106       if(!$ldap->dn_exists($dn)){ 
1107         $ldap->cd($dn); 
1108         $ldap->create_missing_trees($dn);
1109         $ldap->cd($dn);
1110         $ldap->add($arr);
1111         if($ldap->error!="Success"){
1112           show_ldap_error($ldap->get_error(),_("User and/or group could not be created, please check your configuration twice !"));
1113         }
1114       }    
1115     }
1117     /* There's already a group for administrator, so we only need to add the user */
1118     if(!$need_to_create_group) {
1119       if(!isset($data['memberUid'])) {
1120         $arrr['memberUid']= $_POST['admin_name'];
1121       } else {
1122         $data['memberUid'][$data['memberUid']['count']]=$_POST['admin_name'];
1123         $arrr['memberUid'] = $data['memberUid'];
1124         unset($arrr['memberUid']['count']);
1125   
1126         $tmp = array_reverse($arrr['memberUid']);    
1127         foreach($tmp as $tt){
1128           $tmp2[]=$tt;
1129         }
1130         $arrr['memberUid']= $tmp2;
1131 //        $str_there="Group found<br>".$data['dn'];
1132       }
1134       $ldap->cd($data['dn']);
1135       $ldap->modify($arrr);
1137     } else {
1138       $dn                    = "cn=administrators,".$ldapconf['groupou'].",".$ldapconf['base'];
1139       $arrr['objectClass'][0]= "gosaObject";
1140       $arrr['objectClass'][1]= "posixGroup";
1141       $arrr['gosaSubtreeACL']= ":all";
1142       $arrr['cn']            = "administrators";
1143       $arrr['gidNumber']     = "999";
1144       $arrr['memberUid']     = $_POST['admin_name'];
1146       $ldap->cd($dn);
1147       $ldap->create_missing_trees($dn);
1148       $ldap->cd($dn);
1150       $ldap->add($arrr);
1151     }
1152     return(true);
1153   } else {
1155     if((!isset($need_to_create_user))||(!($need_to_create_user))) {
1156       $smarty->assign ("content", get_template_path('setup_useradmin.tpl'));
1157       $smarty->assign("exists",true);
1158     } else {
1159       $smarty->assign ("content", get_template_path('setup_useradmin.tpl'));
1160       $smarty->assign("exists",false);
1161     }
1163   }
1165   /* Smarty output */ 
1166   if($withoutput){
1167     $smarty->display (get_template_path('headers.tpl'));
1168   }
1169   if (isset($_SESSION['errors'])) {
1170     $smarty->assign("errors", $_SESSION['errors']);
1171   }
1172   $smarty->assign("str_there",$str_there);
1173   if($withoutput){
1174     $smarty->display (get_template_path('setup.tpl'));
1175   }
1176   return(false);
1180 /* Returns the classnames auf the mail classes */
1181 function get_available_mail_classes()
1183   $dir = opendir( "../include");
1184   $methods = array();
1185   $suffix = "class_mail-methods-";
1186   $lensuf = strlen($suffix);
1187   $prefix = ".inc";
1188   $lenpre = strlen($prefix);
1190   $i = 0;
1191   while (($file = readdir($dir)) !== false){
1193     if(stristr($file,$suffix)) {
1194       $lenfile = strlen($file);
1195       $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
1196       $methods['file'][$i] = $file;
1197       $methods[$i]['file'] = $file;
1198       $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
1199       $i++;
1200     }
1202   }
1204   return($methods);
1207 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1208 ?>