X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=aa83e13b74f36e95470fa7f484916cfe7cad024e;hb=7f3f860c580046c17d18f2149f6c24a6bda2c901;hp=b6d40608d3a53662d16bb29357b04d4dc28e2367;hpb=47a45ea9324de396816a9af2d4d12ae8a0d248a7;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index b6d40608d3..aa83e13b74 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -43,6 +43,9 @@ if (!defined('__SECURITY')) { // 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(); @@ -343,20 +346,20 @@ function loadTemplate ($template, $return=false, $content=array()) { // 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 = '
{--TEMPLATE_404--}
+ } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) { + // Only admins shall see this warning or when installation mode is active + $ret = '
{--TEMPLATE_404--}
(' . $template . ')

{--TEMPLATE_CONTENT--}
' . print_r($content, true) . '
{--TEMPLATE_DATA--}
' . print_r($DATA, true) . '
-

\";'; +

'; + } else { + // No file! + $GLOBALS['template_eval'][$template] = '404'; + } } else { // Eval the code eval($GLOBALS['template_eval'][$template]); @@ -369,7 +372,7 @@ function loadTemplate ($template, $return=false, $content=array()) { // Return the HTML code return $ret; } else { - // Output direct + // Output directly outputHtml($ret); } } elseif (isDebugModeEnabled()) { @@ -382,9 +385,6 @@ function loadTemplate ($template, $return=false, $content=array()) { 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); @@ -526,7 +526,7 @@ function loadEmailTemplate ($template, $content = array(), $UID = 0) { unset($DATA); // Compile the code and eval it - $eval = '$newContent = "' . compileCode(smartAddSlashes($newContent)) . '";'; + $eval = '$newContent = "' . compileRawCode(smartAddSlashes($newContent)) . '";'; eval($eval); // Return content @@ -538,7 +538,7 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject}
"); // 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)) { @@ -584,10 +584,10 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' } // 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'; @@ -921,7 +921,7 @@ function makeTime ($hours, $minutes, $seconds, $stamp) { // 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://')) { @@ -996,6 +996,30 @@ function compileCode ($code, $simple = false, $constants = true, $full = true) { 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 .= ''; + + // 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']; @@ -1071,7 +1095,7 @@ function compileCode ($code, $simple = false, $constants = true, $full = true) { } // END - foreach } // END - if - // Return compiled code + // Return it return $code; } @@ -1127,19 +1151,19 @@ function array_pk_sort (&$array, $a_sort, $primary_key = 0, $order = -1, $nums = } // -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 .= " \n"; } else { // Begin with regular selection box here if (!empty($prefix)) $prefix .= "_"; $type2 = $type; if ($id > 0) $type2 .= "[" . $id."]"; - $OUT .= " \n"; } switch ($type) { @@ -1265,7 +1289,7 @@ function generateRandomCode ($length, $code, $userid, $DATA = '') { $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; @@ -1752,9 +1776,6 @@ function sendPostRequest ($script, $postData) { return array('', '', ''); } // END - if - // Compile the script name - $script = compileCode($script); - // Extract host name from script $host = extractHostnameFromUrl($script); @@ -1800,7 +1821,7 @@ function sendRawRequest ($host, $request) { //* DEBUG: */ die("SCRIPT=" . $script.'
'); 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); @@ -1821,7 +1842,7 @@ function sendRawRequest ($host, $request) { // 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 @@ -1895,9 +1916,6 @@ function sendRawRequest ($host, $request) { // 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!#$%&\'*+/=?^_<{|}~]+)*'; @@ -2722,36 +2740,6 @@ function getMessageFromErrorCode ($code) { return $message; } -// Generate a "link" for the given admin id (admin_id) -function generateAdminLink ($adminId) { - // No assigned admin is default - $admin = "{--ADMIN_NO_ADMIN_ASSIGNED--}"; - - // 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 = "" . $login.""; - } else { - // Extension not found - $admin = sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'admins'); - } - } else { - // Maybe deleted? - $admin = "
".sprintf(getMessage('ADMIN_ID_404'), $adminId)."
"; - } - } // END - if - - // Return result - return $admin; -} - // Compile characters which are allowed in URLs function compileUriCode ($code, $simple = true) { // Compile constants @@ -2777,7 +2765,7 @@ function compileUriCode ($code, $simple = true) { // 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)+(:\/\/)"; @@ -3237,33 +3225,38 @@ function shutdown () { 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 @@ -3644,7 +3637,7 @@ 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); + $FQFN = sprintf("%s_compiled/templates/%s.tpl.cache", getConfig('CACHE_PATH'), $template); // Is it there? $GLOBALS['template_cache'][$template] = isFileReadable($FQFN); @@ -3657,9 +3650,9 @@ function isTemplateCached ($template) { // 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); @@ -3674,7 +3667,7 @@ function readTemplateCache ($template) { // 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);