-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
class rex_yform_compromised extends \rex_yform_validate_abstract | ||
{ | ||
public function enterObject() | ||
{ | ||
|
||
$Object = $this->getValueObject($this->getElement('name')); | ||
|
||
if (!$this->isObject($Object)) { | ||
return; | ||
} | ||
|
||
if ('' == $Object->getValue()) { | ||
return; | ||
} | ||
|
||
$partitalSHA256 = substr(hash('sha256', $Object->getValue()), 0, 10); | ||
|
||
$url = 'https://api.enzoic.com/v1/passwords'; | ||
$rex_socket = rex_socket::factoryUrl($url); | ||
$rex_socket->addBasicAuthorization(rex_config::get('yform_field', 'compromised_api_key'), rex_config::get('yform_field', 'compromised_api_secret')); | ||
$rex_socket_response = $rex_socket->doPost(['partialSHA256' => $partitalSHA256]); | ||
|
||
if (!$rex_socket_response->isOk()) { | ||
|
||
$body = $rex_socket_response->getBody(); | ||
$candidates = json_decode($body, true); | ||
if(!$candidates) { | ||
return; | ||
} | ||
|
||
if (isset($candidates['candidates'])) { | ||
foreach ($candidates['candidates'] as $candidate) { | ||
if ($candidate['sha256'] == hash('sha256', $Object->getValue())) { | ||
$Object->setValue(''); | ||
$this->params['warning'][$Object->getId()] = $this->params['error_class']; | ||
$this->params['warning_messages'][$Object->getId()] = $this->getElement('message'); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public function getDescription(): string | ||
{ | ||
return 'validate|password_compromised|passwordfieldname|warning_message'; | ||
} | ||
|
||
public function getDefinitions(): array | ||
{ | ||
return [ | ||
'type' => 'validate', | ||
'name' => 'password_compromised', | ||
'values' => [ | ||
'name' => ['type' => 'select_name', 'label' => rex_i18n::msg('yform_validate_password_compromised_name')], | ||
'message' => ['type' => 'text', 'label' => rex_i18n::msg('yform_validate_password_compromised_message')], | ||
], | ||
'description' => rex_i18n::msg('yform_validate_password_compromised_description'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
class rex_yform_value_be_media_preview extends rex_yform_value_be_media | ||
{ | ||
public function getDefinitions(): array | ||
{ | ||
return [ | ||
'type' => 'value', | ||
'name' => 'be_media_preview', | ||
'values' => [ | ||
'name' => ['type' => 'name', 'label' => rex_i18n::msg('yform_values_defaults_name')], | ||
'label' => ['type' => 'text', 'label' => rex_i18n::msg('yform_values_defaults_label')], | ||
'preview' => ['type' => 'checkbox', 'label' => rex_i18n::msg('yform_values_be_media_preview')], | ||
'multiple' => ['type' => 'checkbox', 'label' => rex_i18n::msg('yform_values_be_media_multiple')], | ||
'category' => ['type' => 'text', 'label' => rex_i18n::msg('yform_values_be_media_category')], | ||
'types' => ['type' => 'text', 'label' => rex_i18n::msg('yform_values_be_media_types'), 'notice' => rex_i18n::msg('yform_values_be_media_types_notice')], | ||
'notice' => ['type' => 'text', 'label' => rex_i18n::msg('yform_values_defaults_notice')], | ||
], | ||
'description' => rex_i18n::msg('yform_values_be_media_preview_description'), | ||
'formbuilder' => false, | ||
'db_type' => ['text'], | ||
]; | ||
} | ||
|
||
public static function getListValue($params) | ||
{ | ||
$files = explode(',', $params['subject']); | ||
|
||
$return = []; | ||
foreach ($files as $file) { | ||
if (rex_media::get($file)) { | ||
$return[] = '<img style="width: 40px;" src="' . rex_media_manager::getUrl('rex_media_small', $files[0]) . '">'; | ||
} | ||
} | ||
|
||
return implode('<br />', $return); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/** | ||
* @var rex_addon $this | ||
* @psalm-scope-this rex_addon | ||
*/ | ||
|
||
$page = rex_be_controller::getPageObject('yform/yform_field_docs'); | ||
|
||
echo rex_view::title($this->i18n('product_title')); | ||
|
||
[$Toc, $Content] = rex_markdown::factory()->parseWithToc(rex_file::get(rex_path::addon('yform_field', 'README.md')), 2, 3, [ | ||
rex_markdown::SOFT_LINE_BREAKS => false, | ||
rex_markdown::HIGHLIGHT_PHP => true, | ||
]); | ||
|
||
$fragment = new rex_fragment(); | ||
$fragment->setVar('content', $Content, false); | ||
$fragment->setVar('toc', $Toc, false); | ||
$content = $fragment->parse('core/page/docs.php'); | ||
|
||
$fragment = new rex_fragment(); | ||
$fragment->setVar('title', rex_i18n::msg('package_help') . ' YForm Field', false); | ||
$fragment->setVar('body', $content, false); | ||
echo $fragment->parse('core/page/section.php'); |