global $DATA;
// Do we have cache?
- if (!isset($GLOBALS['template_eval'][$template])) {
+ if (isTemplateCached($template)) {
+ // Evaluate the cache
+ eval(readTemplateCache($template));
+ } elseif (!isset($GLOBALS['template_eval'][$template])) {
// Add more variables which you want to use in your template files
$username = getUsername();
$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;
-
// Base directory
$basePath = sprintf("%stemplates/%s/html/", getConfig('PATH'), getLanguage());
$mode = '';
$ret = "<!-- Template " . $template . " - Start -->\n" . $GLOBALS['tpl_content'] . "<!-- Template " . $template . " - End -->\n";
// Prepare eval() command
- $eval = '$ret = "' . compileCode(smartAddSlashes($GLOBALS['tpl_content'])) . '";';
+ $eval = '$ret = "' . compileCode(smartAddSlashes($ret)) . '";';
} else {
// Prepare eval() command
$eval = '$ret = "' . compileCode(smartAddSlashes($GLOBALS['tpl_content'])) . '";';
return $code;
} // END - if
+ // Start couting
+ $startCompile = explode(' ', microtime());
+
// Init replacement-array with full security characters
$secChars = $GLOBALS['security_chars'];
} // END - foreach
} // END - if
+ // Get timing
+ $compiled = explode(' ', microtime());
+
+ // Add timing
+ $code .= '<!-- Compilation time: ' . ((($compiled[1] + $compiled[0]) - ($startCompile[1] + $startCompile[0])) * 1000). 'ms //-->';
+
// Return compiled code
return $code;
}
return array('', '', '');
} // END - if
- // Compile the script name
- $script = compileCode($script);
-
// Extract host name from script
$host = extractHostnameFromUrl($script);
// Taken from www.php.net eregi() user comments
function isEmailValid ($email) {
- // Compile email
- $email = compileCode($email);
-
// Check first part of email address
$first = '[-a-z0-9!#$%&\'*+/=?^_<{|}~]+(\.[-a-zA-Z0-9!#$%&\'*+/=?^_<{|}~]+)*';
}
// Send notification to admin
function sendAdminNotification ($subject, $templateName, $content=array(), $userid = 0) {
- if (getExtensionVersion('admins') >= '0.4.1') {
+ if (isExtensionInstalledAndNewer('admins', '0.4.1')) {
// Send new way
sendAdminsEmails($subject, $templateName, $content, $userid);
} else {
return $pageTitle;
}
+// Checks wethere there is a cache file there. This function is cached.
+function isTemplateCached ($template) {
+ // Do we have cached this result?
+ if (!isset($GLOBALS['template_cache'][$template])) {
+ // Generate FQFN
+ $FQFN = sprintf("%stemplates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
+
+ // Is it there?
+ $GLOBALS['template_cache'][$template] = isFileReadable($FQFN);
+ } // END - if
+
+ // Return it
+ return $GLOBALS['template_cache'][$template];
+}
+
+// Flushes non-flushed template cache to disk
+function flushTemplateCache ($template, $eval) {
+ // Is this cache flushed?
+ if (!isTemplateCached($template)) {
+ // Generate FQFN
+ $FQFN = sprintf("%stemplates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
+
+ // Replace username with a call
+ $eval = str_replace('$username', '".getUsername()."', $eval);
+
+ // And flush it
+ writeToFile($FQFN, $eval, true);
+ } // END - if
+}
+
+// Reads a template cache
+function readTemplateCache ($template) {
+ // Check it again
+ if (isTemplateCached($template)) {
+ // Generate FQFN
+ $FQFN = sprintf("%stemplates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
+
+ // And read from it
+ $GLOBALS['template_eval'][$template] = readFromFile($FQFN);
+ } // END - if
+
+ // And return it
+ return $GLOBALS['template_eval'][$template];
+}
+
//////////////////////////////////////////////////
// AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
//////////////////////////////////////////////////