]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Cookie code removed, rewritten, internal URLs are now relative (see LOAD_URL()),...
[mailer.git] / inc / functions.php
index 1133a3b1cbd646cb346d202173a33292edb26f40..b2a538bc9ba381acf6542c88cc895750cb95ab84 100644 (file)
@@ -51,16 +51,17 @@ function IS_INC_WRITEABLE($inc) {
        $fp = @fopen($fqfn, 'a');
        if ($inc == "dummy") {
                // Remove dummy file
-               @fclose($fp);
-               return @unlink($fqfn);
+               fclose($fp);
+               return unlink($fqfn);
        } else {
                // Close all other files
-               return @fclose($fp);
+               return fclose($fp);
        }
 }
 
 // Open a table (you may want to add some header stuff here)
-function OPEN_TABLE($PERCENT = "", $CLASS = "", $ALIGN="left", $VALIGN="", $td_only=false) {
+// @DEPRECATED
+function OPEN_TABLE ($PERCENT = "", $CLASS = "", $ALIGN="left", $VALIGN="", $td_only=false) {
        global $table_cnt;
 
        // Count tables so we can generate CSS classes for every table... :-)
@@ -88,14 +89,15 @@ function OPEN_TABLE($PERCENT = "", $CLASS = "", $ALIGN="left", $VALIGN="", $td_o
 }
 
 // Close a table (you may want to add some footer stuff here)
-function CLOSE_TABLE($ADD="") {
+// @DEPRECATED
+function CLOSE_TABLE( $ADD="") {
        OUTPUT_HTML("  </TD>\n</TR>");
        if (!empty($ADD)) OUTPUT_HTML($ADD);
        OUTPUT_HTML("</TABLE>");
 }
 
 // Output HTML code directly or "render" it. You addionally switch the new-line character off
-function OUTPUT_HTML($HTML, $NEW_LINE = true) {
+function OUTPUT_HTML ($HTML, $NEW_LINE = true) {
        // Some global variables
        global $OUTPUT, $footer, $CSS;
 
@@ -648,7 +650,7 @@ function DEREFERER ($URL) {
        // Don't de-refer our own links!
        if (substr($URL, 0, strlen(URL)) != URL) {
                // De-refer this link
-               $URL = URL."/modules.php?module=loader&amp;url=".urlencode(base64_encode(gzcompress($URL)));
+               $URL = "modules.php?module=loader&amp;url=".urlencode(base64_encode(gzcompress($URL)));
        } // END - if
 
        // Return link
@@ -755,12 +757,12 @@ function GET_LANGUAGE() {
        return $ret;
 }
 //
-function SET_LANGUAGE($lang) {
+function SET_LANGUAGE ($lang) {
        // Accept only first 2 chars!
        $lang = substr(SQL_ESCAPE(strip_tags($lang)), 0, 2);
 
        // Set cookie
-       set_session("mx_lang", $lang);
+       set_session('mx_lang', $lang);
 }
 //
 function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") {
@@ -937,7 +939,7 @@ function LOAD_URL($URL, $addUrlData=true) {
        // Check if http(s):// is there
        if ((substr($URL, 0, 7) != "http://") && (substr($URL, 0, 8) != "https://")) {
                // Make all URLs full-qualified
-               $URL = URL."/".$URL;
+               $URL = "".$URL;
        }
 
        // Get output buffer
@@ -1263,7 +1265,6 @@ function GEN_RANDOM_CODE($length, $code, $uid, $DATA="") {
        // Add more additional data
        if (isSessionVariableSet('u_hash'))                     $data .= ":".get_session('u_hash');
        if (isset($GLOBALS['userid']))                          $data .= ":".$GLOBALS['userid'];
-       if (isSessionVariableSet('lifetime'))           $data .= ":".get_session('lifetime');
        if (isSessionVariableSet('mxchange_theme'))     $data .= ":".get_session('mxchange_theme');
        if (isSessionVariableSet('mx_lang'))            $data .= ":".GET_LANGUAGE();
        if (isset($GLOBALS['refid']))                           $data .= ":".$GLOBALS['refid'];
@@ -2377,6 +2378,7 @@ function get_session ($var) {
        // Return the value
        return $value;
 }
+
 // Send notification to admin
 function SEND_ADMIN_NOTIFICATION($subject, $templateName, $content=array(), $uid="0") {
        if (GET_EXT_VERSION("admins") >= "0.4.1") {
@@ -2388,11 +2390,16 @@ function SEND_ADMIN_NOTIFICATION($subject, $templateName, $content=array(), $uid
                SEND_ADMIN_EMAILS($subject, $msg);
        }
 }
+
 // Destroy user session
 function destroy_user_session () {
+       // Reset userid
+       $GLOBALS['userid'] = 0;
+
        // Remove all user data from session
-       return ((set_session("userid", "")) && (set_session("u_hash", "")) && (set_session("lifetime", "")));
+       return ((set_session('userid', "")) && (set_session('u_hash', "")));
 }
+
 // Merges an array together but only if both are arrays
 function merge_array ($array1, $array2) {
        // Are both an array?
@@ -2409,6 +2416,7 @@ function merge_array ($array1, $array2) {
        debug_print_backtrace();
        die("</pre>");
 }
+
 // Debug message logger
 function DEBUG_LOG ($file, $line, $message, $force=true) {
        // Is debug mode enabled?
@@ -2419,6 +2427,7 @@ function DEBUG_LOG ($file, $line, $message, $force=true) {
                fclose($fp);
        } // END - if
 }
+
 // Reads a directory with PHP files in and gets only files back
 function GET_DIR_AS_ARRAY ($baseDir, $prefix) {
        $INCs = array();
@@ -2898,7 +2907,7 @@ function GET_CURR_THEME() {
 
        if (!isSessionVariableSet('mxchange_theme')) {
                // Set default theme
-               set_session("mxchange_theme", $ret);
+               set_session('mxchange_theme', $ret);
        } elseif ((isSessionVariableSet('mxchange_theme')) && (GET_EXT_VERSION("sql_patches") >= "0.1.4")) {
                //die("<pre>".print_r($cacheArray['themes'], true)."</pre>");
                // Get theme from cookie
@@ -2916,17 +2925,17 @@ function GET_CURR_THEME() {
                // Installation mode active
                if ((!empty($_GET['theme'])) && (FILE_READABLE($theme))) {
                        // Set cookie from URL data
-                       set_session("mxchange_theme", SQL_ESCAPE($_GET['theme']));
+                       set_session('mxchange_theme', SQL_ESCAPE($_GET['theme']));
                } elseif (FILE_READABLE(sprintf("%stheme/%s/theme.php", PATH, SQL_ESCAPE($_POST['theme'])))) {
                        // Set cookie from posted data
-                       set_session("mxchange_theme", SQL_ESCAPE($_POST['theme']));
+                       set_session('mxchange_theme', SQL_ESCAPE($_POST['theme']));
                }
 
                // Set return value
                $ret = get_session('mxchange_theme');
        } else {
                // Invalid design, reset cookie
-               set_session("mxchange_theme", $ret);
+               set_session('mxchange_theme', $ret);
        }
 
        // Add (maybe) found theme.php file to inclusion list
@@ -3012,10 +3021,29 @@ function READ_FILE ($FQFN, $sqlPrepare = false) {
        return $content;
 }
 
+// Generates an error code from given account status
+function GEN_ERROR_CODE_FROM_ACCOUNT_STATUS ($status) {
+       // Default error code if unknown account status
+       $ERROR = CODE_UNKNOWN_STATUS;
+
+       // Generate constant name
+       $constantName = sprintf("CODE_ID_%s", $status);
+
+       // Is the constant there?
+       if (defined($constantName)) {
+               // Then get it!
+               $ERROR = constant($constantName);
+       } else {
+               // Unknown status
+               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown error status %s detected.", $status));
+       }
+
+       // Return error code
+       return $ERROR;
+}
+
 //////////////////////////////////////////////////
-//                                              //
 // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
-//                                              //
 //////////////////////////////////////////////////
 //
 if (!function_exists('html_entity_decode')) {
@@ -3027,5 +3055,5 @@ if (!function_exists('html_entity_decode')) {
        }
 } // END - if
 
-//
+// [EOF]
 ?>