Skip to content

Commit b8df094

Browse files
authored
Merge pull request #10 from wirecli/fix-config
Fix config
2 parents 35a0998 + d250942 commit b8df094

File tree

4 files changed

+62
-25
lines changed

4 files changed

+62
-25
lines changed

.github/workflows/releases.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,14 @@ jobs:
2222
run: npm run release --ci
2323
env:
2424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Generate Contributors Images
26+
uses: jaywcjlove/github-action-contributors@main
27+
id: contributors
28+
with:
29+
filter-author: (renovate\[bot\]|renovate-bot|dependabot\[bot\])
30+
avatarSize: 32
31+
- name: Modify README.md
32+
uses: jaywcjlove/github-action-modify-file-content@main
33+
with:
34+
path: README.md
35+
body: '${{steps.contributors.outputs.htmlList}}'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ phpunit.xml
1414
ProcessWire
1515
Tests/processwire.zip
1616

17+
Tests/pw

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ https://processwire.com/talk/topic/28788-wire-cli-a-cli-tool-for-processwire-dev
4747

4848
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please submit an issue or a pull request on the [GitHub repository](https://github.com/wirecli/wire-cli).
4949

50+
## Contributors
51+
52+
As always, thanks to all the contributors!
53+
54+
<!--GAMFC--><!--GAMFC-END-->
55+
56+
5057
## Available commands
5158

5259
![Commands preview](https://github.com/wirecli/wire-cli/blob/main/docs/assets/capture-cmd.jpg)

src/Helpers/Installer.php

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Installer {
5050
* Minimum required PHP version to install ProcessWire
5151
*
5252
*/
53-
const MIN_REQUIRED_PHP_VERSION = '7.4.0';
53+
const MIN_REQUIRED_PHP_VERSION = '5.3.8';
5454

5555
/**
5656
* Test mode for installer development, non destructive
@@ -62,7 +62,7 @@ class Installer {
6262
* Default site profile
6363
*
6464
*/
65-
const PROFILE_DEFAULT = 'site-default';
65+
const PROFILE_DEFAULT = 'site-blank';
6666

6767
/**
6868
* File permissions, determined in the dbConfig function
@@ -79,15 +79,6 @@ class Installer {
7979
*/
8080
protected $numErrors = 0;
8181

82-
/**
83-
* Available color themes
84-
*
85-
*/
86-
protected $colors = array(
87-
'classic',
88-
'warm'
89-
);
90-
9182
/**
9283
* @param LoggerInterface $log
9384
*/
@@ -354,7 +345,17 @@ public function checkDatabaseConnection($values, $out = true) {
354345
* @param array $values
355346
*/
356347
protected function dbSaveConfigFile(array $values) {
357-
$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+
}
358359

359360
$cfg = "\n/**" .
360361
"\n * Installer: Database Configuration" .
@@ -366,14 +367,27 @@ protected function dbSaveConfigFile(array $values) {
366367
"\n\$config->dbPass = '$values[dbPass]';" .
367368
"\n\$config->dbPort = '$values[dbPort]';" .
368369
"\n" .
369-
"\n/**" .
370-
"\n * Installer: User Authentication Salt " .
371-
"\n * " .
372-
"\n * Must be retained if you migrate your site from one server to another" .
373-
"\n * " .
374-
"\n */" .
375-
"\n\$config->userAuthSalt = '$salt'; " .
376-
"\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" .
377391
"\n/**" .
378392
"\n * Installer: File Permission Configuration" .
379393
"\n * " .
@@ -392,6 +406,15 @@ protected function dbSaveConfigFile(array $values) {
392406
"\n *" .
393407
"\n */".
394408
"\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() . ";" .
395418
"\n\n";
396419

397420
if (!empty($values['httpHosts'])) {
@@ -611,14 +634,9 @@ protected function adminAccountSave($accountInfo) {
611634
$adminName = htmlentities($adminName, ENT_QUOTES, "UTF-8");
612635

613636
if ($this->v) $this->log->info("User account saved: <b>{$user->name}</b>");
614-
615-
$colors = $wire->sanitizer->pageName($accountInfo['colors']);
616-
if (!in_array($colors, $this->colors)) $colors = reset($this->colors);
617637
$theme = $wire->modules->getInstall('AdminThemeUikit');
618638
$configData = $wire->modules->getModuleConfigData('AdminThemeUikit');
619-
$configData['colors'] = $colors;
620639
$wire->modules->saveModuleConfigData('AdminThemeUikit', $configData);
621-
if ($this->v) $this->log->info("Saved admin color set <b>$colors</b> - you will see this when you login.");
622640

623641
if ($this->v) $this->log->info("It is recommended that you make <b>/site/config.php</b> non-writable, for security.");
624642

0 commit comments

Comments
 (0)