Vergleich inc/tasks/userpruning.php - 1.6.0 - 1.6.14

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: userpruning.php 5016 2010-06-12 00:24:02Z RyanGordon $

 * $Id$

 */

function task_userpruning($task)
{
global $db, $lang, $mybb, $cache;

 */

function task_userpruning($task)
{
global $db, $lang, $mybb, $cache;

	



	if($mybb->settings['enablepruning'] != 1)

	if($mybb->settings['enablepruning'] != 1)

	{

	{

		return;
}

		return;
}

	



	// Are we pruning by posts?
if($mybb->settings['enableprunebyposts'] == 1)
{
$in_usergroups = array();
$users = array();

	// Are we pruning by posts?
if($mybb->settings['enableprunebyposts'] == 1)
{
$in_usergroups = array();
$users = array();

		



		$usergroups = $cache->read("usergroups");
foreach($usergroups as $gid => $usergroup)

		$usergroups = $cache->read("usergroups");
foreach($usergroups as $gid => $usergroup)

		{

		{

			// Exclude admin, moderators, super moderators, banned
if($usergroup['canmodcp'] == 1 || $usergroup['cancp'] == 1 || $usergroup['issupermod'] == 1 || $usergroup['isbannedgroup'] == 1)
{

			// Exclude admin, moderators, super moderators, banned
if($usergroup['canmodcp'] == 1 || $usergroup['cancp'] == 1 || $usergroup['issupermod'] == 1 || $usergroup['isbannedgroup'] == 1)
{

Zeile 34Zeile 34
			}
$in_usergroups[] = $gid;
}

			}
$in_usergroups[] = $gid;
}

		



		// If we're not pruning unactivated users, then remove them from the criteria
if($mybb->settings['pruneunactived'] == 0)
{
$key = array_search('5', $in_usergroups);
unset($in_usergroups[$key]);
}

		// If we're not pruning unactivated users, then remove them from the criteria
if($mybb->settings['pruneunactived'] == 0)
{
$key = array_search('5', $in_usergroups);
unset($in_usergroups[$key]);
}

		




// Exclude super admins
$exclude_super_admins = not_super_admins(true);

		$regdate = TIME_NOW-(intval($mybb->settings['dayspruneregistered'])*24*60*60);

		$regdate = TIME_NOW-(intval($mybb->settings['dayspruneregistered'])*24*60*60);

		$query = $db->simple_select("users", "uid", "regdate <= ".intval($regdate)." AND postnum <= ".intval($mybb->settings['prunepostcount'])." AND usergroup IN(".$db->escape_string(implode(',', $in_usergroups)).")");

		$query = $db->simple_select("users", "uid", "regdate <= ".intval($regdate)." AND postnum <= ".intval($mybb->settings['prunepostcount'])." AND usergroup IN(".$db->escape_string(implode(',', $in_usergroups)).")".$exclude_super_admins);

		while($user = $db->fetch_array($query))
{
$users[$user['uid']] = $user['uid'];
}
}

		while($user = $db->fetch_array($query))
{
$users[$user['uid']] = $user['uid'];
}
}

	



	// Are we pruning unactivated users?
if($mybb->settings['pruneunactived'] == 1)

	// Are we pruning unactivated users?
if($mybb->settings['pruneunactived'] == 1)

	{

	{

		$regdate = TIME_NOW-(intval($mybb->settings['dayspruneunactivated'])*24*60*60);
$query = $db->simple_select("users", "uid", "regdate <= ".intval($regdate)." AND usergroup='5'");
while($user = $db->fetch_array($query))

		$regdate = TIME_NOW-(intval($mybb->settings['dayspruneunactivated'])*24*60*60);
$query = $db->simple_select("users", "uid", "regdate <= ".intval($regdate)." AND usergroup='5'");
while($user = $db->fetch_array($query))

Zeile 60Zeile 62
			$users[$user['uid']] = $user['uid'];
}
}

			$users[$user['uid']] = $user['uid'];
}
}

	



	if(!empty($users))
{
$uid_list = $db->escape_string(implode(',', $users));

	if(!empty($users))
{
$uid_list = $db->escape_string(implode(',', $users));

		



		// Delete the user
$db->delete_query("userfields", "ufid IN({$uid_list})");
$db->delete_query("privatemessages", "uid IN({$uid_list})");

		// Delete the user
$db->delete_query("userfields", "ufid IN({$uid_list})");
$db->delete_query("privatemessages", "uid IN({$uid_list})");

Zeile 79Zeile 81
		$db->delete_query("awaitingactivation", "uid IN({$uid_list})");
$query = $db->delete_query("users", "uid IN({$uid_list})");
$num_deleted = $db->affected_rows($query);

		$db->delete_query("awaitingactivation", "uid IN({$uid_list})");
$query = $db->delete_query("users", "uid IN({$uid_list})");
$num_deleted = $db->affected_rows($query);

 

// Remove any of the user(s) uploaded avatars
$query = $db->simple_select("users", "avatar", "uid IN ({$uid_list}) AND avatartype = 'upload'");
if($db->num_rows($query))
{
while($avatar = $db->fetch_field($query, "avatar"))
{
$avatar = substr($avatar, 2, -20);
@unlink(MYBB_ROOT.$avatar);
}
}


// Are we removing the posts/threads of a user?
if($mybb->settings['prunethreads'] == 1)


// Are we removing the posts/threads of a user?
if($mybb->settings['prunethreads'] == 1)

Zeile 99Zeile 112
			{
$moderation->delete_post($post['pid']);
}

			{
$moderation->delete_post($post['pid']);
}

		}

		}

		else
{
// We're just updating the UID
$db->update_query("posts", array('uid' => 0), "uid IN({$uid_list})");

		else
{
// We're just updating the UID
$db->update_query("posts", array('uid' => 0), "uid IN({$uid_list})");

 
			$db->update_query("threads", array('uid' => 0), "uid IN({$uid_list})");

		}

		}





		// Update forum stats
update_stats(array('numusers' => '-'.intval($num_deleted)));

		// Update forum stats
update_stats(array('numusers' => '-'.intval($num_deleted)));

		



		$cache->update_moderators();
$cache->update_banned();
}

		$cache->update_moderators();
$cache->update_banned();
}

	



	add_task_log($task, $lang->task_userpruning_ran);
}
?>

	add_task_log($task, $lang->task_userpruning_ran);
}
?>