Merge branch 'bug-1459' into release (Emergency bugfix)
[cacert-devel.git] / scripts / 58at-ate-wien-mail.php.txt
1 #!/usr/bin/php -q
2 <? /*
3 LibreSSL - CAcert web application
4 Copyright (C) 2004-2013 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("58at-ate-wien-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 in [Km]
34 $maxdist = 200;
35
36
37 // location location.ID
38 // verified: 29.4.09 u.schroeter
39 // $locid = 7902857; // Paris
40 // $locid = 238568; // Bielefeld
41 // $locid = 715191; // Hamburg
42 // $locid = 1102495; // London
43 // $locid = 606058; // Frankfurt
44 // $locid = 1775784; // Stuttgart
45 // $locid = 228950; // Berlin
46 // $locid = 606058; // Frankfurt
47 // $locid = 599389; // Flensburg
48 // $locid = 61065; // Amsterdam, Eemnes
49 // $locid = 228950; // Berlin
50 // $locid = 2138880; // Baltimore (Baltimore (city)), Maryland, United States
51 // $locid = 1486658; // Potsdam
52 // $locid = 664715; // Goteborg, Vastra Gotaland, Sweden
53 // $locid = 2094781; // Mission Hills (Los Angeles), California, United States
54 // $locid = 423655; // Copenhagen, Kobenhavn*, Denmark
55 // $locid = 2093625; // Los Angeles, CA ???
56 // $locid = 2094326 // Los Angeles (Los Angeles), California, United States
57 // $locid = 2257312; // Sydney, New South Wales, Australia
58 // $locid = 572764; // Essen, Nordrhein-Westfalen, Germany
59 // $locid = 78; // Aachen, Nordrhein-Westfalen, Germany
60 // $locid = 1260319; // Muenchen
61 // $locid = 266635; // Bonn, Nordrhein-Westfalen, Germany
62 // $locid = 873779; // Karlsruhe, Baden-Wuerttemberg, Germany
63 // $locid = 520340; // Dusseldorf, Nordrhein-Westfalen, Germany
64 // $locid = 2262656; // Melbourne, Victoria, Australia
65 // $locid = 2185076; // Raleigh (Wake), North Carolina, United States
66 // $locid = 2126955; // Lawrence (Douglas), Kansas, United States
67 // $locid = 919560; // Kiel, Schleswig-Holstein, Germany
68 // $locid = 228950; // Berlin
69 // $locid = 1117395; // Lubeck Hansestadt, Schleswig-Holstein, Germany
70 // $locid = 675661; // Graz, Steiermark, Austria
71 // $locid = 1992733; // Wien, Wien, Austria
72
73 // $locid = ; 54334 // Amberg, Bayern, Germany
74 // $eventname = "ATE-Amberg";
75 // $city = "06. Januar 2014";
76
77 // $locid = 1089877; // Linz, Oberoesterreich, Austria
78 // $eventname = "ATE-Linz";
79 // $city = "16. Mai 2014";
80
81 // $locid = 1993029; // Wiesbaden, Hessen, Germany
82 // $eventname = "ATE-Wiesbaden";
83 // $city = "22. Mai 2014";
84
85
86 // $locid = 1356196; // Oberwart, Burgenland, Germany
87 // $eventname = "ATE-Oberwart (Korrektur)";
88 // $city = "27. Juni 2014";
89
90 // $locid = 675661; // Graz, Steiermark, Austria
91 // $eventname = "ATE-Graz";
92 // $city = "13. November 2014";
93
94 $locid = 1992733; // Wien, Wien, Austria
95 $eventname = "ATE-Wien";
96 $city = "19. November 2014";
97
98 $query = "select * from `locations` where `id`='$locid'";
99 $loc = mysql_fetch_assoc(mysql_query($query));
100
101 $query = "SELECT ROUND(6378.137 * ACOS(0.9999999*((SIN(PI() * $loc[lat] / 180) * SIN(PI() * `locations`.`lat` / 180)) +
102 (COS(PI() * $loc[lat] / 180 ) * COS(PI() * `locations`.`lat` / 180) *
103 COS(PI() * `locations`.`long` / 180 - PI() * $loc[long] / 180)))), -1) AS `distance`, sum(`points`) as pts, `users`.*
104 FROM `locations`
105 inner join `users` on `users`.`locid` = `locations`.`id`
106 inner join `alerts` on `users`.`id`=`alerts`.`memid`
107 inner join `notary` on `users`.`id`=`notary`.`to`
108 WHERE (`alerts`.`general`=1 OR `alerts`.`country`=1 OR `alerts`.`regional`=1 OR `alerts`.`radius`=1)
109 GROUP BY `users`.`id`
110 HAVING `distance` <= '$maxdist'
111 ORDER BY `distance` ";
112 echo $query;
113
114 // comment next line when starting to send mail not only to me
115 // $query = "select * from `users` where `email` like 'cacerttest%'";
116
117 $res = mysql_query($query);
118 $xrows = mysql_num_rows($res);
119
120 while($row = mysql_fetch_assoc($res))
121 {
122 // uncomment next line to send mails ...
123 sendmail($row['email'], "[CAcert.org] $eventname - $city", $lines, "events@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
124 }
125 // 1x cc to events.cacert.org
126 sendmail("events@cacert.org", "[CAcert.org] $eventname - $city", $lines, "events@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
127 // 1x mailing report to events.cacert.org
128 sendmail("events@cacert.org", "[CAcert.org] $eventname - $city Report", "invitation sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert Events Organisation", "returns@cacert.org", 1);
129
130 // 1x mailing report to Arbitrator of case http://wiki.cacert.org/wiki/Arbitrations/a20090525.1
131 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);
132 echo "invitation sent to $xrows recipients.\n";
133
134 ?>