X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=318af2c2262240efe73ee8b02eeda1682c680d58;hp=9a9f9d195a53ed2bbb551e3e938828e86fed88b4;hb=e6e3183f794b385f5acc38b371c220cc35cdac38;hpb=8ba389b59f6d41f88752cae896143135e575f34a diff --git a/inc/functions.php b/inc/functions.php index 9a9f9d195a..318af2c226 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -133,9 +133,10 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { // Clear output buffer for later output ob_end_clean(); + // Extension "rewrite" installed? if ((EXT_IS_ACTIVE("rewrite", true)) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) { $OUTPUT = REWRITE_LINKS($OUTPUT); - } + } // END - if // Compile and run finished rendered HTML code while (strpos($OUTPUT, '{!') > 0) { @@ -144,12 +145,13 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { $eval = "\$newContent = \"".COMPILE_CODE(addslashes($OUTPUT))."\";"; @eval($eval); + // Was that eval okay? if (empty($newContent)) { // Something went wrong! die("Evaluation error:
".htmlentities($eval)."
"); - } + } // END - if $OUTPUT = $newContent; - } + } // END - while // Output code here, DO NOT REMOVE! ;-) OUTPUT_RAW($OUTPUT); @@ -157,13 +159,13 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { // Rewrite links when rewrite extension is active if ((EXT_IS_ACTIVE("rewrite", true)) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) { $OUTPUT = REWRITE_LINKS($OUTPUT); - } + } // END - if // Compile and run finished rendered HTML code while (strpos($OUTPUT, '{!') > 0) { $eval = "\$OUTPUT = \"".COMPILE_CODE(addslashes($OUTPUT))."\";"; eval($eval); - } + } // END - while // Output code here, DO NOT REMOVE! ;-) OUTPUT_RAW($OUTPUT); @@ -173,13 +175,13 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { // Output the raw HTML code function OUTPUT_RAW ($HTML) { // Output stripped HTML code to avoid broken JavaScript code, etc. - echo stripslashes($HTML); + echo stripslashes(stripslashes($HTML)); // Flush the output if only _OB_CACHING is not "on" if (_OB_CACHING != "on") { // Flush it flush(); - } + } // END - if } // Add a fatal error message to the queue array @@ -319,7 +321,7 @@ function LOAD_TEMPLATE($template, $return=false, $content="") { // Add surrounding HTML comments to help finding bugs faster $ret = "\n".$ret."\n"; - } elseif ((IS_ADMIN()) || ((isBooleanConstantAndTrue('mxchange_installing')) && (!isBooleanConstantAndTrue('mxchange_installed')))) { + } elseif ((IS_ADMIN()) || ((isBooleanConstantAndTrue('mxchange_installing')) && (!defined('mxchange_installed')))) { // Only admins shall see this warning or when installation mode is active $ret = "
".TEMPLATE_404."
(".basename($file).")
@@ -348,11 +350,10 @@ function LOAD_TEMPLATE($template, $return=false, $content="") { } // Send mail out to an email address -function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML='N', $FROM="") { +function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML = 'N', $FROM = "") { // Compile subject line (for POINTS constant etc.) - $eval = "\$SUBJECT = \"".COMPILE_CODE(addslashes($SUBJECT))."\";"; + $eval = "\$SUBJECT = html_entity_decode(\"".COMPILE_CODE(addslashes($SUBJECT))."\");"; eval($eval); - $SUBJECT = html_entity_decode($SUBJECT); // Set from header if ((!eregi("@", $TO)) && ($TO > 0)) { @@ -361,17 +362,29 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML='N', $FROM="") { ADD_MESSAGE_TO_BOX($TO, $SUBJECT, $MSG, $HTML); return; } else { + // Load email address $result_email = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($TO)), __FILE__, __LINE__); - list($TO) = SQL_FETCHROW($result_email); + + // Does the user exist? + if (SQL_NUMROWS($result_email)) { + // Load email address + list($TO) = SQL_FETCHROW($result_email); + } else { + // Set webmaster + $TO = WEBMASTER; + } + + // Free result SQL_FREERESULT($result_email); } - } elseif ($TO == 0) { + } elseif ("$TO" == "0") { // Is the webmaster! $TO = WEBMASTER; } - // Not in PHPMailer-Mode + // Check for PHPMailer or debug-mode if (!CHECK_PHPMAILER_USAGE()) { + // Not in PHPMailer-Mode if (empty($FROM)) { // Load email header template $FROM = LOAD_EMAIL_TEMPLATE("header"); @@ -389,6 +402,10 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML='N', $FROM="") { } } + // Compile "TO" + $eval = "\$TO = \"".COMPILE_CODE(addslashes($TO))."\";"; + eval($eval); + // Fix HTML parameter (default is no!) if (empty($HTML)) $HTML = "N"; if (isBooleanConstantAndTrue('DEBUG_MODE')) { @@ -403,9 +420,6 @@ Message : ".$MSG." // Send mail as HTML away SEND_HTML_EMAIL($TO, $SUBJECT, $MSG, $FROM); } elseif (!empty($TO)) { - // Compile email - $TO = COMPILE_CODE($TO); - // Send Mail away SEND_RAW_EMAIL($TO, COMPILE_CODE($SUBJECT), COMPILE_CODE($MSG), $FROM); } elseif ($HTML == "N") { @@ -737,15 +751,6 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") { $content['expiration'] = $EXPIRATION; } // END - if - // @TODO Try to rewrite this part - if ($template == "add-points") { - if (isset($_POST['points'])) { - $points = bigintval($_POST['points']); - } else { - $points = __POINTS_VALUE; - } - } // END - if - // Load user's data if ($UID > 0) { if (EXT_IS_ACTIVE("nickname")) { @@ -1260,8 +1265,8 @@ function GENERATE_IMAGE($img_code, $header=true) { } // Create selection box or array of splitted timestamp function CREATE_TIME_SELECTIONS($timestamp, $prefix="", $display="", $align="center", $return_array=false) { - // Calculate 15-seconds timestamp (15-seconds-steps shall be fine ;) ) - $stamp = round($timestamp / 15) * 15; + // Calculate 2-seconds timestamp + $stamp = round($timestamp / 2) * 2; // Do we have a leap year? $SWITCH = 0; @@ -1290,7 +1295,7 @@ function CREATE_TIME_SELECTIONS($timestamp, $prefix="", $display="", $align="cen // Is seconds zero and time is < 60 seconds? if (($s == 0) && ($stamp < 60)) { // Fix seconds - $s = $timestamp; + $s = round($timestamp); } // END - if // @@ -1478,10 +1483,10 @@ function SEND_ADMIN_EMAILS_PRO($subj, $template, $content, $UID) { // Load email template $msg = LOAD_EMAIL_TEMPLATE($template, $content, $UID); - if (GET_EXT_VERSION("admins") < "0.4.0") { + if (EXT_VERSION_IS_OLDER("admins", "0.4.0")) { // Older version detected! return SEND_ADMIN_EMAILS($subj, $msg); - } + } // END - if // Check which admin shall receive this mail $result = SQL_QUERY_ESC("SELECT DISTINCT admin_id FROM "._MYSQL_PREFIX."_admins_mails WHERE mail_template='%s' ORDER BY admin_id", @@ -1537,8 +1542,14 @@ function CREATE_FANCY_TIME($stamp) { } // END - if } // END - foreach - // Remove leading commata and space - $ret = substr($ret, 2); + // Do we have something there? + if (strlen($ret) > 0) { + // Remove leading commata and space + $ret = substr($ret, 2); + } else { + // Zero seconds + $ret = "0 "._SECONDS; + } // Return fancy time string return $ret; @@ -1910,7 +1921,7 @@ function generateHash ($plainText, $salt = "") { global $_CONFIG, $_SERVER; // Is the required extension "sql_patches" there and a salt is not given? - if (((GET_EXT_VERSION("sql_patches") < "0.3.6") || (GET_EXT_VERSION("sql_patches") == "")) && (empty($salt))) { + if (((EXT_VERSION_IS_OLDER("sql_patches", "0.3.6")) || (GET_EXT_VERSION("sql_patches") == "")) && (empty($salt))) { // Extension sql_patches is missing/outdated so we return the plain text return $plainText; } // END - if @@ -2342,9 +2353,9 @@ function RESET_ADD_INCLUDES () { global $_CONFIG; // Is the reset set or old sql_patches? - if ((!isBooleanConstantAndTrue('__DAILY_RESET')) || (GET_EXT_VERSION("sql_patches") < "0.4.5")) { + if ((!defined('__DAILY_RESET')) || (EXT_VERSION_IS_OLDER("sql_patches", "0.4.5"))) { // Then abort here - return; + return array(); } // END - if // Get more daily reset scripts @@ -2515,6 +2526,26 @@ function REBUILD_CACHE ($cache, $inc="") { } // END - if } // END - if } +// Purge admin menu cache +function CACHE_PURGE_ADMIN_MENU ($id=0, $action="", $what="", $str="") { + global $_CONFIG, $cacheInstance; + + // Is the cache extension enabled or no cache instance or admin menu cache disabled? + if (!EXT_IS_ACTIVE("cache")) { + // Cache extension not active + return false; + } elseif (!is_object($cacheInstance)) { + // No cache instance! + DEBUG_LOG(__FUNCTION__.": No cache instance found."); + return false; + } elseif ((!isset($_CONFIG['cache_admin_menu'])) || ($_CONFIG['cache_admin_menu'] == "N")) { + // Caching disabled (currently experiemental!) + return false; + } + + // Experiemental feature! + trigger_error("You have to delete the admin_*.cache files by yourself at this point."); +} // ////////////////////////////////////////////////// // //