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)
|
* 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;
|
$sFrontEndPath = cRegistry::getClientConfig(cRegistry::getClientId())['path']['frontend'] . 'securimage' . DIRECTORY_SEPARATOR;
|
||||||
require_once $sFrontEndPath . 'securimage.php';
|
$captchaInstalled = false;
|
||||||
require_once $sFrontEndPath . 'CaptchaObject.php';
|
if (is_readable($sFrontEndPath)) {
|
||||||
require_once $sFrontEndPath . 'StorageAdapter/AdapterInterface.php';
|
require_once $sFrontEndPath . 'securimage.php';
|
||||||
|
require_once $sFrontEndPath . 'CaptchaObject.php';
|
||||||
|
require_once $sFrontEndPath . 'StorageAdapter/AdapterInterface.php';
|
||||||
|
$captchaInstalled = true;
|
||||||
|
}
|
||||||
|
|
||||||
class w3form
|
class w3form
|
||||||
{
|
{
|
||||||
|
@ -19,10 +25,10 @@ class w3form
|
||||||
private array $email = ['adresses' => '', 'from' => ['name' => '', 'email' => ''], 'message' => '', 'subject' => ''];
|
private array $email = ['adresses' => '', 'from' => ['name' => '', 'email' => ''], 'message' => '', 'subject' => ''];
|
||||||
private array $unraveled = [];
|
private array $unraveled = [];
|
||||||
private array $form = ['form' => '', 'answer' => '', 'colorError' => ''];
|
private array $form = ['form' => '', 'answer' => '', 'colorError' => ''];
|
||||||
private array $formField = [];
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct(private bool $captchaInstalled)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sendEmail(): bool
|
private function sendEmail(): bool
|
||||||
|
@ -191,31 +197,33 @@ class w3form
|
||||||
|
|
||||||
switch ($attribute['type']) {
|
switch ($attribute['type']) {
|
||||||
case 'captcha':
|
case 'captcha':
|
||||||
if ($sent) {
|
if ($this->captchaInstalled) {
|
||||||
$captcha = @$_POST['ct_captcha'];
|
if ($sent) {
|
||||||
$capId = @$_POST['captcha_id'];
|
$captcha = @$_POST['ct_captcha'];
|
||||||
$securimage = new Securimage();
|
$capId = @$_POST['captcha_id'];
|
||||||
|
$securimage = new Securimage();
|
||||||
|
|
||||||
if (!$securimage->check($captcha)) {
|
if (!$securimage->check($captcha)) {
|
||||||
echo '<style>'
|
echo '<style>'
|
||||||
. '#captcha_code {background-color: ' . $this->form['colorError'] . '}'
|
. '#captcha_code {background-color: ' . $this->form['colorError'] . '}'
|
||||||
. '</style>';
|
. '</style>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// show captcha HTML using Securimage::getCaptchaHtml()
|
||||||
// show captcha HTML using Securimage::getCaptchaHtml()
|
$options = [];
|
||||||
$options = [];
|
$options['input_name'] = 'ct_captcha'; // change name of input element for form post input_text
|
||||||
$options['input_name'] = 'ct_captcha'; // change name of input element for form post input_text
|
$options['input_text'] = mi18n("Zeichen eingeben");
|
||||||
$options['input_text'] = mi18n("Zeichen eingeben");
|
$options['input_required'] = false;
|
||||||
$options['input_required'] = false;
|
|
||||||
|
|
||||||
if (!empty($_SESSION['ctform']['captcha_error'])) {
|
if (!empty($_SESSION['ctform']['captcha_error'])) {
|
||||||
// error html to show in captcha output
|
// error html to show in captcha output
|
||||||
$options['error_html'] = $_SESSION['ctform']['captcha_error'];
|
$options['error_html'] = $_SESSION['ctform']['captcha_error'];
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<div id='captcha_container_1'>\n";
|
echo "<div id='captcha_container_1'>\n";
|
||||||
echo Securimage::getCaptchaHtml($options);
|
echo Securimage::getCaptchaHtml($options);
|
||||||
echo "\n</div>\n";
|
echo "\n</div>\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
echo "<input type=\"text\" $parameter value=\"$value\" $style />";
|
echo "<input type=\"text\" $parameter value=\"$value\" $style />";
|
||||||
|
@ -296,8 +304,22 @@ class w3form
|
||||||
$form = $this->form['form'];
|
$form = $this->form['form'];
|
||||||
$fields = $this->formInterpretation($form);
|
$fields = $this->formInterpretation($form);
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if (!$this->formFieldCorrect($field)) {
|
switch ($field['type']) {
|
||||||
return false;
|
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;
|
return true;
|
||||||
|
@ -405,16 +427,7 @@ class w3form
|
||||||
if (!isset($_POST['sent'])) {
|
if (!isset($_POST['sent'])) {
|
||||||
$this->formOutput();
|
$this->formOutput();
|
||||||
} elseif ($this->formComplete()) {
|
} elseif ($this->formComplete()) {
|
||||||
// check captcha
|
$this->success();
|
||||||
$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 {
|
} else {
|
||||||
$this->formOutput(true);
|
$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 "<p>" . mi18n("Hier ist die Ausgabe einzugeben, die erscheint, wenn das Formular erfolgreich prozessiert worden ist:") . "</p>";
|
||||||
echo "CMS_HTML[1]";
|
echo "CMS_HTML[1]";
|
||||||
} else {
|
} else {
|
||||||
$form = new w3form();
|
$form = new w3form($captchaInstalled);
|
||||||
$form->addEmailAdress("CMS_VALUE[0]");
|
$form->addEmailAdress("CMS_VALUE[0]");
|
||||||
$form->setEmailSubject("CMS_VALUE[1]");
|
$form->setEmailSubject("CMS_VALUE[1]");
|
||||||
$form->setEmailFrom("CMS_VALUE[2]", "CMS_VALUE[3]");
|
$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)
|
* 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;
|
$sFrontEndPath = cRegistry::getClientConfig(cRegistry::getClientId())['path']['frontend'] . 'securimage' . DIRECTORY_SEPARATOR;
|
||||||
require_once $sFrontEndPath . 'securimage.php';
|
$captchaInstalled = false;
|
||||||
require_once $sFrontEndPath . 'CaptchaObject.php';
|
if (is_readable($sFrontEndPath)) {
|
||||||
require_once $sFrontEndPath . 'StorageAdapter/AdapterInterface.php';
|
require_once $sFrontEndPath . 'securimage.php';
|
||||||
|
require_once $sFrontEndPath . 'CaptchaObject.php';
|
||||||
|
require_once $sFrontEndPath . 'StorageAdapter/AdapterInterface.php';
|
||||||
|
$captchaInstalled = true;
|
||||||
|
}
|
||||||
|
|
||||||
class w3form
|
class w3form
|
||||||
{
|
{
|
||||||
|
@ -68,10 +74,10 @@ class w3form
|
||||||
private array $email = ['adresses' => '', 'from' => ['name' => '', 'email' => ''], 'message' => '', 'subject' => ''];
|
private array $email = ['adresses' => '', 'from' => ['name' => '', 'email' => ''], 'message' => '', 'subject' => ''];
|
||||||
private array $unraveled = [];
|
private array $unraveled = [];
|
||||||
private array $form = ['form' => '', 'answer' => '', 'colorError' => ''];
|
private array $form = ['form' => '', 'answer' => '', 'colorError' => ''];
|
||||||
private array $formField = [];
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct(private bool $captchaInstalled)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sendEmail(): bool
|
private function sendEmail(): bool
|
||||||
|
@ -240,31 +246,33 @@ class w3form
|
||||||
|
|
||||||
switch ($attribute['type']) {
|
switch ($attribute['type']) {
|
||||||
case 'captcha':
|
case 'captcha':
|
||||||
if ($sent) {
|
if ($this->captchaInstalled) {
|
||||||
$captcha = @$_POST['ct_captcha'];
|
if ($sent) {
|
||||||
$capId = @$_POST['captcha_id'];
|
$captcha = @$_POST['ct_captcha'];
|
||||||
$securimage = new Securimage();
|
$capId = @$_POST['captcha_id'];
|
||||||
|
$securimage = new Securimage();
|
||||||
|
|
||||||
if (!$securimage->check($captcha)) {
|
if (!$securimage->check($captcha)) {
|
||||||
echo '<style>'
|
echo '<style>'
|
||||||
. '#captcha_code {background-color: ' . $this->form['colorError'] . '}'
|
. '#captcha_code {background-color: ' . $this->form['colorError'] . '}'
|
||||||
. '</style>';
|
. '</style>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// show captcha HTML using Securimage::getCaptchaHtml()
|
||||||
// show captcha HTML using Securimage::getCaptchaHtml()
|
$options = [];
|
||||||
$options = [];
|
$options['input_name'] = 'ct_captcha'; // change name of input element for form post input_text
|
||||||
$options['input_name'] = 'ct_captcha'; // change name of input element for form post input_text
|
$options['input_text'] = mi18n("Zeichen eingeben");
|
||||||
$options['input_text'] = mi18n("Zeichen eingeben");
|
$options['input_required'] = false;
|
||||||
$options['input_required'] = false;
|
|
||||||
|
|
||||||
if (!empty($_SESSION['ctform']['captcha_error'])) {
|
if (!empty($_SESSION['ctform']['captcha_error'])) {
|
||||||
// error html to show in captcha output
|
// error html to show in captcha output
|
||||||
$options['error_html'] = $_SESSION['ctform']['captcha_error'];
|
$options['error_html'] = $_SESSION['ctform']['captcha_error'];
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<div id='captcha_container_1'>\n";
|
echo "<div id='captcha_container_1'>\n";
|
||||||
echo Securimage::getCaptchaHtml($options);
|
echo Securimage::getCaptchaHtml($options);
|
||||||
echo "\n</div>\n";
|
echo "\n</div>\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
echo "<input type=\"text\" $parameter value=\"$value\" $style />";
|
echo "<input type=\"text\" $parameter value=\"$value\" $style />";
|
||||||
|
@ -345,8 +353,22 @@ class w3form
|
||||||
$form = $this->form['form'];
|
$form = $this->form['form'];
|
||||||
$fields = $this->formInterpretation($form);
|
$fields = $this->formInterpretation($form);
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if (!$this->formFieldCorrect($field)) {
|
switch ($field['type']) {
|
||||||
return false;
|
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;
|
return true;
|
||||||
|
@ -454,16 +476,7 @@ class w3form
|
||||||
if (!isset($_POST['sent'])) {
|
if (!isset($_POST['sent'])) {
|
||||||
$this->formOutput();
|
$this->formOutput();
|
||||||
} elseif ($this->formComplete()) {
|
} elseif ($this->formComplete()) {
|
||||||
// check captcha
|
$this->success();
|
||||||
$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 {
|
} else {
|
||||||
$this->formOutput(true);
|
$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 "<p>" . mi18n("Hier ist die Ausgabe einzugeben, die erscheint, wenn das Formular erfolgreich prozessiert worden ist:") . "</p>";
|
||||||
echo "CMS_HTML[1]";
|
echo "CMS_HTML[1]";
|
||||||
} else {
|
} else {
|
||||||
$form = new w3form();
|
$form = new w3form($captchaInstalled);
|
||||||
$form->addEmailAdress("CMS_VALUE[0]");
|
$form->addEmailAdress("CMS_VALUE[0]");
|
||||||
$form->setEmailSubject("CMS_VALUE[1]");
|
$form->setEmailSubject("CMS_VALUE[1]");
|
||||||
$form->setEmailFrom("CMS_VALUE[2]", "CMS_VALUE[3]");
|
$form->setEmailFrom("CMS_VALUE[2]", "CMS_VALUE[3]");
|
||||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren