summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMichael Tänzer <neo@nhng.de>2014-04-08 17:43:51 +0200
committerMichael Tänzer <neo@nhng.de>2014-04-08 17:43:51 +0200
commit13aa009d4ca5779b228251f8e3b07c05caf16919 (patch)
tree90d2761269c23e95c17011a29779e7559a0149c3 /scripts
parent0d791f450e65657cfd615471cf31dfc0ba5d9b37 (diff)
downloadcacert-devel-13aa009d4ca5779b228251f8e3b07c05caf16919.tar.gz
cacert-devel-13aa009d4ca5779b228251f8e3b07c05caf16919.tar.xz
cacert-devel-13aa009d4ca5779b228251f8e3b07c05caf16919.zip
bug 1265: Use thawte mail script as starting point for heartbleed mailing
Signed-off-by: Michael Tänzer <neo@nhng.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/send_heartbleed.php167
1 files changed, 167 insertions, 0 deletions
diff --git a/scripts/send_heartbleed.php b/scripts/send_heartbleed.php
new file mode 100644
index 0000000..c7cd88d
--- /dev/null
+++ b/scripts/send_heartbleed.php
@@ -0,0 +1,167 @@
+#!/usr/bin/php -q
+<?php
+/*
+ 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");
+
+// read texts
+
+$lines_EN = "";
+if (file_exists("thawte_EN.txt"))
+{
+ $fp = fopen("thawte_EN.txt", "r");
+ while(!feof($fp))
+ {
+ $line = trim(fgets($fp, 4096));
+ $line = wordwrap($line, 75, "\n")."\n";
+ $line = mb_convert_encoding($line, "HTML-ENTITIES", "UTF-8");
+ $lines_EN .= $line;
+ }
+ fclose($fp);
+}
+
+$lines_DE = "";
+if (file_exists("thawte_DE.txt"))
+{
+ $fp = fopen("thawte_DE.txt", "r");
+ while(!feof($fp))
+ {
+ $line = trim(fgets($fp, 4096));
+ $line = wordwrap($line, 75, "\n")."\n";
+ $line = mb_convert_encoding($line, "HTML-ENTITIES", "UTF-8");
+ $lines_DE .= $line;
+ }
+ fclose($fp);
+}
+
+$lines_NL = "";
+if (file_exists("thawte_NL.txt"))
+{
+ $fp = fopen("thawte_NL.txt", "r");
+ while(!feof($fp))
+ {
+ $line = trim(fgets($fp, 4096));
+ $line = wordwrap($line, 75, "\n")."\n";
+ $line = mb_convert_encoding($line, "HTML-ENTITIES", "UTF-8");
+ $lines_NL .= $line;
+ }
+ fclose($fp);
+}
+
+$lines_FR = "";
+if (file_exists("thawte_FR.txt"))
+{
+ $fp = fopen("thawte_FR.txt", "r");
+ while(!feof($fp))
+ {
+ $line = trim(fgets($fp, 4096));
+ $line = wordwrap($line, 75, "\n")."\n";
+ $line = mb_convert_encoding($line, "HTML-ENTITIES", "UTF-8");
+ $lines_FR .= $line;
+ }
+ fclose($fp);
+}
+
+$lines_ES = "";
+if (file_exists("thawte_ES.txt"))
+{
+ $fp = fopen("thawte_ES.txt", "r");
+ while(!feof($fp))
+ {
+ $line = trim(fgets($fp, 4096));
+ $line = wordwrap($line, 75, "\n")."\n";
+ $line = mb_convert_encoding($line, "HTML-ENTITIES", "UTF-8");
+ $lines_ES .= $line;
+ }
+ fclose($fp);
+}
+
+$lines_RU = "";
+if (file_exists("thawte_RU.txt"))
+{
+ $fp = fopen("thawte_RU.txt", "r");
+ while(!feof($fp))
+ {
+ $line = trim(fgets($fp, 4096));
+ $line = wordwrap($line, 75, "\n")."\n";
+ $line = mb_convert_encoding($line, "HTML-ENTITIES", "UTF-8");
+ $lines_RU .= $line;
+ }
+ fclose($fp);
+}
+
+// read last used id
+$lastid = 0;
+if (file_exists("send_thawte_lastid.txt"))
+{
+ $fp = fopen("send_thawte_lastid.txt", "r");
+ $lastid = trim(fgets($fp, 4096));
+ fclose($fp);
+}
+
+echo "ID now: $lastid\n";
+
+
+$count = 0;
+
+$query = "select `id`,`fname`,`lname`,`email`,`language` from `users` where `deleted` = 0 and `id` > '$lastid' order by `id`";
+
+$res = mysql_query($query);
+
+while($row = mysql_fetch_assoc($res))
+{
+ $mailtxt = "Hello ${row["fname"]} ${row["lname"]},\n".$lines_EN."\n\n";
+ switch ($row["language"])
+ {
+ case "de_DE":
+ case "de":
+ $mailtxt .= $lines_DE;
+ break;
+
+ case "nl_NL":
+ case "nl":
+ $mailtxt .= $lines_NL;
+ break;
+
+ case "fr_FR":
+ case "fr":
+ $mailtxt .= $lines_FR;
+ break;
+
+ case "es_ES":
+ case "es":
+ $mailtxt .= $lines_ES;
+ break;
+
+ case "ru_RU":
+ case "ru":
+ $mailtxt .= $lines_RU;
+ break;
+ }
+
+ sendmail($row['email'], "[CAcert.org] Changes at CAcert", $mailtxt, "mailing@cacert.org", "", "", "CAcert", "returns@cacert.org", "");
+
+ $fp = fopen("send_thawte_lastid.txt", "w");
+ fputs($fp, $row["id"]."\n");
+ fclose($fp);
+
+ $count++;
+ echo "Sent ${count}th mail. User ID: ${row["id"]}\n";
+
+ sleep (1);
+}