remove_unactivated_accounts.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /* GNU FM -- a free network service for sharing your music listening habits
  3. Copyright (C) 2009 Free Software Foundation, Inc
  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 published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (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. // Requires a valid config like gnukebox / nixtape
  16. require_once('config.php');
  17. require_once('adodb/adodb-exceptions.inc.php');
  18. require_once('adodb/adodb.inc.php');
  19. try {
  20. $adodb =& NewADOConnection($connect_string);
  21. } catch (exception $e) {
  22. var_dump($e);
  23. adodb_backtrace($e->gettrace());
  24. }
  25. $sql_update = 'UPDATE AccountActivation SET expires = ' . (time()+(86400*2)) .
  26. ' WHERE expires < ' . time();
  27. try {
  28. $adodb->Execute($sql);
  29. print "Updated field 'expires' in table.\n";
  30. } catch (exception $e) {}
  31. $sql = 'SELECT a.username,authcode,email FROM
  32. accountactivation a LEFT JOIN users u
  33. ON a.username=u.username
  34. WHERE u.active=0';
  35. try {
  36. $res = $adodb->GetAll($sql);
  37. print "Fetched data.\n";
  38. } catch (exception $e) {}
  39. $headers = 'From: Libre.fm Account Activation <account@libre.fm>';
  40. $subject = 'Libre.fm - Have you forgotten us?';
  41. print "Mail body: $mail";
  42. foreach($res as $row) {
  43. $username = $row['username'];
  44. $email = $row['email'];
  45. $authcode = $row['authcode'];
  46. $url = $base_url . '/register.php?auth=' . $authcode;
  47. print "Username: $username, URL: $url";
  48. $mail_body = "Hi!\n\nHave you forgotten to activate your account at Libre.fm? If so, just follow this link to activate
  49. your account within 48 hours, after which time your profile and activation code will be permanently deleted from
  50. our database.\n\n";
  51. $mail_body .= $url . "\n\n - The Libre.fm Team";
  52. //mail($email, $subject, $mail_body, $headers);
  53. }
  54. ?>