remove_unactivated_accounts.php 2.2 KB
Newer Older
1 2
<?php

3
/* GNU FM -- a free network service for sharing your music listening habits
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

   Copyright (C) 2009 Free Software Foundation, Inc

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   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 Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

// Requires a valid config like gnukebox / nixtape
require_once('config.php');
require_once('adodb/adodb-exceptions.inc.php');
require_once('adodb/adodb.inc.php');

try {
	$adodb =& NewADOConnection($connect_string);
} catch (exception $e) {
	var_dump($e);
	adodb_backtrace($e->gettrace());
}

34
$sql_update = 'UPDATE AccountActivation SET expires = ' . (time()+(86400*2)) . 
35 36 37 38 39 40 41
	' WHERE expires < ' . time();

try {
	$adodb->Execute($sql);
	print "Updated field 'expires' in table.\n";
} catch (exception $e) {}

42 43 44 45 46
$sql = 'SELECT a.username,authcode,email FROM
	accountactivation a LEFT JOIN users u 
	ON a.username=u.username 
	WHERE u.active=0';

47 48 49 50
try {
	$res = $adodb->GetAll($sql);
	print "Fetched data.\n";
} catch (exception $e) {}
51 52 53 54 55 56

$headers = 'From: Libre.fm Account Activation <account@libre.fm>';
$subject = 'Libre.fm - Have you forgotten us?';

print "Mail body: $mail";

57
foreach($res as $row) {
58 59 60 61 62 63 64 65
	$username = $row['username'];
	$email = $row['email'];
	$authcode = $row['authcode'];

	$url = $base_url . '/register.php?auth=' . $authcode;

	print "Username: $username, URL: $url";

66 67 68
	$mail_body = "Hi!\n\nHave you forgotten to activate your account at Libre.fm? If so, just follow this link to activate
		your account within 48 hours, after which time your profile and activation code will be permanently deleted from 
		our database.\n\n";
69
	$mail_body .= $url . "\n\n - The Libre.fm Team";
70 71

	//mail($email, $subject, $mail_body, $headers);
72 73 74
}

?>