UBB.Dev
Posted By: JoshPet [7.0.x] Top Posters in Last X Days - 01/15/2007 6:49 AM
Mod Name / Version: Top Posters in X Days

Description: This changes the Top Posters Portal box to reflect top posters in last X days
which keeps the list more current. Otherwise the same people tend to stay on that list.

Working under: 7.0.2

Any pre-requisites: none

Author: JoshPet www.JoshuaPettit.com
for discussion and bugs go to www.ubbdev.com

Date: 1/14/07

Credits: One of my clients for commissioning it

Files Altered: /cache_builders/top_posters.php, /languages/english/island_top_posters.php

Database Altered: none

Info: Make this modification, set the number of days you'd like to use, and clear your cache



Attached File
2339-TopPostersLastXDays.txt  (181 downloads)
Posted By: Ian_W Re: [7.0.x] Top Posters in Last X Days - 01/15/2007 2:32 PM
Works fine in 7.1 - only difference being the location of the language string.
Posted By: Gizmo Re: [7.0.x] Top Posters in Last X Days - 01/15/2007 3:02 PM
Looks good Josh, keep up the good work smile
Posted By: jgeoff Re: [7.0.x] Top Posters in Last X Days - 01/17/2007 12:48 AM

Nice idea!

What if I wanted to have both though?
Could it be converted to a custom island?
Posted By: AllenAyres Re: [7.0.x] Top Posters in Last X Days - 01/17/2007 2:35 AM
Yes, you'd need to add the appropriate code into your custom island tho. (php code above to the top and the template code down below).
Posted By: Mark_S Re: [7.0.x] Top Posters in Last X Days - 02/26/2007 3:54 AM
Does anyone have the Code for this as Custom Island.
Ive been trying but get an error when i submit it?

Its probably because i havnt split it correctly like Allen sugests.

Thanks in advance.

Mark.
Posted By: Gizmo Re: [7.0.x] Top Posters in Last X Days - 02/26/2007 4:22 AM
This only works in 7.0; see this for 7.1
Posted By: Mark_S Re: [7.0.x] Top Posters in Last X Days - 02/26/2007 12:51 PM
Gizmo there two diffrent subjects.
I have that one running you linked too.

Ive seen this "Top Posters in Last X Days "
Running on a 7.1 board, Ian W's.

I think its a really neat addon,
but i'm having problems with the code.

Maybe Ian would be so kind to share the code?

Mark.
Posted By: Gizmo Re: [7.0.x] Top Posters in Last X Days - 02/26/2007 1:12 PM
Sorry, it was late when i posted, i was confusing it for another mod; but I haven't heard of this running succuessfully in 7.1 other than ian's forum
Posted By: Mark_S Re: [7.0.x] Top Posters in Last X Days - 02/26/2007 11:53 PM
I'm going to have another go at this tonight.
Probably screw it up lol...

If i get it working will post below. 7.1
Posted By: AllenAyres Re: [7.0.x] Top Posters in Last X Days - 02/27/2007 12:30 AM
Should be pretty much the same code, with the exception of Ian's noted language string difference.
Posted By: Mark_S Re: [7.0.x] Top Posters in Last X Days - 02/27/2007 1:10 AM
I realised my mistake frown

For what ever reason? ( I blame too much coffee )

I had in my head that it was a custom island add in?

Originally Posted by jgeoff

What if I wanted to have both though?
Could it be converted to a custom island?


I was trying to get it as a custom island,
so i could have both, but i was being greedy....

So i'm having problems converting it too a custom island.

Summary..

The code works great smile
I cant suss a second island to run at the same time.

Thanks to JoshPet for a better Top Posters.

p.s Is there anyway to modify out a banned user?
Posted By: JoshPet Re: [7.0.x] Top Posters in Last X Days - 02/27/2007 3:50 AM
Yeah, I'm running this on 7.1 sites, no changes.
Posted By: Ian_W Re: [7.0.x] Top Posters in Last X Days - 02/28/2007 12:06 AM
Originally Posted by Gizmo
Sorry, it was late when i posted, i was confusing it for another mod; but I haven't heard of this running succuessfully in 7.1 other than ian's forum


Runs fine - no issues - just change the string mentioned and you will be fine smile
Posted By: Carte Blanche Re: [7.0.x] Top Posters in Last X Days - 06/20/2007 4:31 AM
I've made this work with both Top Posters in Last 30 Days and Top Posters overall. Example of both in play

I've taken Josh's instructions and updated them on how to have BOTH on your forums.

Sorta my first foray off my own back...and it's a bit trickier to do with custom islands because of the way the system forces content creation on the customs. Hopefully this works for you smile

