summaryrefslogtreecommitdiff
path: root/scripts/oa02-orgainformation.php.txt
blob: e0d8ca2f44350313e2b7e8daea3a7787c4d5479d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/php -q
<? /*
    LibreSSL - CAcert web application
    Copyright (C) 2004-2009  CAcert Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; version 2 of the License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/
	include_once("../includes/mysql.php");
	include_once("../includes/lib/general.php");

	//default mail text
	$lines = "";
	$fp = fopen("oa02-mailingtextPoints.txt", "r");
	while(!feof($fp))
	{
		$line = trim(fgets($fp, 4096));
		$lines .= wordwrap($line, 75, "\n")."\n";
	}
	fclose($fp);

	//first variant of mail text
	$lines1 = "";
	$fp = fopen("oa02-mailingtextCats.txt", "r");
	while(!feof($fp))
	{
		$line = trim(fgets($fp, 4096));
		$lines1 .= wordwrap($line, 75, "\n")."\n";
	}
	fclose($fp);

	//second variant of mail text
	$lines2 = "";
	$fp = fopen("oa02-mailingtextPointsCats.txt", "r");
	while(!feof($fp))
	{
		$line = trim(fgets($fp, 4096));
		$lines2 .= wordwrap($line, 75, "\n")."\n";
	}
	fclose($fp);

	// comment next line when starting to send mail not only to me 
	//	$query = "select * from `users` where `email` like 'cacerttest%'";

	$query = "
	SELECT
		`users`.`email`,
		`users`.`fname`,
		`users`.`lname`,
		`orginfo`.`O`,
		`orginfo`.`id`,
		`org`.`memid`
	FROM
		`users`,
		`orginfo`,
		`org`
	WHERE	`org`.`orgid` = `orginfo`.`id`
	AND	`org`.`memid` = `users`.`id`
	AND	`users`.`assurer` = 0
	AND	`org`.`deleted` = 0
	ORDER BY
		`users`.`email`,
		`orginfo`.`O`
	";

	$res = mysql_query($query);
	$xrows = mysql_num_rows($res);

	$report = "";
	$report1 = "";
	$report2 = "";
	$report3 = "";

	while($row = mysql_fetch_assoc($res))
	{
		//    uncomment next line to send mails ...
		$fullname = $row['fname']." ".$row['lname'];
		$status = get_assurer_status($row['memid']);
		if (3 == $status) {
			$mail = str_replace("<name>",$fullname,$lines);
			sendmail($row['email'], "[CAcert.org] Assurer Status Requirement Check on Organisation Adminstrators", $mail, "support@cacert.org", "", "", "CAcert Organisation Assurer", "returns@cacert.org", 1);
			$report = $row['email'].", ".$fullname.", ".$row['O']."\n";
		} elseif (5 == $status) {
			$mail = str_replace("<name>",$fullname,$lines1);
			sendmail($row['email'], "[CAcert.org] Assurer Status Requirement Check on Organisation Adminstrators", $mail, "support@cacert.org", "", "", "CAcert Organisation Assurer", "returns@cacert.org", 1);
			$report1 = $row['email'].", ".$fullname.", ".$row['O']."\n";
		} elseif (7 == $status){
			$mail = str_replace("<name>",$fullname,$lines2);
			sendmail($row['email'], "[CAcert.org] Assurer Status Requirement Check on Organisation Adminstrators", $mail, "support@cacert.org", "", "", "CAcert Organisation Assurer", "returns@cacert.org", 1);
			$report2 = $row['email'].", ".$fullname.", ".$row['O']."\n";
		} else {
			$report3 = $row['email'].", ".$fullname.", ".$row['O']."\n";
		}
	}

	// 1x cc to oao.cacert.org
	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);

	// 1x mailing report to oao.cacert.org
	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);

	// 1x detailed mailing report to OAO
	$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;
	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);

	// 1x mailing report to Arbitrator of case http://wiki.cacert.org/wiki/Arbitrations/a20110608.1
	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);

	echo "oa-mailing sent to $xrows recipients.\n";