summaryrefslogtreecommitdiff
path: root/admin/verify_emails_role.php
blob: f9738c88fe91c289e8ab961693f2241b14952692 (plain)
1
2
3
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
34
35
36
37
38
<?php
// $Header$
// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See below for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
// Initialization
require_once( '../../kernel/setup_inc.php' );

	
	$gBitUser->verifyTicket();

	$whereSql = '';
	$bindVars = array( $gBitSystem->getConfig('users_validate_email_role') );
	if( !empty( $_REQUEST['start_user_id'] ) ) {
		$whereSql = " AND user_id>?";
		$bindVars[] = $_REQUEST['start_user_id'];
	}

	$selectSql = "SELECT uu.user_id,uu.email  FROM users_users uu WHERE user_id NOT IN (SELECT user_id FROM users_roles_map WHERE role_id = ?) $whereSql ORDER BY uu.user_id";
	$users     = $gBitDb->getAssoc($selectSql, $bindVars );
	$errors;
	foreach ( $users as $id=>$email ){
		print date( "Y-m-d H:i:s" )." Verifying $email ( $id ) .... ";
		flush();
		$emailStatus = $gBitUser->verifyMx($email,$errors);
		if( $emailStatus === true){
			$gBitUser->addUserToRole( $id , $gBitSystem->getConfig('users_validate_email_role') );
			print "valid";
		} elseif( $emailStatus === -1 )  {
			print "MX connection failed";
		} else {
			print " --INVALID-- ";
		}
		print "<br/>\n";
		flush();
	}