X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=d157a7ed00344842431105feecb76d2b92f85811;hp=8a2ad0e162084d1993b525b9b2c694a59ef05d77;hb=4ccc02299e123d24c043c917fb16208d0338f300;hpb=6e008d188bf9c7f8d4edc2a8799c61940eee48e7
diff --git a/inc/functions.php b/inc/functions.php
index 8a2ad0e162..d157a7ed00 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -37,11 +37,11 @@
************************************************************************/
// Some security stuff...
if (!defined('__SECURITY')) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
+ $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
require($INC);
}
-// Output HTML code directly or "render" it. You addionally switch the new-line character off
+// Output HTML code directly or 'render' it. You addionally switch the new-line character off
function OUTPUT_HTML ($HTML, $newLine = true) {
// Some global variables
global $OUTPUT;
@@ -49,41 +49,40 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
// Do we have HTML-Code here?
if (!empty($HTML)) {
// Yes, so we handle it as you have configured
- switch (constant('OUTPUT_MODE'))
+ switch (getConfig('OUTPUT_MODE'))
{
- case "render":
- // That's why you don't need any \n at the end of your HTML code... :-)
- if (constant('_OB_CACHING') == "on") {
- // Output into PHP's internal buffer
- OUTPUT_RAW($HTML);
-
+ case 'render':
// That's why you don't need any \n at the end of your HTML code... :-)
- if ($newLine) echo "\n";
- } else {
- // Render mode for old or lame servers...
- $OUTPUT .= $HTML;
+ if (constant('_OB_CACHING') == 'on') {
+ // Output into PHP's internal buffer
+ outputRawCode($HTML);
- // That's why you don't need any \n at the end of your HTML code... :-)
- if ($newLine) $OUTPUT .= "\n";
- }
- break;
+ // That's why you don't need any \n at the end of your HTML code... :-)
+ if ($newLine) echo "\n";
+ } else {
+ // Render mode for old or lame servers...
+ $OUTPUT .= $HTML;
- case "direct":
- // If we are switching from render to direct output rendered code
- if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != "on")) { OUTPUT_RAW($OUTPUT); $OUTPUT = ''; }
+ // That's why you don't need any \n at the end of your HTML code... :-)
+ if ($newLine) $OUTPUT .= "\n";
+ }
+ break;
- // The same as above... ^
- OUTPUT_RAW($HTML);
- if ($newLine) echo "\n";
- break;
+ case 'direct':
+ // If we are switching from render to direct output rendered code
+ if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != 'on')) { outputRawCode($OUTPUT); $OUTPUT = ''; }
- default:
- // Huh, something goes wrong or maybe you have edited config.php ???
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", constant('OUTPUT_MODE')));
- app_die(__FUNCTION__, __LINE__, "{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}");
- break;
+ // The same as above... ^
+ outputRawCode($HTML);
+ if ($newLine) echo "\n";
+ break;
+
+ default:
+ // Huh, something goes wrong or maybe you have edited config.php ???
+ app_die(__FUNCTION__, __LINE__, "{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}");
+ break;
}
- } elseif ((constant('_OB_CACHING') == "on") && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
+ } elseif ((constant('_OB_CACHING') == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
// Headers already sent?
if (headers_sent()) {
// Log this error
@@ -102,21 +101,21 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
} // END - if
// Send HTTP header
- header("HTTP/1.1 200");
+ sendHeader('HTTP/1.1 200');
// Used later
$now = gmdate('D, d M Y H:i:s') . ' GMT';
// General headers for no caching
- header("Expired: " . $now); // RFC2616 - Section 14.21
- header("Last-Modified: " . $now);
- header("Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0"); // HTTP/1.1
- header("Pragma: no-cache"); // HTTP/1.0
- header("Connection: Close");
+ sendHeader('Expired: ' . $now); // RFC2616 - Section 14.21
+ sendHeader('Last-Modified: ' . $now);
+ sendHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
+ sendHeader('Pragma: no-cache'); // HTTP/1.0
+ sendHeader('Connection: Close');
// Extension 'rewrite' installed?
- if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1")) {
- $OUTPUT = REWRITE_LINKS($OUTPUT);
+ if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
+ $OUTPUT = rewriteLinksInCode($OUTPUT);
} // END - if
// Compile and run finished rendered HTML code
@@ -135,11 +134,11 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
} // END - while
// Output code here, DO NOT REMOVE! ;-)
- OUTPUT_RAW($OUTPUT);
- } elseif ((constant('OUTPUT_MODE') == "render") && (!empty($OUTPUT))) {
+ 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")) {
- $OUTPUT = REWRITE_LINKS($OUTPUT);
+ if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
+ $OUTPUT = rewriteLinksInCode($OUTPUT);
} // END - if
// Compile and run finished rendered HTML code
@@ -149,17 +148,17 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
} // END - while
// Output code here, DO NOT REMOVE! ;-)
- OUTPUT_RAW($OUTPUT);
+ outputRawCode($OUTPUT);
}
}
// Output the raw HTML code
-function OUTPUT_RAW ($HTML) {
+function outputRawCode ($HTML) {
// Output stripped HTML code to avoid broken JavaScript code, etc.
echo stripslashes(stripslashes($HTML));
- // Flush the output if only constant('_OB_CACHING') is not "on"
- if (constant('_OB_CACHING') != "on") {
+ // Flush the output if only constant('_OB_CACHING') is not 'on'
+ if (constant('_OB_CACHING') != 'on') {
// Flush it
flush();
} // END - if
@@ -177,7 +176,6 @@ function getFatalArray () {
// Add a fatal error message to the queue array
function addFatalMessage ($F, $L, $message, $extra='') {
- debug_report_bug($message);
if (is_array($extra)) {
// Multiple extras for a message with masks
$message = call_user_func_array('sprintf', $extra);
@@ -223,9 +221,9 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
incrementConfigEntry('num_templates');
// Prepare IP number and User Agent
- $REMOTE_ADDR = GET_REMOTE_ADDR();
+ $REMOTE_ADDR = detectRemoteAddr();
if (!defined('REMOTE_ADDR')) define('REMOTE_ADDR', $REMOTE_ADDR);
- $HTTP_USER_AGENT = GET_USER_AGENT();
+ $HTTP_USER_AGENT = detectUserAgent();
// Init some data
$ret = '';
@@ -235,7 +233,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
if ($template == "member_support_form") {
// Support request of a member
$result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(getUserId()), __FUNCTION__, __LINE__);
+ array(getUserId()), __FUNCTION__, __LINE__);
// Is content an array?
if (is_array($content)) {
@@ -243,7 +241,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
$content = merge_array($content, SQL_FETCHARRAY($result));
// Translate gender
- $content['gender'] = TRANSLATE_GENDER($content['gender']);
+ $content['gender'] = translateGender($content['gender']);
} else {
// @DEPRECATED
// @TODO Fine all templates which are using these direct variables and rewrite them.
@@ -251,7 +249,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
list($gender, $surname, $family, $email) = SQL_FETCHROW($result);
// Translate gender
- $gender = TRANSLATE_GENDER($gender);
+ $gender = translateGender($gender);
DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array (%s).", gettype($content)));
}
@@ -260,71 +258,71 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
} // END - if
// Generate date/time string
- $date_time = MAKE_DATETIME(time(), "1");
+ $date_time = generateDateTime(time(), '1');
// Base directory
- $BASE = sprintf("%stemplates/%s/html/", constant('PATH'), GET_LANGUAGE());
- $MODE = '';
+ $basePath = sprintf("%stemplates/%s/html/", constant('PATH'), getLanguage());
+ $mode = '';
// Check for admin/guest/member templates
if (strpos($template, "admin_") > -1) {
// Admin template found
- $MODE = "admin/";
+ $mode = "admin/";
} elseif (strpos($template, "guest_") > -1) {
// Guest template found
- $MODE = "guest/";
+ $mode = "guest/";
} elseif (strpos($template, "member_") > -1) {
// Member template found
- $MODE = "member/";
+ $mode = "member/";
} elseif (strpos($template, "install_") > -1) {
// Installation template found
- $MODE = "install/";
+ $mode = "install/";
} elseif (strpos($template, "ext_") > -1) {
// Extension template found
- $MODE = "ext/";
+ $mode = "ext/";
} elseif (strpos($template, "la_") > -1) {
// "Logical-area" template found
- $MODE = "la/";
+ $mode = "la/";
} else {
// Test for extension
$test = substr($template, 0, strpos($template, "_"));
if (EXT_IS_ACTIVE($test)) {
// Set extra path to extension's name
- $MODE = $test."/";
+ $mode = $test.'/';
}
}
////////////////////////
// Generate file name //
////////////////////////
- $FQFN = $BASE.$MODE.$template.".tpl";
+ $FQFN = $basePath.$mode.$template.".tpl";
- if ((!empty($GLOBALS['what'])) && ((strpos($template, "_header") > 0) || (strpos($template, "_footer") > 0)) && (($MODE == "guest/") || ($MODE == "member/") || ($MODE == "admin/"))) {
+ if ((!empty($GLOBALS['what'])) && ((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",
- $BASE,
- $MODE,
- $template,
- SQL_ESCAPE($GLOBALS['what'])
+ $basePath,
+ $mode,
+ $template,
+ SQL_ESCAPE($GLOBALS['what'])
);
// Probe for it...
- if (FILE_READABLE($file2)) $FQFN = $file2;
+ if (isFileReadable($file2)) $FQFN = $file2;
// Remove variable from memory
unset($file2);
}
// Does the special template exists?
- if (!FILE_READABLE($FQFN)) {
+ if (!isFileReadable($FQFN)) {
// Reset to default template
- $FQFN = $BASE.$template.".tpl";
+ $FQFN = $basePath.$template.".tpl";
} // END - if
// Now does the final template exists?
- if (FILE_READABLE($FQFN)) {
+ if (isFileReadable($FQFN)) {
// The local file does exists so we load it. :)
- $tmpl_file = READ_FILE($FQFN);
+ $tmpl_file = readFromFile($FQFN);
// Replace ' to our own chars to preventing them being quoted
while (strpos($tmpl_file, "'") !== false) { $tmpl_file = str_replace("'", '{QUOT}', $tmpl_file); }
@@ -344,12 +342,12 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
$ret = "\n".$ret."\n";
} elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) {
// Only admins shall see this warning or when installation mode is active
- $ret = "
".TEMPLATE_404."
+ $ret = "
{--TEMPLATE_404--}
(".basename($FQFN).")
-".TEMPLATE_CONTENT."
+{--TEMPLATE_CONTENT--}