form_name))."_"; $attachment_urls = array(); if (isset($_POST["a_form_attachment_urls"]) && $_POST["a_form_attachment_urls"] != "") { $attachment_urls = explode("::", ($_POST["a_form_attachment_urls"])); } $all_fields = AFormsTomM8::get_results("a_form_fields", "*", "form_id='".$atts["id"]."'"); foreach ($all_fields as $field) { $field_name = str_replace(" ", "_", strtolower($field->field_label)); if ($field->field_type == "file") { // Upload file. try { $filedst = AFormHelper::upload_file($form_name.$field_name, $field->file_ext_allowed); // Set global variable to have location so that if this is the last section, the system will know which file was just uploaded. $GLOBALS["upload_".$form_name.$field_name] = $filedst; array_push($attachment_urls, $form_name.$field_name."=>".$filedst); } catch(Exception $ex) { $_SESSION[$form_name.$field_name."_error"] = $ex->getMessage(); throw new Exception($ex->getMessage()); } } } return $attachment_urls; } public static function submitAction($atts) { $current_datetime = gmdate( 'Y-m-d H:i:s'); $email_content = AFormHelper::create_email_content($atts); $form = AFormsTomM8::get_row_by_id("a_form_forms", "*", "ID", $atts["id"]); $form_name = "a_form_".str_replace(" ", "_", strtolower($form->form_name))."_"; $field_values = $GLOBALS["a_form_field_values"]; // User clicked Send, so since form is valid and they click Send, send the email. $subject = $form->subject; $from_name = ""; $user_email = ""; if ($form->field_name_id != "") { $row = AFormsTomM8::get_row_by_id("a_form_fields", "*", "FID", $form->field_name_id); $from_name = ($_POST[$form_name.str_replace(" ", "_", strtolower($row->field_label))]); } if ($form->field_email_id != "") { $row = AFormsTomM8::get_row_by_id("a_form_fields", "*", "FID", $form->field_email_id); $user_email = ($_POST[$form_name.str_replace(" ", "_", strtolower($row->field_label))]); } if ($form->field_subject_id != "") { $row = AFormsTomM8::get_row_by_id("a_form_fields", "*", "FID", $form->field_subject_id); if (isset($_POST[$form_name.str_replace(" ", "_", strtolower($row->field_label))])) { $subject .= " - ".($_POST[$form_name.str_replace(" ", "_", strtolower($row->field_label))]); } } if ($form->confirmation_from_email != "") { $from_email = $form->confirmation_from_email; } // Send Email. $cc_emails = $form->to_cc_email; if ($user_email != "" && $form->send_confirmation_email) { if ($cc_emails == "") { $cc_emails .= $user_email; } else { $cc_emails .= ", ".$user_email; } } if ($cc_emails == "") { $cc_emails .= $from_email; } else { $cc_emails .= ", ".$from_email; } $secure_algorithms = array(); if (get_option("a_forms_enable_tls")) { $secure_algorithms["tls"] = "tls"; } if (get_option("a_forms_enable_ssl")) { $secure_algorithms["ssl"] = "ssl"; } $mail_message = "