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

Recent

Welcome to TinyPortal. Please login or sign up.

April 18, 2024, 03:34:21 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,164
  • Total Topics: 21,219
  • Online today: 190
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 131
  • Total: 131

Active Posters

Started by MeRcChRiS, October 06, 2006, 04:09:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MeRcChRiS

ok i need a TP Block that will show who has posted in a 24hr format.
The posts are going to be how much they posted in that day.

Name | Posts

[name] | [posts]
[name] | [posts]
[name] | [posts]
[name] | [posts]

etc... from the person with the most posts to the person with the least posts of that day, and a way for me to change how many people to show.

JPDeni

#1
With any luck, this should work. This is a slight alteration of the "Top Posters" block, but I changed the start and stop times.
global $db_prefix, $scripturl;

$starttime = time() - (24 * 60 * 60);
$endtime = time(); 
$number_to_list = 9; // (one less than you want to list)

$count= array();
$poster_number = array();
$query = db_query(
    "SELECT posterName, {$db_prefix}messages.ID_MEMBER, ID_GROUP
     FROM {$db_prefix}members
     JOIN {$db_prefix}messages
     ON {$db_prefix}members.ID_MEMBER = {$db_prefix}messages.ID_MEMBER
     WHERE posterTime > $starttime
     AND posterTime < $endtime", __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($query))
{
  if (!isset($count[$row['posterName']]))
    $count[$row['posterName']] = 0;
  ++$count[$row['posterName']];
    $poster_number[$row['posterName']] = $row['ID_MEMBER'];
}

arsort($count);
$list_number = 0;
foreach ($count as $key => $value)
{
  echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $poster_number[$key] . '">' . $key . '</a> | ' . $value . '<br />';
  ++$list_number;
  if ($list_number > $number_to_list) 
    break;
}


I think the problem last night was that I was putting in too many quotes. We'll see if this works.

MeRcChRiS

mm no, i get this error,

   
Parse error: syntax error, unexpected T_STRING in /home/sector/public_html/carnage/oforums/Sources/Load.php(1613) : eval()'d code(34) : eval()'d code on line 5

im going to be at school so ill be back later, but keep working and good luck ;D

JPDeni

#3
Sorry. Somehow I used spaces instead of underlines. It should be

$number_to_list = 9
and
if ($list_number > $number_to_list)

jacortina

#4
Any reason you don't just let the query count and sort and limit?

global $db_prefix, $scripturl, $memberContext, $txt, $modSettings;

$starttime = strtotime('24 hours ago');
$list_count = 10;

$poster = array();

$request = db_query("
SELECTÃ,  m.ID_MEMBER, COUNT(m.ID_MEMBER) as postCount
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE m.posterTime > " . $starttime . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
GROUP BY m.ID_MEMBER
ORDER BY postCount DESC LIMIT " . $list_count, __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($request))
{
Ã,  Ã,  loadMemberData(array($row['ID_MEMBER']));
Ã,  Ã,  loadMemberContext($row['ID_MEMBER']);
$poster[$row['ID_MEMBER']] = array (
Ã,  'id' => $row['ID_MEMBER'],
Ã,  'count' => $row['postCount'],
Ã,  'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $memberContext[$row['ID_MEMBER']]['name'] . '">' . '<font color="' . $memberContext[$row['ID_MEMBER']]['group_color'] . '">' . $memberContext[$row['ID_MEMBER']]['name'] . '</font>' . '</a>' );
}
mysql_free_result($request);

echo '<table width=100%>';
foreach($poster as $top_user)
{
echo '<tr>
Ã,  Ã,  Ã,  <td align="right" width=75%>' . $top_user['link'] . '</td>
Ã,  Ã,  Ã,  <td align="left">| '. $top_user['count'] . '</td>
Ã,  Ã,  Ã,  </tr>';
}
echo '</table>';


This code should ignore recycle bin entries (but doesn't seem to right now) and includes membergroup colors.

Edit: OK, now it excludes recycle been correctly. Forgoet to global $modSettings.

JPDeni

QuoteAny reason you don't just let the query count and sort and limit?
Because I didn't think of it?  ;D


jacortina

Oh. OK. As long as there was a good reason for it.  ;)

MeRcChRiS

 i tried both codes, and the 2nd one is cool, but how do i center it?


Also on both codes it shows posts i did from yesterday and not just today, how do i change that?

Quote$number_to_list = 9

needs to be

Quote$number_to_list = 9;

jacortina

I gave the names 75% of the width as they'll generally be longer than the number of digits in a daily post count. But, you can change that in the line:

<td align="right" width=75%>' . $top_user['link'] . '</td>


And, sorry, interpreted day to mean last 24 hours (which would be a 'rolling', top poster).

Be aware that 'since midnight' will be 'since midnight according to server time'. Change:

$starttime = strtotime('24 hours ago');
to
$starttime = mktime(0, 0, 0, date('m'), date('d'), date('Y'));

JPDeni

Quote$number_to_list = 9

needs to be

$number_to_list = 9;
Right. I didn't put the whole line in. I did, however, fix the line in the original code.