 |
 |
 |
 |
#316668 - 01/29/08 08:05 AM
Re: [7.0.x] Top Posters in Last X Days
[Re: Ian_W]
|
User
Registered: 08/17/02
Posts: 34
|
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 <?php include("{$config['FULL_PATH']}/cache/top_posters_30.php") ?> 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!
_________________________
Organizer
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#316761 - 02/28/08 05:15 AM
Re: [7.0.x] Top Posters in Last X Days
[Re: Ian_W]
|
Newbie
Registered: 10/08/06
Posts: 19
Loc: Auckland, NZ
|
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.
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#317078 - 05/28/08 06:59 AM
Re: [7.0.x] Top Posters in Last X Days
[Re: Ian_W]
|
User
Registered: 04/17/07
Posts: 42
|
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#317080 - 05/28/08 10:55 AM
Re: [7.0.x] Top Posters in Last X Days
[Re: willing]
|
Enthusiast
Registered: 11/08/03
Posts: 442
Loc: SoCal
|
7.3-ized version below:
<?php
$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..
_________________________
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#317113 - 05/31/08 05:33 AM
Re: [7.0.x] Top Posters in Last X Days
[Re: Carte Blanche]
|
Newbie
Registered: 10/08/06
Posts: 19
Loc: Auckland, NZ
|
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.
{* 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...
$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++;
} $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);
$body = <<<EOF
<?php include("/your server path here/cache/top_post_30.php") ?>
EOF;
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  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.
|
|
Top
|
|
|
|
 |
 |
 |
 |
|
|