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
|
<?php /* -*- mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
class Email {
public $timestamp;
public $email;
public function Email($email, $timestamp)
{
$this->email = $email;
$this->timestamp = $timestamp;
}
public function send($subject, $message,
$sender, $replyto)
{
$headers = "From: " . $sender . "\r\n";
$headers .= "Reply-To: " . $replyto . "\r\n";
$headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
// $headers .= "X-Mailer: PHP/" . phpversion();
$headers .= "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7";
return mail($this->email, utf8_decode($subject), utf8_decode($message), $headers);
}
}
class _Mailinglist {
public $mailinglist = array();
public $subj_prefix;
public $sender;
public $replyto;
public $footer;
public function add($email) {
$key = $email->email;
if(array_key_exists($key, $this->mailinglist)) return false;
$this->mailinglist[$key] = $email;
return true;
}
public function remove($email) {
if(array_key_exists($email, $this->mailinglist)) {
unset($this->mailinglist[$email]);
return true;
}
return false;
}
public function postSingle($email, $subject, $message)
{
$subject = "[".$this->subj_prefix."] " . $subject;
$message .= "\n\n".$this->footer;
return $email->send($subject, $message, $this->sender, $this->replyto);
}
public function post($subject, $message)
{
$sz = sizeof($this->mailinglist);
echo "<div style=\"text-align: center; padding-top: 120px; padding-bottom: 100px; position: absolute; top: 25%; left: 0px; width: 99.4%; height: 150px; border: solid #0000ff 3px; background: #fff; color: #000;\">Sending ". $sz ." mails <br/>\n<";
ob_flush();
flush();
$num = 0;
$lvl = 0;
$steps = floor($sz / 10) + 1;
foreach($this->mailinglist as $email) {
if($this->postSingle($email, $subject, $message) == false) {
echo "[fail: " . $email->email . "]";
}
$pct = $num / $sz * 100;
if($pct >= $lvl) {
printf("<font style=\"font-size: 9px;\">%.0f%%</font>", $lvl);
$lvl += 100/$steps;
} else {
echo ".";
}
ob_flush();
flush();
$num++;
}
echo "<font style=\"font-size: 9px;\">[100%]</font>>\n<br/>done<br/>\n";
echo "<a style=\"font-size: 20px; font-weight: bold;\" href=\"?page=admin>[CLOSE]</a>";
echo "</div>\n";
ob_flush();
flush();
}
public function _Mailinglist()
{
}
}
?>
|