Skip to content

Commit 6e07717

Browse files
nicoSWDkelunik
authored andcommitted
Fix anti-spam plugin
1 parent 779448f commit 6e07717

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

dokuwiki/lib/plugins/phpreg/action.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
*/
99

1010
// must be run within Dokuwiki
11+
use dokuwiki\Form\InputElement;
12+
1113
if(!defined('DOKU_INC')) die();
1214

1315
/**
@@ -27,7 +29,7 @@ class action_plugin_phpreg extends DokuWiki_Action_Plugin
2729
public function register(Doku_Event_Handler $controller)
2830
{
2931
$controller->register_hook(
30-
'HTML_REGISTERFORM_OUTPUT',
32+
'FORM_REGISTER_OUTPUT',
3133
'BEFORE',
3234
$this,
3335
'handle_registerform_output'
@@ -52,15 +54,17 @@ public function register(Doku_Event_Handler $controller)
5254
*/
5355
public function handle_registerform_output(Doku_Event &$event, $param)
5456
{
55-
$pos = $event->data->findElementByAttribute('type', 'submit');
57+
$pos = $event->data->findPositionByType('button');
58+
5659
if (!$pos) return;
57-
$spam = isset($_POST['spam']) ? $_POST['spam'] : '';
58-
$out = form_makeTextField(
59-
'spam', $spam,
60-
'To which email address do you have to send an email to now?',
61-
'', 'block', array('size' => '50')
60+
$spam = $_POST['spam'] ?? '';
61+
$element = new InputElement(
62+
'text',
63+
'spam',
64+
'To which email address do you have to send an email to now?'
6265
);
63-
$event->data->insertElement($pos, $out);
66+
$element->val($spam);
67+
$event->data->addElement($element, $pos);
6468
}
6569

6670
/**

0 commit comments

Comments
 (0)