Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('PUN_ROOT', dirname(__FILE__) . '/');
- define('PUN_DEBUG', 1);
- include PUN_ROOT . 'include/common.php';
- header('Content-type: application/xml');
- $result = $db->query('SELECT COUNT(id) FROM ' . $db->prefix . 'users') or error('Failed to get user count', __FILE__, __LINE__, $db->error());
- list($count) = $db->fetch_row($result);
- if ($count > 22) {
- $limit = 10;
- } else if ($count > 12) {
- $limit = $count - 12;
- } else {
- $limit = 0;
- }
- echo '<?xml version="1.0" ?>' . "\n" . '<recordset>';
- $result = $db->query('SELECT u.id,u.username,u.email,u.registration_ip,u.registered,u.signature,u.url,u.last_visit,u.num_posts,p.posted AS post_time,p.message AS post_msg FROM ' . $db->prefix . 'users AS u LEFT JOIN ' . $db->prefix . 'posts AS p ON p.poster=u.id WHERE u.id>2 ORDER BY u.registered ASC,p.posted DESC LIMIT ' . $limit) or error('Failed to get users', __FILE__, __LINE__, $db->error());
- while ($user = $db->fetch_assoc($result)) {
- $id = $user['id'];
- $evidence = 'FST HONEYPOT CAPTURE REPORT' . "\n";
- $evidence .= 'Reason: Registered on a honeypot forum' . "\n";
- $evidence .= 'Registered: ' . gmdate('d M Y H:i:s', $user['registered']) . ' (UTC)' . "\n";
- $evidence .= 'Last visit: ' . gmdate('d M Y H:i:s', $user['last_visit']) . ' (UTC)' . "\n";
- $evidence .= 'Posts: ' . $user['num_posts'] . "\n";
- if ($user['url'] != '') {
- $evidence .= 'Profile website: ' . $user['url'] . "\n";
- }
- if ($user['signature'] != '') {
- $evidence .= 'Signature: ' . "\n" . $user['signature'] . "\n\n";
- }
- if ($user['post_time'] != '') {
- $evidence .= 'Most recent post: ' . date('d M Y H:i:s', $user['post_time']) . ' (UTC), with content as follows (first 400 chars):' . "\n";
- $evidence .= substr($user['post_msg'], 0, 400);
- }
- echo "\t" . '<user><username>' . htmlspecialchars($user['username']) . '</username><email>' . htmlspecialchars($user['email']) . '</email><ip>' . htmlspecialchars($user['registration_ip']) . '</ip><evidence>' . htmlspecialchars($evidence) . '</evidence></user>' . "\n";
- //delete the user and guest all of the posts (keep them to attract more spammers)
- $db->query('UPDATE '.$db->prefix.'posts SET poster_id=1 WHERE poster_id='.$id) or error('Unable to update posts', __FILE__, __LINE__, $db->error());
- $db->query('DELETE FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to delete user', __FILE__, __LINE__, $db->error());
- }
- echo '</recordset>';
- if (file_exists(PUN_ROOT . 'cache/cache_users_info.php')) {
- unlink(PUN_ROOT . 'cache/cache_users_info.php');
- }
- //prune old stuff
- $prune_date = time() - (7 * 86400);
- $result = $db->query('SELECT id FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
- $num_forums = $db->num_rows($result);
- for ($i = 0; $i < $num_forums; ++$i) {
- $fid = $db->result($result, $i);
- prune($fid, $prune_sticky, $prune_date);
- update_forum($fid);
- }
- // Locate any "orphaned redirect topics" and delete them
- $result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
- $num_orphans = $db->num_rows($result);
- if ($num_orphans)
- {
- for ($i = 0; $i < $num_orphans; ++$i)
- $orphans[] = $db->result($result, $i);
- $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
- }
- //clear search index
- $db->query('TRUNCATE TABLE ' . $db->prefix . 'search_cache') or error('Failed to truncate searches', __FILE__, __LINE__, $db->error());
- $db->query('TRUNCATE TABLE ' . $db->prefix . 'search_matches') or error('Failed to truncate searches', __FILE__, __LINE__, $db->error());
- $db->query('TRUNCATE TABLE ' . $db->prefix . 'search_words') or error('Failed to truncate searches', __FILE__, __LINE__, $db->error());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement