Source code taken from cacert-20130129.tar.bz2
[cacert.git] / scripts / ate-us02-mail.php.txt
1 #!/usr/bin/php -q
2 <? /*
3 LibreSSL - CAcert web application
4 Copyright (C) 2004-2008 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("ate-us02-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 // Duesseldorf 51.2167N 6.7667E
31 // VELBERT 51.333 7.050; FRANKFURT AM MAIN 50.117 8.683
32
33 // $locid = intval($_REQUEST['location']);
34 // $maxdist = intval($_REQUEST['maxdist']);
35 // $maxdist = 200; // km
36 $maxdist = 450; // 300 miles * 1,5 => km
37
38
39 // location location.ID
40 // verified: 29.4.09 u.schroeter
41 // $locid = 7902857; // Paris
42 // $locid = 238568; // Bielefeld
43 // $locid = 715191; // Hamburg
44 // $locid = 1102495; // London
45 // $locid = 520340; // Duesseldorf
46 // $locid = 1260319; // Muenchen
47 // $locid = 606058; // Frankfurt
48 // $locid = 1775784; // Stuttgart
49 // $locid = 228950; // Berlin
50
51 // $locid = 2096325; // San Diego
52
53
54 $locid = 2096325; // San Diego
55 $city = "San Diego CA, May, 14th-19th 2009";
56
57
58 $query = "select * from `locations` where `id`='$locid'";
59 $loc = mysql_fetch_assoc(mysql_query($query));
60
61 // `users`.`assurer`=0 => did NOT passed assurer challenge
62 $query = "SELECT ROUND(6378.137 * ACOS(0.9999999*((SIN(PI() * $loc[lat] / 180) * SIN(PI() * `locations`.`lat` / 180)) +
63 (COS(PI() * $loc[lat] / 180 ) * COS(PI() * `locations`.`lat` / 180) *
64 COS(PI() * `locations`.`long` / 180 - PI() * $loc[long] / 180)))), -1) AS `distance`, sum(`points`) as pts, `users`.*
65 FROM `locations`
66 inner join `users` on `users`.`locid` = `locations`.`id`
67 inner join `alerts` on `users`.`id`=`alerts`.`memid`
68 inner join `notary` on `users`.`id`=`notary`.`to`
69 WHERE (`alerts`.`general`=1 OR `alerts`.`country`=1 OR `alerts`.`regional`=1 OR `alerts`.`radius`=1)
70 GROUP BY `users`.`id`
71 HAVING `distance` <= '$maxdist'
72 ORDER BY `distance` ";
73 // and sum(points) < 101
74
75 echo $query;
76
77 // comment next line when starting to send mail not only to me
78 // $query = "select * from `users` where `email` like 'cacerttest%'";
79
80 $res = mysql_query($query);
81 $xrows = mysql_num_rows($res);
82
83 while($row = mysql_fetch_assoc($res))
84 {
85 // echo $row['pts']."..".$row['email']."...\n";
86 // uncomment next line to send mails ...
87 sendmail($row['email'], "[CAcert.org] $city", $lines, "events@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
88 }
89 // 1x cc to events.cacert.org
90 sendmail("events@cacert.org", "[CAcert.org] $city", $lines, "events@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
91 // 1x mailing report to events.cacert.org
92 sendmail("events@cacert.org", "[CAcert.org] $city Report", "invitation sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
93 // 1x mailing report to Arbitrator of case http://wiki.cacert.org/wiki/Arbitrations/a20090525.1
94 sendmail("p.dunkel@cacert.org", "[CAcert.org] $city Report", "invitation sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
95
96 echo "invitation sent to $xrows recipients.";
97 ?>