f8042ac7458d1571a12e081d951963a6ffc9d7cd
[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 // read last used id
48 $lastid = 0;
49 if (file_exists("lastid.txt"))
50 {
51 $fp = fopen("lastid.txt", "r");
52 $line = fgets($fp, 4096);
53 $lastid = wordwrap($line, 75, "\n")."\n";
54 fclose($fp);
55 }
56 $subject = "Change in points calculation";
57
58 echo "ID now: $lastid";
59
60 $query = "select id,fromname,lastname,email* from users where deleted = 0 and id > $lastid order by id";
61
62 $res = mysql_query($query);
63 $xrows = mysql_num_rows($res);
64
65 while($row = mysql_fetch_assoc($res))
66 {
67 $mailtxt = "Hello ".$row["fromname"]." ".$row["lastname"]."\n".$lines_EN."\n\n";
68 switch ($row[$language])
69 {
70 case "de_DE": $mailtxt .= $lines_DE; break;
71 case "ade_DE": $mailtxt .= $lines_DE; break;
72 case "bde_DE": $mailtxt .= $lines_DE; break;
73 case "cde_DE": $mailtxt .= $lines_DE; break;
74 case "dde_DE": $mailtxt .= $lines_DE; break;
75 case "ede_DE": $mailtxt .= $lines_DE; break;
76 }
77 // uncomment next line to send mails ...
78 // sendmail($row['email'], "[CAcert.org] $subject", $mailtxt, "mailing@cacert.org", "", "", "CAcert", "returns@cacert.org", 1);
79 $fp = fopen("lastid.txt", "w");
80 fputs($fp, $row["id"]."\n");
81 fclose($fp);
82 sleep (1);
83 echo "Sent mail to: ".$row["id"];
84 }
85 ?>