In der neuen 4.8er Familie funktioniert diese Modul nicht:
Link zum 4.6er Modul : http://forum.contenido.org/viewtopic.ph ... hencaptcha
Hinweis zur Barrierefreiheit:
Im Input kann man jetzt auswählen, ob man die Rechenausgabe als png-Datei angezeigt bekommen will oder als Text, den dann auch blinde Menschen lesen können.
Und hier das Modul für die 4.8
1. Kopiert den nachfolgenden Code in eine neue Datei.
2. Speichert diese Datei ab als rechen-captcha.php
3. Ladet diese Datei auf Euren Server in den Ordner /cms
Code: Alles auswählen
<?php
if (stristr($_SERVER["PHP_SELF"], basename(__FILE__)) !== false) {
include_once ("config.php");
include_once ($contenido_path."includes/startup.php");
cInclude("includes", "functions.con.php");
cInclude("includes", "functions.con2.php");
cInclude("includes", "functions.api.php");
cInclude("includes", "functions.pathresolver.php");
page_open(array ('sess' => 'Contenido_Frontend_Session', 'auth' => 'Contenido_Frontend_Challenge_Crypt_Auth', 'perm' => 'Contenido_Perm'));
$db = new DB_Contenido;
$sess->register("rechen_captcha_spam");
$zahl1 = rand(10,20); //Erste Zahl 10-20
$zahl2 = rand(1,10); //Zweite Zahl 1-10
$operator = rand(1,2); // + oder -
if($operator == "1"){
$operatorzeichen = " + ";
$ergebnis = $zahl1 + $zahl2;
}else{
$operatorzeichen = " - ";
$ergebnis = $zahl1 - $zahl2;
}
$rechen_captcha_spam = encrypt((string) $ergebnis); //Key
$rechen_captcha_spam = str_replace("=", "", $rechen_captcha_spam);
page_close();
$rechnung = $zahl1.$operatorzeichen.$zahl2." = ?";
$img = imagecreatetruecolor(80,15);
$schriftfarbe = imagecolorallocate($img,13,28,91);
$hintergrund = imagecolorallocate($img,255,255,255);
imagefill($img,0,0,$hintergrund);
imagestring($img, 3, 2, 0, $rechnung, $schriftfarbe);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
} else {
// donut
}
function encrypt($string, $key=null) {
if ($key == null) {
$key = "29jfkd921";
}
$result = '';
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result .= $char;
}
return base64_encode($result);
}
Das muss, wie nachfolgend gezeigt, ergänzt werden:
Code: Alles auswählen
<div id="contactForm">
<form action="{form_action}" method="post">
<input type="hidden" name="send" value="1" />
<div class="contactRow clearfix">
<table>
<tr>
<td class="pt" style="width:80px;"><label for="Anrede">{ANREDE}</label></td>
<td style="width:10px;"><input type="radio" name="Anrede" value="{ANREDE_OPTION1}" id="Anrede" checked="checked" style="width:auto;border:0;" /></td>
<td class="pt">{ANREDE_OPTION1}</td>
<td style="width:10px;"><input type="radio" name="Anrede" value="{ANREDE_OPTION2}" style="width:auto;border:0;" /></td>
<td class="pt">{ANREDE_OPTION2}</td>
<td class="pt" style="text-align:right;">* {PFLICHTFELDER}</td>
</tr>
</table>
</div>
<div class="contactRow clearfix">
<label for="Vorname">{VORNAME} *</label>
<input type="text" name="Vorname" id="Vorname" class="eingabe" maxlength="100"/>
</div>
<div class="contactRow clearfix">
<label for="Name">{NACHNAME} *</label>
<input type="text" name="Nachname" id="Nachname" class="eingabe" maxlength="100"/>
</div>
<div class="contactRow clearfix">
<label for="Firma">{FIRMA} *</label>
<input type="text" name="Firma" id="Firma" class="eingabe" maxlength="100"/>
</div>
<div class="contactRow clearfix">
<label for="Strasse">{STRASSE} *</label>
<input type="text" name="Strasse" id="Strasse" class="eingabe" maxlength="100"/>
</div>
<div class="contactRow clearfix">
<label for="PLZOrt">{PLZORT} *</label>
<input type="text" name="PLZOrt" id="PLZOrt" class="eingabe" maxlength="100"/>
</div>
<div class="contactRow clearfix">
<label for="Telefon">{TELEFON} *</label>
<input type="text" name="Telefon" id="Telefon" class="eingabe" maxlength="100" />
</div>
<div class="contactRow clearfix">
<label for="EMail">{EMAIL} *</label>
<input type="text" name="EMail" id="EMail" class="eingabe" maxlength="100"/>
</div>
<div class="contactRow clearfix">
<label for="Anliegen">{ANLIEGEN} *</label>
<textarea name="Anliegen" id="Anliegen"></textarea>
</div>
<div class="contactRow clearfix">
<label for="Aufgabe">{CAPTCHA_JOB</label>
<!--
<img id="Aufgabe" src="rechen-captcha.php" alt="{CAPTCHA_JOB_MSG}" /></div>
-->
{RECHEN_CAPTCHA_CONTENT}</div>
<div class="contactRow clearfix"><label for="Sicherheitscode">{CAPTCHA_JOB_RESULT}*</label>
<input id="Sicherheitscode" name="Sicherheitscode" type="text" class="eingabe" maxlength="100" /></div>
<div id="contactFormSubmit" class="clearfix">
<div id="contactFormSubmitLeft">
<input type="reset" value="{LOESCHEN}" />
</div>
<div id="contactFormSubmitRight">
<input type="submit" value="{ABSCHICKEN}" />
</div>
</div>
</form>
</div>
5. Das Standard Kontaktmodul von Andreas Lindler muss jetzt geändert werden.
Hierzu müsst Ihr den INPUT und den OUTPUT gegen nachfolgenden Code austauschen.
Input:
Code: Alles auswählen
?><?php
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname : Contact form mit Rechen Captcha
* Author(s) : Andreas Lindner, Patrick Dohmen, Murat Purc
* Copyright : Contenido - four for business
* Created : 28.10.2008
* Erweiterung : apical art webdesign
************************************************/
?>
<table border="0">
<tr>
<td><?php echo mi18n("Absender EMail");?></td>
<td><input type="text" name="<?php echo "CMS_VAR[0]";?>" value="<?php echo "CMS_VALUE[0]"; ?>"></td>
</tr>
<tr>
<td><?php echo mi18n("Absender Name");?></td>
<td><input type="text" name="<?php echo "CMS_VAR[2]";?>" value="<?php echo "CMS_VALUE[2]"; ?>"></td>
</tr>
<tr>
<td><?php echo mi18n("Empfänger EMail");?></td>
<td><input type="text" name="<?php echo "CMS_VAR[1]";?>" value="<?php echo "CMS_VALUE[1]"; ?>"></td>
</tr>
<tr>
<td><?php echo mi18n("Betreff");?></td>
<td><input type="text" name="<?php echo "CMS_VAR[3]";?>" value="<?php echo "CMS_VALUE[3]"; ?>"></td>
</tr>
<?php
$c1 = '';
$c2 = '';
$c3 = '';
$c4 = '';
switch (strtolower("CMS_VALUE[4]")) {
case "smtp" :
$c1 = ' checked';
break;
case "mail" :
$c2 = ' checked';
break;
case "sendmail" :
$c3 = ' checked';
break;
case "qmail" :
$c4 = ' checked';
break;
default :
$c3 = ' checked';
}
?>
<tr>
<td valign="top"><?php echo mi18n("Mailer");?></td>
<td>
<input type="radio" name="<?php echo "CMS_VAR[4]";?>" value="mail"<?php echo $c2;?>> <?php echo mi18n("mail");?><br/>
<input type="radio" name="<?php echo "CMS_VAR[4]";?>" value="qmail"<?php echo $c4;?>> <?php echo mi18n("qmail");?><br/>
<input type="radio" name="<?php echo "CMS_VAR[4]";?>" value="sendmail"<?php echo $c3;?>> <?php echo mi18n("sendmail");?><br/>
<input type="radio" name="<?php echo "CMS_VAR[4]";?>" value="smtp"<?php echo $c1;?>> <?php echo mi18n("smtp");?><br/>
</td>
</tr>
<tr>
<td><?php echo mi18n("SMTP Host");?></td>
<td><input type="text" name="<?php echo "CMS_VAR[5]";?>" value="<?php echo "CMS_VALUE[5]"; ?>"></td>
</tr>
<tr>
<td><?php echo mi18n("SMTP User");?></td>
<td><input type="text" name="<?php echo "CMS_VAR[6]";?>" value="<?php echo "CMS_VALUE[6]"; ?>"></td>
</tr>
<tr>
<td><?php echo mi18n("SMTP Passwort");?></td>
<td><input type="text" name="<?php echo "CMS_VAR[7]";?>" value="<?php echo "CMS_VALUE[7]"; ?>"></td>
</tr>
<?php
$rechenCaptchaChk = ("CMS_VALUE[8]" !== '') ? ' checked' : '';
?>
<tr>
<td><?php echo mi18n("Rechen Captcha");?></td>
<td valign="top"><input type="checkbox" name="<?php echo "CMS_VAR[8]";?>" value="1"<?php echo $rechenCaptchaChk ?>> <?php echo mi18n("Rechen Captcha als Text ausgeben");?><br />
<small>Ist die Option nicht gewählt, wird das Captcha als Bild ausgegeben.</small>
</td>
</tr>
</table>
<?php
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : Contact form mit Rechen Captcha
* Author(s) : Andreas Lindner, Patrick Dohmen, Murat Purc
* Copyright : Contenido - four for business
* Created : 28.10.2008
* Erweiterung : apical art webdesign
************************************************/
#Includes
cInclude("classes", "class.phpmailer.php");
if (!isset ($_POST['send'])) {
#Form has not been sent yet
cInclude('classes', 'class.article.php');
cInclude('classes', 'class.template.php');
#Create contact form
echo '<form id="kontaktform" method="post" action="'.$sess->url("front_content.php?idcat=$idcat&idart=$idart").'">';
echo '<div id="hidden"><input type="hidden" name="send" value="1" /></div>';
$noImgCaptcha = "CMS_VALUE[8]";
#var_dump($noImgCaptcha);
if ($noImgCaptcha == "1") {
#### Textversion des Rechen-Captcha
cInclude("frontend","rechen-captcha.php");
$sess->register("rechen_captcha_spam");
$zahl1 = rand(10,20); //Erste Zahl 10-20
$zahl2 = rand(1,10); //Zweite Zahl 1-10
$operator = rand(1,2); // + oder -
if($operator == "1"){
$ergebnis = $zahl1 + $zahl2;
$captchaContent = '<p>' . sprintf(mi18n("Addiere %s und %s ."), $zahl1, $zahl2);
$captchaContent .= '<br />' . mi18n("Bitte teilen Sie uns im nachfolgenden Feld die Lösung mit") . '</p>';
}else{
$ergebnis = $zahl1 - $zahl2;
$captchaContent = '<p>' . sprintf(mi18n("Subtrahiere %s von % ."), $zahl2, $zahl1);
$captchaContent .= '<br />' . mi18n("Bitte teilen Sie uns im nachfolgenden Feld die Lösung mit") . '</p>';
}
$rechen_captcha_spam = encrypt((string) $ergebnis); //Key
$rechen_captcha_spam = str_replace("=", "", $rechen_captcha_spam);
} else {
#### Bildversion des Rechen-Captcha
$captchaContent = '<img id="Aufgabe" src="rechen-captcha.php" alt="' . mi18n("Bitte teilen Sie uns im nachfolgenden Feld die Lösung mit") . '" />';
}
if (!is_object($tpl)) {
$tpl = new Template;
}
$tpl->set("s", "ANREDE", mi18n("Anrede"));
$tpl->set("s", "ANREDE_OPTION1", mi18n("Herr"));
$tpl->set("s", "ANREDE_OPTION2", mi18n("Frau"));
$tpl->set("s", "NACHNAME", mi18n("Name"));
$tpl->set("s", "VORNAME", mi18n("Vorname"));
$tpl->set("s", "FIRMA", mi18n("Firma"));
$tpl->set("s", "STRASSE", mi18n("Straße/Nr."));
$tpl->set("s", "PLZORT", mi18n("PlzOrt"));
$tpl->set("s", "TELEFON", mi18n("Telefon"));
$tpl->set("s", "EMAIL", mi18n("Email"));
$tpl->set("s", "CAPTCHA_JOB", mi18n("Unsere Aufgabe"));
# $tpl->set("s", "CAPTCHA_JOB_MSG", mi18n("Bitte teilen Sie uns im nachfolgenden Feld die Lösung mit"));
$tpl->set("s", "RECHEN_CAPTCHA_CONTENT", $captchaContent);
$tpl->set("s", "CAPTCHA_JOB_RESULT", mi18n("Ihr Ergebnis"));
$tpl->set("s", "CAPTCHA_JOB_RESULT_MSG", mi18n("Eingabefeld, geben Sie hier Ihr Ergebnis ein"));
$tpl->set("s", "ANLIEGEN", mi18n("Nachricht"));
$tpl->set("s", "PFLICHTFELDER", mi18n("Pflichtfelder"));
$tpl->set("s", "ABSCHICKEN", mi18n("Abschicken"));
$tpl->set("s", "LOESCHEN", mi18n("Löschen"));
$tpl->generate($cfgClient[$client]["path"]["frontend"]."templates/kontaktformular.html");
echo '</form>';
} elseif ($_POST['send'] == 1) {
#Form has been sent
#Check user input
$noerrors = true;
$msg = '';
cInclude("frontend","rechen-captcha.php");
$sicherheits_eingabe = encrypt($_POST["Sicherheitscode"]);
$sicherheits_eingabe = str_replace("=", "", $sicherheits_eingabe);
if(isset($rechen_captcha_spam)&&$sicherheits_eingabe == $rechen_captcha_spam){
$sess->unregister("rechen_captcha_spam");
unset($rechen_captcha_spam);
unset($_POST["Sicherheitscode"]);
}
else {
$noerrors = false;
$msg .= mi18n("Rechenaufgabe wurde falsch gelöst")."<br/>";
}
if ($_POST['Nachname'] == '') {
$noerrors = false;
$msg .= mi18n("Bitte geben Sie Ihren Namen ein!")."'<br/>";
}
if ($_POST['Email'] == '') {
$noerrors = false;
$msg .= mi18n("Bitte geben Sie Ihre EMail-Adresse ein!")."<br/>";
}
if ($noerrors == false) {
#Errors have been found
echo mi18n("<p>Beim Versenden sind folgende Fehler aufgetreten:")."<br/>";
echo $msg.'<br/>';
echo '<a href="javascript:history.back();">'.mi18n("Zurück").'</a></p>';
} else {
#No errors, create and send mail
$mail = new phpmailer;
$mail_body = '<html><head></head><body bgcolor="#ffffff"><table cellspacing="0" cellpadding="2" border="0">';
if (is_array($_POST)) {
foreach ($_POST as $key => $value) {
if ($key != 'send') {
$mail_body .= "<tr><td>$key</td><td>$value</td></tr>";
}
}
}
$mail_body .= '</table></bo'.'dy></html>';
$mail->Host = "localhost";
$mail->IsHTML(true);
#Get mailer from settings
switch (strtolower("CMS_VALUE[4]")) {
case "smtp" :
$mail->IsSMTP();
$host = "CMS_VALUE[5]";
$user = "CMS_VALUE[6]";
$password = "CMS_VALUE[7]";
if (($host != '') && ($user != '') && ($password != '')) {
$mail-> $SMTPAuth = true;
$mail->Host = $host;
$mail->Username = $user;
$mail->Password = $password;
}
break;
case "mail" :
$mail->IsMail();
break;
case "sendmail" :
$mail->IsSendmail();
break;
case "qmail" :
$mail->IsQmail();
break;
default :
}
$mail->From = "CMS_VALUE[0]";
$mail->FromName = "CMS_VALUE[2]";
$mail->AddAddress("CMS_VALUE[1]", "");
$mail->Subject = "CMS_VALUE[3]";
$mail->Body = $mail_body;
$mail->WordWrap = 50;
$mail->Send();
#Display message after mail is sent
echo mi18n("<p>"."Ihr Anliegen wurde uns übermittelt. Vielen Dank!")."<br/></p>";
}
}
?>