diff --git a/index.php b/index.php index a274ac6faf..cd2dae5668 100755 --- a/index.php +++ b/index.php @@ -117,7 +117,7 @@ $line_found = explode(":",chop($lines[$i])); } } - if ($line_found[1] > $phpgw_info["server"]["versions"]["phpgwapi"]) { + if($phpgw->common->cmp_version($phpgw_info["server"]["versions"]["phpgwapi"],$line_found[1])) { echo "

There is a new version of phpGroupWare available. http://www.phpgroupware.org"; } diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 917b36a585..7b4a3e8dd3 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -44,6 +44,29 @@ var $key = ''; var $crypto; var $debug_info; // An array with debugging info from the API + + // Compares two Version strings + /*! + @functionn cmp_version + @@abstract Compares two Version strings and return 1 if str2 is newest (bigger version number) than str1 + @@param $str1 + @@param $str2 + */ + function cmp_version($str1,$str2) + { + ereg("([0-9]+)\.([0-9]+)\.([0-9]+)[a-zA-Z]*([0-9]*)",$str1,$regs); + ereg("([0-9]+)\.([0-9]+)\.([0-9]+)[a-zA-Z]*([0-9]*)",$str2,$regs2); + //echo "$regs[0] - $regs2[0]"; + for($i=1;$i<5;$i++) { + if($regs2[$i] == $regs[$i]) + continue; + if($regs2[$i] > $regs[$i]) + return 1; + else + if($regs2[$i] < $regs[$i]) + return 0; + } + } // Convert an array into the format needed for the access column. /*!