+// "Getter" for __DB_NAME
+function getDbName () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for DOMAIN
+function getDomain () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for proxy_username
+function getProxyUsername () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for proxy_password
+function getProxyPassword () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for proxy_host
+function getProxyHost () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for proxy_port
+function getProxyPort () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for SMTP_HOSTNAME
+function getSmtpHostname () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for SMTP_USER
+function getSmtpUser () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for SMTP_PASSWORD
+function getSmtpPassword () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for points_word
+function getPointsWord () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('points_word');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for profile_lock
+function getProfileLock () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('profile_lock');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for url_tlock
+function getUrlTlock () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('url_tlock');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for title_left
+function getTitleLeft () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('title_left');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for title_right
+function getTitleRight () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('title_right');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for title_middle
+function getTitleMiddle () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('title_middle');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Getter for 'check_double_email'
+function getCheckDoubleEmail () {
+ // Is the cache entry set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // No, so determine it
+ $GLOBALS[__FUNCTION__] = getConfig('check_double_email');
+ } // END - if
+
+ // Return cached entry
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether 'check_double_email' is 'Y'
+function isCheckDoubleEmailEnabled () {
+ // Is the cache entry set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // No, so determine it
+ $GLOBALS[__FUNCTION__] = (getCheckDoubleEmail() == 'Y');
+ } // END - if
+
+ // Return cached entry
+ return $GLOBALS[__FUNCTION__];
+}
+
+// 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__] = (getDisplayHomeInIndex() == 'Y');
+ } // END - if
+
+ // Return cached entry
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Getter for 'admin_menu_javascript'
+function getAdminMenuJavascript () {
+ // Is the cache entry set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // No, so determine it
+ $GLOBALS[__FUNCTION__] = getConfig('admin_menu_javascript');
+ } // END - if
+
+ // Return cached entry
+ return $GLOBALS[__FUNCTION__];
+}
+
+// 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__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.4.3')) && (getConfig('proxy_host') != '') && (getConfig('proxy_port') > 0));
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// 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)) && (is_array(postRequestElement($element))) && (countPostSelection($element) > 0));
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$element];
+}
+
+// Checks whether verbose_sql is Y and returns true/false if so
+function isVerboseSqlEnabled () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y'));
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for total user points
+function getTotalPoints ($userid) {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$userid])) {
+ // Init array for filter chain
+ $data = array(
+ 'userid' => $userid,
+ 'points' => 0
+ );
+
+ // Run filter chain for getting more point values
+ $data = runFilterChain('get_total_points', $data);
+
+ // Determine it
+ $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__][$userid];
+}
+
+// Wrapper to check if url_blacklist is enabled
+function isUrlBlacklistEnabled () {
+ // Do we have 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 () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = (getConfig('allow_direct_pay') == 'Y');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// 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')) && (getAdminMenuJavaScript() == 'Y'));
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Wrapper to check if current task is for extension (not update)
+function isExtensionTask ($content) {
+ // 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'])) || (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 () {
+ // 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 () {
+ // 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 () {
+ // 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 () {
+ // 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 () {
+ // 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
+function generateWrappedUserEmailLink ($email) {
+ // Just call the inner function
+ return generateEmailLink($email, 'user_data');
+}
+
+// Wrapper to check if user points are locked
+function ifUserPointsLocked ($userid) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!');
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$userid])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
+ } // END - if
+
+ // Return cache
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!');
+ return $GLOBALS[__FUNCTION__][$userid];
+}
+
+// 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 reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
+ fwrite($fp, $line . chr(10));
+ fclose($fp);
+}
+
+// Wrapper for changeDataInFile() but with full path added
+function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) {
+ // Add full path
+ $FQFN = getPath() . $FQFN;
+
+ // Call inner function
+ return changeDataInFile($FQFN, $comment, $prefix, $suffix, $inserted, $seek);
+}
+
+// Wrapper for changing entries in config-local.php
+function changeDataInLocalConfigurationFile ($comment, $prefix, $suffix, $inserted, $seek = 0) {
+ // Call the inner function
+ return changeDataInInclude(getCachePath() . 'config-local.php', $comment, $prefix, $suffix, $inserted, $seek);
+}
+
+// Shortens ucfirst(strtolower()) calls
+function firstCharUpperCase ($str) {
+ return ucfirst(strtolower($str));
+}
+
+// Shortens calls with configuration entry as first argument (the second will become obsolete in the future)
+function createConfigurationTimeSelections ($configEntry, $stamps, $align = 'center') {
+ // Get the configuration entry
+ $configValue = getConfig($configEntry);
+
+ // Call inner method
+ return createTimeSelections($configValue, $configEntry, $stamps, $align);
+}
+
+// Shortens converting of German comma to Computer's version in POST data
+function convertCommaToDotInPostData ($postEntry) {
+ // Read and convert given entry
+ $postValue = convertCommaToDot(postRequestElement($postEntry));
+
+ // ... and set it again
+ setPostRequestElement($postEntry, $postValue);
+}
+
+// Converts German commas to Computer's version in all entries
+function convertCommaToDotInPostDataArray ($postEntries) {
+ // Replace german decimal comma with computer decimal dot
+ foreach ($postEntries as $entry) {
+ // Is the entry there?
+ if (isPostRequestElementSet($entry)) {
+ // Then convert it
+ convertCommaToDotInPostData($entry);
+ } // END - if
+ } // END - foreach
+}
+
+/**
+ * Parses a string into a US formated float variable, taken from user comments
+ * from PHP documentation website.
+ *
+ * @param $floatString A string holding a float expression
+ * @return $float Corresponding float variable
+ * @author chris<at>georgakopoulos<dot>com
+ * @link http://de.php.net/manual/en/function.floatval.php#92563
+ */
+function parseFloat ($floatString){
+ // Load locale info
+ $LocaleInfo = localeconv();
+
+ // Remove thousand separators
+ $floatString = str_replace($LocaleInfo['mon_thousands_sep'] , '' , $floatString);
+
+ // Convert decimal point
+ $floatString = str_replace($LocaleInfo['mon_decimal_point'] , '.', $floatString);
+
+ // Return float value of converted string
+ return floatval($floatString);
+}
+
+// Generates a YES/NO option list from given default
+function generateYesNoOptions ($defaultValue = '') {
+ // Generate it
+ 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, runFilterChain('user_exclusion_sql', ' AND `receive_mails` > 0' . runFilterChain('exclude_users', $mode)));
+
+ // Return value
+ return $numRows;
+}
+
+// Wrapper "getter" to get total unconfirmed mails for given userid
+function getTotalUnconfirmedMails ($userid) {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$userid])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__][$userid] = countSumTotalData($userid, 'user_links', 'id', 'userid', true);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$userid];
+}
+
+// Checks whether 'mailer_theme' was found in session
+function isMailerThemeSet () {
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = isSessionVariableSet('mailer_theme');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+/**
+ * Setter for theme in session (This setter does return the success of
+ * setSession() which is required e.g. for destroySponsorSession().
+ */
+function setMailerTheme ($newTheme) {
+ // Set it in session
+ return setSession('mailer_theme', $newTheme);
+}
+
+/**
+ * Getter for theme from session (This getter does return 'mailer_theme' from
+ * session data or throws an error if not possible
+ */
+function getMailerTheme () {
+ // 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 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__];