sendHeader('Connection: Close');
// Extension 'rewrite' installed?
- if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
+ if ((EXT_IS_ACTIVE('rewrite')) && (getOutputMode() != '1') && (getOutputMode() != '-1')) {
$OUTPUT = rewriteLinksInCode($OUTPUT);
} // END - if
outputRawCode($OUTPUT);
} elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($OUTPUT))) {
// Rewrite links when rewrite extension is active
- if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
+ if ((EXT_IS_ACTIVE('rewrite')) && (getOutputMode() != '1') && (getOutputMode() != '-1')) {
$OUTPUT = rewriteLinksInCode($OUTPUT);
} // END - if
// Load a template file and return it's content (only it's name; do not use ' or ")
function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
+ // @TODO Remove this sanity-check if all is fine
+ if (!is_bool($return)) debug_report_bug('return is not bool (' . gettype($return) . ')');
+
// Add more variables which you want to use in your template files
global $DATA, $username;
////////////////////////
$FQFN = $basePath . $mode . $template . '.tpl';
- if ((!empty($GLOBALS['what'])) && ((strpos($template, '_header') > 0) || (strpos($template, '_footer') > 0)) && (($mode == 'guest/') || ($mode == 'member/') || ($mode == 'admin/'))) {
+ if ((isWhatSet()) && ((strpos($template, '_header') > 0) || (strpos($template, '_footer') > 0)) && (($mode == 'guest/') || ($mode == 'member/') || ($mode == 'admin/'))) {
// Select what depended header/footer template file for admin/guest/member area
$file2 = sprintf("%s%s%s_%s.tpl",
$basePath,
$mode,
$template,
- SQL_ESCAPE($GLOBALS['what'])
+ getWhat()
);
// Probe for it...
}
// Generate a password in a specified length or use default password length
-function generatePassword ($LEN = 0) {
+function generatePassword ($length = 0) {
// Auto-fix invalid length of zero
- if ($LEN == 0) $LEN = getConfig('pass_len');
+ if ($length == 0) $length = getConfig('pass_len');
// Initialize array with all allowed chars
- $ABC = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/');
+ $ABC = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/,.');
// Start creating password
$PASS = '';
- for ($i = 0; $i < $LEN; $i++) {
+ for ($i = 0; $i < $length; $i++) {
$PASS .= $ABC[mt_rand(0, count($ABC) -1)];
} // END - for
// Loads an email template and compiles it
function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
- global $DATA, $_CONFIG;
+ global $DATA;
+
+ // Our configuration is kept non-global here
+ $_CONFIG = getConfigArray();
// Make sure all template names are lowercase!
$template = strtolower($template);
clearOutputBuffer();
} // END - if
- // Secure the URL against bad things such als HTML insertions and so on...
- $URL = htmlentities(strip_tags($URL), ENT_QUOTES);
-
// Simple probe for bots/spiders from search engines
if ((strpos(detectUserAgent(), 'spider') !== false) || (strpos(detectUserAgent(), 'bot') !== false)) {
+ // Secure the URL against bad things such als HTML insertions and so on...
+ $URL = htmlentities(strip_tags($URL), ENT_QUOTES);
+
// Output new location link as anchor
OUTPUT_HTML('<a href="' . $URL . '"' . $rel . '>' . $URL . '</a>');
} elseif (!headers_sent()) {
$NAV .= "<strong>-";
} else {
// Open anchor tag and add base URL
- $NAV .= "<a href=\"{!URL!}/modules.php?module=admin&what=" . $GLOBALS['what']."&page=" . $page."&offset=" . $offset;
+ $NAV .= "<a href=\"{!URL!}/modules.php?module=admin&what=" . getWhat()."&page=" . $page."&offset=" . $offset;
// Add userid when we shall show all mails from a single member
if ((REQUEST_ISSET_GET('uid')) && (bigintval(REQUEST_GET('uid')) > 0)) $NAV .= "&uid=".bigintval(REQUEST_GET('uid'));
// Load header
loadIncludeOnce('inc/header.php');
- // Prepare message for output
+ // Rewrite message for output
$message = sprintf(getMessage('MXCHANGE_HAS_DIED'), basename($F), $L, $message);
+ // Better log this message away
+ DEBUG_LOG($F, $L, $message);
+
// Load the message template
LOAD_TEMPLATE('admin_settings_saved', false, $message);
// Fix it to default
$ret = 'default';
} // END - if
- } elseif ((!isInstalled()) && ((isInstalling()) || ($GLOBALS['output_mode'] == true)) && ((REQUEST_ISSET_GET('theme')) || (REQUEST_ISSET_POST('theme')))) {
+ } elseif ((!isInstalled()) && ((isInstalling()) || (getOutputMode() == true)) && ((REQUEST_ISSET_GET('theme')) || (REQUEST_ISSET_POST('theme')))) {
// Prepare FQFN for checking
$theme = sprintf("%stheme/%s/theme.php", constant('PATH'), REQUEST_GET('theme'));
// Generates an error code from given account status
function generateErrorCodeFromUserStatus ($status) {
+ // @TODO The status should never be empty
+ if (empty($status)) {
+ // Something really bad happend here
+ debug_report_bug(__FUNCTION__ . ': status is empty.');
+ } // END - if
+
// Default error code if unknown account status
$errorCode = getCode('UNKNOWN_STATUS');
if (EXT_IS_ACTIVE('cache')) {
// Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
- if (REQUEST_ISSET_GET('check_revision_data') && REQUEST_GET('check_revision_data') == 'yes') $new = true;
- if (!isset($GLOBALS['cache_array']['revision'][$type])
- || count($GLOBALS['cache_array']['revision']) < 3
- || !$GLOBALS['cache_instance']->loadCacheFile('revision')) $new = true;
+ if (REQUEST_ISSET_GET('check_revision_data') && REQUEST_GET('check_revision_data') == 'yes') {
+ // Force rebuild by URL parameter
+ $new = true;
+ } elseif ((
+ !isset($GLOBALS['cache_array']['revision'][$type])
+ ) || (
+ count($GLOBALS['cache_array']['revision']) < 3
+ ) || (
+ !$GLOBALS['cache_instance']->loadCacheFile('revision')
+ )) {
+ // Out-dated cache
+ $new = true;
+ } // END - if
// Is the cache file outdated/invalid?
if ($new === true){
- $GLOBALS['cache_instance']->destroyCacheFile(); // @TODO isn't it better to do $GLOBALS['cache_instance']->destroyCacheFile('revision')?
+ // Destroy cache file
+ $GLOBALS['cache_instance']->destroyCacheFile();
// @TODO shouldn't do the unset and the reloading $GLOBALS['cache_instance']->destroyCacheFile() Or a new methode like forceCacheReload('revision')?
unset($GLOBALS['cache_array']['revision']);
// Reload load_cach-revison.php
loadInclude('inc/loader/load_cache-revision.php');
+
+ // Abort here
+ return;
} // END - if
// Return found value
return $GLOBALS['cache_array']['revision'][$type][0];
-
} else {
// Old Version without ext-cache active (deprecated ?)
// Check if REQUEST_GET('check_revision_data') is setted (switch for manually rewrite the .revision-File)
if ((REQUEST_ISSET_GET('check_revision_data')) && (REQUEST_GET('check_revision_data') == 'yes')) {
- // Has changed!
+ // Forced rebuild of .revision file
$new = true;
} else {
// Check for revision file
} // END - if
// Add output
- $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a> and include the logfile from <strong>inc/cache/debug.log</strong> in your report (you cannot attach files!):<pre>";
+ $debug .= "Please report this bug at <a title=\"Direct link to the bug-tracker\" href=\"http://bugs.mxchange.org\" rel=\"external\" target=\"_blank\">bugs.mxchange.org</a> and include the logfile from <strong>inc/cache/debug.log</strong> in your report (you can now attach files):<pre>";
$debug .= debug_get_printable_backtrace();
$debug .= "</pre>\nRequest-URI: " . $_SERVER['REQUEST_URI']."<br />\n";
$debug .= "Thank you for finding bugs.";
// Generates a ***weak*** seed (taken from de.php.net/mt_srand)
function generateSeed () {
- list($usec, $sec) = explode(" ", microtime());
- return ((float)$sec + (float)$usec);
+ list($usec, $sec) = explode(' ', microtime());
+ $microTime = (((float)$sec + (float)$usec)) * 100000;
+ return $microTime;
}
// Converts a message code to a human-readable message
// Log this message away
$fp = fopen(constant('PATH')."inc/cache/debug.log", 'a') or app_die(__FUNCTION__, __LINE__, "Cannot write logfile debug.log!");
- fwrite($fp, date("d.m.Y|H:i:s", time())."|" . $GLOBALS['module']."|".basename($funcFile)."|" . $line."|".strip_tags($message)."\n");
+ fwrite($fp, date("d.m.Y|H:i:s", time())."|" . getModule()."|".basename($funcFile)."|" . $line."|".strip_tags($message)."\n");
fclose($fp);
} // END - if
}
// Handle message codes from URL
function handleCodeMessage () {
if (REQUEST_ISSET_GET('msg')) {
- // Default extension is "unknown"
+ // Default extension is 'unknown'
$ext = 'unknown';
// Is extension given?