Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

remind-unconfirmed-with-obscured-url-sdkfsy3i4j5skd354kmds4w.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /*
  3. Copyright (C) 2012 Otto Kekäläinen <otto@fsfe.org> for Free Software Foundation Europe
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Affero General Public License as
  6. published by the Free Software Foundation, either version 3 of the
  7. License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. header("Content-Type: text/plain")
  16. ?>
  17. Sending reminders to supporters who's e-mail is still unconfirmed:
  18. <?
  19. /*
  20. ini_set( "display_errors","1" );
  21. ERROR_REPORTING( E_ALL) ;
  22. */
  23. $timestamp = date('Y-m-d H:i:s');
  24. try {
  25. //open the database
  26. $db = new PDO( 'sqlite:../../../db/support.sqlite' );
  27. }
  28. catch(PDOException $e) {
  29. print 'Error while connecting to Database: '.$e->getMessage();
  30. }
  31. // get all unconfirmed rows
  32. try {
  33. $query = $db->prepare("SELECT * FROM t1 WHERE confirmed is NULL
  34. AND time > '".date('Y-m-d', time()-60*60*24*30)." 00:00:00'"); // restrict to rows younger than a month
  35. $query->execute();
  36. }
  37. catch(PDOException $e) {
  38. print "Database Error: \n";
  39. print_r($db->errorInfo());
  40. }
  41. while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
  42. echo "\n".$row['email'].
  43. " signed up ".$row['time'].
  44. ", confirmed: ".$row['confirmed']."\n".
  45. " reminder 1: ".$row['reminder1'].
  46. " 2: ".$row['reminder2'].
  47. " 3: ".$row['reminder3']."\n";
  48. $two_days_ago = date('Y-m-d', time()-60*60*24*2)." 00:00:00";
  49. // send only one reminder
  50. // don't send reminders more frequent than every third day
  51. if ($row['reminder1'] == '' && $row['time'] < $two_days_ago) {
  52. send_reminder("1", $row);
  53. } elseif ($row['reminder2'] == '' && $row['reminder1'] != '' && $row['reminder1'] < $two_days_ago) {
  54. send_reminder("2", $row);
  55. } elseif ($row['reminder3'] == '' && $row['reminder2'] != '' && $row['reminder2'] < $two_days_ago) {
  56. send_reminder("3", $row);
  57. } // else do nothing
  58. }
  59. // close the database connection
  60. $db = NULL;
  61. function send_reminder($reminder_number, $row) {
  62. GLOBAL $db, $timestamp;
  63. $secret = $row['secret'];
  64. // don't send reminders to yahoo.com addresses
  65. if (preg_match("/yahoo.com/i", $row['email'])) {
  66. echo " => Don't send reminder to Yahoo.com address.";
  67. return false;
  68. }
  69. if (file_exists('template-email-confirm.'. $row['lang'] .'.inc')) {
  70. require('template-email-confirm.'. $row['lang'] .'.inc');
  71. } else {
  72. require('template-email-confirm.en.inc');
  73. }
  74. $to = $row['email'];
  75. $headers = 'From: "FSFE" <office@fsfe.org>' . "\r\n";
  76. mail($to, $subject, $message, $headers);
  77. echo " => Sent reminder number ".$reminder_number." to ".$row['email']."\n";
  78. try {
  79. $query = $db->prepare("UPDATE t1 SET
  80. reminder".$reminder_number." = '". $timestamp ."'
  81. where secret='". $row['secret'] ."'");
  82. $query->execute();
  83. }
  84. catch(PDOException $e) {
  85. print "Database Error: \n";
  86. print_r($db->errorInfo());
  87. return false;
  88. }
  89. return true;
  90. }
  91. ?>