Hello,
This small mod adds the top 5 karma ratings, and the lowest 5 karma ratings to the stats page. You can see an example of it here:
http://forums.tauonline.org/index.php?action=stats (http://forums.tauonline.org/index.php?action=stats)
Update: This has been updated on 4/12/04. The changes are:
- If you have karma disabled on your forum, this mod won't take effect, if you have it on 'Enable Karma Total' this mod will show the highest and lowest total karma, and if you have it on 'Enable Karma Positive/Negative' this mod will show the members with the highest positive karma, and the members with the lowest negative karma. Thanks to NiXnAx (http://www.simplemachines.org/community/index.php?action=profile;u=3163) for helping make the showing of karma totals display correctly.
- The members' names are now linked to their profile. Thanks to Burpee (http://www.simplemachines.org/community/index.php?action=profile;u=3129) for helping out with this
Here's what to change:
In /Sources/Stats.php
Find:// Activity by month.
Add above it:// Top 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);
$context['karma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}
// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);
$context['bkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}
// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);
$context['htkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
$context['ltkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
In /Themes/(ThemeFolder)/Stats.template.php
Find:foreach ($context['top_time_online'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : ' ', '</td>
<td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
</tr>';
echo '
</table>
</td>
</tr><tr>
<td class="catbg" colspan="4"><b>', $txt['smf_stats_5'], '</b></td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_history.gif" border="0" width="20" height="20" alt="" /></td>
<td class="windowbg2" colspan="4">';
Replace with:foreach ($context['top_time_online'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : ' ', '</td>
<td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
</tr>';
echo ' </table></td></tr>';
if( $modSettings['karmaMode'] == 1 )
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Total</td>
<td class="catbg" colspan="2">Lowest Karma Total</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';
foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$htkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';
foreach($context['ltkarma'] as $ltkarma)
{
$total = $ltkarma['Good'] - $ltkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$ltkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
}
if( $modSettings['karmaMode'] == 2)
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Rating</td>
<td class="catbg" colspan="2">Lowest Karma Rating</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';
foreach($context['gkarma'] as $gkarma)
{
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$gkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">+'.$gkarma['Karma'].'</td>
</tr></table>';
}
echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';
foreach($context['bkarma'] as $bkarma)
{
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr valign="top"><td class="windowbg2" width="80%" align="left">'.
$bkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">-'.$bkarma['Karma'].'</td>
</tr></table>';
}
}
echo'</tr></td><tr><td class="catbg" colspan="4"><b>', $txt['smf_stats_5'], '</b></td>
</tr>
<tr>
<td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_history.gif" border="0" width="20" height="20" alt="" /></td>
<td class="windowbg2" colspan="4">';
If you want it to show more (Or less) stats then:
In /Sources/Stats.php
Find the following: SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT
5SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT
5SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) DESC LIMIT
5SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) ASC LIMIT 5
5And replace the number bolded above to however many results you want shown.
That's it! Please say if you have any questions/queries about this,
TauOnline.Org (http://tauonline.org)
nice tip .. thanks for sharing it.
Quote from: A.M.A on October 24, 2004, 11:16:48 AM
nice tip .. thanks for sharing it.
Thanks and your welcome :) Also whatever happened to the links to all these tips? They were in the sticky, but now they aren't.. Was it too much work?
nope .. just thinking it is not hard to find a tip in here.
Quote from: A.M.A on October 24, 2004, 11:56:55 AM
nope .. just thinking it is not hard to find a tip in here.
Ah right. :) Will it come back if this board gets bigger?
Nice idea Tau, very useful. :)
Hmm... would it be possible to show the lowest and highest totals, instead of the votes casted upon each user?
PS: Nice trick, Tau :D
Quote from: Burpee on November 16, 2004, 08:55:36 AM
Hmm... would it be possible to show the lowest and highest totals, instead of the votes casted upon each user?
PS: Nice trick, Tau :D
Yeah it's possible, it's just that at the time of making the code, I couldn't be bothered to show the totals! I'll edit my first post soon to show the rating, or the totals depending on what setting you choose :)
EDIT: It appears it's not as easy as I thought it'd be.. I've got the main bit of this script working, I just can't get an ordered list to show up...
E.g: (Taken from my forum when testing this script)
Brother Edwin -3
Orion -1
Fire Eater -1
Feugan AM -1
misfits Tau punk -2
... I'm not good enough with arrays right now to complete this... I can give you the code that I have done at the moment, although it doesn't show an ordered list and so is kind of pointless.. I'll keep working on this, although I doubt I can do this at the moment... Sorry :-[ If anyone wants to help out, It'd be appreciated
Hmm... perhaps you should share the code you have right now so people can try and help you...
I probably can't help you, but ofcourse I'm willing to give it a try :P
Quote from: Burpee on November 16, 2004, 04:36:20 PM
Hmm... perhaps you should share the code you have right now so people can try and help you...
I probably can't help you, but ofcourse I'm willing to give it a try :P
I've updated my first post to do this :)
Wow, I tried doing this on my forum a while back and just gave up. Having a max and min is nice, but I was just trying to show the max listings. All you would have to do is sum their max and mins and then sort the highest n number of returns, and store those into a new array. Then run a counter from 0 to the number of names -1 and you would have it.
I dont have time right now, but when I do I'll see if I can figure it out. But Im only going to figure out how to show the Higest totals, not the lowest..
Here's your code running on my forum: http://board.marlincrawler.com/index.php?action=stats (http://board.marlincrawler.com/index.php?action=stats)
Thanks for the code and I'll see what I can do...
Quote from: BigMike on November 17, 2004, 05:31:07 PM
Wow, I tried doing this on my forum a while back and just gave up. Having a max and min is nice, but I was just trying to show the max listings. All you would have to do is sum their max and mins and then sort the highest n number of returns, and store those into a new array. Then run a counter from 0 to the number of names -1 and you would have it.
I dont have time right now, but when I do I'll see if I can figure it out. But Im only going to figure out how to show the Higest totals, not the lowest..
Here's your code running on my forum: http://board.marlincrawler.com/index.php?action=stats (http://board.marlincrawler.com/index.php?action=stats)
Thanks for the code and I'll see what I can do...
Cool, thanks :) Also I'm glad you liked the code :)
Hey this is great and all, but I have a question:
http://www.ozmafans.com/forum
People seem to show up multiple times.
For example: "stefanie" has the highest at +123, but also the lowest at -118 ? How is this possible?
I just read some of the comments, I understand now. If someone could make this a real feature, that includes BOTH totals and the original stats (as both are interesting) I would love it.
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
Quote from: NiXnAx on December 02, 2004, 11:53:29 AM
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
that worked perfectly (karmaBad-karmaGood) as well, for the Top 5 posters.
sorry for double-replying, but I am noticing now that after increasing the count to 10, the stats are no longer in order.
To see for yourself, www.ozmafans.com/forum
Quote from: ozmafans on December 02, 2004, 01:35:04 PM
Quote from: NiXnAx on December 02, 2004, 11:53:29 AM
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
that worked perfectly (karmaBad-karmaGood) as well, for the Top 5 posters.
You only need to change ASC to DESC to get the top 5 karma total.
Quote from: NiXnAx on December 02, 2004, 02:45:14 PM
Quote from: ozmafans on December 02, 2004, 01:35:04 PM
Quote from: NiXnAx on December 02, 2004, 11:53:29 AM
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
that worked perfectly (karmaBad-karmaGood) as well, for the Top 5 posters.
You only need to change ASC to DESC to get the top 5 karma total.
Thank you for that tip, I know very little about php/sql.
The problem seems to be that say I had -100 karma points given to me, and 100 positive karma points given to me.
karmaBad (100) - karmaGood (100) = -200, when it should really be 0. Is there an absolute value function?
when you remove good karma from bad karma, you usually get negative karma. (that is supposed when you are nice on the forum), and int (the value of karma, stored in the database cannot be negative) ant that is the reason there is two karma colums. So when you substract 100 (goodkarma) from 100 (badkarma) you get, well you guessed it, 0.
Quote from: NiXnAx on December 02, 2004, 09:40:55 PM
when you remove good karma from bad karma, you usually get negative karma. (that is supposed when you are nice on the forum), and int (the value of karma, stored in the database cannot be negative) ant that is the reason there is two karma colums. So when you substract 100 (goodkarma) from 100 (badkarma) you get, well you guessed it, 0.
okay, then the question is:
Why will person X on the forum show in the stats page a -30, but on the actual forum have a -3 ? Something here is wrong..
PLUS - The sorting is definitely out of order.
Quote from: NiXnAx on December 02, 2004, 11:53:29 AM
To get the lowest total karma correct, you have to use this query: SELECT karmaGood, karmaBad, realName FROM smf_members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
Ahhh! I never knew you could do that! Thanks, I'll look this over and see if I can get all the problems reported here sorted out so that the mod will show the highest and lower karma totals as well :)
Quote from: ozmafans on December 02, 2004, 09:27:15 PM
Thank you for that tip, I know very little about php/sql.
The problem seems to be that say I had -100 karma points given to me, and 100 positive karma points given to me.
karmaBad (100) - karmaGood (100) = -200, when it should really be 0. Is there an absolute value function?
That's not true. The data stored in the fields 'karmaGood' and 'KarmaBad' are both positive numbers, therefore if you had 100 good karma, and 100 bad karma, the sum would be:
100 - 100, which would equal 0, not -200.
The mistake you're making is thinking that the data stored is 'karmaBad' has a negative sign in it. You're thinking the sum would be:
-100 - 100, which would, as you say, equal -200.
Update: I've updated this mod, it now shows the correct stats depending on what you have chosen for your karma format. Thanks to NiXnAx for supplying the corrrect SQL query to use for showing the karma totals. :)
Quote from: Tau Online on December 03, 2004, 12:34:07 PM
Update: I've updated this mod, it now shows the correct stats depending on what you have chosen for your karma format. Thanks to NiXnAx for supplying the corrrect SQL query to use for showing the karma totals. :)
NP
But you need to add this back to the start of the karma mod of the Stats.template.php
foreach ($context['top_time_online'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : ' ', '</td>
<td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
</tr>';
echo ' </table></td></tr>';
Because you might want to show the most users online stats ;)
Quote from: NiXnAx on December 03, 2004, 01:26:50 PM
Quote from: Tau Online on December 03, 2004, 12:34:07 PM
Update: I've updated this mod, it now shows the correct stats depending on what you have chosen for your karma format. Thanks to NiXnAx for supplying the corrrect SQL query to use for showing the karma totals. :)
NP
But you need to add this back to the start of the karma mod of the Stats.template.php
foreach ($context['top_time_online'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : ' ', '</td>
<td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
</tr>';
echo ' </table></td></tr>';
Because you might want to show the most users online stats ;)
Thanks! That might be a good thing to keep :P
How about making the names clickable as well?
All you need to do is add this
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
to each karma-related array in Stats.php,
and replace all ltkarma[Name], $htkarma[Name], $gkarma[Name] and $bkarma[Name]
with $ltkarma[link], $htkarma[link], $gkarma[link] and $bkarma[link] in Stats.template.php.
Quote from: Burpee on December 04, 2004, 08:13:19 AM
How about making the names clickable as well?
All you need to do is add this
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
to each karma-related array in Stats.php,
and replace all ltkarma[Name], $htkarma[Name], $gkarma[Name] and $bkarma[Name]
with $ltkarma[link], $htkarma[link], $gkarma[link] and $bkarma[link] in Stats.template.php.
Thanks :) I meant to add that, but must have forgot. I've changed my first post to reflect these changes :)
I was wondering whether it would be possible to use this mod to show the table of LLama captures..
since that uses Karma, but... doesnt rely on Karma being enabled ???
*EDIT*
yes just added this code into the stats.template.php and it shows the data without karma being enabled :)
if( $modSettings['karmaMode'] == 0 )
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Total</td>
<td class="catbg" colspan="2">Lowest Karma Total</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';
foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$htkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';
foreach($context['ltkarma'] as $ltkarma)
{
$total = $ltkarma['Good'] - $ltkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$ltkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
}
brilliant mod :)
hello Guys,
Nice mod, I already implemented and it works great...
Now, I ask from some extra stuf... if possible off course: ;)
- below the Karma on the post menu, telling for example: 1st place...or 39th place (based on the total Sum off course)
- On the profile page, the same thing
Is that possible ? or is it difficult ?
I mean, its very good to have that on the stats page off course, but imagine a message board, where you have lots of old timers, with very high karma totals, and a lot of new commers, and they watch +350 or +250... but they dont know if its high or low... so showing also the position of that karma on the total users, would be just perfect.
best regards,
Quote from: vipmoney on January 20, 2005, 10:03:30 PM
hello Guys,
Nice mod, I already implemented and it works great...
Now, I ask from some extra stuf... if possible off course: ;)
- below the Karma on the post menu, telling for example: 1st place...or 39th place (based on the total Sum off course)
- On the profile page, the same thing
Is that possible ? or is it difficult ?
I mean, its very good to have that on the stats page off course, but imagine a message board, where you have lots of old timers, with very high karma totals, and a lot of new commers, and they watch +350 or +250... but they dont know if its high or low... so showing also the position of that karma on the total users, would be just perfect.
best regards,
Your welcome, I'm glad it's working for you :) As for the rank thing, I'm fairly busy right now and so won't be able to make the changes I'm afraid..
Thanks anyway Tau
Thanks for the mod it works really well!
:)
Quote from: redone on January 24, 2005, 02:36:02 PM
Thanks for the mod it works really well!
:)
Your welcome :) I'm glad it's worked.
Flawless Install! Thanks! :)
Thank you for that mod. I installed it too and it works really well.
It would be nice to have thebar graph next to it, like the rest of the page. It would fit in better.
Quote from: NukeWorker.com on April 17, 2005, 03:27:30 PM
It would be nice to have thebar graph next to it, like the rest of the page. It would fit in better.
???
Anybody knows how?
I've got the graph working, and I'll post it once it's perfect.
The <table> stuff should be moved outside of the foreach.
I installed the mod using teh directions from the first post. It works, however top karma guy is -10. How's that? What do I need to do tto fix that. I know nothing about php...
-Xarcell
Is that his actual karma?
thanks. works great.
Neat mod, I'm playing with it now.
We use totals and have renamed them. How do I change the titles "Highest Karma Total" & Lowest Karma Total?
Ignore this, I've found them in the stats.template and changed them to reflect our particular admin applied 'karma' (https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.nokonium.plus.com%2Fblack-cat%2Fdevils%2Fdevil-wink.gif&hash=ac7e4233d6bda381a7bdd563740a6df0482bfa7d)
echo '<tr>
<td class="catbg" colspan="2">Well Bogled</td>
<td class="catbg" colspan="2">Un-Bogled</td>
</tr>
Quote from: nokonium on June 25, 2005, 10:53:47 AM
Neat mod, I'm playing with it now.
We use totals and have renamed them. How do I change the titles "Highest Karma Total" & Lowest Karma Total?
Find:
<td class="catbg" colspan="2">Highest Karma Total</td>
<td class="catbg" colspan="2">Lowest Karma Total</td>
Replace the titles with whatever you wish. Thanks for the feedback on this.
Quote from: eldacar on May 03, 2005, 04:54:42 AM
I've got the graph working, and I'll post it once it's perfect.
The <table> stuff should be moved outside of the foreach.
Can you share the code for the graph please?
Um yeah, but it's not done for the default theme. I've got it working in curveSMF only. i'll post it tomorrow
Search:
foreach ($context['top_time_online'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : ' ', '</td>
<td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
</tr>';
echo '
</table>
</td>
</tr><tr>
<td class="catbg" colspan="4"><b>', $txt['smf_stats_5'], '</b></td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_history.gif" border="0" width="20" height="20" alt="" /></td>
<td class="windowbg2" colspan="4">';
Replace:
foreach ($context['top_time_online'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['time_online'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['time_percent'] . '" height="15" alt="" border="0" />' : ' ', '</td>
<td width="20%" align="right" valign="top" nowrap="nowrap">', $poster['time_online'], '</td>
</tr>';
echo ' </table></td></tr>';
if( $modSettings['karmaMode'] == 1 )
{
echo '<tr>
<td class="catbg" colspan="2">Highest Karma Total</td>
<td class="catbg" colspan="2">Lowest Karma Total</td>
</tr>
<tr>
<td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';
foreach($context['htkarma'] as $htkarma)
{
$total = $htkarma['Good'] - $htkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$htkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
echo'</td><td class="windowbg" colspan="1">
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">';
foreach($context['ltkarma'] as $ltkarma)
{
$total = $ltkarma['Good'] - $ltkarma['Bad'];
echo '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>
<td class="windowbg2" width="80%" align="left">'.
$ltkarma['Link']
.'</td>
<td class="windowbg2" width="20%" align="right">'.$total.'</td>
</tr></table>';
}
}
if( $modSettings['karmaMode'] == 2)
{
echo '<tr>
<td class="catbg" colspan="2" width="50%"><b>Highest Positive Karma</b></td>
<td class="catbg" colspan="2" width="50%"><b>Highest Negative Karma</b></td>
</tr>
<tr>
<td colspan="1" class="windowbg" >
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">
<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr>';
foreach($context['gkarma'] as $gkarma)
{
echo '<td width="60%" valign="top">'.
$gkarma['Link']
.'</td>
<td width="20%" align="left" valign="top">', $gkarma['Karma'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $gkarma['karma_percent'] . '" height="15" alt="" border="0" />' : ' ', '</td>
<td width="20%" align="right">+'.$gkarma['Karma'].'</td>
</tr>';
}
echo'</table></td><td colspan="1" class="windowbg" >
<img src="'. $settings['images_url']. '/stats_posters.gif" width="20" height="20" />
</td>
<td class="windowbg2">
<table border="0" cellpadding="1" cellspacing="0" width="100%">';
foreach($context['bkarma'] as $bkarma)
{
echo '<tr valign="top"><td width="60%" valign="top">'.
$bkarma['Link']
.'</td>
<td width="20%" align="left" valign="top">', $bkarma['Karma'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $bkarma['karma_percent'] . '" height="15" alt="" border="0" />' : ' ', '</td>
<td width="20%" align="right">-'.$bkarma['Karma'].'</td>
</tr>';
}
}
echo'</tr></td><tr><td class="catbg" colspan="4"><b>', $txt['smf_stats_5'], '</b></td>
</tr>
<tr>
<td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_history.gif" border="0" width="20" height="20" alt="" /></td>
<td class="windowbg2" colspan="4">';
Let me know if that doesn't work.
is this for 1.1 beta 3?
AFAIK this works for 1.1 as well as 1.0. :) I'm running it fine on 1.1, and it used to work on 1.0.0 with me and so I presume it still works for the latest versions of 1.1 and 1.0.
My code in stats.php does not look anything like that. This is what I have. What do I need to do to get the bar graph in this code:
foreach ($context['top_time_online'] as $i => $member)
{
$context['top_time_online'][$i]['time_percent'] = round(($member['seconds_online'] * 100) / $max_time_online);
$temp[] = $member['id'];
}
// Cache the ones we found for a bit, just so we don't have to look again.
cache_put_data('stats_total_time_members', $temp, 480);
// Top 10 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 10", __FILE__, __LINE__);
$context['karma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}
// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 10", __FILE__, __LINE__);
$context['bkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}
// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 10", __FILE__, __LINE__);
$context['htkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 10", __FILE__, __LINE__);
$context['ltkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
Thats the source file. You want to edit the theme template file.
I'm fiddling with 1.1.4b and although I get the totals, I don't get the graphs. I pasted the code on page 4 instead of the stats.template code on page 1, was that correct?
My code is for 1.0 and I don't know how it would have changed for 1.1 sorry.
Looking at my code again, I'm not sure what I'm doing. Can you change it to karmamode 2? I don't think I've put bars for mode 1.
I'm setting 1.1.4b up as close as I can to our live board, which has the totals. If it was possible it would have been good to add the graphs.
Thanks
I've added the code for this to RC2 and it only displays two empty boxes. Could you please have a look at is for RC2. :)
Quote from: nokonium on January 02, 2006, 06:55:03 AM
I've added the code for this to RC2 and it only displays two empty boxes. Could you please have a look at is for RC2. :)
Yeah, when I upgraded to rc2, it stoped working.
I'll have a look at it.
Thanks Eldacar
Hi
Some member told me the question to made a version with colored memberlinks. (For user who use this mod (http://mods.simplemachines.org/index.php?mod=111))
So this is the changed part in the stats.php for this (I hope this is the current version) ;D
// Top 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);
$context['karma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}
// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);
$context['bkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}
// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);
$context['htkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
$context['ltkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
Change this too
// Top 5 Karma Rating
$MemberColor_ID_MEMBER = array();
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);
$context['karma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);
$context['bkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);
$context['htkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
$context['ltkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Okay add know the colors :)
if (!empty($MemberColor_ID_MEMBER)) {
//Now i can Load the Missing global :)
global $user_profile;
loadMemberData($MemberColor_ID_MEMBER);
$cmemcolid = NULL;
if(!empty($context['gkarma']))
foreach($context['gkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['gkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['gkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['bkarma']))
foreach($context['bkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['bkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['bkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['htkarma']))
foreach($context['htkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['htkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['htkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['ltkarma']))
foreach($context['ltkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['ltkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['ltkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
}
Bye
DIN1031
ooooh thanx for doing that for me :)
*runs to do now*
I've got an issue now where my negative karma holders are showing up at the top of the Highest Karma Total list. Any ideas?
http://dayton-online.com/index.php?action=stats
This is a great mod, exactly what i've been looking for.Thanks!
Quote from: Killian on January 25, 2006, 02:30:41 PM
I've got an issue now where my negative karma holders are showing up at the top of the Highest Karma Total list. Any ideas?
http://dayton-online.com/index.php?action=stats
i have this too, but it only started when i moved to a new server with php5
anyone know a fix for this?
thanks my friend :)
hello , i need what is mod (top karma total) is showing in the index of my forum ,
help me!! (si alguien sabe español mejor, perdon por mi ingles)
i only wish the member colours worked with it... the code that the guy from the other mod put in here doesn't work and has never worked for me...
Quote from: ディン1031 on January 19, 2006, 10:23:24 AM
Hi
Some member told me the question to made a version with colored memberlinks. (For user who use this mod (http://mods.simplemachines.org/index.php?mod=111))
So this is the changed part in the stats.php for this (I hope this is the current version) ;D
// Top 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);
$context['karma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}
// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);
$context['bkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}
// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);
$context['htkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
$context['ltkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
Change this too
// Top 5 Karma Rating
$MemberColor_ID_MEMBER = array();
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);
$context['karma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);
$context['bkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);
$context['htkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
$context['ltkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Okay add know the colors :)
if (!empty($MemberColor_ID_MEMBER)) {
//Now i can Load the Missing global :)
global $user_profile;
loadMemberData($MemberColor_ID_MEMBER);
$cmemcolid = NULL;
if(!empty($context['gkarma']))
foreach($context['gkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['gkarma']['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['gkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['bkarma']))
foreach($context['bkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['bkarma']['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['bkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['htkarma']))
foreach($context['htkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['htkarma']['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['htkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['ltkarma']))
foreach($context['ltkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['ltkarma']['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['ltkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
}
Bye
DIN1031
really wants this code to work but it just doesn't work and doesn't show any colours...
P.s - has anyone actually managed to get the bar graphs displaying for this karma yet in RC2?
Quote from: mrselnombre on March 14, 2006, 10:29:37 AM
Quote from: Killian on January 25, 2006, 02:30:41 PM
I've got an issue now where my negative karma holders are showing up at the top of the Highest Karma Total list. Any ideas?
http://dayton-online.com/index.php?action=stats
i have this too, but it only started when i moved to a new server with php5
same here my negative karma holders are showing up at the top of the Highest Karma Total list
can i get some help on this please?
Quote from: ディン1031 on January 19, 2006, 10:23:24 AM
Hi
Some member told me the question to made a version with colored memberlinks. (For user who use this mod (http://mods.simplemachines.org/index.php?mod=111))
So this is the changed part in the stats.php for this (I hope this is the current version) ;D
// Top 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);
$context['karma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
}
// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);
$context['bkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
}
// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);
$context['htkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
$context['ltkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
}
Change this too
// Top 5 Karma Rating
$MemberColor_ID_MEMBER = array();
$karma_results = db_query("
SELECT realName, karmaGood, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaGood DESC LIMIT 5", __FILE__, __LINE__);
$context['karma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['gkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Karma' => $row_karma['karmaGood'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>'
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Bottom 5 Karma Rating
$karma_results = db_query("
SELECT realName, karmaBad, ID_MEMBER FROM {$db_prefix}members ORDER BY karmaBad DESC LIMIT 5", __FILE__, __LINE__);
$context['bkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['bkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Karma' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Highest Total Karma
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);
$context['htkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['htkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Lowest karma total
$karma_results = db_query("
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY (karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
$context['ltkarma'] = array();
while( $row_karma = mysql_fetch_assoc($karma_results) )
{
$context['ltkarma'][] = array(
'id' => $row_karma['ID_MEMBER'],
'Link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_karma['ID_MEMBER'] . '">' . $row_karma['realName'] . '</a>',
'Good' => $row_karma['karmaGood'],
'Bad' => $row_karma['karmaBad']
);
$MemberColor_ID_MEMBER[$row_karma['ID_MEMBER']] = $row_karma['ID_MEMBER'];
}
// Okay add know the colors :)
if (!empty($MemberColor_ID_MEMBER)) {
//Now i can Load the Missing global :)
global $user_profile;
loadMemberData($MemberColor_ID_MEMBER);
$cmemcolid = NULL;
if(!empty($context['gkarma']))
foreach($context['gkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['gkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['gkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['bkarma']))
foreach($context['bkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['bkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['bkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['htkarma']))
foreach($context['htkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['htkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['htkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
if(!empty($context['ltkarma']))
foreach($context['ltkarma'] as $kkey => $kvalue) {
$cmemcolid = $context['ltkarma'][$kkey]['id'];
$profile = &$user_profile[$cmemcolid];
if(!empty($profile['member_group_color']) || !empty($profile['post_group_color']))
$context['ltkarma'][$kkey]['Link'] = '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '"><font color="'.(!empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color']).'">' . $profile['realName'] . '</font></a>';
}
}
Bye
DIN1031
It's correct know... never thought that i forgot this *runs* (never tested it :P).
*runs*
Bye
DIN1031
thanks for that din :)
Just so I'm clear...
Does the code at the top of this topic work for 1.1RC2 yet?
Thanks,
yep sure does :)
Thanks, Proph...all add it today and report if I have any issues.
Just to let you all know, I had to use:
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);
for highest total and:
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
for lowest...
MySQL version perhaps?
OK. It works perfectly for me. I was curious how I could just get the top 5 or the bottom 5 alone, and not have them in the stats list. I am using Lunabyte Enigma 2.0, and I want to put the top 5 or bottom 5 in a box. So basically, I just need the php to ask for either set of information in a simple mode. But its way over my head to do it. I suppose I could keep tinkering and I'll get it, but I figured I'd ask first.
this work on 1.1 ?
thanks ;)
Yes,
But just to let you know, if you use my code, it doesn't seem to work on MySQL 5. I guess FLOOR works differently in 5 or has been depracated...not sure and definitely over my head.
Good luck!
Quote from: ssoltz on July 25, 2006, 05:34:48 PM
Just to let you all know, I had to use:
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);
for highest total and:
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
for lowest...
Thank you. With this fix it works even with SMF 1.1.2
Quote from: ssoltz on July 25, 2006, 05:34:48 PM
Just to let you all know, I had to use:
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) DESC LIMIT 5", __FILE__, __LINE__);
for highest total and:
SELECT karmaGood, karmaBad, realName, ID_MEMBER FROM {$db_prefix}members ORDER BY FLOOR(karmaGood-karmaBad) ASC LIMIT 5", __FILE__, __LINE__);
for lowest...
MySQL version perhaps?
Ah, good point. Thanks for that fix, first post updated :)
Hi,
this is great mod and works on my smf 1.1.3 forum :D
But I whant to make it show on the top of my board on index page of my forum, but i can't make it work.
Can somebody help me ?
My SMF version is 1.1.3, and MySQL is at 5.0.27-standard. For the most part, it works great...until someone goes into Negative Karma.
Right now, there's one person at my board with a negative karma, and he's listed at the top of the "Highest Karma" list. Shouldn't he be at the bottom of the "Lowest Karma" list??
In the hopes that I mistyped something, I re-edited the files, and the results are the same. Any idea on how to correct this?
Thanks!
Because MySQL have a bug there on some Versions. You need to use trick for this that it work.
Replace the FLOOR(karmaGood-karmaBad) with FLOOR(1000000+karmaGood-karmaBad) than it should work correct ;). I used this in my SSI Karma mod that it work correct. Why 1000000 because the maximum Karma is 999999 more is not allowed in the table so it would never go under 0 ;).
Bye
DIN1031
Thanks, DIN! That worked perfectly! ;D
Kudos to you!! :)
possible to show those stats in the board index? at the bottom
it should be, but tbh i have no idea what to put where. You'd have to modify the Sources/BoardIndex.php and the Boardindex.template.php
nah... i added the highest karma SSI mod and used that...
that works :)
does this work on smf 2.0 rc2 or is there an alternative hack/mod for something like this?
Thanks :)
anything like this for smf 2.0 rc2/3?