Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Building a Mailing List Manager CHAPTER 28 705 LISTING 28.16 Continued } else if (mysql_num_rows($result)==0) { echo “There is nobody subscribed to list number $listid”; return false; } else { include(‘class.html.mime.mail.inc’); $mail = new html_mime_mail(); // read in the text version $filename = “archive/$listid/$mailid/text.txt”; $fp = fopen ($filename, “r”); $text = fread($fp, filesize($filename)); fclose ($fp); // read in the HTML version $filename = “archive/$listid/$mailid/index.html”; $fp = fopen ($filename, “r”); $html = fread($fp, filesize($filename)); fclose ($fp); // get the list of images that relate to this message $query = “select path, mimetype from images where mailid = $mailid”; if(db_connect()) { $result = mysql_query($query); if(!$result) {. | Building a Mailing List Manager 705 Chapter 28 Listing 28.16 Continued else if mysql_num_rows result 0 echo There is nobody subscribed to list number listid return false else include class.html.mime.mail.inc mail new html_mime_mail read in the text version filename archive listid mailid text.txt fp fopen filename r text fread fp filesize filename fclose fp read in the HTML version filename archive listid mailid index.html fp fopen filename r html fread fp filesize filename fclose fp get the list of images that relate to this message query select path mimetype from images where mailid mailid if db_connect result mysql_query query if result echo p Unable to get image list from database. return false num mysql_numrows result for i 0 i num i load each image from disk filename archive listid mailid .mysql_result result i 0 fp fopen filename r image fread fp filesize filename fclose fp add images to the mimemail object mail- add_html_image image mysql_result result i 0 28 Building a Mailing List Manager Building Practical PHP and MySQL Projects 706 Part V Listing 28.16 Continued mysql_result result i 1 add HTML and text to the mimemail object mail- add_html html text note that we build and encode the message here outside the loop not repeatedly inside the loop mail- build_message if status STORED send the HTML version of the message to administrator mail- send get_real_name admin_user admin_user from_name from_address subject send the text version of the message to administrator mail get_real_name admin_user . . admin_user. subject text From from_name from_address echo Mail sent to admin_user query update mail set status TESTED where mailid mailid if db_connect result mysql_query query echo p Press send again to send mail to whole list. center display_button send id mailid echo center else if status TESTED send to whole list query select subscribers.realname sub_lists.email subscribers.mimetype from sub_lists subscribers where listid listid and sub_lists.email .