* $Author:: $ *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team *
* For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
// Some security stuff...
if (!defined('__SECURITY')) {
- die();
+ exit();
} // END - if
// Read a given file
// Sanity-check if file is there (should be there, but just to make it sure)
if (!isFileReadable($FQFN)) {
// This should not happen
- debug_report_bug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
+ reportBug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
} elseif (!isset($GLOBALS['file_content'][$FQFN])) {
// Load the file
if (function_exists('file_get_contents')) {
}
} else {
// Write it with fopen
- $fp = fopen($FQFN, 'w') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
+ $fp = fopen($FQFN, 'w') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
// Do we need to aquire a lock?
if ($aquireLock === true) {
// Clears the output buffer. This function does *NOT* backup sent content.
function clearOutputBuffer () {
+ // Make sure this function is not called twice (no double-cleaning!)
+ if (isset($GLOBALS[__FUNCTION__])) {
+ // This function is called twice
+ reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' may cause more trouble.');
+ } // END - if
+
// Trigger an error on failure
if ((ob_get_length() > 0) && (!ob_end_clean())) {
// Failed!
- debug_report_bug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
+ reportBug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
} // END - if
+
+ // Mark this function as called
+ $GLOBALS[__FUNCTION__] = true;
}
// Encode strings
// Are both an array?
if ((!is_array($array1)) && (!is_array($array2))) {
// Both are not arrays
- debug_report_bug(__FUNCTION__, __LINE__, 'No arrays provided!');
+ reportBug(__FUNCTION__, __LINE__, 'No arrays provided!');
} elseif (!is_array($array1)) {
// Left one is not an array
- debug_report_bug(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
+ reportBug(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
} elseif (!is_array($array2)) {
// Right one is not an array
- debug_report_bug(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
+ reportBug(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
}
- // Merge all together
+ // Merge both together
return array_merge($array1, $array2);
}
return $GLOBALS['file_readable'][$FQFN];
}
-// Checks wether the given FQFN is a directory and not ., .. or .svn
+// Checks whether the given FQFN is a directory and not ., .. or .svn
function isDirectory ($FQFN) {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__][$FQFN])) {
return $GLOBALS[__FUNCTION__];
}
-// Check wether we are installing
+// Check whether we are installing
function isInstalling () {
- // Determine wether we are installing
- if (!isset($GLOBALS['mailer_installing'])) {
+ // 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');
} // END - if
// Return result
- return $GLOBALS['mailer_installing'];
+ return $GLOBALS['__mailer_installing'];
}
-// Check wether this script is installed
+// Check whether this script is installed
function isInstalled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
- // Determine wether this script is installed
+ // Determine whether this script is installed
$GLOBALS[__FUNCTION__] = (
(
// First is config
return $GLOBALS[__FUNCTION__];
}
-// Check wether an admin is registered
+// Check whether an admin is registered
function isAdminRegistered () {
// Is cache set?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether the hourly reset mode is active
+// Checks whether the hourly reset mode is active
function isHourlyResetEnabled () {
// Now simply check it
return ((isset($GLOBALS['hourly_enabled'])) && ($GLOBALS['hourly_enabled'] === true));
}
-// Checks wether the reset mode is active
+// Checks whether the reset mode is active
function isResetModeEnabled () {
// Now simply check it
return ((isset($GLOBALS['reset_enabled'])) && ($GLOBALS['reset_enabled'] === true));
}
-// Checks wether the debug mode is enabled
+// Checks whether the debug mode is enabled
function isDebugModeEnabled () {
// Is cache set?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether the debug reset is enabled
+// Checks whether the debug reset is enabled
function isDebugResetEnabled () {
// Is cache set?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether SQL debugging is enabled
+// Checks whether SQL debugging is enabled
function isSqlDebuggingEnabled () {
// Is cache set?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether we shall debug regular expressions
+// Checks whether we shall debug regular expressions
function isDebugRegularExpressionEnabled () {
// Is cache set?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether the cache instance is valid
+// Checks whether the cache instance is valid
function isCacheInstanceValid () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
// Is the source file there?
if (!isFileReadable($source)) {
// Then abort here
- debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
+ reportBug(__FUNCTION__, __LINE__, 'Cannot read from source file ' . basename($source) . '.');
} // END - if
// Is the target directory there?
if (!isDirectory(dirname($dest))) {
// Then abort here
- debug_report_bug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
+ reportBug(__FUNCTION__, __LINE__, 'Cannot find directory ' . str_replace(getPath(), '', dirname($dest)) . '.');
} // END - if
// Now try to copy it
if (!copy($source, $dest)) {
// Something went wrong
- debug_report_bug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
+ reportBug(__FUNCTION__, __LINE__, 'copy() has failed to copy the file.');
} else {
// Reset cache
$GLOBALS['file_readable'][$dest] = true;
// Is the file/directory there?
if ((!isFileReadable($FQFN)) && (!isDirectory($FQFN))) {
// Neither, so abort here
- debug_report_bug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
+ reportBug(__FUNCTION__, __LINE__, 'Cannot chmod() on ' . basename($FQFN) . '.');
} // END - if
// Try to set them
return countSelection(postRequestElement($element));
} else {
// Return zero if not found
- return 0;
+ return '0';
}
}
-// Checks wether the config-local.php is loaded
+// Checks whether the config-local.php is loaded
function isConfigLocalLoaded () {
return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
}
-// Checks wether a nickname or userid was entered and caches the result
+// Checks whether a nickname or userid was entered and caches the result
function isNicknameUsed ($userid) {
// Is the cache there
if (!isset($GLOBALS[__FUNCTION__][$userid])) {
// Determine it
- $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . round($userid) . '') != $userid) && ($userid != 'NULL'));
+ $GLOBALS[__FUNCTION__][$userid] = ((!empty($userid)) && (('' . bigintval($userid, true, false) . '') != $userid) && ($userid != 'NULL'));
} // END - if
// Return the result
// Setter for 'what' value
function setWhat ($newWhat) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newWhat=' . $newWhat);
$GLOBALS['__what'] = $newWhat;
}
setWhat($what);
}
-// Checks wether what is set and optionally aborts on miss
+// Checks whether what is set and optionally aborts on miss
function isWhatSet ($strict = false) {
// Check for it
$isset = (isset($GLOBALS['__what']) && (!empty($GLOBALS['__what'])));
$GLOBALS['__action'] = $newAction;
}
-// Checks wether action is set and optionally aborts on miss
+// Checks whether action is set and optionally aborts on miss
function isActionSet ($strict = false) {
// Check for it
$isset = ((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action'])));
// Should we abort here?
if (($strict === true) && ($isset === false)) {
// Output backtrace
- debug_report_bug(__FUNCTION__, __LINE__, 'action is empty.');
+ reportBug(__FUNCTION__, __LINE__, 'action is empty.');
} // END - if
// Return it
$GLOBALS['__module'] = strtolower($newModule);
}
-// Checks wether module is set and optionally aborts on miss
+// Checks whether module is set and optionally aborts on miss
function isModuleSet ($strict = false) {
// Check for it
$isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
// Should we abort here?
if (($strict === true) && ($isset === false)) {
// Output backtrace
- debug_report_bug(__FUNCTION__, __LINE__, 'Module is empty.');
+ reportBug(__FUNCTION__, __LINE__, 'Module is empty.');
} // END - if
// Return it
// Getter for 'output_mode' value
function getScriptOutputMode () {
- // Do we have cache?
+ // Is cache set?
if (!isset($GLOBALS[__FUNCTION__])) {
- // Default is null
- $output_mode = NULL;
-
- // Is the value set?
- if (isOutputModeSet(true)) {
- // Then use it
- $output_mode = $GLOBALS['output_mode'];
+ // Is the output mode set?
+ if (!isOutputModeSet()) {
+ // No, then abort here
+ reportBug(__FUNCTION__, __LINE__, 'Output mode not set.');
} // END - if
- // Store it in cache
- $GLOBALS[__FUNCTION__] = $output_mode;
+ // Set it in cache
+ $GLOBALS[__FUNCTION__] = $GLOBALS['__output_mode'];
} // END - if
// Return cache
// Setter for 'output_mode' value
function setOutputMode ($newOutputMode) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'output_mode=' . $newOutputMode);
- $GLOBALS['output_mode'] = (int) $newOutputMode;
- $GLOBALS['getScriptOutputMode'] = (int) $newOutputMode;
+ $GLOBALS['__output_mode'] = (int) $newOutputMode;
}
-// Checks wether output_mode is set and optionally aborts on miss
+// Checks whether output_mode is set and optionally aborts on miss
function isOutputModeSet ($strict = false) {
// Check for it
- $isset = (isset($GLOBALS['output_mode']));
+ $isset = (isset($GLOBALS['__output_mode']));
// Should we abort here?
if (($strict === true) && ($isset === false)) {
// Output backtrace
- debug_report_bug(__FUNCTION__, __LINE__, 'Output mode is not set.');
+ reportBug(__FUNCTION__, __LINE__, 'Output mode is not set.');
} // END - if
// Return it
// Enables block-mode
function enableBlockMode ($enabled = true) {
- $GLOBALS['block_mode'] = $enabled;
+ $GLOBALS['__block_mode'] = $enabled;
}
-// Checks wether block-mode is enabled
+// Checks whether block-mode is enabled
function isBlockModeEnabled () {
// Abort if not set
- if (!isset($GLOBALS['block_mode'])) {
+ if (!isset($GLOBALS['__block_mode'])) {
// Needs to be fixed
- debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
+ reportBug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
} // END - if
// Return it
- return $GLOBALS['block_mode'];
-}
-
-/**
- * Wrapper function for addPointsThroughReferralSystem(), you should generally
- * avoid this function and use addPointsThroughReferralSystem() directly and add
- * your special payment method entry to points_data instead.
- *
- * @param $subject A string-encoded subject for this add
- * @param $userid The recipient (member) for given points
- * @param $points Points to be added to member's account
- * @return $added Wether the points has been added to the user's account
- */
-function addPointsDirectly ($subject, $userid, $points) {
- // Reset level here
- initReferralSystem();
-
- // Call more complicated method (due to more parameters)
- return addPointsThroughReferralSystem($subject, $userid, $points, false, 0, 'DIRECT');
+ return $GLOBALS['__block_mode'];
}
// Wrapper for redirectToUrl but URL comes from a configuration entry
return $GLOBALS[__FUNCTION__];
}
-// Checks wether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
+// Checks whether the extension demo is actuve and the admin login is demo (password needs to be demo, too!)
function isDemoModeActive () {
// Is cache set?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS['php_caching'];
}
-// Checks wether the admin hash is set
+// Checks whether the admin hash is set
function isAdminHashSet ($adminId) {
// Is the array there?
if (!isset($GLOBALS['cache_array']['admin'])) {
// Missing array should be reported
- debug_report_bug(__FUNCTION__, __LINE__, 'Cache not set.');
+ reportBug(__FUNCTION__, __LINE__, 'Cache not set.');
} // END - if
// Check for admin hash
// User id should not be zero
if (!isValidUserId(getCurrentUserId())) {
// Should be always valid
- debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
+ reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
} // END - if
// Init the user
// User id should not be zero
if (!isValidUserId(getCurrentUserId())) {
// Should be always valid
- debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
+ reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
} // END - if
// Default is empty
return $data;
}
-// Checks wether given user data is set to 'Y'
+// Checks whether given user data is set to 'Y'
function isUserDataEnabled ($column) {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__][getCurrentUserId()][$column])) {
// Is the current userid valid?
if (!isValidUserId($userid)) {
// Should be always valid
- debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
+ reportBug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
} // END - if
// Get the whole array if found
// Unset it to re-determine the actual state
unset($GLOBALS['is_userdata_valid'][$userid]);
+
+ // Is the cache from below functions different?
+ if ((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) {
+ // Then unset both
+ unset($GLOBALS['getCurrentUserId']);
+ unset($GLOBALS['isCurrentUserIdSet']);
+ } // END - if
}
// Getter for current userid
function getCurrentUserId () {
- // Userid must be set before it can be used
- if (!isCurrentUserIdSet()) {
- // Not set
- debug_report_bug(__FUNCTION__, __LINE__, 'User id is not set.');
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Userid must be set before it can be used
+ if (!isCurrentUserIdSet()) {
+ // Not set
+ reportBug(__FUNCTION__, __LINE__, 'User id is not set.');
+ } // END - if
+
+ // Set userid in cache
+ $GLOBALS[__FUNCTION__] = $GLOBALS['current_userid'];
} // END - if
- // Return the userid
- return $GLOBALS['current_userid'];
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
}
// Checks if current userid is set
function isCurrentUserIdSet () {
- return ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = ((isset($GLOBALS['current_userid'])) && (isValidUserId($GLOBALS['current_userid'])));
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
}
-// Checks wether we are debugging template cache
+// Checks whether we are debugging template cache
function isDebuggingTemplateCache () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return (getTotalFatalErrors() > 0);
}
+// Checks whether a HTTP status has been set
+function isHttpStatusSet () {
+ // Is it set and not empty?
+ return ((isset($GLOBALS['http_status'])) && (!empty($GLOBALS['http_status'])));
+}
+
// Setter for HTTP status
function setHttpStatus ($status) {
$GLOBALS['http_status'] = (string) $status;
// Getter for HTTP status
function getHttpStatus () {
// Is the status set?
- if (!isset($GLOBALS['http_status'])) {
+ if (!isHttpStatusSet()) {
// Abort here
- debug_report_bug(__FUNCTION__, __LINE__, 'No HTTP status set!');
+ reportBug(__FUNCTION__, __LINE__, 'No HTTP status set!');
} // END - if
// Return it
clearOutputBuffer();
// Clear own output buffer
- $GLOBALS['output'] = '';
+ $GLOBALS['__output'] = '';
// To make redirects working (no content type), output mode must be raw
setOutputMode(-1);
}
// Shutdown here
- shutdown();
+ doShutdown();
}
// Determines the country of the given user id
if (!isset($GLOBALS[__FUNCTION__])) {
// Then do it
if (isExtensionActive('user')) {
- $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
+ $GLOBALS[__FUNCTION__] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, runFilterChain('user_exclusion_sql', ' '));
} else {
$GLOBALS[__FUNCTION__] = 0;
}
if (!isset($GLOBALS[__FUNCTION__])) {
// Then do it
if (isExtensionActive('user')) {
- $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true);
+ $GLOBALS[__FUNCTION__] = countSumTotalData('UNCONFIRMED', 'user_data', 'userid', 'status', true, runFilterChain('user_exclusion_sql', ' '));
} else {
$GLOBALS[__FUNCTION__] = 0;
}
if (!isset($GLOBALS[__FUNCTION__])) {
// Then do it
if (isExtensionActive('user')) {
- $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true);
+ $GLOBALS[__FUNCTION__] = countSumTotalData('LOCKED', 'user_data', 'userid', 'status', true, runFilterChain('user_exclusion_sql', ' '));
} else {
$GLOBALS[__FUNCTION__] = 0;
}
if (!isset($GLOBALS[__FUNCTION__])) {
// Then do it
if (isExtensionInstalledAndNewer('user', '0.3.4')) {
- $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', true, '', '>=');
+ $GLOBALS[__FUNCTION__] = countSumTotalData('{?user_min_confirmed?}', 'user_data', 'userid', 'rand_confirmed', true, runFilterChain('user_exclusion_sql', ' '), '>=');
} else {
$GLOBALS[__FUNCTION__] = 0;
}
// Is given userid valid?
function isValidUserId ($userid) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid);
+
+ // Handle NULL
+ if (is_null($userid)) {
+ // Do not handle this as of below isset() will always return false
+ return false;
+ } // END - if
+
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__][$userid])) {
// Check it out
return $GLOBALS[__FUNCTION__][$timestamp];
}
-// Checks wether the title decoration is enabled
+// Checks whether the title decoration is enabled
function isTitleDecorationEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether filter usage updates are enabled (expensive queries!)
+// Checks whether filter usage updates are enabled (expensive queries!)
function isFilterUsageUpdateEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether debugging of weekly resets is enabled
+// Checks whether debugging of weekly resets is enabled
function isWeeklyResetDebugEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether debugging of monthly resets is enabled
+// Checks whether debugging of monthly resets is enabled
function isMonthlyResetDebugEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether displaying of debug SQLs are enabled
+// Checks whether displaying of debug SQLs are enabled
function isDisplayDebugSqlEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether module title is enabled
+// Checks whether module title is enabled
function isModuleTitleEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether what title is enabled
+// Checks whether what title is enabled
function isWhatTitleEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether stats are enabled
+// Checks whether stats are enabled
function ifInternalStatsEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether admin-notification of certain user actions is enabled
+// Checks whether admin-notification of certain user actions is enabled
function isAdminNotificationEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether random referral id selection is enabled
+// Checks whether random referral id selection is enabled
function isRandomReferralIdEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether 'check_double_email' is 'Y'
+// Checks whether 'check_double_email' is 'Y'
function isCheckDoubleEmailEnabled () {
// Is the cache entry set?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether 'display_home_in_index' is 'Y'
+// Checks whether 'display_home_in_index' is 'Y'
function isDisplayHomeInIndexEnabled () {
// Is the cache entry set?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether proxy configuration is used
+// Getter for 'points_remove_account'
+function getPointsRemoveAccount () {
+ // Is the cache entry set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // No, so determine it
+ $GLOBALS[__FUNCTION__] = getConfig('points_remove_account');
+ } // END - if
+
+ // Return cached entry
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether proxy configuration is used
function isProxyUsed () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether POST data contains selections
+// Checks whether POST data contains selections
function ifPostContainsSelections ($element = 'sel') {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__][$element])) {
// Determine it
- $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (countPostSelection($element) > 0));
+ $GLOBALS[__FUNCTION__][$element] = ((isPostRequestElementSet($element)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
} // END - if
// Return cache
return $GLOBALS[__FUNCTION__][$element];
}
-// Checks wether verbose_sql is Y and returns true/false if so
+// Checks whether verbose_sql is Y and returns true/false if so
function isVerboseSqlEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
$data = runFilterChain('get_total_points', $data);
// Determine it
- $GLOBALS[__FUNCTION__][$userid] = $data['points'] - countSumTotalData($userid, 'user_data', 'used_points');
+ $GLOBALS[__FUNCTION__][$userid] = $data['points'] - getUserUsedPoints($userid);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$userid];
+}
+
+// Wrapper to get used points for given userid
+function getUserUsedPoints ($userid) {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$userid])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_data', 'used_points');
} // END - if
// Return cache
return $GLOBALS[__FUNCTION__];
}
-// Checks wether direct payment is allowed in configuration
+// Checks whether direct payment is allowed in configuration
function isDirectPaymentEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
return $GLOBALS[__FUNCTION__];
}
-// Checks wether JavaScript-based admin menu is enabled
+// Checks whether JavaScript-based admin menu is enabled
function isAdminMenuJavascriptEnabled () {
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__])) {
// Determine it
- $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getConfig('admin_menu_javascript') == 'Y'));
+ $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.8.7')) && (getAdminMenuJavaScript() == 'Y'));
} // END - if
// Return cache
// Do we have cache?
if (!isset($GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']])) {
// Determine it
- $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && (isExtensionNameValid($content['infos'])) && (!isExtensionInstalled($content['infos'])));
+ $GLOBALS[__FUNCTION__][$content['task_type'] . '_' . $content['infos']] = (($content['task_type'] == 'EXTENSION') && ((isExtensionNameValid($content['infos'])) || (isExtensionDeprecated($content['infos']))) && (!isExtensionInstalled($content['infos'])));
} // END - if
// Return cache
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?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // No, so determine it
+ $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('ALLOW_TESTER_ACCOUNTS')) && (getConfig('ALLOW_TESTER_ACCOUNTS') == 'Y'));
+ } // END - if
+
+ // Return cached entry
+ return $GLOBALS[__FUNCTION__];
+}
+
// Wrapper to check if output mode is CSS
function isCssOutputMode () {
- // Determine it
- return (getScriptOutputMode() == 1);
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
+ $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 1);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
}
// Wrapper to check if output mode is HTML
function isHtmlOutputMode () {
- // Determine it
- return (getScriptOutputMode() == 0);
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
+ $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == 0);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
}
// Wrapper to check if output mode is RAW
function isRawOutputMode () {
- // Determine it
- return (getScriptOutputMode() == -1);
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
+ $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -1);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
}
// Wrapper to check if output mode is AJAX
function isAjaxOutputMode () {
- // Determine it
- return (getScriptOutputMode() == -2);
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
+ $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -2);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
}
// Wrapper to check if output mode is image
function isImageOutputMode () {
- // Determine it
- return (getScriptOutputMode() == -3);
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getScriptOutputMode()=' . getScriptOutputMode());
+ $GLOBALS[__FUNCTION__] = (getScriptOutputMode() == -3);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
}
// Wrapper to generate a user email link
// Appends a line to an existing file or creates it instantly with given content.
// This function does always add a new-line character to every line.
function appendLineToFile ($file, $line) {
- $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
- fwrite($fp, $line . "\n");
+ $fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
+ fwrite($fp, $line . chr(10));
fclose($fp);
}
}
// Generates a YES/NO option list from given default
-function generateYesNoOptionList ($defaultValue = '') {
+function generateYesNoOptions ($defaultValue = '') {
// Generate it
- return generateOptionList('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
+ return generateOptions('/ARRAY/', array('Y', 'N'), array('{--YES--}', '{--NO--}'), $defaultValue);
}
// "Getter" for total available receivers
function getTotalReceivers ($mode = 'normal') {
// Get num rows
- $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode));
+ $numRows = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
// Return value
return $numRows;
return $GLOBALS[__FUNCTION__][$userid];
}
-// Checks wether 'mailer_theme' was found in session
+// Checks whether 'mailer_theme' was found in session
function isMailerThemeSet () {
- // Check session
- return isSessionVariableSet('mailer_theme');
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
}
/**
* session data or throws an error if not possible
*/
function getMailerTheme () {
- // Is 'mailer_theme' set?
- if (!isMailerThemeSet()) {
- // No, then abort here
- debug_report_bug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Is 'mailer_theme' set?
+ if (!isMailerThemeSet()) {
+ // No, then abort here
+ reportBug(__FUNCTION__, __LINE__, 'mailer_theme not set in session. Please fix your code.');
+ } // END - if
+
+ // Get it and store it in cache
+ $GLOBALS[__FUNCTION__] = getSession('mailer_theme');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for last_module/last_what depending on ext-user version
+function getUserLastWhatName () {
+ // Default is old one: last_module
+ $columnName = 'last_module';
+
+ // Is ext-user up-to-date?
+ if (isExtensionInstalledAndNewer('user', '0.4.9')) {
+ // Yes, then use new one
+ $columnName = 'last_what';
+ } // END - if
+
+ // Return it
+ return $columnName;
+}
+
+// "Getter" for all columns for given alias and separator
+function getAllPointColumns ($alias = NULL, $separator = ',') {
+ // Prepare the filter array
+ $filterData = array(
+ 'columns' => '',
+ 'alias' => $alias,
+ 'separator' => $separator
+ );
+
+ // Run the filter
+ $filterData = runFilterChain('get_all_point_columns', $filterData);
+
+ // Return the columns
+ return $filterData['columns'];
+}
+
+// Checks whether the copyright footer (which breaks framesets) is enabled
+function ifCopyrightFooterEnabled () {
+ // Is not unset and not 'N'?
+ return ((!isset($GLOBALS['__copyright_enabled'])) || ($GLOBALS['__copyright_enabled'] == 'Y'));
+}
+
+/**
+ * Wrapper to check whether we have a "full page". This means that the actual
+ * content is not delivered in any frame of a frameset.
+ */
+function isFullPage () {
+ /*
+ * The parameter 'frame' is generic and always indicates that this content
+ * will be output into a frame. Furthermore, if a frameset is reported or
+ * the copyright line is explicitly deactivated, this cannot be a "full
+ * page" again.
+ */
+ // @TODO Find a way to not use direct module comparison
+ $isFullPage = ((!isGetRequestElementSet('frame')) && (getModule() != 'frametester') && (!isFramesetModeEnabled()) && (ifCopyrightFooterEnabled()));
+
+ // Return it
+ return $isFullPage;
+}
+
+// Checks whether frameset_mode is set to true
+function isFramesetModeEnabled () {
+ // Check it
+ return ((isset($GLOBALS['frameset_mode'])) && ($GLOBALS['frameset_mode'] === true));
+}
+
+// Function to determine correct 'what' value
+function determineWhat ($module = NULL) {
+ // Init default 'what'
+ $what = 'welcome';
+
+ // Is module NULL?
+ if (is_null($module)) {
+ // Then use default
+ $module = getModule();
+ } // END - if
+
+ // Is what set?
+ if (isWhatSet()) {
+ // Then use it
+ $what = getWhat();
+ } else {
+ // Else try to get it from current module
+ $what = getWhatFromModule($module);
+ }
+ //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.$module.'/'.getAction().'/'.getWhat().'*');
+
+ // Remove any spaces from variable
+ $what = trim($what);
+
+ // Is it empty?
+ if (empty($what)) {
+ // Default action for non-admin menus
+ $what = 'welcome';
+ } else {
+ // Secure it
+ $what = secureString($what);
+ }
+
+ // Return what
+ return $what;
+}
+
+// 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) {
+ // Return prepended string
+ return sprintf('%0' . (int) $length . 's', $mStretch);
+}
+
+// Wraps convertSelectionsToEpocheTime()
+function convertSelectionsToEpocheTimeInPostData ($id) {
+ // Init variables
+ $content = array();
+ $skip = false;
+
+ // Get all POST data
+ $postData = postRequestArray();
+
+ // Convert given selection id
+ convertSelectionsToEpocheTime($postData, $content, $id, $skip);
+
+ // Set the POST array back
+ setPostRequestArray($postData);
+}
+
+// Wraps checking if given points account type matches with given in POST data
+function ifPointsAccountTypeMatchesPost ($type) {
+ // Check condition
+ exit(__FUNCTION__.':type='.$type.',post=<pre>'.print_r(postRequestArray(), true).'</pre>');
+}
+
+// Gets given user's total referral
+function getUsersTotalReferrals ($userid, $level = NULL) {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
+ // Is the level NULL?
+ if (is_null($level)) {
+ // Get total amount (all levels)
+ $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', true);
+ } else {
+ // Get it from user refs
+ $GLOBALS[__FUNCTION__][$userid][$level] = countSumTotalData($userid, 'user_refs', 'refid', 'userid', true, ' AND `level`=' . bigintval($level));
+ }
} // END - if
- // Return the theme from session
- return getSession('mailer_theme');
+ // Return it
+ return $GLOBALS[__FUNCTION__][$userid][$level];
+}
+
+// Gets given user's total referral
+function getUsersTotalLockedReferrals ($userid, $level = NULL) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ' - ENTERED!');
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$userid][$level])) {
+ // Default is all refs
+ $add = '';
+
+ // Is the not level NULL?
+ if (!is_null($level)) {
+ // Then add referral level
+ $add = ' AND r.`level`=' . bigintval($level);
+ } // END - if
+
+ // Check for all referrals
+ $result = SQL_QUERY_ESC("SELECT
+ COUNT(d.`userid`) AS `cnt`
+FROM
+ `{?_MYSQL_PREFIX?}_user_data` AS d
+INNER JOIN
+ `{?_MYSQL_PREFIX?}_user_refs` AS r
+ON
+ d.`userid`=r.`refid`
+WHERE
+ d.`status` != 'CONFIRMED' AND
+ r.`userid`=%s
+ " . $add . "
+ORDER BY
+ d.`userid` ASC
+LIMIT 1",
+ array(
+ $userid
+ ), __FUNCTION__, __LINE__);
+
+ // Load count
+ list($GLOBALS[__FUNCTION__][$userid][$level]) = SQL_FETCHROW($result);
+
+ // Free result
+ SQL_FREERESULT($result);
+ } // END - if
+
+ // Return it
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level[' . gettype($level) . ']=' . $level . ':' . $GLOBALS[__FUNCTION__][$userid][$level] . ' - EXIT!');
+ return $GLOBALS[__FUNCTION__][$userid][$level];
+}
+
+// Converts, if found, dollar data to get element
+function convertDollarDataToGetElement ($data) {
+ // Is first char a dollar?
+ if (substr($data, 0, 1) == chr(36)) {
+ // Use last part for getRequestElement()
+ $data = getRequestElement(substr($data, 1));
+ } // END - if
+
+ // Return it
+ return $data;
+}
+
+// Wrapper function for SQL layer to speed-up things
+function SQL_DEBUG_ENABLED () {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = ((!isCssOutputMode()) && (isDebugModeEnabled()) && (isSqlDebuggingEnabled()));
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
}
// [EOF]