Ignore:
Timestamp:
09/23/07 23:49:33 (5 years ago)
Author:
hverton
Message:

changed copyright notice
added Smarty buttonlink function, to replace image buttons by real buttons using a locale for the button text

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/common/newsletters/php-files/modules/newsletters/newsletters.php

    r798 r836  
    11<?php 
    22/*---------------------------------------------------+ 
    3 | PLi-Fusion Content Management System               | 
     3| ExiteCMS Content Management System                 | 
    44+----------------------------------------------------+ 
    5 | Copyright 2007 WanWizard (wanwizard@gmail.com)     | 
    6 | http://www.pli-images.org/pli-fusion              | 
     5| Copyright 2007 Harro "WanWizard" Verton, Exite BV  | 
     6| for support, please visit http://exitecms.exite.eu | 
    77+----------------------------------------------------+ 
    8 | Some portions copyright ? 2002 - 2006 Nick Jones   | 
    9 | http://www.php-fusion.co.uk/                       | 
    108| Released under the terms & conditions of v2 of the | 
    119| GNU General Public License. For details refer to   | 
     
    232230                $mail->FromName = $settings['siteusername']; 
    233231                $mail->AddAddress($data2['user_email'], ($data2['user_fullname']=="" ? $data2['user_name'] : $data2['user_fullname'])); 
    234                 $mail->AddCustomHeader("X-version: PLi-Fusion Newsletters v".$locale['nlver']); 
     232                $mail->AddCustomHeader("X-version: ExiteCMS Newsletters v".$locale['nlver']); 
    235233                 
    236234                switch ($data2['user_newsletters']) { 
     
    414412require_once PATH_THEME."/theme.php"; 
    415413?> 
    416 <?php 
    417 die(); 
    418 /*---------------------------------------------------+ 
    419 | PLi-Fusion 7 Content Management System Infusion 
    420 +----------------------------------------------------+ 
    421 | Mail2Forum - CLI POP3 processor 
    422 | uses the POP3 and MIME classes from the PEAR library 
    423 +----------------------------------------------------+ 
    424 | Copyright © 2006-2007 WanWizard 
    425 | http://www.pli-images.org/PLi-Fusion/ 
    426 +----------------------------------------------------+ 
    427 | Released under the terms & conditions of v2 of the 
    428 | GNU General Public License. For details refer to 
    429 | the included gpl.txt file or visit http://gnu.org 
    430 +----------------------------------------------------*/ 
    431 if (isset($_SERVER['SERVER_SOFTWARE'])) { 
    432     die("This is a batch program that needs to run from cron!"); 
    433 } 
    434  
    435 /*---------------------------------------------------+ 
    436 | Read the user configuration 
    437 +----------------------------------------------------*/ 
    438  
    439 require "m2f_config.php"; 
    440  
    441 // find the webroot, so we can load the core functions 
    442 $webroot = ""; 
    443 while(!file_exists($webroot."includes/core_functions.php")) {  
    444     $webroot .= '../';  
    445     if (strlen($webroot)>100) die('Unable to find the PLi-Fusion document root!');  
    446 } 
    447 require_once $webroot."includes/core_functions.php"; 
    448  
    449 if (file_exists(PATH_MODULES."mail2forum/locale/".$settings['locale'].".php")) { 
    450     include PATH_MODULES."mail2forum/locale/".$settings['locale'].".php"; 
    451 } else { 
    452     include PATH_MODULES."mail2forum/locale/English.php"; 
    453 } 
    454  
    455 /*---------------------------------------------------+ 
    456 | local variables 
    457 +----------------------------------------------------*/ 
    458  
    459 $imagetypes = array(".bmp",".gif",".jpg",".jpeg",".png",".psd",".tiff",".wbmp"); 
    460 $contenttypes = array("image/bmp", "image/gif", "image/jpeg", "image/jpeg", "image/png", "image/x-photoshop", "image/tiff", "image/vnd.wap.wbmp"); 
    461 $processor = strtoupper(basename($argv[0],'.php')); 
    462  
    463 /*---------------------------------------------------+ 
    464 | local functions 
    465 +----------------------------------------------------*/ 
    466  
    467 // write an entry to the process log, and optionally abort the program 
    468 function logentry($task="", $message="", $abort=false, $exitcode=0) { 
    469  
    470     global $processor; 
    471      
    472     $handle = fopen(M2F_LOGFILE.'/M2F_process.log', 'a'); 
    473     fwrite($handle, date("Ymd").";".date("His").";".$processor.";".$task.";".$message.chr(10)); 
    474     fclose($handle); 
    475      
    476     if ($abort) die($exitcode); 
    477 } 
    478  
    479 // debug function - write an entry to the debug log 
    480 function logdebug($task="", $message="") { 
    481  
    482     global $processor; 
    483      
    484     $handle = fopen(M2F_LOGFILE.'/'.$processor.'.debug.log', 'a'); 
    485     fwrite($handle, date("Ymd").";".date("His").";".$task.";".$message.chr(10)); 
    486     fclose($handle); 
    487 } 
    488  
    489 /*---------------------------------------------------+ 
    490 | initialisation code 
    491 +----------------------------------------------------*/ 
    492  
    493 ini_set('memory_limit', '32M'); 
    494 ini_set('max_execution_time', '0'); 
    495  
    496 // log the start 
    497 if (M2F_PROCESS_LOG) logentry('INIT', 'Program start'); 
    498  
    499 // get the last modified timestamp of this module 
    500 $module_lastmod = filemtime('m2f_smtp.php'); 
    501  
    502 // get the last modified timestamp of the config file 
    503 $config_lastmod = filemtime('m2f_config.php'); 
    504  
    505 // check if the Mail2Forum Infusion is installed 
    506 $result = dbquery("SELECT * FROM ".$db_prefix."infusions WHERE inf_title = '".$locale['m2f100']."'"); 
    507 if (dbrows($result) == 0) { 
    508     if (M2F_PROCESS_LOG) logentry('INIT', $locale['m2f999'].' '.$locale['m2f110'], true, 1); 
    509     die('Mail2Forum is not infused'); 
    510 } 
    511  
    512 // initialize PHP-Mailer 
    513 require_once PATH_INCLUDES."phpmailer_include.php"; 
    514 $mail = new PHPMailer(); 
    515 mailer_init(); 
    516  
    517 // get the last polled time from the database 
    518 $result = dbquery("SELECT * FROM ".$db_prefix."M2F_status"); 
    519 if (dbrows($result) == 0) { 
    520     // the first time we start. Forget all old posts for now 
    521     $lastpoll = time(); 
    522     $result = dbquery("INSERT INTO ".$db_prefix."M2F_status (m2f_lastpoll) VALUES ('".$lastpoll."')"); 
    523     if (M2F_PROCESS_LOG) logentry("INIT", sprintf($locale['m2f800'], $processor)); 
    524 } else { 
    525     if ($data = dbarray($result)) { 
    526         if ($data['m2f_lastpoll'] == 0) { 
    527             // 0 is used as an invalid polltime. This can be reset via the admin module 
    528             die($processor.': LastPoll time is invalid. Use the admin module to correct this'); 
    529         } 
    530         if ((time() - $data['m2f_lastpoll']) > M2F_POLL_THRESHOLD) { 
    531             $result = dbquery("UPDATE ".$db_prefix."M2F_status SET m2f_lastpoll = 0"); 
    532             if (M2F_PROCESS_LOG) logentry('INIT', $locale['m2f999'].' '.$locale['m2f801'], true, 1); 
    533             die($processor.': More than a week has passed since the last run! Use the admin module to correct this'); 
    534         } 
    535         $lastpoll = $data['m2f_lastpoll']+1; 
    536     } else { 
    537         if (M2F_PROCESS_LOG) logentry('INIT', $locale['m2f999'].' '.$locale['m2f802'], true, 1); 
    538         die('This should never happen'); 
    539     } 
    540 } 
    541  
    542 // strip bbcode so a message stays readable in plain text 
    543 function stripubb($text) { 
    544     global $locale; 
    545      
    546     $text = preg_replace('#\[li\](.*?)\[/li\]#si', '* \1', $text); 
    547     $text = preg_replace('#\[ul\](.*?)\[/ul\]#si', '\1', $text); 
    548  
    549     $text = preg_replace('#\[b\](.*?)\[/b\]#si', '\1', $text); 
    550     $text = preg_replace('#\[i\](.*?)\[/i\]#si', '\1', $text); 
    551     $text = preg_replace('#\[u\](.*?)\[/u\]#si', '\1', $text); 
    552     $text = preg_replace('#\[center\](.*?)\[/center\]#si', '\1', $text); 
    553      
    554     $text = preg_replace('#\[url\]([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\";\+]*?)([\r\n]*)\[/url\]#si', '\2\3', $text); 
    555     $text = preg_replace('#\[url\]([\r\n]*)([^\s\'\";\+]*?)([\r\n]*)\[/url\]#si', 'http://\2', $text); 
    556     $text = preg_replace('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\";\+]*?)\](.*?)([\r\n]*)\[/url\]#si', '\2\3', $text); 
    557     $text = preg_replace('#\[url=([\r\n]*)([^\s\'\";\+]*?)\](.*?)([\r\n]*)\[/url\]#si', 'http://\2', $text); 
    558      
    559     $text = preg_replace('#\[mail\]([\r\n]*)([^\s\'\";:\+]*?)([\r\n]*)\[/mail\]#si', 'mailto:\2', $text); 
    560     $text = preg_replace('#\[mail=([\r\n]*)([^\s\'\";:\+]*?)\](.*?)([\r\n]*)\[/mail\]#si', 'mailto:\2', $text); 
    561      
    562     $text = preg_replace('#\[small\](.*?)\[/small\]#si', '\1', $text); 
    563     $text = preg_replace('#\[color=(black|blue|brown|cyan|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|violet|white|yellow)\](.*?)\[/color\]#si', '\2', $text); 
    564      
    565     $text = preg_replace('#\[flash width=([0-9]*?) height=([0-9]*?)\]([^\s\'\";:\+]*?)(\.swf)\[/flash\]#si', '\3\4', $text); 
    566     $text = preg_replace("#\[img\]((http|ftp|https|ftps)://)(.*?)(\.(jpg|jpeg|gif|png|JPG|JPEG|GIF|PNG))\[/img\]#sie","'\\1'.str_replace(array('.php','?','&','='),'','\\3').'\\4'",$text); 
    567  
    568     $text = descript($text,false); 
    569  
    570     return $text; 
    571 } 
    572  
    573 // preserve the exact content of [code] blocks 
    574 function quotecode($text) { 
    575     global $locale; 
    576      
    577     $text = preg_replace(':&#([0-9]*);:sie', 'chr(\1)', $text); 
    578         $replace = array("\"", "<", ">", " ", "&"); 
    579         $search = array("&quot;", "&lt;", "&gt;", "&nbsp;", "&amp;"); 
    580         $text = str_replace($search, $replace, $text); 
    581  
    582     $lines = preg_split("#\n|(\[quote[^\]]*\]|\[/quote\]|\[code\]|\[/code\])#si", $text, -1, PREG_SPLIT_DELIM_CAPTURE); 
    583     $quotelevel = 0; 
    584     $literal = 0; 
    585     $boundary = 0; 
    586     $new = ""; 
    587     $indent = ""; 
    588     $emptylines = ""; 
    589     foreach ($lines as $line) { 
    590         if ($boundary == 1) { // skip empty lines at the start of a quote or code block 
    591             if (strlen(trim($line)) == 0) 
    592                 continue; 
    593             $boundary = 0; 
    594         } 
    595  
    596         if (strlen(trim($line)) == 0) { // collect empty lines so we can skip them if we hit  
    597                         // a new block before a non-empty line 
    598             $emptylines .= "$indent\n"; 
    599         } 
    600         elseif ($line == "[/code]") 
    601         { 
    602             $emptylines = ""; 
    603             $boundary = 1; 
    604             $literal = 0; 
    605             $new .= "$indent" . "[/code]\n$indent\n"; // one 'empty' line after code block 
    606         } 
    607         elseif ($literal == 1) { 
    608             $new .= "$emptylines$indent    $line\n"; 
    609             $emptylines = ""; 
    610         } 
    611         elseif ($line == "[code]") { 
    612             $emptylines = ""; 
    613             $boundary = 1; 
    614             $literal = 1; 
    615             $new .= "$indent\n$indent" . "[code]\n"; // one 'empty' line before a code block 
    616         } 
    617         elseif ($line == "[quote]") { 
    618             $emptylines = ""; 
    619             $new .= "$indent\n"; // one 'empty' line before a new quote 
    620             $boundary = 1; 
    621             $quotelevel++; 
    622             $indent .= "> "; 
    623         } 
    624         elseif (preg_match("#\[quote=([^\]]*)\]#i", $line, $matches)) { 
    625             $emptylines = ""; 
    626             $boundary = 1; 
    627             $quotelevel++; 
    628             $poster = $matches[1]; 
    629             $poster = trim($poster, '"'); 
    630             $new .= "$indent\n$indent" . $poster . " ".$locale['m2f815'].":\n"; // one 'empty' line before a new quote 
    631             $indent .= "> "; 
    632         } 
    633         elseif ($line == "[/quote]") { 
    634             $emptylines = ""; 
    635             $boundary = 1; 
    636             if ($quotelevel > 0) { 
    637                 $quotelevel--; 
    638                 $indent = substr($indent, 0, $quotelevel*2); 
    639             } 
    640             $new .= "$indent\n"; // one 'empty' line after a quote 
    641         } 
    642         else { 
    643             $new .= "$emptylines$indent" . stripubb($line) . "\n"; 
    644             $emptylines = ""; 
    645         } 
    646     } 
    647     //$text = descript($text,false); 
    648  
    649     return $new; 
    650 } 
    651  
    652 /*---------------------------------------------------+ 
    653 | main loop 
    654 +----------------------------------------------------*/ 
    655  
    656 while (true) { 
    657  
    658     // time of this poll. 
    659     $polltime = time(); 
    660      
    661     // Insert a marker in the log every hour to show we're still alive 
    662     if (isset($marker) && $marker <> date("H")) 
    663         if (M2F_PROCESS_LOG) logentry("MARKER", "---"); 
    664     $marker = date("H"); 
    665  
    666     // check for messages posted since the last poll 
    667     $result = dbquery("SELECT * FROM ".$db_prefix."posts WHERE (post_datestamp BETWEEN '".$lastpoll."' AND '".$polltime."') OR (post_edittime BETWEEN '".$lastpoll."' AND '".$polltime."')"); 
    668     if (dbrows($result) != 0) { 
    669  
    670         // get all posts in the selected interval 
    671         while($postrecord = dbarray($result)) { 
    672             if (M2F_SMTP_DEBUG) logdebug('POSTRECORD', print_r($postrecord, true)); 
    673  
    674             $new_post = ($postrecord['post_datestamp'] >= $lastpoll && $postrecord['post_datestamp'] <= $polltime); 
    675             $edit_post = ($postrecord['post_edittime'] >= $lastpoll && $postrecord['post_edittime'] <= $polltime); 
    676  
    677             if (M2F_SMTP_DEBUG) logdebug('POST_STATE', ($new_post?"ADD":"").($new_post&&$edit_post?"-":"").($edit_post?"EDIT":"")); 
    678  
    679             // if a new post was edited within one poll cycle, don't mark it as edited 
    680             if ($new_post) $edit_post = false; 
    681              
    682             // get the forum mailing list info 
    683             $result2 = dbquery("SELECT m.m2f_email, f.forum_name FROM ".$db_prefix."M2F_forums m, ".$db_prefix."forums f WHERE m.m2f_active = '1' AND m.m2f_forumid = '".$postrecord['forum_id']."' AND m.m2f_forumid = f.forum_id"); 
    684             if (!$result2) { 
    685                 if (M2F_PROCESS_LOG) logentry('ERROR', $locale['m2f999'].' '.$locale['m2f803'].$postrecord['forum_id'], true, 1); 
    686                 die($locale['m2f803']); 
    687             } else { 
    688                 // get sender information            
    689                 $sender = dbarray($result2); 
    690                 if (M2F_SMTP_DEBUG) logdebug('SENDER', print_r($sender, true)); 
    691                  
    692                 // get all subscribed users for this forum 
    693                 $result2 = dbquery("SELECT u.*, c.* FROM ".$db_prefix."users u, ".$db_prefix."M2F_subscriptions s, ".$db_prefix."M2F_config c  
    694                     WHERE s.m2f_forumid = '".$postrecord['forum_id']."' AND s.m2f_subscribed = '1' AND u.user_id = s.m2f_userid AND u.user_id = c.m2f_userid"); 
    695                 while ($recipient = dbarray($result2)) { 
    696                     if (M2F_SMTP_DEBUG) logdebug('RECIPIENT', print_r($recipient, true)); 
    697                      
    698                     // get the senders profile (need the email address and the email-hidden flag) 
    699                     if ($edit_post) { 
    700                         // check of automatic or system posts 
    701                         if ($postrecord['post_edituser'] != 0) { 
    702                             $poster = dbarray(dbquery("SELECT user_name, user_fullname, user_email, user_hide_email FROM ".$db_prefix."users WHERE user_id = '".$postrecord['post_edituser']."'")); 
    703                         } else { 
    704                             $poster = array('user_name' => $locale['sysusr'], 'user_fullname'  => $locale['sysusr'], 'user_email' => "", 'user_hide_email' => true); 
    705                         } 
    706                     } else { 
    707                         // check of automatic or system posts 
    708                         if ($postrecord['post_author'] != 0) { 
    709                             $poster = dbarray(dbquery("SELECT user_name, user_fullname, user_email, user_hide_email FROM ".$db_prefix."users WHERE user_id = '".$postrecord['post_author']."'")); 
    710                         } else { 
    711                             $poster = array('user_name' => $locale['sysusr'], 'user_fullname'  => $locale['sysusr'], 'user_email' => "", 'user_hide_email' => true); 
    712                         } 
    713                     } 
    714                     if (M2F_SMTP_DEBUG) logdebug('POSTER', print_r($poster, true)); 
    715                      
    716                     // check if the poster wants his email address hidden. If so, use the forum address as sender 
    717                     if (M2F_USE_FORUM_EMAIL || $poster['user_hide_email']) 
    718                         $poster['user_email'] = $sender['m2f_email']; 
    719  
    720                     // basics, as from who, to whom, and use the site email as sender                    
    721                     $mail->Sender = $settings['siteemail']; 
    722                     $mail->From = $poster['user_email']; 
    723                     $mail->FromName = $poster['user_name']; 
    724                     $mail->AddAddress($recipient['user_email'], $recipient['user_fullname']); 
    725                     $mail->AddReplyTo($sender['m2f_email'], $sender['forum_name']); 
    726  
    727                     // identify this email as one from us 
    728                     $mail->AddCustomHeader("X-M2F-version: PHP-Fusion Mail2Forum v".$locale['m2fver']); 
    729                     $mail->AddCustomHeader("X-M2F-host: ".utf8_decode($settings['sitename'])); 
    730                     $mail->AddCustomHeader("X-M2F-forum: ".$sender['forum_name']); 
    731  
    732                     // set the message format, and convert the message text if needed 
    733                     $HTMLbody = $edit_post?("<b>".$locale['m2f814']."</b><br /><br />"):""; 
    734                     $HTMLbody = $postrecord['post_message']; 
    735 //                  if ($postrecord['post_showsig']) { $HTMLbody = $HTMLbody."\n\n<hr>".$postrecord['user_sig']; } 
    736                     if ($postrecord['post_smileys']) { $HTMLbody = parsesmileys($HTMLbody); } 
    737                     $HTMLbody = parseubb($HTMLbody); 
    738                     $HTMLbody = nl2br($HTMLbody); 
    739  
    740                     $TEXTbody = $edit_post?($locale['m2f814']."\r\n\r\n"):""; 
    741                     $TEXTbody .= html_entity_decode($postrecord['post_message'], ENT_QUOTES); 
    742                     //$TEXTbody = stripubb($TEXTbody); 
    743                     $TEXTbody = quotecode($TEXTbody); 
    744  
    745                     // check for attachments. If found, process them according to the users config 
    746                     if ($recipient['m2f_attach'] > 0) { 
    747                         $res_att = dbquery("SELECT * FROM ".$db_prefix."forum_attachments WHERE post_id = '".$postrecord['post_id']."'"); 
    748                         if (dbrows($res_att) != 0) { 
    749                             // although PHP-Fusion does not support multiple attachments, we do... ;-) 
    750                             while ($attachment = dbarray($res_att)) { 
    751                                 if (M2F_SMTP_DEBUG) logdebug('ATTACHMENT', print_r($attachment, true)); 
    752                                 if (USE_PLI_ENHANCEMENTS) { 
    753                                     $attachURL = $settings['siteurl']."forum/viewthread.php?forum_id=".$postrecord['forum_id']."&thread_id=".$postrecord['thread_id']."&getfile=".$attachment['attach_id']."&user_name=".$recipient['user_name']."&user_pass="; 
    754                                     $attachURL = str_replace(" ", "%20", $attachURL); 
    755                                 } else { 
    756                                     $attachURL = $settings['siteurl']."forum/attachments/".$attachment['attach_name']; 
    757                                 } 
    758                                 if ($recipient['m2f_html'] == 1) { 
    759                                     // If the attachment is an image and the config is 'show inline' 
    760                                     $isimage = array_search($attachment['attach_ext'], $imagetypes); 
    761                                     if ($isimage != false and $recipient['m2f_inline'] == 0) { 
    762                                         // include original image or only the attachment? 
    763                                         if ($recipient['m2f_thumbnail'] == 0 and file_exists(PATH_ATTACHMENTS.$attachment['attach_name'].".thumb")) { 
    764                                             $cid = uniqid("", true); 
    765                                             $mail->AddEmbeddedImage(PATH_ATTACHMENTS.$attachment['attach_name'].".thumb", $cid, ($attachment['attach_realname']==""?$attachment['attach_name']:$attachment['attach_realname']), "base64", $contenttypes[$isimage]); 
    766                                             $HTMLbody .= "<br><hr<br><a href=\"".$attachURL."\"><img src='cid:".$cid."' /></a>"; 
    767                                             $TEXTbody .= "\r\n\r\n".($attachment['attach_realname']==""?$attachment['attach_name']:$attachment['attach_realname']).": ".$attachURL; 
    768                                         } else { 
    769                                             $cid = uniqid("", true); 
    770                                             $mail->AddEmbeddedImage(PATH_ATTACHMENTS.$attachment['attach_name'], $cid, ($attachment['attach_realname']==""?$attachment['attach_name']:$attachment['attach_realname']), "base64", $contenttypes[$isimage]); 
    771                                             $HTMLbody .= "<br><hr><br><img src='cid:".$cid."' />"; 
    772                                             $TEXTbody .= "\r\n\r\n".($attachment['attach_realname']==""?$attachment['attach_name']:$attachment['attach_realname']).": ".$attachURL; 
    773                                         } 
    774                                     } else { 
    775                                         // process the attachments 
    776                                         switch ($recipient['m2f_attach']) { 
    777                                             case 0: 
    778                                                 // ignore the attachments 
    779                                                 break; 
    780                                             case 1: 
    781                                                 // attach the attachments to the email 
    782                                                 $mail->AddAttachment(PATH_ATTACHMENTS.$attachment['attach_name']); 
    783                                                 break; 
    784                                             case 2: 
    785                                                 // add a link pointing to the attachment 
    786                                                 $HTMLbody .= "<br><br>Attachment: <a href=\"".$attachURL."\">".($attachment['attach_realname']==""?$attachment['attach_name']:$attachment['attach_realname'])."</a>"; 
    787                                                 $TEXTbody .= "\r\n\r\n".($attachment['attach_realname']==""?$attachment['attach_name']:$attachment['attach_realname']).": ".$attachURL; 
    788                                                 break; 
    789                                         } 
    790                                     } 
    791                                 } else { 
    792                                     // process the attachments 
    793                                     switch ($recipient['m2f_attach']) { 
    794                                         case 0: 
    795                                             // ignore the attachments 
    796                                             break; 
    797                                         case 1: 
    798                                             // attach the attachments to the email 
    799                                             $mail->AddAttachment(PATH_ATTACHMENTS.$attachment['attach_name']); 
    800                                             break; 
    801                                         case 2: 
    802                                             // add a link pointing to the attachment 
    803                                             $TEXTbody .= "\r\n\r\nAttachment: ".$attachURL; 
    804                                             break; 
    805                                     } 
    806                                 } 
    807                             } 
    808                         }    
    809                     } 
    810  
    811                     // add a direct link to the forum message at the bottom of the email 
    812                     $HTMLbody .= "<br><br><hr>".$locale['m2f812']." - <a href='".$settings['siteurl']."forum/viewthread.php?forum_id=".$postrecord['forum_id']."&thread_id=" 
    813                         .$postrecord['thread_id']."&pid=".$postrecord['post_id']."#post_".$postrecord['post_id']."'>".$locale['m2f813']."</a>"; 
    814                     $footer = $settings['siteurl']."forum/viewthread.php?forum_id=".$postrecord['forum_id']."&thread_id=".$postrecord['thread_id']."&pid=".$postrecord['post_id']."#post_".$postrecord['post_id']; 
    815                     $TEXTbody .= "\r\n".str_repeat('_', strlen($footer))."\r\n".$footer."\r\n".$locale['m2f811']; 
    816  
    817                     // the message body (both HTML and plain-text if need be) and set the body type 
    818                     if ($recipient['m2f_html'] == 1) { 
    819                         $mail->IsHTML(true); 
    820                         $mail->Body = $HTMLbody; 
    821                         $mail->AltBody = $TEXTbody; 
    822                     } else { 
    823                         $mail->IsHTML(false); 
    824                         $mail->Body = $TEXTbody; 
    825                         $mail->AltBody = ""; 
    826                     } 
    827                                          
    828                     // add the thread ID to the subject of this post in the correct format 
    829                     $subject = html_entity_decode($postrecord['post_subject'], ENT_QUOTES)." [-".$postrecord['thread_id']."-]"; 
    830                     $mail->Subject = $subject; 
    831                      
    832                     // send the post to the user 
    833                     if(!$mail->Send()) { 
    834                         if (M2F_PROCESS_LOG) logentry('SEND', 'ERROR! From:'.$poster['user_email'].' To:'.$recipient['user_email'].' -> '.$mail->ErrorInfo); 
    835                         unset($mail); 
    836                         $mail = new PHPMailer(); 
    837                         mailer_init(); 
    838                     } else { 
    839                         $result4 = dbquery("UPDATE ".$db_prefix."M2F_forums SET m2f_sent = m2f_sent + 1 WHERE m2f_forumid = '".$postrecord['forum_id']."' "); 
    840                         if (M2F_PROCESS_LOG) logentry('SEND', 'From:'.$poster['user_email'].' To:'.$recipient['user_email'].' -> '.$subject); 
    841                     } 
    842  
    843                     // make sure all traces of the mail are wiped out 
    844                     $mail->ClearAddresses(); 
    845                     $mail->ClearAllRecipients(); 
    846                     $mail->ClearAttachments(); 
    847                     $mail->ClearBCCs(); 
    848                     $mail->ClearCCs(); 
    849                     $mail->ClearCustomHeaders(); 
    850                     $mail->ClearReplyTos(); 
    851                     $mail->Body = ""; 
    852                     $mail->AltBody = ""; 
    853                 } 
    854             } 
    855         } 
    856     } else { 
    857         if (M2F_PROCESS_LOG) logentry('POLL', 'no new posts'); 
    858     } 
    859  
    860     // update the status table 
    861     $result = dbquery("UPDATE ".$db_prefix."M2F_status SET m2f_lastpoll = '".$polltime."'"); 
    862      
    863     // if the module has been modified, exit so it can be restarted 
    864     clearstatcache(); 
    865     if (filemtime('m2f_smtp.php') != $module_lastmod) { 
    866         if (M2F_PROCESS_LOG) logentry('EXIT', 'Restart due to module code update'); 
    867         exit(99); 
    868     } 
    869     // if the config has been modified, exit so it can be reloaded 
    870     if (filemtime('m2f_config.php') != $config_lastmod) { 
    871         if (M2F_PROCESS_LOG) logentry('EXIT', 'Restart due to configuration change'); 
    872         exit(99); 
    873     } 
    874  
    875     // calculate the next interval. Log a warning if we can't process quick enough 
    876     $interval = $polltime + M2F_INTERVAL - time(); 
    877     if ($interval < 0) { 
    878         if (M2F_PROCESS_LOG) logentry('SLEEP', $locale['m2f999'].' '.$locale['m2f804']); 
    879     } else { 
    880         sleep($interval); 
    881     } 
    882  
    883     // get the last polled time from the database 
    884     $result = dbquery("SELECT * FROM ".$db_prefix."M2F_status"); 
    885     if ($data = dbarray($result)) { 
    886         if ($data['m2f_abort'] == 1) { 
    887             if (M2F_PROCESS_LOG) logentry('WAKE-UP', $locale['m2f999'].' '.$locale['m2f805'], true, 1); 
    888             die($locale['m2f805']); 
    889         } 
    890         $lastpoll = $data['m2f_lastpoll']+1; 
    891     } else { 
    892         if (M2F_PROCESS_LOG) logentry('WAKE-UP', $locale['m2f999'].' '.$locale['m2f802'], true, 1); 
    893         die($locale['m2f802']); 
    894     } 
    895 } 
    896 ?> 
Note: See TracChangeset for help on using the changeset viewer.