From 97bdc607e7415ef9b9c28e56062d280ccaddb95a Mon Sep 17 00:00:00 2001 From: ebullient Date: Sun, 29 Dec 2002 19:10:34 +0000 Subject: [PATCH] Wanted to add the SquirrelMail versioning functions we'd talked about before we split the streams to the new RC for 1.4. check_sm_version performs similar function to check_php_version, and will return true if version is >= what is specified. For Thijs/Jonathan - the check_sm_version will return false if the constant it checks against is not defined, making the function itself safe for previous levels, should you want to roll it back to stable to allow plugin developers to use the check_sm_version function to test for 'new' elements like SM_PATH, etc. that are present in 1.3.x and up. More info (though not a ton, I'll admit) is in the sm2-planning module in cvs: cvs co sm2-planning, then pull up sm2-planning/index.php in your browser. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4319 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/global.php | 29 +++++++++++++++++++++++++++-- functions/strings.php | 8 ++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/functions/global.php b/functions/global.php index 5221b44e..cead10a2 100644 --- a/functions/global.php +++ b/functions/global.php @@ -53,17 +53,42 @@ if (get_magic_quotes_gpc()) { $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']); -/* returns true if current php version is at mimimum a.b.c */ +/** + * returns true if current php version is at mimimum a.b.c + * + * Called: check_php_version(4,1) + */ function check_php_version ($a = '0', $b = '0', $c = '0') { global $SQ_PHP_VERSION; - + if(!isset($SQ_PHP_VERSION)) $SQ_PHP_VERSION = substr( str_pad( preg_replace('/\D/','', PHP_VERSION), 3, '0'), 0, 3); return $SQ_PHP_VERSION >= ($a.$b.$c); } +/** + * returns true if the current internal SM version is at minimum a.b.c + * These are plain integer comparisons, as our internal version is + * constructed by us, as an array of 3 ints. + * + * Called: check_sm_version(1,3,3) + */ +function check_sm_version($a = 0, $b = 0, $c = 0) +{ + global $SQM_INTERNAL_VERSION; + if ( !isset($SQM_INTERNAL_VERSION) || + $SQM_INTERNAL_VERSION[0] < $a || + $SQM_INTERNAL_VERSION[1] < $b || + ( $SQM_INTERNAL_VERSION[1] == $b && + $SQM_INTERNAL_VERSION[2] < $c ) ) { + return FALSE; + } + return TRUE; +} + + /* recursively strip slashes from the values of an array */ function sqstripslashes(&$array) { if(count($array) > 0) { diff --git a/functions/strings.php b/functions/strings.php index 1b62cffb..ffbc5707 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -18,6 +18,14 @@ global $version; $version = '1.3.3 [CVS-DEVEL]'; +/** + * SquirrelMail internal version number -- DO NOT CHANGE + * $sm_internal_version = array (release, major, minor) + */ +//global $SQM_INTERNAL_VERSION; +//$SQM_INTERNAL_VERSION = array(1,3,3); + + /** * Wraps text at $wrap characters * -- 2.25.1