X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=ea7a4297b03927ff325b6421940c3a9febd05982;hb=1a00ba8958d8b6f0cb689690e955eb63fc75ffa8;hp=2900e464e0dbc84d93f865afc4f9271aa72fa271;hpb=6bcc8f1ebbd646d15c5905a5cec47d1c1e446238;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index 2900e464e0..ea7a4297b0 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -114,12 +114,15 @@ function OUTPUT_HTML ($HTML, $newLine = true) { sendHeader('Connection: Close'); // Extension 'rewrite' installed? - if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) { + if ((EXT_IS_ACTIVE('rewrite')) && (getOutputMode() != '1') && (getOutputMode() != '-1')) { $OUTPUT = rewriteLinksInCode($OUTPUT); } // END - if // Compile and run finished rendered HTML code while (strpos($OUTPUT, '{!') > 0) { + // Replace _MYSQL_PREFIX + $OUTPUT = str_replace("{!_MYSQL_PREFIX!}", getConfig('_MYSQL_PREFIX'), $OUTPUT); + // Prepare the content and eval() it... $newContent = ''; $eval = "\$newContent = \"".COMPILE_CODE(smartAddSlashes($OUTPUT))."\";"; @@ -128,7 +131,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) { // Was that eval okay? if (empty($newContent)) { // Something went wrong! - app_die(__FUNCTION__, __LINE__, "Evaluation error:
".htmlentities($eval)."
"); + app_die(__FUNCTION__, __LINE__, 'Evaluation error:
' . htmlentities($eval) . '
'); } // END - if $OUTPUT = $newContent; } // END - while @@ -137,7 +140,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) { outputRawCode($OUTPUT); } elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($OUTPUT))) { // Rewrite links when rewrite extension is active - if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) { + if ((EXT_IS_ACTIVE('rewrite')) && (getOutputMode() != '1') && (getOutputMode() != '-1')) { $OUTPUT = rewriteLinksInCode($OUTPUT); } // END - if @@ -300,13 +303,13 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { //////////////////////// $FQFN = $basePath . $mode . $template . '.tpl'; - if ((!empty($GLOBALS['what'])) && ((strpos($template, '_header') > 0) || (strpos($template, '_footer') > 0)) && (($mode == 'guest/') || ($mode == 'member/') || ($mode == 'admin/'))) { + if ((isWhatSet()) && ((strpos($template, '_header') > 0) || (strpos($template, '_footer') > 0)) && (($mode == 'guest/') || ($mode == 'member/') || ($mode == 'admin/'))) { // Select what depended header/footer template file for admin/guest/member area $file2 = sprintf("%s%s%s_%s.tpl", $basePath, $mode, $template, - SQL_ESCAPE($GLOBALS['what']) + getWhat() ); // Probe for it... @@ -514,16 +517,16 @@ function sendRawEmail ($toEmail, $subject, $message, $from) { } // Generate a password in a specified length or use default password length -function generatePassword ($LEN = 0) { +function generatePassword ($length = 0) { // Auto-fix invalid length of zero - if ($LEN == 0) $LEN = getConfig('pass_len'); + if ($length == 0) $length = getConfig('pass_len'); // Initialize array with all allowed chars - $ABC = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/'); + $ABC = explode(',', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/,.'); // Start creating password $PASS = ''; - for ($i = 0; $i < $LEN; $i++) { + for ($i = 0; $i < $length; $i++) { $PASS .= $ABC[mt_rand(0, count($ABC) -1)]; } // END - for @@ -735,7 +738,10 @@ function generateCaptchaCode ($code, $type, $DATA, $uid) { // Loads an email template and compiles it function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') { - global $DATA, $_CONFIG; + global $DATA; + + // Our configuration is kept non-global here + $_CONFIG = getConfigArray(); // Make sure all template names are lowercase! $template = strtolower($template); @@ -929,11 +935,11 @@ function redirectToUrl ($URL) { clearOutputBuffer(); } // END - if - // Secure the URL against bad things such als HTML insertions and so on... - $URL = htmlentities(strip_tags($URL), ENT_QUOTES); - // Simple probe for bots/spiders from search engines if ((strpos(detectUserAgent(), 'spider') !== false) || (strpos(detectUserAgent(), 'bot') !== false)) { + // Secure the URL against bad things such als HTML insertions and so on... + $URL = htmlentities(strip_tags($URL), ENT_QUOTES); + // Output new location link as anchor OUTPUT_HTML('' . $URL . ''); } elseif (!headers_sent()) { @@ -1671,7 +1677,7 @@ function ADD_EMAIL_NAV ($PAGES, $offset, $show_form, $colspan, $return=false) { $NAV .= "-"; } else { // Open anchor tag and add base URL - $NAV .= "loadCacheFile('revision')) $new = true; + if (REQUEST_ISSET_GET('check_revision_data') && REQUEST_GET('check_revision_data') == 'yes') { + // Force rebuild by URL parameter + $new = true; + } elseif (( + !isset($GLOBALS['cache_array']['revision'][$type]) + ) || ( + count($GLOBALS['cache_array']['revision']) < 3 + ) || ( + !$GLOBALS['cache_instance']->loadCacheFile('revision') + )) { + // Out-dated cache + $new = true; + } // END - if // Is the cache file outdated/invalid? if ($new === true){ - $GLOBALS['cache_instance']->destroyCacheFile(); // @TODO isn't it better to do $GLOBALS['cache_instance']->destroyCacheFile('revision')? + // Destroy cache file + $GLOBALS['cache_instance']->destroyCacheFile(); // @TODO shouldn't do the unset and the reloading $GLOBALS['cache_instance']->destroyCacheFile() Or a new methode like forceCacheReload('revision')? unset($GLOBALS['cache_array']['revision']); // Reload load_cach-revison.php loadInclude('inc/loader/load_cache-revision.php'); + + // Abort here + return; } // END - if // Return found value return $GLOBALS['cache_array']['revision'][$type][0]; - } else { // Old Version without ext-cache active (deprecated ?) @@ -2476,7 +2503,7 @@ function getActualVersion ($type = 'Revision') { // 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')) { - // Has changed! + // Forced rebuild of .revision file $new = true; } else { // Check for revision file @@ -2619,7 +2646,7 @@ function debug_report_bug ($message = '') { } // END - if // Add output - $debug .= "Please report this bug at bugs.mxchange.org and include the logfile from inc/cache/debug.log in your report (you cannot attach files!):
";
+	$debug .= "Please report this bug at bugs.mxchange.org and include the logfile from inc/cache/debug.log in your report (you can now attach files):
";
 	$debug .= debug_get_printable_backtrace();
 	$debug .= "
\nRequest-URI: " . $_SERVER['REQUEST_URI']."
\n"; $debug .= "Thank you for finding bugs."; @@ -2631,8 +2658,9 @@ function debug_report_bug ($message = '') { // Generates a ***weak*** seed (taken from de.php.net/mt_srand) function generateSeed () { - list($usec, $sec) = explode(" ", microtime()); - return ((float)$sec + (float)$usec); + list($usec, $sec) = explode(' ', microtime()); + $microTime = (((float)$sec + (float)$usec)) * 100000; + return $microTime; } // Converts a message code to a human-readable message @@ -2891,7 +2919,7 @@ function DEBUG_LOG ($funcFile, $line, $message, $force=true) { // Log this message away $fp = fopen(constant('PATH')."inc/cache/debug.log", 'a') or app_die(__FUNCTION__, __LINE__, "Cannot write logfile debug.log!"); - fwrite($fp, date("d.m.Y|H:i:s", time())."|" . $GLOBALS['module']."|".basename($funcFile)."|" . $line."|".strip_tags($message)."\n"); + fwrite($fp, date("d.m.Y|H:i:s", time())."|" . getModule()."|".basename($funcFile)."|" . $line."|".strip_tags($message)."\n"); fclose($fp); } // END - if } @@ -3260,7 +3288,7 @@ function isUserIdSet () { // Handle message codes from URL function handleCodeMessage () { if (REQUEST_ISSET_GET('msg')) { - // Default extension is "unknown" + // Default extension is 'unknown' $ext = 'unknown'; // Is extension given?