X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=d94a0336fee24b04d53de9fb23c67cc9fd9ece54;hp=9a9ea0dfc89080b04fd6617f1cbed14bed1afa8b;hb=fbd528919a0e2762d423c5bcbc0289436e07a1d4;hpb=f8a2f0c9d334d87fdaf8f010678ca5ad8b95211f diff --git a/inc/functions.php b/inc/functions.php index 9a9ea0dfc8..d94a0336fe 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -71,18 +71,15 @@ function OPEN_TABLE($PERCENT = "", $CLASS = "", $ALIGN="left", $VALIGN="", $td_o // Vertical align is given if (!empty($VALIGN)) $OUT .= " valign=\"".$VALIGN."\""; - $OUT .= "> - - "; - OUTPUT_HTML($OUT); + OUTPUT_HTML($OUT); } // Close a table (you may want to add some footer stuff here) function CLOSE_TABLE($ADD="") { - OUTPUT_HTML(" -"); + OUTPUT_HTML(" \n"); if (!empty($ADD)) OUTPUT_HTML($ADD); OUTPUT_HTML(""); } @@ -140,9 +137,17 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { } // Compile and run finished rendered HTML code - while (strpos($OUTPUT, "{!") > 0) { - $eval = "\$OUTPUT = \"" . COMPILE_CODE(addslashes($OUTPUT)) . "\";"; + while (strpos($OUTPUT, '{!') > 0) { + // Prepare the content and eval() it... + $newContent = ""; + $eval = "\$newContent = \"" . COMPILE_CODE(addslashes($OUTPUT)) . "\";"; @eval($eval); + + if (empty($newContent)) { + // Something went wrong! + die("Evaluation error:
".htmlentities($eval)."
"); + } + $OUTPUT = $newContent; } // Output code here, DO NOT REMOVE! ;-) @@ -154,9 +159,9 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { } // Compile and run finished rendered HTML code - while (strpos($OUTPUT, "{!") > 0) { + while (strpos($OUTPUT, '{!') > 0) { $eval = "\$OUTPUT = \"" . COMPILE_CODE(addslashes($OUTPUT)) . "\";"; - @eval($eval); + eval($eval); } // Output code here, DO NOT REMOVE! ;-) @@ -166,21 +171,18 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { // Output the raw HTML code function OUTPUT_RAW ($HTML) { - if ((isBooleanConstantAndTrue('mxchange_installed')) && (basename($_SERVER['PHP_SELF']) != "install.php")) { - // Not in install-mode so strip slashes away - echo stripslashes($HTML); - } else { - // Output directly in install-mode - echo $HTML; - } + // Output stripped HTML code to avoid broken JavaScript code, etc. + echo stripslashes($HTML); - // Flush the output - flush(); + // Flush the output if only _OB_CACHING is not "on" + if (_OB_CACHING != "on") { + // Flush it + flush(); + } } // Add a fatal error message to the queue array -function ADD_FATAL ($message, $extra="") -{ +function ADD_FATAL ($message, $extra="") { global $FATAL; if (empty($extra)) { // Regular text message to add to $FATAL @@ -284,12 +286,12 @@ function LOAD_TEMPLATE($template, $return=false, $content="") { $tmpl_file = implode("", file($file)); // Replace ' to our own chars to preventing them being quoted - while (strpos($tmpl_file, "\'") !== false) { $tmpl_file = str_replace("\'", "{QUOT}", $tmpl_file); } + while (strpos($tmpl_file, "\'") !== false) { $tmpl_file = str_replace("\'", '{QUOT}', $tmpl_file); } // Do we have to compile the code? if ((strpos($tmpl_file, "\$") !== false) || (strpos($tmpl_file, '{--') !== false) || (strpos($tmpl_file, '--}') > 0)) { // Okay, compile it! - $tmpl_file = "\$ret=\"".COMPILE_CODE(addslashes($tmpl_file))."\";"; + $tmpl_file = "\$ret=\"" . COMPILE_CODE(addslashes($tmpl_file)) . "\";"; eval($tmpl_file); } else { // Simply return loaded code @@ -329,7 +331,7 @@ function LOAD_TEMPLATE($template, $return=false, $content="") { // Send mail out to an email address function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML='N', $FROM="") { // Compile subject line (for POINTS constant etc.) - $eval = "\$SUBJECT = \"".COMPILE_CODE(addslashes($SUBJECT))."\";"; + $eval = "\$SUBJECT = \"" . COMPILE_CODE(addslashes($SUBJECT)) . "\";"; eval($eval); $SUBJECT = html_entity_decode($SUBJECT); @@ -366,7 +368,7 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML='N', $FROM="") { } // Fix HTML parameter (default is no!) - if (empty($HTML)) $HTML = 'N'; + if (empty($HTML)) $HTML = "N"; if (isBooleanConstantAndTrue('DEBUG_MODE')) { // In debug mode we want to display the mail instead of sending it away so we can debug this part echo "
@@ -375,7 +377,7 @@ To      : ".$TO."
 Subject : ".$SUBJECT."
 Message : ".$MSG."
 
\n"; - } elseif (($HTML == 'Y') && (EXT_IS_ACTIVE("html_mail", true))) { + } elseif (($HTML == "Y") && (EXT_IS_ACTIVE("html_mail", true))) { // Send mail as HTML away SEND_HTML_EMAIL($TO, $SUBJECT, $MSG, $FROM); } elseif (!empty($TO)) { @@ -384,7 +386,7 @@ Message : ".$MSG." // Send Mail away SEND_RAW_EMAIL($TO, COMPILE_CODE($SUBJECT), COMPILE_CODE($MSG), $FROM); - } elseif ($HTML == 'N') { + } elseif ($HTML == "N") { // Problem found! SEND_RAW_EMAIL(WEBMASTER, COMPILE_CODE($SUBJECT), COMPILE_CODE($MSG), $FROM); } @@ -660,6 +662,9 @@ function GET_LANGUAGE() { } elseif (!isSessionVariableSet('mx_lang')) { // Return stored value from cookie $ret = get_session('mx_lang'); + + // Fixes a warning before the session has the mx_lang constant + if (empty($ret)) $ret = DEFAULT_LANG; } return $ret; } @@ -679,7 +684,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") { // Keept for backward-compatiblity (please replace these variables against our new {--CONST--} syntax!) $MAIN_TITLE = MAIN_TITLE; $URL = URL; $WEBMASTER = WEBMASTER; - $surname = ""; $family = ""; $nick = ""; $sex = 'N'; + $surname = ""; $family = ""; $nick = ""; $sex = "N"; // Prepare IP number and User Agent $REMOTE_ADDR = getenv('REMOTE_ADDR'); @@ -787,7 +792,11 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") { break; case "add-points": - $points = bigintval($_POST['points']); + if (isset($_POST['points'])) { + $points = bigintval($_POST['points']); + } else { + $points = __POINTS_VALUE; + } break; case "guest_request_confirm": @@ -813,7 +822,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") { } } else { // Neutral sex and email address is default - $sex = 'N'; + $sex = "N"; $email = WEBMASTER; } @@ -915,6 +924,12 @@ function LOAD_URL($URL, $addUrlData=true) { // Compile out URI codes $URL = COMPILE_CODE($URL); + // Get output buffer + $OUTPUT = ob_get_contents(); + + // Clear it + ob_end_clean(); + // Add some data to URL if cookies are not accepted if (((!defined('__COOKIES')) || (!__COOKIES)) && ($addUrlData)) $URL = ADD_URL_DATA($URL); @@ -931,7 +946,7 @@ function LOAD_URL($URL, $addUrlData=true) { } else { // Output error message include(PATH."inc/header.php"); - OUTPUT_HTML(LOAD_URL_ERROR_1.$URL.LOAD_URL_ERROR_2); + LOAD_TEMPLATE("redirect_url", false, str_replace("&", "&", $URL)); include(PATH."inc/footer.php"); } exit(); @@ -948,11 +963,11 @@ function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) { if ($constants) { // BEFORE 0.2.1 : Language and data constants // WITH 0.2.1+ : Only language constants - $code = str_replace("{--", '".', str_replace("--}", '."', $code)); + $code = str_replace('{--', '".', str_replace('--}', '."', $code)); // BEFORE 0.2.1 : Not used // WITH 0.2.1+ : Data constants - $code = str_replace("{!", '".', str_replace("!}", '."', $code)); + $code = str_replace('{!', '".', str_replace("!}", '."', $code)); } // Compile QUOT and other non-HTML codes @@ -962,7 +977,7 @@ function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) { } // But shall I keep simple quotes for later use? - if ($simple) $code = str_replace("\'", "{QUOT}", $code); + if ($simple) $code = str_replace("\'", '{QUOT}', $code); // Find $content[bla][blub] entries @preg_match_all('/\$(content|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches); @@ -1147,10 +1162,10 @@ function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0") case "yn": $OUT .= "