|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
* @package acp
|
|
|
4c79b5 |
* @version $Id: acp_prune.php 8479 2008-03-29 00:22:48Z naderman $
|
|
|
4c79b5 |
* @copyright (c) 2005 phpBB Group
|
|
|
4c79b5 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
4c79b5 |
*
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* @ignore
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
if (!defined('IN_PHPBB'))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
exit;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* @package acp
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
class acp_prune
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
var $u_action;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function main($id, $mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $user, $phpEx, $phpbb_admin_path, $phpbb_root_path;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$user->add_lang('acp/prune');
|
|
|
4c79b5 |
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
switch ($mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
case 'forums':
|
|
|
4c79b5 |
$this->tpl_name = 'acp_prune_forums';
|
|
|
4c79b5 |
$this->page_title = 'ACP_PRUNE_FORUMS';
|
|
|
4c79b5 |
$this->prune_forums($id, $mode);
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
case 'users':
|
|
|
4c79b5 |
$this->tpl_name = 'acp_prune_users';
|
|
|
4c79b5 |
$this->page_title = 'ACP_PRUNE_USERS';
|
|
|
4c79b5 |
$this->prune_users($id, $mode);
|
|
|
4c79b5 |
break;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Prune forums
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function prune_forums($id, $mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $user, $auth, $template, $cache;
|
|
|
4c79b5 |
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$all_forums = request_var('all_forums', 0);
|
|
|
4c79b5 |
$forum_id = request_var('f', array(0));
|
|
|
4c79b5 |
$submit = (isset($_POST['submit'])) ? true : false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($all_forums)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql = 'SELECT forum_id
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE . '
|
|
|
4c79b5 |
ORDER BY left_id';
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_id = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_id[] = $row['forum_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($submit)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (confirm_box(true))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$prune_posted = request_var('prune_days', 0);
|
|
|
4c79b5 |
$prune_viewed = request_var('prune_vieweddays', 0);
|
|
|
4c79b5 |
$prune_all = (!$prune_posted && !$prune_viewed) ? true : false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$prune_flags = 0;
|
|
|
4c79b5 |
$prune_flags += (request_var('prune_old_polls', 0)) ? 2 : 0;
|
|
|
4c79b5 |
$prune_flags += (request_var('prune_announce', 0)) ? 4 : 0;
|
|
|
4c79b5 |
$prune_flags += (request_var('prune_sticky', 0)) ? 8 : 0;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Convert days to seconds for timestamp functions...
|
|
|
4c79b5 |
$prunedate_posted = time() - ($prune_posted * 86400);
|
|
|
4c79b5 |
$prunedate_viewed = time() - ($prune_viewed * 86400);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_PRUNED' => true)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$sql_forum = (sizeof($forum_id)) ? ' AND ' . $db->sql_in_set('forum_id', $forum_id) : '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Get a list of forum's or the data for the forum that we are pruning.
|
|
|
4c79b5 |
$sql = 'SELECT forum_id, forum_name
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE . '
|
|
|
4c79b5 |
WHERE forum_type = ' . FORUM_POST . "
|
|
|
4c79b5 |
$sql_forum
|
|
|
4c79b5 |
ORDER BY left_id ASC";
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$prune_ids = array();
|
|
|
4c79b5 |
$p_result['topics'] = 0;
|
|
|
4c79b5 |
$p_result['posts'] = 0;
|
|
|
4c79b5 |
$log_data = '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
do
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if (!$auth->acl_get('f_list', $row['forum_id']))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
continue;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($prune_all)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$p_result = prune($row['forum_id'], 'posted', time(), $prune_flags, false);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($prune_posted)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$return = prune($row['forum_id'], 'posted', $prunedate_posted, $prune_flags, false);
|
|
|
4c79b5 |
$p_result['topics'] += $return['topics'];
|
|
|
4c79b5 |
$p_result['posts'] += $return['posts'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($prune_viewed)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$return = prune($row['forum_id'], 'viewed', $prunedate_viewed, $prune_flags, false);
|
|
|
4c79b5 |
$p_result['topics'] += $return['topics'];
|
|
|
4c79b5 |
$p_result['posts'] += $return['posts'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$prune_ids[] = $row['forum_id'];
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_block_vars('pruned', array(
|
|
|
4c79b5 |
'FORUM_NAME' => $row['forum_name'],
|
|
|
4c79b5 |
'NUM_TOPICS' => $p_result['topics'],
|
|
|
4c79b5 |
'NUM_POSTS' => $p_result['posts'])
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$log_data .= (($log_data != '') ? ', ' : '') . $row['forum_name'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Sync all pruned forums at once
|
|
|
4c79b5 |
sync('forum', 'forum_id', $prune_ids, true, true);
|
|
|
4c79b5 |
add_log('admin', 'LOG_PRUNE', $log_data);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
confirm_box(false, $user->lang['PRUNE_FORUM_CONFIRM'], build_hidden_fields(array(
|
|
|
4c79b5 |
'i' => $id,
|
|
|
4c79b5 |
'mode' => $mode,
|
|
|
4c79b5 |
'submit' => 1,
|
|
|
4c79b5 |
'all_forums' => $all_forums,
|
|
|
4c79b5 |
'f' => $forum_id,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'prune_days' => request_var('prune_days', 0),
|
|
|
4c79b5 |
'prune_vieweddays' => request_var('prune_vieweddays', 0),
|
|
|
4c79b5 |
'prune_old_polls' => request_var('prune_old_polls', 0),
|
|
|
4c79b5 |
'prune_announce' => request_var('prune_announce', 0),
|
|
|
4c79b5 |
'prune_sticky' => request_var('prune_sticky', 0),
|
|
|
4c79b5 |
)));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// If they haven't selected a forum for pruning yet then
|
|
|
4c79b5 |
// display a select box to use for pruning.
|
|
|
4c79b5 |
if (!sizeof($forum_id))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'U_ACTION' => $this->u_action,
|
|
|
4c79b5 |
'S_SELECT_FORUM' => true,
|
|
|
4c79b5 |
'S_FORUM_OPTIONS' => make_forum_select(false, false, false))
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$sql = 'SELECT forum_id, forum_name
|
|
|
4c79b5 |
FROM ' . FORUMS_TABLE . '
|
|
|
4c79b5 |
WHERE ' . $db->sql_in_set('forum_id', $forum_id);
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
$row = $db->sql_fetchrow($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!$row)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$forum_list = $s_hidden_fields = '';
|
|
|
4c79b5 |
do
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$forum_list .= (($forum_list != '') ? ', ' : '') . '' . $row['forum_name'] . '';
|
|
|
4c79b5 |
$s_hidden_fields .= '<input type="hidden" name="f[]" value="' . $row['forum_id'] . '" />';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$l_selected_forums = (sizeof($forum_id) == 1) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'L_SELECTED_FORUMS' => $user->lang[$l_selected_forums],
|
|
|
4c79b5 |
'U_ACTION' => $this->u_action,
|
|
|
4c79b5 |
'U_BACK' => $this->u_action,
|
|
|
4c79b5 |
'FORUM_LIST' => $forum_list,
|
|
|
4c79b5 |
'S_HIDDEN_FIELDS' => $s_hidden_fields)
|
|
|
4c79b5 |
);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Prune users
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function prune_users($id, $mode)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $db, $user, $auth, $template, $cache;
|
|
|
4c79b5 |
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$user->add_lang('memberlist');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$prune = (isset($_POST['prune'])) ? true : false;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($prune)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$action = request_var('action', 'deactivate');
|
|
|
4c79b5 |
$deleteposts = request_var('deleteposts', 0);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (confirm_box(true))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$user_ids = $usernames = array();
|
|
|
4c79b5 |
$this->get_prune_users($user_ids, $usernames);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($user_ids))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($action == 'deactivate')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
user_active_flip('deactivate', $user_ids);
|
|
|
4c79b5 |
$l_log = 'LOG_PRUNE_USER_DEAC';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if ($action == 'delete')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
if ($deleteposts)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($user_ids as $user_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
user_delete('remove', $user_id);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$l_log = 'LOG_PRUNE_USER_DEL_DEL';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
foreach ($user_ids as $user_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
user_delete('retain', $user_id, $usernames[$user_id]);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$l_log = 'LOG_PRUNE_USER_DEL_ANON';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
add_log('admin', $l_log, implode(', ', $usernames));
|
|
|
4c79b5 |
$msg = $user->lang['USER_' . strtoupper($action) . '_SUCCESS'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$msg = $user->lang['USER_PRUNE_FAILURE'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
trigger_error($msg . adm_back_link($this->u_action));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// We list the users which will be pruned...
|
|
|
4c79b5 |
$user_ids = $usernames = array();
|
|
|
4c79b5 |
$this->get_prune_users($user_ids, $usernames);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (!sizeof($user_ids))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['USER_PRUNE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Assign to template
|
|
|
4c79b5 |
foreach ($user_ids as $user_id)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$template->assign_block_vars('users', array(
|
|
|
4c79b5 |
'USERNAME' => $usernames[$user_id],
|
|
|
4c79b5 |
'U_PROFILE' => append_sid($phpbb_root_path . 'memberlist.' . $phpEx, 'mode=viewprofile&u=' . $user_id),
|
|
|
4c79b5 |
'U_USER_ADMIN' => ($auth->acl_get('a_user')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview&u=' . $user_id, true, $user->session_id) : '',
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'S_DEACTIVATE' => ($action == 'deactivate') ? true : false,
|
|
|
4c79b5 |
'S_DELETE' => ($action == 'delete') ? true : false,
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
|
|
|
4c79b5 |
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
|
|
|
4c79b5 |
'i' => $id,
|
|
|
4c79b5 |
'mode' => $mode,
|
|
|
4c79b5 |
'prune' => 1,
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'users' => request_var('users', '', true),
|
|
|
4c79b5 |
'username' => request_var('username', '', true),
|
|
|
4c79b5 |
'email' => request_var('email', ''),
|
|
|
4c79b5 |
'joined_select' => request_var('joined_select', ''),
|
|
|
4c79b5 |
'joined' => request_var('joined', ''),
|
|
|
4c79b5 |
'active_select' => request_var('active_select', ''),
|
|
|
4c79b5 |
'active' => request_var('active', ''),
|
|
|
4c79b5 |
'count_select' => request_var('count_select', ''),
|
|
|
4c79b5 |
'count' => request_var('count', ''),
|
|
|
4c79b5 |
'deleteposts' => request_var('deleteposts', 0),
|
|
|
4c79b5 |
|
|
|
4c79b5 |
'action' => request_var('action', ''),
|
|
|
4c79b5 |
)), 'confirm_body_prune.html');
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']);
|
|
|
4c79b5 |
$s_find_count = '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
foreach ($find_count as $key => $value)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$selected = ($key == 'eq') ? ' selected="selected"' : '';
|
|
|
4c79b5 |
$s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']);
|
|
|
4c79b5 |
$s_find_join_time = '';
|
|
|
4c79b5 |
foreach ($find_time as $key => $value)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$s_find_join_time .= '<option value="' . $key . '">' . $value . '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$s_find_active_time = '';
|
|
|
4c79b5 |
foreach ($find_time as $key => $value)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$s_find_active_time .= '<option value="' . $key . '">' . $value . '</option>';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$template->assign_vars(array(
|
|
|
4c79b5 |
'U_ACTION' => $this->u_action,
|
|
|
4c79b5 |
'S_JOINED_OPTIONS' => $s_find_join_time,
|
|
|
4c79b5 |
'S_ACTIVE_OPTIONS' => $s_find_active_time,
|
|
|
4c79b5 |
'S_COUNT_OPTIONS' => $s_find_count,
|
|
|
4c79b5 |
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=acp_prune&field=users'),
|
|
|
4c79b5 |
));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
/**
|
|
|
4c79b5 |
* Get user_ids/usernames from those being pruned
|
|
|
4c79b5 |
*/
|
|
|
4c79b5 |
function get_prune_users(&$user_ids, &$usernames)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
global $user, $db;
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$users = request_var('users', '', true);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ($users)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$users = explode("\n", $users);
|
|
|
4c79b5 |
$where_sql = ' AND ' . $db->sql_in_set('username_clean', array_map('utf8_clean_string', $users));
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$username = request_var('username', '', true);
|
|
|
4c79b5 |
$email = request_var('email', '');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$joined_select = request_var('joined_select', 'lt');
|
|
|
4c79b5 |
$active_select = request_var('active_select', 'lt');
|
|
|
4c79b5 |
$count_select = request_var('count_select', 'eq');
|
|
|
4c79b5 |
$joined = request_var('joined', '');
|
|
|
4c79b5 |
$active = request_var('active', '');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$active = ($active) ? explode('-', $active) : array();
|
|
|
4c79b5 |
$joined = ($joined) ? explode('-', $joined) : array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if ((sizeof($active) && sizeof($active) != 3) || (sizeof($joined) && sizeof($joined) != 3))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
trigger_error($user->lang['WRONG_ACTIVE_JOINED_DATE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$count = request_var('count', '');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');
|
|
|
4c79b5 |
$sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit');
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$where_sql = '';
|
|
|
4c79b5 |
$where_sql .= ($username) ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : '';
|
|
|
4c79b5 |
$where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : '';
|
|
|
4c79b5 |
$where_sql .= (sizeof($joined)) ? " AND user_regdate " . $key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]) : '';
|
|
|
4c79b5 |
$where_sql .= ($count !== '') ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : '';
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if (sizeof($active) && $active_select != 'lt')
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$where_sql .= ' AND user_lastvisit ' . $key_match[$active_select] . ' ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
else if (sizeof($active))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$where_sql .= ' AND (user_lastvisit > 0 AND user_lastvisit < ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]) . ')';
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Protect the admin, do not prune if no options are given...
|
|
|
4c79b5 |
if (!$where_sql)
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
return;
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Get bot ids
|
|
|
4c79b5 |
$sql = 'SELECT user_id
|
|
|
4c79b5 |
FROM ' . BOTS_TABLE;
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$bot_ids = array();
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$bot_ids[] = $row['user_id'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
// Do not prune founder members
|
|
|
4c79b5 |
$sql = 'SELECT user_id, username
|
|
|
4c79b5 |
FROM ' . USERS_TABLE . '
|
|
|
4c79b5 |
WHERE user_id <> ' . ANONYMOUS . '
|
|
|
4c79b5 |
AND user_type <> ' . USER_FOUNDER . "
|
|
|
4c79b5 |
$where_sql";
|
|
|
4c79b5 |
$result = $db->sql_query($sql);
|
|
|
4c79b5 |
|
|
|
4c79b5 |
$where_sql = '';
|
|
|
4c79b5 |
$user_ids = $usernames = array();
|
|
|
4c79b5 |
|
|
|
4c79b5 |
while ($row = $db->sql_fetchrow($result))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
// Do not prune bots and the user currently pruning.
|
|
|
4c79b5 |
if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids))
|
|
|
4c79b5 |
{
|
|
|
4c79b5 |
$user_ids[] = $row['user_id'];
|
|
|
4c79b5 |
$usernames[$row['user_id']] = $row['username'];
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
$db->sql_freeresult($result);
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
?>
|