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: 0
  • Guests: 249
  • Total: 249

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.

confuzed

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

IchBin

It uses the time you set at the beginning of the script. If you read the comments you will see.

insanemustang

What if you wanted to take this and say, "Top posters for today..."

texasflats

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.

insanemustang

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.

IchBin

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.

insanemustang

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.

jdvarner

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

insanemustang

I don't want it to stop or start, i just want it to display the top posters - minus the administrators and moderators.

jdvarner

oops. got you confused with the contest time frame request. :)

This website is proudly hosted on Crocweb Cloud Website Hosting.