X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=9daec4f80d97259f60a72dbff68ea501694d0143;hb=3f96fb4deadc0f967980e855d3541224057606b2;hp=da1848b706f021c733159beee1c36cf3c07fb330;hpb=9207b69bff87abcb880d457148fda2f1adaebf24;p=mailer.git
diff --git a/inc/functions.php b/inc/functions.php
index da1848b706..9daec4f80d 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -10,7 +10,12 @@
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Viele Nicht-MySQL-Funktionen (auch Dateizugriff) *
* -------------------------------------------------------------------- *
- * *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
+ * Needs to be in all Files and every File needs "svn propset *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2008 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
@@ -30,35 +35,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
* MA 02110-1301 USA *
************************************************************************/
-
// Some security stuff...
if (!defined('__SECURITY')) {
$INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
require($INC);
}
-// Check if our config file is writeable or not
-function IS_INC_WRITEABLE($inc) {
- // Generate FQFN
- $fqfn = sprintf("%sinc/%s.php", constant('PATH'), $inc);
-
- // Abort by simple test
- if ((FILE_READABLE($fqfn)) && (!is_writeable($fqfn))) {
- return false;
- } // END - if
-
- // Test if we can append data
- $fp = fopen($fqfn, 'a');
- if ($inc == "dummy") {
- // Remove dummy file
- fclose($fp);
- return unlink($fqfn);
- } else {
- // Close all other files
- return fclose($fp);
- }
-}
-
// Output HTML code directly or "render" it. You addionally switch the new-line character off
function OUTPUT_HTML ($HTML, $newLine = true) {
// Some global variables
@@ -98,7 +80,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
default:
// Huh, something goes wrong or maybe you have edited config.php ???
DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", constant('OUTPUT_MODE')));
- mxchange_die("{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}");
+ app_die(__FUNCTION__, __LINE__, "{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}");
break;
}
} elseif ((constant('_OB_CACHING') == "on") && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
@@ -147,7 +129,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
// Was that eval okay?
if (empty($newContent)) {
// Something went wrong!
- mxchange_die("Evaluation error:
".htmlentities($eval)."
");
+ app_die(__FUNCTION__, __LINE__, "Evaluation error:".htmlentities($eval)."
");
} // END - if
$OUTPUT = $newContent;
} // END - while
@@ -195,6 +177,7 @@ 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);
@@ -249,7 +232,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($GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array(getUserId()), __FUNCTION__, __LINE__);
// Is content an array?
if (is_array($content)) {
@@ -375,7 +358,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
// Do we have some content to output or return?
if (!empty($ret)) {
// Not empty so let's put it out! ;)
- if ($return) {
+ if ($return === true) {
// Return the HTML code
return $ret;
} else {
@@ -389,68 +372,68 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
}
// Send mail out to an email address
-function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML = "N", $FROM = "") {
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$TO},SUBJECT={$SUBJECT}
\n";
+function SEND_EMAIL($toEmail, $subject, $message, $HTML = "N", $mailHeader = "") {
+ //* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject}
\n";
// Compile subject line (for POINTS constant etc.)
- $eval = "\$SUBJECT = decodeEntities(\"".COMPILE_CODE(smartAddSlashes($SUBJECT))."\");";
+ $eval = "\$subject = decodeEntities(\"".COMPILE_CODE(smartAddSlashes($subject))."\");";
eval($eval);
// Set from header
- if ((!eregi("@", $TO)) && ($TO > 0)) {
+ if ((!eregi("@", $toEmail)) && ($toEmail > 0)) {
// Value detected, is the message extension installed?
if (EXT_IS_ACTIVE("msg")) {
- ADD_MESSAGE_TO_BOX($TO, $SUBJECT, $MSG, $HTML);
+ 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($TO)), __FUNCTION__, __LINE__);
+ $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";
// Does the user exist?
if (SQL_NUMROWS($result_email)) {
// Load email address
- list($TO) = SQL_FETCHROW($result_email);
+ list($toEmail) = SQL_FETCHROW($result_email);
} else {
// Set webmaster
- $TO = constant('WEBMASTER');
+ $toEmail = constant('WEBMASTER');
}
// Free result
SQL_FREERESULT($result_email);
}
- } elseif ("$TO" == "0") {
+ } elseif ("$toEmail" == "0") {
// Is the webmaster!
- $TO = constant('WEBMASTER');
+ $toEmail = constant('WEBMASTER');
}
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$TO}
\n";
+ //* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$toEmail}
\n";
// Check for PHPMailer or debug-mode
if (!CHECK_PHPMAILER_USAGE()) {
// Not in PHPMailer-Mode
- if (empty($FROM)) {
+ if (empty($mailHeader)) {
// Load email header template
- $FROM = LOAD_EMAIL_TEMPLATE("header");
+ $mailHeader = LOAD_EMAIL_TEMPLATE("header");
} else {
// Append header
- $FROM .= LOAD_EMAIL_TEMPLATE("header");
+ $mailHeader .= LOAD_EMAIL_TEMPLATE("header");
}
} elseif (isDebugModeEnabled()) {
- if (empty($FROM)) {
+ if (empty($mailHeader)) {
// Load email header template
- $FROM = LOAD_EMAIL_TEMPLATE("header");
+ $mailHeader = LOAD_EMAIL_TEMPLATE("header");
} else {
// Append header
- $FROM .= LOAD_EMAIL_TEMPLATE("header");
+ $mailHeader .= LOAD_EMAIL_TEMPLATE("header");
}
}
// Compile "TO"
- $eval = "\$TO = \"".COMPILE_CODE(smartAddSlashes($TO))."\";";
+ $eval = "\$toEmail = \"".COMPILE_CODE(smartAddSlashes($toEmail))."\";";
eval($eval);
// Compile "MSG"
- $eval = "\$MSG = \"".COMPILE_CODE(smartAddSlashes($MSG))."\";";
+ $eval = "\$message = \"".COMPILE_CODE(smartAddSlashes($message))."\";";
eval($eval);
// Fix HTML parameter (default is no!)
@@ -458,20 +441,20 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML = "N", $FROM = "") {
if (isDebugModeEnabled()) {
// In debug mode we want to display the mail instead of sending it away so we can debug this part
print("
-".htmlentities(trim($FROM))."
-To : ".$TO."
-Subject : ".$SUBJECT."
-Message : ".$MSG."
+".htmlentities(trim($mailHeader))."
+To : ".$toEmail."
+Subject : ".$subject."
+Message : ".$message."
\n");
} elseif (($HTML == "Y") && (EXT_IS_ACTIVE("html_mail"))) {
// Send mail as HTML away
- SEND_HTML_EMAIL($TO, $SUBJECT, $MSG, $FROM);
- } elseif (!empty($TO)) {
+ SEND_HTML_EMAIL($toEmail, $subject, $message, $mailHeader);
+ } elseif (!empty($toEmail)) {
// Send Mail away
- SEND_RAW_EMAIL($TO, $SUBJECT, $MSG, $FROM);
+ SEND_RAW_EMAIL($toEmail, $subject, $message, $mailHeader);
} elseif ($HTML == "N") {
// Problem found!
- SEND_RAW_EMAIL(constant('WEBMASTER'), "[PROBLEM:]".$SUBJECT, $MSG, $FROM);
+ SEND_RAW_EMAIL(constant('WEBMASTER'), "[PROBLEM:]".$subject, $message, $mailHeader);
}
}
@@ -485,7 +468,7 @@ function CHECK_PHPMAILER_USAGE() {
/*
* Send out a raw email with PHPMailer class or legacy mail() command
*/
-function SEND_RAW_EMAIL ($to, $subject, $msg, $from) {
+function SEND_RAW_EMAIL ($toEmail, $subject, $msg, $from) {
// Shall we use PHPMailer class or legacy mode?
if (CHECK_PHPMAILER_USAGE()) {
// Use PHPMailer class with SMTP enabled
@@ -517,14 +500,14 @@ function SEND_RAW_EMAIL ($to, $subject, $msg, $from) {
} else {
$mail->Body = decodeEntities($msg);
}
- $mail->AddAddress($to, "");
+ $mail->AddAddress($toEmail, "");
$mail->AddReplyTo(constant('WEBMASTER'), constant('MAIN_TITLE'));
$mail->AddCustomHeader("Errors-To:".constant('WEBMASTER'));
$mail->AddCustomHeader("X-Loop:".constant('WEBMASTER'));
$mail->Send();
} else {
// Use legacy mail() command
- @mail($to, $subject, decodeEntities($msg), $from);
+ @mail($toEmail, $subject, decodeEntities($msg), $from);
}
}
//
@@ -540,7 +523,7 @@ function GEN_PASS ($LEN = 0) {
// Start creating password
$PASS = "";
for ($i = 0; $i < $LEN; $i++) {
- $PASS .= $ABC[mt_rand(0, sizeof($ABC) -1)];
+ $PASS .= $ABC[mt_rand(0, count($ABC) -1)];
} // END - for
// When the size is below 40 we can also add additional security by scrambling it
@@ -665,8 +648,7 @@ function TRANSLATE_GENDER ($gender) {
//
function FRAMETESTER ($URL) {
// Prepare frametester URL
- $frametesterUrl = sprintf("%s/modules.php?module=frametester&url=%s",
- URL,
+ $frametesterUrl = sprintf("{!URL!}/modules.php?module=frametester&url=%s",
encodeString(compileUriCode($URL))
);
return $frametesterUrl;
@@ -703,7 +685,7 @@ function TRANSLATE_STATUS ($status) {
default:
DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
- $ret = sprintf(getMessage('UNKNOWN_STATUS"'), $status);
+ $ret = sprintf(getMessage('UNKNOWN_STATUS'), $status);
break;
}
@@ -954,7 +936,7 @@ function LOAD_URL ($URL, $addUrlData=true) {
LOAD_TEMPLATE("redirect_url", false, str_replace("&", "&", $URL));
LOAD_INC("inc/footer.php");
}
- exit();
+ shutdown();
}
// Wrapper for LOAD_URL but URL comes from a configuration entry
@@ -980,13 +962,14 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
return $code;
} // END - if
- $ARRAY = $GLOBALS['security_chars'];
+ // Init replacement-array with full security characters
+ $secChars = $GLOBALS['security_chars'];
// Select smaller set of chars to replace when we e.g. want to compile URLs
- if (!$full) $ARRAY = $GLOBALS['url_chars'];
+ if (!$full) $secChars = $GLOBALS['url_chars'];
// Compile constants
- if ($constants) {
+ if ($constants === true) {
// BEFORE 0.2.1 : Language and data constants
// WITH 0.2.1+ : Only language constants
$code = str_replace('{--','".', str_replace('--}','."', $code));
@@ -997,16 +980,16 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
} // END - if
// Compile QUOT and other non-HTML codes
- foreach ($ARRAY['to'] as $k => $to) {
+ foreach ($secChars['to'] as $k => $to) {
// Do the reversed thing as in inc/libs/security_functions.php
- $code = str_replace($to, $ARRAY['from'][$k], $code);
+ $code = str_replace($to, $secChars['from'][$k], $code);
} // END - foreach
// But shall I keep simple quotes for later use?
if ($simple) $code = str_replace("'", '{QUOT}', $code);
// Find $content[bla][blub] entries
- @preg_match_all('/\$(content|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches);
+ preg_match_all('/\$(content|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches);
// Are some matches found?
if ((count($matches) > 0) && (count($matches[0]) > 0)) {
@@ -1108,7 +1091,6 @@ function array_pk_sort (&$array, $a_sort, $primary_key = 0, $order = -1, $nums =
//
function ADD_SELECTION ($type, $DEFAULT, $prefix="", $id="0") {
- global $MONTH_DESCR;
$OUT = "";
if ($type == "yn") {
@@ -1133,7 +1115,7 @@ function ADD_SELECTION ($type, $DEFAULT, $prefix="", $id="0") {
break;
case "month": // Month
- foreach ($MONTH_DESCR as $month => $descr) {
+ foreach ($GLOBALS['month_descr'] as $month => $descr) {
$OUT .= "