From 5708186b376ec6b2c67d01a88d35f8cf34009aa0 Mon Sep 17 00:00:00 2001 From: Patrick Canterino Date: Sat, 3 Mar 2012 13:06:24 +0000 Subject: [PATCH 1/1] Ich bin ein Idiot - ich hab nie getestet, was passiert, wenn man die indiv. Formularfelder abschaltet... --- form-email/functions.php | 22 +++--- form-email/mailer.php | 154 ++++++++++++++++++++------------------- 2 files changed, 91 insertions(+), 85 deletions(-) diff --git a/form-email/functions.php b/form-email/functions.php index d9f3482..ad330eb 100644 --- a/form-email/functions.php +++ b/form-email/functions.php @@ -7,7 +7,7 @@ # geschrieben wurde. # # Autor: Patrick Canterino -# Letzte Aenderung: 17.12.2011 +# Letzte Aenderung: 03.03.2012 # # Copyright (C) 2002-2012 Patrick Canterino # @@ -144,17 +144,19 @@ function show_user_error($errmsg) { $tpl->set_var('SUBJECT',htmlspecialchars($subject)); $tpl->set_var('TEXT', htmlspecialchars($text)); - reset($user_fields); + if(isset($user_fields)) { + reset($user_fields); - while(list($user_field,$user_field_data) = each($user_fields)) { - if(isset($user_field_data['tpl_var']) && $user_field_data['tpl_var'] != '') { - $tpl_var = $user_field_data['tpl_var']; - } - else { - $tpl_var = 'USER_'.$user_field; - } + while(list($user_field,$user_field_data) = each($user_fields)) { + if(isset($user_field_data['tpl_var']) && $user_field_data['tpl_var'] != '') { + $tpl_var = $user_field_data['tpl_var']; + } + else { + $tpl_var = 'USER_'.$user_field; + } - $tpl->set_var($tpl_var,htmlspecialchars(formdata($user_field))); + $tpl->set_var($tpl_var,htmlspecialchars(formdata($user_field))); + } } $tpl->parse(); diff --git a/form-email/mailer.php b/form-email/mailer.php index 4d2e500..6520dcb 100644 --- a/form-email/mailer.php +++ b/form-email/mailer.php @@ -7,7 +7,7 @@ # geschrieben wurde. # # Autor: Patrick Canterino -# Letzte Aenderung: 05.02.2012 +# Letzte Aenderung: 03.03.2012 # # Copyright (C) 2002-2012 Patrick Canterino # @@ -91,99 +91,101 @@ if(!filter_var($email,FILTER_VALIDATE_EMAIL)) show_user_error($err_invalid_email $prepared_user_fields = array(); -while(list($user_field,$user_field_data) = each($user_fields)) { - $user_field_content = formdata($user_field); +if(isset($user_fields)) { + while(list($user_field,$user_field_data) = each($user_fields)) { + $user_field_content = formdata($user_field); - # Pruefung, ob es ein Pflichtfeld ist + # Pruefung, ob es ein Pflichtfeld ist - if(!$user_field_content) { - if(isset($user_field_data['required']) && $user_field_data['required']) { - if(isset($user_field_data['errors']['not_set'])) { - show_user_error($user_field_data['errors']['not_set']); + if(!$user_field_content) { + if(isset($user_field_data['required']) && $user_field_data['required']) { + if(isset($user_field_data['errors']['not_set'])) { + show_user_error($user_field_data['errors']['not_set']); + } + else { + show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'not_set', 'INDIVIDUAL' => $user_field)); + } } else { - show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'not_set', 'INDIVIDUAL' => $user_field)); - } - } - else { - # Wenn das Feld optional ist und nicht gesetzt wurde, brechen wir hier ab - # und machen mit dem naechsten Feld weiter + # Wenn das Feld optional ist und nicht gesetzt wurde, brechen wir hier ab + # und machen mit dem naechsten Feld weiter - $prepared_user_fields[$user_field_data['tpl_var']] = ''; - continue; + $prepared_user_fields[$user_field_data['tpl_var']] = ''; + continue; + } } - } - # Laengen-Pruefung + # Laengen-Pruefung - if(isset($user_field_data['min']) && $user_field_data['min']) { - if(strlen($user_field_content) < $user_field_data['min']) { - if(isset($user_field_data['errors']['too_short'])) { - show_user_error($user_field_data['errors']['too_short']); - } - else { - show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'too_short', 'INDIVIDUAL' => $user_field)); + if(isset($user_field_data['min']) && $user_field_data['min']) { + if(strlen($user_field_content) < $user_field_data['min']) { + if(isset($user_field_data['errors']['too_short'])) { + show_user_error($user_field_data['errors']['too_short']); + } + else { + show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'too_short', 'INDIVIDUAL' => $user_field)); + } } } - } - if(isset($user_field_data['min']) && $user_field_data['max']) { - if(strlen($user_field_content) > $user_field_data['max']) { - if(isset($user_field_data['errors']['too_long'])) { - show_user_error($user_field_data['errors']['too_long']); - } - else { - show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'too_long', 'INDIVIDUAL' => $user_field)); + if(isset($user_field_data['min']) && $user_field_data['max']) { + if(strlen($user_field_content) > $user_field_data['max']) { + if(isset($user_field_data['errors']['too_long'])) { + show_user_error($user_field_data['errors']['too_long']); + } + else { + show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'too_long', 'INDIVIDUAL' => $user_field)); + } } } - } - # Pruefung gegen frei definierbare Pruef-Funktion + # Pruefung gegen frei definierbare Pruef-Funktion - if(isset($user_field_data['check']) && $user_field_data['check'] != '') { - if(function_exists($user_field_data['check']) && call_user_func($user_field_data['check'],$user_field_content) === false) { - if(isset($user_field_data['errors']['check_fail'])) { - show_user_error($user_field_data['errors']['check_fail']); - } - else { - show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'check_fail', 'INDIVIDUAL' => $user_field)); + if(isset($user_field_data['check']) && $user_field_data['check'] != '') { + if(function_exists($user_field_data['check']) && call_user_func($user_field_data['check'],$user_field_content) === false) { + if(isset($user_field_data['errors']['check_fail'])) { + show_user_error($user_field_data['errors']['check_fail']); + } + else { + show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'check_fail', 'INDIVIDUAL' => $user_field)); + } } } - } - # Pruefung gegen frei definierbaren regulaeren Ausdruck + # Pruefung gegen frei definierbaren regulaeren Ausdruck - if(isset($user_field_data['regex']) && $user_field_data['regex'] != '') { - if(!preg_match($user_field_data['regex'],$user_field_content)) { - if(isset($user_field_data['errors']['match_fail'])) { - show_user_error($user_field_data['errors']['match_fail']); - } - else { - show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'match_fail', 'INDIVIDUAL' => $user_field)); + if(isset($user_field_data['regex']) && $user_field_data['regex'] != '') { + if(!preg_match($user_field_data['regex'],$user_field_content)) { + if(isset($user_field_data['errors']['match_fail'])) { + show_user_error($user_field_data['errors']['match_fail']); + } + else { + show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'match_fail', 'INDIVIDUAL' => $user_field)); + } } } - } - # Formularfeld durch frei definierbare Funktion bearbeiten + # Formularfeld durch frei definierbare Funktion bearbeiten - if(isset($user_field_data['prepare']) && $user_field_data['prepare'] != '') { - if(function_exists($user_field_data['check'])) { - $user_field_content = call_user_func($user_field_data['prepare'],$user_field_content); + if(isset($user_field_data['prepare']) && $user_field_data['prepare'] != '') { + if(function_exists($user_field_data['check'])) { + $user_field_content = call_user_func($user_field_data['prepare'],$user_field_content); + } } - } - # Name der Template-Variable ermitteln + # Name der Template-Variable ermitteln - if(isset($user_field_data['tpl_var']) && $user_field_data['tpl_var'] != '') { - $tpl_var = $user_field_data['tpl_var']; - } - else { - $tpl_var = 'USER_'.$user_field; - } + if(isset($user_field_data['tpl_var']) && $user_field_data['tpl_var'] != '') { + $tpl_var = $user_field_data['tpl_var']; + } + else { + $tpl_var = 'USER_'.$user_field; + } - # Fertige Formulardaten wegkopieren und fuer spaeter zur Verfuegung stellen + # Fertige Formulardaten wegkopieren und fuer spaeter zur Verfuegung stellen - $prepared_user_fields[$tpl_var] = $user_field_content; + $prepared_user_fields[$tpl_var] = $user_field_content; + } } # Captcha ueberpruefen @@ -464,17 +466,19 @@ else { $stpl->set_var('TEXT', plain($text)); $stpl->set_var('TIME', plain($time)); - reset($user_fields); + if(isset($user_fields)) { + reset($user_fields); - while(list($user_field,$user_field_data) = each($user_fields)) { - if(isset($user_field_data['tpl_var']) && $user_field_data['tpl_var'] != '') { - $tpl_var = $user_field_data['tpl_var']; - } - else { - $tpl_var = 'USER_'.$user_field; - } + while(list($user_field,$user_field_data) = each($user_fields)) { + if(isset($user_field_data['tpl_var']) && $user_field_data['tpl_var'] != '') { + $tpl_var = $user_field_data['tpl_var']; + } + else { + $tpl_var = 'USER_'.$user_field; + } - $stpl->set_var($tpl_var,htmlspecialchars(formdata($user_field))); + $stpl->set_var($tpl_var,htmlspecialchars(formdata($user_field))); + } } $stpl->parse(); -- 2.34.1