// Main compilation loop
function doFinalCompilation ($code, $insertComments = true) {
- // Insert comments?
+ // Insert comments? (Only valid with HTML templates, of course)
enableTemplateHtml($insertComments);
// Init counter
$cnt = 0;
// Compile all out
- while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{!') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($cnt < 3)) {
+ while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($cnt < 3)) {
// Init common variables
$content = array();
$newContent = '';
// Compile it
//* DEBUG: */ print '<pre>'.htmlentities($code).'</pre>';
$eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code))) . '";';
- //* DEBUG: */ die('<pre>'.htmlentities($eval).'</pre>');
+ //* DEBUG: */ if ($insertComments) die('<pre>'.linenumberCode($eval).'</pre>');
eval($eval);
//* DEBUG: */ die('<pre>'.htmlentities($newContent).'</pre>');
// Do we have to compile the code?
$ret = '';
- if ((strpos($GLOBALS['tpl_content'], '$') !== false) || (strpos($GLOBALS['tpl_content'], '{--') !== false) || (strpos($GLOBALS['tpl_content'], '{!') !== false) || (strpos($GLOBALS['tpl_content'], '{?') !== false) || (strpos($GLOBALS['tpl_content'], '{%') !== false)) {
+ if ((strpos($GLOBALS['tpl_content'], '$') !== false) || (strpos($GLOBALS['tpl_content'], '{--') !== false) || (strpos($GLOBALS['tpl_content'], '{?') !== false) || (strpos($GLOBALS['tpl_content'], '{%') !== false)) {
// Normal HTML output?
if (getOutputMode() == '0') {
// Add surrounding HTML comments to help finding bugs faster
}
// Why did we end up here? This should not happen
- debug_report_bug('Ending up: template=' . $template);
+ debug_report_bug(__FUNCTION__, __LINE__, 'Ending up: template=' . $template);
}
// Check to use wether legacy mail() command or PHPMailer class
case 'N': $content[$prefix . 'visible_css'] = $prefix . 'menu_invisible'; break;
default:
// Please report this
- debug_report_bug('Unsupported visible value detected. content=<pre>'.print_r($content, true).'</pre>');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Unsupported visible value detected. content=<pre>'.print_r($content, true).'</pre>');
break;
} // END - switch
case 'N': $content[$prefix . 'locked_css'] = $prefix . 'menu_unlocked'; break;
default:
// Please report this
- debug_report_bug('Unsupported locked value detected. content=<pre>'.print_r($content, true).'</pre>');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Unsupported locked value detected. content=<pre>'.print_r($content, true).'</pre>');
break;
} // END - switch
// Simple probe for bots/spiders from search engines
if ((isSpider()) && ($allowSpider === true)) {
+ // Set HTTP-Status
+ setHttpStatus('200 OK');
+
// Set content-type here to fix a missing array element
setContentType('text/html');
}
// Compiles the code (use compileCode() only for HTML because of the comments)
-// @TODO $simple is deprecated
+// @TODO $simple/$constants are deprecated
function compileRawCode ($code, $simple = false, $constants = true, $full = true) {
// Is the code a string?
if (!is_string($code)) {
// Compile more through a filter
$code = runFilterChain('compile_code', $code);
- // Compile constants
- if ($constants === true) {
- // BEFORE 0.2.1 : Language and data constants
- // WITH 0.2.1+ : Only language constants
- $code = str_replace('{--', "{DQUOTE} . getMessage('", str_replace('--}', "') . {DQUOTE}", $code));
-
- // BEFORE 0.2.1 : Not used
- // WITH 0.2.1+ : Data constants
- $code = str_replace('{!', "{DQUOTE} . constant('", str_replace('!}', "') . {DQUOTE}", $code));
- } // END - if
+ // Compile message strings
+ $code = str_replace('{--', '{%message,', str_replace('--}', '%}', $code));
// Compile QUOT and other non-HTML codes
foreach ($secChars['to'] as $k => $to) {
// Back-ported from the new ship-simu engine. :-)
function debug_get_printable_backtrace () {
// Init variable
- $backtrace = "<ol>\n";
+ $backtrace = '<ol>';
// Get and prepare backtrace for output
$backtraceArray = debug_backtrace();
if (!isset($trace['file'])) $trace['file'] = __FUNCTION__;
if (!isset($trace['line'])) $trace['line'] = __LINE__;
if (!isset($trace['args'])) $trace['args'] = array();
- $backtrace .= "<li class=\"debug_list\"><span class=\"backtrace_file\">".basename($trace['file'])."</span>:" . $trace['line'].", <span class=\"backtrace_function\">" . $trace['function'].'('.count($trace['args']).")</span></li>\n";
+ $backtrace .= '<li class="debug_list"><span class="backtrace_file">' . basename($trace['file']) . '</span>:' . $trace['line'].", <span class=\"backtrace_function\">" . $trace['function'] . '(' . count($trace['args']) . ')</span></li>';
} // END - foreach
// Close it
- $backtrace .= "</ol>\n";
+ $backtrace .= '</ol>';
// Return the backtrace
return $backtrace;
} // 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\">http://bugs.mxchange.org</a> and include the logfile from <strong>" . str_replace(getConfig('PATH'), '', getConfig('CACHE_PATH')) . "debug.log</strong> in your report (you can now 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">http://bugs.mxchange.org</a> and include the logfile from <strong>' . str_replace(getConfig('PATH'), '', getConfig('CACHE_PATH')) . 'debug.log</strong> in your report (you can now attach files):<pre>';
$debug .= debug_get_printable_backtrace();
- $debug .= "</pre>\nRequest-URI: " . getRequestUri()."<br />\n";
- $debug .= "Thank you for finding bugs.";
+ $debug .= '</pre>Request-URI: ' . getRequestUri() . '<br />';
+ $debug .= 'Thank you for finding bugs.';
// Send an email? (e.g. not wanted for evaluation errors)
if (($sendEmail === true) && (!isInstallationPhase())) {
// Prepare content
$content = array(
- 'message' => trim($message),
- 'backtrace' => trim(debug_get_mailable_backtrace())
+ 'message' => trim($message),
+ 'backtrace' => trim(debug_get_mailable_backtrace())
);
// Send email to webmaster
$GLOBALS['cache_instance'] = new CacheSystem();
if ($GLOBALS['cache_instance']->getStatus() != 'done') {
// Failed to initialize cache sustem
- addFatalMessage(__FUNCTION__, __LINE__, '(<font color="#0000aa">' . __LINE__ . '</font>): ' . getMessage('CACHE_CANNOT_INITIALIZE'));
+ addFatalMessage(__FUNCTION__, __LINE__, '(<font color="#0000aa">' . __LINE__ . '</font>): {--CACHE_CANNOT_INITIALIZE--}');
} // END - if
}
// Prepares the header for HTML output
function loadHtmlHeader () {
- // Enable HTML templates
- enableTemplateHtml();
-
// Run two filters:
// 1.) pre_page_header (mainly loads the page_header template and includes
// meta description)