function build_message($request_input) { if (!isset($message_output)) { $message_output = ""; } if (!is_array($request_input)) { $message_output = $request_input; } else { foreach ($request_input as $key => $value) { if (!empty($value)) { if (!is_numeric($key)) { $message_output .= str_replace("_", " ", ucfirst($key)) . ": " . build_message($value) . PHP_EOL . PHP_EOL; } else { $message_output .= build_message($value) . ", "; } } } } return rtrim($message_output, ", "); }
function build_message($request_input) { global $colon_sep; global $html_format; global $table_left_column_color; global $table_left_column_font; global $table_left_column_font_size; global $table_left_column_font_color; global $table_right_column_color; global $table_right_column_font; global $table_right_column_font_size; global $table_right_column_font_color; global $line_space; global $show_blank_fields; if (!isset($message_output)) { $message_output = ""; } if (!is_array($request_input)) { $message_output = $request_input; } else { foreach ($request_input as $key => $value) { if (!empty($value) || $show_blank_fields) { if ($html_format) { if (!is_numeric($key)) { $message_output .= "<tr><td valign=\"top\" bgcolor=\"" . $table_left_column_color . "\" nowrap><font face=\"" . $table_left_column_font . "\" size=\"" . $table_left_column_font_size . "\" color=\"" . $table_left_column_font_color . "\"><b>" . str_replace("_", " ", ucfirst($key)) . "</b></font></td><td bgcolor=\"" . $table_right_column_color . "\"><font face=\"" . $table_right_column_font . "\" size=\"" . $table_right_column_font_size . "\" color=\"" . $table_right_column_font_color . "\">" . build_message($value) . "</font></td></tr>" . PHP_EOL; } else { $message_output .= "<table><tr><td><font face=\"" . $table_right_column_font . "\" size=\"" . $table_right_column_font_size . "\" color=\"" . $table_right_column_font_color . "\">" . build_message($value) . "</font></td></tr></table>"; } } else { if (!is_numeric($key)) { $message_output .= str_replace("_", " ", ucfirst($key)) . $colon_sep . build_message($value) . $line_space; } else { $message_output .= build_message($value) . ", "; } } } } } return rtrim($message_output, ", "); }
$validation_three = missing_attention($attention); if (!empty($validation_three)) { $error_message = $validation_three; } if (!empty($validation_two)) { $error_message = $validation_two; } if (!empty($validation_one)) { $error_message = $validation_one; } if (empty($validation_one) && empty($validation_two) && empty($validation_three)) { $today_is = date("l, F j, Y, g:i a"); $notes = stripcslashes($notes); $attention_values = get_attention($attention); $subject = "To " . $attention_values[1] . " from ynotradio.net"; $message = build_message($today_is, $attention_values, $notes, $visitor, $visitormail); $from = "From: {$visitormail}\r\n"; send_mail($attention_values[0], $subject, $message, $from); echo "<div class=\"success center\">\n <h2>" . ucfirst($visitor) . ", thanks for your message!</h2>\n </div>"; } else { echo "<div class=\"center error\">" . $error_message . "</div>"; } function valid_email($visitormail) { if (!empty($visitormail) && (!strstr($visitormail, "@") || !strstr($visitormail, "."))) { return "Use the back button and enter a valid e-mail address.\n<br>\nYour feedback was not submitted.\n"; } } function missing_data($visitor, $visitormail, $notes) { if (empty($visitor) || empty($visitormail) || empty($notes)) {
function build_multipart() { global $_parts; $boundary = "b".md5(uniqid(time())); $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary"; for ($i = sizeof ($_parts) - 1; $i >= 0; $i--) { $multipart .= "\n" . build_message($_parts[$i]) . "--$boundary"; } return $multipart.= "--\n"; }