added a new function cmp_version

This commit is contained in:
el_latino 2001-03-23 05:56:15 +00:00
parent c2357d72a3
commit 43f048acca
2 changed files with 24 additions and 1 deletions

View File

@ -117,7 +117,7 @@
$line_found = explode(":",chop($lines[$i])); $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 "<p>There is a new version of phpGroupWare available. <a href=\"" echo "<p>There is a new version of phpGroupWare available. <a href=\""
. "http://www.phpgroupware.org\">http://www.phpgroupware.org</a>"; . "http://www.phpgroupware.org\">http://www.phpgroupware.org</a>";
} }

View File

@ -45,6 +45,29 @@
var $crypto; var $crypto;
var $debug_info; // An array with debugging info from the API 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. // Convert an array into the format needed for the access column.
/*! /*!
@function array_to_string @function array_to_string