Source code taken from cacert-20131016.tar.bz2
[cacert-devel.git] / scripts / oa02-orgainformation.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 include_once("../includes/lib/general.php");
21
22 //default mail text
23 $lines = "";
24 $fp = fopen("oa02-mailingtextPoints.txt", "r");
25 while(!feof($fp))
26 {
27 $line = trim(fgets($fp, 4096));
28 $lines .= wordwrap($line, 75, "\n")."\n";
29 }
30 fclose($fp);
31
32 //first variant of mail text
33 $lines1 = "";
34 $fp = fopen("oa02-mailingtextCats.txt", "r");
35 while(!feof($fp))
36 {
37 $line = trim(fgets($fp, 4096));
38 $lines1 .= wordwrap($line, 75, "\n")."\n";
39 }
40 fclose($fp);
41
42 //second variant of mail text
43 $lines2 = "";
44 $fp = fopen("oa02-mailingtextPointsCats.txt", "r");
45 while(!feof($fp))
46 {
47 $line = trim(fgets($fp, 4096));
48 $lines2 .= wordwrap($line, 75, "\n")."\n";
49 }
50 fclose($fp);
51
52 // comment next line when starting to send mail not only to me
53 // $query = "select * from `users` where `email` like 'cacerttest%'";
54
55 $query = "
56 SELECT
57 `users`.`email`,
58 `users`.`fname`,
59 `users`.`lname`,
60 `orginfo`.`O`,
61 `orginfo`.`id`,
62 `org`.`memid`
63 FROM
64 `users`,
65 `orginfo`,
66 `org`
67 WHERE `org`.`orgid` = `orginfo`.`id`
68 AND `org`.`memid` = `users`.`id`
69 AND `users`.`assurer` = 0
70 AND `org`.`deleted` = 0
71 ORDER BY
72 `users`.`email`,
73 `orginfo`.`O`
74 ";
75
76 $res = mysql_query($query);
77 $xrows = mysql_num_rows($res);
78
79 $report = "";
80 $report1 = "";
81 $report2 = "";
82 $report3 = "";
83
84 while($row = mysql_fetch_assoc($res))
85 {
86 // uncomment next line to send mails ...
87 $fullname = $row['fname']." ".$row['lname'];
88 $status = get_assurer_status($row['memid']);
89 if (3 == $status) {
90 $mail = str_replace("<name>",$fullname,$lines);
91 sendmail($row['email'], "[CAcert.org] Assurer Status Requirement Check on Organisation Adminstrators", $mail, "support@cacert.org", "", "", "CAcert Organisation Assurer", "returns@cacert.org", 1);
92 $report = $row['email'].", ".$fullname.", ".$row['O']."\n";
93 } elseif (5 == $status) {
94 $mail = str_replace("<name>",$fullname,$lines1);
95 sendmail($row['email'], "[CAcert.org] Assurer Status Requirement Check on Organisation Adminstrators", $mail, "support@cacert.org", "", "", "CAcert Organisation Assurer", "returns@cacert.org", 1);
96 $report1 = $row['email'].", ".$fullname.", ".$row['O']."\n";
97 } elseif (7 == $status){
98 $mail = str_replace("<name>",$fullname,$lines2);
99 sendmail($row['email'], "[CAcert.org] Assurer Status Requirement Check on Organisation Adminstrators", $mail, "support@cacert.org", "", "", "CAcert Organisation Assurer", "returns@cacert.org", 1);
100 $report2 = $row['email'].", ".$fullname.", ".$row['O']."\n";
101 } else {
102 $report3 = $row['email'].", ".$fullname.", ".$row['O']."\n";
103 }
104 }
105
106 // 1x cc to oao.cacert.org
107 sendmail("oao@cacert.org", "[CAcert.org] Assurer Status Requirement Check on Organisation Adminstrators", $lines."\n\n".$lines1."\n\n".$lines2, "oao@cacert.org", "", "", "CAcert OA Support", "returns@cacert.org", 1);
108
109 // 1x mailing report to oao.cacert.org
110 sendmail("oao@cacert.org", "[CAcert.org] Assurer Status Requirement Check on Organisation Adminstrators - Report", "oa-mailing sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert OA Support", "returns@cacert.org", 1);
111
112 // 1x detailed mailing report to OAO
113 $reporttotal = "Result of the Mailing \n\n Organisation Administrators with missing points \n".$report."\n\n Organisation Adminstrators with missing points ".$report1."\n\n Organisation Adminstrators with missing points and CATS ".$report2."\n\n Organisation Adminstrators with blocked assurer ".$report3;
114 sendmail("oao@cacert.org", "[CAcert.org] Assurer Status Requirement Check on Organisation Adminstrators - Report", $reporttotal, "support@cacert.org", "", "", "CAcert Organisation Assurer", "returns@cacert.org", 1);
115
116 // 1x mailing report to Arbitrator of case http://wiki.cacert.org/wiki/Arbitrations/a20110608.1
117 sendmail("bernhard@cacert.org", "[CAcert.org] Assurer Status Requirement Check on Organisation Adminstrators - Report", "oa-mailing sent to $xrows recipients.", "support@cacert.org", "", "", "CAcert OA Support", "returns@cacert.org", 1);
118
119 echo "oa-mailing sent to $xrows recipients.\n";