Fix for installation phase (thx to AndreasJung)
[mailer.git] / inc / mysql-connect.php
index f7df593665497ee16ef9bcc6165b1f1240f45c26..ccbc5ac41e17031e8746011d39d330fb0d953b75 100644 (file)
@@ -180,11 +180,17 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
                                // Shall we activate the exchange?
                                if ($_CONFIG['activate_xchange'] > 0) activateExchange();
 
-                               // Generate random number
-                               if (isset($GLOBALS['userid'])) {
-                                       define('RAND_NUMBER', GEN_RANDOM_CODE(10, mt_rand(10000,32766), $GLOBALS['userid'], ""));
+                               // Is the extension sql_patches installed and at least 0.3.6?
+                               if (GET_EXT_VERSION("sql_patches") >= "0.3.6") {
+                                       // 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 {
-                                       define('RAND_NUMBER', GEN_RANDOM_CODE(10, mt_rand(10000,32766), 0, ""));
+                                       // Generate weak (!!!) code
+                                       define('RAND_NUMBER', mt_rand(1000000, 9999999));
                                }
                        } else {
                                // Wrong database?