From 95c63810079c9759cf1c8b9f9e55e09e8e4407d4 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 1 Mar 2006 18:03:41 +0000 Subject: [PATCH] reorganize the send_communication script to be more efficient --- admin/send_communication.php | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/admin/send_communication.php b/admin/send_communication.php index 5c68ce8b..81685e61 100644 --- a/admin/send_communication.php +++ b/admin/send_communication.php @@ -43,33 +43,33 @@ if(file_exists("../data/communication.lock")) $headers="From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n"; $x=1; - - if(array_key_exists($to,$mailqueries)) + { $q=mysql_query($mailqueries[$to]['query']); + while($r=mysql_fetch_object($q)) + { + if($r->firstname && $r->lastname) + $to="$r->firstname $r->lastname <".$r->email.">"; + else if($r->firstname) + $to="$r->firstname <".$r->email.">"; + else + $to=$r->email; + + mail($to,$subject,$body,$headers); + + $fp=fopen("../data/communication.lock.$id","w"); + fputs($fp,$x."\n"); + fclose($fp); + usleep(rand($sleepmin,$sleepmax)); + $x++; + + } + unlink("../data/communication.lock.$id"); + unlink("../data/communication.lock"); + } else echo i18n("Unknown 'to' to send email communication to (%1)",array($to)); - while($r=mysql_fetch_object($q)) - { - if($r->firstname && $r->lastname) - $to="$r->firstname $r->lastname <".$r->email.">"; - else if($r->firstname) - $to="$r->firstname <".$r->email.">"; - else - $to=$r->email; - - mail($to,$subject,$body,$headers); - - $fp=fopen("../data/communication.lock.$id","w"); - fputs($fp,$x."\n"); - fclose($fp); - usleep(rand($sleepmin,$sleepmax)); - $x++; - - } - unlink("../data/communication.lock.$id"); - unlink("../data/communication.lock"); } else {