X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fwrapper-functions.php;h=6e41821cd2bc15cc9945465e00287c3549c5d40b;hp=2e500b1617efa3bfb7f4a79d87fb0319d5fb6bb0;hb=c3db0c416433a946c25ea1ce8d9329c0912a1616;hpb=2cf4fdd43142b6ed33e4fa3a22539a415333a643 diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 2e500b1617..6e41821cd2 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -326,7 +326,7 @@ function isInstalling () { // Determine whether we are installing if (!isset($GLOBALS['__mailer_installing'])) { // Check URL (css.php/js.php need this) - $GLOBALS['__mailer_installing'] = isGetRequestElementSet('installing'); + $GLOBALS['__mailer_installing'] = (isGetRequestElementSet('installing') || ((isGetRequestElementSet('level')) && (getRequestElement('level') == 'install'))); } // END - if // Return result @@ -389,10 +389,28 @@ function isHourlyResetEnabled () { return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === TRUE)); } -// Checks whether the reset mode is active +// Checks whether the daily reset mode is active +function isDailyResetEnabled () { + // Now simply check it + return ((isset($GLOBALS['daily_enabled'])) && ($GLOBALS['daily_enabled'] === TRUE)); +} + +// Checks whether the weekly reset mode is active +function isWeeklyResetEnabled () { + // Now simply check it + return ((isset($GLOBALS['weekly_enabled'])) && ($GLOBALS['weekly_enabled'] === TRUE)); +} + +// Checks whether the monthly reset mode is active +function isMonthlyResetEnabled () { + // Now simply check it + return ((isset($GLOBALS['monthly_enabled'])) && ($GLOBALS['monthly_enabled'] === TRUE)); +} + +// Checks whether one of the reset modes is enabled function isResetModeEnabled () { // Now simply check it - return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === TRUE)); + return ((isHourlyResetEnabled()) || (isDailyResetEnabled()) || (isWeeklyResetEnabled()) || (isMonthlyResetEnabled())); } // Checks whether the debug mode is enabled @@ -407,12 +425,48 @@ function isDebugModeEnabled () { return $GLOBALS[__FUNCTION__]; } -// Checks whether the debug reset is enabled -function isDebugResetEnabled () { +// Checks whether the debug hourly is enabled +function isDebugHourlyEnabled () { // Is cache set? if (!isset($GLOBALS[__FUNCTION__])) { // Simply check it - $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y')); + $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_HOURLY')) && (getConfig('DEBUG_HOURLY') == 'Y')); + } // END - if + + // Return it + return $GLOBALS[__FUNCTION__]; +} + +// Checks whether the debug daily is enabled +function isDebugDailyEnabled () { + // Is cache set? + if (!isset($GLOBALS[__FUNCTION__])) { + // Simply check it + $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_DAILY')) && (getConfig('DEBUG_DAILY') == 'Y')); + } // END - if + + // Return it + return $GLOBALS[__FUNCTION__]; +} + +// Checks whether the debug weekly is enabled +function isDebugWeeklyEnabled () { + // Is cache set? + if (!isset($GLOBALS[__FUNCTION__])) { + // Simply check it + $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_WEEKLY')) && (getConfig('DEBUG_WEEKLY') == 'Y')); + } // END - if + + // Return it + return $GLOBALS[__FUNCTION__]; +} + +// Checks whether the debug monthly is enabled +function isDebugMonthlyEnabled () { + // Is cache set? + if (!isset($GLOBALS[__FUNCTION__])) { + // Simply check it + $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_MONTHLY')) && (getConfig('DEBUG_MONTHLY') == 'Y')); } // END - if // Return it @@ -673,6 +727,27 @@ function setModule ($newModule) { $GLOBALS['__module'] = strtolower($newModule); } +// Wrapper to get extra module names +function getExtraModule () { + // Default is 'NULL' + $extra = 'NULL'; + + // Is 'tab/step' set? + if (isPostRequestElementSet('tab')) { + // Use this + $extra = 'tab=' . postRequestElement('tab'); + } elseif (isPostRequestElementSet('step')) { + // Use this + $extra = 'step=' . postRequestElement('step'); + } elseif ((isActionSet()) && (isWhatSet())) { + // Use 'action/what' + $extra = 'action=' . getAction() . ':what=' . getWhat(); + } + + // Return it + return $extra; +} + // Checks whether module is set and optionally aborts on miss function isModuleSet ($strict = FALSE) { // Check for it @@ -928,7 +1003,7 @@ function getAdminMd5 () { // Init user data array function initUserData () { // User id should not be zero - if (!isValidUserId(getCurrentUserId())) { + if (!isValidId(getCurrentUserId())) { // Should be always valid reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId()); } // END - if @@ -941,7 +1016,7 @@ function initUserData () { // Getter for user data function getUserData ($column) { // User id should not be zero - if (!isValidUserId(getCurrentUserId())) { + if (!isValidId(getCurrentUserId())) { // Should be always valid reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId()); } // END - if @@ -976,7 +1051,7 @@ function getUserDataArray () { $userid = getCurrentUserId(); // Is the current userid valid? - if (!isValidUserId($userid)) { + if (!isValidId($userid)) { // Should be always valid reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid); } // END - if @@ -1057,7 +1132,7 @@ function isCurrentUserIdSet () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid']))); + $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidId($GLOBALS['current_userid']))); } // END - if // Return cache @@ -1069,7 +1144,7 @@ function unsetCurrentUserId () { // Is it set? if (isset($GLOBALS['current_userid'])) { // Unset this, too - unset($GLOBALS['isValidUserId'][$GLOBALS['current_userid']]); + unset($GLOBALS['isValidId'][$GLOBALS['current_userid']]); } // END - if // Unset all cache entries @@ -1079,7 +1154,7 @@ function unsetCurrentUserId () { } // Checks whether we are debugging template cache -function isDebuggingTemplateCache () { +function isDebugTemplateCacheEnabled () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it @@ -1099,7 +1174,7 @@ function getFetchedUserData ($keyColumn, $userid, $valueColumn) { $data = NULL; // Can we fetch the user data? - if ((isValidUserId($userid)) && (fetchUserData($userid, $keyColumn))) { + if ((isValidId($userid)) && (fetchUserData($userid, $keyColumn))) { // Now get the data back $data = getUserData($valueColumn); } // END - if @@ -1295,20 +1370,20 @@ function getTotalRandomRefidUser () { return $GLOBALS[__FUNCTION__]; } -// Is given userid valid? -function isValidUserId ($userid) { +// Is given id number valid? +function isValidId ($id) { // Debug message - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id[' . gettype($id) . ']=' . $id); // Is there cache? - if (!isset($GLOBALS[__FUNCTION__][$userid])) { + if (!isset($GLOBALS[__FUNCTION__][$id])) { // Check it out - $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid != 'NULL') && ($userid > 0)); + $GLOBALS[__FUNCTION__][$id] = ((!is_null($id)) && (!is_bool($id)) && (!empty($id)) && ($id != 'NULL') && ($id > 0)); } // END - if // Return cache - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',result=' . intval($GLOBALS[__FUNCTION__][$userid])); - return $GLOBALS[__FUNCTION__][$userid]; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',result=' . intval($GLOBALS[__FUNCTION__][$id])); + return $GLOBALS[__FUNCTION__][$id]; } // Encodes entities @@ -1351,7 +1426,7 @@ function getDateTimeFromRepository () { function getYear ($timestamp = NULL) { // Is it cached? if (!isset($GLOBALS[__FUNCTION__][$timestamp])) { - // null is time() + // If NULL is set, use time() if (is_null($timestamp)) { $timestamp = time(); } // END - if @@ -1368,7 +1443,7 @@ function getYear ($timestamp = NULL) { function getMonth ($timestamp = NULL) { // Is it cached? if (!isset($GLOBALS[__FUNCTION__][$timestamp])) { - // If null is set, use time() + // If NULL is set, use time() if (is_null($timestamp)) { // Use time() which is current timestamp $timestamp = time(); @@ -1592,7 +1667,7 @@ function isAdminNotificationEnabled () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = (getConfig('admin_notify') == 'Y'); + $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('other', '0.3.0')) && (getConfig('admin_notify') == 'Y')); } // END - if // Return cache @@ -1604,7 +1679,7 @@ function isRandomReferralIdEnabled () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y')); + $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getSelectUserZeroRefid() == 'Y')); } // END - if // Return cache @@ -1671,6 +1746,18 @@ function getCachePath () { return $GLOBALS[__FUNCTION__]; } +// "Getter" for WRITE_FOOTER +function getWriteFooter () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('WRITE_FOOTER'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // "Getter" for secret_key function getSecretKey () { // Is there cache? @@ -2126,96 +2213,96 @@ function getOneDay () { return $GLOBALS[__FUNCTION__]; } -// "Getter" for activate_xchange -function getActivateXchange () { +// "Getter" for img_type +function getImgType () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = getConfig('activate_xchange'); + $GLOBALS[__FUNCTION__] = getConfig('img_type'); } // END - if // Return cache return $GLOBALS[__FUNCTION__]; } -// "Getter" for img_type -function getImgType () { +// "Getter" for code_length +function getCodeLength () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = getConfig('img_type'); + $GLOBALS[__FUNCTION__] = getConfig('code_length'); } // END - if // Return cache return $GLOBALS[__FUNCTION__]; } -// "Getter" for code_length -function getCodeLength () { +// "Getter" for pass_len +function getPassLen () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = getConfig('code_length'); + $GLOBALS[__FUNCTION__] = getConfig('pass_len'); } // END - if // Return cache return $GLOBALS[__FUNCTION__]; } -// "Getter" for least_cats -function getLeastCats () { +// "Getter" for admin_menu +function getAdminMenu () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = getConfig('least_cats'); + $GLOBALS[__FUNCTION__] = getConfig('admin_menu'); } // END - if // Return cache return $GLOBALS[__FUNCTION__]; } -// "Getter" for pass_len -function getPassLen () { +// "Getter" for last_hourly +function getLastHourly () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = getConfig('pass_len'); + $GLOBALS[__FUNCTION__] = getConfig('last_hourly'); } // END - if // Return cache return $GLOBALS[__FUNCTION__]; } -// "Getter" for admin_menu -function getAdminMenu () { +// "Getter" for last_daily +function getLastDaily () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = getConfig('admin_menu'); + $GLOBALS[__FUNCTION__] = getConfig('last_daily'); } // END - if // Return cache return $GLOBALS[__FUNCTION__]; } -// "Getter" for last_month -function getLastMonth () { +// "Getter" for last_weekly +function getLastWeekly () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = getConfig('last_month'); + $GLOBALS[__FUNCTION__] = getConfig('last_weekly'); } // END - if // Return cache return $GLOBALS[__FUNCTION__]; } -// "Getter" for max_send -function getMaxSend () { +// "Getter" for last_monthly +function getLastMonthly () { // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = getConfig('max_send'); + $GLOBALS[__FUNCTION__] = getConfig('last_monthly'); } // END - if // Return cache @@ -2426,48 +2513,96 @@ function getTitleMiddle () { return $GLOBALS[__FUNCTION__]; } -// Getter for 'check_double_email' -function getCheckDoubleEmail () { +// Getter for 'display_home_in_index' +function getDisplayHomeInIndex () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Checks whether 'display_home_in_index' is 'Y' +function isDisplayHomeInIndexEnabled () { // Is the cache entry set? if (!isset($GLOBALS[__FUNCTION__])) { // No, so determine it - $GLOBALS[__FUNCTION__] = getConfig('check_double_email'); + $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y'); } // END - if // Return cached entry return $GLOBALS[__FUNCTION__]; } -// Checks whether 'check_double_email' is 'Y' -function isCheckDoubleEmailEnabled () { +// Getter for 'show_points_unconfirmed' +function getShowPointsUnconfirmed () { // Is the cache entry set? if (!isset($GLOBALS[__FUNCTION__])) { // No, so determine it - $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y'); + $GLOBALS[__FUNCTION__] = getConfig('show_points_unconfirmed'); } // END - if // Return cached entry return $GLOBALS[__FUNCTION__]; } -// Getter for 'display_home_in_index' -function getDisplayHomeInIndex () { +// Checks whether 'show_points_unconfirmed' is 'Y' +function isShowPointsUnconfirmedEnabled () { // Is the cache entry set? if (!isset($GLOBALS[__FUNCTION__])) { // No, so determine it - $GLOBALS[__FUNCTION__] = getConfig('display_home_in_index'); + $GLOBALS[__FUNCTION__] = (getShowPointsUnconfirmed() == 'Y'); } // END - if // Return cached entry return $GLOBALS[__FUNCTION__]; } -// Checks whether 'display_home_in_index' is 'Y' -function isDisplayHomeInIndexEnabled () { +// Getter for 'youre_here' +function getYoureHere () { // Is the cache entry set? if (!isset($GLOBALS[__FUNCTION__])) { // No, so determine it - $GLOBALS[__FUNCTION__] = (getDisplayHomeInIndex() == 'Y'); + $GLOBALS[__FUNCTION__] = getConfig('youre_here'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Checks whether 'show_timings' is 'Y' +function isYoureHereEnabled () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = (getYoureHere() == 'Y'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Getter for 'show_timings' +function getShowTimings () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = getConfig('show_timings'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Checks whether 'show_timings' is 'Y' +function isShowTimingsEnabled () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = (getShowTimings() == 'Y'); } // END - if // Return cached entry @@ -2498,6 +2633,18 @@ function getApServerName () { return $GLOBALS[__FUNCTION__]; } +// Getter for 'index_delay' +function getIndexDelay () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = getConfig('index_delay'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + // Checks whether 'ap_server_name' is 'Y' function isApServerNameEnabled () { // Is the cache entry set? @@ -2534,6 +2681,90 @@ function getPointsRemoveAccount () { return $GLOBALS[__FUNCTION__]; } +// Getter for 'css_php' +function getCssPhp () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = getConfig('css_php'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Getter for 'guest_menu' +function getGuestMenu () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = getConfig('guest_menu'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Checks if guest menu is enabled +function isGuestMenuEnabled () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = (getGuestMenu() == 'Y'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Getter for 'member_menu' +function getMemberMenu () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = getConfig('member_menu'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Checks if member menu is enabled +function isMemberMenuEnabled () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = (getMemberMenu() == 'Y'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Getter for 'word_wrap' +function getWordWrap () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // Construct config entry name + $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat(); + + // Is a special config entry found or ext-sql_patches updated? + if (isConfigEntrySet($configEntry)) { + // A special config entry has been found, then use it + $GLOBALS[__FUNCTION__] = getConfig($configEntry); + } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) { + // No special config entry found, then use it as "fall-back" + $GLOBALS[__FUNCTION__] = getConfig('word_wrap'); + } else { + // No, use default (15 characters) + $GLOBALS[__FUNCTION__] = 15; + } + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + // Checks whether proxy configuration is used function isProxyUsed () { // Is there cache? @@ -2603,18 +2834,6 @@ function getUserUsedPoints ($userid) { return $GLOBALS[__FUNCTION__][$userid]; } -// Wrapper to check if url_blacklist is enabled -function isUrlBlacklistEnabled () { - // Is there cache? - if (!isset($GLOBALS[__FUNCTION__])) { - // Determine it - $GLOBALS[__FUNCTION__] = (getConfig('url_blacklist') == 'Y'); - } // END - if - - // Return cache - return $GLOBALS[__FUNCTION__]; -} - // Checks whether direct payment is allowed in configuration function isDirectPaymentEnabled () { // Is there cache? @@ -2651,18 +2870,6 @@ function isExtensionTask ($content) { return $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']]; } -// Getter for 'mt_start' -function getMtStart () { - // Is the cache entry set? - if (!isset($GLOBALS[__FUNCTION__])) { - // No, so determine it - $GLOBALS[__FUNCTION__] = getConfig('mt_start'); - } // END - if - - // Return cached entry - return $GLOBALS[__FUNCTION__]; -} - // Checks whether ALLOW_TESTER_ACCOUNTS is set function ifTesterAccountsAllowed () { // Is the cache entry set? @@ -3056,9 +3263,9 @@ function determineWhat ($module = NULL) { } // Fills (prepend) a string with zeros. This function has been taken from user comments at de.php.net/str_pad -function prependZeros ($mStretch, $length = 2) { +function prependZeros ($str, $length = 2) { // Return prepended string - return sprintf('%0' . (int) $length . 's', $mStretch); + return sprintf('%0' . (int) $length . 's', $str); } // Wraps convertSelectionsToEpocheTime() @@ -3112,24 +3319,24 @@ function getUsersTotalLockedReferrals ($userid, $level = NULL) { // Is the not level NULL? if (!is_null($level)) { // Then add referral level - $add = ' AND r.`level`=' . bigintval($level); + $add = ' AND `r`.`level`=' . bigintval($level); } // END - if // Check for all referrals $result = SQL_QUERY_ESC("SELECT - COUNT(d.`userid`) AS `cnt` + COUNT(`d`.`userid`) AS `cnt` FROM - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` INNER JOIN - `{?_MYSQL_PREFIX?}_user_refs` AS r + `{?_MYSQL_PREFIX?}_user_refs` AS `r` ON - d.`userid`=r.`refid` + `d`.`userid`=`r`.`refid` WHERE - d.`status` != 'CONFIRMED' AND - r.`userid`=%s + `d`.`status` != 'CONFIRMED' AND + `r`.`userid`=%s " . $add . " ORDER BY - d.`userid` ASC + `d`.`userid` ASC LIMIT 1", array( $userid @@ -3171,5 +3378,67 @@ function SQL_DEBUG_ENABLED () { return $GLOBALS[__FUNCTION__]; } +// Wrapper function to wrap call of wordwrap() +function wrapWords ($text) { + // Wrap words + $wrapped = wordwrap($test, getWordWrap()); + + // Return it + return $wrapped; +} + +// Encodes given data into a JSON object +function encodeJson ($data) { + // Encode it + return json_encode($data, JSON_FORCE_OBJECT); +} + +// Get all extension files +function loadAllExtensionsByTemplate () { + // Get all + $extensions = getArrayFromDirectory( + 'templates/' . getLanguage() . '/html/ext/', + 'ext_', + false, + false, + array(), + '.tpl', + '@(\.|\.\.)$@', + false + ); + + // Return them + return $extensions; +} + +// Wrapper function to allow full float values as supported by current database layout +function translateFullComma ($dotted) { + // Call inner function + return translateComma($dotted, TRUE, 5); +} + +// Wrapper to check if the first element to be shifted is set to given value +function shift_array (&$array, $value, $key = '0') { + // Is the element set and value matches? + assert(is_array($array)); + assert(isset($array[$key])); + assert($array[$key] === $value); + + // Shift it + array_shift($array); +} + +// Wrapper for str_pad() with left padding zeros +function padLeftZero ($str, $amount = 2) { + // Is str_pad() there? + if (function_exists('str_pad')) { + // Use prependZeros() + return prependZeros($str, $amount); + } else { + // Pad it + return str_pad($str, $amount, '0', STR_PAD_LEFT); + } +} + // [EOF] ?>