//SMTP Mailer
include_once('class.phpmailer.php');
function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
$proceed = false;
$seconds = 60*10;
// Process form
if ($_POST['submitted'] == "true") {
/* --------- CHECK TO SEE IF IT'S A HUMAN SUBMISSION --------------- */
if($_SERVER['HTTP_HOST'] != "bmcms1.com") {
if($_COOKIE['token'] != md5('secret salt'.$_POST['ts'])) {
$errors['email'] = 'Too much time elapsed. Please try again.';
echo '{"SUCCESS":"false","CONFIRMATION":"Too much time elapsed. Please try again.","REASON":"token_error"}';
}
}
if ((empty($_POST['form-password']))) {} else{$errors['form-password'] = 'spam check';}
// Check for Errors
if ((empty($_POST['email'])) or ($_POST['email'] == "Enter your e-mail*")) {
echo '{"SUCCESS":"false","CONFIRMATION":"Please enter an email address","REASON":"email_not_provided"}';
$errors['email'] = '
*Valid Email Required
';
} else {
if (check_email_address($_POST['email'])) {
$validEmail = "true";
if(empty($_POST['form-contact-page-hidden'])){
if ((empty($_POST['name'])) or ($_POST['name'] == "Enter your name*")) {
echo '{"SUCCESS":"false","CONFIRMATION":"Please enter a name","REASON":"name_not_provided"}';
$errors['name'] = ' *Valid Name Required
';
}
}
} else {
$errors['email'] = '*Valid Email Required
';
echo '{"SUCCESS":"false","CONFIRMATION":"Please enter a valid email address","REASON":"email_invalid"}';
}
}
// if no errors
if ( empty($errors) && empty($_POST['form-contact-page-hidden']) ) { // Success from all signups
echo '{"SUCCESS":"true","CONFIRMATION":"FURTHER ACTION REQUIRED
Please check your email and click on the link to confirm your subscription"}';
// Interface with Lyris
$fields['name'] = $_POST['name'];
$fields['email'] = $_POST['email'];
$fields['list'] = 'uraniumenergy_com';
//$fields['confirm'] = 'none';
//$fields['showconfirm'] = 'F';
//print_r($fields);
foreach($fields as $key => $val) {
$post_variables .= $key.'='.$val.'&';
}
$post_variables = substr($post_variables,0,-1);
$ch = curl_init('http://dissemination.blendermedia.com:81/subscribe/subscribe.tml');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_variables);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
/* POST TO WORDPRESS */
$post_variables .= 'form_to_mailpoet=true&list_id=3&admin_email=ehren@blendermedia.com';
$autonews_post_variables = 'form_to_mailpoet=true&email='.$fields['email'].'&list_id=3&admin_email=ehren@blendermedia.com';
$post_variables = substr($autonews_post_variables,0,-1);
$ch = curl_init('http://em.blendermedia.com/uec/');
if (!$ch) {
echo 'Error ['.curl_errorno($ch).']: '.curl_error($ch);
}
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $autonews_post_variables);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
// Email Confirmation
$name= 'Uranium Energy';
$from= $_POST['email'];
$fromname= $_POST['name'];
$subject= $_POST['adsource'] . 'Addition to Uranium Energy Email List';
$message= "The following person has joined your email list: \n\rName: " . trim($_POST['name']) . "\nEmail: " . trim($_POST['email']) . "\nPhone: " . trim($_POST['phone']) . "\n\n". "IP:" . $_SERVER['REMOTE_ADDR'];
$mail = new PHPMailer();
$mail->isHTML(false);
$mail->IsSMTP(); // set mailer to use SMTP
$mail->From = 'info@uraniumenergy.net';
$mail->FromName = 'UEC Website Signups';
$mail->Host = "smtp.sendgrid.net"; // specify main and backup server
$mail->AddAddress('mehranb@uraniumenergy.com', 'Uranium Energy');
$mail->AddBCC('signups@blendermedia.com', 'Blender Media Signups');
$mail->SMTPAuth = true; // These three lines are necessary
$mail->Username = 'blendermedia2'; // only if your SMTP server
$mail->Password = 'telus351'; // requires authentication
$mail->Subject = $subject;
$mail->Body = $message;
if(!$mail->Send()) {
} else {
}
} elseif ( empty($errors) && $_POST['form-contact-page-hidden'] == 'true' ) {
echo '{"SUCCESS":"true","CONFIRMATION":"Thanks for getting in contact with us
Someone will be in touch with you shortly."}';
$name= 'Uranium Energy';
$from= $_POST['email'];
$fromname= $_POST['name'];
$subject= 'Contact from uraniumenergy.com website contact form';
$message= "Someone has attempted to get in touch with the following details: \n\r "
. "\nEmail: " . trim($_POST['email']) . "\nIP:" . $_SERVER['REMOTE_ADDR'] . "\n\r================================================";
foreach($_POST as $key => $value)
{
if (strstr($key, 'contact_form_value_'))
{
$x = str_replace('contact_form_value_','',$key);
$message .= "\n\rKey: " . $x . ' Value: ' . $value;
}
}
$message .= "\n\r================================================";
$mail = new PHPMailer();
$mail->isHTML(false);
$mail->IsSMTP(); // set mailer to use SMTP
$mail->From = 'info@uraniumenergy.net';
$mail->FromName = 'UEC Website Signups';
$mail->Host = "smtp.sendgrid.net"; // specify main and backup server
// $mail->AddAddress('chris@blendermedia.com', 'Uranium Energy');
$mail->AddAddress('mehranb@uraniumenergy.com', 'Uranium Energy');
$mail->AddBCC('signups@blendermedia.com', 'Blender Media Signups');
$mail->SMTPAuth = true; // These three lines are necessary
$mail->Username = 'blendermedia2'; // only if your SMTP server
$mail->Password = 'telus351'; // requires authentication
$mail->Subject = $subject;
$mail->Body = $message;
if(!$mail->Send()) {
} else {
}
} else {
}
} else {
}
?>