Created
October 11, 2018 14:08
-
-
Save GerB/6250b109c37cbccc921f9c703eadf5f2 to your computer and use it in GitHub Desktop.
Script for phpBB 3.2 to delete all users in Newly registers users group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @package phpBB3 | |
* @author GerB https://github.com/GerB | |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | |
* | |
*/ | |
/** | |
* @ignore | |
*/ | |
// Connect to phpBB | |
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); | |
include($phpbb_root_path . 'includes/functions_user.' . $phpEx); | |
$user->session_begin(); | |
$auth->acl($user->data); | |
$user->setup(); | |
// Sanity check | |
if ($user->data['user_type'] != USER_FOUNDER) | |
{ | |
trigger_error('This script is only available for founders'); | |
} | |
// Get correct group id | |
$sql = 'SELECT group_id | |
FROM ' . GROUPS_TABLE . " | |
WHERE group_name = 'NEWLY_REGISTERED' | |
AND group_type = " . GROUP_SPECIAL; | |
$result = $db->sql_query($sql); | |
$group = $db->sql_fetchrow($result); | |
$db->sql_freeresult($result); | |
// Get users from this group and add to list | |
$sql2 = 'SELECT user_id | |
FROM ' . USER_GROUP_TABLE . ' | |
WHERE group_id = ' . $group['group_id']; | |
$result2 = $db->sql_query($sql2); | |
while ($user = $db->sql_fetchrow($result2)) | |
{ | |
$deleteArray[] = $user['user_id']; | |
} | |
$db->sql_freeresult($result2); | |
// Now go and report | |
user_delete('remove', $deleteArray); | |
$count = (int) count($deleteArray); | |
echo '<pre>' . $count . ' users removed. Now please remove this script from your public HTML.</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment