X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=6a87f258cce888a8cdc0a1836a5d528ac22922d8;hp=e25fce111139915ff13934aeaf5e26894a8bb0f5;hb=bfbf712685680761babfd9ea059a224a4aa244bf;hpb=56156f6c4392510cdbe0eb4f2ccefc23b43e2672 diff --git a/inc/functions.php b/inc/functions.php index e25fce1111..6a87f258cc 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -59,43 +59,6 @@ function IS_INC_WRITEABLE($inc) { } } -// Open a table (you may want to add some header stuff here) -// @DEPRECATED -function OPEN_TABLE ($PERCENT = "", $CLASS = "", $ALIGN="left", $VALIGN="", $td_only=false) { - global $table_cnt; - - // Count tables so we can generate CSS classes for every table... :-) - if (empty($CLASS)) { - // Class is empty so count one up and create a class - $table_cnt++; $CLASS = "class".$table_cnt; - } - $OUT = ""; - OUTPUT_HTML($OUT); -} - -// Close a table (you may want to add some footer stuff here) -// @DEPRECATED -function CLOSE_TABLE( $ADD="") { - OUTPUT_HTML(" \n"); - if (!empty($ADD)) OUTPUT_HTML($ADD); - OUTPUT_HTML("
"); -} - // Output HTML code directly or "render" it. You addionally switch the new-line character off function OUTPUT_HTML ($HTML, $NEW_LINE = true) { // Some global variables @@ -135,7 +98,7 @@ function OUTPUT_HTML ($HTML, $NEW_LINE = true) { default: // Huh, something goes wrong or maybe you have edited config.php ??? DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", OUTPUT_MODE)); - MXCHANGE_DIE("".FATAL_ERROR.": ".LANG_NO_RENDER_DIRECT); + mxchange_die("{!FATAL_ERROR!}: {!LANG_NO_RENDER_DIRECT!}"); break; } } elseif ((_OB_CACHING == "on") && ($footer == 1)) { @@ -144,18 +107,15 @@ function OUTPUT_HTML ($HTML, $NEW_LINE = true) { // Log this error DEBUG_LOG(__FUNCTION__, __LINE__, "Headers already sent! We need debug backtrace here."); - // Output debug trace - print("Headers are already sent!
\n"); - print("Please report this error at bugs.mxchange.org:
");
-			debug_print_backtrace();
-			die("
Thank you for your help finding bugs."); + // Trigger an user error + trigger_error("Headers are already sent!"); } // END - if // Output cached HTML code $OUTPUT = ob_get_contents(); // Clear output buffer for later output - ob_end_clean(); + clearOutputBuffer(); // Send HTTP header header("HTTP/1.1 200"); @@ -171,7 +131,7 @@ function OUTPUT_HTML ($HTML, $NEW_LINE = true) { header("Connection: Close"); // Extension "rewrite" installed? - if ((EXT_IS_ACTIVE("rewrite")) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) { + if ((EXT_IS_ACTIVE("rewrite")) && ($CSS != "1") && ($CSS != "-1")) { $OUTPUT = REWRITE_LINKS($OUTPUT); } // END - if @@ -194,7 +154,7 @@ function OUTPUT_HTML ($HTML, $NEW_LINE = true) { OUTPUT_RAW($OUTPUT); } elseif ((OUTPUT_MODE == "render") && (!empty($OUTPUT))) { // Rewrite links when rewrite extension is active - if ((EXT_IS_ACTIVE("rewrite")) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) { + if ((EXT_IS_ACTIVE("rewrite")) && ($CSS != "1") && ($CSS != "-1")) { $OUTPUT = REWRITE_LINKS($OUTPUT); } // END - if @@ -239,7 +199,7 @@ function addFatalMessage ($message, $extra="") { } // Getter for total fatal message count -function getTotalFatalMessages () { +function getTotalFatalErrors () { global $FATAL; // Init coun @@ -817,12 +777,9 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { if (getConfig('auto_purge') == 0) { // Will never expire! $EXPIRATION = MAIL_WILL_NEVER_EXPIRE; - } elseif (function_exists('CREATE_FANCY_TIME')) { + } else { // Create nice date string $EXPIRATION = CREATE_FANCY_TIME(getConfig('auto_purge')); - } else { - // Display days only - $EXPIRATION = round(getConfig('auto_purge')/60/60/24)." "._DAYS; } // Is content an array? @@ -926,6 +883,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { if (empty($newContent)) { // Compiling failed $newContent = "Compiler error for template {$template}!\nUncompiled content:\n".$tmpl_file; + // Add last error if the required function exists if (function_exists('error_get_last')) $newContent .= "\n--------------------------------------\nDebug:\n".print_r(error_get_last(), true)."--------------------------------------\nPlease don't alter these informations!\nThanx."; } // END - if @@ -969,7 +927,7 @@ function LOAD_URL($URL, $addUrlData=true) { // Clear it only if there is content if (!empty($OUTPUT)) { - ob_end_clean(); + clearOutputBuffer(); } // END - if // Add some data to URL if cookies are not accepted @@ -989,15 +947,31 @@ function LOAD_URL($URL, $addUrlData=true) { debug_print_backtrace(); die("URL={$URL}"); */ - @header ("Location: ".str_replace("&", "&", $URL)); + header ("Location: ".str_replace("&", "&", $URL)); } else { // Output error message - include(PATH."inc/header.php"); + require(PATH."inc/header.php"); LOAD_TEMPLATE("redirect_url", false, str_replace("&", "&", $URL)); - include(PATH."inc/footer.php"); + require(PATH."inc/footer.php"); } exit(); } + +// Wrapper for LOAD_URL but URL comes from a configuration entry +function LOAD_CONFIGURED_URL ($configEntry) { + // Get the URL + $URL = getConfig($configEntry); + + // Is this URL set? + if (is_null($URL)) { + // Then abort here + trigger_error(sprintf("Configuration entry %s is not set!", $configEntry)); + } // END - if + + // Load the URL + LOAD_URL($URL); +} + // function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) { global $SEC_CHARS, $URL_CHARS; @@ -1443,133 +1417,133 @@ function CREATE_TIME_SELECTIONS ($timestamp, $prefix="", $display="", $align="ce } else { // Generate table $OUT = "
\n"; - $OUT .= "\n"; - $OUT .= "\n"; + $OUT .= "
\n"; + $OUT .= "\n"; if (ereg('Y', $display) || (empty($display))) { - $OUT .= " \n"; + $OUT .= " \n"; } if (ereg("M", $display) || (empty($display))) { - $OUT .= " \n"; + $OUT .= " \n"; } if (ereg("W", $display) || (empty($display))) { - $OUT .= " \n"; + $OUT .= " \n"; } if (ereg("D", $display) || (empty($display))) { - $OUT .= " \n"; + $OUT .= " \n"; } if (ereg("h", $display) || (empty($display))) { - $OUT .= " \n"; + $OUT .= " \n"; } if (ereg("m", $display) || (empty($display))) { - $OUT .= " \n"; + $OUT .= " \n"; } if (ereg("s", $display) || (empty($display))) { - $OUT .= " \n"; + $OUT .= " \n"; } - $OUT .= "\n"; - $OUT .= "\n"; + $OUT .= "\n"; + $OUT .= "\n"; if (ereg('Y', $display) || (empty($display))) { // Generate year selection - $OUT .= " \n"; + $OUT .= " \n"; } else { $OUT .= "\n"; } if (ereg("M", $display) || (empty($display))) { // Generate month selection - $OUT .= " \n"; + $OUT .= " \n"; } else { $OUT .= "\n"; } if (ereg("W", $display) || (empty($display))) { // Generate week selection - $OUT .= " \n"; + $OUT .= " \n"; } else { $OUT .= "\n"; } if (ereg("D", $display) || (empty($display))) { // Generate day selection - $OUT .= " \n"; + $OUT .= " \n"; } else { $OUT .= "\n"; } if (ereg("h", $display) || (empty($display))) { // Generate hour selection - $OUT .= " \n"; + $OUT .= " \n"; } else { $OUT .= "\n"; } if (ereg("m", $display) || (empty($display))) { // Generate minute selection - $OUT .= " \n"; + $OUT .= " \n"; } else { $OUT .= "\n"; } if (ereg("s", $display) || (empty($display))) { // Generate second selection - $OUT .= " \n"; + $OUT .= " \n"; } else { $OUT .= "\n"; } - $OUT .= "\n"; - $OUT .= "
"._YEARS."
"._YEARS."
"._MONTHS."
"._MONTHS."
"._WEEKS."
"._WEEKS."
"._DAYS."
"._DAYS."
"._HOURS."
"._HOURS."
"._MINUTES."
"._MINUTES."
"._SECONDS."
"._SECONDS."
\n"; + $OUT .= "\n"; + $OUT .= "\n"; $OUT .= "
\n"; // Return generated HTML code } @@ -1688,7 +1662,7 @@ function ADD_EMAIL_NAV($PAGES, $offset, $show_form, $colspan, $return=false) { $SEP = ""; $TOP = ""; if (!$show_form) { $TOP = " top2"; - $SEP = " "; + $SEP = " "; } $NAV = ""; @@ -2017,9 +1991,9 @@ function MEMBER_ACTION_LINKS($uid, $status="") { return $OUT; } // Function for backward-compatiblity -function ADD_CATEGORY_TABLE ($MODE, $return=false) { +function ADD_CATEGORY_table ($MODE, $return=false) { // Load it from the register extension - return REGISTER_ADD_CATEGORY_TABLE ($MODE, $return); + return REGISTER_ADD_CATEGORY_table ($MODE, $return); } // Generate an email link function CREATE_EMAIL_LINK ($email, $table = "admins") { @@ -2265,13 +2239,14 @@ function FIX_DELETED_COOKIES ($cookies) { // Output error messages in a fasioned way and die... function mxchange_die ($msg) { - global $footer; + // Load header + require_once(PATH."inc/header.php"); // Load the message template LOAD_TEMPLATE("admin_settings_saved", false, $msg); // Load footer - include(PATH."inc/footer.php"); + require(PATH."inc/footer.php"); // Exit explicitly exit; @@ -2626,22 +2601,22 @@ function HANDLE_LOGIN_FAILTURES ($accessLevel) { $OUT = ""; // Is the session data set? - if ((isSessionVariableSet('mxchange_'.$accessLevel.'_failtures')) && (isSessionVariableSet('mxchange_'.$accessLevel.'_last_fail'))) { + if ((isSessionVariableSet('mxchange_'.$accessLevel.'_failures')) && (isSessionVariableSet('mxchange_'.$accessLevel.'_last_fail'))) { // Ignore zero values - if (get_session('mxchange_'.$accessLevel.'_failtures') > 0) { - // Non-guest has login failtures found, get both data and prepare it for template + if (get_session('mxchange_'.$accessLevel.'_failures') > 0) { + // Non-guest has login failures found, get both data and prepare it for template //* DEBUG: */ print __FUNCTION__."(".__LINE__."):accessLevel={$accessLevel}
\n"; $content = array( - 'login_failtures' => get_session('mxchange_'.$accessLevel.'_failtures'), - 'last_failture' => MAKE_DATETIME(get_session('mxchange_'.$accessLevel.'_last_fail'), "2") + 'login_failures' => get_session('mxchange_'.$accessLevel.'_failures'), + 'last_failure' => MAKE_DATETIME(get_session('mxchange_'.$accessLevel.'_last_fail'), "2") ); // Load template - $OUT = LOAD_TEMPLATE("login_failtures", true, $content); + $OUT = LOAD_TEMPLATE("login_failures", true, $content); } // END - if // Reset session data - set_session('mxchange_'.$accessLevel.'_failtures', ""); + set_session('mxchange_'.$accessLevel.'_failures', ""); set_session('mxchange_'.$accessLevel.'_last_fail', ""); } // END - if @@ -2890,7 +2865,7 @@ function getConfig ($entry) { return $value; } -// @TODO Rewrite all language constants to the function getLanguage(). +// @TODO Rewrite all language constants to this function. // "Getter" for language strings function getMessage ($messageId) { // Default is not found! @@ -3059,6 +3034,15 @@ function GEN_ERROR_CODE_FROM_ACCOUNT_STATUS ($status) { return $ERROR; } +// Clears the output buffer. This function does *NOT* backup sent content. +function clearOutputBuffer () { + // Trigger an error on failure + if (!ob_end_clean()) { + // Failed! + trigger_error(__FUNCTION__.": Failed to clean output buffer."); + } // END - if +} + ////////////////////////////////////////////////// // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS // //////////////////////////////////////////////////