bug827 script to send mails ... needs to be modified before start
authordirk <beliebige_email_adresse@fidocon.de>
Tue, 22 Nov 2011 21:38:58 +0000 (22:38 +0100)
committerdirk <beliebige_email_adresse@fidocon.de>
Tue, 22 Nov 2011 21:38:58 +0000 (22:38 +0100)
scripts/send_thawte.php.txt [new file with mode: 0644]

diff --git a/scripts/send_thawte.php.txt b/scripts/send_thawte.php.txt
new file mode 100644 (file)
index 0000000..f8042ac
--- /dev/null
@@ -0,0 +1,85 @@
+#!/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");
+
+// english (use the same for foreign language, too)
+
+       $lines_EN = "";
+       if (file_exists("thawte_EN.txt"))
+       {
+               $fp = fopen("thawte_EN.txt", "r");
+               while(!feof($fp))
+               {
+                       $line = trim(fgets($fp, 4096));
+                       $lines_EN .= wordwrap($line, 75, "\n")."\n";
+               }
+               fclose($fp);
+       }
+
+       $lines_DE = "";
+       if (file_exists("thawte_DE.txt"))
+       {
+               $fp = fopen("thawte_DE.txt", "r");
+               while(!feof($fp))
+               {
+                       $line = trim(fgets($fp, 4096));
+                       $lines_DE .= wordwrap($line, 75, "\n")."\n";
+               }
+               fclose($fp);
+       }
+
+// read last used id
+       $lastid = 0;
+       if (file_exists("lastid.txt"))
+       {
+               $fp = fopen("lastid.txt", "r");
+               $line = fgets($fp, 4096);
+               $lastid = wordwrap($line, 75, "\n")."\n";
+               fclose($fp);
+       }
+        $subject = "Change in points calculation";
+
+       echo "ID now: $lastid";
+
+       $query = "select id,fromname,lastname,email* from users where deleted = 0 and id > $lastid order by id";
+
+       $res = mysql_query($query);
+       $xrows = mysql_num_rows($res);
+
+       while($row = mysql_fetch_assoc($res))
+       {
+               $mailtxt = "Hello ".$row["fromname"]." ".$row["lastname"]."\n".$lines_EN."\n\n";
+               switch ($row[$language])
+               {
+                       case "de_DE":   $mailtxt .= $lines_DE; break;
+                       case "ade_DE":  $mailtxt .= $lines_DE; break;
+                       case "bde_DE":  $mailtxt .= $lines_DE; break;
+                       case "cde_DE":  $mailtxt .= $lines_DE; break;
+                       case "dde_DE":  $mailtxt .= $lines_DE; break;
+                       case "ede_DE":  $mailtxt .= $lines_DE; break;
+               }
+    //    uncomment next line to send mails ...
+//             sendmail($row['email'], "[CAcert.org] $subject", $mailtxt, "mailing@cacert.org", "", "", "CAcert", "returns@cacert.org", 1);
+               $fp = fopen("lastid.txt", "w");
+                fputs($fp, $row["id"]."\n");
+                fclose($fp);
+               sleep (1);
+               echo "Sent mail to: ".$row["id"];
+       }
+?>