]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Does this fix the JS bug and header bug as well?
[mailer.git] / inc / functions.php
index 5692191704452f620a42d03ab5294cd50a9d96df..56d8a184117263c2e6c825eeaa467b27bc550bcb 100644 (file)
@@ -786,7 +786,11 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") {
                break;
 
        case "add-points":
-               $points         = bigintval($_POST['points']);
+               if (isset($_POST['points'])) {
+                       $points         = bigintval($_POST['points']);
+               } else {
+                       $points = __POINTS_VALUE;
+               }
                break;
 
        case "guest_request_confirm":
@@ -914,6 +918,12 @@ function LOAD_URL($URL, $addUrlData=true) {
        // Compile out URI codes
        $URL = COMPILE_CODE($URL);
 
+       // Get output buffer
+       $OUTPUT = ob_get_contents();
+
+       // Clear it
+       ob_end_clean();
+
        // Add some data to URL if cookies are not accepted
        if (((!defined('__COOKIES')) || (!__COOKIES)) && ($addUrlData)) $URL = ADD_URL_DATA($URL);
 
@@ -930,7 +940,7 @@ function LOAD_URL($URL, $addUrlData=true) {
        } else {
                // Output error message
                include(PATH."inc/header.php");
-               OUTPUT_HTML(LOAD_URL_ERROR_1.$URL.LOAD_URL_ERROR_2);
+               LOAD_TEMPLATE("redirect_url", false, str_replace("&", "&", $URL));
                include(PATH."inc/footer.php");
        }
        exit();
@@ -1212,9 +1222,15 @@ function GEN_RANDOM_CODE($length, $code, $uid, $DATA="")
        return $return;
 }
 // Does only allow numbers
-function bigintval($num)
+function bigintval($num, $castValue = true)
 {
-       $ret = (int) preg_replace("/[^0123456789]/", "", $num);
+       // Filter all numbers out
+       $ret = preg_replace("/[^0123456789]/", "", $num);
+
+       // Cast the value?
+       if ($castValue) $ret = (int) $ret;
+
+       // Return result
        return $ret;
 }
 // Insert the code in $img_code into jpeg or PNG image
@@ -1635,9 +1651,11 @@ function ADD_EMAIL_NAV($PAGES, $offset, $show_form, $colspan, $return=false) {
 }
 
 //
-function MXCHANGE_OPEN($script) {
+function MXCHANGE_OPEN ($script) {
+       //* DEBUG */ print("SCRIPT=".$script."<br />\n");
        // Compile the script name
        $script = COMPILE_CODE($script);
+       //* DEBUG */ print("SCRIPT=".$script."<br />\n");
 
        // Use default SERVER_URL by default... ;) So?
        $url = SERVER_URL;
@@ -1654,13 +1672,22 @@ function MXCHANGE_OPEN($script) {
        if (ereg("/", $host)) $host = substr($host, 0, strpos($host, "/"));
 
        // Generate relative URL
-       $script = substr($script, (strlen($url) + 7));
+       //* DEBUG */ print("SCRIPT=".$script."<br />\n");
+       if (substr(strtolower($script), 0, 7) == "http://") {
+               // But only if http:// is in front!
+               $script = substr($script, (strlen($url) + 7));
+       } elseif (substr(strtolower($script), 0, 8) == "https://") {
+               // Does this work?!
+               $script = substr($script, (strlen($url) + 8));
+       }
+
+       //* DEBUG */ print("SCRIPT=".$script."<br />\n");
        if (substr($script, 0, 1) == "/") $script = substr($script, 1);
 
        // Open connection
+       //* DEBUG */ die("SCRIPT=".$script."<br />\n");
        $fp = @fsockopen($host, 80, $errno, $errdesc, 30);
-       if (!$fp)
-       {
+       if (!$fp) {
                // Failed!
                return array("", "", "");
        }
@@ -1781,7 +1808,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 ((GET_EXT_VERSION("user") >= "0.3.3") && ($table == "user_data")) {
+       } elseif ((EXT_IS_ACTIVE("user", true)) && (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")) {
@@ -1796,7 +1823,7 @@ function CREATE_EMAIL_LINK($email, $table="admins") {
        return $EMAIL;
 }
 // Generate a hash for extra-security for all passwords
-function generateHash($plainText, $salt = "") {
+function generateHash ($plainText, $salt = "") {
        global $_CONFIG, $_SERVER;
 
        // Is the required extension "sql_patches" there?
@@ -1988,6 +2015,11 @@ function generatePassString($passHash) {
 
                //* DEBUG: */ die($passHash."<br>".$newHash." (".strlen($newHash).")");
                $ret = generateHash($newHash, $_CONFIG['master_salt']);
+       } else {
+               // Hash it simple
+               //* DEBUG: */ echo "--".$passHash."--<br />\n";
+               $ret = md5($passHash);
+               //* DEBUG: */ echo "++".$ret."++<br />\n";
        }
 
        // Return result