Oh, and this is working on 7.1.1

Attached File
Posted By: sirdude Re: [7.0.x] Top Posters in Last X Days - 06/20/2007 5:45 AM
nice mod

and i love that dark theme you have...

:rawk:
Posted By: Ian_W Re: [7.0.x] Top Posters in Last X Days - 06/28/2007 8:43 AM
The original mod works fine in 7.2 smile

Except as previously mentioned the language file is now in /languages/xxxx/portal_islands.php

Posted By: AshtarRose Re: [7.0.x] Top Posters in Last X Days - 10/07/2007 5:40 AM
I attempted this and I got

Parse error: syntax error, unexpected '<' in /home/riddle6/public_html/hprpg/cache_builders/custom/portal_box_7.php on line 2
Posted By: AshtarRose Re: [7.0.x] Top Posters in Last X Days - 10/07/2007 5:58 AM
Is here anything like 'Top Poster of the Month' out there that could display the top poster of the month instead of a list. Or if I can get this working, can I edit it to do that?
Posted By: Gizmo Re: [7.0.x] Top Posters in Last X Days - 10/07/2007 6:37 AM
Ensure you're pasting content between the EOF lines
Posted By: AshtarRose Re: [7.0.x] Top Posters in Last X Days - 10/07/2007 7:29 AM
Nah Giz, I put it all under the EOF and nothing works, I get a blank white page
Posted By: Gizmo Re: [7.0.x] Top Posters in Last X Days - 10/07/2007 4:16 PM
So it's for sure above the bottom EOF; and under the initial EOF>>> ?
Posted By: Gizmo Re: [7.0.x] Top Posters in Last X Days - 10/07/2007 4:17 PM
If so, please post the full code you're using.
Posted By: Ian_W Re: [7.0.x] Top Posters in Last X Days - 12/31/2007 7:38 PM
This needs a rewrite for 7.3 - I have tried, but can't quite get it correct frown frown
Posted By: Organizer Re: [7.0.x] Top Posters in Last X Days - 01/29/2008 4:05 PM
Originally Posted by Gizmo
So it's for sure above the bottom EOF; and under the initial EOF>>> ?

Got a blank page at first, then noticed that the island was built just not shown...
- - - -
$body = <<
EOF;
- - - -

Note! Carte Blanches instructions might have an error as in the above text it was first called top_post_30.php, had to change to top_posters_30.php as that was my filename at least!
Posted By: Organizer Re: [7.0.x] Top Posters in Last X Days - 01/29/2008 4:22 PM
I got another issue with 7.2.2 and the verison from Carte Blanches, the style in the box screws up, if cut and paste as below the backgroun goes black and my default backgroun on all other boxes are white... if I leave more of the original code it end up being either double heading or leave a bit less and I get a box in a box (in both cases then with right styles though)...

Any idea? (code below)

{$tbopen}
{section name=user loop=$users}
{$users[user].posts}

{$users[user].name}


{/section}
{$tbclose}
Posted By: Mark_S Re: [7.0.x] Top Posters in Last X Days - 02/19/2008 10:37 PM
Originally Posted by Ian_W
This needs a rewrite for 7.3 - I have tried, but can't quite get it correct frown frown
My members need to know whos spamming over 30 days.

If this can be sorted for 7.3 it would make alot of my
members very happy.

Still amazed this is not stock.
The best Top Posters ive seen.
Posted By: Ian_W Re: [7.0.x] Top Posters in Last X Days - 02/21/2008 2:08 PM
Indeed - I did try for several hours - got almost there, but the output was in the wrong format/order LOL
Posted By: Carte Blanche Re: [7.0.x] Top Posters in Last X Days - 02/28/2008 1:15 PM
There may be issues with my tweaks, as I said, it was my first foray into it, and actually, I've turned off the standard and custom islands showing posters.

I do recall I had to do some tweaking to get it to look just right, and stated, it was working in 7.1.1 but I didn't try it out with 7.2.2 and I have no idea how it'll play with 7.3

If I recall, I essentially took the original top posters embedded stuff, created the same thing and tweaked it according to Josh's or someone else's script and named it slight differently so that the original function still existed and my altered one could too. But, heck, that's been some time ago and my brain being all mushy at the moment....bleh.
Posted By: Mark_S Re: [7.0.x] Top Posters in Last X Days - 03/26/2008 10:34 PM
Originally Posted by Ian_W
Indeed - I did try for several hours - got almost there, but the output was in the wrong format/order LOL
Huge thanks wink

You've had a month since the last try.
< tease > You don't quit that easily normally lol

This should be stock smile
Members love the fact is dynamic and changes.
Posted By: Ian_W Re: [7.0.x] Top Posters in Last X Days - 03/28/2008 10:21 AM
Still no joy frown

Sorry about that - would love to have this running in 7.3
Posted By: willing Re: [7.0.x] Top Posters in Last X Days - 05/28/2008 1:59 PM
Does it not work in 7.3?
Posted By: sirdude Re: [7.0.x] Top Posters in Last X Days - 05/28/2008 5:55 PM
7.3-ized version below:

PHP Code

<?php
// Number of days - Top Posters in X days - Edit as needed
$days = 1;

if (!
defined('UBB_MAIN_PROGRAM')) {
exit;
}
$today = $html -> get_date();
$limittime = ($today - ($days * 86400));

$query = "
SELECT
COUNT(*) as Total, p.USER_ID, u.USER_DISPLAY_NAME,
u.USER_MEMBERSHIP_LEVEL, up.USER_NAME_COLOR
FROM
{$config['TABLE_PREFIX']}POSTS p,
{$config['TABLE_PREFIX']}USERS u,
{$config['TABLE_PREFIX']}USER_PROFILE up
WHERE u.USER_ID = up.USER_ID
AND p.POST_POSTED_TIME >
$limittime
AND p.USER_ID != 1
AND p.USER_ID = u.USER_ID
GROUP BY p.USER_ID ORDER BY Total DESC
limit
{$config['TOP_POSTERS']}
"
;
$sth = $dbh->do_query($query);
$users = array();
$i = 0;
while(list(
$total,$uid,$username,$memberlevel,$namecolor) = $dbh->fetch_array($sth)) {
$users[$i]['namecolor'] = $html->user_color($username, $namecolor, $memberlevel);
$users[$i]['name'] = $username;
$users[$i]['posts'] = $total;
$users[$i]['uid'] = $uid;
$i++;
}

$smarty->assign("users",$users);

$island = $smarty->fetch("island_top_posters.tpl");

lock_and_write("{$config['FULL_PATH']}/cache/top_posters.php",$island);

@
chmod("{$config['FULL_PATH']}/cache/top_posters.php",0666);

?>


/cache_builders/top_posters.php

set $days to the number of days you want and *poof*

this also colorizes the username to be consistent..
Posted By: AllenAyres Re: [7.0.x] Top Posters in Last X Days - 05/30/2008 5:00 AM
Thanks SD, works well thumbsup

Open for suggestions on a shorter title smile
Posted By: willing Re: [7.0.x] Top Posters in Last X Days - 05/31/2008 3:43 AM
Does it look like what is in the top right on this forum?

Looks good.

So what exactly do I need to do with the above code for 7.3? Is that a new island and exactly what do I need to put in the box? Would be a big help!

thank you
Posted By: AllenAyres Re: [7.0.x] Top Posters in Last X Days - 05/31/2008 4:42 AM
You take sd's code and put it in place of the code in the /cache_builders/top_posters.php file. Upload it and edit the post islands language file if you want to change the title.
Posted By: willing Re: [7.0.x] Top Posters in Last X Days - 05/31/2008 5:05 AM
It works!

Great.

Can I ask - how often is this data refreshed?

Thank you.
Posted By: Carte Blanche Re: [7.0.x] Top Posters in Last X Days - 05/31/2008 10:58 AM
I think you set that in your config for islands by saying how long it should be cached for.
Posted By: Carte Blanche Re: [7.0.x] Top Posters in Last X Days - 05/31/2008 11:04 AM
Also, the only problem I have with this is that this forces you to replace the top posters with top posters over the last x days.

As stated previously, I was getting too many people trying to push their epeens on post counts over the long haul that I disabled both of my islands showing top posters overall and top posters over last 30 days, but I think I may bring back just the X days variant because of it's dynamic non accruing nature. I'll see if I can't get it working again in a custom island instead of having it overwriting the original top posters one.

Btw, just as a matter of principles too, I've also disabled showing post counts on my forums because of the idiotic nature of some just trying to push post counts higher with "+1" etc.
Posted By: Carte Blanche Re: [7.0.x] Top Posters in Last X Days - 05/31/2008 12:33 PM
Ok, here's what I've come up with and it's seemingly working.

To make it as a custom island, first, you need to create a template file, I called mine "island_top_posters_30.tpl"

This file should have this content in it.

PHP Code

{* Script Version 7.3 *}

<?
php if(!defined('UBB_MAIN_PROGRAM')) exit; ?>
{$tbopen}
{section name=user loop=$users}
<div style="float:right">{$users[user].posts}</div>
<a href="{$config.BASE_URL}/ubbthreads.php?ubb=showprofile&User={$users[user].uid}">{$users[user].name}</a><br />
<div style="clear: both"></div>
{/section}
{$tbclose}


This file should be saved in /templates/default directory.

You can name it whatever you want, you just need to match the name in this next bit, which is what you will put into your custom island.

In the custom island, replace the entire contents with the following code...

PHP Code

/* PHP CODE HERE, IF NECESSARY */
// Number of days - Top Posters in X days - Edit as needed
$days = 30;

if (!
defined('UBB_MAIN_PROGRAM')) {
exit;
}

$today = $html -> get_date();
$limittime = ($today - ($days * 86400));


$query = "
SELECT
COUNT(*) as total, p.USER_ID, u.USER_DISPLAY_NAME,
u.USER_MEMBERSHIP_LEVEL, up.USER_NAME_COLOR
FROM
{$config['TABLE_PREFIX']}POSTS as p,
{$config['TABLE_PREFIX']}USERS as u,
{$config['TABLE_PREFIX']}USER_PROFILE as up

WHERE u.USER_ID = up.USER_ID
AND p.POST_POSTED_TIME >
$limittime
AND p.USER_ID != 1
AND p.USER_ID = u.USER_ID
GROUP BY p.USER_ID ORDER BY total DESC
limit
{$config['TOP_POSTERS']}
"
;
$sth = $dbh->do_query($query);
$users = array();
$i = 0;
while(list(
$total,$uid,$username,$memberlevel,$namecolor) = $dbh->fetch_array($sth)) {
$users[$i]['namecolor'] = $html->user_color($username, $namecolor, $memberlevel);
$users[$i]['name'] = $username;
$users[$i]['posts'] = $total;
$users[$i]['uid'] = $uid;
$i++;
}
// end while


$smarty->assign("users",$users);

$island = $smarty->fetch("island_top_posters_30.tpl");

lock_and_write("{$config['FULL_PATH']}/cache/top_post_30.php",$island);

@
chmod("{$config['FULL_PATH']}/cache/top_post_30.php",0666);


/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF
<?php include("/your server path here/cache/top_post_30.php") ?>



EOF;
/* DO NOT CHANGE THE LINE ABOVE */


What it does is when it fires based on the timings you've placed, it uses the "island_top_posters_30.tpl" file as a template to create some html code. it then saves this code in your cache directory as "top_post_30.php" or you can change this to be whatever you want as well. It also chmods it so it's usable, and then creates html content and just sucks in the contents of that file for display.

Thing to note is that you need to use your own server path rather than what I wrote near the bottom..i.e. replace "your server path here" with your server path.

I am by no means a fully proficient php coder, I'm more an engineer who can take existing things and make tweaks to get what I want out of them, so, if I've got "not so elegant" codign practices...this is why. Lord knows I couldn't sit down and yield this stuff from scratch.

If one of you more proficient coders notices any major issues, by all means feel free to post corrections...I'm all about function, not form and won't have feelings hurt smile

One final note, the # of people listed is pulled from the Portal Settings page, the # contained within the Top Posters field. I think it makes for a nice symmetry that if you're running both total top posters and top posters over X days that they have the same # of users listed.
Posted By: AllenAyres Re: [7.0.x] Top Posters in Last X Days - 05/31/2008 6:39 PM
Thanks CB smile
Posted By: Grymmie Re: [7.0.x] Top Posters in Last X Days - 06/11/2008 5:58 PM
Is there any way of modifying the code CB so that you can remove a specific user from being included?

I.E.

With the new newsfeed mod, the admin could recieve hundresd if not thousands of posted credits per day. This of course would upset the ratio, and I would ultimately like to keep it with those people actually making posts versus bots.

Thanks.
Posted By: sirdude Re: [7.0.x] Top Posters in Last X Days - 06/11/2008 7:27 PM
easy peasy smile

find:
SQL Query
AND	 p.USER_ID != 1

change to
SQL Query
AND	 p.USER_ID NOT IN (1,xx,yy)

where xx and yy are member numbers you don't want in the calcs..

so assume there are 3 members you don't want included (1 is always included) -- ids 10, 69, 443

the statement would read
SQL Query
AND	 p.USER_ID NOT IN(1,10,69,443)

*poof* done smile
Posted By: Grymmie Re: [7.0.x] Top Posters in Last X Days - 06/12/2008 12:42 AM
SIR DUDE YOUR THE BEST!

Thanks
Posted By: Carte Blanche Re: [7.0.x] Top Posters in Last X Days - 06/12/2008 3:49 AM
Heh, actually, I might use something like that against some of my post farmers too. Just not sure it if would encourage their spammming even more to try to get back on....
© UBB.Developers