function send_Messages() { include_once "lib/mail.class.php"; $conf = $this->conf(); $db = new sql(); $db->connect(); $res = $db->query("select * from subs_messages where id={$this->mid}"); $data = $db->fetch_array($res); $page = $this->page ? $this->page : 1; $res = $db->query("select * from subs_users left join subs_subscribed on subs_users.id=subs_subscribed.sid where lid={$this->id} limit " . 10 * ($page - 1) . ",10"); if ($db->num_rows($res)) { while ($user = $db->fetch_array($res)) { $i++; $text["txt"] = $data["text"]; $text["html"] = $data["html"]; if ($data["text"]) { $txt = $this->replaceMacros($conf["text"], $text, $conf, $user); } if ($data["html"]) { $html = $this->replaceMacros($conf["html"], $text, $conf, $user); } $mail = new htmlMimeMail(); $mail->setSubject($data["subj"]); $mail->setFrom($conf["email_from"]); if ($html) { $mail->setHtmlEncoding("base64"); $mail->setHTML($html, $txt, ''); } elseif ($txt && !$html) { $mail->setText($txt); } $result = $mail->send(array($user["email"])); } $page++; //echo "Location: ?chid=".$this->chid."&action=send_Messages&id=".$this->id."&mid=$this->mid&page=$page;"; header("Location: ?chid=" . $this->chid . "&action=send_Messages&id=" . $this->id . "&mid={$this->mid}&page={$page}&i={$i}"); } else { if ($this->page) { $count = 10 * ($this->page - 2) + $this->i; $_SESSION["warning"] = "Писем отправлено: {$count}"; $db->query("update subs_messages set date_sent=" . time() . " where id={$this->mid}"); } header("Location: ?chid=" . $this->chid . "&action=show_Messages&id=" . $this->id . "&w=1"); } }