Code

Added edit link
[gosa.git] / include / functions_setup.inc
index 77ca026fbf9071f1a8b2d6d1df31c1e198a86ca1..cabcbbdb1c9128883b402e4fe900c3d2757a03c0 100644 (file)
@@ -32,28 +32,13 @@ function view_schema_check($table)
 
 function is_schema_readable($server, $admin, $password)
 {
-  $ds= ldap_connect ($server);
-  if (!$ds) {
-    return (false);
-  }
-  ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
-  $r= ldap_bind ($ds, $admin, $password);
-
-  /* Get base to look for schema */
-  $sr  = @ldap_read ($ds, NULL, "objectClass=*", array("subschemaSubentry"));
-  $attr= @ldap_get_entries($ds,$sr);
-  if (!isset($attr[0]['subschemasubentry'][0])){
-    return (false);
-  }
+  $ldap = new LDAP($admin,$password,$server);
+  $tmp = $ldap->get_objectclasses();
 
-  $nb= $attr[0]['subschemasubentry'][0];
-  $objectclasses= array();
-  $sr= ldap_read ($ds, $nb, "objectClass=*", array("objectclasses"));
-  $attrs= ldap_get_entries($ds,$sr);
-  if (!isset($attrs[0])){
-    return (false);
+  if(count($tmp)){
+    return(true);
   }
-  return(true);
+  return(false);
 } 
 
 function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false)
@@ -92,35 +77,13 @@ function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false
       "goFaxServer"           => array("version" => "2.4", "class" => "gofaxAccount","file" => "gofax.schema"),
       );
 
-  /* Build LDAP connection */
-  $ds= ldap_connect ($server);
-  if (!$ds) {
-    return (array(array("msg" => _("Can't bind to LDAP. No schema check possible!"), "status" => FALSE)));
-  }
-  ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
-  $r= ldap_bind ($ds, $admin, $password);
-
-  /* Get base to look for schema */
-  $sr  = @ldap_read ($ds, NULL, "objectClass=*", array("subschemaSubentry"));
-  $attr= @ldap_get_entries($ds,$sr);
-  if (!isset($attr[0]['subschemasubentry'][0])){
+  /* Get objectclasses */
+  $ldap = new LDAP($admin,$password, $server);
+  $objectclasses = $ldap->get_objectclasses(); 
+  if(count($objectclasses) == 0){
     return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE)));
   }
 
-  /* Get list of objectclasses */
-  $nb= $attr[0]['subschemasubentry'][0];
-  $objectclasses= array();
-  $sr= ldap_read ($ds, $nb, "objectClass=*", array("objectclasses"));
-  $attrs= ldap_get_entries($ds,$sr);
-  if (!isset($attrs[0])){
-    return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE)));
-  }
-  foreach ($attrs[0]['objectclasses'] as $val){
-    $name= preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $val);
-    if ($name != $val){
-      $objectclasses[$name]= $val;
-    }
-  }
   /* Walk through objectclasses and check if they are needed or not */
   foreach ($required_classes as $key => $value){
     if (isset($value['class'])){
@@ -311,6 +274,7 @@ function perform_php_checks(&$faults)
   $msg= "";
 
   $msg.= "<h1>"._("PHP setup inspection")."</h1>";
+
   $msg.= check (       $faults, _("Checking for PHP version (>=4.1.0)"),
       _("PHP must be of version 4.1.0 or above for some functions and known bugs in PHP language."),
       version_compare(phpversion(), "4.1.0")>=0);
@@ -318,6 +282,10 @@ function perform_php_checks(&$faults)
   $msg.= check (       $faults, _("Checking if register_globals is set to 'off'"),
       _("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."),
       $check_globals == 0, FALSE);
+  
+  $msg.= check (  $faults, _("PHP session.gc_maxlifetime (>= 86400 seconds)."),
+      _("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."),
+      ini_get("session.gc_maxlifetime") >= 86400,FALSE);
 
   $msg.= check (       $faults, _("Checking for ldap module"),
       _("This is the main module used by GOsa and therefore really required."),