// Output HTML code directly or 'render' it. You addionally switch the new-line character off
function outputHtml ($htmlCode, $newLine = true) {
+ // Init output
+ if (!isset($GLOBALS['output'])) $GLOBALS['output'] = '';
+
// Transfer username
$username = getMessage('USERNAME_UNKNOWN');
if (isset($GLOBALS['username'])) $username = getUsername();
// Eval the code
eval($GLOBALS['template_eval'][$template]);
- } else {
- // No file!
- $GLOBALS['template_eval'][$template] = '404';
- }
- } elseif (((isAdmin()) || ((isInstalling()) && (!isInstalled()))) && ($GLOBALS['template_eval'][$template] == '404')) {
- // Only admins shall see this warning or when installation mode is active
- $ret = '<br /><span class=\\"guest_failed\\">{--TEMPLATE_404--}</span><br />
+ } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) {
+ // Only admins shall see this warning or when installation mode is active
+ $ret = '<br /><span class=\\"guest_failed\\">{--TEMPLATE_404--}</span><br />
(' . $template . ')<br />
<br />
{--TEMPLATE_CONTENT--}
<pre>' . print_r($content, true) . '</pre>
{--TEMPLATE_DATA--}
<pre>' . print_r($DATA, true) . '</pre>
-<br /><br />\";';
+<br /><br />';
+ } else {
+ // No file!
+ $GLOBALS['template_eval'][$template] = '404';
+ }
} else {
// Eval the code
eval($GLOBALS['template_eval'][$template]);
// Return the HTML code
return $ret;
} else {
- // Output direct
+ // Output directly
outputHtml($ret);
}
} elseif (isDebugModeEnabled()) {
function loadEmailTemplate ($template, $content = array(), $UID = 0) {
global $DATA;
- // Our configuration is kept non-global here
- $_CONFIG = getConfigArray();
-
// Make sure all template names are lowercase!
$template = strtolower($template);
unset($DATA);
// Compile the code and eval it
- $eval = '$newContent = "' . compileCode(smartAddSlashes($newContent)) . '";';
+ $eval = '$newContent = "' . compileRawCode(smartAddSlashes($newContent)) . '";';
eval($eval);
// Return content
//* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):TO={$toEmail},SUBJECT={$subject}<br />");
// Compile subject line (for POINTS constant etc.)
- eval("\$subject = decodeEntities(\"".compileCode(smartAddSlashes($subject))."\");");
+ eval("\$subject = decodeEntities(\"".compileRawCode(smartAddSlashes($subject))."\");");
// Set from header
if ((!eregi('@', $toEmail)) && ($toEmail > 0)) {
}
// Compile "TO"
- eval("\$toEmail = \"".compileCode(smartAddSlashes($toEmail))."\";");
+ eval("\$toEmail = \"".compileRawCode(smartAddSlashes($toEmail))."\";");
// Compile "MSG"
- eval("\$message = \"".compileCode(smartAddSlashes($message))."\";");
+ eval("\$message = \"".compileRawCode(smartAddSlashes($message))."\";");
// Fix HTML parameter (default is no!)
if (empty($isHtml)) $isHtml = 'N';
// Redirects to an URL and if neccessarry extends it with own base URL
function redirectToUrl ($URL) {
// Compile out codes
- eval('$URL = "' . compileCode($URL) . '";');
+ eval('$URL = "' . compileRawCode($URL) . '";');
// Check if http(s):// is there
if ((substr($URL, 0, 7) != 'http://') && (substr($URL, 0, 8) != 'https://')) {
return $code;
} // END - if
+ // Start couting
+ $startCompile = explode(' ', microtime());
+
+ // Comile the code
+ $code = compileRawCode($code, $simple, $constants, $full);
+
+ // 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;
+}
+
+// Compiles the code (use compileCode() only for HTML because of the comments)
+function compileRawCode ($code, $simple = false, $constants = true, $full = true) {
+ // Is the code a string?
+ if (!is_string($code)) {
+ // Silently return it
+ return $code;
+ } // END - if
+
// Init replacement-array with full security characters
$secChars = $GLOBALS['security_chars'];
} // END - foreach
} // END - if
- // Return compiled code
+ // Return it
return $code;
}
}
//
-function addSelectionBox ($type, $default, $prefix = '', $id = 0) {
+function addSelectionBox ($type, $default, $prefix = '', $id = 0, $class = 'register_select') {
$OUT = '';
if ($type == 'yn') {
// This is a yes/no selection only!
if ($id > 0) $prefix .= "[" . $id."]";
- $OUT .= " <select name=\"" . $prefix."\" class=\"register_select\" size=\"1\">\n";
+ $OUT .= " <select name=\"" . $prefix."\" class=\"" . $class . "\" size=\"1\">\n";
} else {
// Begin with regular selection box here
if (!empty($prefix)) $prefix .= "_";
$type2 = $type;
if ($id > 0) $type2 .= "[" . $id."]";
- $OUT .= " <select name=\"".strtolower($prefix . $type2)."\" class=\"register_select\" size=\"1\">\n";
+ $OUT .= " <select name=\"".strtolower($prefix . $type2)."\" class=\"" . $class . "\" size=\"1\">\n";
}
switch ($type) {
$data .= getConfig('ENCRYPT_SEPERATOR') . determineReferalId();
$data .= getConfig('ENCRYPT_SEPERATOR') . getLanguage();
$data .= getConfig('ENCRYPT_SEPERATOR') . getCurrentTheme();
- $data .= getConfig('ENCRYPT_SEPERATOR') . getUserId();
+ $data .= getConfig('ENCRYPT_SEPERATOR') . getMemberId();
// Calculate number for generating the code
$a = $code + getConfig('_ADD') - 1;
return array('', '', '');
} // END - if
- // Compile the script name
- $script = compileCode($script);
-
// Extract host name from script
$host = extractHostnameFromUrl($script);
//* DEBUG: */ die("SCRIPT=" . $script.'<br />');
if ($useProxy === true) {
// Connect to host through proxy connection
- $fp = @fsockopen(compileCode(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
+ $fp = @fsockopen(compileRawCode(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
} else {
// Connect to host directly
$fp = @fsockopen($host, 80, $errno, $errdesc, 30);
// Use login data to proxy? (username at least!)
if (getConfig('proxy_username') != '') {
// Add it as well
- $encodedAuth = base64_encode(compileCode(getConfig('proxy_username')) . getConfig('ENCRYPT_SEPERATOR') . compileCode(getConfig('proxy_password')));
+ $encodedAuth = base64_encode(compileRawCode(getConfig('proxy_username')) . getConfig('ENCRYPT_SEPERATOR') . compileRawCode(getConfig('proxy_password')));
$proxyTunnel .= "Proxy-Authorization: Basic " . $encodedAuth . getConfig('HTTP_EOL');
} // END - if
// 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!#$%&\'*+/=?^_<{|}~]+)*';
return $message;
}
-// Generate a "link" for the given admin id (admin_id)
-function generateAdminLink ($adminId) {
- // No assigned admin is default
- $admin = "<span class=\"admin_note\">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>";
-
- // Zero? = Not assigned
- if (bigintval($adminId) > 0) {
- // Load admin's login
- $login = getAdminLogin($adminId);
-
- // Is the login valid?
- if ($login != '***') {
- // Is the extension there?
- if (isExtensionActive('admins')) {
- // Admin found
- $admin = "<a href=\"".generateEmailLink(getAdminEmail($adminId), 'admins')."\">" . $login."</a>";
- } else {
- // Extension not found
- $admin = sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'admins');
- }
- } else {
- // Maybe deleted?
- $admin = "<div class=\"admin_note\">".sprintf(getMessage('ADMIN_ID_404'), $adminId)."</div>";
- }
- } // END - if
-
- // Return result
- return $admin;
-}
-
// Compile characters which are allowed in URLs
function compileUriCode ($code, $simple = true) {
// Compile constants
// Function taken from user comments on www.php.net / function eregi()
function isUrlValidSimple ($url) {
// Prepare URL
- $url = secureString(str_replace("\\", '', compileCode(urldecode($url))));
+ $url = secureString(str_replace("\\", '', compileRawCode(urldecode($url))));
// Allows http and https
$http = "(http|https)+(:\/\/)";
exit;
}
-// Setter for userid
-function setUserId ($userid) {
- // We should not set userid to zero
- if ($userid == 0) debug_report_bug('Userid should not be set zero.');
+// Init member id
+function initMemberId () {
+ $GLOBALS['member_id'] = 0;
+}
+
+// Setter for member id
+function setMemberId ($memberid) {
+ // We should not set member id to zero
+ if ($memberid == 0) debug_report_bug('Userid should not be set zero.');
// Set it secured
- $GLOBALS['userid'] = bigintval($userid);
+ $GLOBALS['member_id'] = bigintval($memberid);
}
-// Getter for userid or returns zero
-function getUserId () {
- // Default userid
- $userid = 0;
+// Getter for member id or returns zero
+function getMemberId () {
+ // Default member id
+ $memberid = 0;
- // Is the userid set?
- if (isUserIdSet()) {
+ // Is the member id set?
+ if (isMemberIdSet()) {
// Then use it
- $userid = $GLOBALS['userid'];
+ $memberid = $GLOBALS['member_id'];
} // END - if
// Return it
- return $userid;
+ return $memberid;
}
-// Checks ether the userid is set
-function isUserIdSet () {
- return (isset($GLOBALS['userid']));
+// Checks ether the member id is set
+function isMemberIdSet () {
+ return (isset($GLOBALS['member_id']));
}
// Handle message codes from URL
// Do we have cached this result?
if (!isset($GLOBALS['template_cache'][$template])) {
// Generate FQFN
- $FQFN = sprintf("%stemplates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
+ $FQFN = sprintf("%s_compiled/templates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
// Is it there?
$GLOBALS['template_cache'][$template] = isFileReadable($FQFN);
// Flushes non-flushed template cache to disk
function flushTemplateCache ($template, $eval) {
// Is this cache flushed?
- if (!isTemplateCached($template)) {
+ if ((!isTemplateCached($template)) && ($eval != '404')) {
// Generate FQFN
- $FQFN = sprintf("%stemplates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
+ $FQFN = sprintf("%s_compiled/templates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
// Replace username with a call
$eval = str_replace('$username', '".getUsername()."', $eval);
// Check it again
if (isTemplateCached($template)) {
// Generate FQFN
- $FQFN = sprintf("%stemplates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
+ $FQFN = sprintf("%s_compiled/templates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
// And read from it
$GLOBALS['template_eval'][$template] = readFromFile($FQFN);