Skip to content

Commit

Permalink
Apply php-cs-fixer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndr-w authored and github-actions[bot] committed Feb 18, 2024
1 parent fbb4263 commit f26f5c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
8 changes: 4 additions & 4 deletions fragments/choice_status_select.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
data-id="<?= $data_id ?>" class="form-control btn btn-sm btn-default dropdown-toggle"
data-status="choice_status_select" style="width: auto;">
<?php foreach ($options as $value => $option) {
?>
?>
<option value="<?= $value ?>" <?php if ($value == $selected) {
echo 'selected';
} ?>><?= $option ?></option>
echo 'selected';
} ?>><?= $option ?></option>
<?php
} // foreach $options
} // foreach $options
?>
</select>
18 changes: 8 additions & 10 deletions lib/yform/validate/pwned.php
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
<?php

class rex_yform_validate_pwned extends \rex_yform_validate_abstract
class rex_yform_validate_pwned extends rex_yform_validate_abstract
{
public function enterObject()
{

$PasswordObject = $this->getValueObject();

if (!$this->isObject($PasswordObject)) {
return;
}

if ('' == $PasswordObject->getValue()) {
return;
}

$password = $PasswordObject->getValue();
$hash = strtoupper(sha1($password));
$range = substr($hash, 0, 5);
$suffix = substr($hash, 5);

$url = "https://api.pwnedpasswords.com/range/$range";
$rex_socket = rex_socket::factoryUrl($url);
$rex_socket_response = $rex_socket->doGet();

if (!$rex_socket_response->isOk()) {
rex_logger::logError(E_WARNING, "Failed to connect to pwnedpasswords.com", "", 0);
rex_logger::logError(E_WARNING, 'Failed to connect to pwnedpasswords.com', '', 0);
return;
}

$output = $rex_socket_response->getBody();
$lines = explode("\n", $output);
foreach ($lines as $line) {
list($hashSuffix, $count) = explode(":", $line);
[$hashSuffix, $count] = explode(':', $line);
if (trim($hashSuffix) == $suffix) {
$PasswordObject->setValue('');
$this->params['warning'][$PasswordObject->getId()] = $this->params['error_class'];
$this->params['warning_messages'][$PasswordObject->getId()] = $this->getElement('message');
return;
}
}
return;
}

public function getDescription(): string
Expand Down

0 comments on commit f26f5c1

Please sign in to comment.