Codice PHP:
<?php if(!isset($_SESSION['admin'])){echo 'Hacking attempted'; return ;} ?>
<?php
// the settings are stored here //
require("admin/class/phpmailer/class.phpmailer.php");
$recordset=$conn->Execute("SELECT * FROM wiml_history WHERE id = $task_id");
$row=$recordset->GetArray();
$subject=stripslashes($row[0]['subject']);
$text_message=stripslashes($row[0]['text_message']);
$html_message=stripslashes($row[0]['html_message']);
$template=$row[0]['template'];
$group_id=$row[0]['group_id'];
$charsettype=$row[0]['charsetiso'];
$priorityemail=$row[0]['priority'];
$emailfrom=$row[0]['emailfrom'];
$send_cont=25;
if(!isset($email_from))$email_from=0;
if(!isset($last_address))$last_address='';
if(!isset($last_index))$last_index=0;
$extra_info=true;
/*
MODIFIED BY MOISES TO CHANGE ULINK UNSUBSCRIBE LINK
//modify by Moises Hdez.
//last update 2004/11/18
//www.hgmnetwork.com
*/
//if($group_id==-2 || $group_id==-3)$extra_info=false;
//echo "el grupo es $group_id";
//if($group_id==-1 || $group_id==-3)$extra_info=false;
/*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(substr(stristr($emailfrom,"<"),1,-1));
$mail->Sender = trim(substr(stristr($emailfrom,"<"),1,-1));; // reply to
//echo " el mensaje se enviara desde $emailfrom";
$mail->FromName = trim(strip_tags($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;
}
/* unsubscribe part */
$unsub_html="";
$unsub_text="";
//echo "esto es para probar email_ussubscribe es $email_unsubscribe y group_ip es $group_id";
if($email_unsubscribe=="yes")
{
$unsub_html=str_replace("{ulink}",'<a href="'.$website.$main_dir.'unsubscribe.php?mail={email}&id={id}">',$email_unsubscribe_message);
$unsub_html=str_replace("{/ulink}","</a>",$unsub_html);
$unsub_text="\n\n Please Paste following link to Un-subscribe : ".$website.$main_dir."unsubscribe.php?mail={email}&id={id}";
}
/////////////////////////////////////////////////////////////////////
// Fill in the content
/////////////////////////////////////////////////////////////////////
if(strlen($text_message)>0)
{
if(strlen($html_message) == 0 ) {$mail->Body = $text_message;
if($extra_info)$mail->Body.=$unsub_text;}
else {$mail->AltBody = $text_message;
if($extra_info)$mail->AltBody.=$unsub_text;}
}
// load the template //
if((strlen($template)>0) && (strlen($html_message)>0) )
{
$mail->IsHTML(true);
$fp=fopen("admin/templates/".$template."/email.htm","r");
$html=fread($fp,filesize("admin/templates/".$template."/email.htm"));
fclose($fp);
$html=str_replace("{content}",$html_message,$html);
if(!($dir=opendir("admin/templates/".$template."/images/")))
{
echo "Error : Unable to access the templates directory !!!</body></html>";
return;
}
while ( $name = readdir($dir))
{
if( $name=="." || $name==".." )continue;
if( is_file( "admin/templates/".$template."/images/".$name ) )
{
$ext=array();
$ext=explode(".",$name,strlen($name));
$extn=$ext[count($ext)-1];
if(strtolower($extn)=="gif")
{
if($email_images=="yes"){$html=str_replace("images/".$name,"cid:".md5($name),$html);
$mail->AddEmbeddedImage("admin/templates/".$template."/images/".$name,md5($name),'','base64',"image/gif");
}else
{
$html=str_replace("images/".$name,$website.$main_dir."admin/templates/".$template."/images/".$name,$html);
}
}
if(strtolower($extn)=="jpg")
{
if($email_images=="yes"){$html=str_replace("images/".$name,"cid:".md5($name),$html);
$mail->AddEmbeddedImage("admin/templates/".$template."/images/".$name,md5($name),'','base64',"image/jpeg");
}else
{
$html=str_replace("images/".$name,$website.$main_dir."admin/templates/".$template."/images/".$name,$html);
}
}
if(strtolower($extn)=="png")
{
if($email_images=="yes"){$html=str_replace("images/".$name,"cid:".md5($name),$html);
$mail->AddEmbeddedImage("admin/templates/".$template."/images/".$name,md5($name),'','base64',"image/png");
}else
{
$html=str_replace("images/".$name,$website.$main_dir."admin/templates/".$template."/images/".$name,$html);
}
}
}
}
//change by moises Hdez.
//last update 2004/11/18
//www.hgmnetwork.com
$mail->Body=$html;
if($extra_info)$mail->Body=str_replace("{ulink}",'<a href="'.$website.$main_dir.'unsubscribe.php?mail={email}&id={id}" >',$mail->Body);
if($extra_info)$mail->Body=str_replace("{/ulink}","</a>",$mail->Body);
$mail->Body;
}
else if (strlen($html_message)>0)
{
$mail->IsHTML(true);
$mail->Body=$html_message;
if($extra_info)$mail->Body.=$unsub_html;
$mail->Body;
}
/*$myDomain = parse_url($website);
$mail->Host = $myDomain["host"];
*/
$mail_type="";
$tmail = new phpmailer();
//Actual loop which sends mail to every one
/* send to a single user */
//modify by moises Hdez.
//last update 2004/11/27
//www.hgmnetwork.com
$total_emails_deleted=0;
if($group_id== -2 )
{
$tmail=$mail;
$tmail->AddAddress($row[0]['email_address']);
if (isset($row[0]["email_name"])){
$tmail->Body=str_replace("{name}",$row[0]["email_name"],$tmail->Body);
} else {
$tmail->Body=str_replace("{name}","",$tmail->Body);
};
$tmail->Body=str_replace("{email}",$row[0]["email_address"],$tmail->Body);
$tmail->Body=str_replace("{id}",$row[0]["group_id"],$tmail->Body);
if (isset($row[0]["email_name"])){
$tmail->AltBody=str_replace("{name}",$row[0]["email_name"],$tmail->AltBody);
} else {
$tmail->AltBody=str_replace("{name}","",$tmail->AltBody);
};
$tmail->AltBody=str_replace("{email}",$row[0]["email_address"],$tmail->AltBody);
$tmail->AltBody=str_replace("{id}",$row[0]["group_id"],$tmail->AltBody);
if (isset($row[0]["email_name"])){
$tmail->Subject=str_replace("{name}",$row[0]["email_name"],$mail->Subject);
} else {
$tmail->Subject=str_replace("{name}","",$mail->Subject);
};
$tmail->Subject=str_replace("{email}",$row[0]["email_address"],$mail->Subject);
if(!isAddressValid($row[0]["email_address"]))
{
$conn->Execute("DELETE FROM wiml_maillist WHERE id = ".$row[0]["id"]);
//variable para saber el numero de Emails Eliminados por mala direccion
$total_emails_deleted= $total_emails_deleted + 1 ;
continue;
}
if(!$tmail->Send())echo "Error Enviando a : ".$row[0]['email_address'];
$send_all="true";
}