mge |
Valuable expert |
|
|
Joined: Jul 16, 2008 |
Posts: 142 |
|
|
|
|
|
|
|
Code: | <?php
function mailLead($lID, $mDay, $id) {
include "config.php";
$qryL = mysql_query("SELECT lName,lEmail,username,kota,nama_sponsor,email_sponsor,phone_sponsor FROM ar_lead WHERE lID='$lID'",$id);
$rowL = mysql_fetch_array($qryL);
$qryM = mysql_query("SELECT * FROM ar_msg WHERE mDay=$mDay",$id);
$rowM = mysql_fetch_array($qryM);
$headerPlain = "From:$email\r\n";
$headerHtml = $headerPlain."Content-type: text/html; charset=iso-8859-1\r\n";
$mBody = formatMBody($lID, $rowL[lName], $rowL[lEmail], $rowM[mBody], $rowM[mType], $rowL[username], $rowL[kota], $rowL[nama_sponsor], $rowL[email_sponsor], $rowL[phone_sponsor]);
$mSubject = formatMSubject($rowL[lName], $rowL[lEmail], $rowM[mSubject]);
if($rowM[mType] == 'html') {
@mail("$rowL[lEmail]","$mSubject","$mBody","$headerHtml");
} else {
@mail("$rowL[lEmail]","$mSubject","$mBody","$headerPlain");
}
mysql_query("UPDATE ar_lead SET lMOut='$mDay', lDateOut=current_date WHERE lID='$lID'",$id);
}
function mailLeadFilter($lID, $mType, $mSubject, $mBody, $id) {
include "config.php";
$qryL = mysql_query("SELECT lName,lEmail,username,kota,nama_sponsor,email_sponsor,phone_sponsor FROM ar_lead WHERE lID='$lID'",$id);
$rowL = mysql_fetch_array($qryL);
$headerPlain = "From:$email\r\n";
$headerHtml = $headerPlain."Content-type: text/html; charset=iso-8859-1\r\n";
$mBody = formatMBody($lID, $rowL[lName], $rowL[lEmail], $mBody, $mType, $rowL[username], $rowL[kota], $rowL[nama_sponsor], $rowL[email_sponsor], $rowL[phone_sponsor]);
$mSubject = formatMSubject($rowL[lName], $rowL[lEmail], $mSubject);
if($mType == 'html') {
@mail("$rowL[lEmail]", "$mSubject", "$mBody", "$headerHtml");
} else {
@mail("$rowL[lEmail]", "$mSubject", "$mBody", "$headerPlain");
}
}
function formatMBody($lID, $lName, $lEmail, $mBody, $mType, $username, $kota, $nama_sponsor, $email_sponsor, $phone_sponsor) {
include "config.php";
if($mType == 'html') {
$uLink .= $httpAdd.'/unsubscribe.php?lEmail='.$lEmail.'&lID='.$lID;
$uLink = '<a href="'.$uLink.'">'.$uLink.'</a>';
} else {
$uLink .= $httpAdd.'/unsubscribe.php?lEmail='.$lEmail.'&lID='.$lID;
}
$mBody = str_replace('<?Name?>',$lName,$mBody);
$mBody = str_replace('<?Email?>',$lEmail,$mBody);
$mBody = str_replace('<?Username?>',$username,$mBody);
$mBody = str_replace('<?Kota?>',$kota,$mBody);
$mBody = str_replace('<?NamaSponsor?>',$nama_sponsor,$mBody);
$mBody = str_replace('<?EmailSponsor?>',$email_sponsor,$mBody);
$mBody = str_replace('<?PhoneSponsor?>',$phone_sponsor,$mBody);
$mBody = str_replace('<?Unsubscribe?>',$uLink,$mBody);
return $mBody;
}
function formatMSubject($lName, $lEmail, $mSubject) {
$mSubject = str_replace('<?Name?>', $lName, $mSubject);
$mSubject = str_replace('<?lEmail?>', $lEmail, $mSubject);
return $mSubject;
}
function buildLeadIndex($qty, $leadsPage) {
if($qty > $leadsPage) {
echo "Index ";
$index = 0;
$start = 0;
while($qty > 0) {
echo ' <a href="leads.php?start='.$start.'">'.++$index.'</a>';
$qty = $qty - $leadsPage;
$start = $start + $leadsPage;
}
}
}
?> |
|
|