Esempio n. 1
0
     if (strtolower($fs['req']) == 'true' && $t == "") {
         $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
     } else {
         if (strlen($t) > (int) $fs['max']) {
             $errors[] = $fs['max'] . ' ' . DDFM_MAXCHARLIMIT . " '" . $fs['label'] . "'";
         } else {
             if (ddfm_injection_chars($t)) {
                 $errors[] = DDFM_INVALIDINPUT . " '" . $fs['label'] . "'";
             } else {
                 if (strtolower($fs['ver']) == 'email' && (strtolower($fs['req']) == "true" || $t != "")) {
                     if (!dd_is_valid_email($t)) {
                         $errors[] = DDFM_INVALIDEMAIL . " '" . $fs['label'] . "'";
                     }
                 } else {
                     if (strtolower($fs['ver']) == 'url' && (strtolower($fs['req']) == "true" || $t != "")) {
                         if (!ddfm_is_valid_url($t)) {
                             $errors[] = DDFM_INVALIDURL . " '" . $fs['label'] . "'";
                         }
                     }
                 }
             }
         }
     }
     $csv .= str_replace($save_delimiter, ' ', $t) . $save_delimiter;
     $mail_message .= $fs['label'] . $msg_field_sep . $t . $msg_field_line_end;
     $message_structure = ddfm_str_replace($fs['fieldname'], $t, $message_structure);
     $auto_reply_message = ddfm_str_replace($fs['fieldname'], $t, $auto_reply_message);
     $sent_message = ddfm_str_replace($fs['fieldname'], ddfm_bsafe($t), $sent_message);
     break;
 case 'password':
     // type=password|class=|label=|fieldname=|max=|req=(TRUEFALSE)|confirm=(TRUEFALSE)
