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.
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.
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
Sorry. Somehow I used spaces instead of underlines. It should be
$number_to_list = 9
and
if ($list_number > $number_to_list)
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.
QuoteAny reason you don't just let the query count and sort and limit?
Because I didn't think of it? ;D
Oh. OK. As long as there was a good reason for it. ;)
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;
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'));
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.
So if i change it to
$starttime = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
then what ever the server time is at then it uses that time?
It will mean starting time is start of calendar day AT the server (hour 0, minute 0, sec 0 of current server date; all these are according to the server the script is on).
how would i know what date my server is on? is it the thing that in the Features and Options>Overall time offset?
How to put this...
The date should be current (within a couple of hours). The time YOU see when logged on is your offset (in your profile) plue the Overall time offset. If you display time to guests, that will reflect the Overall time offset only.
[NOTE: Are you SURE you don't want a running 24 hour count? ;) ]
yeah i switched it back, thought it would be easier.
Can you make me a Gallery php block,
1.Stats
Total Pictures:
Total Views:
Total Gallery Filesize:
Total Comments:
2.
Most Viewed Image
[Image Thumbnail]
Most Recent Picture
[Image Thumbnail]
heres the mod im using:http://mods.simplemachines.org/index.php?mod=473 (http://mods.simplemachines.org/index.php?mod=473)
I'll have to take a pass on that. Don't like trying to code blind and I don't use that mod.
oh ok, thanks for everything to!
How do I exclude admin from showing?
what kind of block is this suitbale for pls...php........ script
Its a PHP block.
Regards,
Wilsy.
How do I exclude admin?
I'm assuming you're using J. A. Cortina's code.
Change
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__);
to
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, {$db_prefix}members AS mem)
WHERE m.posterTime > " . $starttime . "
AND mem.ID_GROUP != 1
AND t.ID_TOPIC = m.ID_TOPIC
AND m.ID_MEMBER = mem.ID_MEMBER
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__);
I think. :-) I haven't tested this, but it should work.
It's perfect :D thank you!
I'm pasting the code in a PHP block but I get an error, could somebody give me the whole correct code to paste in a PHP block...... :-\
How about you read the topic from the start.
JP Denis clearly said her change was from JA Cortina code earlier in the topic.
Clipper, what code did you paste into a php block? What is the error?
could this be changed to show all users logged on during the last 24 hrs (or ever) rather than users that posted together with the time they are logged on (like what the admin can see in the members list via the admin panel)?
This shows those logged in during the past 24 hours, in order by the most recent log in.
global $db_prefix, $scripturl;
$starttime = time() - (24 * 60 * 60);
$query = db_query(
"SELECT memberName, lastLogin
FROM {$db_prefix}members
WHERE lastLogin > $starttime
ORDER BY lastLogin DESC", __FILE__, __LINE__);
echo "<table>";
while ($row = mysql_fetch_assoc($query))
{
echo "<tr><td>";
echo $row['memberName'];
echo "</td><td>";
echo timeformat($row['lastLogin']);
echo "</td></tr>";
}
echo "</table>";
cheers, have added the post count to it, just in case anyone is interested
global $db_prefix, $scripturl;
$starttime = time() - (30 * 7 * 24 * 60 * 60);
$query = db_query(
"SELECT memberName, lastLogin, posts
FROM {$db_prefix}members
WHERE lastLogin > $starttime
ORDER BY lastLogin DESC", __FILE__, __LINE__);
echo "<table>";
while ($row = mysql_fetch_assoc($query))
{
echo "<tr><td>";
echo $row['memberName'];
echo "</td><td>";
echo " | last logged on: ";
echo "</td><td>";
echo timeformat($row['lastLogin']);
echo "</td><td>";
echo " | posts: ";
echo "</td><td>";
echo $row['posts'];
echo "</td></tr>";
}
echo "</table>";
Quote from: warhonowicz on February 13, 2008, 08:04:40 PM
cheers, have added the post count to it, just in case anyone is interested
Could this block be made to scroll?
Regards,
Wilsy.
global $db_prefix, $scripturl;
$starttime = time() - (30 * 7 * 24 * 60 * 60);
$query = db_query(
"SELECT memberName, lastLogin, posts
FROM {$db_prefix}members
WHERE lastLogin > $starttime
ORDER BY lastLogin DESC", __FILE__, __LINE__);
echo "<table>";
while ($row = mysql_fetch_assoc($query))
{
echo "<tr><td>";
echo $row['memberName'];
echo "</td><td>";
echo " | last logged on: ";
echo "</td><td>";
echo timeformat($row['lastLogin']);
echo "</td><td>";
echo " | posts: ";
echo "</td><td>";
echo $row['posts'];
echo "</td></tr>";
}
echo "</table>";
Quote from: JPDeni on October 06, 2006, 02:29:32 PM
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.
hello Im tryin to learn all this stuff and Im totally confused what the right code to add to block would be by all the well I forgot this and if you do that lol can you please post the code exactly the way it should be so I can just add it till i learn all this scripting alittle bit better.
Thanks a bunch and happy easter !
I'm not sure I understand what you're trying to say. I had to insert my own punctuation. :)
But, from the look of the code you posted, it is complete. Have you tried it?
This is a nice block. But it displays the usernames of members - not the chosen 'Display Name'.
I'm hopeful its an easy change... but I am not up to the task today...
Change
"SELECT posterName,
to
"SELECT realName,
Thank you.
edit:
For completeness, the entire code for the block using Display Names:
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 realName, {$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['realName']]))
$count[$row['realName']] = 0;
++$count[$row['realName']];
$poster_number[$row['realName']] = $row['ID_MEMBER'];
}
arsort($count);
$list_number = 0;
foreach ($count as $key => $value)
{
echo '<span class="smalltext"><a href="' . $scripturl . '?action=profile;u=' . $poster_number[$key] . '">' . $key . '</a> ' . $value . '</span><br />';
++$list_number;
if ($list_number > $number_to_list)
break;
}
Quote from: wyvern on March 26, 2008, 03:32:11 PM
Thank you.
edit:
For completeness, the entire code for the block using Display Names:
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 realName, {$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['realName']]))
$count[$row['realName']] = 0;
++$count[$row['realName']];
$poster_number[$row['realName']] = $row['ID_MEMBER'];
}
arsort($count);
$list_number = 0;
foreach ($count as $key => $value)
{
echo '<span class="smalltext"><a href="' . $scripturl . '?action=profile;u=' . $poster_number[$key] . '">' . $key . '</a> ' . $value . '</span><br />';
++$list_number;
if ($list_number > $number_to_list)
break;
}
Thanks for displaying the total code!
This is a awesome block thanks guys!!!