Skip to content

Commit

Permalink
aktiviertes Javascript überprüfen
Browse files Browse the repository at this point in the history
Vorbereitung für #12
  • Loading branch information
alxndr-w committed Feb 10, 2020
1 parent faa0d5b commit ccf3ee4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lib/yform/value/spam_protection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public function postValidateAction()
$debug = (int)$this->getElement(4);
$session_timestamp = rex_request::session('spamfilter');
$form_timestamp = rex_request($this->getFieldId()."_microtime", 'int', false);
$js_enabled = rex_request($this->getFieldId()."_js_enabled", 'int', false);

$ipv4 = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
$ipv6 = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
Expand All @@ -28,7 +29,7 @@ public function postValidateAction()
$log[] = "honeypot wurde ausgefüllt: ".rex_request($this->getFieldId());
}

if(rex_config::get('yform_spam_protection', 'ip_block_limit') > $count) {
if (rex_config::get('yform_spam_protection', 'ip_block_limit') > $count) {
rex_sql::factory()->setDebug($debug)->setQuery("INSERT INTO rex_tmp_yform_spam_protection_frequency (`ipv4`, `ipv6`, `createdate`, `was_blocked`) VALUES (INET_ATON(:ipv4), :ipv6, NOW(), 1)", [':ipv4'=>$ipv4, ':ipv6'=>$ipv6]);
$this->params['warning'][$this->getId()] = $this->params['error_class'];
$this->params['warning_messages'][$this->getId()] = $this->getElement(3);
Expand Down
35 changes: 24 additions & 11 deletions ytemplates/bootstrap/value.spam_protection.tpl.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
<div id="<?= $this->getHTMLId() ?>">
<label for="<?= $this->getFieldId() ?>"><?= $this->getLabel() ?></label>
<input id="<?= $this->getFieldId() ?>" name="<?= $this->getFieldId() ?>" type="email" autocomplete="off" tabindex="-1">
<input id="<?= $this->getFieldId() ?>_microtime" name="<?= $this->getFieldId() ?>_microtime" type="hidden" value="<?= microtime(true) ?>" readonly="readonly" tabindex="-1">
<style>
[id="<?=$this->getHTMLId() ?>"] {
overflow: hidden;
height: 1px;
opacity: 100%;
}
</style>
</div>
<label for="<?= $this->getFieldId() ?>"><?= $this->getLabel() ?></label>
<input id="<?= $this->getFieldId() ?>"
name="<?= $this->getFieldId() ?>" type="email"
autocomplete="off" tabindex="-1">
<input id="<?= $this->getFieldId() ?>_microtime"
name="<?= $this->getFieldId() ?>_microtime" type="hidden"
value="<?= microtime(true) ?>" readonly="readonly"
tabindex="-1">
<input id="<?= $this->getFieldId() ?>_js_enabled"
name="<?= $this->getFieldId() ?>_js_enabled" type="hidden"
value="0" readonly="readonly" tabindex="-1">
<style>
[id="<?=$this->getHTMLId() ?>"] {
overflow: hidden;
height: 1px;
opacity: 100%;
}
</style>
<script type="text/javascript">
var date = new Date();
document.getElementById("<?= $this->getFieldId() ?>_js_enabled").value =
date.getFullYear();
</script>
</div>

0 comments on commit ccf3ee4

Please sign in to comment.