X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=fa2b69e6941be1c3ac5975b94196d264a19499eb;hb=e0eb0432f1049f2b645a84d964d7d40adc8a11bb;hp=545a2f2eb41823b76000be5e197cb823262656a8;hpb=06a24901c58897845bafc1e5b428fee99024bc64;p=mailer.git
diff --git a/inc/functions.php b/inc/functions.php
index 545a2f2eb4..fa2b69e694 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -58,7 +58,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
outputRawCode($HTML);
// That's why you don't need any \n at the end of your HTML code... :-)
- if ($newLine) echo "\n";
+ if ($newLine) print("\n");
} else {
// Render mode for old or lame servers...
$OUTPUT .= $HTML;
@@ -74,7 +74,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
// The same as above... ^
outputRawCode($HTML);
- if ($newLine) echo "\n";
+ if ($newLine) print("\n");
break;
default:
@@ -120,6 +120,9 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
// 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
@@ -155,7 +158,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
// Output the raw HTML code
function outputRawCode ($HTML) {
// Output stripped HTML code to avoid broken JavaScript code, etc.
- echo stripslashes(stripslashes($HTML));
+ print(stripslashes(stripslashes($HTML)));
// Flush the output if only constant('_OB_CACHING') is not 'on'
if (constant('_OB_CACHING') != 'on') {
@@ -235,7 +238,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
// @DEPRECATED Try to rewrite the if() condition
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",
+ $result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
array(getUserId()), __FUNCTION__, __LINE__);
// Is content an array?
@@ -247,13 +250,13 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
$content['gender'] = translateGender($content['gender']);
} else {
// @DEPRECATED
- // @TODO Fine all templates which are using these direct variables and rewrite them.
+ // @TODO Find all templates which are using these direct variables and rewrite them.
// @TODO After this step is done, this else-block is history
list($gender, $surname, $family, $email) = SQL_FETCHROW($result);
// Translate gender
$gender = translateGender($gender);
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array (%s).", gettype($content)));
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array [%s], template=%s.", gettype($content), $template));
}
// Free result
@@ -286,13 +289,16 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
} elseif (strpos($template, 'la_') > -1) {
// 'Logical-area' template found
$mode = 'la/';
+ } elseif (strpos($template, 'js_') > -1) {
+ // JavaScript template found
+ $mode = 'js/';
} 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 . '/';
+ } // END - if
}
////////////////////////
@@ -341,8 +347,11 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
$ret = $tmpl_file;
}
- // Add surrounding HTML comments to help finding bugs faster
- $ret = "\n" . $ret . "\n";
+ // Normal HTML output?
+ if ($GLOBALS['output_mode'] == 0) {
+ // Add surrounding HTML comments to help finding bugs faster
+ $ret = "\n" . $ret . "\n";
+ } // END - if
} elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) {
// Only admins shall see this warning or when installation mode is active
$ret = "
{--TEMPLATE_404--}
@@ -377,22 +386,24 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
// Send mail out to an email address
function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') {
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject}
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject}
");
// Compile subject line (for POINTS constant etc.)
$eval = "\$subject = decodeEntities(\"".COMPILE_CODE(smartAddSlashes($subject))."\");";
eval($eval);
// Set from header
- if ((!eregi("@", $toEmail)) && ($toEmail > 0)) {
+ if ((!eregi('@', $toEmail)) && ($toEmail > 0)) {
// Value detected, is the message extension installed?
- if (EXT_IS_ACTIVE("msg")) {
+ // @TODO Extension 'msg' does not exist
+ if (EXT_IS_ACTIVE('msg')) {
ADD_MESSAGE_TO_BOX($toEmail, $subject, $message, $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($toEmail)), __FUNCTION__, __LINE__);
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):numRows=".SQL_NUMROWS($result_email)."
\n";
+ $result_email = SQL_QUERY_ESC("SELECT `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(bigintval($toEmail)), __FUNCTION__, __LINE__);
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):numRows=".SQL_NUMROWS($result_email)."
");
// Does the user exist?
if (SQL_NUMROWS($result_email)) {
@@ -410,7 +421,7 @@ function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
// Is the webmaster!
$toEmail = constant('WEBMASTER');
}
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$toEmail}
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):TO={$toEmail}
");
// Check for PHPMailer or debug-mode
if (!checkPhpMailerUsage()) {
@@ -514,16 +525,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
@@ -782,25 +793,25 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
} // END - if
// Load user's data
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):UID={$UID},template={$template},content[]=".gettype($content)."
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):UID={$UID},template={$template},content[]=".gettype($content)."
");
if (($UID > 0) && (is_array($content))) {
// If nickname extension is installed, fetch nickname as well
if (EXT_IS_ACTIVE('nickname')) {
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):NICKNAME!
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):NICKNAME!
");
// Load nickname
- $result = SQL_QUERY_ESC("SELECT surname, family, gender, email, nickname FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($UID)), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email`, `nickname` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(bigintval($UID)), __FUNCTION__, __LINE__);
} else {
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):NO-NICK!
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):NO-NICK!
");
/// Load normal data
- $result = SQL_QUERY_ESC("SELECT surname, family, gender, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($UID)), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(bigintval($UID)), __FUNCTION__, __LINE__);
}
// Fetch and merge data
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):content()=".count($content)." - PRE
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):content()=".count($content)." - PRE
");
$content = merge_array($content, SQL_FETCHARRAY($result));
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):content()=".count($content)." - AFTER
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):content()=".count($content)." - AFTER
");
// Free result
SQL_FREERESULT($result);
@@ -1020,10 +1031,10 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
$test = substr($found, 0, strlen($match));
// Does this entry exist?
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):found={$found},match={$match},set={$set}
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):found={$found},match={$match},set={$set}
");
if ($test == $match) {
// Match found!
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):fuzzyFound!
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):fuzzyFound!
");
$fuzzyFound = true;
break;
} // END - if
@@ -1035,14 +1046,14 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
// Take all string elements
if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key."_" . $matches[4][$key]]))) {
// Replace it in the code
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):key={$key},match={$match}
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):key={$key},match={$match}
");
$newMatch = str_replace("[" . $matches[4][$key]."]", "['" . $matches[4][$key]."']", $match);
$code = str_replace($match, "\"." . $newMatch.".\"", $code);
$matchesFound[$key."_" . $matches[4][$key]] = 1;
$matchesFound[$match] = 1;
} elseif (!isset($matchesFound[$match])) {
// Not yet replaced!
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):match={$match}
\n";
+ //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."(".__LINE__."):match={$match}
");
$code = str_replace($match, "\"." . $match.".\"", $code);
$matchesFound[$match] = 1;
}
@@ -1234,7 +1245,7 @@ function generateRandomCode ($length, $code, $uid, $DATA = '') {
$keys = getConfig('SITE_KEY').getConfig('ENCRYPT_SEPERATOR').getConfig('DATE_KEY');
if (isConfigEntrySet('secret_key')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('secret_key');
if (isConfigEntrySet('file_hash')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('file_hash');
- $keys .= getConfig('ENCRYPT_SEPERATOR').date("d-m-Y (l-F-T)", getConfig(('patch_ctime')));
+ $keys .= getConfig('ENCRYPT_SEPERATOR') . date("d-m-Y (l-F-T)", getConfig('patch_ctime'));
if (isConfigEntrySet('master_salt')) $keys .= getConfig('ENCRYPT_SEPERATOR').getConfig('master_salt');
// Build string from misc data
@@ -1286,9 +1297,9 @@ function bigintval ($num, $castValue = true) {
// Has the whole value changed?
// @TODO Remove this if() block if all is working fine
- if ("" . $ret."" != '' . $num."") {
+ if ('' . $ret . '' != '' . $num . '') {
// Log the values
- debug_report_bug("{$ret}<>{$num}");
+ //debug_report_bug("{$ret}<>{$num}");
} // END - if
// Return result
@@ -1362,25 +1373,25 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
// First of all years...
$Y = abs(floor($timestamp / (31536000 + $SWITCH)));
- //* DEBUG: */ print("Y={$Y}
\n");
+ //* DEBUG: */ print("Y={$Y}
");
// Next months...
$M = abs(floor($timestamp / 2628000 - $Y * 12));
- //* DEBUG: */ print("M={$M}
\n");
+ //* DEBUG: */ print("M={$M}
");
// Next weeks
$W = abs(floor($timestamp / 604800 - $Y * ((365 + $SWITCH / getConfig('one_day')) / 7) - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) / 7)));
- //* DEBUG: */ print("W={$W}
\n");
+ //* DEBUG: */ print("W={$W}
");
// Next days...
$D = abs(floor($timestamp / 86400 - $Y * (365 + $SWITCH / getConfig('one_day')) - ($M / 12 * (365 + $SWITCH / getConfig('one_day'))) - $W * 7));
- //* DEBUG: */ print("D={$D}
\n");
+ //* DEBUG: */ print("D={$D}
");
// Next hours...
$h = abs(floor($timestamp / 3600 - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24) - $W * 7 * 24 - $D * 24));
- //* DEBUG: */ print("h={$h}
\n");
+ //* DEBUG: */ print("h={$h}
");
// Next minutes..
$m = abs(floor($timestamp / 60 - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 * 60 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24 * 60) - $W * 7 * 24 * 60 - $D * 24 * 60 - $h * 60));
- //* DEBUG: */ print("m={$m}
\n");
+ //* DEBUG: */ print("m={$m}
");
// And at last seconds...
$s = abs(floor($timestamp - $Y * (365 + $SWITCH / getConfig('one_day')) * 24 * 3600 - ($M / 12 * (365 + $SWITCH / getConfig('one_day')) * 24 * 3600) - $W * 7 * 24 * 3600 - $D * 24 * 3600 - $h * 3600 - $m * 60));
- //* DEBUG: */ print("s={$s}
\n");
+ //* DEBUG: */ print("s={$s}
");
// Is seconds zero and time is < 60 seconds?
if (($s == 0) && ($timestamp < 60)) {
@@ -1412,7 +1423,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
$OUT .= " {--_YEARS--} | \n";
}
- if (ereg("M", $display) || (empty($display))) {
+ if (ereg('M', $display) || (empty($display))) {
$OUT .= " {--_MONTHS--} | \n";
}
@@ -1452,7 +1463,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
$OUT .= "\n";
}
- if (ereg("M", $display) || (empty($display))) {
+ if (ereg('M', $display) || (empty($display))) {
// Generate month selection
$OUT .= " |