Esempio n. 2
0
 function generate_data()
 {
     global $form_submitted, $form_input, $show_required;
     // Get local copy of options
     $path_contact_page = get_option($this->var_pre . 'path_contact_page');
     $wrap_messages = get_option($this->var_pre . 'wrap_messages');
     $show_required = get_option($this->var_pre . 'show_required');
     $show_ip_hostname = get_option($this->var_pre . 'show_ip_hostname');
     $recipients = get_option($this->var_pre . 'recipients');
     $form_struct = get_option($this->var_pre . 'form_struct');
     $manual_form_code = get_option($this->var_pre . 'manual_form_code');
     $sender_name = get_option($this->var_pre . 'sender_name');
     $sender_email = get_option($this->var_pre . 'sender_email');
     $email_subject = get_option($this->var_pre . 'email_subject');
     $max_file_size = get_option($this->var_pre . 'max_file_size');
     $save_to_file = get_option($this->var_pre . 'save_to_file');
     $save_email = get_option($this->var_pre . 'save_email');
     $save_path = get_option($this->var_pre . 'save_path');
     $save_delimiter = get_option($this->var_pre . 'save_delimiter');
     $save_newlines = get_option($this->var_pre . 'save_newlines');
     $save_timestamp = get_option($this->var_pre . 'save_timestamp');
     $verify_method = get_option('ddfm_verify_method');
     // convert $form_struct into array of strings
     $form_struct = (array) explode('<br />', nl2br(trim($form_struct)));
     // Prepare globals
     $form_submitted = FALSE;
     // Load language settings
     @(include_once 'lang/' . get_option($this->var_pre . 'language') . '.php');
     $message_sent = FALSE;
     // Prepare output
     $o = "\n\n\n" . '<!-- START of Dagon Design Formmailer output -->' . "\n\n";
     // Convert form structure to multi-dimensional array
     $fs_tmp1 = array();
     $fs_tmp2 = array();
     $fitem = 0;
     foreach ($form_struct as $fs) {
         if (trim($fs) != "") {
             $fs_tmp1 = (array) explode("|", trim($fs));
             foreach ($fs_tmp1 as $fs1) {
                 list($k, $v) = (array) explode("=", trim($fs1), 2);
                 $fs_tmp2[$fitem][$k] = $v;
             }
         }
         $fitem++;
     }
     $form_struct = $fs_tmp2;
     // Make sure form structure is not missing empty keys
     $valid_keys = array('fieldname', 'type', 'req', 'label', 'max', 'ver', 'confirm', 'data', 'multi', 'allowed', 'default');
     for ($i = 0; $i < count($form_struct); $i++) {
         foreach ($valid_keys as $k) {
             if (!isset($form_struct[$i][$k])) {
                 $form_struct[$i][$k] = NULL;
             }
         }
     }
     // Do a quick check to make sure there are no duplicate field names
     $dd_unique_fields = array();
     $dd_unique_test = TRUE;
     foreach ($form_struct as $fs) {
         if ($dd_unique_test && $fs['fieldname'] != NULL && in_array($fs['fieldname'], $dd_unique_fields)) {
             $dd_unique_test = FALSE;
         } else {
             $dd_unique_fields[] = $fs['fieldname'];
         }
     }
     if (!$dd_unique_test) {
         echo '<p>*** ERROR - You have duplicate fieldnames in your form structure ***</p>';
     }
     // Was form submitted?
     if (isset($_POST["form_submitted_" . $this->inst])) {
         $form_submitted = TRUE;
         $csv = "";
         $mail_message = "";
         $auto_reply_message = "";
         $orig_auto_reply_message = trim(get_option($this->var_pre . 'auto_reply_message'));
         // make correct encoding in auto - sokai - BEGIN
         $mime_boundary = md5(time());
         $auto_reply_message .= '--' . $mime_boundary . PHP_EOL;
         $auto_reply_message .= 'Content-Type: text/plain; charset="utf-8"' . PHP_EOL;
         $auto_reply_message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;
         // make correct encoding in auto - sokai - END
         $sent_message = "";
         $attached_files = array();
         $attached_index = 0;
         $sel_recip = NULL;
         $message_structure = trim(get_option($this->var_pre . 'message_structure'));
         $auto_reply_name = trim(get_option($this->var_pre . 'auto_reply_name'));
         $auto_reply_email = trim(get_option($this->var_pre . 'auto_reply_email'));
         $auto_reply_subject = trim(get_option($this->var_pre . 'auto_reply_subject'));
         $auto_reply_message .= trim(get_option($this->var_pre . 'auto_reply_message'));
         $sent_message = trim(get_option($this->var_pre . 'sent_message'));
         unset($errors);
         $errors = array();
         if ($verify_method == 'recaptcha') {
             @(include_once 'recaptchalib.php');
             $privatekey = get_option('ddfm_re_private');
             $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
             if (!$resp->is_valid) {
                 $errors[] = DDFM_INVALIDVER;
             }
         }
         // Get form input and put in array
         foreach ($_POST as $key => $i) {
             if ($key != "form_submitted") {
                 if (!is_array($i)) {
                     $form_input[strtolower($key)] = trim($i);
                 } else {
                     $form_input[strtolower($key)] = $i;
                 }
             }
         }
         $msg_field_sep = ': ';
         $msg_field_line_end = "\n\n";
         $fsindex = -1;
         // Validate input
         foreach ($form_struct as $fs) {
             if (!isset($form_input[$fs['fieldname']])) {
                 $form_input[$fs['fieldname']] = '';
             }
             $fsindex++;
             // check for fields used in vars
             if (isset($form_input[$fs['fieldname']])) {
                 $sender_name = ddfm_str_replace($fs['fieldname'], ddfm_stripslashes($form_input[$fs['fieldname']]), $sender_name);
                 $sender_email = ddfm_str_replace($fs['fieldname'], ddfm_stripslashes($form_input[$fs['fieldname']]), $sender_email);
                 $email_subject = ddfm_str_replace($fs['fieldname'], ddfm_stripslashes($form_input[$fs['fieldname']]), $email_subject);
             }
             switch ($fs['type']) {
                 case 'date':
                     // type=date|class=|label=|fieldname=|req=(TRUEFALSE)
                     $t = ddfm_stripslashes($form_input[$fs['fieldname']]);
                     if (strtolower($fs['req']) == 'true' && $t == "") {
                         $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
                     } else {
                         if (ddfm_injection_chars($t)) {
                             $errors[] = DDFM_INVALIDINPUT . " '" . $fs['label'] . "'";
                         }
                     }
                     $csv .= str_replace($save_delimiter, ' ', $t) . $save_delimiter;
                     $mail_message .= $fs['label'] . $msg_field_sep . $t . $msg_field_line_end;
                     $message_structure = ddfm_str_replace($fs['fieldname'], $t, $message_structure);
                     $auto_reply_message = ddfm_str_replace($fs['fieldname'], $t, $auto_reply_message);
                     $sent_message = ddfm_str_replace($fs['fieldname'], ddfm_bsafe($t), $sent_message);
                     break;
                 case 'text':
                     // type=text|class=|label=|fieldname=|max=|req=(TRUEFALSE)|[ver=]|[default=]
                     $t = ddfm_stripslashes($form_input[$fs['fieldname']]);
                     if (strtolower($fs['req']) == 'true' && $t == "") {
                         $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
                     } else {
                         if (strlen($t) > (int) $fs['max']) {
                             $errors[] = $fs['max'] . ' ' . DDFM_MAXCHARLIMIT . " '" . $fs['label'] . "'";
                         } else {
                             if (ddfm_injection_chars($t)) {
                                 $errors[] = DDFM_INVALIDINPUT . " '" . $fs['label'] . "'";
                             } else {
                                 if (strtolower($fs['ver']) == 'email' && (strtolower($fs['req']) == "true" || $t != "")) {
                                     if (!dd_is_valid_email($t)) {
                                         $errors[] = DDFM_INVALIDEMAIL . " '" . $fs['label'] . "'";
                                     }
                                 } else {
                                     if (strtolower($fs['ver']) == 'url' && (strtolower($fs['req']) == "true" || $t != "")) {
                                         if (!ddfm_is_valid_url($t)) {
                                             $errors[] = DDFM_INVALIDURL . " '" . $fs['label'] . "'";
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $csv .= str_replace($save_delimiter, ' ', $t) . $save_delimiter;
                     $mail_message .= $fs['label'] . $msg_field_sep . $t . $msg_field_line_end;
                     $message_structure = ddfm_str_replace($fs['fieldname'], $t, $message_structure);
                     $auto_reply_message = ddfm_str_replace($fs['fieldname'], $t, $auto_reply_message);
                     $sent_message = ddfm_str_replace($fs['fieldname'], ddfm_bsafe($t), $sent_message);
                     break;
                 case 'password':
                     // type=password|class=|label=|fieldname=|max=|req=(TRUEFALSE)|confirm=(TRUEFALSE)
                     $t = ddfm_stripslashes($form_input[$fs['fieldname']]);
                     if (strtolower($fs['req']) == 'true' && $t == "") {
                         $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
                     } else {
                         if (strlen($t) > (int) $fs['max']) {
                             $errors[] = $fs['max'] . ' ' . DDFM_MAXCHARLIMIT . " '" . $fs['label'] . "'";
                         } else {
                             if (ddfm_injection_chars($t)) {
                                 $errors[] = DDFM_INVALIDINPUT . " '" . $fs['label'] . "'";
                             } else {
                                 if (strtolower($fs['confirm']) == 'true') {
                                     $tc = ddfm_stripslashes($form_input[$fs['fieldname'] . 'c']);
                                     if ($t != $tc) {
                                         $errors[] = DDFM_NOMATCH . " '" . $fs['label'] . "'";
                                     }
                                 }
                             }
                         }
                     }
                     $csv .= str_replace($save_delimiter, ' ', $t) . $save_delimiter;
                     $mail_message .= $fs['label'] . $msg_field_sep . $t . $msg_field_line_end;
                     $message_structure = ddfm_str_replace($fs['fieldname'], $t, $message_structure);
                     $auto_reply_message = ddfm_str_replace($fs['fieldname'], $t, $auto_reply_message);
                     $sent_message = ddfm_str_replace($fs['fieldname'], ddfm_bsafe($t), $sent_message);
                     break;
                 case 'textarea':
                 case 'widetextarea':
                     // type=textarea|class=|label=|fieldname=|max=|rows=|req=(TRUEFALSE)|[default=]
                     $t = ddfm_stripslashes($form_input[$fs['fieldname']]);
                     if (strtolower($fs['req']) == 'true' && $t == "") {
                         $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
                     } else {
                         if (strlen($t) > (int) $fs['max']) {
                             $errors[] = $fs['max'] . ' ' . DDFM_MAXCHARLIMIT . " '" . $fs['label'] . "'";
                         }
                     }
                     $csv .= str_replace($save_delimiter, ' ', $t) . $save_delimiter;
                     $mail_message .= $fs['label'] . $msg_field_sep . $t . $msg_field_line_end;
                     $message_structure = ddfm_str_replace($fs['fieldname'], $t, $message_structure);
                     $auto_reply_message = ddfm_str_replace($fs['fieldname'], $t, $auto_reply_message);
                     $sent_message = ddfm_str_replace($fs['fieldname'], ddfm_bsafe($t), $sent_message);
                     break;
                 case 'verify':
                     // type=verify|class=|label=
                     if ($verify_method == 'basic') {
                         $t = ddfm_stripslashes($form_input['fm_verify']);
                         if ($t == "") {
                             $errors[] = DDFM_MISSINGVER;
                         } else {
                             if (trim($_COOKIE["ddfmcode"]) == "") {
                                 $errors[] = DDFM_NOVERGEN;
                             } else {
                                 if ($_COOKIE["ddfmcode"] != md5(strtoupper($t))) {
                                     $errors[] = DDFM_INVALIDVER;
                                 }
                             }
                         }
                     }
                     break;
                 case 'checkbox':
                     //  type=checkbox|class=|label=|data=
                     //	  (fieldname),(text),(CHECKED),(REQUIRED),
                     //	  (fieldname),(text),(CHECKED),(REQUIRED),
                     //	  (fieldname),(text),(CHECKED),(REQUIRED)
                     // ### following three lines edited in order to have commas in the values, add by MG ###
                     $fs['data'] = str_replace(",,", "C0mM@", $fs['data']);
                     $data = explode(",", trim($fs['data']));
                     $data = str_replace("C0mM@", ",", $data);
                     $tmp_msg = array();
                     $checkBoxChecked = false;
                     //### added by MG ###
                     for ($i = 0; $i < count($data); $i += 4) {
                         $t = '';
                         if (isset($form_input[$data[$i]])) {
                             $t = ddfm_stripslashes(trim($form_input[$data[$i]]));
                         }
                         if (strtolower($data[$i + 3]) == 'true' && $t == "") {
                             $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
                         }
                         if ($t != "") {
                             $tmp_msg[] = $t;
                             $checkBoxChecked = true;
                             //### added by MG ###
                         }
                         $message_structure = ddfm_str_replace($data[$i], $t, $message_structure);
                         $auto_reply_message = ddfm_str_replace($data[$i], $t, $auto_reply_message);
                         $sent_message = ddfm_str_replace($data[$i], ddfm_bsafe($t), $sent_message);
                     }
                     // ### start of changes by MG ###
                     if (strtolower($fs['req']) == 'true' && !$checkBoxChecked) {
                         $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
                     }
                     // ### end of changes by MG ###
                     $csv .= str_replace($save_delimiter, ' ', implode(', ', $tmp_msg)) . $save_delimiter;
                     $mail_message .= $fs['label'] . $msg_field_sep . implode(', ', $tmp_msg) . $msg_field_line_end;
                     break;
                 case 'radio':
                     //  type=radio|class=|label=|fieldname=|req=|[default=]|data=
                     //	  (text),(text),(text),(text)
                     $t = ddfm_stripslashes(trim($form_input[$fs['fieldname']]));
                     if (strtolower($fs['req']) == 'true' && $t == "") {
                         $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
                     }
                     $csv .= str_replace($save_delimiter, ' ', $t) . $save_delimiter;
                     $mail_message .= $fs['label'] . $msg_field_sep . $t . $msg_field_line_end;
                     $message_structure = ddfm_str_replace($fs['fieldname'], $t, $message_structure);
                     $auto_reply_message = ddfm_str_replace($fs['fieldname'], $t, $auto_reply_message);
                     $sent_message = ddfm_str_replace($fs['fieldname'], ddfm_bsafe($t), $sent_message);
                     break;
                 case 'select':
                     //  type=select|class=|label=|fieldname=|multi=(TRUEFALSE)|data=
                     //    (#group),(text),(text),(#group),(text),(text)
                     $data = explode(",", trim($fs['data']));
                     if (strtolower($fs['multi']) != 'true') {
                         $t = ddfm_stripslashes($form_input[$fs['fieldname']]);
                         $first_item = $data[0];
                         if (strtolower($fs['req']) == 'true' && ($t == "" || $t == $first_item)) {
                             $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
                         }
                         $csv .= str_replace($save_delimiter, ' ', $t) . $save_delimiter;
                         $mail_message .= $fs['label'] . $msg_field_sep . $t . $msg_field_line_end;
                         $message_structure = ddfm_str_replace($fs['fieldname'], $t, $message_structure);
                         $auto_reply_message = ddfm_str_replace($fs['fieldname'], $t, $auto_reply_message);
                         $sent_message = ddfm_str_replace($fs['fieldname'], ddfm_bsafe($t), $sent_message);
                     } else {
                         // multi = true
                         $t = (array) $form_input[$fs['fieldname']];
                         if (count($t) == 1 && $t[0] == '') {
                             unset($t[0]);
                         }
                         if (strtolower($fs['req']) == 'true' && count($t) == 0) {
                             $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
                         }
                         $tmp_msg = array();
                         foreach ($t as $tt) {
                             if ($tt != "") {
                                 $tmp_msg[] = $tt;
                             }
                         }
                         $csv .= str_replace($save_delimiter, ' ', implode(', ', $tmp_msg)) . $save_delimiter;
                         $mail_message .= $fs['label'] . $msg_field_sep . implode(', ', $tmp_msg) . $msg_field_line_end;
                         $message_structure = ddfm_str_replace($fs['fieldname'], implode(', ', $tmp_msg), $message_structure);
                         $auto_reply_message = ddfm_str_replace($fs['fieldname'], implode(', ', $tmp_msg), $auto_reply_message);
                         $sent_message = ddfm_str_replace($fs['fieldname'], ddfm_bsafe(implode(', ', $tmp_msg)), $sent_message);
                     }
                     break;
                 case 'file':
                     // type=file|class=|label=|fieldname=|[req=]|[allowed=1,2,3]
                     if (strtolower($fs['req']) == 'true' && $_FILES[$fs['fieldname']]['name'] == "") {
                         $errors[] = DDFM_MISSINGFILE . " '" . $fs['label'] . "'";
                     }
                     $allowed = array();
                     if (trim($fs['allowed']) != "") {
                         $allowed = (array) explode(",", trim(strtolower($fs['allowed'])));
                     }
                     if ($_FILES[$fs['fieldname']]['name'] != "" && (int) $_FILES[$fs['fieldname']]['size'] == 0) {
                         $errors[] = DDFM_FILETOOBIG . ' ' . $_FILES[$fs['fieldname']]['name'];
                     } else {
                         if ($_FILES[$fs['fieldname']]['tmp_name'] != "") {
                             if ($_FILES[$fs['fieldname']]['error'] == UPLOAD_ERR_OK && $_FILES[$fs['fieldname']]['size'] > 0) {
                                 $origfilename = $_FILES[$fs['fieldname']]['name'];
                                 $filename = explode(".", $_FILES[$fs['fieldname']]['name']);
                                 $filenameext = $filename[count($filename) - 1];
                                 unset($filename[count($filename) - 1]);
                                 $filename = implode(".", $filename);
                                 $filename = substr($filename, 0, 15) . "." . $filenameext;
                                 $file_ext_allow = TRUE;
                                 if (count($allowed) > 0) {
                                     $file_ext_allow = FALSE;
                                     for ($x = 0; $x < count($allowed); $x++) {
                                         if (strtolower($filenameext) == strtolower($allowed[$x])) {
                                             $file_ext_allow = TRUE;
                                         }
                                     }
                                 }
                                 if ($file_ext_allow) {
                                     if ((int) $_FILES[$fs['fieldname']]['size'] < $max_file_size) {
                                         $attached_files[$attached_index]['file'] = $_FILES[$fs['fieldname']]['name'];
                                         $attached_files[$attached_index]['tmpfile'] = $_FILES[$fs['fieldname']]['tmp_name'];
                                         $attached_files[$attached_index]['content_type'] = $_FILES[$fs['fieldname']]['type'];
                                         $attached_index++;
                                         $csv .= str_replace($save_delimiter, ' ', $_FILES[$fs['fieldname']]['name']) . $save_delimiter;
                                         $attach_save = (bool) get_option($this->var_pre . 'attach_save');
                                         if (!$attach_save) {
                                             $mail_message .= DDFM_ATTACHED . $msg_field_sep . $_FILES[$fs['fieldname']]['name'] . $msg_field_line_end;
                                         } else {
                                             $mail_message .= $fs['label'] . $msg_field_sep . $_FILES[$fs['fieldname']]['name'] . $msg_field_line_end;
                                         }
                                         $message_structure = ddfm_str_replace($fs['fieldname'], $_FILES[$fs['fieldname']]['name'], $message_structure);
                                         $auto_reply_message = ddfm_str_replace($fs['fieldname'], $_FILES[$fs['fieldname']]['name'], $auto_reply_message);
                                         $sent_message = ddfm_str_replace($fs['fieldname'], $_FILES[$fs['fieldname']]['name'], $sent_message);
                                     } else {
                                         $errors[] = DDFM_FILETOOBIG . ' ' . $_FILES[$fs['fieldname']]['name'];
                                     }
                                 } else {
                                     $errors[] = DDFM_INVALIDEXT . ' ' . $_FILES[$fs['fieldname']]['name'];
                                 }
                             } else {
                                 $errors[] = DDFM_UPLOADERR . ' ' . $_FILES[$fs['fieldname']]['name'];
                             }
                         }
                     }
                     /* handled above
                     			$csv .= str_replace($save_delimiter, ' ', $_FILES[$fs['fieldname']]['name']) . $save_delimiter;
                     			$mail_message .= $fs['label'] . $msg_field_sep . $_FILES[$fs['fieldname']]['name'] . $msg_field_line_end;
                     			$message_structure = ddfm_str_replace($fs['fieldname'], $_FILES[$fs['fieldname']]['name'], $message_structure);
                     			$auto_reply_message = ddfm_str_replace($fs['fieldname'], $_FILES[$fs['fieldname']]['name'], $auto_reply_message);
                     			$sent_message = ddfm_str_replace($fs['fieldname'], $_FILES[$fs['fieldname']]['name'], $sent_message);
                     			*/
                     break;
                 case 'selrecip':
                     //  type=selrecip|class=|label=|data=(select),User1,user1@domain.com,User2 etc..
                     $data = explode(",", trim($fs['data']));
                     $t = ddfm_stripslashes($form_input['fm_selrecip']);
                     if ($t == "" || $t == $data[0]) {
                         $errors[] = DDFM_MISSINGFIELD . " '" . $fs['label'] . "'";
                     } else {
                         for ($i = 1; $i < count($data); $i += 2) {
                             if ($data[$i] == $t) {
                                 $sel_recip = trim($data[$i + 1]);
                             }
                         }
                     }
                     break;
             }
         }
         // make sure no un-used fieldnames are left in template
         foreach ($form_struct as $fs) {
             $message_structure = ddfm_str_replace($fs['fieldname'], '', $message_structure);
             $auto_reply_message = ddfm_str_replace($fs['fieldname'], '', $auto_reply_message);
             $sent_message = ddfm_str_replace($fs['fieldname'], '', $sent_message);
         }
         if (ddfm_injection_chars($sender_name)) {
             $errors[] = DDFM_INVALIDINPUT;
         }
         if (ddfm_injection_chars($sender_email)) {
             $errors[] = DDFM_INVALIDINPUT;
         }
         if (ddfm_injection_chars($email_subject)) {
             $errors[] = DDFM_INVALIDINPUT;
         }
         if ($errors) {
             $o .= '<div class="ddfmwrap"><div class="ddfmerrors">' . DDFM_ERRORMSG . '</div>';
             $o .= '<div class="errorlist">';
             foreach ($errors as $err) {
                 $o .= $err . '<br />';
             }
             $o .= '</div><div style="clear:both;"><!-- --></div></div>';
         } else {
             if ($wrap_messages) {
                 $mail_message = wordwrap($mail_message, 70);
             }
             if ($recipients == 'selrecip') {
                 $recipients = $sel_recip;
             }
             // if template exists, use it instead
             if (strlen(trim($message_structure)) > 0) {
                 $mail_message = $message_structure . "\n\n";
             }
             if ($show_ip_hostname) {
                 $mail_message .= 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n" . 'HOST: ' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "\n\n";
             }
             $sndmsg = TRUE;
             if ($save_to_file == TRUE && $save_email == FALSE) {
                 $sndmsg = FALSE;
             }
             $csv = str_replace("\n", $save_newlines, $csv);
             $csv = str_replace("\r", '', $csv);
             $csv = substr($csv, 0, strlen($csv) - strlen($save_delimiter));
             if (trim($save_timestamp) != '') {
                 $csv = date($save_timestamp) . $save_delimiter . $csv;
             }
             if (is_writable($save_path)) {
                 $handle = fopen($save_path, 'a+');
                 fwrite($handle, $csv . "\n");
                 fclose($handle);
             }
             $show_url = (bool) get_option($this->var_pre . 'show_url');
             if ($show_url == TRUE) {
                 $mail_message .= "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
             }
             if ($sndmsg == TRUE) {
                 $attach_path = trim(get_option($this->var_pre . 'attach_path'));
                 $attach_save = trim(get_option($this->var_pre . 'attach_save'));
                 if (ddfm_send_mail($recipients, $sender_name, $sender_email, $email_subject, $mail_message, $attach_save, $attach_path, $attached_files)) {
                     $o .= $sent_message;
                     if ($orig_auto_reply_message != "" && trim($sender_email != "")) {
                         $auto_reply_headers = '';
                         $auto_reply_headers .= 'From: ' . $auto_reply_name . ' <' . $auto_reply_email . '>' . PHP_EOL;
                         $auto_reply_headers .= 'Reply-To: ' . $auto_reply_name . ' <' . $auto_reply_email . '>' . PHP_EOL;
                         $auto_reply_headers .= 'Return-Path: ' . $auto_reply_name . ' <' . $auto_reply_email . '>' . PHP_EOL;
                         $auto_reply_headers .= "Message-ID: <" . time() . "ddfm@" . $_SERVER['SERVER_NAME'] . ">" . PHP_EOL;
                         $auto_reply_headers .= 'X-Sender-IP: ' . $_SERVER["REMOTE_ADDR"] . PHP_EOL;
                         $auto_reply_headers .= "X-Mailer: PHP v" . phpversion() . PHP_EOL;
                         $auto_reply_headers .= 'MIME-Version: 1.0' . PHP_EOL;
                         $auto_reply_headers .= 'Content-Type: multipart/related; boundary="' . $mime_boundary . '"';
                         // $auto_reply_headers .= 'Content-Type: text/plain; charset=utf-8';
                         // make correct encoding in auto - sokai - BEGIN
                         //$auto_reply_message .= PHP_EOL . PHP_EOL;
                         $auto_reply_message .= PHP_EOL . PHP_EOL . '--' . $mime_boundary . '--' . PHP_EOL . PHP_EOL;
                         // make correct encoding in auto - sokai - END
                         mail($sender_email, $auto_reply_subject, $auto_reply_message, $auto_reply_headers);
                     }
                     $message_sent = TRUE;
                 } else {
                     $o .= DDFM_SERVERERR;
                     $message_sent = FALSE;
                 }
             } else {
                 $o .= $sent_message;
             }
         }
     }
     // end of form submission processing
     // Generate form if message has not been sent
     if (!$message_sent) {
         if ($verify_method == 'basic' && !ddfm_check_gd_support()) {
             $o .= DDFM_GDERROR;
         }
         if (trim($manual_form_code) == '') {
             // ** Use normal form generation
             $o .= '<div class="ddfmwrap">';
             $o .= '<form class="ddfm" method="post" action="' . $path_contact_page . '" enctype="multipart/form-data">' . "\n\n";
             // Loop through form items
             foreach ($form_struct as $f_i) {
                 switch ($f_i['type']) {
                     case 'html':
                         $o .= $this->ddfm_gen_html($f_i);
                         break;
                     case 'date':
                         $o .= $this->ddfm_gen_date($f_i);
                         break;
                     case 'text':
                         $o .= $this->ddfm_gen_text($f_i);
                         break;
                     case 'password':
                         $o .= $this->ddfm_gen_password($f_i);
                         break;
                     case 'textarea':
                         $o .= $this->ddfm_gen_textarea($f_i);
                         break;
                     case 'widetextarea':
                         $o .= $this->ddfm_gen_widetextarea($f_i);
                         break;
                     case 'verify':
                         $o .= $this->ddfm_gen_verify($f_i);
                         break;
                     case 'fullblock':
                         $o .= $this->ddfm_gen_fullblock($f_i);
                         break;
                     case 'halfblock':
                         $o .= $this->ddfm_gen_halfblock($f_i);
                         break;
                     case 'openfieldset':
                         $o .= $this->ddfm_gen_openfieldset($f_i);
                         break;
                     case 'closefieldset':
                         $o .= $this->ddfm_gen_closefieldset($f_i);
                         break;
                     case 'checkbox':
                         $o .= $this->ddfm_gen_checkbox($f_i);
                         break;
                     case 'radio':
                         $o .= $this->ddfm_gen_radio($f_i);
                         break;
                     case 'select':
                         $o .= $this->ddfm_gen_select($f_i);
                         break;
                     case 'file':
                         $o .= $this->ddfm_gen_file($f_i);
                         break;
                     case 'selrecip':
                         $o .= $this->ddfm_gen_selrecip($f_i);
                         break;
                 }
             }
             if ($verify_method == 'recaptcha') {
                 $o .= "<script>\r\n\t\t\t\tvar RecaptchaOptions = {\r\n\t\t\t    theme : 'white'\r\n\t\t\t\t};\r\n\t\t\t\t</script>";
                 @(include_once 'recaptchalib.php');
                 $publickey = get_option('ddfm_re_public');
                 $o .= '<div class="recaptcha"><div class="recaptcha-inner">';
                 $o .= recaptcha_get_html($publickey);
                 $o .= '</div></div>';
             }
             $o .= "\n\n" . '<p><input type="hidden" name="MAX_FILE_SIZE" value="' . $max_file_size . '" /></p>' . "\n";
             $o .= '<div class="submit"><input type="submit" name="form_submitted_' . $this->inst . '" value="' . DDFM_SUBMITBUTTON . '" /></div>' . "\n\n";
             $o .= '<div class="credits">' . DDFM_CREDITS . ' <a href="http://www.dagondesign.com" title="Dagon Design">Dagon Design</a></div>' . "\n\n";
             $o .= '</form>';
             $o .= '</div>' . "\n\n";
         } else {
             // Use manual form code
             $o .= stripslashes($manual_form_code);
         }
         // Form generation complete
     }
     // end of display form code
     $o .= '<!-- END of Dagon Design Formmailer output -->' . "\n\n\n";
     return $o;
 }