]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Even more constants/language strings rewritten, merge_array() now logs debug messages
[mailer.git] / inc / functions.php
index f071322d043c171fd85417d3dd4f23f0885ee8b3..6f668fc188a1775352b19ec101e1b93074eb1597 100644 (file)
@@ -67,7 +67,7 @@ function OUTPUT_HTML ($HTML, $NEW_LINE = true) {
        // Do we have HTML-Code here?
        if (!empty($HTML)) {
                // Yes, so we handle it as you have configured
        // Do we have HTML-Code here?
        if (!empty($HTML)) {
                // Yes, so we handle it as you have configured
-               switch (OUTPUT_MODE)
+               switch (constant('OUTPUT_MODE'))
                {
                case "render":
                        // That's why you don't need any \n at the end of your HTML code... :-)
                {
                case "render":
                        // That's why you don't need any \n at the end of your HTML code... :-)
@@ -97,7 +97,7 @@ function OUTPUT_HTML ($HTML, $NEW_LINE = true) {
 
                default:
                        // Huh, something goes wrong or maybe you have edited config.php ???
 
                default:
                        // Huh, something goes wrong or maybe you have edited config.php ???
-                       DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", OUTPUT_MODE));
+                       DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", constant('OUTPUT_MODE')));
                        mxchange_die("<strong>{!FATAL_ERROR!}:</strong> {!LANG_NO_RENDER_DIRECT!}");
                        break;
                }
                        mxchange_die("<strong>{!FATAL_ERROR!}:</strong> {!LANG_NO_RENDER_DIRECT!}");
                        break;
                }
@@ -152,7 +152,7 @@ function OUTPUT_HTML ($HTML, $NEW_LINE = true) {
 
                // Output code here, DO NOT REMOVE! ;-)
                OUTPUT_RAW($OUTPUT);
 
                // Output code here, DO NOT REMOVE! ;-)
                OUTPUT_RAW($OUTPUT);
-       } elseif ((OUTPUT_MODE == "render") && (!empty($OUTPUT))) {
+       } elseif ((constant('OUTPUT_MODE') == "render") && (!empty($OUTPUT))) {
                // Rewrite links when rewrite extension is active
                if ((EXT_IS_ACTIVE("rewrite")) && ($CSS != "1") && ($CSS != "-1")) {
                        $OUTPUT = REWRITE_LINKS($OUTPUT);
                // Rewrite links when rewrite extension is active
                if ((EXT_IS_ACTIVE("rewrite")) && ($CSS != "1") && ($CSS != "-1")) {
                        $OUTPUT = REWRITE_LINKS($OUTPUT);
@@ -459,7 +459,7 @@ Message : ".$MSG."
                SEND_RAW_EMAIL($TO, $SUBJECT, $MSG, $FROM);
        } elseif ($HTML == "N") {
                // Problem found!
                SEND_RAW_EMAIL($TO, $SUBJECT, $MSG, $FROM);
        } elseif ($HTML == "N") {
                // Problem found!
-               SEND_RAW_EMAIL(WEBMASTER, "[PROBLEM:]".$SUBJECT, $MSG, $FROM);
+               SEND_RAW_EMAIL(constant('WEBMASTER'), "[PROBLEM:]".$SUBJECT, $MSG, $FROM);
        }
 }
 
        }
 }
 
@@ -485,16 +485,16 @@ function SEND_RAW_EMAIL ($to, $subject, $msg, $from) {
 
                $mail->IsSMTP();
                $mail->SMTPAuth   = true;
 
                $mail->IsSMTP();
                $mail->SMTPAuth   = true;
-               $mail->Host       = SMTP_HOSTNAME;
+               $mail->Host       = constant('SMTP_HOSTNAME');
                $mail->Port       = 25;
                $mail->Port       = 25;
-               $mail->Username   = SMTP_USER;
-               $mail->Password   = SMTP_PASSWORD;
+               $mail->Username   = constant('SMTP_USER');
+               $mail->Password   = constant('SMTP_PASSWORD');
                if (empty($from)) {
                        $mail->From = constant('WEBMASTER');
                } else {
                        $mail->From = $from;
                }
                if (empty($from)) {
                        $mail->From = constant('WEBMASTER');
                } else {
                        $mail->From = $from;
                }
-               $mail->FromName   = MAIN_TITLE;
+               $mail->FromName   = constant('MAIN_TITLE');
                $mail->Subject    = $subject;
                if ((EXT_IS_ACTIVE("html_mail")) && (strip_tags($msg) != $msg)) {
                        $mail->Body       = $msg;
                $mail->Subject    = $subject;
                if ((EXT_IS_ACTIVE("html_mail")) && (strip_tags($msg) != $msg)) {
                        $mail->Body       = $msg;
@@ -505,9 +505,9 @@ function SEND_RAW_EMAIL ($to, $subject, $msg, $from) {
                        $mail->Body       = html_entity_decode($msg);
                }
                $mail->AddAddress($to, "");
                        $mail->Body       = html_entity_decode($msg);
                }
                $mail->AddAddress($to, "");
-               $mail->AddReplyTo(WEBMASTER,MAIN_TITLE);
-               $mail->AddCustomHeader("Errors-To:".WEBMASTER);
-               $mail->AddCustomHeader("X-Loop:".WEBMASTER);
+               $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->Send();
        } else {
                // Use legacy mail() command
@@ -751,15 +751,12 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") {
        // Default "nickname" if extension is not installed
        $nick = "---";
 
        // Default "nickname" if extension is not installed
        $nick = "---";
 
-       // Keept for backward-compatiblity (please replace these variables against our new {!CONST!} syntax!)
-       // No longer used: $MAIN_TITLE = MAIN_TITLE; $URL = constant('URL'); $WEBMASTER = constant('WEBMASTER');
-
        // Prepare IP number and User Agent
        $REMOTE_ADDR     = GET_REMOTE_ADDR();
        $HTTP_USER_AGENT = GET_USER_AGENT();
 
        // Default admin
        // Prepare IP number and User Agent
        $REMOTE_ADDR     = GET_REMOTE_ADDR();
        $HTTP_USER_AGENT = GET_USER_AGENT();
 
        // Default admin
-       $ADMIN = MAIN_TITLE;
+       $ADMIN = constant('MAIN_TITLE');
 
        // Is the admin logged in?
        if (IS_ADMIN()) {
 
        // Is the admin logged in?
        if (IS_ADMIN()) {
@@ -1955,7 +1952,7 @@ function VALIDATE_URL ($URL, $compile=true) {
        return (((substr($URL, 0, 7) == "http://") || (substr($URL, 0, 8) == "https://")) && (strlen($URL) >= 12));
 }
 //
        return (((substr($URL, 0, 7) == "http://") || (substr($URL, 0, 8) == "https://")) && (strlen($URL) >= 12));
 }
 //
-function MEMBER_ACTION_LINKS($uid, $status="") {
+function MEMBER_ACTION_LINKS ($uid, $status = "") {
        // Define all main targets
        $TARGETS = array("del_user", "edit_user", "lock_user", "add_points", "sub_points");
 
        // Define all main targets
        $TARGETS = array("del_user", "edit_user", "lock_user", "add_points", "sub_points");
 
@@ -2400,10 +2397,15 @@ function merge_array ($array1, $array2) {
                return array_merge($array1, $array2);
        } elseif (is_array($array1)) {
                // Return left array
                return array_merge($array1, $array2);
        } elseif (is_array($array1)) {
                // Return left array
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array2 is not an array. array != %s", gettype($array2)));
                return $array1;
                return $array1;
+       } elseif (is_array($array2)) {
+               // Return right array
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
+               return $array2;
        }
 
        }
 
-       // Something wired happened here...
+       // Both are not arrays
        print(__FUNCTION__.":<pre>");
        debug_print_backtrace();
        die("</pre>");
        print(__FUNCTION__.":<pre>");
        debug_print_backtrace();
        die("</pre>");