// Output HTML code directly or 'render' it. You addionally switch the new-line character off
function OUTPUT_HTML ($HTML, $newLine = true) {
// Some global variables
- global $OUTPUT;
+ global $OUTPUT, $username;
+
+ // Prepare IP number and User Agent
+ $REMOTE_ADDR = detectRemoteAddr();
+ $HTTP_USER_AGENT = detectUserAgent();
// Do we have HTML-Code here?
if (!empty($HTML)) {
default:
// Huh, something goes wrong or maybe you have edited config.php ???
- app_die(__FUNCTION__, __LINE__, "<strong>{--FATAL_ERROR--}:</strong> {--LANG_NO_RENDER_DIRECT--}");
+ app_die(__FUNCTION__, __LINE__, '<strong>{--FATAL_ERROR--}:</strong> {--LANG_NO_RENDER_DIRECT--}');
break;
}
} elseif ((constant('_OB_CACHING') == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
// Headers already sent?
if (headers_sent()) {
// Log this error
- DEBUG_LOG(__FUNCTION__, __LINE__, "Headers already sent! We need debug backtrace here.");
+ DEBUG_LOG(__FUNCTION__, __LINE__, 'Headers already sent! We need debug backtrace here.');
// Trigger an user error
- debug_report_bug("Headers are already sent!");
+ debug_report_bug('Headers are already sent!');
} // END - if
// Output cached HTML code
// Compile and run finished rendered HTML code
while (strpos($OUTPUT, '{!') > 0) {
// Replace _MYSQL_PREFIX
- $OUTPUT = str_replace("{!_MYSQL_PREFIX!}", getConfig('_MYSQL_PREFIX'), $OUTPUT);
+ $OUTPUT = str_replace('{!_MYSQL_PREFIX!}', getConfig('_MYSQL_PREFIX'), $OUTPUT);
// Prepare the content and eval() it...
$newContent = '';
// @TODO Remove this sanity-check if all is fine
if (!is_bool($return)) debug_report_bug('return is not bool (' . gettype($return) . ')');
+ // Prepare IP number and User Agent
+ $REMOTE_ADDR = detectRemoteAddr();
+ $HTTP_USER_AGENT = detectUserAgent();
+
// Add more variables which you want to use in your template files
global $DATA, $username;
- // Get whole config array
- $_CONFIG = getConfigArray();
-
// Make all template names lowercase
$template = strtolower($template);
// Count the template load
incrementConfigEntry('num_templates');
- // Prepare IP number and User Agent
- $REMOTE_ADDR = detectRemoteAddr();
- if (!defined('REMOTE_ADDR')) define('REMOTE_ADDR', $REMOTE_ADDR);
- $HTTP_USER_AGENT = detectUserAgent();
-
// Init some data
$ret = '';
if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0;
+ // Generate date/time string
+ $date_time = generateDateTime(time(), '1');
+
+ // Is content an array
+ if (is_array($content)) $content['date_time'] = $date_time;
+
// @DEPRECATED Try to rewrite the if() condition
if ($template == 'member_support_form') {
// Support request of a member
SQL_FREERESULT($result);
} // END - if
- // Generate date/time string
- $date_time = generateDateTime(time(), '1');
-
// Base directory
- $basePath = sprintf("%stemplates/%s/html/", constant('PATH'), getLanguage());
+ $basePath = sprintf("%stemplates/%s/html/", getConfig('PATH'), getLanguage());
$mode = '';
// Check for admin/guest/member templates
// Do we have to compile the code?
$ret = '';
if ((strpos($tmpl_file, "\$") !== false) || (strpos($tmpl_file, '{--') !== false) || (strpos($tmpl_file, '--}') > 0)) {
- // Okay, compile it!
- $tmpl_file = "\$ret=\"".COMPILE_CODE(smartAddSlashes($tmpl_file))."\";";
- eval($tmpl_file);
+ // Compile it
+ $eval = "\$ret = \"".COMPILE_CODE(smartAddSlashes($tmpl_file))."\";";
+ eval($eval);
+ // NEW WAY: $ret = str_replace("\$content", "\$GLOBALS[compile][".$template."]", $tmpl_file);
+ // NEW WAY: $ret = str_replace("\$DATA", "\$GLOBALS[data][".$template."]", $ret);
+ // NEW WAY: $GLOBALS['compile'][$template] = $content;
+ // NEW WAY: $GLOBALS['data'][$template] = $DATA;
} else {
// Simply return loaded code
$ret = $tmpl_file;
list($toEmail) = SQL_FETCHROW($result_email);
} else {
// Set webmaster
- $toEmail = constant('WEBMASTER');
+ $toEmail = getConfig('WEBMASTER');
}
// Free result
}
} elseif ($toEmail == '0') {
// Is the webmaster!
- $toEmail = constant('WEBMASTER');
+ $toEmail = getConfig('WEBMASTER');
}
//* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail}<br />");
sendRawEmail($toEmail, $subject, $message, $mailHeader);
} elseif ($HTML == 'N') {
// Problem found!
- sendRawEmail(constant('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader);
+ sendRawEmail(getConfig('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader);
}
}
// get new instance
$mail = new PHPMailer();
- $mail->PluginDir = sprintf("%sinc/phpmailer/", constant('PATH'));
+ $mail->PluginDir = sprintf("%sinc/phpmailer/", getConfig('PATH'));
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Username = getConfig('SMTP_USER');
$mail->Password = getConfig('SMTP_PASSWORD');
if (empty($from)) {
- $mail->From = constant('WEBMASTER');
+ $mail->From = getConfig('WEBMASTER');
} else {
$mail->From = $from;
}
- $mail->FromName = constant('MAIN_TITLE');
+ $mail->FromName = getConfig('MAIN_TITLE');
$mail->Subject = $subject;
if ((EXT_IS_ACTIVE('html_mail')) && (strip_tags($message) != $message)) {
$mail->Body = $message;
$mail->Body = decodeEntities($message);
}
$mail->AddAddress($toEmail, '');
- $mail->AddReplyTo(constant('WEBMASTER'), constant('MAIN_TITLE'));
- $mail->AddCustomHeader('Errors-To:' . constant('WEBMASTER'));
- $mail->AddCustomHeader('X-Loop:' . constant('WEBMASTER'));
+ $mail->AddReplyTo(getConfig('WEBMASTER'), getConfig('MAIN_TITLE'));
+ $mail->AddCustomHeader('Errors-To:' . getConfig('WEBMASTER'));
+ $mail->AddCustomHeader('X-Loop:' . getConfig('WEBMASTER'));
$mail->Send();
} else {
// Use legacy mail() command
// Generates an URL for the dereferer
function DEREFERER ($URL) {
// Don't de-refer our own links!
- if (substr($URL, 0, strlen(constant('URL'))) != constant('URL')) {
+ if (substr($URL, 0, strlen(getConfig('URL'))) != getConfig('URL')) {
// De-refer this link
$URL = 'modules.php?module=loader&url=' . encodeString(compileUriCode($URL));
} // END - if
// Generates an URL for the frametester
function FRAMETESTER ($URL) {
// Prepare frametester URL
- $frametesterUrl = sprintf("{!URL!}/modules.php?module=frametester&url=%s",
+ $frametesterUrl = sprintf("{?URL?}/modules.php?module=frametester&url=%s",
encodeString(compileUriCode($URL))
);
return $frametesterUrl;
// Generate XHTML code for the CAPTCHA
function generateCaptchaCode ($code, $type, $DATA, $uid) {
- return '<IMG border="0" alt="Code" src="{!URL!}/mailid_top.php?uid=' . $uid . '&' . $type . '=' . $DATA . '&mode=img&code=' . $code . '" />';
+ return '<IMG border="0" alt="Code" src="{?URL?}/mailid_top.php?uid=' . $uid . '&' . $type . '=' . $DATA . '&mode=img&code=' . $code . '" />';
}
// Loads an email template and compiles it
$HTTP_USER_AGENT = detectUserAgent();
// Default admin
- $ADMIN = constant('MAIN_TITLE');
+ $ADMIN = getConfig('MAIN_TITLE');
// Is the admin logged in?
if (IS_ADMIN()) {
} // END - if
// Neutral email address is default
- $email = constant('WEBMASTER');
+ $email = getConfig('WEBMASTER');
// Expiration in a nice output format
// NOTE: Use $content[expiration] in your templates instead of $EXPIRATION
$DATA['email'] = $email;
// Base directory
- $basePath = sprintf("%stemplates/%s/emails/", constant('PATH'), getLanguage());
+ $basePath = sprintf("%stemplates/%s/emails/", getConfig('PATH'), getLanguage());
// Check for admin/guest/member templates
if (strpos($template, 'admin_') > -1) {
// Check if http(s):// is there
if ((substr($URL, 0, 7) != 'http://') && (substr($URL, 0, 8) != 'https://')) {
// Make all URLs full-qualified
- $URL = constant('URL') . '/' . $URL;
+ $URL = getConfig('URL') . '/' . $URL;
} // END - if
// Three different debug ways...
$rel = ' rel="external"';
// Do we have internal or external URL?
- if (substr($URL, 0, strlen(constant('URL'))) == constant('URL')) {
+ if (substr($URL, 0, strlen(getConfig('URL'))) == getConfig('URL')) {
// Own (=internal) URL
$rel = '';
} // END - if
if ($constants === true) {
// BEFORE 0.2.1 : Language and data constants
// WITH 0.2.1+ : Only language constants
- $code = str_replace('{--','".', str_replace('--}','."', $code));
+ $code = str_replace('{--', "\".getMessage('", str_replace('--}', "').\"", $code));
// BEFORE 0.2.1 : Not used
// WITH 0.2.1+ : Data constants
- $code = str_replace('{!','".', str_replace("!}", '."', $code));
+ $code = str_replace('{!', "\".constant('", str_replace("!}", "').\"", $code));
} // END - if
// Compile QUOT and other non-HTML codes
// But shall I keep simple quotes for later use?
if ($simple) $code = str_replace("'", '{QUOT}', $code);
+ // Compile {?some_var?} to getConfig('some_var')
+ preg_match_all('/\{\?(([a-zA-Z0-9-_]+)*)\?\}/', $code, $matches);
+
+ // Some entries found?
+ if ((count($matches) > 0) && (count($matches[0]) > 0)) {
+ // Replace all matches
+ foreach ($matches[0] as $key => $match) {
+ // Replace it
+ //* DEBUG: */ if ($key == 0) { print '<pre>'; debug_print_backtrace(); print '</pre>'; }
+ //* DEBUG: */ print $match.'='.$matches[1][$key].' ('.$key.')<br />';
+ $code = str_replace($match, getConfig($matches[1][$key]), $code);
+ } // END - foreach
+ } // END - if
+
// Find $content[bla][blub] entries
- preg_match_all('/\$(content|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches);
+ preg_match_all('/\$(content|GLOBALS|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches);
// Are some matches found?
if ((count($matches) > 0) && (count($matches[0]) > 0)) {
} // END - foreach
// Skip this entry?
- if ($fuzzyFound) continue;
+ if ($fuzzyFound === true) continue;
// Take all string elements
if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key."_" . $matches[4][$key]]))) {
// Replace it in the code
//* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):key={$key},match={$match}<br />");
- $newMatch = str_replace("[" . $matches[4][$key]."]", "['" . $matches[4][$key]."']", $match);
+ $newMatch = str_replace('[', "['", str_replace(']', "']", $match));
$code = str_replace($match, "\"." . $newMatch.".\"", $code);
- $matchesFound[$key."_" . $matches[4][$key]] = 1;
+ $matchesFound[$key . '_' . $matches[4][$key]] = 1;
$matchesFound[$match] = 1;
} elseif (!isset($matchesFound[$match])) {
// Not yet replaced!
// Optional : $DATA
//
function generateRandomCode ($length, $code, $uid, $DATA = '') {
- // Fix missing _MAX constant
- // @TODO Rewrite this unnice code
- if (!defined('_MAX')) define('_MAX', 15235);
-
// Build server string
- $server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr().":'.':".filemtime(constant('PATH').'inc/databases.php');
+ $server = $_SERVER['PHP_SELF'].getConfig('ENCRYPT_SEPERATOR').detectUserAgent().getConfig('ENCRYPT_SEPERATOR').getenv('SERVER_SOFTWARE').getConfig('ENCRYPT_SEPERATOR').detectRemoteAddr().":'.':".filemtime(getConfig('PATH').'inc/databases.php');
// Build key string
$keys = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY');
$saltedHash = generateHash(($a % getConfig('_PRIME')).getConfig('ENCRYPT_SEPERATOR') . $server.getConfig('ENCRYPT_SEPERATOR') . $keys.getConfig('ENCRYPT_SEPERATOR') . $data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR') . $a, getConfig('master_salt'));
// Create number from hash
- $rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(constant('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi();
+ $rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(getConfig('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi();
} else {
// Generate hash with "hash of site key" from modula of number with the prime number and other data
$saltedHash = generateHash(($a % getConfig('_PRIME')).getConfig('ENCRYPT_SEPERATOR') . $server.getConfig('ENCRYPT_SEPERATOR') . $keys.getConfig('ENCRYPT_SEPERATOR') . $data.getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY').getConfig('ENCRYPT_SEPERATOR') . $a, substr(sha1(getConfig('SITE_KEY')), 0, 8));
// Create number from hash
- $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(constant('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi();
+ $rcode = hexdec(substr($saltedHash, 8, 9)) / abs(getConfig('_MAX') - $a + sqrt(getConfig('_ADD'))) / pi();
}
// At least 10 numbers shall be secure enought!
return;
} elseif (!$headerSent) {
// Return in an HTML code code
- return "<img src=\"{!URL!}/img.php?code=" . $img_code."\" alt=\"Image\" />\n";
+ return "<img src=\"{?URL?}/img.php?code=" . $img_code."\" alt=\"Image\" />\n";
}
// Load image
- $img = sprintf("%s/theme/%s/images/code_bg.%s", constant('PATH'), getCurrentTheme(), getConfig('img_type'));
+ $img = sprintf("%s/theme/%s/images/code_bg.%s", getConfig('PATH'), getCurrentTheme(), getConfig('img_type'));
if (isFileReadable($img)) {
// Switch image type
switch (getConfig('img_type'))
$NAV .= "<strong>-";
} else {
// Open anchor tag and add base URL
- $NAV .= "<a href=\"{!URL!}/modules.php?module=admin&what=" . getWhat()."&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'));
// Extract host from script name
function extractHostnameFromUrl (&$script) {
// Use default SERVER_URL by default... ;) So?
- $url = constant('SERVER_URL');
+ $url = getConfig('SERVER_URL');
// Is this URL valid?
if (substr($script, 0, 7) == 'http://') {
// Generate GET request header
$request = "GET /" . trim($script) . " HTTP/1.1" . getConfig('HTTP_EOL');
$request .= "Host: " . $host . getConfig('HTTP_EOL');
- $request .= "Referer: " . constant('URL') . "/admin.php" . getConfig('HTTP_EOL');
- if (defined('FULL_VERSION')) {
- $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . getConfig('HTTP_EOL');
- } else {
- $request .= "User-Agent: " . constant('TITLE') . "/?.?.?" . getConfig('HTTP_EOL');
- }
+ $request .= "Referer: " . getConfig('URL') . "/admin.php" . getConfig('HTTP_EOL');
+ $request .= "User-Agent: " . getConfig('TITLE') . '/' . getConfig('FULL_VERSION') . getConfig('HTTP_EOL');
$request .= "Content-Type: text/plain" . getConfig('HTTP_EOL');
$request .= "Cache-Control: no-cache" . getConfig('HTTP_EOL');
$request .= "Connection: Close" . getConfig('HTTP_EOL') . getConfig('HTTP_EOL');
// Generate POST request header
$request = "POST /" . trim($script) . " HTTP/1.1" . getConfig('HTTP_EOL');
$request .= "Host: " . $host . getConfig('HTTP_EOL');
- $request .= "Referer: " . constant('URL') . "/admin.php" . getConfig('HTTP_EOL');
- $request .= "User-Agent: " . constant('TITLE') . '/' . constant('FULL_VERSION') . getConfig('HTTP_EOL');
+ $request .= "Referer: " . getConfig('URL') . "/admin.php" . getConfig('HTTP_EOL');
+ $request .= "User-Agent: " . getConfig('TITLE') . '/' . getConfig('FULL_VERSION') . getConfig('HTTP_EOL');
$request .= "Content-type: application/x-www-form-urlencoded" . getConfig('HTTP_EOL');
$request .= "Content-length: " . strlen($data) . getConfig('HTTP_EOL');
$request .= "Cache-Control: no-cache" . getConfig('HTTP_EOL');
$eval = "\$OUT = \"[ ";
foreach ($TARGETS as $tar) {
- $eval .= "<span class=\\\"admin_user_link\\\"><a href=\\\"{!URL!}/modules.php?module=admin&what=" . $tar."&uid=" . $uid."\\\" title=\\\"{--ADMIN_LINK_";
+ $eval .= "<span class=\\\"admin_user_link\\\"><a href=\\\"{?URL?}/modules.php?module=admin&what=" . $tar."&uid=" . $uid."\\\" title=\\\"{--ADMIN_LINK_";
//* DEBUG: */ OUTPUT_HTML("*" . $tar.'/' . $status."*<br />");
if (($tar == "lock_user") && ($status == 'LOCKED')) {
// Locked accounts shall be unlocked
} // END - if
} 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'));
+ $theme = sprintf("%stheme/%s/theme.php", getConfig('PATH'), REQUEST_GET('theme'));
// Installation mode active
if ((REQUEST_ISSET_GET('theme')) && (isFileReadable($theme))) {
// Set cookie from URL data
setSession('mxchange_theme', REQUEST_GET('theme'));
- } elseif (isFileReadable(sprintf("%stheme/%s/theme.php", constant('PATH'), SQL_ESCAPE(REQUEST_POST('theme'))))) {
+ } elseif (isFileReadable(sprintf("%stheme/%s/theme.php", getConfig('PATH'), SQL_ESCAPE(REQUEST_POST('theme'))))) {
// Set cookie from posted data
setSession('mxchange_theme', SQL_ESCAPE(REQUEST_POST('theme')));
}
// Walk through all entries
foreach ($ds as $d) {
// Generate proper FQFN
- $FQFN = str_replace('//', '/', constant('PATH') . $dir. '/'. $d);
+ $FQFN = str_replace('//', '/', getConfig('PATH') . $dir. '/'. $d);
// Is it a file and readable?
//* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):FQFN={$FQFN}<br />");
// Old Version without ext-cache active (deprecated ?)
// FQFN of revision file
- $FQFN = sprintf("%sinc/cache/.revision", constant('PATH'));
+ $FQFN = sprintf("%sinc/cache/.revision", getConfig('PATH'));
// 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')) {
if (!empty($message)) {
// Use and log it
$debug = sprintf("Note: %s<br />\n",
- $message
+ $message
);
// @TODO Add a little more infos here
$message = str_replace("\r", '', str_replace("\n", '', $message));
// Log this message away, we better don't call app_die() here to prevent an endless loop
- $fp = fopen(constant('PATH') . 'inc/cache/debug.log', 'a') or die(__FUNCTION__.'['.__LINE__.']: Cannot write logfile debug.log!');
+ $fp = fopen(getConfig('PATH') . 'inc/cache/debug.log', 'a') or die(__FUNCTION__.'['.__LINE__.']: Cannot write logfile debug.log!');
fwrite($fp, date('d.m.Y|H:i:s', time()) . '|' . getModule() . '|' . basename($funcFile) . '|' . $line . '|' . strip_tags($message) . "\n");
fclose($fp);
} // END - if
$files = array();
// Open directory
- $dirPointer = opendir(constant('PATH') . $baseDir) or app_die(__FUNCTION__, __LINE__, 'Cannot read directory ' . basename($baseDir) . '.');
+ $dirPointer = opendir(getConfig('PATH') . $baseDir) or app_die(__FUNCTION__, __LINE__, 'Cannot read directory ' . basename($baseDir) . '.');
// Read all entries
while ($baseFile = readdir($dirPointer)) {
// Construct include filename and FQFN
$fileName = $baseDir . '/' . $baseFile;
- $FQFN = constant('PATH') . $fileName;
+ $FQFN = getConfig('PATH') . $fileName;
// Remove double slashes
$FQFN = str_replace('//', '/', $FQFN);