Skip to content

Commit

Permalink
Various minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancramerdesign committed Jul 24, 2020
1 parent ecb58f9 commit 380583a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
37 changes: 30 additions & 7 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -786,11 +786,22 @@ protected function dbCreateDatabase($dsn, $values, $driver_options) {
*/
protected function dbSaveConfigFile(array $values) {

if(self::TEST_MODE) return true;

$salt = md5(mt_rand() . microtime(true));
if(self::TEST_MODE) return true;

$file = __FILE__;
$time = time();
$host = empty($values['httpHosts']) ? '' : implode(',', $values['httpHosts']);

$cfg = "\n/**" .
if(function_exists('random_bytes')) {
$authSalt = sha1(random_bytes(random_int(40, 128)));
$tableSalt = sha1(random_int(0, 65535) . "$host$file$time");
} else {
$authSalt = md5(mt_rand() . microtime(true));
$tableSalt = md5(mt_rand() . "$host$file$time");
}

$cfg =
"\n/**" .
"\n * Installer: Database Configuration" .
"\n * " .
"\n */" .
Expand All @@ -807,11 +818,23 @@ protected function dbSaveConfigFile(array $values) {
"\n" .
"\n/**" .
"\n * Installer: User Authentication Salt " .
"\n * " .
"\n * This value was randomly generated for your system on " . date('Y/m/d') . "." .
"\n * This should be kept as private as a password and never stored in the database." .
"\n * Must be retained if you migrate your site from one server to another." .
"\n * Do not change this value, or user passwords will no longer work." .
"\n * " .
"\n * Must be retained if you migrate your site from one server to another" .
"\n * " .
"\n */" .
"\n\$config->userAuthSalt = '$salt'; " .
"\n\$config->userAuthSalt = '$authSalt'; " .
"\n" .
"\n * Installer: Table Salt (General Purpose) " .
"\n * " .
"\n * Use this rather than userAuthSalt when a hashing salt is needed for non user " .
"\n * authentication purposes. Like with userAuthSalt, you should never change " .
"\n * this value or it may break internal system comparisons that use it. " .
"\n * " .
"\n */" .
"\n\$config->tableSalt = '$tableSalt'; " .
"\n" .
"\n/**" .
"\n * Installer: File Permission Configuration" .
Expand Down
9 changes: 5 additions & 4 deletions wire/core/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,8 @@ public function ___getMarkup($key) {
/**
* Same as getMarkup() except returned value is plain text
*
* Returned value is entity encoded, unless $entities argument is false.
* If no `$entities` argument is provided, returned value is entity encoded when output formatting
* is on, and not entity encoded when output formatting is off.
*
* #pw-advanced
*
Expand All @@ -1769,12 +1770,12 @@ public function getText($key, $oneLine = false, $entities = null) {
$length = strlen($value);
if(!$length) return '';
$options = array(
'entities' => (is_null($entities) ? $this->outputFormatting() : (bool) $entities)
'entities' => ($entities === null ? $this->outputFormatting() : (bool) $entities)
);
if($oneLine) {
$value = $this->wire('sanitizer')->markupToLine($value, $options);
$value = $this->wire()->sanitizer->markupToLine($value, $options);
} else {
$value = $this->wire('sanitizer')->markupToText($value, $options);
$value = $this->wire()->sanitizer->markupToText($value, $options);
}
// if stripping tags from non-empty value made it empty, just indicate that it was markup and length
if(!strlen(trim($value))) $value = "markup($length)";
Expand Down
2 changes: 1 addition & 1 deletion wire/core/Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ public function markupToText($value, array $options = array()) {
}

// remove entities
$value = $this->wire('sanitizer')->unentities($value);
$value = $this->unentities($value);

if(strpos($value, '<') !== false) {
// tag replacements before strip_tags()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {

$wrap = $this->wire('modules')->get('InputfieldFieldset');
$wrap->addClass('InputfieldRepeaterItem InputfieldNoFocus');
$wrap->entityEncodeLabel = false;
if(!$isPost) {
$wrap->entityEncodeLabel = false;
$wrap->label =
"<span class='InputfieldRepeaterItemLabel'>" .
$this->entityEncode($this->renderRepeaterLabel($label, ++$cnt, $page)) .
Expand Down
7 changes: 6 additions & 1 deletion wire/modules/LanguageSupport/LanguageSupport.module
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {

/** @var Inputfield $inputfield */
$inputfield = $event->object;
$user = $this->wire('user');
if(!$inputfield->useLanguages) return;

$user = $this->wire()->user;
$userLanguage = $user->language;
if(!$userLanguage) return;

Expand Down Expand Up @@ -619,6 +621,9 @@ class LanguageSupport extends WireData implements Module, ConfigurableModule {
}
$inputfield->set('value' . $language->id, $languageValue);
}

// following this hookInputfieldBeforeRender() completes the process after
// Fieldgroup::getPageInputfields() which sets the value attribute of Inputfields
}

$event->return = $inputfield;
Expand Down

0 comments on commit 380583a

Please sign in to comment.