More fixes for reflink and rallye extension
[mailer.git] / inc / functions.php
index 9a7b1fc6f1fb23c6758cf81baf23b15a7d45cf5b..3dcee7a5cce4ea43680c3ae67ac6ee7f27ff18a3 100644 (file)
@@ -134,7 +134,7 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) {
                ob_end_clean();
 
                // Extension "rewrite" installed?
-               if ((EXT_IS_ACTIVE("rewrite", true)) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) {
+               if ((EXT_IS_ACTIVE("rewrite")) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) {
                        $OUTPUT = REWRITE_LINKS($OUTPUT);
                } // END - if
 
@@ -157,7 +157,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", true)) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) {
+               if ((EXT_IS_ACTIVE("rewrite")) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) {
                        $OUTPUT = REWRITE_LINKS($OUTPUT);
                } // END - if
 
@@ -420,7 +420,10 @@ To      : ".$TO."
 Subject : ".$SUBJECT."
 Message : ".$MSG."
 </pre>\n";
-       } elseif (($HTML == "Y") && (EXT_IS_ACTIVE("html_mail", true))) {
+
+               // Log the mail away
+               if (defined('DEBUG_MAIL')) DEBUG_LOG(__FUNCTION__.":to={$TO},subject={$SUBJECT},msg={$MSG}");
+       } elseif (($HTML == "Y") && (EXT_IS_ACTIVE("html_mail"))) {
                // Send mail as HTML away
                SEND_HTML_EMAIL($TO, $SUBJECT, $MSG, $FROM);
        } elseif (!empty($TO)) {
@@ -898,6 +901,15 @@ function LOAD_URL($URL, $addUrlData=true) {
 //
 function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) {
        global $SEC_CHARS, $URL_CHARS;
+       // Is the code a string?
+       if (!is_string($code)) {
+               // Abort here with backtrace
+               DEBUG_LOG(__FUNCTION__.": code is not string!");
+               print "<pre>";
+               debug_print_backtrace();
+               die("</pre>");
+       } // END - if
+
        $ARRAY = $SEC_CHARS;
 
        // Select smaller set of chars to replace when we e.g. want to compile URLs
@@ -1908,7 +1920,7 @@ function CREATE_EMAIL_LINK($email, $table="admins") {
        if ((EXT_IS_ACTIVE("admins")) && ($table == "admins")) {
                // Create email link for contacting admin in guest area
                $EMAIL = ADMINS_CREATE_EMAIL_LINK($email);
-       } elseif ((EXT_IS_ACTIVE("user", true)) && (GET_EXT_VERSION("user") >= "0.3.3") && ($table == "user_data")) {
+       } elseif ((EXT_IS_ACTIVE("user")) && (GET_EXT_VERSION("user") >= "0.3.3") && ($table == "user_data")) {
                // Create email link for contacting a member within admin area (or later in other areas, too?)
                $EMAIL = USER_CREATE_EMAIL_LINK($email);
        } elseif ((EXT_IS_ACTIVE("sponsor")) && ($table == "sponsor_data")) {
@@ -1927,7 +1939,7 @@ function generateHash ($plainText, $salt = "") {
        global $_CONFIG, $_SERVER;
 
        // Is the required extension "sql_patches" there and a salt is not given?
-       if (((EXT_VERSION_IS_OLDER("sql_patches", "0.3.6")) || (EXT_IS_ACTIVE("sql_patches"))) && (empty($salt))) {
+       if (((EXT_VERSION_IS_OLDER("sql_patches", "0.3.6")) || (!EXT_IS_ACTIVE("sql_patches"))) && (empty($salt))) {
                // Extension sql_patches is missing/outdated so we return the plain text
                return $plainText;
        } // END - if
@@ -2333,7 +2345,7 @@ function GET_DIR_AS_ARRAY ($baseDir, $prefix) {
 
                // Is this a valid reset file?
                //* DEBUG: */ echo __FUNCTION__.":baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}<br />\n";
-               if ((is_file($file)) && (is_readable($file)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) {
+               if ((FILE_READABLE($file)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) {
                        // Remove both for extension name
                        $extName = substr($baseFile, strlen($prefix), -4);
 
@@ -2529,8 +2541,17 @@ function REBUILD_CACHE ($cache, $inc="") {
 
                        // Include file given?
                        if (!empty($inc)) {
-                               // And rebuild it from scratch
-                               require_once(PATH."inc/loader/load_cache-".$inc.".php");
+                               // Construct FQFN
+                               $fqfn = sprintf("%sinc/loader/load_cache-%s.php", PATH, $inc);
+
+                               // Is the include there?
+                               if (FILE_READABLE($fqfn)) {
+                                       // And rebuild it from scratch
+                                       require_once($fqfn);
+                               } else {
+                                       // Include not found!
+                                       DEBUG_LOG(__FUNCTION__.":Include {$inc} not found. cache={$cache}");
+                               }
                        } // END - if
                } // END - if
        } // END - if