Captcha error if captcha not set in form def Closes #7
Dieser Commit ist enthalten in:
Ursprung
7a0bc2d4f3
Commit
a06a6050c4
2 geänderte Dateien mit 104 neuen und 78 gelöschten Zeilen
|
@ -8,10 +8,16 @@
|
|||
* modified and adapted to Contenido 4.8 under PHP 5.x by Murat Purc (2013-08-24)
|
||||
*/
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
$sFrontEndPath = cRegistry::getClientConfig(cRegistry::getClientId())['path']['frontend'] . 'securimage' . DIRECTORY_SEPARATOR;
|
||||
$captchaInstalled = false;
|
||||
if (is_readable($sFrontEndPath)) {
|
||||
require_once $sFrontEndPath . 'securimage.php';
|
||||
require_once $sFrontEndPath . 'CaptchaObject.php';
|
||||
require_once $sFrontEndPath . 'StorageAdapter/AdapterInterface.php';
|
||||
$captchaInstalled = true;
|
||||
}
|
||||
|
||||
class w3form
|
||||
{
|
||||
|
@ -19,10 +25,10 @@ class w3form
|
|||
private array $email = ['adresses' => '', 'from' => ['name' => '', 'email' => ''], 'message' => '', 'subject' => ''];
|
||||
private array $unraveled = [];
|
||||
private array $form = ['form' => '', 'answer' => '', 'colorError' => ''];
|
||||
private array $formField = [];
|
||||
|
||||
public function __construct()
|
||||
public function __construct(private bool $captchaInstalled)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function sendEmail(): bool
|
||||
|
@ -191,6 +197,7 @@ class w3form
|
|||
|
||||
switch ($attribute['type']) {
|
||||
case 'captcha':
|
||||
if ($this->captchaInstalled) {
|
||||
if ($sent) {
|
||||
$captcha = @$_POST['ct_captcha'];
|
||||
$capId = @$_POST['captcha_id'];
|
||||
|
@ -216,6 +223,7 @@ class w3form
|
|||
echo "<div id='captcha_container_1'>\n";
|
||||
echo Securimage::getCaptchaHtml($options);
|
||||
echo "\n</div>\n";
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
echo "<input type=\"text\" $parameter value=\"$value\" $style />";
|
||||
|
@ -296,10 +304,24 @@ class w3form
|
|||
$form = $this->form['form'];
|
||||
$fields = $this->formInterpretation($form);
|
||||
foreach ($fields as $field) {
|
||||
switch ($field['type']) {
|
||||
case 'captcha':
|
||||
if ($this->captchaInstalled) {
|
||||
$captcha = @$_POST['ct_captcha'];
|
||||
$capId = @$_POST['captcha_id'];
|
||||
$securimage = new Securimage();
|
||||
if (!$securimage->check($captcha, $capId, true)) {
|
||||
echo '<div style="color: red;">' . mi18n("Ihr Captcha Code war nicht korrekt. Bitte versuchen Sie es erneut.") . '</div>';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!$this->formFieldCorrect($field)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -405,16 +427,7 @@ class w3form
|
|||
if (!isset($_POST['sent'])) {
|
||||
$this->formOutput();
|
||||
} elseif ($this->formComplete()) {
|
||||
// check captcha
|
||||
$captcha = @$_POST['ct_captcha'];
|
||||
$capId = @$_POST['captcha_id'];
|
||||
$securimage = new Securimage();
|
||||
if (!$securimage->check($captcha, $capId, true)) {
|
||||
echo '<div style="color: red;">' . mi18n("Ihr Captcha Code war nicht korrekt. Bitte versuchen Sie es erneut.") . '</div>';
|
||||
$this->formOutput(true);
|
||||
} else {
|
||||
$this->success();
|
||||
}
|
||||
} else {
|
||||
$this->formOutput(true);
|
||||
}
|
||||
|
@ -429,7 +442,7 @@ if (isset($edit) && $edit) {
|
|||
echo "<p>" . mi18n("Hier ist die Ausgabe einzugeben, die erscheint, wenn das Formular erfolgreich prozessiert worden ist:") . "</p>";
|
||||
echo "CMS_HTML[1]";
|
||||
} else {
|
||||
$form = new w3form();
|
||||
$form = new w3form($captchaInstalled);
|
||||
$form->addEmailAdress("CMS_VALUE[0]");
|
||||
$form->setEmailSubject("CMS_VALUE[1]");
|
||||
$form->setEmailFrom("CMS_VALUE[2]", "CMS_VALUE[3]");
|
||||
|
|
|
@ -57,10 +57,16 @@ $oCfgTable->render(true);
|
|||
* modified and adapted to Contenido 4.8 under PHP 5.x by Murat Purc (2013-08-24)
|
||||
*/
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
$sFrontEndPath = cRegistry::getClientConfig(cRegistry::getClientId())['path']['frontend'] . 'securimage' . DIRECTORY_SEPARATOR;
|
||||
$captchaInstalled = false;
|
||||
if (is_readable($sFrontEndPath)) {
|
||||
require_once $sFrontEndPath . 'securimage.php';
|
||||
require_once $sFrontEndPath . 'CaptchaObject.php';
|
||||
require_once $sFrontEndPath . 'StorageAdapter/AdapterInterface.php';
|
||||
$captchaInstalled = true;
|
||||
}
|
||||
|
||||
class w3form
|
||||
{
|
||||
|
@ -68,10 +74,10 @@ class w3form
|
|||
private array $email = ['adresses' => '', 'from' => ['name' => '', 'email' => ''], 'message' => '', 'subject' => ''];
|
||||
private array $unraveled = [];
|
||||
private array $form = ['form' => '', 'answer' => '', 'colorError' => ''];
|
||||
private array $formField = [];
|
||||
|
||||
public function __construct()
|
||||
public function __construct(private bool $captchaInstalled)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function sendEmail(): bool
|
||||
|
@ -240,6 +246,7 @@ class w3form
|
|||
|
||||
switch ($attribute['type']) {
|
||||
case 'captcha':
|
||||
if ($this->captchaInstalled) {
|
||||
if ($sent) {
|
||||
$captcha = @$_POST['ct_captcha'];
|
||||
$capId = @$_POST['captcha_id'];
|
||||
|
@ -265,6 +272,7 @@ class w3form
|
|||
echo "<div id='captcha_container_1'>\n";
|
||||
echo Securimage::getCaptchaHtml($options);
|
||||
echo "\n</div>\n";
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
echo "<input type=\"text\" $parameter value=\"$value\" $style />";
|
||||
|
@ -345,10 +353,24 @@ class w3form
|
|||
$form = $this->form['form'];
|
||||
$fields = $this->formInterpretation($form);
|
||||
foreach ($fields as $field) {
|
||||
switch ($field['type']) {
|
||||
case 'captcha':
|
||||
if ($this->captchaInstalled) {
|
||||
$captcha = @$_POST['ct_captcha'];
|
||||
$capId = @$_POST['captcha_id'];
|
||||
$securimage = new Securimage();
|
||||
if (!$securimage->check($captcha, $capId, true)) {
|
||||
echo '<div style="color: red;">' . mi18n("Ihr Captcha Code war nicht korrekt. Bitte versuchen Sie es erneut.") . '</div>';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!$this->formFieldCorrect($field)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -454,16 +476,7 @@ class w3form
|
|||
if (!isset($_POST['sent'])) {
|
||||
$this->formOutput();
|
||||
} elseif ($this->formComplete()) {
|
||||
// check captcha
|
||||
$captcha = @$_POST['ct_captcha'];
|
||||
$capId = @$_POST['captcha_id'];
|
||||
$securimage = new Securimage();
|
||||
if (!$securimage->check($captcha, $capId, true)) {
|
||||
echo '<div style="color: red;">' . mi18n("Ihr Captcha Code war nicht korrekt. Bitte versuchen Sie es erneut.") . '</div>';
|
||||
$this->formOutput(true);
|
||||
} else {
|
||||
$this->success();
|
||||
}
|
||||
} else {
|
||||
$this->formOutput(true);
|
||||
}
|
||||
|
@ -478,7 +491,7 @@ if (isset($edit) && $edit) {
|
|||
echo "<p>" . mi18n("Hier ist die Ausgabe einzugeben, die erscheint, wenn das Formular erfolgreich prozessiert worden ist:") . "</p>";
|
||||
echo "CMS_HTML[1]";
|
||||
} else {
|
||||
$form = new w3form();
|
||||
$form = new w3form($captchaInstalled);
|
||||
$form->addEmailAdress("CMS_VALUE[0]");
|
||||
$form->setEmailSubject("CMS_VALUE[1]");
|
||||
$form->setEmailFrom("CMS_VALUE[2]", "CMS_VALUE[3]");
|
||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren