'Please fill out all the requested fields before submitting your message.',
C_MSG_SEND_SUCCESS => 'Your message has been sent. Thank you for your interest in our products.',
C_MSG_SEND_FAILED => 'Failed to send message. Please try again later.',
);
$GLOBALS['FLV_CONTACT']['SUBJECT_OPT'] = array(
0 => 'Select a subject',
1 => 'General',
2 => 'Product Support',
3 => 'Partnership Inquiry',
);
function ct_valid_fields($params) {
if ( !is_str_not_empty($params['c_name']) ||
!is_str_not_empty($params['c_mess']) ||
!is_valid_email($params['c_mail']) ||
$params['c_subj'] == '0' ) {
return false;
}
return true;
}
function ct_send_mail($data) {
$head = "From: {$data['c_mail']}\r\nReply-To: {$data['c_mail']}\r\n";
$subj = "FLV.com - " . $GLOBALS['FLV_CONTACT']['SUBJECT_OPT'][$data['c_subj']];
$body = "\r\nThe following message was sent by {$data['c_name']}\r\n{$data['c_mess']}";
if ( !mail(FLV_CONTACT_EMAIL, $subj, $body, $head) ) {
return false;
}
return true;
}
function ct_subj_options() {
foreach ( $GLOBALS['FLV_CONTACT']['SUBJECT_OPT'] as $val => $text ) {
$sel = ($_POST['c_subj'] == $val) ? " selected" : "";
$opts .= "";
}
return $opts;
}
function ct_feedback_box($msg) {
return <<{$msg}
HTML;
}
$gp_params = $_POST = array_map('strip_tags', $_POST);
$feedback = "";
if ( ct_valid_fields($gp_params) ) {
if ( !ct_send_mail($gp_params) ) {
$feedback = ct_feedback_box($GLOBALS['FLV_CONTACT']['FEEDBACK'][C_MSG_SEND_FAILED]);
}
$feedback = ct_feedback_box($GLOBALS['FLV_CONTACT']['FEEDBACK'][C_MSG_SEND_SUCCESS]);
$gp_params = array();
$_POST = array();
}
elseif( isset($gp_params['c_mess']) ) {
$feedback = ct_feedback_box($GLOBALS['FLV_CONTACT']['FEEDBACK'][C_MSG_INVALID_FIELD]);
}
$gp_params['c_subj_opts'] = ct_subj_options();
?>