/var/www/(Del)pathways.org.hk/admin/emailcontentengine.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
ini_set
('display_errors'1);
error_reporting(E_ALL);
 require(
"configure.php"); ?>

<?
//print_r($_POST);

$nemailsubject            $_POST["emailsubject"];
$emaildesc                $_POST["emaildesc"];
$emaildesc str_replace("\\\"""\""$emaildesc);
$emaildesc str_replace("\\""\\"$emaildesc);
$emaildesc    str_replace("'""\'",$emaildesc);
//echo $emaildesc;
$emailaddress  $_POST['custemailaddress'];
$len          count($_POST['custemailaddress']);

//echo "loopnum".$len."<br>";
echo "Loading...............";
$INCLUDE_DIR "";
$to "";

require(
$INCLUDE_DIR "class.phpmailer.php");
error_reporting(E_ALL);
//$countemail=1;
for($i=0;$i<$len;$i++) {
    if     (
substr($emailaddress[$i],0,2) == 'G_') {
        
$emailaddress2 substr($emailaddress[$i],2);
            
$result1 mysql_query("SELECT * from emailgroup inner join custemail on emailgroup.emailgroupid = custemail.emailgroupid where custemail.emailgroupid = '".$emailaddress2."' ");
            while (
$row1 mysql_fetch_array($result1,MYSQL_ASSOC))
            {
            
//echo ', '.$row1{'custemailaddress'};
            
$cmail=$row1{'custemailaddress'};
            
//$numid=$row1{'custemailid'};
        
        
        
$body '<HTML>';
        
$body .= '<HEAD>';
        
$body .= '<TITLE>NEWS LETTER</TITLE>';
        
$body .= '<META http-equiv=Content-Type content=text/html; charset=UTF-8>';
        
$body .= '<link rel="stylesheet" type="text/css" href="http://www.pathways.org.hk/css/style.css" />';
        
$body .= '</HEAD>';
        
$body .= '<body>';
        
//$body .= ''. $numid .'';
        
$body .= ''$emaildesc .'';
        
$body .= '<br><br>';
        
$body .= '<table width="800" border="0" cellpadding="0" cellspacing="0">';
        
$body .= '  <tr>';
        
$body .= '    <td height="50" align="center" class="footertxt">Copyright © 2010 The Pathways Foundation Ltd. All Rights Reserved.  |   Sponsored by <a href="http://www.onesolution.com.hk" target="_blank">One Solution Limited</a>.<br />';
        
$body .= '    <a href="http://www.onesolution.com.hk" target="_blank"><img src="http://www.pathways.org.hk/images/webicon137w23h.jpg" width="137" height="23" border="0" /></a></td>';
        
$body .= '  </tr>';
        
$body .= '</table>';
        
$body .= '</BODY>';
        
$body .= '</HTML>';
        
        
$FromEmail="info@pathways.org.hk";
        
//$to=$custemailaddress;
        
$to=$cmail;
        
$FromName="Pathways Foundation";
        
$subject=$nemailsubject;
        
$x_mail = new PHPMailer();
        
$x_mail->IsSMTP();
        
//$x_mail->Host = "smtp2.onesolution.com.hk";
        
$x_mail->Host "localhost";
        
$x_mail->SMTPAuth true;
        
$x_mail->charSet "utf-8";
        
$x_mail->From $FromEmail;
        
$x_mail->FromName $FromName;
        
$x_mail->AddAddress($to);
        
$x_mail->WordWrap 50;
        
$x_mail->IsHTML(true);
        
$x_mail->Subject $subject;
        
$x_mail->Body    $body;
        
$x_mail->Send();
            }
            
    } else {
        
//echo $emailaddress[$i];
        
        
        
$body '<HTML>';
        
$body .= '<HEAD>';
        
$body .= '<TITLE>NEWS LETTER</TITLE>';
        
$body .= '<META http-equiv=Content-Type content=text/html; charset=UTF-8>';
        
$body .= '<link rel="stylesheet" type="text/css" href="http://www.pathways.org.hk/css/style.css" />';
        
$body .= '</HEAD>';
        
$body .= '<body>';
        
$body .= ''$emaildesc .'';
        
$body .= '<br><br>';
        
$body .= '<table width="800" border="0" cellpadding="0" cellspacing="0">';
        
$body .= '  <tr>';
        
$body .= '    <td height="50" align="center" class="footertxt">Copyright © 2010 The Pathways Foundation Ltd. All Rights Reserved.  |   Sponsored by <a href="http://www.onesolution.com.hk" target="_blank">One Solution Limited</a>.<br />';
        
$body .= '    <a href="http://www.onesolution.com.hk" target="_blank"><img src="http://www.pathways.org.hk/images/webicon137w23h.jpg" width="137" height="23" border="0" /></a></td>';
        
$body .= '  </tr>';
        
$body .= '</table>';
        
$body .= '</BODY>';
        
$body .= '</HTML>';
        
        
$FromEmail="info@pathways.org.hk";
        
//$to=$custemailaddress;
        
$to=$emailaddress[$i];
        
$FromName="Pathways Foundation";
        
$subject=$nemailsubject;
        
$x_mail = new PHPMailer();
        
$x_mail->IsSMTP();
        
//$x_mail->Host = "smtp2.onesolution.com.hk";
        
$x_mail->Host "localhost";
        
$x_mail->SMTPAuth true;
        
$x_mail->charSet "utf-8";
        
$x_mail->From $FromEmail;
        
$x_mail->FromName $FromName;
        
$x_mail->AddAddress($to);
        
$x_mail->WordWrap 50;
        
$x_mail->IsHTML(true);
        
$x_mail->Subject $subject;
        
$x_mail->Body    $body;
        
$x_mail->Send();
    }
    
    
/*echo $countemail;
    $countemail++;*/
    
}


$sql3 "select max(emailcontentid) as maxid ";
$sql3 .= "from emailcontent";
$result3=mysql_query($sql3);
$row3 mysql_fetch_array($result3,MYSQL_ASSOC);
$emailcontentid $row3{maxid}+1;

$emaildate date("F j, Y, g:i a");

$sql3 "insert into emailcontent (emailcontentid, emailsubject, emaildesc, emaildate) values ('$emailcontentid', '$nemailsubject', '$emaildesc', '$emaildate')";

mysql_query($sql3);

//echo $sql3;

mysql_close($dbh);


header("Location: emailcontentindex.php?msg=Update Successful");
?>