TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 210
  • Total: 211
  • @rjen

Top posters

Started by JPDeni, September 20, 2006, 01:27:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TexasBartender

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

Thief

#51
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.

Zetan

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)

jdvarner

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

Thief

Zetan, thanks for such a positive feedback, my pleasure reading it. cheers!

jdvarner, thanks for info, should be fixed now. please check.

Zetan

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.

Thief

#56
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.

Zetan

 :) That seems to have fixed it now. No errors.

jdvarner

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.

Thief

what errors are you having, jdvarner? the same?

This website is proudly hosted on Crocweb Cloud Website Hosting.