Code

Added check for trust.schema
[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)
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.4", "class" => "terminals","file" => "goto.schema"),
82       "gotoTerminal"          => array("version" => "2.0", "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         }
163     
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   }
219   
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   }
249   
250   /* Fix for PHP Fehler "Undefined index: ldapconf"
251    * Ablaufverfolgung[1]: Funktion schema_check Datei: /home/hickert/gosa/include/functions_setup.inc (Zeile 230)
252    */
253   if((isset($_SESSION['ldapconf']['mail_methods']))&&(isset($_SESSION['ldapconf']))){
254         if(($_SESSION['ldapconf']['mail_methods'][$_SESSION['ldapconf']['mail']] == "kolab")&&(!$CalledByIndexPhP)){
255           if(!isset($objectclasses['kolabInetOrgPerson']))  {
256             $messages['kolab']['msg']= _("Support for Kolab disabled, no schema seems to be installed, setting mail-method to cyrus");
257             $affich['kolab']['msg']=$messages['kolab']['msg']."<td class=\"check\">kolab2.schema</td>";
258             $tmp= array_flip($_SESSION['ldapconf']['mail_methods']);
259             $_SESSION['ldapconf']['mail']=$tmp['cyrus'];
260             $messages['kolab']['status']= FALSE;
261             $affich['kolab']['status']= FALSE;
262           }else{
263             $affich['kolab']['msg']=_("Support for Kolab enabled")."<td class=\"check\">gofon.schema</td>";
264             $affich['kolab']['status']= TRUE;
265           }
266         }
267   }
268   if($aff==0){
269     return ($messages);
270   } else {
271     return(array_merge($affich,$affich2));
272   }
276 function check(&$faults, $message, $description, $test, $required= TRUE)
278   $msg= "<table summary=\"\" class='check'><tr><td class='check' style='font-size:14px;'>$message</td>
279     <td rowspan=2 style='vertical-align:middle; text-align:center;width:45px;'>";
280   if ($test){
281     $msg.= _("OK")."<br>";
282   } else {
283     if (!$required){
284       $msg.="<font color=red>"._("Ignored")."</font><br>";
285     } else {
286       $msg.="<font color=red>"._("Failed")."</font><br>";
287       $faults++;
288     }
289   }
290   $msg.= "</td></tr><tr><td class='check' style='padding-left:20px;".
291     "background-color:#F0F0F0;'>$description</td></tr></table><br>";
293   return $msg;
296 function perform_php_checks(&$faults)
298   global $check_globals;
300   $faults= 0;
301   $msg= "";
303   $msg.= "<h1>"._("PHP setup inspection")."</h1>";
304   $msg.= check (        $faults, _("Checking for PHP version (>=4.1.0)"),
305       _("PHP must be of version 4.1.0 or above for some functions and known bugs in PHP language."),
306       version_compare(phpversion(), "4.1.0")>=0);
308   $msg.= check (        $faults, _("Checking if register_globals is set to 'off'"),
309       _("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."),
310       $check_globals == 0, FALSE);
312   $msg.= check (        $faults, _("Checking for ldap module"),
313       _("This is the main module used by GOsa and therefore really required."),
314       is_callable('ldap_bind'));
316   $msg.= check (  $faults, _("Checking for XML functions"),
317       _("XML functions are required to parse the configuration file."),
318       is_callable('xml_parser_create'));
320   $msg.= check (        $faults, _("Checking for gettext support"),
321       _("Gettext support is required for internationalized GOsa."),
322       is_callable('bindtextdomain'));
324   $msg.= check (        $faults, _("Checking for iconv support"),
325       _("This module is used by GOsa to convert samba munged dial informations and is therefore required."),
326       is_callable('iconv'));
328   $msg.= check (        $faults, _("Checking for mhash module"),
329       _("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."),
330       is_callable('mhash'), FALSE);
332   $msg.= check (        $faults, _("Checking for imap module"),
333       _("The IMAP module is needed to communicate with the IMAP server. It gets status informations, creates and deletes mail users."),
334       is_callable('imap_open'));
336   $msg.= check (        $faults, _("Checking for getacl in imap"),
337       _("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."),
338       is_callable('imap_getacl'), FALSE);
340   $msg.= check (        $faults, _("Checking for mysql module"),
341       _("MySQL support is needed for reading GOfax reports from databases."),
342       is_callable('mysql_query'), FALSE);
344   $msg.= check (        $faults, _("Checking for cups module"),
345       _("In order to read available printers from IPP protocol instead of printcap files, you've to install the CUPS module."),
346       is_callable('cups_get_dest_list'), FALSE);
348   $msg.= check (        $faults, _("Checking for kadm5 module"),
349       _("Managing users in kerberos requires the kadm5 module which is downloadable via PEAR network."),
350       is_callable('kadm5_init_with_password'), FALSE);
352   $msg.= check (  $faults, _("Checking for snmp Module"),
353       _("Simple Network Management Protocol (SNMP) is required for client monitoring."),
354       is_callable('snmpget'), FALSE);
356   return ($msg);
359 function get_link($function_name) {
360   $result= "<a href='http://de.php.net/manual/en/function.";
362   /* Replace all underscores with hyphens (phpdoc convention) */
363   $function_name= str_replace("_", "-", $function_name);
365   /* Append to base URL */
366   $result.= $function_name.".php'>$function_name</a>";
368   return $result;
371 function perform_additional_function_checks(&$faults) {
372   global $check_globals;
374   $faults= 0;
375   $msg= "";
376   $functions= array();
377   
378   $functions_list= '../include/functions_list.inc';
380   /* Make sure that we can read the file */
381   if(is_readable($functions_list)) {
382     /* Open filehandle */
383     $fh= fopen($functions_list,'rb');
384     if($fh!=null) {
385       $functions= eval(fread($fh,filesize($functions_list)));
386     }
387   }
389   $msg.= "<h1>"._("PHP detailed function inspection")."</h1>";
390   /* Only print message, if function is not callable */
391   foreach($functions as $key => $fn_name) {
392     if(!is_callable($fn_name)) {
393       $msg.= check ($faults, sprintf(_("Checking for function %s"), "<b>".get_link($fn_name)."</b>"),
394         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>"),
395         is_callable($fn_name), false);
396     }
397   }
398   return $msg;
401 function perform_additional_checks(&$faults)
403   $ret = NULL;
404   /* Programm check */
405   $msg= "<h1>"._("Checking for some additional programms")."</h1>";
407   /* Image Magick */
408   $query= "LC_ALL=C LANG=C convert -help";
409   $output= shell_exec ($query);
410   if ($output != ""){
411     $lines= split ("\n", $output);
412     $version= preg_replace ("/^Version:.+Magick ([^\s]+).*/", "\\1", $lines[0]);
413     list($major, $minor)= split("\.", $version);
414     $msg.= check (      $faults, _("Checking for ImageMagick (>=5.4.0)"),
415         _("ImageMagick is used to convert user supplied images to fit the suggested size and the unified JPEG format."),
416         ($major > 5 || ($major == 5 && $minor >= 4)));
417   } else {
418     $msg.= check (      $faults, _("Checking imagick module for PHP"),
419         _("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);
420   }
422   /* Check for fping */
423   $query= "LC_ALL=C LANG=C fping -v 2>&1";
424   $output= shell_exec ($query);
425   $have_fping= preg_match("/^fping:/", $output);
426   $msg.= check (        $faults, _("Checking for fping utility"),
427       _("The fping utility is only used if you've got a thin client based terminal environment running."),
428       $have_fping, FALSE);
430   /* Check for smb hash generation tool */
431   $query= "mkntpwd 2>&1";
432   $output= shell_exec ($query);
433   $have_mkntpwd= preg_match("/^Usage: mkntpwd /", $output);
434   $alt = 0;
436   if (!$have_mkntpwd){
437     $query= "LC_ALL=C LANG=C perl -MCrypt::SmbHash -e 'ntlmgen \"PASSWD\", \$lm, \$nt; print \"\${lm}:\${nt}\\n\";' &>/dev/null";
438     system ($query, $ret);
439     $alt= ($ret == 0);
440   }
442   $msg.= check (        $faults, _("Checking for a way to generate LM/NT password hashes"),
443       _("In order to use SAMBA 2/3, you've to install some additional packages to generate password hashes."),
444       ($have_mkntpwd || $alt));
446   /* seesio.auto_start should be off, in order to without trouble*/
447   $session_auto_start = ini_get('session.auto_start');
448   $implicit_flush     = ini_get('implicit_flush');
449   $max_execution_time = ini_get('max_execution_time');
450   $memory_limit       = ini_get('memory_limit');
451   $expose_php         = ini_get('expose_php');
452   $magic_quotes_gpc   = ini_get('magic_quotes_gpc');
453   $register_globals   = ini_get('register_globals');
455   /* auto_register */
456   $msg.= check (  $faults, _("php.ini check -> session.auto_register"),
457       _("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']));
459   /* implicit_flush */
460   $msg.= check (  $faults, _("php.ini check -> implicit_flush"),
461       _("This option influences the Output handling. Turn this Option off, to increase performance."),
462       !$implicit_flush['local_value'],0,false);
464   /* max_execution_time */
465   if($max_execution_time['local_value'] < 30 ){
466     $max_execution_time['local_value']=false;
467   }
468   $msg.= check (  $faults, _("php.ini check -> max_execution_time"),
469       _("The Execution time should be at least 30 seconds, because some actions may consume more time."),
470       $max_execution_time['local_value'],0,false);
472   /* memory_limit */
473   if($memory_limit['local_value'] < 16 ){
474     $memory_limit['local_value']=false;
475   }
476   $msg.= check (  $faults, _("php.ini check -> memory_limit"),
477       _("GOsa needs at least 16MB of memory, less will cause unpredictable errors! Increase it for larger setups."),
478       !$implicit_flush['local_value'],0,false);
480   /* expose_php */
481   $msg.= check (  $faults, _("php.ini check -> expose_php"),
482       _("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."),
483       !$implicit_flush['local_value'],0,false);
485   /* magic_quotes_gpc */
486   $msg.= check (  $faults, _("php.ini check -> magic_quotes_gpc"),
487       _("Increase your server security by setting magic_quotes_gpc to 'on'. PHP will escape all quotes in strings in this case."),
488       $magic_quotes_gpc['local_value'],0,false);
490   return $msg;
494 function parse_contrib_conf()
497   $str                = "";
498   $used_samba_version = 0;
499   $query              = ""; 
500   $fp                 = false;
501   $output             = "";
502   $needridbase_sid    = false;
503   $pwdhash            = "";
504   $replacements       = array();
505   $ldapconf           = $_SESSION['ldapconf']; // The Installation information
506   $classes            = $_SESSION['classes'];  // Class information needed to define which features are enabled
507   $possible_plugins   = array();
509   /* Which samba version do we use? */
510   if(isset($classes['samba3'])){
511     $used_samba_version = 2;
512   } else {
513     $used_samba_version = 3;
514   }
516   /* Look for samba password generation method */
517   if(file_exists("/usr/bin/mkntpasswd")){
518     $pwdhash  = "/usr/bin/mkntpasswd";
519   } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){
520     $pwdhash= "mkntpwd";
521   } else {
522     $pwdhash=('perl -MCrypt::SmbHash -e "ntlmgen \"\$ARGV[0]\", \$lm, \$nt; print \"\${lm}:\${nt}\n\";" $1');
523   }
526   /* Define which variables will be replaced */
527   $replacements['{LOCATIONNAME}']  = $ldapconf['location'];
528   $replacements['{SAMBAVERSION}']  = $used_samba_version;
529   $replacements['{LDAPBASE}']      = $ldapconf['base'];
530   $replacements['{LDAPADMIN}']     = $ldapconf['admin'];
531   $replacements['{UIDBASE}']       = $ldapconf['uidbase'];
532   $replacements['{DNMODE}']        = $ldapconf['peopledn'];
533   $replacements['{LDAPHOST}']      = $ldapconf['uri'];
534   $replacements['{PASSWORD}']      = $ldapconf['password'];
535   $replacements['{CRYPT}']         = $ldapconf['arr_cryptkeys'][$ldapconf['arr_crypts']];
536   $replacements['{SID}']         = "";
537   $replacements['{RIDBASE}']     = "";
538   if($ldapconf['mail'] != "disabled"){
539     $replacements['{MAILMETHOD}']    = $ldapconf['mail_methods'][$ldapconf['mail']];
540   }   
541   $replacements['{SMBHASH}']       = $pwdhash;
542   $replacements['{GOVERNMENTMODE}']= "false"; 
543   $replacements['{kolabAccount}']  = "";
544   $replacements['{servKolab}']     = "";
545   $replacements['{errorlvl}']     = $ldapconf['errorlvl'];
547   /* This array contains all preg_replace syntax to delete all unused plugins
548      THE kEY MUST BE THE CLASSNAME so we can check it with $ldapconf['classes'] */
550   $possible_plugins['fonreport'][]   = "'\n.*<plugin.*fonreport+.*\n.*>.*\n'i";
551   $possible_plugins['phoneaccount'][]= "'\n.*<tab.*phoneAccount.*>.*\n'i";
552   $possible_plugins['logview'][]     = "'\n.*<plugin.*logview+.*\n.*>.*\n'i";
553   $possible_plugins['pureftp'][]     = "'\n.*<tab.*pureftp.*>.*\n'i";
554   $possible_plugins['webdav'][]      = "'\n.*<tab.*webdav.*>.*\n'i";
555   $possible_plugins['phpgroupware'][]= "'\n.*<tab.*phpgroupware.*>.*\n'i";
557   /*Header information
558      Needed to send the generated gosa.conf to the browser */
559   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
560   header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
561   header("Cache-Control: no-cache");
562   header("Pragma: no-cache");
563   header("Cache-Control: post-check=0, pre-check=0");
564   header("Content-type: text/plain");
566   if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) ||
567       preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){
568     header('Content-Disposition: filename="gosa.conf"');
569   } else {
570     header('Content-Disposition: attachment; filename="gosa.conf"');
571   }
573   if(!$fp=fopen(CONFIG_TEMPLATE_DIR."/gosa.conf","r")) {
574     echo "Can't open file ".CONFIG_TEMPLATE_DIR."/gosa.conf";
575   } else {
576     while(!feof($fp)) {
577       $str.= fread($fp,512);
578     }
580     if($ldapconf['mail_methods'][$ldapconf['mail']]=="kolab") {
581       $replacements['{kolabAccount}']  ="<tab class=\"kolabAccount\" />\n     ";
582       $replacements['{servKolab}']     ="<tab class=\"servkolab\" name=\"Kolab\" />";
583     }
585     if($used_samba_version == 2) {
586       /* Do nothing for samba 2... */
587     } else {
588       /* Create LDAP connection, to check if there's a domain
589          object defined in the LDAP schema */
590       $ldap= new LDAP($ldapconf['admin'], $ldapconf['password'], $ldapconf['uri']);
592       /* Try to find a Samba Domain Objekt */
593       $ldap->search("(objectClass=sambaDomain)");
594     
595       /* Something found ??? so we need to define ridbase an SID by ourselfs */
596       if($ldap->count()< 1) {
597         $replacements['{SID}']= "sid=\"123412-11\"";
598         $replacements['{RIDBASE}']= "ridbase=\"1000\"";  
599       } 
600     }
602     /* Data readed, types replaced, samba version detected and checked if
603        we need to add SID and RIDBASE. Check if there is an ivbbEntry in
604        the LDAP tree, in this case we will set the governmentmode to true.
605        Create LDAP connection, to check if theres a domain Objekt definen
606        in the LDAP schema. */
607     if(!isset($ldap)){
608       $ldap= new LDAP($ldapconf['admin'], $ldapconf['password'], $ldapconf['uri']);
609     }
611     /* Try to find a Samba Domain Objekt */
612     $ldap->search("(objectClass=ivbbEntry)");
614     /* Something found ??? so we need to define ridbase an SID by ourselfs */
615     if($ldap->count()> 0) {
616       $replacements['{GOVERNMENTMODE}']= "true";
617     }
619     /* Replace all colleted information with placeholder */
620     foreach($replacements as $key => $val) {
621       $str = preg_replace("/".$key."/",$val,$str);
622     }    
624     if($ldapconf['mail'] == "disabled"){
625       $str = str_replace("mailMethod=\"{MAILMETHOD}\"","",$str);
626     }
629     /* Remove all unused plugins */
630     foreach($possible_plugins as $key=> $plugin) {
631       foreach($plugin as $key=>$val) {
632         if(in_array($plugin,$classes)) {
633           $str = preg_replace($val,"\n",$str);
634         }
635       }
636     }
637   }
639   return ((($str)));
643 /* Show setup_page 1 */
644 function show_setup_page1($withoutput = true)
646   $faults = array();
647   $smarty = get_smarty();  
648   $smarty->assign ("content", get_template_path('setup_introduction.tpl'));
649   $smarty->assign ("tests", perform_php_checks($faults));
650   $smarty->assign ("detailed_tests", perform_additional_function_checks($faults));
652   /* This var is true if anything went wrong */
653   if ($faults){
654     $smarty->assign("mode", "disabled");
655   }
657   /* This line displays the template only if (withoutput is set) */
658   if($withoutput){
659     $smarty->display (get_template_path('headers.tpl'));
660   }
662   if (isset($_SESSION['errors'])){
663     $smarty->assign("errors", $_SESSION['errors']);
664   }
666   if($withoutput){
667     $smarty->display (get_template_path('setup.tpl'));
668   }
670   return (!$faults);
674 /* Show setup_page 2 */
675 function show_setup_page2($withoutput = true)
677   $faults = array();
678   $smarty = get_smarty();
679   $smarty->assign ("content", get_template_path('setup_step2.tpl'));
680   $smarty->assign ("tests", perform_additional_checks($faults));
682   if ($faults) {
683     $smarty->assign("mode", "disabled");
684   }
685   if($withoutput){
686     $smarty->display (get_template_path('headers.tpl'));
687   }
688   if (isset($_SESSION['errors']))  {
689     $smarty->assign("errors", $_SESSION['errors']);
690   }
691   if($withoutput){
692     $smarty->display (get_template_path('setup.tpl'));
693   }
695   return (!$faults);                               
699 function show_setup_page3($withoutput = true)
701   $ds = NULL;
702   $smarty = get_smarty();
704   /* Take the Post oder the Sessioin saved data */
705   if(isset($_POST['uri'])){
706     $uri = $_POST['uri'];
707   } elseif(isset($_SESSION['ldapconf']['uri'])){
708     $uri = $_SESSION['ldapconf']['uri'];
709   }
711   /* If Page called first time, field is empty */
712   if((!isset($uri))||(empty($uri))){
713     $uri = "ldap://localhost:389";
714   }
716   /* if isset $uri save it to session */
717   if(isset($uri)) {
718     $_SESSION['ldapconf']['uri'] = $uri;
719     $smarty->assign ("uri", validate($uri));
720   }
722   /* No error till now */
723   $fault = false;
725   /* If we pushed the Button continue */
726   if(isset($_POST['continue3'])){
727     if(!isset($uri)) {
728       $fault = true;
730       /* Output the Error */
731       if($withoutput) {
732         print_red (_("You've to specify an ldap server before continuing!"));
733         $smarty->assign ("content", get_template_path('setup_step3.tpl'));
734       }
735     }
736   } elseif (!$ds = @ldap_connect (validate($uri))) {
737     $fault =true;
739     /* Output the Error */
740     if($withoutput) {
741       print_red (_("Can't connect to the specified LDAP server! Please make sure that is reachable for GOsa."));
742       $smarty->assign ("uri", validate($uri));
743       $smarty->assign ("content", get_template_path('setup_step3.tpl'));
744     }
745   } else {
746     /* Try to bind the connection */    
747     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
749     /* if we can't bind , print error */
750     if (!$r  =  @ldap_bind ($ds)) {
751       $fault = true;
753       /* Output the Error */
754       if($withoutput) {
755         print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
756         $smarty->assign ("content", get_template_path('setup_step3.tpl'));
757         $smarty->assign ("uri", validate($uri));
758       }
759     } else {
760       $fault = false;
761     }
762   }
764   $smarty->assign ("content", get_template_path('setup_step3.tpl'));
766   /* Load Header */
767   if($withoutput){
768     $smarty->display (get_template_path('headers.tpl'));
769   }
771   /* Set Errors to Smarty */
772   if (isset($_SESSION['errors'])) {
773     $smarty->assign("errors", $_SESSION['errors']);
774   }
776   /* Print out Template */ 
777   if($withoutput){
778     $smarty->display (get_template_path('setup.tpl'));
779   }
781   return (!$fault);                             
785 function show_setup_page4($withoutput = true)
787   $smarty= get_smarty();      
789         // ?
790   if(!isset($_SESSION['ldapconf']['base'])){
791     $_SESSION['ldapconf']['base']= $base;
792   }
794   if(!isset($_SESSION['ldapconf']['base'])){
795     $_SESSION['ldapconf']['base']= $base;
796   }
797   require_once("class_password-methods.inc");
799   $fault     = false;              
800   $uri       = $_SESSION['ldapconf']['uri'];
801   $ldapconf  = $_SESSION['ldapconf'];
802   $arr_crypts= array();
803   $temp      = "";
804   $checkvars = array("location", "admin", "password", "peopleou", "base",
805       "peopledn", "arr_crypts", "mail", "uidbase","errorlvl");
807   if(!isset($_SESSION['ldapconf']['arr_cryptkeys'])) {
808     require_once("class_password-methods.inc");
809     $tmp= passwordMethod::get_available_methods_if_not_loaded();
810     $_SESSION['ldapconf']['arr_cryptkeys']= $tmp['name'];
811   }
813   if(!isset($_SESSION['ldapconf']['mail_methods'])) {
814     $_SESSION['ldapconf']['mail_methods']=array();
815     $temp = get_available_mail_classes();
816     $_SESSION['ldapconf']['mail_methods']= $temp['name'];
817   }
819   /* If there are some empty vars in ldapconnect -
820      these values also represent out default values */
821   if(!$ds = @ldap_connect (validate($uri))){
822     $fault = true;
823     if($withoutput){
824       print_red (_("Can't connect to the specified LDAP server! Please make sure that is reachable for GOsa."));
825     }
826   } elseif(!@ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)){
827     $fault = true;
828     if($withoutput){
829       print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
830     }
831   } elseif(!$r= @ldap_bind ($ds)){
832     $fault = true;
833     if($withoutput){
834       print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
835     }
836   } else {
837     $sr=   @ldap_search ($ds, NULL, "objectClass=*", array("namingContexts"));
838     $attr= @ldap_get_entries($ds,$sr);
840     if((empty($attr))) {
841       $base= "dc=example,dc=net";
843       if($withoutput){
844         print_red(_("Bind to server successful, but the server seems to be completly empty, please check all information twice"));
845       }
847     } else {
848       $base= $attr[0]['dn'];
849     }
850   }
852   if(!isset($_SESSION['ldapconf']['base'])){
853     $_SESSION['ldapconf']['base']= $base;
854   }
855   if(!isset($_SESSION['ldapconf']['admin'])){
856     $_SESSION['ldapconf']['admin']= "cn=ldapadmin,".$base;
857   }
858   if(!isset($_SESSION['ldapconf']['peopleou'])){
859     $_SESSION['ldapconf']['peopleou']= "ou=people";
860   }
861   if(!isset($_SESSION['ldapconf']['groupou'])){
862     $_SESSION['ldapconf']['groupou']= "ou=groups";
863   }
864   if(!isset($_SESSION['ldapconf']['peopledn'])){
865     $_SESSION['ldapconf']['peopledn']= "cn";
866   }
867   if(!isset($_SESSION['ldapconf']['password'])){
868     $_SESSION['ldapconf']['password']= "";
869   }
870   if(!isset($_SESSION['ldapconf']['location'])){
871     $_SESSION['ldapconf']['location']= "Example";
872   }
873   if(!isset($_SESSION['ldapconf']['uidbase'])){
874     $_SESSION['ldapconf']['uidbase']= "1000";
875   }
876   if(!isset($_SESSION['ldapconf']['mail'])){
877     $_SESSION['ldapconf']['mail']= 0;
878   }
879   $tmp= array_flip($_SESSION['ldapconf']['arr_cryptkeys']);
880   if(!isset($_SESSION['ldapconf']['arr_crypts'])){
881     $_SESSION['ldapconf']['arr_crypts']   = $tmp['md5'];
882   }
884   /* check POST data */
885   if(isset($_POST['check'])) {
887     /* Check if all needed vars are submitted */
888     foreach($checkvars as $key) {
889       if($key == "peopleou"){
890         continue;
891       }
892       if($key == "groupou"){
893         continue;
894       }
896       if((isset($_POST[$key]))&&($_POST[$key]!="")) {
897         $_SESSION['ldapconf'][$key] = $_POST[$key];
898       } else {
899         if($withoutput) {
900           print_red(sprintf(_("You're missing the required attribute '%s' from this formular. Please complete!"), $key));
901         }
902         $fault = true;
903       }
904     }
905   }
907   /* Transfer base */
908   if(isset($_POST['base'])){
909     $_SESSION['ldapconf']['base']= $_POST['base'];
910   }
912   $smarty->assign("arr_cryptkeys",$_SESSION['ldapconf']['arr_cryptkeys']);
913   $smarty->assign("mail_methods", $_SESSION['ldapconf']['mail_methods']);
915   foreach($_SESSION['ldapconf'] as $key => $val) {
916     $smarty->assign($key,$val);
917   }
919   if(isset($_POST['check'])) {
920     $ldap= new LDAP($_SESSION['ldapconf']['admin'],
921         $_SESSION['ldapconf']['password'],
922         $_SESSION['ldapconf']['uri']);
924     $m= schema_check($_SESSION['ldapconf']['uri'],
925         $_SESSION['ldapconf']['admin'],
926         $_SESSION['ldapconf']['password']);
927     $_SESSION['classes']= $m;
929     if(!is_schema_readable($ldapconf['uri'],$ldapconf['admin'],$ldapconf['password'])){
930       if($withoutput){
931         print_red(_("Can't read schema informations, GOsa needs to know your schema setup. Please verify that it is readable for GOsa"));
932       }
933       $fault=true;
934     }
938     if ($ldap->error != "Success") {
939       if($withoutput) {
940         print_red(sprintf(_("Can't log into LDAP server. Reason was: %s."), $ldap->get_error()));
941       }
942       $fault = true;
943     }
944   }
946   /* Set smarty output */
947   $smarty->assign ("content", get_template_path('setup_step4.tpl'));
948   $smarty->assign ("peopledns", array("cn", "uid"));
949   if($withoutput){
950     $smarty->display (get_template_path('headers.tpl'));
951   }
952   if(isset($_SESSION['errors'])) {
953     $smarty->assign("errors", $_SESSION['errors']);
954   }
955   if($withoutput){
956     $smarty->display (get_template_path('setup.tpl'));
957   }
958   return (!$fault);
962 function show_setup_page5($withoutput=true)
964   /* Get ldapconf */
965   $ldapconf= $_SESSION['ldapconf'];
967   /* get smarty */
968   $smarty = get_smarty();
970   if(isset($_SESSION['classes'])){
971     $classes = $_SESSION['classes'];
972   }
974   $info= posix_getgrgid(posix_getgid());
975   $smarty->assign("webgroup", $info['name']);
976   $smarty->assign("path", CONFIG_DIR);
977   $message= "<table summary=\"\" class=\"check\">";
978   $m= schema_check($ldapconf['uri'], $ldapconf['admin'], $ldapconf['password'],1);
980   if($withoutput) {
981     $smarty->assign ("schemas", view_schema_check($m));
982     $smarty->assign ("content", get_template_path('setup_finish.tpl'));
983   }
985   /* Output templates... */
986   if($withoutput){
987     $smarty->display (get_template_path('headers.tpl'));
988   }
989   if (isset($_SESSION['errors'])) {
990     $smarty->assign("errors", $_SESSION['errors']);
991   }
992   if($withoutput){
993     $smarty->display (get_template_path('setup.tpl'));
994   }
996   return(true);
1000 function create_user_for_setup($withoutput=true)
1002   global $samba;
1004   $ldapconf = $_SESSION['ldapconf'];
1005   $smarty = get_smarty();
1006   
1007   $need_to_create_group = false;
1008   $need_to_create_user  = false;
1010   $str_there="";
1012   if(isset($_SESSION['classes'])){
1013     $classes= $_SESSION['classes'];
1014   }
1016   /* Everything runns perfect ...
1017      So we do a last test on this page
1018      is there a user with ACLs :all which will be able to adminsitrate GOsa
1019      We check that, if this user or group is missing we ask for creating them */
1020   $ldap= new LDAP($_SESSION['ldapconf']['admin'],    $_SESSION['ldapconf']['password'],   $_SESSION['ldapconf']['uri']);
1022   /* 
1023   Now we are testing for a group, with the rights :all 
1024   */
1025   
1026   $ldap->cd($ldapconf['base']);
1027   $ldap->search("(&(objectClass=gosaObject)(gosaSubtreeACL=:all))");
1029   $group_cnt  = $ldap->count();
1030   $data       = $ldap->fetch();
1032 //  $str_there  = "Searching for Aminitrative users <br><br>";
1034   /* 
1035   We need to create administrative user and group  because theres no group found 
1036   */
1037   if($group_cnt < 1) {
1038     
1039     /* 
1040     Set var to create user 
1041     */
1042 //    $str_there  =   "no group found<br>";
1044     $need_to_create_group = true;
1045     $need_to_create_user  = true;
1048     /* Output error */
1049     if(($withoutput)&&(!isset($_POST['new_admin']))){
1050       print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!"));
1051     }
1052   } else {
1053     
1054 //    $str_there = "Group found <br>".$data['dn'];    
1056     $need_to_create_group = false;
1057  
1058     $ldap->clearResult();
1059    
1060     /* We found an Administrative Group, is there a user, too */
1061     if(isset($data['memberUid'][0])) {
1062       $str = "uid=".$data['memberUid']['0'];
1063       $ldap->search("(&(objectClass=gosaAccount)(objectClass=person)(".$str."))");
1064       $data2   = $ldap->fetch();
1065   
1066       /* We must create a user */
1067       if (($ldap->count() < 1)||(!isset($data2))) {
1068 //        $str_there.="Missing user";
1069         
1070         $need_to_create_user = true;
1071       
1072         if(($withoutput)&&(!isset($_POST['new_admin']))){
1073           print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!"));
1074         }
1075       }else {
1076 //        $str_there.="<br>User found <br>".$data2['dn'];
1077         $need_to_create_user = false;
1078       }
1079     } else {
1080       $need_to_create_user=true;
1081       if(($withoutput)&&(!isset($_POST['new_admin']))){
1082           print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!"));
1083         }   
1084 //      $str_there.="<br>No User found <br>";
1085     }
1086   }
1088   if(!($need_to_create_user&&$need_to_create_group))
1089     return(true);
1091   /* We need to create a new user with group */
1092   if(isset($_POST['new_admin']))
1093   {
1094   
1095     /* Adjust password attributes according to the samba version */
1096     if (isset($classes['samba3'])) {
1097       $samba= "2";
1098       $lmPassword = "lmPassword";
1099       $ntPassword = "ntPassword";
1100     } else {
1101       $samba= "3";
1102       $lmPassword = "sambaLMPassword";
1103       $ntPassword = "sambaNtPassword";
1104     }
1106     /* Nothing submitted */
1107     if(((empty($_POST['admin_name']))||(empty($_POST['admin_pass'])))) {
1108       return(true);
1109     }
1111     if($need_to_create_user) {
1112       /* We have the order to create an Admin */
1113       /* Define the user we are going to create */
1114       $dn= "cn=".$_POST['admin_name'].",".$ldapconf['peopleou'].",".$ldapconf['base'];
1115       $arr['objectClass'][0] ="person";
1116       $arr['objectClass'][1] ="organizationalPerson";
1117       $arr['objectClass'][2] ="inetOrgPerson";
1118       $arr['objectClass'][3] ="gosaAccount";
1119       $arr['uid']            = $_POST['admin_name'];
1120       $arr['cn']             = $_POST['admin_name'];
1121       $arr['sn']             = $_POST['admin_name'];
1122       $arr['givenName']      = "GOsa main administrator";
1123       $arr[$lmPassword]      = "10974C6EFC0AEE1917306D272A9441BB";
1124       $arr[$ntPassword]      = "38F3951141D0F71A039CFA9D1EC06378";
1125       $arr['userPassword']   = crypt_single($_POST['admin_pass'],"md5");
1126     
1128       if(!$ldap->dn_exists($dn)){ 
1129         $ldap->cd($dn); 
1130         $ldap->create_missing_trees($dn);
1131         $ldap->cd($dn);
1132         $ldap->add($arr);
1133         if($ldap->error!="Success"){
1134           print_red($ldap->error);
1135           print_red("Can't create user, and / or Group, possibly this problem  depends on an empty LDAP server. Check your configuration and try again!");
1136         }
1137       }    
1138     }
1140     /* There's already a group for administrator, so we only need to add the user */
1141     if(!$need_to_create_group) {
1142       if(!isset($data['memberUid'])) {
1143         $arrr['memberUid']= $_POST['admin_name'];
1144       } else {
1145         $data['memberUid'][$data['memberUid']['count']]=$_POST['admin_name'];
1146         $arrr['memberUid'] = $data['memberUid'];
1147         unset($arrr['memberUid']['count']);
1148   
1149         $tmp = array_reverse($arrr['memberUid']);    
1150         foreach($tmp as $tt){
1151           $tmp2[]=$tt;
1152         }
1153         $arrr['memberUid']= $tmp2;
1154 //        $str_there="Group found<br>".$data['dn'];
1155       }
1157       $ldap->cd($data['dn']);
1158       $ldap->modify($arrr);
1160     } else {
1161       $dn                    = "cn=administrators,".$ldapconf['groupou'].",".$ldapconf['base'];
1162       $arrr['objectClass'][0]= "gosaObject";
1163       $arrr['objectClass'][1]= "posixGroup";
1164       $arrr['gosaSubtreeACL']= ":all";
1165       $arrr['cn']            = "administrators";
1166       $arrr['gidNumber']     = "999";
1167       $arrr['memberUid']     = $_POST['admin_name'];
1169       $ldap->cd($dn);
1170       $ldap->create_missing_trees($dn);
1171       $ldap->cd($dn);
1173       $ldap->add($arrr);
1174     }
1175     return(true);
1176   } else {
1178     if((!isset($create_user))||(!($create_user))) {
1179       $smarty->assign ("content", get_template_path('setup_useradmin.tpl'));
1180       $smarty->assign("exists",true);
1181     } else {
1182       $smarty->assign ("content", get_template_path('setup_useradmin.tpl'));
1183       $smarty->assign("exists",false);
1184     }
1186   }
1188   /* Smarty output */ 
1189   if($withoutput){
1190     $smarty->display (get_template_path('headers.tpl'));
1191   }
1192   if (isset($_SESSION['errors'])) {
1193     $smarty->assign("errors", $_SESSION['errors']);
1194   }
1195   $smarty->assign("str_there",$str_there);
1196   if($withoutput){
1197     $smarty->display (get_template_path('setup.tpl'));
1198   }
1199   return(false);
1203 /* Returns the classnames auf the mail classes */
1204 function get_available_mail_classes()
1206   $dir = opendir( "../include");
1207   $methods = array();
1208   $suffix = "class_mail-methods-";
1209   $lensuf = strlen($suffix);
1210   $prefix = ".inc";
1211   $lenpre = strlen($prefix);
1213   $i = 0;
1214   while (($file = readdir($dir)) !== false){
1216     if(stristr($file,$suffix)) {
1217       $lenfile = strlen($file);
1218       $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
1219       $methods['file'][$i] = $file;
1220       $methods[$i]['file'] = $file;
1221       $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre);
1222       $i++;
1223     }
1225   }
1227   return($methods);
1230 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1231 ?>