add org code and modify output
Dieser Commit ist enthalten in:
Ursprung
a06a6050c4
Commit
5888026236
4 geänderte Dateien mit 700 neuen und 12 gelöschten Zeilen
|
@ -8,8 +8,6 @@
|
||||||
* 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;
|
||||||
$captchaInstalled = false;
|
$captchaInstalled = false;
|
||||||
if (is_readable($sFrontEndPath)) {
|
if (is_readable($sFrontEndPath)) {
|
||||||
|
@ -162,7 +160,7 @@ class w3form
|
||||||
echo $item;
|
echo $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
echo '<input type="submit" value="submit">';
|
||||||
echo '</form></div>';
|
echo '</form></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,16 +168,16 @@ class w3form
|
||||||
{
|
{
|
||||||
$style = '';
|
$style = '';
|
||||||
$value = '';
|
$value = '';
|
||||||
$parameter = "name=\"{$attribute['name']}\"";
|
$parameter = 'name="' . $attribute['name'] . '"';
|
||||||
if ($sent && !$this->formFieldCorrect($attribute))
|
if ($sent && !$this->formFieldCorrect($attribute))
|
||||||
$style = "style=\"background-color:{$this->form['colorError']};\"";
|
$style = 'style="background-color: ' . $this->form['colorError'] . ';"';
|
||||||
|
|
||||||
switch ($attribute['type']) {
|
switch ($attribute['type']) {
|
||||||
case 'select':
|
case 'select':
|
||||||
case 'password':
|
case 'password':
|
||||||
case 'text':
|
case 'text':
|
||||||
if (!empty($attribute['size']))
|
if (!empty($attribute['size']))
|
||||||
$parameter .= " size=\"{$attribute['size']}\"";
|
$parameter .= ' size="' . $attribute['size'] . '"';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +185,7 @@ class w3form
|
||||||
case 'textarea':
|
case 'textarea':
|
||||||
case 'text':
|
case 'text':
|
||||||
if (!empty($attribute['size']))
|
if (!empty($attribute['size']))
|
||||||
$parameter .= " size=\"{$attribute['size']}\"";
|
$parameter .= ' size="' . $attribute['size'] . '"';
|
||||||
if (!empty($attribute['value']))
|
if (!empty($attribute['value']))
|
||||||
$value = $attribute['value'];
|
$value = $attribute['value'];
|
||||||
if (!empty($_POST["{$attribute['name']}"]))
|
if (!empty($_POST["{$attribute['name']}"]))
|
||||||
|
@ -435,20 +433,21 @@ class w3form
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($edit) && $edit) {
|
if (cRegistry::isBackendEditMode()) {
|
||||||
echo "<h1>" . mi18n("Formularkonfiguration") . "</h1>";
|
echo "<h1>" . mi18n("Formularkonfiguration") . "</h1>";
|
||||||
echo "<p>" . mi18n("Hier ist das Formular sowie der Text einzugeben, der zusammen mit dem Formular ausgegeben werden soll:") . "</p>";
|
echo "<p>" . mi18n("Hier ist das Formular sowie der Text einzugeben, der zusammen mit dem Formular ausgegeben werden soll:") . "</p>";
|
||||||
echo "CMS_HTML[0]";
|
echo "CMS_HTML[100]";
|
||||||
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[101]";
|
||||||
} else {
|
} else {
|
||||||
$form = new w3form($captchaInstalled);
|
$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]");
|
||||||
$form->setBackgroundError("CMS_VALUE[4]");
|
$form->setBackgroundError("CMS_VALUE[4]");
|
||||||
$form->setForm("CMS_HTML[0]");
|
$form->setForm("CMS_HTML[100]");
|
||||||
$form->setAnswer("CMS_HTML[1]");
|
$form->setAnswer("CMS_HTML[101]");
|
||||||
$form->process();
|
$form->process();
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
308
php/form.org.php
Normale Datei
308
php/form.org.php
Normale Datei
|
@ -0,0 +1,308 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* CONTENIDO MODUL - OUTPUT
|
||||||
|
*
|
||||||
|
* Modulname : w3concepts.form.v1
|
||||||
|
* Author : Andreas Kummer
|
||||||
|
* Copyright : mumprecht & kummer w3concepts
|
||||||
|
* Created : 20-08-2004
|
||||||
|
* Modified : 20-08-2004
|
||||||
|
************************************************/
|
||||||
|
|
||||||
|
class w3form {
|
||||||
|
|
||||||
|
var $email, $aufgedroeselt, $form, $formularFeld;
|
||||||
|
|
||||||
|
function w3form() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function sendEmail() {
|
||||||
|
$this->aufdroeseln($this->suppress('sent'));
|
||||||
|
$this->generateEmailMessage();
|
||||||
|
mail($this->email['adresses'],$this->email['subject'],$this->email['message'],"From: {$this->email['from']['name']} <{$this->email['from']['email']}>\nReply-To: {$this->email['from']['email']}\nX-Mailer: PHP/" . phpversion());
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function aufdroeseln($aufzudroeseln,$prefix = '') {
|
||||||
|
foreach ($aufzudroeseln as $key => $value) {
|
||||||
|
if (is_array($value)) {
|
||||||
|
$this->aufdroeseln($value,$key." ");
|
||||||
|
} else {
|
||||||
|
$this->aufgedroeselt["{$prefix}{$key}"] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function add2Message($key,$value) {
|
||||||
|
if (strlen($key) > 25 OR strlen($value) > 54) {
|
||||||
|
$this->email['message'] .= "$key\n$value\n";
|
||||||
|
} else {
|
||||||
|
$this->email['message'] .= $key;
|
||||||
|
$this->email['message'] .= str_repeat(' ',25-strlen($key));
|
||||||
|
$this->email['message'] .= "$value\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function generateEmailMessage() {
|
||||||
|
if ($this->aufgedroeselt) foreach ($this->aufgedroeselt as $key => $value) {
|
||||||
|
$this->add2Message($key,$value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function suppress() {
|
||||||
|
$suppress = func_get_args();
|
||||||
|
foreach ($_POST as $key => $value) {
|
||||||
|
if (array_search($key,$suppress) === false) $fields[$key] = $value;
|
||||||
|
}
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// PUBLIC
|
||||||
|
function addEmailAdress($email) {
|
||||||
|
if (empty($this->emailAdresses)) {
|
||||||
|
$this->email['adresses'] .= "$email";
|
||||||
|
} else {
|
||||||
|
$this->email['adresses'] .= ", $email";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUBLIC
|
||||||
|
function setEmailSubject($subject) {
|
||||||
|
$this->email['subject'] = $subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUBLIC
|
||||||
|
function setEmailFrom($email,$name) {
|
||||||
|
$this->email['from']['email'] = $email;
|
||||||
|
$this->email['from']['name'] = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUBLIC
|
||||||
|
function setForm($form) {
|
||||||
|
$this->form['form'] = $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUBLIC
|
||||||
|
function setAnswer($answer) {
|
||||||
|
$this->form['answer'] = $answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUBLIC
|
||||||
|
function setBackgroundError($color) {
|
||||||
|
$this->form['colorError'] = $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function formularInterpretation(&$formular) {
|
||||||
|
$felder = split('###',$formular);
|
||||||
|
for ($i=1;$i<count($felder);$i=$i+2) {
|
||||||
|
$attributte = split(';',trim($felder[$i]));
|
||||||
|
foreach ($attributte as $attribut) {
|
||||||
|
$namewert = split(':',trim($attribut));
|
||||||
|
if ($namewert[0] != 'option' && $namewert[0] != 'optionvalue') {
|
||||||
|
$feld["{$felder[$i]}"]["{$namewert[0]}"] = $namewert[1];
|
||||||
|
} else {
|
||||||
|
$feld["{$felder[$i]}"]["{$namewert[0]}"][] = $namewert[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $feld;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function formularAusgabe($sent = false) {
|
||||||
|
echo '<form action="" method="post">';
|
||||||
|
echo '<input type="hidden" name="sent" value="true" />';
|
||||||
|
$formular = $this->form['form'];
|
||||||
|
$formulardaten = $this->formularInterpretation(&$formular);
|
||||||
|
$formular = split('###',$formular);
|
||||||
|
foreach ($formular as $formularteil) {
|
||||||
|
if (!empty($formulardaten["{$formularteil}"])) {
|
||||||
|
$this->formularFeld($formulardaten["{$formularteil}"],$sent);
|
||||||
|
} else {
|
||||||
|
echo $formularteil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '</form>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function formularFeld($attribute,$sent) {
|
||||||
|
$parameter = "name=\"{$attribute['name']}\"";
|
||||||
|
if ($sent && !$this->formularFeldKorrekt(&$attribute)) $style ="style=\"background-color:{$this->form['colorError']};\"";
|
||||||
|
switch ($attribute['type']) {
|
||||||
|
case 'select':
|
||||||
|
case 'password':
|
||||||
|
case 'text':
|
||||||
|
if (!empty($attribute['size'])) $parameter .= " size=\"{$attribute['size']}\"";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch ($attribute['type']) {
|
||||||
|
case 'textarea':
|
||||||
|
case 'text':
|
||||||
|
if (!empty($attribute['size'])) $parameter .= " size=\"{$attribute['size']}\"";
|
||||||
|
if (!empty($attribute['value'])) $value = $attribute['value'];
|
||||||
|
if (!empty($_POST["{$attribute['name']}"])) $value = $_POST["{$attribute['name']}"];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch ($attribute['type']) {
|
||||||
|
case 'text':
|
||||||
|
echo "<input type=\"text\" $parameter value=\"$value\" $style />";
|
||||||
|
break;
|
||||||
|
case 'password':
|
||||||
|
echo "<input type=\"password\" $parameter value=\"$value\" $style />";
|
||||||
|
break;
|
||||||
|
case 'textarea':
|
||||||
|
echo "<textarea name=\"{$attribute['name']}\" cols=\"";
|
||||||
|
echo (empty($attribute['cols']))?('20'):($attribute['cols']);
|
||||||
|
echo "\" rows=\"";
|
||||||
|
echo (empty($attribute['rows']))?('2'):($attribute['rows']);
|
||||||
|
echo "\" wrap=\"virtual\" $style>$value</textarea>";
|
||||||
|
break;
|
||||||
|
case 'select':
|
||||||
|
echo "<select $parameter $style>";
|
||||||
|
for ($i=0;$i<count($attribute['option']);$i++) {
|
||||||
|
if (!empty($attribute['optionvalue'][$i])) {
|
||||||
|
if (!empty($_POST["{$attribute['name']}"]) && $_POST["{$attribute['name']}"] == $attribute['optionvalue'][$i]) {
|
||||||
|
echo "<option value=\"{$attribute['optionvalue'][$i]}\" selected=\"selected\">{$attribute['option'][$i]}</option>\n";
|
||||||
|
} else {
|
||||||
|
if (empty($_POST["{$attribute['name']}"]) && !empty($attribute['optionvalue'][$i]) && $attribute['optionvalue'][$i] == $attribute['value']) {
|
||||||
|
echo "<option value=\"{$attribute['optionvalue'][$i]}\" selected=\"selected\">{$attribute['option'][$i]}</option>\n";
|
||||||
|
} else {
|
||||||
|
echo "<option value=\"{$attribute['optionvalue'][$i]}\">{$attribute['option'][$i]}</option>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!empty($_POST["{$attribute['name']}"]) && $_POST["{$attribute['name']}"] == $attribute['option'][$i]) {
|
||||||
|
echo "<option selected=\"selected\">{$attribute['option'][$i]}</option>\n";
|
||||||
|
} else {
|
||||||
|
if (empty($_POST["{$attribute['name']}"]) && $attribute['option'][$i] == $attribute['value']) {
|
||||||
|
echo "<option selected=\"selected\">{$attribute['option'][$i]}</option>\n";
|
||||||
|
} else {
|
||||||
|
echo "<option>{$attribute['option'][$i]}</option>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</select>";
|
||||||
|
break;
|
||||||
|
case 'checkbox':
|
||||||
|
$formularbezeichner = preg_split('[\[|\]]',$attribute['name']);
|
||||||
|
if ($sent) {
|
||||||
|
if ($_POST["{$formularbezeichner[0]}"]["{$formularbezeichner[1]}"] == $attribute['value']) {
|
||||||
|
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
|
||||||
|
} else {
|
||||||
|
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\"/>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!empty($attribute['selected']) && $attribute['selected'] == 'true') {
|
||||||
|
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
|
||||||
|
} else {
|
||||||
|
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\"/>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'radio':
|
||||||
|
if (!empty($_POST["{$attribute['name']}"])) {
|
||||||
|
if ($_POST["{$attribute['name']}"] == $attribute['value']) {
|
||||||
|
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
|
||||||
|
} else {
|
||||||
|
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" />";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!empty($attribute['selected']) && $attribute['selected'] == 'true') {
|
||||||
|
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
|
||||||
|
} else {
|
||||||
|
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\"/>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function formularVollstaendig() {
|
||||||
|
|
||||||
|
$formular = $this->form['form'];
|
||||||
|
|
||||||
|
$felder = $this->formularInterpretation(&$formular);
|
||||||
|
|
||||||
|
foreach ($felder as $feld) {
|
||||||
|
if (!$this->formularFeldKorrekt(&$feld)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function success() {
|
||||||
|
$this->sendEmail();
|
||||||
|
echo $this->form['answer'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// PRIVATE
|
||||||
|
function formularFeldKorrekt(&$feld) {
|
||||||
|
|
||||||
|
// prüfung, ob pflichtfeld vorhanden
|
||||||
|
if (!empty($feld['mandatory']) && $feld['mandatory'] == 'true' && empty($_POST["{$feld['name']}"])) return false;
|
||||||
|
|
||||||
|
// wenn das formularfeld kein pflichtfeld und nicht vorhanden ist, true zurück geben
|
||||||
|
if (empty($_POST["{$feld['name']}"])) return true;
|
||||||
|
|
||||||
|
// regular expression prüfungen
|
||||||
|
if (!empty($feld['valid']) && $feld['valid'] == 'simpletext' && !eregi("^[öäüéàèâêîça-z-]*$",$_POST["{$feld['name']}"])) return false;
|
||||||
|
if (!empty($feld['valid']) && $feld['valid'] == 'text' && !eregi("^[ .,;!?()öäüéàèâêîça-z-]*$",$_POST["{$feld['name']}"])) return false;
|
||||||
|
if (!empty($feld['valid']) && $feld['valid'] == 'integer' && !eregi("^[0-9]*$",$_POST["{$feld['name']}"])) return false;
|
||||||
|
if (!empty($feld['valid']) && $feld['valid'] == 'float' && !eregi("^[0-9]*[.]{0,1}[0-9]*$",$_POST["{$feld['name']}"])) return false;
|
||||||
|
if (!empty($feld['valid']) && $feld['valid'] == 'date' && !eregi("^[0-9]{1,2}.[0-9]{1,2}.[0-9]{2}$",$_POST["{$feld['name']}"])) return false;
|
||||||
|
if (!empty($feld['valid']) && $feld['valid'] == 'email' && !eregi("^[öäüéàèâêîç_a-z0-9-]+(\.[öäüéàèâêîç_a-z0-9-]+)*@[öäüéàèâêîça-z0-9-]+(\.[öäüéàèâêîça-z0-9-]+)*$",$_POST["{$feld['name']}"])) return false;
|
||||||
|
|
||||||
|
// grössenbereich bei integer und float prüfen
|
||||||
|
if (!empty($feld['minvalue']) && $_POST["{$feld['name']}"] < $feld['minvalue']) return false;
|
||||||
|
if (!empty($feld['maxvalue']) && $_POST["{$feld['name']}"] > $feld['maxvalue']) return false;
|
||||||
|
|
||||||
|
// längenbereich bei allen typen prüfen
|
||||||
|
if (!empty($feld['minlength']) && strlen($_POST["{$feld['name']}"]) < $feld['minlength']) return false;
|
||||||
|
if (!empty($feld['maxlength']) && strlen($_POST["{$feld['name']}"]) > $feld['maxlength']) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//PUBLIC
|
||||||
|
function process() {
|
||||||
|
if (!isset($_POST['sent'])) {
|
||||||
|
$this->formularAusgabe();
|
||||||
|
} elseif ($this->formularVollstaendig()) {
|
||||||
|
$this->success();
|
||||||
|
} else {
|
||||||
|
$this->formularAusgabe(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($edit) {
|
||||||
|
echo "<h1>Formularkonfiguration</h1>";
|
||||||
|
echo "<p>Hier ist das Formular sowie der Text einzugeben, der zusammen mit dem Formular ausgegeben werden soll:</p>";
|
||||||
|
echo "CMS_HTML[0]";
|
||||||
|
echo "<p>Hier ist die Ausgabe einzugeben, die erscheint, wenn das Formular erfolgreich prozessiert worden ist:</p>";
|
||||||
|
echo "CMS_HTML[1]";
|
||||||
|
} else {
|
||||||
|
$formular = new w3form();
|
||||||
|
$formular->addEmailAdress("CMS_VALUE[0]");
|
||||||
|
$formular->setEmailSubject("CMS_VALUE[1]");
|
||||||
|
$formular->setEmailFrom("CMS_VALUE[2]","CMS_VALUE[3]");
|
||||||
|
$formular->setBackgroundError("CMS_VALUE[4]");
|
||||||
|
$formular->setForm("CMS_HTML[0]");
|
||||||
|
$formular->setAnswer("CMS_HTML[1]");
|
||||||
|
$formular->process();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
37
php/murat_input.php
Normale Datei
37
php/murat_input.php
Normale Datei
|
@ -0,0 +1,37 @@
|
||||||
|
?><?php
|
||||||
|
|
||||||
|
/**************************************************
|
||||||
|
* CONTENIDO MODULE - INPUT
|
||||||
|
*
|
||||||
|
* Modulname : w3concepts.form.v1
|
||||||
|
* Author : Andreas Kummer
|
||||||
|
* Copyright : mumprecht & kummer w3concepts
|
||||||
|
* Created : 20-08-2004
|
||||||
|
* Modified : 20-08-2004
|
||||||
|
* Modified : 24-08-2013, Murat Purc, adapted to newer CONTENIDO (4.8) version
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
echo "
|
||||||
|
<table cellspacing='0' cellpadding='10' border='0'>
|
||||||
|
<tr>
|
||||||
|
<td>" . mi18n("Zieladresse (alias@mydomain.com):") . "</td>
|
||||||
|
<td><input type='text' name=\"CMS_VAR[0]\" value=\"CMS_VALUE[0]\" size='30' /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>" . mi18n("Betreff:") . "</td>
|
||||||
|
<td><input type='text' name=\"CMS_VAR[1]\" value=\"CMS_VALUE[1]\" size='30' /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>" . mi18n("Antwortadresse (alias@mydomain.com):") . "</td>
|
||||||
|
<td><input type='text' name=\"CMS_VAR[2]\" value=\"CMS_VALUE[2]\" size='30' /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>" . mi18n("Emailname (z.B. Vorname Name):") . "</td>
|
||||||
|
<td><input type='text' name=\"CMS_VAR[3]\" value=\"CMS_VALUE[3]\" size='30' /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>" . mi18n("Hintergrundfarbe bei Fehlern (z.B. red):") . "</td>
|
||||||
|
<td><input type='text' name=\"CMS_VAR[4]\" value=\"CMS_VALUE[4]\" size='30' /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
";
|
344
php/murat_output.php
Normale Datei
344
php/murat_output.php
Normale Datei
|
@ -0,0 +1,344 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**************************************************
|
||||||
|
* CONTENIDO MODULE - OUTPUT
|
||||||
|
*
|
||||||
|
* Modulname : w3concepts.form.v1
|
||||||
|
* Author : Andreas Kummer
|
||||||
|
* Copyright : mumprecht & kummer w3concepts
|
||||||
|
* Created : 20-08-2004
|
||||||
|
* Modified : 20-08-2004
|
||||||
|
* Modified : 24-08-2013, Murat Purc, adapted to newer CONTENIDO (4.8) and PHP (5.3/5.4) versions
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
class w3form {
|
||||||
|
|
||||||
|
private $email;
|
||||||
|
private $unraveled = array();
|
||||||
|
private $form;
|
||||||
|
private $formField = array();
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->email = array(
|
||||||
|
'adresses' => '',
|
||||||
|
'from' => array(
|
||||||
|
'name' => '',
|
||||||
|
'email' => ''
|
||||||
|
),
|
||||||
|
'message' => '',
|
||||||
|
'subject' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->form = array(
|
||||||
|
'form' => '',
|
||||||
|
'answer' => '',
|
||||||
|
'colorError' => ''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sendEmail() {
|
||||||
|
$this->unravel($this->suppress('sent'));
|
||||||
|
$this->generateEmailMessage();
|
||||||
|
mail(
|
||||||
|
$this->email['adresses'],
|
||||||
|
$this->email['subject'],
|
||||||
|
$this->email['message'],
|
||||||
|
sprintf(
|
||||||
|
"From: %s <%s>\nReply-To: %s\nX-Mailer: PHP/%s",
|
||||||
|
$this->email['from']['name'],
|
||||||
|
$this->email['from']['email'],
|
||||||
|
$this->email['from']['email'],
|
||||||
|
phpversion()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function unravel($toUnravel, $prefix = '') {
|
||||||
|
foreach ($toUnravel as $key => $value) {
|
||||||
|
if (is_array($value)) {
|
||||||
|
$this->unravel($value, $key . ' ');
|
||||||
|
} else {
|
||||||
|
$this->unraveled["{$prefix}{$key}"] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function add2Message($key, $value) {
|
||||||
|
if (strlen($key) > 25 OR strlen($value) > 54) {
|
||||||
|
$this->email['message'] .= "$key\n$value\n";
|
||||||
|
} else {
|
||||||
|
$this->email['message'] .= $key;
|
||||||
|
$this->email['message'] .= str_repeat(' ', 25 - strlen($key));
|
||||||
|
$this->email['message'] .= "$value\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function generateEmailMessage() {
|
||||||
|
if ($this->unraveled)
|
||||||
|
foreach ($this->unraveled as $key => $value) {
|
||||||
|
$this->add2Message($key, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function suppress() {
|
||||||
|
$suppress = func_get_args();
|
||||||
|
foreach ($_POST as $key => $value) {
|
||||||
|
if (array_search($key, $suppress) === false)
|
||||||
|
$fields[$key] = $value;
|
||||||
|
}
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addEmailAdress($email) {
|
||||||
|
if (empty($this->emailAdresses)) {
|
||||||
|
$this->email['adresses'] .= "$email";
|
||||||
|
} else {
|
||||||
|
$this->email['adresses'] .= ", $email";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmailSubject($subject) {
|
||||||
|
$this->email['subject'] = $subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmailFrom($email, $name) {
|
||||||
|
$this->email['from']['email'] = $email;
|
||||||
|
$this->email['from']['name'] = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setForm($form) {
|
||||||
|
$this->form['form'] = $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAnswer($answer) {
|
||||||
|
$this->form['answer'] = $answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBackgroundError($color) {
|
||||||
|
$this->form['colorError'] = $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formInterpretation(&$form) {
|
||||||
|
$fields = explode('###', $form);
|
||||||
|
$field = array();
|
||||||
|
|
||||||
|
for ($i = 1; $i < count($fields); $i = $i + 2) {
|
||||||
|
$attributte = explode(';', trim($fields[$i]));
|
||||||
|
foreach ($attributte as $attribute) {
|
||||||
|
$nameValue = explode(':', trim($attribute));
|
||||||
|
if ($nameValue[0] != 'option' && $nameValue[0] != 'optionvalue') {
|
||||||
|
$field["{$fields[$i]}"]["{$nameValue[0]}"] = $nameValue[1];
|
||||||
|
} else {
|
||||||
|
$field["{$fields[$i]}"]["{$nameValue[0]}"][] = $nameValue[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formOutput($sent = false) {
|
||||||
|
echo '<form action="" method="POST">';
|
||||||
|
echo '<input type="hidden" name="sent" value="true" />';
|
||||||
|
$form = $this->form['form'];
|
||||||
|
$formData = $this->formInterpretation($form);
|
||||||
|
$form = explode('###', $form);
|
||||||
|
|
||||||
|
foreach ($form as $item) {
|
||||||
|
if (!empty($formData["{$item}"])) {
|
||||||
|
$this->formField($formData["{$item}"], $sent);
|
||||||
|
} else {
|
||||||
|
echo $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</form>';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formField($attribute, $sent) {
|
||||||
|
$parameter = "name=\"{$attribute['name']}\"";
|
||||||
|
if ($sent && !$this->formFieldCorrect($attribute))
|
||||||
|
$style = "style=\"background-color:{$this->form['colorError']};\"";
|
||||||
|
|
||||||
|
switch ($attribute['type']) {
|
||||||
|
case 'select':
|
||||||
|
case 'password':
|
||||||
|
case 'text':
|
||||||
|
if (!empty($attribute['size']))
|
||||||
|
$parameter .= " size=\"{$attribute['size']}\"";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($attribute['type']) {
|
||||||
|
case 'textarea':
|
||||||
|
case 'text':
|
||||||
|
if (!empty($attribute['size']))
|
||||||
|
$parameter .= " size=\"{$attribute['size']}\"";
|
||||||
|
if (!empty($attribute['value']))
|
||||||
|
$value = $attribute['value'];
|
||||||
|
if (!empty($_POST["{$attribute['name']}"]))
|
||||||
|
$value = $_POST["{$attribute['name']}"];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($attribute['type']) {
|
||||||
|
case 'text':
|
||||||
|
echo "<input type=\"text\" $parameter value=\"$value\" $style />";
|
||||||
|
break;
|
||||||
|
case 'password':
|
||||||
|
echo "<input type=\"password\" $parameter value=\"$value\" $style />";
|
||||||
|
break;
|
||||||
|
case 'textarea':
|
||||||
|
echo "<textarea name=\"{$attribute['name']}\" cols=\"";
|
||||||
|
echo (empty($attribute['cols'])) ? ('20') : ($attribute['cols']);
|
||||||
|
echo "\" rows=\"";
|
||||||
|
echo (empty($attribute['rows'])) ? ('2') : ($attribute['rows']);
|
||||||
|
echo "\" wrap=\"virtual\" $style>$value</textarea>";
|
||||||
|
break;
|
||||||
|
case 'select':
|
||||||
|
echo "<select $parameter $style>";
|
||||||
|
for ($i = 0; $i < count($attribute['option']); $i++) {
|
||||||
|
if (!empty($attribute['optionvalue'][$i])) {
|
||||||
|
if (!empty($_POST["{$attribute['name']}"]) && $_POST["{$attribute['name']}"] == $attribute['optionvalue'][$i]) {
|
||||||
|
echo "<option value=\"{$attribute['optionvalue'][$i]}\" selected=\"selected\">{$attribute['option'][$i]}</option>\n";
|
||||||
|
} else {
|
||||||
|
if (empty($_POST["{$attribute['name']}"]) && !empty($attribute['optionvalue'][$i]) && $attribute['optionvalue'][$i] == $attribute['value']) {
|
||||||
|
echo "<option value=\"{$attribute['optionvalue'][$i]}\" selected=\"selected\">{$attribute['option'][$i]}</option>\n";
|
||||||
|
} else {
|
||||||
|
echo "<option value=\"{$attribute['optionvalue'][$i]}\">{$attribute['option'][$i]}</option>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!empty($_POST["{$attribute['name']}"]) && $_POST["{$attribute['name']}"] == $attribute['option'][$i]) {
|
||||||
|
echo "<option selected=\"selected\">{$attribute['option'][$i]}</option>\n";
|
||||||
|
} else {
|
||||||
|
if (empty($_POST["{$attribute['name']}"]) && $attribute['option'][$i] == $attribute['value']) {
|
||||||
|
echo "<option selected=\"selected\">{$attribute['option'][$i]}</option>\n";
|
||||||
|
} else {
|
||||||
|
echo "<option>{$attribute['option'][$i]}</option>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</select>";
|
||||||
|
break;
|
||||||
|
case 'checkbox':
|
||||||
|
$formId = preg_split('[\[|\]]', $attribute['name']);
|
||||||
|
if ($sent) {
|
||||||
|
if ($_POST["{$formId[0]}"]["{$formId[1]}"] == $attribute['value']) {
|
||||||
|
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
|
||||||
|
} else {
|
||||||
|
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\"/>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!empty($attribute['selected']) && $attribute['selected'] == 'true') {
|
||||||
|
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
|
||||||
|
} else {
|
||||||
|
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\"/>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'radio':
|
||||||
|
if (!empty($_POST["{$attribute['name']}"])) {
|
||||||
|
if ($_POST["{$attribute['name']}"] == $attribute['value']) {
|
||||||
|
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
|
||||||
|
} else {
|
||||||
|
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" />";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!empty($attribute['selected']) && $attribute['selected'] == 'true') {
|
||||||
|
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
|
||||||
|
} else {
|
||||||
|
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\"/>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function formComplete() {
|
||||||
|
$form = $this->form['form'];
|
||||||
|
$fields = $this->formInterpretation($form);
|
||||||
|
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
if (!$this->formFieldCorrect($field)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function success() {
|
||||||
|
$this->sendEmail();
|
||||||
|
echo $this->form['answer'];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function formFieldCorrect(&$field) {
|
||||||
|
// prüfung, ob pflichtfeld vorhanden
|
||||||
|
if (!empty($field['mandatory']) && $field['mandatory'] == 'true' && empty($_POST["{$field['name']}"]))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// wenn das formularfeld kein pflichtfeld und nicht vorhanden ist, true zurück geben
|
||||||
|
if (empty($_POST["{$field['name']}"]))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// regular expression prüfungen
|
||||||
|
if (!empty($field['valid']) && $field['valid'] == 'simpletext' && !preg_match("/^[öäüéàèâêîça-z-]*$/i", $_POST["{$field['name']}"]))
|
||||||
|
return false;
|
||||||
|
if (!empty($field['valid']) && $field['valid'] == 'text' && !preg_match("/^[ .,;!?()öäüéàèâêîça-z-]*$/i", $_POST["{$field['name']}"]))
|
||||||
|
return false;
|
||||||
|
if (!empty($field['valid']) && $field['valid'] == 'integer' && !preg_match("/^[0-9]*$/", $_POST["{$field['name']}"]))
|
||||||
|
return false;
|
||||||
|
if (!empty($field['valid']) && $field['valid'] == 'float' && !preg_match("/^[0-9]*[.]{0,1}[0-9]*$/", $_POST["{$field['name']}"]))
|
||||||
|
return false;
|
||||||
|
if (!empty($field['valid']) && $field['valid'] == 'date' && !preg_match("/^[0-9]{1,2}.[0-9]{1,2}.[0-9]{2}$/", $_POST["{$field['name']}"]))
|
||||||
|
return false;
|
||||||
|
if (!empty($field['valid']) && $field['valid'] == 'email' && !preg_match("/^[öäüéàèâêîç_a-z0-9-]+(\.[öäüéàèâêîç_a-z0-9-]+)*@[öäüéàèâêîça-z0-9-]+(\.[öäüéàèâêîça-z0-9-]+)*$/i", $_POST["{$field['name']}"]))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// grössenbereich bei integer und float prüfen
|
||||||
|
if (!empty($field['minvalue']) && $_POST["{$field['name']}"] < $field['minvalue'])
|
||||||
|
return false;
|
||||||
|
if (!empty($field['maxvalue']) && $_POST["{$field['name']}"] > $field['maxvalue'])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// längenbereich bei allen typen prüfen
|
||||||
|
if (!empty($field['minlength']) && strlen($_POST["{$field['name']}"]) < $field['minlength'])
|
||||||
|
return false;
|
||||||
|
if (!empty($field['maxlength']) && strlen($_POST["{$field['name']}"]) > $field['maxlength'])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process() {
|
||||||
|
if (!isset($_POST['sent'])) {
|
||||||
|
$this->formOutput();
|
||||||
|
} elseif ($this->formComplete()) {
|
||||||
|
$this->success();
|
||||||
|
} else {
|
||||||
|
$this->formOutput(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($edit) && $edit) {
|
||||||
|
echo "<h1>" . mi18n("Formularkonfiguration") . "</h1>";
|
||||||
|
echo "<p>" . mi18n("Hier ist das Formular sowie der Text einzugeben, der zusammen mit dem Formular ausgegeben werden soll:") . "</p>";
|
||||||
|
echo "CMS_HTML[0]";
|
||||||
|
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->addEmailAdress("CMS_VALUE[0]");
|
||||||
|
$form->setEmailSubject("CMS_VALUE[1]");
|
||||||
|
$form->setEmailFrom("CMS_VALUE[2]", "CMS_VALUE[3]");
|
||||||
|
$form->setBackgroundError("CMS_VALUE[4]");
|
||||||
|
$form->setForm("CMS_HTML[0]");
|
||||||
|
$form->setAnswer("CMS_HTML[1]");
|
||||||
|
$form->process();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren