';
if (is_numeric($_REQUEST['contactid'])) {
// Insert Header File
$contactid = $_REQUEST['contactid'];
$db_link = pg_pconnect($pg_connect_string);
$query = "SELECT * FROM pbo_webmail_view WHERE (idctc =" . $contactid . ")";
$result = pg_exec($db_link, $query);
$numrow = pg_numrows($result);
if (!$result) {
virtual($header_parser);
echo "Could not find contact.";
virtual($footer_parser);
}
else {
if ($numrow == 1) {
for ($row = 0; $row < pg_numrows($result); $row++) {
$contactid = pg_result($result, $row, 'idctc');
$fname = pg_result($result, $row, 'ctcfname');
$lname = pg_result($result, $row, 'ctclname');
$email = pg_result($result, $row, 'ctcemail');
if ((isset($_REQUEST['task'])) and ($_REQUEST['task'] == "send_message")) {
// Form variables
if ((isset($_REQUEST['fullname'])) and (strlen(trim($_REQUEST['fullname'])) > 0)) {
$name_email = trim($_REQUEST['fullname']);
}
else {
$name_email = "Not Provided";
}
$sender_email = trim(stripslashes($_REQUEST['emailaddress']));
$subject_email = trim(stripslashes($_REQUEST['subject']));
$message_email = trim(stripslashes($_REQUEST['message']));
if ((isset($_REQUEST['emailaddress'])) and (!checkemailaddress($sender_email,''))) {
$error = "You need to enter a VALID EMAIL ADDRESS.";
}
if ((isset($_REQUEST['subject'])) and (strlen($subject_email) < 1)) {
$error .= "You need to enter a SUBJECT.";
}
if ((isset($_REQUEST['message'])) and (strlen($message_email) < 1)) {
$error .= "You need to enter a MESSAGE.";
}
if (!empty($error)) {
virtual($header_parser);
echo 'Error Message(s):';
echo '
';
echo '';
echo $error;
echo '';
echo '
';
echo '';
require_once('send_message.php');
virtual($footer_parser);
}
else {
// CHECK FOR BAD FIELD INPUT AND EMAIL HEADER
if (checkemailform() == true) {
if (checkemailaddress($email,'')) {
// Send Email
$mail_body = "-------------------------------------------------------------" . $mail_newline;
$mail_body .= "The following message was sent to you via " . $org_acronym . " Web2Email system:" . $mail_newline;
$mail_body .= "------------------------------------------------------------" . $mail_newline;
$mail_body .= "Name: " . $name_email . $mail_newline;
$mail_body .= "Email Address: " . $sender_email . $mail_newline;
$mail_body .= "Date Sent: " . date("F j, Y, g:i a") . $mail_newline;
$mail_body .= "Subject: " . $subject_email . $mail_newline;
$mail_body .= "Message:" . $message_email . $mail_newline;
$mail_body .= "------------------------------------------------------------" . $mail_newline;
$mail_body .= "REMOTE IP ADDRESS : " . $_SERVER['REMOTE_ADDR'] . $mail_newline;
$mail_body .= "REMOTE HOST : " . $_SERVER['REMOTE_HOST'] . $mail_newline;
$mail_body .= "USER AGENT/BROWSER : " . $_SERVER['HTTP_USER_AGENT'] . $mail_newline;
$mail_body .= "REFERRING PAGE : " . $_SERVER['HTTP_REFERER'] . $mail_newline;
$mail_header = "From: " . $name_email . "<" . $sender_email . ">" . $mail_newline;
if (mail($email, $org_acronym . ": " . $subject_email, $mail_body, $mail_header)) {
// Confirmation Message - Send to Screen
header("Location:" . $_SERVER['SCRIPT_NAME'] . "?contactid=" . $contactid . "&action=messagesent");
}
else {
// Could not send email, problem with sending, email not configured correctly
virtual($header_parser);
echo 'Could not send email. Email codes not properly configured.';
virtual($footer_parser);
}
}
else {
virtual($header_parser);
echo 'No valid email address found for ' . $fname . ' ' . $lname . '. Email not sent.';
virtual($footer_parser);
}
}
else {
virtual($header_parser);
error_message('Sorry. You are attempting to SPAM our email addresses. Have a nice day, BOT.');
virtual($footer_parser);
}
}
}
elseif ((isset($_REQUEST['action'])) and ($_REQUEST['action'] == "messagesent")) {
virtual($header_parser);
echo 'Message sent to ' . $fname . ' ' . $lname . '.';
virtual($footer_parser);
}
else {
virtual($header_parser);
require_once('send_message.php');
virtual($footer_parser);
}
}
}
else {
virtual($header_parser);
echo "Could not find contact.";
virtual($footer_parser);
}
}
pg_close($db_link);
}
else {
virtual($header_parser);
echo "Could not find contact.";
virtual($footer_parser);
}
}
else {
header("Location: /");
}
?>