]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
More usage of GET_URL() than file()
[mailer.git] / inc / functions.php
index c32fbdc0fa0c27ebaa66483fa9847efee4bd3a23..5c69d92b29035759c1871c3202bc4c8ed23a0689 100644 (file)
@@ -132,7 +132,8 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) {
 
                default:
                        // Huh, something goes wrong or maybe you have edited config.php ???
-                       die ("<STRONG>".FATAL_ERROR.":</STRONG> ".LANG_NO_RENDER_DIRECT);
+                       DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", OUTPUT_MODE));
+                       MXCHANGE_DIE("<STRONG>".FATAL_ERROR.":</STRONG> ".LANG_NO_RENDER_DIRECT);
                        break;
                }
        } elseif ((_OB_CACHING == "on") && ($footer == 1)) {
@@ -239,11 +240,11 @@ function LOAD_TEMPLATE($template, $return=false, $content=array()) {
        $ret = "";
        if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0;
 
-       // @DEPRECATED Try to remove this if() block
+       // @DEPRECATED Try to rewrite the if() condition
        if ($template == "member_support_form") {
                // Support request of a member
-               $result = SQL_QUERY_ESC("SELECT gender, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
-                array($GLOBALS['userid']), __FILE__, __LINE__);
+               $result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
+                       array($GLOBALS['userid']), __FILE__, __LINE__);
 
                // Is content an array?
                if (is_array($content)) {
@@ -258,6 +259,7 @@ function LOAD_TEMPLATE($template, $return=false, $content=array()) {
 
                        // Translate gender
                        $gender = TRANSLATE_GENDER($gender);
+                       DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array (%s).", gettype($content)));
                }
 
                // Free result
@@ -537,13 +539,13 @@ function GEN_PASS($LEN = 0) {
        $PASS = "";
        for ($i = 0; $i < $LEN; $i++) {
                $PASS .= $ABC[mt_rand(0, sizeof($ABC) -1)];
-       }
+       } // END - for
 
        // When the size is below 40 we can also add additional security by scrambling it
        if (strlen($PASS) <= 40) {
                // Also scramble the password
                $PASS = scrambleString($PASS);
-       }
+       } // END - if
 
        // Return the password
        return $PASS;
@@ -567,6 +569,9 @@ function MAKE_DATETIME ($time, $mode="0")
                        case "1": $ret = strtolower(date("d.m.Y - H:i", $time)); break;
                        case "2": $ret = date("d.m.Y|H:i", $time); break;
                        case "3": $ret = date("d.m.Y", $time); break;
+                       default:
+                               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
+                               break;
                }
                break;
 
@@ -576,6 +581,9 @@ function MAKE_DATETIME ($time, $mode="0")
                        case "1": $ret = date("Y-m-d - g:i A", $time); break;
                        case "2": $ret = date("y-m-d|H:i", $time); break;
                        case "3": $ret = date("y-m-d", $time); break;
+                       default:
+                               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
+                               break;
                }
        }
        return $ret;
@@ -696,6 +704,7 @@ function TRANSLATE_STATUS($status) {
                break;
 
        default:
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
                $ret = UNKNOWN_STATUS_1.$status.UNKNOWN_STATUS_2;
                break;
        }
@@ -1747,6 +1756,7 @@ function POST_URL ($script, $postData) {
        // Is postData an array?
        if (!is_array($postData)) {
                // Abort here
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("postData is not an array. Type: %s", gettype($postData)));
                return array("", "", "");
        } // END - if
 
@@ -2375,7 +2385,7 @@ function merge_array ($array1, $array2) {
        die("</pre>");
 }
 // Debug message logger
-function DEBUG_LOG ($file, $line, $message, $force=false) {
+function DEBUG_LOG ($file, $line, $message, $force=true) {
        // Is debug mode enabled?
        if ((isBooleanConstantAndTrue('DEBUG_MODE')) || ($force)) {
                // Log this message away
@@ -2782,6 +2792,24 @@ function DETERMINE_REFID () {
        } // END - if
 }
 
+// Destroys the admin session
+function DESTROY_ADMIN_SESSION () {
+       // Kill maybe existing session variables including array elements
+       set_session('admin_login'       , "");
+       set_session('admin_md5'         , "");
+       set_session('admin_last'        , "");
+       set_session('admin_to'          , "");
+
+       // Destroy session and return status
+       return @session_destroy();
+}
+
+// Checks if a given apache module is loaded
+function IF_APACHE_MODULE_LOADED ($apacheModule) {
+       // Check it and return result
+       return (in_array($apacheModule, apache_get_modules()));
+}
+
 //////////////////////////////////////////////////
 //                                              //
 // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //