Showing Highest and Lowest Karma Rating in Stats Page

Started by Tristan Perry, October 24, 2004, 05:05:33 AM

Previous topic - Next topic

Spork

This is a great mod, exactly what i've been looking for.Thanks!

mrselnombre

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
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
Total Twaddle.

londonhogfan


CeZa


marciano

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)

LostProphecy

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...
Angelus Ex Quo Nox

LostProphecy

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)

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?
Angelus Ex Quo Nox

steve51184

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?

ディン1031

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)

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
Support only via MOD Thread! NO PM Support!
My Forum: ayu][kult Forum
My Mods: My Small Mod Collection
My Parser: DIN1031's ModParser
Current Info: More away the next days, because i've to much work to do :x

LostProphecy

Angelus Ex Quo Nox

ssoltz

Just so I'm clear...

Does the code at the top of this topic work for 1.1RC2 yet?

Thanks,
Steve Soltz
SSK Creatives, Inc.

LostProphecy

Angelus Ex Quo Nox

ssoltz

Thanks, Proph...all add it today and report if I have any issues.
Steve Soltz
SSK Creatives, Inc.

ssoltz

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?
Steve Soltz
SSK Creatives, Inc.

The Fat Boy

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.

vipmoney

VipMoney

ssoltz

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!
Steve Soltz
SSK Creatives, Inc.

Zenigata

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

Tristan Perry

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 :)

JohnyNS

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  ?

Advertisement: