This is a list of top posters within a specific time frame, such as for a posting contest. As it stands, it lists the 10 most prolific posters, with the number of posts and a link to the posters' profiles.
First, you need to find out the unix time for when you want it to start and end. You can compute it here (http://www.onlineconversion.com/unix_time.htm), among many other places. Put those numbers into the $starttime and $endtime variables below.
The code does not count admins or global moderators and prints out the 10 most prolific posters within the time frame, with the number of posts in parentheses after the name. There isn't any error checking for the beginning when there won't be any posts, though. It also prints a link to the profile, which you can delete if you want.
global $db_prefix, $scripturl;
$starttime = 1152182762; // Change this to the time you want the contest to start
$endtime = 1152405444; // Change this to the time you want the contest to end
$count= array();
$poster_number = array();
$query = db_query(
"SELECT posterName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
FROM {$db_prefix}members
JOIN {$db_prefix}messages
ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
WHERE ID_GROUP <> 1 AND ID_GROUP <> 2
AND posterTime > $starttime
AND posterTime < $endtime", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
if (!isset($count[$row['posterName']]))
$count[$row['posterName']] = 0;
++$count[$row['posterName']];
$poster_number[$row['posterName']] = $row['ID_MEMBER'];
}
arsort($count);
$list_number = 0;
foreach ($count as $key => $value)
{
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $poster_number[$key] . '">' . $key . '</a> (' . $value . ')<br />';
++$list_number;
if ($list_number > 9)
break;
}
Thanks a lot. I was looking for something like that. :)
It works great. I use it to have a posting contest and I can see who has the most posts in a specific time frame.
Great snippet JP.
Nice snippet. Great for contests...
Thanks. I'm glad to help. I wouldn't have thought this would be something used a lot, but if it is, wonderful.
Can this be done counting everyone on the forum including admins and mods. To show the top say 5 posters with the number of post per person?
Sure. That's easier to do than what I have above.
You want just a general top x number of posters, right? No time limit?
$numberofposters = 5; // You can change this to however many you want
require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");
foreach ($top_posters as $poster)
{
echo $poster['link'] , ' (', $poster['posts'] , ')<br />';
}
Edited to make the variables a little neater.
That is perfect thank you
is it possible to have this code so that when a person reaches top posted count (becomes #1) the computer CD rom ejects and a pizza comes out of it?
Quote from: akulion on October 19, 2006, 04:32:29 PM
is it possible to have this code so that when a person reaches top posted count (becomes #1) the computer CD rom ejects and a pizza comes out of it?
Now that would be too cool
i thought i would give it a try in asking jpdeni - she seems to have codes for everything :D
so we might just get one yet!
:2funny: Well, I think you've got me stumped on that one, aku!! :2funny:
hey u know when u view the stats page (http://www.tinyportal.net/smf/index.php?action=stats) how they have those cool bar graphs alongside?
how would I include that in this?
thanks
Oh, Aku. You always come up with something new. :)
I haven't tried this myself, but this seems like it would work.
First, add $settings to your global statement at the beginning of the code.
Then change
foreach ($count as $key => $value)
{
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $poster_number[$key] . '">' . $key . '</a> (' . $value . ')<br />';
++$list_number;
if ($list_number > 9)
break;
}
to
$biggest = 0;
foreach ($count as $key => $value)
{
if ($biggest == 0)
$biggest = $value;
$bar_length = intval(($value/$biggest) * 100);
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $poster_number[$key] . '">' . $key . '</a> (' . $value . ')
<img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="15" alt="" /><br />';
++$list_number;
if ($list_number > 9)
break;
}
The potential problem I see is that it might be too long, especially if you have this on a side block. The bar for the top poster will be 100 pixels long. If it turns out to be too long, change the 100 to something smaller.
Of course, it may not work at all. :)
Cool :D thanks :D
ill try it out until I can think of more things to ask :2funny:
Thank you very much :up:
My pleasure. :)
got an error:
Quote
Parse error: syntax error, unexpected '>' in /home/.cash/akulion/goofy-goobers.com/forum/Sources/Load.php(1715) : eval()'d code(35) : eval()'d code on line 34
Sorry. There was an extra apostrophe in the code. I'll go change it.
aaahhh now it works very nicely!!
I like the cool mouse over effects with the popup java box and the flashing symbols :up:
thanks :D
i tried it but all that shows up in the block is the code.
what am i doing wrong?
What kind of block are you using?
no html seems to work in my bbc-html blocks
You're supposed to put this code in a phpbox.
ok ill try that
great it works now. thx
why doesnt the html work in a bbc-html block?
all that shows up is the code
Please, do NOT crosspost the same questions, it's hard for us to keep track on things if you crosspost.
sry
i dont want specific time frame with start and end time.
is it possible top posters, topics for "last 7 days"
i did top posters for last 7 days:
change:
$starttime = time() - 604800;
$endtime = time ();
This code should work for you ok. I am using this code on my forum too. This code isn't mine at all. RebelRose put the code in for me..SO thank's to RebelRose
Use this block (phpbox) for this code
$numberofposters = 10; // You can change this to however many you want
require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");
foreach ($top_posters as $key => $value)
{
echo $top_posters[$key]['link'] , ' (', $top_posters[$key]['posts'] , ')<br />';
}
This code last forever...
First of all I LOVE this code!!
Second I would like to request a change...
I have a few users that registered under one name but then changed it later to a name they liked more. Now this block displays their "account" name but not the name they use in the rest of the forum. Is there a way to make it display their "used" name instead of the "account" name ??
Thanks!!
nice snippet i might add it too some of my stuff. try using mktime() format for your dates it will make it easier to understand.
mktime(0,0,0,1,10,07)
Description
int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )
http://us3.php.net/manual/en/function.mktime.php
I figured it out...
Thanks for the code!!!
really a nice script....
I love this code very much...
how would i make the original one posted "time based" include the admin as well?
By "orginial one posted" I'm assuming you mean the one in the first post. :) To include everyone, delete
WHERE ID_GROUP <> 1 AND ID_GROUP <> 2
from the query.
I'm not sure what you mean by "time based."
awesome. thank you. by time based, i meant the first post as you mentioned that was for counting post by the unix time stamp. thanks. :)
I love this bloc. Its awesome. I have a question... kind of related to the way this one works. Can it be coded to pull name and top 5 high rank person out of the member list? I do my members rank by post count and its all military rank. :)
couple of posts is a private, more posts and you move up of course. Just curious if this was possible, and i figured it was kind of related and thought i'd ask. Just would be cool to show top 5 highest ranked persons on the site. Just an idea.
Hey thanks all for your great bloc's, and responses. Love the site and this board.
John
The block isn't intended to do what you want. There's actually another function built-in to do what you want, I think, if I understand what it is that you want. It would probably have to be combined with the ranks table, which could be done.
At any rate, it's a completely different code than I wrote here.
I understand. Thank You. Im not a good guy with codes, so thought i'd ask the professionals. :)
Which code is that?
Quote from: Shadow Queen on February 14, 2007, 04:55:10 AM
Which code is that?
This is what i had asked...
Can it be coded to pull name and top 5 high rank person out of the member list? I do my members rank by post count and its all military rank.
couple of posts is a private, more posts and you move up of course. Just curious if this was possible, and i figured it was kind of related and thought i'd ask. Just would be cool to show top 5 highest ranked persons on the site. Just an idea.
Hey thanks all for your great bloc's, and responses. Love the site and this board.
John
John
Here a pic you can see
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg165.imageshack.us%2Fimg165%2F8972%2Funtitlediw7.th.jpg&hash=6d820dae4f4fe9fdcc5beaf1f57043b2c08c4ecb) (http://img165.imageshack.us/my.php?image=untitlediw7.jpg)
I really don't know if the code can do that or what...
I'm back JPDeni :o
I've combined some code from this topic to
- php side block (180 pixels)
- last week top posters
- used gfx-bars
- include admins/mods
global $db_prefix, $scripturl, $settings;
// $starttime = 1167609601; // Change this to the time you want the contest to start [http://www.onlineconversion.com/unix_time.htm]
// $endtime = 1199145601; // Change this to the time you want the contest to end
$starttime = time() - 604800; // Last week posters
$endtime = time ();
$count= array();
$poster_number = array();
$query = db_query(
"SELECT posterName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
FROM {$db_prefix}members
JOIN {$db_prefix}messages
ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
AND posterTime > $starttime
AND posterTime < $endtime", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
if (!isset($count[$row['posterName']]))
$count[$row['posterName']] = 0;
++$count[$row['posterName']];
$poster_number[$row['posterName']] = $row['ID_MEMBER'];
}
arsort($count);
$list_number = 0;
$biggest = 0;
foreach ($count as $key => $value)
{
if ($biggest == 0)
$biggest = $value;
$bar_length = intval(($value/$biggest) * 40);
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><a href="' . $scripturl . '?action=profile;u=' . $poster_number[$key] . '">' . $key . '</a> (' . $value . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" alt="" /></div></td>
</tr>
</table>
';
++$list_number;
if ($list_number > 4)
break;
}
but I have the same question as Gargoyle
Quote from: Gargoyle on January 07, 2007, 03:48:19 AM
I have a few users that registered under one name but then changed it later to a name they liked more. Now this block displays their "account" name but not the name they use in the rest of the forum. Is there a way to make it display their "used" name instead of the "account" name ??
I would like to echo the '
realName' from '
{$db_prefix}members'
I assume it's not very tough, but I'm nothing like a php/db guru
tnx in advange
Change every instance of posterName to realName.
Damn, it works.
I figured that was too easy because '{$db_prefix}messages' does not use 'realName'.
Tnx, it works perfect on our site.
Quote'{$db_prefix}messages' does not use 'realName'
Right. But '{$db_prefix}members' has it and the query joins the two tables on the ID_MEMBER field.
You're welcome. Glad I could help. :)
I try that code in a phpbox and it's didn't show up for me at all.
Quote$numberofposters = 5; // You can change this to however many you want
require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");
foreach ($top_posters as $poster)
{
echo $poster['link'] , ' (', $poster['posts'] , ')
';
Am Using this code , but it is not displaying the member group color.
Can u tell me the code for it ??
Quote from: Sledge HaMMeR on March 30, 2007, 02:12:46 AM
I'm back JPDeni :o
I've combined some code from this topic to
- php side block (180 pixels)
- last week top posters
- used gfx-bars
- include admins/mods
global $db_prefix, $scripturl, $settings;
// $starttime = 1167609601; // Change this to the time you want the contest to start [http://www.onlineconversion.com/unix_time.htm]
// $endtime = 1199145601; // Change this to the time you want the contest to end
$starttime = time() - 604800; // Last week posters
$endtime = time ();
$count= array();
$poster_number = array();
$query = db_query(
"SELECT posterName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
FROM {$db_prefix}members
JOIN {$db_prefix}messages
ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
AND posterTime > $starttime
AND posterTime < $endtime", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
if (!isset($count[$row['posterName']]))
$count[$row['posterName']] = 0;
++$count[$row['posterName']];
$poster_number[$row['posterName']] = $row['ID_MEMBER'];
}
arsort($count);
$list_number = 0;
$biggest = 0;
foreach ($count as $key => $value)
{
if ($biggest == 0)
$biggest = $value;
$bar_length = intval(($value/$biggest) * 40);
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><a href="' . $scripturl . '?action=profile;u=' . $poster_number[$key] . '">' . $key . '</a> (' . $value . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" alt="" /></div></td>
</tr>
</table>
';
++$list_number;
if ($list_number > 4)
break;
}
but I have the same question as Gargoyle
Quote from: Gargoyle on January 07, 2007, 03:48:19 AM
I have a few users that registered under one name but then changed it later to a name they liked more. Now this block displays their "account" name but not the name they use in the rest of the forum. Is there a way to make it display their "used" name instead of the "account" name ??
I would like to echo the 'realName' from '{$db_prefix}members'
I assume it's not very tough, but I'm nothing like a php/db guru
tnx in advange
This is the only code in this topic that works for me so my question is how to add change it from 5 members and how do I take it to where admins and mods don't count
I have modified top posters script(s) posted here to support member color links if they are available. Also removed some redundant code.
global $db_prefix, $scripturl, $modSettings;
$memberstoshow = 7;
$matchperiod = false;
$countmodsandadmins = true; // not yet implemented
// Change this to the time you want the contest to start [http://www.onlineconversion.com/unix_time.htm]
$starttime = time() - 604800; // Last week posters
$endtime = time(); // Change this to the time you want the contest to end
$where_period = '';
if (!empty($modSettings['MemberColorLink'])) // check if MemberColorLink mod is installed and enabled
{
if ($matchperiod) // select only posts matching period
$where_period = "AND m.posterTime > $starttime AND m.posterTime < $endtime";
$query = db_query(
"SELECT m.realName, m.ID_MEMBER, mg.onlineColor, m.posts
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS mg ON (m.ID_GROUP = mg.ID_GROUP AND m.ID_GROUP)
$where_period
ORDER BY m.posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
else
{
if ($matchperiod) // select only posts matching period
$where_period = "WHERE posterTime > $starttime AND posterTime < $endtime";
$query = db_query(
"SELECT realName, ID_MEMBER, posts
FROM {$db_prefix}members
$where_period
ORDER BY posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
$firstrecord = true;
while ($row = mysql_fetch_assoc($query))
{
if ($firstrecord)
{
$biggest = $row['posts'];
$firstrecord = false;
}
$bar_length = intval(($row['posts']/$biggest) * 40);
if(isset($row['onlineColor']))
$style = 'color: '. $row['onlineColor'];
else
$style = '';
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><b><a style="' . $style . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></b> (' . $row['posts'] . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" title="' . $bar_length*2.5 . '%" alt="" /></div></td>
</tr>
</table>
';
}
Please post comments and suggestions so I will be able to improve it for your needs :) Thanks.
Brilliant :up: I've had Top Ten posters on my site for ages.. Just used you're script and it looks and works a treat... Thanks 8)
Theif, get this error when using yours:
8: Undefined variable: starttime
File: /home/content/j/d/w/jdworld/html/Themes/default/languages/Arcade.english.php (eval?)
Line: 28
Zetan, thanks for such a positive feedback, my pleasure reading it. cheers!
jdvarner, thanks for info, should be fixed now. please check.
Just checked my logs.. had the same error.
I'm getting this error still:
Quote8: Undefined variable: where
File: /home/zetan/public_html/Themes/default/languages/Stats.english.php (eval?)
Line: 23
[Edit] I'm assuming that its the Top Posters causing it.. I'll turn it off and check.
Sorry guys, its hard for me to write code without "notice" errors, but I'm trying..
please check updated block code. if it won't help I'll rewrite part about period match.
[edit] Zetan, yeah its my bad code causes this, no doubts :P
[edit2] one more code change.
:) That seems to have fixed it now. No errors.
I still get the errors thief. Not sure why. Im not changing any of the code. Just copy and paste. I checked to make sure i have no errors prior to block creation and then i put the code and check the log and it fills up in seconds. I'll keep it on deactive for a bit.
what errors are you having, jdvarner? the same?
same
Okay, I've updated (http://www.tinyportal.net/index.php?topic=8762.msg131637#msg131637) code once again. Hopefully it will shutdown those notices :)
(By the way I don't see any errors at my forum logs)
[edit] one more - fixes incorrect percent display on hovering bars.
[edit2] fixed - members without group (thus color) weren't shown. sql fixes. increased default member count to "7" as well.
must be my site and or my additional mods. still getting error (different one now) and i dont see any color difference even though there should be.
2: mysql_result(): Unable to jump to row 0 on MySQL result index 57
File: /home/content/j/d/w/jdworld/html/Themes/default/languages/Arcade.english.php (eval?)
Line: 16
Wait, now it doesn't show top posters at all, right?
Do you have Member Color Link mod installed?
From my last error check, I had none from this snippit, I've just checked again since the updates you've made and I have no errors
QuoteForum Error Log
The error log tracks every error encountered by your forum. To delete any errors from the database, mark the checkbox, and click the Remove button at the bottom of the page.
Pages: [1]
No messages...
Pages: [1]
jdvarner, I assume that you haven't MemberColorLink mod installed and because code to check if it is available was really lame you were getting that error.
Now I did a proper check (I hope so, I'm not much a Tinyportal expert), so this issue should be solved.
Please check updated code (http://www.tinyportal.net/index.php?topic=8762.msg131637#msg131637) and let me know if my assumptions are correct. Thanks.
Im using the following code and it works great but when someone has a longer name the post count ends up under their name is there anything i can do to change that ?
global $db_prefix, $scripturl, $memberContext, $txt, $modSettings;
// $starttime = strtotime('24 hours ago'); //posters laatste 24 uur
$starttime = mktime(0, 0, 0, date('m'), date('d'), date('Y')); //posters vandaag
$list_count = 10;
$poster = array();
$request = db_query("
SELECT m.ID_MEMBER, COUNT(m.ID_MEMBER) as postCount
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE m.posterTime > " . $starttime . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
GROUP BY m.ID_MEMBER
ORDER BY postCount DESC LIMIT " . $list_count, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
loadMemberData(array($row['ID_MEMBER']));
loadMemberContext($row['ID_MEMBER']);
$poster[$row['ID_MEMBER']] = array (
'id' => $row['ID_MEMBER'],
'count' => $row['postCount'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $memberContext[$row['ID_MEMBER']]['name'] . '">' . '<font color="' . $memberContext[$row['ID_MEMBER']]['group_color'] . '">' . $memberContext[$row['ID_MEMBER']]['name'] . '</font>' . '</a>' );
}
mysql_free_result($request);
echo '<table width=100%>';
foreach($poster as $top_user)
{
echo '<tr>
<td align="right" width=75%>' . $top_user['link'] . '</td>
<td align="left">| '. $top_user['count'] . '</td>
</tr>';
}
echo '</table>';
well, you can try to increase rows width. You have:
width=75%
already tried that with no luck
hmm, then sorry no idea why it can wrap. can you provide screenshot/link to site?
well it would already help if you could somehow set the max size of the names, so if there is anywat to do this
yup that did it thief. thanks.
thief, i install member color mod, but dont see a difference. did i have to activate that in admin panel? just asking. not trying to change topic of your thread here. but it kind of goes with your mod and thought i'd ask since you suggested the mod.
jd
CyberOPs,
you can try to define maxlength:
$maxlength=20;
and then, using function substr (http://ua2.php.net/manual/en/function.substr.php), code like this:
$membername = (strlen($memberContext[$row['ID_MEMBER']]['name'])) > $maxlength) substr($memberContext[$row['ID_MEMBER']]['name']),0,$maxlength) : $memberContext[$row['ID_MEMBER']]['name'];
jdvarner,
Quote from: jdvarner on May 13, 2007, 06:14:40 AM
yup that did it thief. thanks.
glad to hear that :) you are wellcome
and yes, my code checks if Member color link mod enabled.
how would i put that in thief im not that good with all the coding could you maybe post a modified code from what i posted ?
not tested:
global $db_prefix, $scripturl, $memberContext, $txt, $modSettings;
$maxlength=20;
// $starttime = strtotime('24 hours ago'); //posters laatste 24 uur
$starttime = mktime(0, 0, 0, date('m'), date('d'), date('Y')); //posters vandaag
$list_count = 10;
$poster = array();
$request = db_query("
SELECT m.ID_MEMBER, COUNT(m.ID_MEMBER) as postCount
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE m.posterTime > " . $starttime . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
GROUP BY m.ID_MEMBER
ORDER BY postCount DESC LIMIT " . $list_count, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
loadMemberData(array($row['ID_MEMBER']));
loadMemberContext($row['ID_MEMBER']);
$membername = (strlen($memberContext[$row['ID_MEMBER']]['name']) > $maxlength) ? substr($memberContext[$row['ID_MEMBER']]['name'],0,$maxlength) : $memberContext[$row['ID_MEMBER']]['name'];
$poster[$row['ID_MEMBER']] = array (
'id' => $row['ID_MEMBER'],
'count' => $row['postCount'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $memberContext[$row['ID_MEMBER']]['name'] . '">' . '<font color="' . $memberContext[$row['ID_MEMBER']]['group_color'] . '">' . $membername . '</font>' . '</a>' );
}
mysql_free_result($request);
echo '<table width=100%>';
foreach($poster as $top_user)
{
echo '<tr>
<td align="right" width=75%>' . $top_user['link'] . '</td>
<td align="left">| '. $top_user['count'] . '</td>
</tr>';
}
echo '</table>';
Thief it didn't work im getting some sort of error about the database
Could you be more specific? It shoudn't change the way its working with database.
And please try updated code.
Parse error: syntax error, unexpected T_STRING in /home/Sources/Load.php(1735) : eval()'d code(35) : eval()'d code on line 23
that is the error i get even with the updated code
should be fixed.
zo far it works thanks now it's just waiting for someone with a long name to come online lol, thanks for the help apreciate it very much.
Just wanted to let you know that it works great, again thanks for the time and work.
You are wellcome, CyberOPs, cheers :)
This is really a very nice script:Quote$numberofposters = 5; // You can change this to however many you want
require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");
foreach ($top_posters as $poster)
{
echo $poster['link'] , ' (', $poster['posts'] , ')
';
}
Would it be possible to show the color of the membergroup, the rank title and the rank image there.
Is anyone have script for that, thanks in advance
My script (http://www.tinyportal.net/index.php?topic=8762.msg131637#msg131637) can show member colors (it can be done by modifing ssi_topPoster function too).
about the rank title and image - I can do that as well, just tell me how you want to see it, the layout.
thanks for your reply, I want the top poster just like this
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg511.imageshack.us%2Fimg511%2F5723%2Ftop10fa6.jpg&hash=2a16a42aee121dcf5543950947869d4846c29bcc)
hope you can help
okay, I'll try to collect needed info. Do you know html to make such layout?
[edit] not sure what "Rank" means. Is it group name?
No, I didn't know the html code for that, Rank is the membergroup name just like Jr. Member with their no. of stars.
It is possible to add something to this script so that it only counted posts in certain boards for the duration of the contest? (I know I can change the boards in admin CP to count posts or not but I dont want to change how that is set up.) I just want to have a competition for posting in certain boards for a period of time.
Is that possible and can someone tell me what code to use?
Quote from: confuzed on July 06, 2007, 05:01:30 PM
It is possible to add something to this script so that it only counted posts in certain boards for the duration of the contest? (I know I can change the boards in admin CP to count posts or not but I dont want to change how that is set up.) I just want to have a competition for posting in certain boards for a period of time.
Is that possible and can someone tell me what code to use?
This would be a SMF mod. You should check their for something similar. If you don't find something, post a request in the Code help boards.
thanks.
Question does this code use the time that the board is set to or the time on the server that the board is on? Because that would be a problem :(
It uses the time you set at the beginning of the script. If you read the comments you will see.
What if you wanted to take this and say, "Top posters for today..."
Thief,
I'm using your code, and it works great, so thanks!
One question, how do I exclude admins and moderators from being counted?
Thanks again.
Quote from: Thief on May 11, 2007, 02:18:46 PM
I have modified top posters script(s) posted here to support member color links if they are available. Also removed some redundant code.
global $db_prefix, $scripturl, $modSettings;
$memberstoshow = 7;
$matchperiod = false;
$countmodsandadmins = true; // not yet implemented
// Change this to the time you want the contest to start [http://www.onlineconversion.com/unix_time.htm]
$starttime = time() - 604800; // Last week posters
$endtime = time(); // Change this to the time you want the contest to end
$where_period = '';
if (!empty($modSettings['MemberColorLink'])) // check if MemberColorLink mod is installed and enabled
{
if ($matchperiod) // select only posts matching period
$where_period = "AND m.posterTime > $starttime AND m.posterTime < $endtime";
$query = db_query(
"SELECT m.realName, m.ID_MEMBER, mg.onlineColor, m.posts
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS mg ON (m.ID_GROUP = mg.ID_GROUP AND m.ID_GROUP)
$where_period
ORDER BY m.posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
else
{
if ($matchperiod) // select only posts matching period
$where_period = "WHERE posterTime > $starttime AND posterTime < $endtime";
$query = db_query(
"SELECT realName, ID_MEMBER, posts
FROM {$db_prefix}members
$where_period
ORDER BY posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
$firstrecord = true;
while ($row = mysql_fetch_assoc($query))
{
if ($firstrecord)
{
$biggest = $row['posts'];
$firstrecord = false;
}
$bar_length = intval(($row['posts']/$biggest) * 40);
if(isset($row['onlineColor']))
$style = 'color: '. $row['onlineColor'];
else
$style = '';
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><b><a style="' . $style . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></b> (' . $row['posts'] . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" title="' . $bar_length*2.5 . '%" alt="" /></div></td>
</tr>
</table>
';
}
Please post comments and suggestions so I will be able to improve it for your needs :) Thanks.
Quote from: texasflats on December 31, 2007, 03:00:06 AM
Thief,
I'm using your code, and it works great, so thanks!
One question, how do I exclude admins and moderators from being counted?
Thanks again.
I too am interested in this. Did you figure it out, I can't.
Headed out the door, so this was quick and untested. I'll check back later to see if it works.
global $db_prefix, $scripturl, $modSettings;
$memberstoshow = 7;
$matchperiod = false;
$countmodsandadmins = true; // not yet implemented
// Change this to the time you want the contest to start [http://www.onlineconversion.com/unix_time.htm]
$starttime = time() - 604800; // Last week posters
$endtime = time(); // Change this to the time you want the contest to end
$where_period = '';
if (!empty($modSettings['MemberColorLink'])) // check if MemberColorLink mod is installed and enabled
{
if ($matchperiod) // select only posts matching period
$where_period = "AND m.posterTime > $starttime AND m.posterTime < $endtime";
$query = db_query(
"SELECT m.realName, m.ID_GROUP, m.ID_MEMBER, mg.onlineColor, m.posts
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS mg ON (m.ID_GROUP = mg.ID_GROUP AND m.ID_GROUP)
$where_period
ORDER BY m.posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
else
{
if ($matchperiod) // select only posts matching period
$where_period = "WHERE posterTime > $starttime AND posterTime < $endtime";
$query = db_query(
"SELECT realName, ID_GROUP, ID_MEMBER, posts
FROM {$db_prefix}members
$where_period
ORDER BY posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
$firstrecord = true;
while ($row = mysql_fetch_assoc($query))
{
// Change the ID_GROUP 1 and 2 here to match the groups you don't want in the output
if ($row['ID_GROUP'] != 1 && $row['ID_GROUP'] != 2)
{
if ($firstrecord)
{
$biggest = $row['posts'];
$firstrecord = false;
}
$bar_length = intval(($row['posts']/$biggest) * 40);
if(isset($row['onlineColor']))
$style = 'color: '. $row['onlineColor'];
else
$style = '';
}
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><b><a style="' . $style . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></b> (' . $row['posts'] . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" title="' . $bar_length*2.5 . '%" alt="" /></div></td>
</tr>
</table>
';
}
I put a comment in the code on what you need to change. So please read the code comment I put in there.
Quote from: IchBinâ,,¢ on January 02, 2008, 04:47:26 PM
Headed out the door, so this was quick and untested. I'll check back later to see if it works.
global $db_prefix, $scripturl, $modSettings;
$memberstoshow = 7;
$matchperiod = false;
$countmodsandadmins = true; // not yet implemented
// Change this to the time you want the contest to start [http://www.onlineconversion.com/unix_time.htm]
$starttime = time() - 604800; // Last week posters
$endtime = time(); // Change this to the time you want the contest to end
$where_period = '';
if (!empty($modSettings['MemberColorLink'])) // check if MemberColorLink mod is installed and enabled
{
if ($matchperiod) // select only posts matching period
$where_period = "AND m.posterTime > $starttime AND m.posterTime < $endtime";
$query = db_query(
"SELECT m.realName, m.ID_GROUP, m.ID_MEMBER, mg.onlineColor, m.posts
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS mg ON (m.ID_GROUP = mg.ID_GROUP AND m.ID_GROUP)
$where_period
ORDER BY m.posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
else
{
if ($matchperiod) // select only posts matching period
$where_period = "WHERE posterTime > $starttime AND posterTime < $endtime";
$query = db_query(
"SELECT realName, ID_GROUP, ID_MEMBER, posts
FROM {$db_prefix}members
$where_period
ORDER BY posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
$firstrecord = true;
while ($row = mysql_fetch_assoc($query))
{
// Change the ID_GROUP 1 and 2 here to match the groups you don't want in the output
if ($row['ID_GROUP'] != 1 && $row['ID_GROUP'] != 2)
{
if ($firstrecord)
{
$biggest = $row['posts'];
$firstrecord = false;
}
$bar_length = intval(($row['posts']/$biggest) * 40);
if(isset($row['onlineColor']))
$style = 'color: '. $row['onlineColor'];
else
$style = '';
}
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><b><a style="' . $style . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></b> (' . $row['posts'] . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" title="' . $bar_length*2.5 . '%" alt="" /></div></td>
</tr>
</table>
';
}
I put a comment in the code on what you need to change. So please read the code comment I put in there.
I copied and pasted this and it did not work... I read the comment, but I was unsure what to change. Sorry for my low-level of php understanding.
insane, looks as if you just need to put in time stamp of contest start and stop as per note.
here is link to convert and get those digits...
http://www.onlineconversion.com/unix_time.htm
I don't want it to stop or start, i just want it to display the top posters - minus the administrators and moderators.
oops. got you confused with the contest time frame request. :)
:( help lol
I tried it also, it still shows Mods and Admins. But I DO appreciate the effort!
Quote from: IchBinâ,,¢ on January 02, 2008, 04:47:26 PM
Headed out the door, so this was quick and untested. I'll check back later to see if it works.
global $db_prefix, $scripturl, $modSettings;
$memberstoshow = 7;
$matchperiod = false;
$countmodsandadmins = true; // not yet implemented
// Change this to the time you want the contest to start [http://www.onlineconversion.com/unix_time.htm]
$starttime = time() - 604800; // Last week posters
$endtime = time(); // Change this to the time you want the contest to end
$where_period = '';
if (!empty($modSettings['MemberColorLink'])) // check if MemberColorLink mod is installed and enabled
{
if ($matchperiod) // select only posts matching period
$where_period = "AND m.posterTime > $starttime AND m.posterTime < $endtime";
$query = db_query(
"SELECT m.realName, m.ID_GROUP, m.ID_MEMBER, mg.onlineColor, m.posts
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS mg ON (m.ID_GROUP = mg.ID_GROUP AND m.ID_GROUP)
$where_period
ORDER BY m.posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
else
{
if ($matchperiod) // select only posts matching period
$where_period = "WHERE posterTime > $starttime AND posterTime < $endtime";
$query = db_query(
"SELECT realName, ID_GROUP, ID_MEMBER, posts
FROM {$db_prefix}members
$where_period
ORDER BY posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
$firstrecord = true;
while ($row = mysql_fetch_assoc($query))
{
// Change the ID_GROUP 1 and 2 here to match the groups you don't want in the output
if ($row['ID_GROUP'] != 1 && $row['ID_GROUP'] != 2)
{
if ($firstrecord)
{
$biggest = $row['posts'];
$firstrecord = false;
}
$bar_length = intval(($row['posts']/$biggest) * 40);
if(isset($row['onlineColor']))
$style = 'color: '. $row['onlineColor'];
else
$style = '';
}
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><b><a style="' . $style . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></b> (' . $row['posts'] . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" title="' . $bar_length*2.5 . '%" alt="" /></div></td>
</tr>
</table>
';
}
I put a comment in the code on what you need to change. So please read the code comment I put in there.
The numbers 1 and 2 in this code are the ID numbers for your groups in SMF that you DON'T want to show. You can get the ID number by hovering your mouse over the link in the member groups section of your admin. Just exchange your numbers with these numbers.
Change this line:
if ($row['ID_GROUP'] != 1 && $row['ID_GROUP'] != 2)
To this:
if ($row['ID_GROUP'] != 1 || $row['ID_GROUP'] != 2)
See if this works. Still haven't had a chance to test it as I'm at work.
I'm sorry, I should have mentioned that I, well in fact 1 and 2 were the membergroups I wanted to exclude.
Thanks again.
So based on your last message, I have no idea whether its working for you or not...lol
Ich, I put this
if ($row['ID_GROUP'] != 1 || $row['ID_GROUP'] != 2)
into the spot, and it still has admins and moderators included in the list.
Thank you for trying to help, I know you will figure it out.
lol sorry... No it didn't work.
Quote from: IchBinâ,,¢ on January 04, 2008, 03:21:33 AM
So based on your last message, I have no idea whether its working for you or not...lol
Ok, lemme think on this for a bit. Don't know why it wouldn't work. Maybe I'll try an array later to see if it makes a difference. Bring the topic up if you don't see something by the end of Saturday.
Well fork me sideways, it worked on my site with this code. Which seems to be the same as I posted above. Can you try this please.
global $db_prefix, $scripturl, $modSettings;
$memberstoshow = 7;
$matchperiod = false;
$countmodsandadmins = true; // not yet implemented
// Change this to the time you want the contest to start [http://www.onlineconversion.com/unix_time.htm]
$starttime = time() - 604800; // Last week posters
$endtime = time(); // Change this to the time you want the contest to end
$where_period = '';
if (!empty($modSettings['MemberColorLink'])) // check if MemberColorLink mod is installed and enabled
{
if ($matchperiod) // select only posts matching period
$where_period = "AND m.posterTime > $starttime AND m.posterTime < $endtime";
$query = db_query(
"SELECT m.realName, m.ID_GROUP, m.ID_MEMBER, mg.onlineColor, m.posts
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS mg ON (m.ID_GROUP = mg.ID_GROUP AND m.ID_GROUP)
$where_period
ORDER BY m.posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
else
{
if ($matchperiod) // select only posts matching period
$where_period = "WHERE posterTime > $starttime AND posterTime < $endtime";
$query = db_query(
"SELECT realName, ID_GROUP, ID_MEMBER, posts
FROM {$db_prefix}members
$where_period
ORDER BY posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
$firstrecord = true;
while ($row = mysql_fetch_assoc($query))
{
// Change the ID_GROUP 1 and 2 here to match the groups you don't want in the output
if ($row['ID_GROUP'] != 1 && $row['ID_GROUP'] != 2)
{
if ($firstrecord)
{
$biggest = $row['posts'];
$firstrecord = false;
}
$bar_length = intval(($row['posts']/$biggest) * 40);
if(isset($row['onlineColor']))
$style = 'color: '. $row['onlineColor'];
else
$style = '';
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><b><a style="' . $style . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></b> (' . $row['posts'] . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" title="' . $bar_length*2.5 . '%" alt="" /></div></td>
</tr>
</table>';
}
}
Ich your a genius. Thank you sir.
The last one works for me also, thank you IchBinâ,,¢
threw this on our site today and have to say that its a quality block. thanks for putting it up
First of all, i really liked this script.I started a competition in my site.I wanted certain members to be excluded.See, i have got 1 bot working from 1 id.I started top poster of the month comp. .That bot welcomes all the members(SMF welcome mod).So, i wanted that bot not to be displayed in the top posters.
Any help?
I assume from your post that you have a script that you refer to as a bot. I wouldn't know how to alter that script unless I could see it.
No, several other posters like 5-6 normal members doesn't want to participate.Its ok to me but they just don't want their names in the list, as its a post based so they also cannot do about it.So, i was looking for some script so that this script ignores few users if i type in their ids, or id no. or something...
I really got it wrong, didn't I? :)
You can add a line to the query.
Before
ORDER BY m.posts DESC
you can add
AND m.ID_MEMBER NOT IN (34,87,156)
substituting the numbers of the people you want to exclude.
Quote from: JPDeni on October 19, 2006, 01:58:12 AM
Sure. That's easier to do than what I have above.
You want just a general top x number of posters, right? No time limit?
$numberofposters = 5; // You can change this to however many you want
require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");
foreach ($top_posters as $poster)
{
echo $poster['link'] , ' (', $poster['posts'] , ')<br />';
}
Edited to make the variables a little neater.
Hi,
Great piece of code!
I got this to work and modified it a little so that it shows the rank(top poster is #1) of the poster. What i wanted to know is how can I add th user's avatar with a set width and height, say, 20px x 20px.
Help will be very much appreciated.
Thanks in advance.
darkwind
I don't know. I've never figured out how to work with avatars.
And please don't change the font size in your posts. Some of us have been around a few more years than others and our eyes aren't as good as they used to be. I had to copy your text and paste it into a text editor in order to be able to read it.
ok. noted. my apologies.
hope someone will be able to shed some light.
thanks.
I got it working with the avatar, using this code
global $db_prefix, $scripturl, $memberContext, $txt, $modSettings, $context, $settings, $options;
$starttime = strtotime('24 hours ago');
$list_count = 10;
$poster = array();
$request = db_query("
SELECT m.ID_MEMBER, COUNT(m.ID_MEMBER) as postCount
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE m.posterTime > " . $starttime . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
GROUP BY m.ID_MEMBER
ORDER BY postCount DESC LIMIT " . $list_count, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
loadMemberData(array($row['ID_MEMBER']));
loadMemberContext($row['ID_MEMBER']);
$poster[$row['ID_MEMBER']] = array (
'id' => $row['ID_MEMBER'],
'count' => $row['postCount'],
'ava' =>$memberContext[$row['ID_MEMBER']]['avatar']['image'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $memberContext[$row['ID_MEMBER']]['name'] . '">' . '<font color="' . $memberContext[$row['ID_MEMBER']]['group_color'] . '">' . $memberContext[$row['ID_MEMBER']]['name'] . '</font>' . '</a>' );
}
mysql_free_result($request);
echo '<table width=100%>';
foreach($poster as $top_user)
{
echo '<tr>
<td align="left" width=10%>' . $top_user['ava'] . '</td>
<td align="left" width=80%>' . $top_user['link'] . '</td>
<td align="right"> '. $top_user['count'] . '</td>
</tr>';
}
echo '</table>';
The only problem is the avatars need to be resized
here is a screenshot of what I have so far:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fnextsite.org%2Fforum%2Fimagehost%2Fuploads%2F1eacbb031a.jpg&hash=35d12e76da522449d764a9571622510e2de3530e)
You won't be able to "resize" theme without using some php library like GD. You could limit the HTML to only display a certain size, but that would be cutting the avatar off, and not "resizing" it.
Couldn't a function like this be applied?
'ava' => ‘<img src="', htmlspecialchars($memberContext[$row['ID_MEMBER']]['avatar']['image']), '" width="20" alt="">’,
This one is giving a parse error, but I was wondering if this would be on the right track to getting this to work
That'll work, but you might end up with distorted avatars. If the original is wider than 20 pixels, then the avatar will look tall and skinny. If the original is narrower than 20 pixels, the avatar will look short and fat. It might not make a whole lot of difference, but it'll be noticeable, especially to the owners of the avatars.
I think your parse error is because you've ended the line with a , instead of a ;
Hmmm...I tried changing the comma to a semicolon and still recieved a parse error here is the code thus far
global $db_prefix, $scripturl, $memberContext, $txt, $modSettings, $context, $settings, $options;
$starttime = strtotime('24 hours ago');
$list_count = 10;
$poster = array();
$request = db_query("
SELECT m.ID_MEMBER, COUNT(m.ID_MEMBER) as postCount
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE m.posterTime > " . $starttime . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
GROUP BY m.ID_MEMBER
ORDER BY postCount DESC LIMIT " . $list_count, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
loadMemberData(array($row['ID_MEMBER']));
loadMemberContext($row['ID_MEMBER']);
$poster[$row['ID_MEMBER']] = array (
'id' => $row['ID_MEMBER'],
'count' => $row['postCount'],
'ava' => '<img src="', htmlspecialchars($memberContext[$row['ID_MEMBER']]['avatar']['image']), '" width="20" alt="">';
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $memberContext[$row['ID_MEMBER']]['name'] . '">' . '<font color="' . $memberContext[$row['ID_MEMBER']]['group_color'] . '">' . $memberContext[$row['ID_MEMBER']]['name'] . '</font>' . '</a>' );
}
mysql_free_result($request);
echo '<table width=100%>';
foreach($poster as $top_user)
{
echo '<tr>
<td align="left" width="20"> '. $top_user['ava'] .'</td>
<td align="left" width=50%>' . $top_user['link'] . '</td>
<td align="right"> '. $top_user['count'] . '</td>
</tr>';
}
echo '</table>';
I have been looking through it and haven't seen anything that looks outta the ordinary that would make it parse...
Now I am stumped :uglystupid2:
What exactly is your parse error? It makes it a whole lot easier to find things if I know what I'm looking for.
Thats what I usually use, but in TP 1.05 it doesn't tell you which line...The block just doesn't show up
Thanks for the code, one thing I would like is to not put a start time but to take the top posters all-time.
I know what line it is I'm just not sure what value should it be.
$starttime = strtotime('24 hours ago');
darkwind:
Quote
I know what line it is I'm just not sure what value should it be.
$starttime = 0;
Anubis, I just got home. I'll take a look at your code if I can find it. I have received parse code line numbers when there was a problem, so it probably is more of a logic error than a parse code error. But I'll take a look.
Thanks JP :)
You were right about ending that line with a comma. I didn't realize it was part of an array.
I'm getting a return. At first I didn't think I was, but then I realized there were no posts in the past 24 hours, so it's logical that nothing would be there. But when I added it to my live active site, I got the list of today's posters. Are you sure you have posts within the time frame that you've set?
Yes tons my site is very active :)
and the code keeps up with the users postings correctly as I have observed (without the use of the avatars)
Update okay I reinserted the code into a new Block, then turned off my other old one and I am getting a return but no avatars are showing
Quote from: darkwind on April 19, 2008, 01:24:36 AM
Thanks for the code, one thing I would like is to not put a start time but to take the top posters all-time.
I know what line it is I'm just not sure what value should it be.
$starttime = strtotime('24 hours ago');
Got it to work. Thanks everyone!
Glad you got it sorted, darkwind.
I don't know what the issue is, Anubis. I haven't worked with avatars enough to be able to get them to work for me either.
Well I will keep trying to see if I can get this last piece of the puzzle sorted
Thanks for your help :up:
I did a check using Internet Explorer to see where it is trying to get the image from and it spit out some funky looking url, LOL
http://www.mysite.com/forum/%3C/td%3E%20%20%20%20%20%20%3Ctd%20align=
Hi!
I'm back
$request = db_query("
SELECT m.ID_MEMBER, COUNT(m.ID_MEMBER) as postCount
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE m.posterTime > " . $starttime . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
GROUP BY m.ID_MEMBER
ORDER BY postCount DESC LIMIT " . $list_count, __FILE__, __LINE__);
I would like to change the query above so that it will only select posts from a particular board.
Any help will be much appreciated.
Thanks in advance
darkwind
Put this with the other "AND" commands -- somewhere between the "WHERE" line and the "GROUP BY" line
AND b.ID_BOARD = 43
Change the 43 to the number of the board you want to use.
That was quick and works perfectly.
Thanks!
hello iam use the following code topposter
global $db_prefix, $scripturl, $modSettings;
$memberstoshow = 7;
$matchperiod = true;
$countmodsandadmins = true; // not yet implemented
// Change this to the time you want the contest to start [http://www.onlineconversion.com/unix_time.htm]
$starttime = time() - 604800; // Last week posters
$endtime = time(); // Change this to the time you want the contest to end
$where_period = '';
if (!empty($modSettings['MemberColorLink'])) // check if MemberColorLink mod is installed and enabled
{
if ($matchperiod) // select only posts matching period
$where_period = "AND m.posterTime > $starttime AND m.posterTime < $endtime";
$query = db_query(
"SELECT m.realName, m.ID_GROUP, m.ID_MEMBER, mg.onlineColor, m.posts
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS mg ON (m.ID_GROUP = mg.ID_GROUP AND m.ID_GROUP)
$where_period
ORDER BY m.posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
else
{
if ($matchperiod) // select only posts matching period
$where_period = "WHERE posterTime > $starttime AND posterTime < $endtime";
$query = db_query(
"SELECT realName, ID_GROUP, ID_MEMBER, posts
FROM {$db_prefix}members
$where_period
ORDER BY posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
$firstrecord = true;
if($countmodsandadmins)
{
while ($row = mysql_fetch_assoc($query))
{
if ($firstrecord)
{
$biggest = $row['posts'];
$firstrecord = false;
}
$bar_length = intval(($row['posts']/$biggest) * 40);
if(isset($row['onlineColor']))
$style = 'color: '. $row['onlineColor'];
else
$style = '';
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><b><a style="' . $style . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></b> (' . $row['posts'] . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" title="' . $bar_length*2.5 . '%" alt="" /></div></td>
</tr>
</table>';
}
}
else
{
while ($row = mysql_fetch_assoc($query))
{
// Change the ID_GROUP 1 and 2 here to match the groups you don't want in the output
if ($row['ID_GROUP'] != 1 && $row['ID_GROUP'] != 2)
{
if ($firstrecord)
{
$biggest = $row['posts'];
$firstrecord = false;
}
$bar_length = intval(($row['posts']/$biggest) * 40);
if(isset($row['onlineColor']))
$style = 'color: '. $row['onlineColor'];
else
$style = '';
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><b><a style="' . $style . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a></b> (' . $row['posts'] . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" title="' . $bar_length*2.5 . '%" alt="" /></div></td>
</tr>
</table>';
}
}
}
the problem is
if the
$matchperiod = false;
working fine
but
$matchperiod = true;
this made error
error message:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND m.posterTime > 1209443662 AND m.posterTime < 1210048462
ORDER BY p' at line 3
File: /home/prankcom/public_html/******/Sources/Load.php(1738) : eval()'d code(209) : eval()'d code
Line: 33
help me............
I don't know if this will solve your problem, but I see an error.
Change
if (!empty($modSettings['MemberColorLink'])) // check if MemberColorLink mod is installed and enabled
{
if ($matchperiod) // select only posts matching period
{
$where_period = "AND m.posterTime > $starttime AND m.posterTime < $endtime";
$query = db_query(
"SELECT m.realName, m.ID_GROUP, m.ID_MEMBER, mg.onlineColor, m.posts
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS mg ON (m.ID_GROUP = mg.ID_GROUP AND m.ID_GROUP)
$where_period
ORDER BY m.posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
to
if (!empty($modSettings['MemberColorLink'])) // check if MemberColorLink mod is installed and enabled
{
if ($matchperiod) // select only posts matching period
{
$where_period = "WHERE m.posterTime > $starttime AND m.posterTime < $endtime";
$query = db_query(
"SELECT m.realName, m.ID_GROUP, m.ID_MEMBER, mg.onlineColor, m.posts
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS mg ON (m.ID_GROUP = mg.ID_GROUP AND m.ID_GROUP)
$where_period
ORDER BY m.posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
sorry to disturb you one more time
but i've problem with the following code (red color code)
if i remove working fine
what can i do ?
Quoteglobal $db_prefix, $scripturl, $modSettings;
$memberstoshow = 7;
$matchperiod = true;
$countmodsandadmins = true; // not yet implemented
// Change this to the time you want the contest to start [http://www.onlineconversion.com/unix_time.htm]
$starttime = time() - 604800; // Last week posters
$endtime = time(); // Change this to the time you want the contest to end
$where_period = '';
if (!empty($modSettings['MemberColorLink'])) // check if MemberColorLink mod is installed and enabled
{
if ($matchperiod) // select only posts matching period
$where_period = "AND m.posterTime > $starttime AND m.posterTime < $endtime";
$query = db_query(
"SELECT m.realName, m.ID_GROUP, m.ID_MEMBER, mg.onlineColor, m.posts
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}membergroups AS mg ON (m.ID_GROUP = mg.ID_GROUP AND m.ID_GROUP)
$where_period
ORDER BY m.posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
else
{
if ($matchperiod) // select only posts matching period
$where_period = "WHERE posterTime > $starttime AND posterTime < $endtime";
$query = db_query(
"SELECT realName, ID_GROUP, ID_MEMBER, posts
FROM {$db_prefix}members
$where_period
ORDER BY posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
}
$firstrecord = true;
if($countmodsandadmins)
{
while ($row = mysql_fetch_assoc($query))
{
if ($firstrecord)
{
$biggest = $row['posts'];
$firstrecord = false;
}
$bar_length = intval(($row['posts']/$biggest) * 40);
if(isset($row['onlineColor']))
$style = 'color: '. $row['onlineColor'];
else
$style = '';
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><a style="' . $style . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a> (' . $row['posts'] . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" title="' . $bar_length*2.5 . '%" alt="" /></div></td>
</tr>
</table>';
}
}
else
{
while ($row = mysql_fetch_assoc($query))
{
// Change the ID_GROUP 1 and 2 here to match the groups you don't want in the output
if ($row['ID_GROUP'] != 1 && $row['ID_GROUP'] != 2)
{
if ($firstrecord)
{
$biggest = $row['posts'];
$firstrecord = false;
}
$bar_length = intval(($row['posts']/$biggest) * 40);
if(isset($row['onlineColor']))
$style = 'color: '. $row['onlineColor'];
else
$style = '';
echo '
<table width="100%" border="0">
<tr>
<td><div class="smalltext"><a style="' . $style . '" href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a> (' . $row['posts'] . ')</div></td>
<td><div align="right"><img src="' . $settings['images_url'] . '/bar.gif" width="' . $bar_length . '" height="10" title="' . $bar_length*2.5 . '%" alt="" /></div></td>
</tr>
</table>';
}
}
}
If you remove it, you won't get posts within the time frame.
Try this.
Replace
if ($matchperiod) // select only posts matching period
$where_period = "WHERE posterTime > $starttime AND posterTime < $endtime";
$query = db_query(
"SELECT realName, ID_GROUP, ID_MEMBER, posts
FROM {$db_prefix}members
$where_period
ORDER BY posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
with
$query = db_query(
"SELECT realName, ID_GROUP, ID_MEMBER, posts
FROM {$db_prefix}members
WHERE posterTime > $starttime AND posterTime < $endtime
ORDER BY posts DESC
LIMIT 0,$memberstoshow", __FILE__, __LINE__);
Is it possible to adapt this a little bit for a post contest so that the total number of forum posts is also displayed plus what your target number of posts is, with a countdown to say how many are still needed?
Like this:
Posting target 250,000 posts
Current forum posts 200,000 posts
Number of posts needed to reach target : 50,000
So that the current forum posts and the number needed to reach target would change every time someone posts
and then underneath you could have the top ten posters post counts for the period.
Im using this code for the top posts block for this month. I want to make it where it ignores the posts of just one specific board. Is there a line of code i can add so it ignores this one specific board.
Thanks.
global $db_prefix, $scripturl;
$starttime = 1225551600; // Change this to the time you want the contest to start
$endtime = 1228089599; // Change this to the time you want the contest to end
$count= array();
$poster_number = array();
$query = db_query(
"SELECT posterName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
FROM {$db_prefix}members
JOIN {$db_prefix}messages
ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
AND posterTime > $starttime
AND posterTime < $endtime", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
if (!isset($count[$row['posterName']]))
$count[$row['posterName']] = 0;
++$count[$row['posterName']];
$poster_number[$row['posterName']] = $row['ID_MEMBER'];
}
arsort($count);
$list_number = 0;
foreach ($count as $key => $value)
{
echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $poster_number[$key] . '">' . $key . '</a> (' . $value . ')<br />';
++$list_number;
if ($list_number > 10)
break;
}
ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
WHERE ID_BOARD <> XX
AND posterTime > $starttime
AND posterTime < $endtime", __FILE__, __LINE__);
Replace the XX with the number of the board you want to exclude.
Thank you JP. That worked great. Thank You.
Quote from: JPDeni on November 01, 2008, 04:22:37 PM
ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
WHERE ID_BOARD <> XX
AND posterTime > $starttime
AND posterTime < $endtime", __FILE__, __LINE__);
Replace the XX with the number of the board you want to exclude.
ooh is it possible to do this in reverse, and specify the boards you want to include? As this would be great if it only included certain on-topic boards :)
thanks in advance
Sure.
WHERE ID_BOARD = #
OR ID_BOARD = #
Fill in the boards you want instead of the # character. Add as many OR lines as you need.
thanks JPdeni
and with this one excluding boards can I do the same thing and just add as many
of these lines as boards that I want to exclude?
WHERE ID_BOARD <> XX
Quote from: JPDeni on November 01, 2008, 04:22:37 PM
ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
WHERE ID_BOARD <> XX
AND posterTime > $starttime
AND posterTime < $endtime", __FILE__, __LINE__);
Replace the XX with the number of the board you want to exclude.
My problem is that I want to exclude the off-topic boards, but I think I have more on-topic boards, so I'm trying to work out the easiest/quickest way to only count the boards I want. I thought entering each on-topic board would work but there are probably more of them than off-topic, and they also get added too, whereas the off-topic boards are static and there are probably slightly less of them.
Is it possible to use this then
WHERE ID_BOARD <> XX
one line for each off-topic board I want to exclude? Or do they have to be added like in a list (array?)
thanks again for your help
If you want an answer today, the answer is:
to include boards, use a series of OR statements as above. You can have as many as you want, but the first one must be a WHERE and after that, each one is an OR.
or
to exclude boards, use a series of AND statements.
WHERE ID_BOARD <> #
AND ID_BOARD <> #
AND ID_BOARD <> #
Again, use as many as you want. The first one starts with WHERE and after that, each one starts with AND.
There is probably a more elegant way to do this, but I've been up for far too long and I can't think of what it is right now.
Thanks I think
$top_posters = ssi_topPoster(5, 'array');
echo '
<ol>';
foreach ($top_posters as $poster)
echo '
<li>', $poster['link'], ' - ', $poster['posts'], '</li>';
echo '
</ol>';
hello there,
I am looking for top 10 poster that will display similar to this format.
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg511.imageshack.us%2Fimg511%2F5723%2Ftop10fa6.jpg&hash=2a16a42aee121dcf5543950947869d4846c29bcc)
Any idea how to achieve it.
Thanks in advance ;)
This is overall top posters or only those from certain boards? Where is the "rank" definied?
Yeah, this is the overall forum top poster. Rank is defined as membergroup name.
I'm sorry. I can't figure out what they do with the stars. Makes no sense to me. Maybe if I look at it later I'll understand it. Or maybe someone else will be able to help.
JPDeni...
just to clarify what the coding is, I can't figure out how to do it either lol, but it would be pretty cool :up:
It would show as follows:
1. a number in front of the user name followed by the number of posts this user has
2. underneath this data the membergroup this user belongs to for instance...if it were your data and ATM you were the top poster on TP it would look like:
1. JPDeni (3249)
(https://www.tinyportal.net/Themes/bz29/images/tp-code.gif)
2. Lord Anubis (653)
(https://www.tinyportal.net/Themes/bz29/images/star.gif)(https://www.tinyportal.net/Themes/bz29/images/star.gif)(https://www.tinyportal.net/Themes/bz29/images/star.gif)(https://www.tinyportal.net/Themes/bz29/images/star.gif)(https://www.tinyportal.net/Themes/bz29/images/star.gif)
etc.....
Does that help at all?
EDIT: Aha...see where a problem in coding this might lye is because if using stars, rather than full images it uses a function to check the number of postings and adds an image to it....dunno the difficulties that might impose
Hope I make any sense :)
JPDeni,
These stars are obviously for the post count based groups, not for regular membergoups. The difference is that she is using 5 yellow stars for Captain and 5 red stars for Colonel. See enclosed images.
ZarPrime
I know all that, guys. :) I looked at the code which displays the stars and I can't figure out what the code means. IIRC, it's in Load.php in either loadMemberContext or loadMemberData. Theoretically, I could probably just run those functions, but it seems such a waste of resources to get all that data when all I need is the stars. The problem I have is in breaking down the code for the stars to figure out how they got it.