forked from science-ation/science-ation
83 lines
2.1 KiB
PHP
83 lines
2.1 KiB
PHP
<?
|
|
/*
|
|
This file is part of the 'Science Fair In A Box' project
|
|
SFIAB Website: http://www.sfiab.ca
|
|
|
|
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
|
Copyright (C) 2005 James Grant <james@lightbox.org>
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public
|
|
License as published by the Free Software Foundation, version 2.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; see the file COPYING. If not, write to
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Boston, MA 02111-1307, USA.
|
|
*/
|
|
?>
|
|
<?
|
|
include "../common.inc.php";
|
|
|
|
$sleepmin=500000; // 0.5 seconds
|
|
$sleepmax=2000000; // 2.0 second
|
|
|
|
if(file_exists("../data/communication.lock"))
|
|
{
|
|
$lines=file("../data/communication.lock");
|
|
$id=trim($lines[0]);
|
|
$to=trim($lines[4]);
|
|
|
|
$q=mysql_query("SELECT * FROM emails WHERE id='$id'");
|
|
$communication=mysql_fetch_object($q);
|
|
|
|
$from=$communication->from;
|
|
$subject=$communication->subject;
|
|
$body=$communication->body;
|
|
$headers="From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n";
|
|
$x=1;
|
|
|
|
|
|
|
|
switch ($to)
|
|
{
|
|
case "judges_all":
|
|
$q=mysql_query("SELECT firstname, lastname, email FROM judges ORDER BY email");
|
|
break;
|
|
default:
|
|
echo i18n("Unknown 'to' to send email communication to (%1)",array($_GET['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
|
|
{
|
|
//no communication to send... why were we called?!?!?!
|
|
}
|
|
|
|
?>
|