Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@irwiss
Last active April 2, 2019 22:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irwiss/9b5a3cea65e5d2a9bdb72bb8b63f21c5 to your computer and use it in GitHub Desktop.
Save irwiss/9b5a3cea65e5d2a9bdb72bb8b63f21c5 to your computer and use it in GitHub Desktop.
phpbb_mass_prune.php
phpbb user pruning tool fails to actually work at > 100 users to prune
even though it happily displays a form with about 30000 checkboxes and
usernames to choose.
Slightly modified - this script wants user_ids_to_delete.txt near it,
with numerical user ids, one id per line.
Bulk delete all users with 0 posts in prevoius revision
This needs a *lot* of memory (or swapfile) if you have a lot of users
matching criterias.
Run via CLI as running via browser will most likely make the web server
abort due to time out
also needs includes/functions.php edited:
function confirm_box(...) {
return true; // add this line on top to disable confirm box
}
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
require($phpbb_root_path . 'includes/functions_acp.' . $phpEx);
require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
ini_set('memory_limit', '4096M'); // will fail otherwise
include "includes/acp/acp_prune.php";
class req_mock implements \phpbb\request\request_interface {
function overwrite($var_name, $value, $super_global = \phpbb\request\request_interface::REQUEST) { return false; }
function header($var_name, $default = '') { return false; }
function is_set_post($name) { return false; }
function is_ajax() { return false; }
function is_secure() { return false; }
function variable_names($super_global = \phpbb\request\request_interface::REQUEST) { return false; }
function is_set($var, $super_global = \phpbb\request\request_interface::REQUEST) { return false; }
function get_super_global($super_global = \phpbb\request\request_interface::REQUEST) { return false; }
function escape($value, $multibyte) { return ""; }
function raw_variable($var_name, $default, $super_global = \phpbb\request\request_interface::REQUEST) { return $default; }
function variable($name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST) {
if($name == "count") { return "0"; }
if($name == "count_select") { return "eq"; }
if($name == "action") { return "delete"; }
if($name == "deleteposts") { return "0"; }
if($name == "i") { return "acp_prune"; }
if($name == "mode") { return "users"; }
if($name == "user_ids") { return NULL; }
return $default;
}
function server($name, $default = '') {
if($name == "SERVER_PROTOCOL") { return "HTTP/1.1"; }
return $default;
}
}
error_reporting(-1);
global $request, $_POST, $userIdsToDelete;
$_POST = array();
$_POST['prune'] = "true";
$userIdsToDelete = file('user_ids_to_delete.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$request = new req_mock();
$prune = new \acp_prune();
$result = $prune->prune_users("acp_prune", "users");
echo print_r($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment