Code

Applied modifications for fixed PHP versions
[gosa.git] / include / functions_setup.inc
index f7f3e422492ac8ca599f706a130bd4bba9a36cdc..44adf1ac1fd9893c3c6708177efd722cf0fc1b75 100644 (file)
@@ -40,7 +40,7 @@ function is_schema_readable($server, $admin, $password)
   $r= ldap_bind ($ds, $admin, $password);
 
   /* Get base to look for schema */
-  $sr  = @ldap_read ($ds, "", "objectClass=*", array("subschemaSubentry"));
+  $sr  = @ldap_read ($ds, NULL, "objectClass=*", array("subschemaSubentry"));
   $attr= @ldap_get_entries($ds,$sr);
   if (!isset($attr[0]['subschemasubentry'][0])){
     return (false);
@@ -56,7 +56,7 @@ function is_schema_readable($server, $admin, $password)
   return(true);
 } 
 
-function schema_check($server, $admin, $password, $aff=0)
+function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false)
 {
   global $config;
 
@@ -79,10 +79,10 @@ function schema_check($server, $admin, $password, $aff=0)
       "gosaApplicationGroup"  => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
 
       "GOhard"                => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
-      "gotoTerminal"          => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
+      "gotoTerminal"          => array("version" => "2.0", "class" => "terminals","file" => "goto.schema"),
       "goServer"              => array("version" => "2.4","class" => "server","file" => "goserver.schema"),
       "goTerminalServer"      => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
-      "goNfsServer"           => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
+      "goShareServer"           => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
       "goNtpServer"           => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
       "goSyslogServer"        => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
       "goLdapServer"          => array("version" => "2.4"),
@@ -101,7 +101,7 @@ function schema_check($server, $admin, $password, $aff=0)
   $r= ldap_bind ($ds, $admin, $password);
 
   /* Get base to look for schema */
-  $sr  = @ldap_read ($ds, "", "objectClass=*", array("subschemaSubentry"));
+  $sr  = @ldap_read ($ds, NULL, "objectClass=*", array("subschemaSubentry"));
   $attr= @ldap_get_entries($ds,$sr);
   if (!isset($attr[0]['subschemasubentry'][0])){
     return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE)));
@@ -227,20 +227,33 @@ function schema_check($server, $admin, $password, $aff=0)
     $affich['phoneaccount']['status']= true;
   }
 
-  if(($_SESSION['ldapconf']['mail_methods'][$_SESSION['ldapconf']['mail']] == "kolab")){
-    if(!isset($objectclasses['kolabInetOrgPerson']))
-    {
-      $messages['kolab']['msg']= _("Support for Kolab disabled, no schema seems to be installed, setting mail-method to cyrus");
-      $affich['kolab']['msg']=$messages['kolab']['msg']."<td class=\"check\">kolab2.schema</td>";
-
-      $tmp= array_flip($_SESSION['ldapconf']['mail_methods']);
-      $_SESSION['ldapconf']['mail']=$tmp['cyrus'];
-      $messages['kolab']['status']= FALSE;
-      $affich['kolab']['status']= FALSE;
-    }else{
-      $affich['kolab']['msg']=_("Support for Kolab enabled")."<td class=\"check\">gofon.schema</td>";
-      $affich['kolab']['status']= TRUE;
-    }
+  if (!isset($objectclasses['nagiosContact'])){
+    $messages['nagioscontact']['msg']= _("Support for nagios disabled, no schema seems to be installed");
+    $affich['nagioscontact']['msg']= $messages['nagioscontact']['msg']."<td class=\"check\">nagios.schema</td>";
+    $messages['nagioscontact']['status']= FALSE;
+    $affich['nagioscontact']['status']= FALSE;
+  }else{
+    $affich['nagioscontact']['msg']= _("Support for nagios enabled")."<td class=\"check\">nagios.schema</td>";
+    $affich['nagioscontact']['status']= true;
+  }
+  
+  /* Fix for PHP Fehler "Undefined index: ldapconf"
+   * Ablaufverfolgung[1]: Funktion schema_check        Datei: /home/hickert/gosa/include/functions_setup.inc (Zeile 230)
+   */
+  if((isset($_SESSION['ldapconf']['mail_methods']))&&(isset($_SESSION['ldapconf']))){
+       if(($_SESSION['ldapconf']['mail_methods'][$_SESSION['ldapconf']['mail']] == "kolab")&&(!$CalledByIndexPhP)){
+         if(!isset($objectclasses['kolabInetOrgPerson']))  {
+           $messages['kolab']['msg']= _("Support for Kolab disabled, no schema seems to be installed, setting mail-method to cyrus");
+           $affich['kolab']['msg']=$messages['kolab']['msg']."<td class=\"check\">kolab2.schema</td>";
+           $tmp= array_flip($_SESSION['ldapconf']['mail_methods']);
+           $_SESSION['ldapconf']['mail']=$tmp['cyrus'];
+           $messages['kolab']['status']= FALSE;
+           $affich['kolab']['status']= FALSE;
+         }else{
+           $affich['kolab']['msg']=_("Support for Kolab enabled")."<td class=\"check\">gofon.schema</td>";
+           $affich['kolab']['status']= TRUE;
+         }
+       }
   }
   if($aff==0){
     return ($messages);
@@ -288,52 +301,96 @@ function perform_php_checks(&$faults)
 
   $msg.= check (       $faults, _("Checking for ldap module"),
       _("This is the main module used by GOsa and therefore really required."),
-      function_exists('ldap_bind'));
+      is_callable('ldap_bind'));
 
   $msg.= check (  $faults, _("Checking for XML functions"),
       _("XML functions are required to parse the configuration file."),
-      function_exists('xml_parser_create'));
+      is_callable('xml_parser_create'));
 
   $msg.= check (       $faults, _("Checking for gettext support"),
-      _("Gettext support is required for internationalized GOsa."), function_exists('bindtextdomain'));
+      _("Gettext support is required for internationalized GOsa."),
+      is_callable('bindtextdomain'));
 
   $msg.= check (       $faults, _("Checking for iconv support"),
       _("This module is used by GOsa to convert samba munged dial informations and is therefore required."),
-      function_exists('iconv'));
+      is_callable('iconv'));
 
   $msg.= check (       $faults, _("Checking for mhash module"),
       _("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."),
-      function_exists('mhash'), FALSE);
+      is_callable('mhash'), FALSE);
 
   $msg.= check (       $faults, _("Checking for imap module"),
       _("The IMAP module is needed to communicate with the IMAP server. It gets status informations, creates and deletes mail users."),
-      function_exists('imap_open'));
+      is_callable('imap_open'));
 
   $msg.= check (       $faults, _("Checking for getacl in imap"),
       _("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."),
-      function_exists('imap_getacl'), FALSE);
+      is_callable('imap_getacl'), FALSE);
 
   $msg.= check (       $faults, _("Checking for mysql module"),
       _("MySQL support is needed for reading GOfax reports from databases."),
-      function_exists('mysql_query'), FALSE);
+      is_callable('mysql_query'), FALSE);
 
   $msg.= check (       $faults, _("Checking for cups module"),
       _("In order to read available printers from IPP protocol instead of printcap files, you've to install the CUPS module."),
-      function_exists('cups_get_dest_list'), FALSE);
+      is_callable('cups_get_dest_list'), FALSE);
 
   $msg.= check (       $faults, _("Checking for kadm5 module"),
       _("Managing users in kerberos requires the kadm5 module which is downloadable via PEAR network."),
-      function_exists('kadm5_init_with_password'), FALSE);
+      is_callable('kadm5_init_with_password'), FALSE);
 
   $msg.= check (  $faults, _("Checking for snmp Module"),
       _("Simple Network Management Protocol (SNMP) is required for client monitoring."),
-      function_exists('snmpget'), FALSE);
+      is_callable('snmpget'), FALSE);
+
   return ($msg);
 }
 
+function get_link($function_name) {
+  $result= "<a href='http://de.php.net/manual/en/function.";
+
+  /* Replace all underscores with hyphens (phpdoc convention) */
+  $function_name= str_replace("_", "-", $function_name);
+
+  /* Append to base URL */
+  $result.= $function_name.".php'>$function_name</a>";
+
+  return $result;
+}
+
+function perform_additional_function_checks(&$faults) {
+  global $check_globals;
+
+  $faults= 0;
+  $msg= "";
+  $functions= array();
+  
+  $functions_list= '../include/functions_list.inc';
+
+  /* Make sure that we can read the file */
+  if(is_readable($functions_list)) {
+    /* Open filehandle */
+    $fh= fopen($functions_list,'rb');
+    if($fh!=null) {
+      $functions= eval(fread($fh,filesize($functions_list)));
+    }
+  }
+
+  $msg.= "<h1>"._("PHP detailed function inspection")."</h1>";
+  /* Only print message, if function is not callable */
+  foreach($functions as $key => $fn_name) {
+    if(!is_callable($fn_name)) {
+      $msg.= check ($faults, sprintf(_("Checking for function %s"), "<b>".get_link($fn_name)."</b>"),
+        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>"),
+        is_callable($fn_name), false);
+    }
+  }
+  return $msg;
+}
 
 function perform_additional_checks(&$faults)
 {
+  $ret = NULL;
   /* Programm check */
   $msg= "<h1>"._("Checking for some additional programms")."</h1>";
 
@@ -447,19 +504,21 @@ function parse_contrib_conf()
   }
 
   /* Look for samba password generation method */
-  if(file_exists("/usr/lib/gosa/mkntpasswd")){
-    $pwdhash  = "/usr/lib/gosa/mkntpasswd";
+  if(file_exists("/usr/bin/mkntpasswd")){
+    $pwdhash  = "/usr/bin/mkntpasswd";
   } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){
     $pwdhash= "mkntpwd";
   } else {
     $pwdhash=('perl -MCrypt::SmbHash -e "ntlmgen \"\$ARGV[0]\", \$lm, \$nt; print \"\${lm}:\${nt}\n\";" $1');
   }
 
+
   /* Define which variables will be replaced */
   $replacements['{LOCATIONNAME}']  = $ldapconf['location'];
   $replacements['{SAMBAVERSION}']  = $used_samba_version;
   $replacements['{LDAPBASE}']      = $ldapconf['base'];
   $replacements['{LDAPADMIN}']     = $ldapconf['admin'];
+  $replacements['{UIDBASE}']       = $ldapconf['uidbase'];
   $replacements['{DNMODE}']        = $ldapconf['peopledn'];
   $replacements['{LDAPHOST}']      = $ldapconf['uri'];
   $replacements['{PASSWORD}']      = $ldapconf['password'];
@@ -473,6 +532,7 @@ function parse_contrib_conf()
   $replacements['{GOVERNMENTMODE}']= "false"; 
   $replacements['{kolabAccount}']  = "";
   $replacements['{servKolab}']     = "";
+  $replacements['{errorlvl}']     = $ldapconf['errorlvl'];
 
   /* This array contains all preg_replace syntax to delete all unused plugins
      THE kEY MUST BE THE CLASSNAME so we can check it with $ldapconf['classes'] */
@@ -573,9 +633,11 @@ function parse_contrib_conf()
 /* Show setup_page 1 */
 function show_setup_page1($withoutput = true)
 {
+  $faults = array();
   $smarty = get_smarty();  
   $smarty->assign ("content", get_template_path('setup_introduction.tpl'));
   $smarty->assign ("tests", perform_php_checks($faults));
+  $smarty->assign ("detailed_tests", perform_additional_function_checks($faults));
 
   /* This var is true if anything went wrong */
   if ($faults){
@@ -602,6 +664,7 @@ function show_setup_page1($withoutput = true)
 /* Show setup_page 2 */
 function show_setup_page2($withoutput = true)
 {
+  $faults = array();
   $smarty = get_smarty();
   $smarty->assign ("content", get_template_path('setup_step2.tpl'));
   $smarty->assign ("tests", perform_additional_checks($faults));
@@ -625,6 +688,7 @@ function show_setup_page2($withoutput = true)
 
 function show_setup_page3($withoutput = true)
 {
+  $ds = NULL;
   $smarty = get_smarty();
 
   /* Take the Post oder the Sessioin saved data */
@@ -712,6 +776,7 @@ function show_setup_page4($withoutput = true)
 {
   $smarty= get_smarty();      
 
+       // ?
   if(!isset($_SESSION['ldapconf']['base'])){
     $_SESSION['ldapconf']['base']= $base;
   }
@@ -727,7 +792,7 @@ function show_setup_page4($withoutput = true)
   $arr_crypts= array();
   $temp      = "";
   $checkvars = array("location", "admin", "password", "peopleou", "base",
-      "peopledn", "arr_crypts", "mail", "uidbase");
+      "peopledn", "arr_crypts", "mail", "uidbase","errorlvl");
 
   if(!isset($_SESSION['ldapconf']['arr_cryptkeys'])) {
     require_once("class_password-methods.inc");
@@ -759,14 +824,14 @@ function show_setup_page4($withoutput = true)
       print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
     }
   } else {
-    $sr=   @ldap_search ($ds, "", "objectClass=*", array("namingContexts"));
+    $sr=   @ldap_search ($ds, NULL, "objectClass=*", array("namingContexts"));
     $attr= @ldap_get_entries($ds,$sr);
 
     if((empty($attr))) {
       $base= "dc=example,dc=net";
 
       if($withoutput){
-        print_red(_("Bind to server successful, but the server seems to be completly empty, please check all informations twice"));
+        print_red(_("Bind to server successful, but the server seems to be completly empty, please check all information twice"));
       }
 
     } else {
@@ -853,7 +918,7 @@ function show_setup_page4($withoutput = true)
 
     if(!is_schema_readable($ldapconf['uri'],$ldapconf['admin'],$ldapconf['password'])){
       if($withoutput){
-        print_red(_("Can't read schema informations, GOsa needs to know your schema setup. Pleasy verify taht it is readable for GOsa"));
+        print_red(_("Can't read schema informations, GOsa needs to know your schema setup. Please verify that it is readable for GOsa"));
       }
       $fault=true;
     }
@@ -1100,7 +1165,7 @@ function create_user_for_setup($withoutput=true)
     return(true);
   } else {
 
-    if(!($create_user)) {
+    if((!isset($create_user))||(!($create_user))) {
       $smarty->assign ("content", get_template_path('setup_useradmin.tpl'));
       $smarty->assign("exists",true);
     } else {