9299f30555f6e4e9e6323566132bd49522c7958c
[cacert-devel.git] / scripts / send_thawte.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
21 // english (use the same for foreign language, too)
22
23 $lines_EN = "";
24 if (file_exists("thawte_EN.txt"))
25 {
26 $fp = fopen("thawte_EN.txt", "r");
27 while(!feof($fp))
28 {
29 $line = trim(fgets($fp, 4096));
30 $lines_EN .= wordwrap($line, 75, "\n")."\n";
31 }
32 fclose($fp);
33 }
34
35 $lines_DE = "";
36 if (file_exists("thawte_DE.txt"))
37 {
38 $fp = fopen("thawte_DE.txt", "r");
39 while(!feof($fp))
40 {
41 $line = trim(fgets($fp, 4096));
42 $lines_DE .= wordwrap($line, 75, "\n")."\n";
43 }
44 fclose($fp);
45 }
46
47 $lines_NL = "";
48 if (file_exists("thawte_NL.txt"))
49 {
50 $fp = fopen("thawte_NL.txt", "r");
51 while(!feof($fp))
52 {
53 $line = trim(fgets($fp, 4096));
54 $lines_EN .= wordwrap($line, 75, "\n")."\n";
55 }
56 fclose($fp);
57 }
58
59 $lines_FR = "";
60 if (file_exists("thawte_FR.txt"))
61 {
62 $fp = fopen("thawte_FR.txt", "r");
63 while(!feof($fp))
64 {
65 $line = trim(fgets($fp, 4096));
66 $lines_EN .= wordwrap($line, 75, "\n")."\n";
67 }
68 fclose($fp);
69 }
70
71 $lines_ES = "";
72 if (file_exists("thawte_ES.txt"))
73 {
74 $fp = fopen("thawte_ES.txt", "r");
75 while(!feof($fp))
76 {
77 $line = trim(fgets($fp, 4096));
78 $lines_EN .= wordwrap($line, 75, "\n")."\n";
79 }
80 fclose($fp);
81 }
82
83 $lines_RU = "";
84 if (file_exists("thawte_RU.txt"))
85 {
86 $fp = fopen("thawte_RU.txt", "r");
87 while(!feof($fp))
88 {
89 $line = trim(fgets($fp, 4096));
90 $lines_EN .= wordwrap($line, 75, "\n")."\n";
91 }
92 fclose($fp);
93 }
94
95 // read last used id
96 $lastid = 0;
97 if (file_exists("send_thawte_lastid.txt"))
98 {
99 $fp = fopen("send_thawte_lastid.txt", "r");
100 $line = fgets($fp, 4096);
101 $lastid = wordwrap($line, 75, "\n")."\n";
102 fclose($fp);
103 }
104
105 $subject = "Change in points calculation";
106
107 echo "ID now: $lastid\n";
108
109 $query = "select `id`,`fname`,`lname`,`email`,`language` from `users` where `deleted` = '0' and `id` > '$lastid' order by `id`";
110
111 $res = mysql_query($query);
112
113 while($row = mysql_fetch_assoc($res))
114 {
115 $mailtxt = "Hello ".$row["fname"]." ".$row["lname"]."\n".$lines_EN."\n\n";
116 switch ($row["language"])
117 {
118 case "de_DE":
119 case "de":
120 $mailtxt .= $lines_DE;
121 break;
122
123 case "nl_NL":
124 case "nl":
125 $mailtxt .= $lines_NL;
126 break;
127
128 case "fr_FR":
129 case "fr":
130 $mailtxt .= $lines_FR;
131 break;
132
133 case "es_ES":
134 case "es":
135 $mailtxt .= $lines_ES;
136 break;
137
138 case "ru_RU":
139 case "ru":
140 $mailtxt .= $lines_RU;
141 break;
142 }
143
144 sendmail($row['email'], "[CAcert.org] $subject", $mailtxt, "mailing@cacert.org", "", "", "CAcert", "returns@cacert.org", 1);
145
146 $fp = fopen("send_thawte_lastid.txt", "w");
147 fputs($fp, $row["id"]."\n");
148 fclose($fp);
149
150 echo "Sent mail to: ".$row["id"]."\n";
151
152 sleep (1);
153 }
154 ?>