]> git.mxchange.org Git - mailer.git/commitdiff
Fix for wrong SERVER_NAME usage (may cause trouble)
authorRoland Häder <roland@mxchange.org>
Sat, 3 Nov 2012 21:26:44 +0000 (21:26 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 3 Nov 2012 21:26:44 +0000 (21:26 +0000)
inc/filter-functions.php
inc/filters.php
inc/mysql-connect.php
inc/sql-functions.php
mailid.php

index accd0c9475fa66feb6446ac8ea3ad754267a4e92..4670227106b753a503fe432e7949f65c1f3f624f 100644 (file)
@@ -119,6 +119,7 @@ ORDER BY
        registerFilter(__FUNCTION__, __LINE__, 'init', 'COUNT_MODULE');
        registerFilter(__FUNCTION__, __LINE__, 'init', 'UPDATE_LOGIN_DATA');
        registerFilter(__FUNCTION__, __LINE__, 'init', 'ACTIVATE_EXCHANGE');
+       registerFilter(__FUNCTION__, __LINE__, 'init', 'REDIRECT_WRONG_SERVER_NAME');
 
        // Page headers - pre-filter (normally, you want to register here)
        registerFilter(__FUNCTION__, __LINE__, 'pre_page_header', 'LOAD_PAGE_HEADER');
index a4adfd44d64b46814d4b826f9896ab43d131a060..ecfa95f2698085585572c575bb5853e39f468f35 100644 (file)
@@ -1316,5 +1316,17 @@ function FILTER_HANDLE_REFERRER_BANNER_VIEW ($filterData) {
        }
 }
 
+// Filter for redirecting on wrong server name (e.g. bad.your-server.tld will be redirected to your-server.tld)
+function FILTER_REDIRECT_WRONG_SERVER_NAME ($filterData) {
+       // Is the configured URL same as SERVER_NAME?
+       if (extractHostnameFromUrl(getUrl()) != detectServerName()) {
+               // Then redirect to configured URL
+               redirectToRequestUri();
+       } // END - if
+
+       // Return filter data
+       return $filterData;
+}
+
 // [EOF]
 ?>
index df7a3d17513adc11a84cac77023f2be3aab56025..77eb4bb074d33739ebbd9d06ebbffb458c45abcc 100644 (file)
@@ -109,37 +109,8 @@ if ((!isInstalling()) && (!isInstallationPhase())) {
        // CSS array
        initExtensionCssFiles();
 
-       if ((!empty($GLOBALS['mysql']['host'])) && (!empty($GLOBALS['mysql']['login'])) && (!empty($GLOBALS['mysql']['dbase']))) {
-               // Connect to DB
-               SQL_CONNECT($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FILE__, __LINE__);
-
-               // Is the link valid?
-               if (SQL_IS_LINK_UP()) {
-                       // Enable exit on error
-                       enableExitOnError();
-
-                       // Is it a valid resource?
-                       if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FILE__, __LINE__) === TRUE) {
-                               // Set database name (required for ext-optimize and ifSqlTableExists())
-                               setConfigEntry('__DB_NAME', $GLOBALS['mysql']['dbase']);
-
-                               // Remove MySQL array from namespace
-                               unset($GLOBALS['mysql']);
-
-                               // Load cache
-                               loadIncludeOnce('inc/load_cache.php');
-                       } else {
-                               // Wrong database?
-                               reportBug(__FILE__, __LINE__, 'Wrong database selected.');
-                       }
-               } else {
-                       // No link to database!
-                       reportBug(__FILE__, __LINE__, 'Database link is not yet up.');
-               }
-       } else {
-               // Maybe you forgot to enter your database login?
-               reportBug(__FILE__, __LINE__, 'Database login is missing.');
-       }
+       // Initialize SQL link
+       initSqlLink();
 } else {
        // Default output is 'direct' for HTML output
        setConfigEntry('OUTPUT_MODE', 'direct');
index 069f459d93a35b471a06883d80301c91d8799433..c1840fa1bcb278ccfeabe081afc20c7b6600bdbe 100644 (file)
@@ -218,5 +218,47 @@ function getInsertSqlFromArray ($array, $tableName) {
        return $SQL;
 }
 
+// Initializes the SQL link by bringing it up if set
+function initSqlLink () {
+       // Do this only if link is down
+       assert(!SQL_IS_LINK_UP());
+
+       // Is the configuration data set?
+       if ((!empty($GLOBALS['mysql']['host'])) && (!empty($GLOBALS['mysql']['login'])) && (!empty($GLOBALS['mysql']['dbase']))) {
+               // Remove cache
+               unset($GLOBALS['is_sql_link_up']);
+
+               // Connect to DB
+               SQL_CONNECT($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FILE__, __LINE__);
+
+               // Is the link valid?
+               if (SQL_IS_LINK_UP()) {
+                       // Enable exit on error
+                       enableExitOnError();
+
+                       // Is it a valid resource?
+                       if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FILE__, __LINE__) === TRUE) {
+                               // Set database name (required for ext-optimize and ifSqlTableExists())
+                               setConfigEntry('__DB_NAME', $GLOBALS['mysql']['dbase']);
+
+                               // Remove MySQL array from namespace
+                               unset($GLOBALS['mysql']);
+
+                               // Load cache
+                               loadIncludeOnce('inc/load_cache.php');
+                       } else {
+                               // Wrong database?
+                               reportBug(__FILE__, __LINE__, 'Wrong database selected.');
+                       }
+               } else {
+                       // No link to database!
+                       reportBug(__FILE__, __LINE__, 'Database link is not yet up.');
+               }
+       } else {
+               // Maybe you forgot to enter your database login?
+               reportBug(__FILE__, __LINE__, 'Database login is missing.');
+       }
+}
+
 // [EOF]
 ?>
index 289ac310cd4a701d728f6993b57a358078e3b5fa..784bd996b49db5865795141ca965b4790f135633 100644 (file)
@@ -183,7 +183,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr
                                        if ($isValid === TRUE) {
                                                // If time is zero seconds we have a sponsor mail. 1 Second shall be set to avoid problems
                                                if (($time == '0') && ($payment > 0)) { 
-                                                       $url = getUrl();
+                                                       $url  = getUrl();
                                                        $time = 1; 
                                                } // END - if