]> git.p6c8.net - form-email.git/blobdiff - form-email/mailer.php
Ich bin ein Idiot - ich hab nie getestet, was passiert, wenn man die indiv.
[form-email.git] / form-email / mailer.php
index 76fc6480679c555e0bd75d60d9d717c99e65885a..6520dcb595a98277c306dfdf1c34ac31cb1f63a9 100644 (file)
@@ -7,7 +7,7 @@
 # geschrieben wurde.\r
 #\r
 # Autor:            Patrick Canterino <patrick@patshaping.de>\r
-# Letzte Aenderung: 09.01.2012\r
+# Letzte Aenderung: 03.03.2012\r
 #\r
 # Copyright (C) 2002-2012 Patrick Canterino\r
 #\r
@@ -21,7 +21,7 @@
 #  Hauptteil\r
 # ===========\r
 \r
-$VERSION = '3.5-dev';\r
+$VERSION = '3.5';\r
 \r
 require('config.php');\r
 require('functions.php');\r
@@ -91,99 +91,101 @@ if(!filter_var($email,FILTER_VALIDATE_EMAIL)) show_user_error($err_invalid_email
 \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
+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
+        # 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
+        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' => 'not_set', 'INDIVIDUAL' => $user_field));\r
-            }\r
-        }\r
-        else {\r
-            # Wenn das Feld optional ist und nicht gesetzt wurde, brechen wir hier ab\r
-            # und machen mit dem naechsten Feld weiter\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
+                $prepared_user_fields[$user_field_data['tpl_var']] = '';\r
+                continue;\r
+            }\r
         }\r
-    }\r
 \r
-    # Laengen-Pruefung\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
+        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
-    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
+        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
         }\r
-    }\r
 \r
-    # Pruefung gegen frei definierbare Pruef-Funktion\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
+        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
+        # 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
+        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
         }\r
-    }\r
 \r
-    # Formularfeld durch frei definierbare Funktion bearbeiten\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
+        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
-    # Name der Template-Variable ermitteln\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
+        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
@@ -347,7 +349,7 @@ if($recipient && is_array($aliases) && $aliases[$recipient]) {
 $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
@@ -373,7 +375,7 @@ if(isset($store_mails) && $store_mails) {
 \r
     # Daten in Datei schreiben\r
 \r
-    file_put_contents($file_name,$mailtext);\r
+    file_put_contents($file_name,$mailtext) or show_fatal($err_store_error);\r
 \r
     # Alte Dateien loeschen\r
 \r
@@ -464,17 +466,19 @@ else {
     $stpl->set_var('TEXT',   plain($text));\r
     $stpl->set_var('TIME',   plain($time));\r
 \r
-    reset($user_fields);\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
+        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
+            $stpl->set_var($tpl_var,htmlspecialchars(formdata($user_field)));\r
+        }\r
     }\r
 \r
     $stpl->parse();\r

patrick-canterino.de