}
// "Getter" for user agent
-function detectUserAgent () {
+function detectUserAgent ($alwaysReal = false) {
// Get remote ip from environment
$userAgent = getenv('HTTP_USER_AGENT');
// Is removeip installed?
- if (isExtensionActive('removeip')) {
+ if ((isExtensionActive('removeip')) && ($alwaysReal === false)) {
// Then anonymize it
$userAgent = getAnonymousUserAgent($userAgent);
} // END - if
return $referer;
}
+// "Getter" for request URI
+function detectRequestUri () {
+ // Return it
+ return (getenv('REQUEST_URI'));
+}
+
+// "Getter" for query string
+function detectQueryString () {
+ return str_replace('&', '&', (getenv('QUERY_STRING')));
+}
+
// Check wether we are installing
function isInstalling () {
// Determine wether we are installing
if (!isset($GLOBALS['mxchange_installing'])) {
// Check URL (css.php/js.php need this)
- $GLOBALS['mxchange_installing'] = isGetRequestElementSet('installing');
+ $GLOBALS['mxchange_installing'] = isGetRequestParameterSet('installing');
} // END - if
// Return result
// Wrapper function for header()
// Send a header but checks before if we can do so
function sendHeader ($header) {
+ // Send the header
+ $GLOBALS['header'][] = trim($header);
+}
+
+// Flushes all headers
+function flushHeaders () {
// Is the header already sent?
if (headers_sent()) {
// Then abort here
debug_report_bug('Headers already sent!');
} // END - if
- // Send the header
- header(trim($header));
+ // Flush all headers
+ foreach ($GLOBALS['header'] as $header) {
+ header($header);
+ } // END - foreach
+
+ // Mark them as flushed
+ $GLOBALS['header'] = array();
}
// Wrapper function for chmod()
// Wrapper for $_POST['sel']
function countPostSelection ($element = 'sel') {
// Is it set?
- if (isPostRequestElementSet($element)) {
+ if (isPostRequestParameterSet($element)) {
// Return counted elements
- return countSelection(postRequestElement($element));
+ return countSelection(postRequestParameter($element));
} else {
// Return zero if not found
return 0;
$isUsed = $GLOBALS['is_nickname_used'][$userid];
} else {
// Determine it
- $isUsed = ((isExtensionActive('nickname')) && (('' . round($userid) . '') != $userid));
+ $isUsed = (('' . round($userid) . '') != $userid);
// And write it to the cache
$GLOBALS['is_nickname_used'][$userid] = $isUsed;
// Checks wether what is set and optionally aborts on miss
function isWhatSet ($strict = false) {
// Check for it
- $isset = (isset($GLOBALS['what']));
+ $isset = isset($GLOBALS['what']);
// Should we abort here?
if (($strict === true) && ($isset === false)) {
// Checks wether action is set and optionally aborts on miss
function isActionSet ($strict = false) {
// Check for it
- $isset = (isset($GLOBALS['action']));
+ $isset = ((isset($GLOBALS['action'])) && (!empty($GLOBALS['action'])));
// Should we abort here?
if (($strict === true) && ($isset === false)) {
// Get username
function getUsername () {
- return $GLOBALS['username'];
+ // default is guest
+ $username = getMessage('USERNAME_GUEST');
+
+ // User name set?
+ if (isset($GLOBALS['username'])) {
+ // Use the set name
+ $username = $GLOBALS['username'];
+ } // END - if
+
+ // Return it
+ return $username;
}
// Wrapper function for installation phase
return (getConfig('DEBUG_TEMPLATE_CACHE') == 'Y');
}
+// Wrapper for fetchUserData() and getUserData() calls
+function getFetchedUserData ($keyColumn, $userId, $valueColumn) {
+ // Default is 'guest'
+ $data = getMessage('USERNAME_GUEST');
+
+ // Can we fetch the user data?
+ if (($userId > 0) && (fetchUserData($userId, $keyColumn))) {
+ // Now get the data back
+ $data = getUserData($valueColumn);
+ } // END - if
+
+ // Return it
+ return $data;
+}
+
// [EOF]
?>