Random code generation added. This can be used for so-called cash-buster codes in...
[mailer.git] / inc / mysql-connect.php
index 813bcb6..cdde847 100644 (file)
@@ -48,6 +48,9 @@ require_once(PATH."inc/functions.php");  // Non-database functions
 require_once(PATH."inc/extensions.php");
 require_once(PATH."inc/language.php");
 
+// Load "databases" aka static arrays
+require_once(PATH."inc/databases.php");     // Several hard-coded databases (arrays, constants)
+
 // Check if the user setups his MySQL stuff...
 if ((empty($MySQL['login'])) && (!isBooleanConstantAndTrue('mxchange_installing')) && (!isset($_GET['installing'])) && (isBooleanConstantAndTrue('mxchange_installed'))) {
        // No login entered and outside installation mode
@@ -79,9 +82,6 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
        }
        $EXT_CSS_FILES = array();
 
-       // Load "databases" aka static arrays
-       require_once(PATH."inc/databases.php");     // Several hard-coded databases (arrays, constants)
-
        if ((!empty($MySQL['host'])) && (!empty($MySQL['login'])) && (!empty($MySQL['password'])) && (!empty($MySQL['dbase']))) {
                // Connect to DB
                global $link;
@@ -205,6 +205,13 @@ LIMIT 1", __FILE__, __LINE__);
 
                                // Free memory
                                SQL_FREERESULT($result);
+
+                               // Generate random number
+                               if (isset($GLOBALS['userid'])) {
+                                       define('RAND_NUMBER', GEN_RANDOM_CODE(10, mt_rand(10000,32766), $GLOBALS['userid'], ""));
+                               } else {
+                                       define('RAND_NUMBER', GEN_RANDOM_CODE(10, mt_rand(10000,32766), 0, ""));
+                               }
                        } else {
                                // Wrong database?
                                ADD_FATAL(WRONG_DB_SELECTED);