Code

Simplified PHP version detection
[gosa.git] / include / setup_checks.inc
index 7003058e8281d57a5d69f7742948066ede4158fa..2195c9b0ec8033ff4701bcd66e2e1714c2296ffc 100644 (file)
@@ -1,44 +1,5 @@
 <?php
 
-
-
-
-function minimum_version($vercheck)
-{
-  $needver = split("\.",$vercheck);
-  $curver  = split("\.",phpversion());
-  
-  $c1 = count($needver);
-  $c2 = count($curver);
-
-  if($c2 >= $c1) $c1 = $c2;
-
-  for($i=0; $i < $c1 ; $i++)
-  {
-  if($needver[$i] > $curver[$i])
-    {
-    return(false);
-    }
-  if($needver[$i] < $curver[$i])
-    {
-    return(true);
-    }
-  } 
-}
-
-function minimum_versioni2($vercheck)
-{
-  $minver = (int)str_replace('.', '', $vercheck);
-  $curver = (int)str_replace('.', '', phpversion());
-
-  if($curver >= $minver){
-    return (true);
-  }
-
-  return (false);
-}
-
-
 function check_schema_version($description, $version)
 {
   $desc= preg_replace("/^.* DESC\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $description);
@@ -258,12 +219,7 @@ function perform_php_checks(&$faults)
   $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."),
-      minimum_version('4.1.0'));
-
-  $msg.= check (  $faults, _("Checking for PHP version (<=5)"),
-      _("PHP must be below version 5."),
-      !minimum_version('5'));
-
+       version_compare(phpversion(), "4.1.0")>=0);
 
   $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."),
@@ -375,42 +331,43 @@ $register_globals =       ($arra['register_globals']);
 
 
 // auto_register
-$msg.= check (  $faults, _("PHP.ini check -> session.auto_register"),
-      _("In Order to use GOsa without any trouble, the session.auto_register option in your php.ini musst be 'Off'."),
-      (!$session_auto_start['local_value']));
+$msg.= check (  $faults, _("php.ini check -> session.auto_register"),
+    _("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']));
 
 
 
 //implicit_flush
-$msg.= check (  $faults, _("PHP.ini check -> implicit_flush"),
-      _("This Option defines the Ouput handling, turn this Option off, to increase performance."),
-        !$implicit_flush['local_value'],0,false);
+$msg.= check (  $faults, _("php.ini check -> implicit_flush"),
+    _("This option influences the Output handling. Turn this Option off, to increase performance."),
+    !$implicit_flush['local_value'],0,false);
 
 //max_execution_time
-if($max_execution_time['local_value'] < 30 )
+if($max_execution_time['local_value'] < 30 ){
   $max_execution_time['local_value']=false;
-$msg.= check (  $faults, _("PHP.ini check -> max_execution_time"),
-      _("The Execution time, should be 30 seconds minimun, cause some actions will need huge ammount of time ."),
-        $max_execution_time['local_value'],0,false);
+}
+$msg.= check (  $faults, _("php.ini check -> max_execution_time"),
+    _("The Execution time should be at least 30 seconds, because some actions may consume more time."),
+    $max_execution_time['local_value'],0,false);
 
 //memory_limit
-if($memory_limit['local_value'] < 8 )
+if($memory_limit['local_value'] < 8 ){
   $memory_limit['local_value']=false;
-$msg.= check (  $faults, _("PHP.ini check -> memory_limit"),
-      _("GOsa need at least 8M of memory, less will cause unpredictable errors, sometimes without error message!. Best would be 32 M here."),
-        !$implicit_flush['local_value'],0,false);
+}
+$msg.= check (  $faults, _("php.ini check -> memory_limit"),
+    _("GOsa needs at least 8MB of memory, less will cause unpredictable errors! An optimal setting would be 16MB, increase it for larger setups."),
+    !$implicit_flush['local_value'],0,false);
 
 //expose_php
-$msg.= check (  $faults, _("PHP.ini check -> expose_php"),
-      _("PHP won't send any Information about the Server you are running, should be a security fact."),
-        !$implicit_flush['local_value'],0,false);
+$msg.= check (  $faults, _("php.ini check -> expose_php"),
+    _("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."),
+    !$implicit_flush['local_value'],0,false);
 
 //magic_quotes_gpc
-$msg.= check (  $faults, _("PHP.ini check -> magic_quotes_gpc"),
-      _("Security option, php will escape all quotes in strings ."),
-        $magic_quotes_gpc['local_value'],0,false);
+$msg.= check (  $faults, _("php.ini check -> magic_quotes_gpc"),
+    _("Increase your server security by setting magic_quotes_gpc to 'on'. PHP will escape all quotes in strings in this case."),
+    $magic_quotes_gpc['local_value'],0,false);
 
-  return $msg;
+return $msg;
 }
 
 
@@ -736,7 +693,7 @@ function show_setup_page3($withoutput = true)
         // Output the Error
         if($withoutput)      
         {
-          print_red (_("Can't bind to the specified LDAP server! Please make sure that is reachable for GOsa."));
+          print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
           $smarty->assign ("content", get_template_path('setup_step3.tpl'));
           $smarty->assign ("uri", validate($uri));
         }
@@ -828,13 +785,13 @@ function show_setup_page4($withoutput = true)
   {
     $fault = true;
     if($withoutput)
-      print_red (_("Can't bind to the specified LDAP server!. Please make sure that is reachable for GOsa."));
+      print_red (_("Can't bind to the specified LDAP server!. Please make sure that it is reachable for GOsa."));
   }
   elseif(! $r =  @ldap_bind ($ds))    
   {
     $fault = true;
     if($withoutput)
-      print_red (_("Can't bind to the specified LDAP server! Please make sure that is reachable for GOsa."));
+      print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
   }
   else
   {