From d2ba50a32fbd58595f0fc4c2a215922877b45776 Mon Sep 17 00:00:00 2001 From: Christian Weber Date: Thu, 29 Jan 2009 15:56:19 +0000 Subject: add it::is_devel() and it::is_live() as abstraction for $GLOBALS['ULTRASERVERTYPE'] --- it.class | 20 ++++++++++++++++++++ itjs.class | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/it.class b/it.class index 2cb625b..81cdf01 100644 --- a/it.class +++ b/it.class @@ -250,6 +250,26 @@ function bail($message = "Bailed.\n") } +/** + * Check wether I am on a live server for this service. Honors 'aslive' and 'asdevel' debug vars + * @return true if servertype is 'live' + */ +function is_live() +{ + return (preg_match("/^live/", $GLOBALS['ULTRASERVERTYPE']) || EDC('aslive')) && !EDC('asdevel'); +} + + +/** + * Check wether I am on a development server for this service. Honors 'aslive' and 'asdevel' debug vars + * @return true if servertype is 'devel' + */ +function is_devel() +{ + return (preg_match("/^devel/", $GLOBALS['ULTRASERVERTYPE']) || EDC('asdevel')) && !EDC('aslive'); +} + + /** * Convert a string to ASCII-only chars, map/strip ISO-8859-1 accents * @param $text Text to convert diff --git a/itjs.class b/itjs.class index b89e37a..2d9e764 100644 --- a/itjs.class +++ b/itjs.class @@ -139,7 +139,7 @@ function filenames($filelist) */ function strip($code) { - if (!preg_match("/^devel/", $GLOBALS['ULTRASERVERTYPE'])) + if (!it::is_devel()) $code = preg_replace(array( '|\s//.*$|m', '|\s+/\*.*?\*/|s', # MUST require at least one space before "/*" (jquery.js) but MUST NOT require space before "*/" (searchmap.js) @@ -162,7 +162,7 @@ function checksum($files = array()) foreach (array_merge($files, $service_itjs, $itools_itjs, array("$itjs/itjs.php", "$itjs/itjs.class")) as $file) { - if (!preg_match("/^devel/", $GLOBALS['ULTRASERVERTYPE'])) + if (!it::is_devel()) $result += @filesize($file); else $result = md5($result . @file_get_contents($file)); -- cgit v1.2.3