include('e-newsletter/globals.php');
mysql_connect($dbhostname,$dbusername,$dbpassword) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
if(!isset($selection)) {$selection='';}
if(!isset($uid)) {$uid = '';}
?>
Thanks
//........................................................ flust dummy table for deleting the email which has expired.................
//........................................................ flust dummy table for deleting the email which has expired.................
$del = intval(time()) - 172800 ;
mysql_query("delete from wiml_maillist_dummy where email_date < $del");
//....................................................... subscribe user .............................................................//
if($selection=='add')
{
$dup = mysql_query("select * from wiml_maillist where email_address = "."'". $email_add ."'". " AND group_id = 1") or die();
$auto = mysql_query("select * from wiml_autoresponder where res_id = 1 ");
$data = mysql_fetch_array($auto);
if(mysql_num_rows($dup) == 0)
{
$done = mysql_query("INSERT INTO wiml_maillist_dummy (e_name,email_address,email_ip,email_date,group_id)
VALUES ('".$e_name."','".$email_add."', '".$_SERVER['REMOTE_ADDR']."', '".time()."', 1)") or die(mysql_error());
if($done)
{
mysql_query("commit") or die("action failed");
echo"
Thank you for your subscribing.An E-Mail has been sent to your email address.
Click on the given link to confirm your account activatoin or ignore the link if you don't .
";
require("e-newsletter/admin/class/phpmailer/class.phpmailer.php");
$get_info = mysql_query("select * from wiml_maillist_dummy where email_address = '".$email_add."'") or die ('action failed .try again') ;
$info = mysql_fetch_array($get_info) or die('aciton failed.');
$sender = $email_email;
$to = $email_add;
$sub = $data['subjects'];;
$body = "
You need to confirm the account by pointing your browser at Click here for confirm your account activation to get newsletter
If you did not apply for the account please ignore this message.
The validation of this email is only for 2 days.";
$subject=stripslashes($sub);
$message = $body;
$charsettype =$data['charset'];
$emailfrom = $email_email;
if(!isset($email_from))$email_from = $email_email;
if(!isset($last_address))$last_address='';
if(!isset($last_index))$last_index=0;
$extra_info=true;
/*intialize PHP mailer class */
//echo "Emailfrom es : ".$emailfrom." Nombre: ".strip_tags($emailfrom) ." email : ".substr(stristr($emailfrom,"<"),1,-1);
$mail = new phpmailer();
$mail->Subject = $subject;
$mail->From = trim($emailfrom);
$mail->Sender = trim($emailfrom); // reply to
//echo " el mensaje se enviara desde $emailfrom";
$mail->FromName = trim($emailfrom);
$mail->ContentType = "text/plain";
$mail->CharSet = $charsettype;
//$mail->Priority = $priorityemail;
switch($mserver)
{
case "smtp" :
$mail->Host=$smtp_string;
if($smtp_auth=="yes")
{
$mail->SMTPAuth=true;
$mail->Username=$smtp_username;
$mail->Password=$smtp_password;
}
$mail->Mailer="smtp";
break;
case "sendmail" :
$mail->Sendmail=$sendmail_string;
$mail->Mailer="sendmail";
break;
case "php":
default :
$mail->Mailer="mail";
break;
}
$mail->IsHTML(true);
$mail->Body=$message;
$mail_type="";
$tmail = new phpmailer();
$tmail=$mail;
$tmail->AddAddress($to);
$tmail->Send();
}
}
else
{
echo "
Sorry,but the email address already exist.Please try to another email address.
";
}
} // if selection
//....................................................... unsubscribe user .............................................................//
if($selection=='delete') // unsubscribe user
{
$auto = mysql_query("select * from wiml_autoresponder where res_id = 2 ") or die(mysql_error());
$data = mysql_fetch_array($auto) or die(mysql_error());
$sql = "SELECT * FROM wiml_maillist WHERE email_address = "."'".$email_add."'";
$chk = mysql_query($sql) or die(mysql_error());
if( mysql_num_rows($chk)!= 0)
{
$del_data = mysql_fetch_array($chk) or die('action failed');
mysql_query("INSERT INTO wiml_deleted_email VALUES ('','".$del_data['email_address']."')") or die(mysql_error());
$row = mysql_fetch_array($chk);
$sql = "DELETE FROM wiml_maillist WHERE email_address = '".$row['email_address']."';";
$del_done = mysql_query($sql) or die(mysql_error());
if($del_done)
{
echo"
Thank you for choosing us. You are completely unsubscribed.