Source code taken from cacert-20131120.tar.bz2
[cacert-devel.git] / scripts / mailing archive / oa01-allowance.php.txt
1 #!/usr/bin/php -q
2 <? /*
3 LibreSSL - CAcert web application
4 Copyright (C) 2004-2011 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("oa01-allowance.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 // --- Variable parameters --- begin
31
32 // $country
33 // "" (empty) email to _all_ countries
34 // "DE" 2-digit country code, eg. email to Germany Org's only
35
36 // $status
37 // Status: 1 mails to org contacts only
38 // 2 mails to org admins only
39 // 3 mails to org contacts + org admins
40
41 // $subject
42 // sample:
43 // with
44 // mailing subject results in
45 // a) $country = ""
46 // "[CAcert.org] Allowance to publish Organisation Assurance on CAcert website"
47 // b) $country = "DE"
48 // "[CAcert.org] Allowance to publish Organisation Assurance on CAcert website (DE)"
49
50
51 //OA Allowance
52 $country = ""; // "DE" or ""
53 $status = 3; // 1, 2 or 3 3 = 1+2
54 $subject = "Allowance to publish Organisation Assurance on CAcert website";
55
56
57 // --- Variable parameters --- end
58
59 $query = "SELECT orginfo.contact as email, orginfo.O, 1 as status
60 FROM orginfo
61 WHERE (orginfo.C like '$country%' and (1=$status or 3=$status))
62 UNION
63 Select users.email, orginfo.O, 2 as status
64 FROM users
65 inner join org on users.id = org.memid
66 inner join orginfo on org.orgid=orginfo.id
67 WHERE (orginfo.C like '$country%' and (2=$status or 3=$status))
68 ORDER BY O";
69
70
71 echo $query;
72
73 // comment next line when starting to send mail not only to me
74 // $query = "select * from `users` where `email` like 'cacerttest%'";
75
76 $res = mysql_query($query);
77 $xrows = mysql_num_rows($res);
78
79 while($row = mysql_fetch_assoc($res))
80 {
81 // uncomment next line to send mails ...
82 sendmail($row['email'], "[CAcert.org] ".$subject.(empty($country)?"":" (".$country.")") , $lines, "support@cacert.org", "", "", "CAcert OA Support", "returns@cacert.org", 1);
83 }
84 // 1x cc to oao.cacert.org
85 sendmail("oao@cacert.org", "[CAcert.org] ".$subject.(empty($country)?"":" (".$country.")"), $lines, "oao@cacert.org", "", "", "CAcert OA Support", "returns@cacert.org", 1);
86 // 1x mailing report to oao.cacert.org
87 sendmail("oao@cacert.org", "[CAcert.org] ".$subject.(empty($country)?"":" (".$country.")")." - Report", "oa-mailing sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert OA Support", "returns@cacert.org", 1);
88
89 // 1x mailing report to Arbitrator of case http://wiki.cacert.org/wiki/Arbitrations/a20110608.1
90 sendmail("bernhard@cacert.org", "[CAcert.org] ".$subject.(empty($country)?"":" (".$country.")")." - Report", "oa-mailing sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert OA Support", "returns@cacert.org", 1);
91
92 echo "oa-mailing sent to $xrows recipients.\n";
93 ?>