You must be a member to post in this area
No more Banned users Part 3
avatar
leefish
28-11-2010, 10:11 PM
Post: #1
And here it is - part 3 of the "hide banned users" code edits - index stats. This one gave me a fair bit of trouble as the required code is IN index.php, and so I wanted to keep the load as light as possible - preferably with no queries - it was not to be though. No matter what I did I could not get this edit to work without putting an extra SQL query in the index.

I think its worth it though - now we can welcome a real user rather than a banned spammer.

This one is really easy - we will get the stats.php query and run it in the index php. I tried just calling the variables, but also no luck.

Index php http://crossreference.mybboard.de/index.php.html

Step 1. Make a copy of your index.php. Save it in a folder called originals
Step 2. Open the index.php from the forum root and go to line 225. Select line 225 - 239 inclusive and replace with the code below.
Step 3 Change the usergroups in the array to fit your needs.

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Build the forum statistics to show on the index page.
if($mybb->settings['showindexstats'] != 0)
	// First, load the stats cache.
	$stats = $cache->read("stats");
{
$bfxquery = $db->query("
	SELECT u.*, f.*, u.usergroup
	FROM ".TABLE_PREFIX."users u
	LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
	WHERE u.usergroup NOT IN ('7','1')
	ORDER BY u.uid DESC
	LIMIT 1
	");
	while($bfx = $db->fetch_array($bfxquery))
           {
                $stats['newest_user'] = build_profile_link($bfx['username'], $bfx['uid']);
	}
	// Check who's the newest member.
	if(!$stats['lastusername'])
	{
		$newestmember = "no new members";
	}
	else
	{
			
		$newestmember = $stats['newest_user'];
	}

For those who are still reading......

This code is a bit odd - it is loading the cache from the stats.php - but that cache is created BEFORE we run our mod in the stats php - so the data in the cache is not correct. So we load the cache (we have to have the cache data for the threads and posts) and then we run our query for the username, then we splice our query into the stats.cache. Um yeah. Sort of.

Anyhoo - it works Smile

Enjoy

avatar
Jayfore
22-03-2011, 03:23 PM
Post: #2
Thanks again for all your work with this! Just signed up on this site today, but we had been talking before over on the MyBB site. Anyway, I've been using this mod for a few months, and just noticed a nuance... Let's say 2 users sign up... User1 today and User2 tomorrow. User1 does not reply to my activation questions, so he does not get activated initially. However, User2 responds right away, and gets activated. User2 then shows up as the newest user. A few days later, User1 responds to my questions and I activate the account. User1 never shows up as the newest user -- newest user remains User2, because User2 REGISTERED most recently.

Your thoughts? Is there a way to make this look at activation time, instead of registration time?

avatar
leefish
22-03-2011, 04:28 PM
Post: #3
Hmmm, thats an interesting one. At the moment it's taking its last user data from the MYBB default stats table. This means we minimise the amount of queries, but the default table is sorting on last userid rather than date.

I will have a look at it.

avatar
Jayfore
30-11-2011, 06:22 AM
Post: #4
Hello again... Just upgraded to MyBB 1.6.5, and the index.php has been changed to add birthday functions. The line number range is now 265-279 inclusive. I made the changes, and everything seems to once again be working as it should be. Have you, by chance, had any time to review 1.6.5? See any need for further updating?

avatar
leefish
30-11-2011, 07:32 AM
Post: #5
hi Jayfore - thank you for the update. I have not gone with 1.6.5 yet, I am waiting for some mods to be updated Smile


You must be a member to post in this area


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
PHP No more banned users Part 2 leefish 0 408 28-11-2010 05:07 PM
Last Post: leefish
PHP No more Banned users leefish 1 632 28-11-2010 08:26 AM
Last Post: leefish