)/i", $_POST['message'])) {
$points += 2;
}
if (strlen($_POST['fname']) < 3) {
$points += 1;
}
if (strlen($_POST['message']) < 15 || strlen($_POST['message']) > 1500) {
$points += 2;
}
if (preg_match("/[bcdfghjklmnpqrstvwxyz]{7,}/i", $_POST['message'])) {
$points += 1;
}
// end score assignments
if ( !empty( $requiredFields ) ) {
foreach($requiredFields as $field) {
trim($_POST[$field]);
if (!isset($_POST[$field]) || empty($_POST[$field]) && array_pop($error_msg) != "Please fill in all the required fields and submit again.\r\n")
$error_msg[] = "Please fill in all the required fields and submit again.";
}
}
if (!empty($_POST['fname']) && !preg_match("/^[a-zA-Z-'\s]*$/", stripslashes($_POST['fname']))) {
$error_msg[] = "The name field must not contain special characters.\r\n";
}
if (!empty($_POST['email']) && !preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', strtolower($_POST['email']))) {
$error_msg[] = "That is not a valid e-mail address.\r\n";
}
//if (!empty($_POST['url']) && !preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i', $_POST['url']))
// $error_msg[] = "Invalid website url.\r\n";
if ($error_msg == NULL && $points <= $maxPoints) {
// if (count($error_msg) == 0 && $points <= $maxPoints) {
// echo("error_msg: " . count($error_msg) . "\n");
// echo("points: " . $points . "\n");
// echo("maxPoints: " . $maxPoints . "\n");
$subject = "Automatic Form Email";
$message = "You received this e-mail message through your website: \n\n";
foreach ($_POST as $key => $val) {
if (is_array($val)) {
foreach ($val as $subval) {
$message .= ucwords($key) . ": " . clean($subval) . "\r\n";
}
} else {
$message .= ucwords($key) . ": " . clean($val) . "\r\n";
}
}
$message .= "\r\n";
$message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";
$message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";
$message .= 'Points: '.$points;
if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
$headers = "From: $yourEmail\r\n";
} else {
$headers = "From: $yourWebsite <$yourEmail>\r\n";
}
$headers .= "Reply-To: {$_POST['email']}\r\n";
require("class.phpmailer.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 587; // or 587 465
$mail->IsHTML(false);
//$mail->SetLanguage("tr", "phpmailer/language");
$mail->CharSet ="utf-8";
$mail->Username = "corevid@gmail.com"; // Mail adresi
$mail->Password = "jtwyjxxcwctdbaot"; // Parola
$mail->SetFrom("corevid@gmail.com", "from Contact Form"); // Mail adresi
$mail->AddAddress("info@corevid.com"); // Gönderilecek kişi
//$mail->Subject = "Sideden Gönderildi";
//$mail->Body = "$name
$email
$subject
$message";
$mail->Subject = "Contact form submission:";
$mail->Body = $message; //"You have received a new message. ".
//" Here are the details:
\n Name: $name
\n ".
//"Email: $email_address
\n Message:
\n $message";
if ($mail->Send())//(mail($yourEmail,$subject,$message,$headers)) {
if (!empty($thanksPage)) {
header("Location: $thanksPage");
exit;
} else {
$result = 'Your mail was successfully sent.';
$disable = true;
}
} else {
$error_msg[] = 'Your mail could not be sent this time.';
// $error_msg[] = 'Your mail could not be sent this time. ['.$points.']';
}
} //else {
//if (empty($error_msg)) {
// $error_msg[] = 'Your mail looks too much like spam, and could not be sent this time. ['.$points.']';
//}
//}
function get_data($var, $result) {
if ($result == NULL) {
if (isset($_POST[$var])) {
echo htmlspecialchars($_POST[$var]);
}
}
}
?>