Skip to content

Commit d250942

Browse files
committed
fix(config): Added missing installed, authSalt and tableSalt config #9
1 parent 9a1339a commit d250942

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

src/Helpers/Installer.php

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,17 @@ public function checkDatabaseConnection($values, $out = true) {
345345
* @param array $values
346346
*/
347347
protected function dbSaveConfigFile(array $values) {
348-
$salt = md5(mt_rand() . microtime(true));
348+
$file = __FILE__;
349+
$time = time();
350+
$host = empty($values['httpHosts']) ? '' : implode(',', $values['httpHosts']);
351+
352+
if(function_exists('random_bytes')) {
353+
$authSalt = sha1(random_bytes(random_int(40, 128)));
354+
$tableSalt = sha1(random_int(0, 65535) . "$host$file$time");
355+
} else {
356+
$authSalt = md5(mt_rand() . microtime(true));
357+
$tableSalt = md5(mt_rand() . "$host$file$time");
358+
}
349359

350360
$cfg = "\n/**" .
351361
"\n * Installer: Database Configuration" .
@@ -357,14 +367,27 @@ protected function dbSaveConfigFile(array $values) {
357367
"\n\$config->dbPass = '$values[dbPass]';" .
358368
"\n\$config->dbPort = '$values[dbPort]';" .
359369
"\n" .
360-
"\n/**" .
361-
"\n * Installer: User Authentication Salt " .
362-
"\n * " .
363-
"\n * Must be retained if you migrate your site from one server to another" .
364-
"\n * " .
365-
"\n */" .
366-
"\n\$config->userAuthSalt = '$salt'; " .
367-
"\n" .
370+
"\n/**" .
371+
"\n * Installer: User Authentication Salt " .
372+
"\n * " .
373+
"\n * This value was randomly generated for your system on " . date('Y/m/d') . "." .
374+
"\n * This should be kept as private as a password and never stored in the database." .
375+
"\n * Must be retained if you migrate your site from one server to another." .
376+
"\n * Do not change this value, or user passwords will no longer work." .
377+
"\n * " .
378+
"\n */" .
379+
"\n\$config->userAuthSalt = '$authSalt'; " .
380+
"\n" .
381+
"\n/**" .
382+
"\n * Installer: Table Salt (General Purpose) " .
383+
"\n * " .
384+
"\n * Use this rather than userAuthSalt when a hashing salt is needed for non user " .
385+
"\n * authentication purposes. Like with userAuthSalt, you should never change " .
386+
"\n * this value or it may break internal system comparisons that use it. " .
387+
"\n * " .
388+
"\n */" .
389+
"\n\$config->tableSalt = '$tableSalt'; " .
390+
"\n" .
368391
"\n/**" .
369392
"\n * Installer: File Permission Configuration" .
370393
"\n * " .
@@ -383,6 +406,15 @@ protected function dbSaveConfigFile(array $values) {
383406
"\n *" .
384407
"\n */".
385408
"\n\$config->defaultAdminTheme = 'AdminThemeUikit';" .
409+
"\n" .
410+
"\n/**" .
411+
"\n * Installer: Unix timestamp of date/time installed" .
412+
"\n * " .
413+
"\n * This is used to detect which when certain behaviors must be backwards compatible." .
414+
"\n * Please leave this value as-is." .
415+
"\n * " .
416+
"\n */" .
417+
"\n\$config->installed = " . time() . ";" .
386418
"\n\n";
387419

388420
if (!empty($values['httpHosts'])) {

0 commit comments

Comments
 (0)