Vergleich inc/tasks/userpruning.php - 1.6.2 - 1.6.16

  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)
{

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)
{
$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))

	// 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))

		{

		{

			$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 96Zeile 98
		{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation();

		{
require_once MYBB_ROOT."inc/class_moderation.php";
$moderation = new Moderation();





			// Threads
$query = $db->simple_select("threads", "tid", "uid IN({$uid_list})");
while($thread = $db->fetch_array($query))

			// Threads
$query = $db->simple_select("threads", "tid", "uid IN({$uid_list})");
while($thread = $db->fetch_array($query))

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

		{
// 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);
}
?>