// 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
return $GLOBALS[__FUNCTION__];
}
+// Checks whether the debug hourly is enabled
+function isDebugHourlyEnabled () {
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Simply check it
+ $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_HOURLY')) && (getConfig('DEBUG_HOURLY') == 'Y'));
+ } // END - if
+
+ // Return it
+ return $GLOBALS[__FUNCTION__];
+}
+
// Checks whether the debug reset is enabled
function isDebugResetEnabled () {
// Is cache set?
$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
// 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
// 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
$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
// 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
// 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
}
// Checks whether we are debugging template cache
-function isDebuggingTemplateCache () {
+function isDebugTemplateCacheEnabled () {
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__])) {
// Determine it
$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
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
}
// 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()
// 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
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]
?>