Merge remote-tracking branch 'origin/bug-1213' into release
[cacert-devel.git] / scripts / 29au-ate-brisbane-mail.php.txt
1 #!/usr/bin/php -q
2 <? /*
3 LibreSSL - CAcert web application
4 Copyright (C) 2004-2009 CAcert Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; version 2 of the License.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 include_once("../includes/mysql.php");
20
21 $lines = "";
22 $fp = fopen("29au-ate-brisbane-email.txt", "r");
23 while(!feof($fp))
24 {
25 $line = trim(fgets($fp, 4096));
26 $lines .= wordwrap($line, 75, "\n")."\n";
27 }
28 fclose($fp);
29
30
31 // $locid = intval($_REQUEST['location']);
32 // $maxdist = intval($_REQUEST['maxdist']);
33 $maxdist = 100;
34
35 // ATE Brisbane, AU, 24 Jan 2011
36 $locid = 2258704; // Brisbane, QLD, Australia
37 $eventname = "ATE-Brisbane";
38 $city = "Monday 24th January";
39
40
41
42 $query = "select * from `locations` where `id`='$locid'";
43 $loc = mysql_fetch_assoc(mysql_query($query));
44
45 $query = "SELECT ROUND(6378.137 * ACOS(0.9999999*((SIN(PI() * $loc[lat] / 180) * SIN(PI() * `locations`.`lat` / 180)) +
46 (COS(PI() * $loc[lat] / 180 ) * COS(PI() * `locations`.`lat` / 180) *
47 COS(PI() * `locations`.`long` / 180 - PI() * $loc[long] / 180)))), -1) AS `distance`, sum(`points`) as pts, `users`.*
48 FROM `locations`
49 inner join `users` on `users`.`locid` = `locations`.`id`
50 inner join `alerts` on `users`.`id`=`alerts`.`memid`
51 inner join `notary` on `users`.`id`=`notary`.`to`
52 WHERE (`alerts`.`general`=1 OR `alerts`.`country`=1 OR `alerts`.`regional`=1 OR `alerts`.`radius`=1)
53 GROUP BY `users`.`id`
54 HAVING `distance` <= '$maxdist'
55 ORDER BY `distance` ";
56 echo $query;
57
58 // comment next line when starting to send mail not only to me
59 // $query = "select * from `users` where `email` like 'cacerttest%'";
60
61 $res = mysql_query($query);
62 $xrows = mysql_num_rows($res);
63
64 while($row = mysql_fetch_assoc($res))
65 {
66 // uncomment next line to send mails ...
67 sendmail($row['email'], "[CAcert.org] $eventname - $city", $lines, "events@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
68 }
69 // 1x cc to events.cacert.org
70 sendmail("events@cacert.org", "[CAcert.org] $eventname - $city", $lines, "events@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
71 // 1x mailing report to events.cacert.org
72 sendmail("events@cacert.org", "[CAcert.org] $eventname - $city Report", "invitation sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
73
74 // 1x mailing report to Arbitrator of case http://wiki.cacert.org/wiki/Arbitrations/a20090525.1
75 sendmail("p.dunkel@cacert.org", "[CAcert.org] $eventname - $city Report", "invitation sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
76 echo "invitation sent to $xrows recipients.\n";
77
78 ?>