# geschrieben wurde.\r
#\r
# Autor: Patrick Canterino <patrick@patshaping.de>\r
-# Letzte Aenderung: 16.12.2011\r
+# Letzte Aenderung: 03.03.2012\r
#\r
-# Copyright (C) 2002-2011 Patrick Canterino\r
+# Copyright (C) 2002-2012 Patrick Canterino\r
#\r
# Diese Datei kann unter den Bedingungen der "Artistic License 2.0"\r
# weitergegeben und / oder veraendert werden.\r
# Hauptteil\r
# ===========\r
\r
-$VERSION = '3.5-dev';\r
+$VERSION = '3.5';\r
\r
require('config.php');\r
require('functions.php');\r
\r
$prepared_user_fields = array();\r
\r
-while(list($user_field,$user_field_data) = each($user_fields)) {\r
- $user_field_content = formdata($user_field);\r
- \r
- # Pruefung, ob das Feld gesetzt wurde und ob es optional ist\r
- \r
- if((!$user_field_data['optional']) && (!$user_field_content)) {\r
- show_user_error($user_field_data['errors']['not_set']);\r
- }\r
- elseif($user_field_data['optional'] && (!$user_field_content)) {\r
- # Wenn das Feld optional ist und nicht gesetzt wurde, brechen wir hier ab\r
- # und machen mit dem naechsten Feld weiter\r
- \r
- $prepared_user_fields[$user_field_data['tpl_var']] = '';\r
- continue;\r
- }\r
- \r
- # Laengen-Pruefung\r
- \r
- if(isset($user_field_data['min']) && $user_field_data['min']) {\r
- if(strlen($user_field_content) < $user_field_data['min']) {\r
- if(isset($user_field_data['errors']['too_short'])) {\r
- show_user_error($user_field_data['errors']['too_short']);\r
+if(isset($user_fields)) {\r
+ while(list($user_field,$user_field_data) = each($user_fields)) {\r
+ $user_field_content = formdata($user_field);\r
+\r
+ # Pruefung, ob es ein Pflichtfeld ist\r
+\r
+ if(!$user_field_content) {\r
+ if(isset($user_field_data['required']) && $user_field_data['required']) {\r
+ if(isset($user_field_data['errors']['not_set'])) {\r
+ show_user_error($user_field_data['errors']['not_set']);\r
+ }\r
+ else {\r
+ show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'not_set', 'INDIVIDUAL' => $user_field));\r
+ }\r
}\r
else {\r
- show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'too_short', 'INDIVIDUAL' => $user_field));\r
+ # Wenn das Feld optional ist und nicht gesetzt wurde, brechen wir hier ab\r
+ # und machen mit dem naechsten Feld weiter\r
+\r
+ $prepared_user_fields[$user_field_data['tpl_var']] = '';\r
+ continue;\r
}\r
}\r
- }\r
- \r
- if(isset($user_field_data['min']) && $user_field_data['max']) {\r
- if(strlen($user_field_content) > $user_field_data['max']) {\r
- if(isset($user_field_data['errors']['too_long'])) {\r
- show_user_error($user_field_data['errors']['too_long']);\r
- }\r
- else {\r
- show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'too_long', 'INDIVIDUAL' => $user_field));\r
+\r
+ # Laengen-Pruefung\r
+\r
+ if(isset($user_field_data['min']) && $user_field_data['min']) {\r
+ if(strlen($user_field_content) < $user_field_data['min']) {\r
+ if(isset($user_field_data['errors']['too_short'])) {\r
+ show_user_error($user_field_data['errors']['too_short']);\r
+ }\r
+ else {\r
+ show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'too_short', 'INDIVIDUAL' => $user_field));\r
+ }\r
}\r
}\r
- }\r
- \r
- # Pruefung gegen frei definierbare Pruef-Funktion\r
\r
- if(isset($user_field_data['check']) && $user_field_data['check'] != '') {\r
- if(function_exists($user_field_data['check']) && call_user_func($user_field_data['check'],$user_field_content) === false) {\r
- if(isset($user_field_data['errors']['check_fail'])) {\r
- show_user_error($user_field_data['errors']['check_fail']);\r
+ if(isset($user_field_data['min']) && $user_field_data['max']) {\r
+ if(strlen($user_field_content) > $user_field_data['max']) {\r
+ if(isset($user_field_data['errors']['too_long'])) {\r
+ show_user_error($user_field_data['errors']['too_long']);\r
+ }\r
+ else {\r
+ show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'too_long', 'INDIVIDUAL' => $user_field));\r
+ }\r
}\r
- else {\r
- show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'check_fail', 'INDIVIDUAL' => $user_field));\r
+ }\r
+\r
+ # Pruefung gegen frei definierbare Pruef-Funktion\r
+\r
+ if(isset($user_field_data['check']) && $user_field_data['check'] != '') {\r
+ if(function_exists($user_field_data['check']) && call_user_func($user_field_data['check'],$user_field_content) === false) {\r
+ if(isset($user_field_data['errors']['check_fail'])) {\r
+ show_user_error($user_field_data['errors']['check_fail']);\r
+ }\r
+ else {\r
+ show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'check_fail', 'INDIVIDUAL' => $user_field));\r
+ }\r
}\r
}\r
- }\r
- \r
- # Pruefung gegen frei definierbaren regulaeren Ausdruck\r
\r
- if(isset($user_field_data['regex']) && $user_field_data['regex'] != '') {\r
- if(!preg_match($user_field_data['regex'],$user_field_content)) {\r
- if(isset($user_field_data['errors']['match_fail'])) {\r
- show_user_error($user_field_data['errors']['match_fail']);\r
+ # Pruefung gegen frei definierbaren regulaeren Ausdruck\r
+\r
+ if(isset($user_field_data['regex']) && $user_field_data['regex'] != '') {\r
+ if(!preg_match($user_field_data['regex'],$user_field_content)) {\r
+ if(isset($user_field_data['errors']['match_fail'])) {\r
+ show_user_error($user_field_data['errors']['match_fail']);\r
+ }\r
+ else {\r
+ show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'match_fail', 'INDIVIDUAL' => $user_field));\r
+ }\r
}\r
- else {\r
- show_fatal($err_indiv_errmsg_miss,array('ERRMSG' => 'match_fail', 'INDIVIDUAL' => $user_field));\r
+ }\r
+\r
+ # Formularfeld durch frei definierbare Funktion bearbeiten\r
+\r
+ if(isset($user_field_data['prepare']) && $user_field_data['prepare'] != '') {\r
+ if(function_exists($user_field_data['check'])) {\r
+ $user_field_content = call_user_func($user_field_data['prepare'],$user_field_content);\r
}\r
}\r
- }\r
- \r
- # Formularfeld durch frei definierbare Funktion bearbeiten\r
\r
- if(isset($user_field_data['prepare']) && $user_field_data['prepare'] != '') {\r
- if(function_exists($user_field_data['check'])) {\r
- $user_field_content = call_user_func($user_field_data['prepare'],$user_field_content);\r
+ # Name der Template-Variable ermitteln\r
+\r
+ if(isset($user_field_data['tpl_var']) && $user_field_data['tpl_var'] != '') {\r
+ $tpl_var = $user_field_data['tpl_var'];\r
+ }\r
+ else {\r
+ $tpl_var = 'USER_'.$user_field;\r
}\r
- }\r
- \r
- # Name der Template-Variable ermitteln\r
\r
- if(isset($user_field_data['tpl_var']) && $user_field_data['tpl_var'] != '') {\r
- $tpl_var = $user_field_data['tpl_var'];\r
- }\r
- else {\r
- $tpl_var = 'USER_'.$user_field;\r
- }\r
- \r
- # Fertige Formulardaten wegkopieren und fuer spaeter zur Verfuegung stellen\r
+ # Fertige Formulardaten wegkopieren und fuer spaeter zur Verfuegung stellen\r
\r
- $prepared_user_fields[$tpl_var] = $user_field_content;\r
+ $prepared_user_fields[$tpl_var] = $user_field_content;\r
+ }\r
}\r
\r
# Captcha ueberpruefen\r
else {\r
if(!$captcha_input || empty($captcha_input) || strtolower($captcha_input) != strtolower($_SESSION['captcha'])) $captcha_incorrect = true;\r
}\r
- \r
+\r
if($captcha_incorrect) {\r
if($captcha_max) {\r
if(isset($_SESSION['captcha_failed']) && $_SESSION['captcha_failed']) {\r
if($captcha_max && isset($_SESSION['captcha_failed']) && $_SESSION['captcha_failed'] >= $captcha_max) {\r
show_fatal($err_captcha_max);\r
}\r
- else { \r
+ else {\r
show_user_error($err_captcha_incorrect);\r
}\r
}\r
\r
# Uhrzeit formatieren\r
\r
+$timestamp = time();\r
+\r
date_default_timezone_set($timezone);\r
-$time = strftime($timeformat);\r
+$time = strftime($timeformat,$timestamp);\r
\r
# Header der Mail\r
\r
$mailto = semicolon_split($mailto);\r
\r
for($x=0;$x<count($mailto);$x++) {\r
- mail($mailto[$x],$encoded_subject,$mailtext,$header) or die($err_send_error);\r
+ mail($mailto[$x],$encoded_subject,$mailtext,$header) or show_fatal($err_send_error);\r
+}\r
+\r
+# Mails auf Festplatte speichern\r
+\r
+if(isset($store_mails) && $store_mails) {\r
+ # Standard-Werte fuer einige Variablen\r
+\r
+ if(!isset($store_mails_dir) || $store_mails_dir == '') $store_mails_dir = 'stored_mails';\r
+ if(!isset($store_mails_prefix) || $store_mails_prefix == '') $store_mails_prefix = 'feml_';\r
+\r
+ # Verzeichnis ggf. anlegen\r
+\r
+ if(!is_dir($store_mails_dir)) mkdir($store_mails_dir);\r
+\r
+ # Betreff saeubern\r
+\r
+ $clean_subject = str_replace(' ','_',$subject);\r
+ $clean_subject = preg_replace('/[^a-z0-9\-_]/i','',$clean_subject);\r
+\r
+ # Eindeutigen Dateinamen der Mail zusammensetzen\r
+\r
+ $file_name = $store_mails_dir.'/'.uniqid($store_mails_prefix.$email.'_'.$clean_subject.'_'.strftime('%d%m%Y-%H%M%S',$timestamp));\r
+\r
+ # Daten in Datei schreiben\r
+\r
+ file_put_contents($file_name,$mailtext) or show_fatal($err_store_error);\r
+\r
+ # Alte Dateien loeschen\r
+\r
+ if(isset($store_mails_max) && $store_mails_max > 0) {\r
+ $dp = opendir($store_mails_dir);\r
+\r
+ while($stored_mail_file = readdir($dp)) {\r
+ if($stored_mail_file != '.' && $stored_mail_file != '..' && substr($stored_mail_file,0,strlen($store_mails_prefix)) == $store_mails_prefix) {\r
+ $stored_mail_files[$store_mails_dir.'/'.$stored_mail_file] = filemtime($store_mails_dir.'/'.$stored_mail_file);\r
+ }\r
+ }\r
+\r
+ closedir($dp);\r
+\r
+ arsort($stored_mail_files);\r
+\r
+ $x = 0;\r
+\r
+ foreach(array_keys($stored_mail_files) as $stored_mail_filename) {\r
+ $x++;\r
+\r
+ if($x > $store_mails_max) {\r
+ unlink($stored_mail_filename);\r
+ }\r
+ }\r
+ }\r
}\r
\r
if($captcha_enable) session_destroy();\r
$return_url = $protocol.$http_host.$port.$return_url;\r
}\r
else {\r
- if(substr($_SERVER['SCRIPT_NAME'],-1,1) == '/') $path = substr($_SERVER['SCRIPT_NAME'],0,-1);\r
+ if(substr($_SERVER['SCRIPT_NAME'],-1,1) == '/') {\r
+ $path = substr($_SERVER['SCRIPT_NAME'],0,-1);\r
+ }\r
+ else {\r
+ $path = $_SERVER['SCRIPT_NAME'];\r
+ }\r
+\r
$path = substr($path,0,strrpos($path,'/')+1);\r
if(substr($path,0,1) != '/') $path = '/'.$path;\r
\r
$stpl->set_var('TEXT', plain($text));\r
$stpl->set_var('TIME', plain($time));\r
\r
+ if(isset($user_fields)) {\r
+ reset($user_fields);\r
+\r
+ while(list($user_field,$user_field_data) = each($user_fields)) {\r
+ if(isset($user_field_data['tpl_var']) && $user_field_data['tpl_var'] != '') {\r
+ $tpl_var = $user_field_data['tpl_var'];\r
+ }\r
+ else {\r
+ $tpl_var = 'USER_'.$user_field;\r
+ }\r
+\r
+ $stpl->set_var($tpl_var,htmlspecialchars(formdata($user_field)));\r
+ }\r
+ }\r
+\r
$stpl->parse();\r
\r
print $stpl->get_template();\r