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

Recent

Welcome to TinyPortal. Please login or sign up.

May 19, 2024, 11:51:18 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 128
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 59
  • Total: 59

Top Stats - 3 in 1 Block

Started by akulion, November 04, 2006, 03:53:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

akulion

 :2funny: 3 in 1  :2funny:

man I sound like a salesman!!

Anyways here is a "combinitation" of some excellent codes by JPdeni

Demo
Just browse down until u see it  :coolsmiley:

Put this in a center block and activate

global $db_prefix, $memberContext;

$count = 2;
$users = array();

$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($request)) {
$users[] = intval($row['ID_MEMBER']);
}

loadMemberData($users);
echo'<table border="1" width="100%" id="table1" cellpadding="2" style="border-collapse: collapse">
<tr><td  bgcolor="#FF9900" width="150"><font color="#FFFFFF" face="Verdana" size="2"><b>Newest Members</b></font></td><td bgcolor="#660066" width="200"><font color="#FFFFFF" face="Verdana" size="2"><b>Top 10 Posters</b></font></td><td  bgcolor="#336699"><font color="#FFFFFF" face="Verdana" size="2"><b>This Weeks Top Posters</b></font></td></tr><tr>
<td>';
$i = 0;
foreach($users as $user_id) {
if ($i > 0) echo '<hr>';
$i++;

loadMemberContext($user_id);

if (!empty($memberContext[$user_id]['avatar']['image']))
echo '<div align="center">'.$memberContext[$user_id]['avatar']['image'].'<BR>'.$memberContext[$user_id]['link'].'</div>';
else
echo '<div align="center"><img src="http://path-to-peace.net/forum/noava2.gif" height=80 widh=80><BR><BR>'.$memberContext[$user_id]['link'].'</div>';
}

$numberofposters = 10; // You can change this to however many you want

require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");
echo'</td><td>';
foreach ($top_posters as $poster)
{
  echo $poster['link'] , ' (', $poster['posts'] , ')<br />';
}
echo'</td><td>';

global $db_prefix;
$count= array();

$query = db_query(
    "SELECT posterName
     FROM {$db_prefix}messages
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);

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

$random = array_rand($count, count($count));
echo '<div style="text-align: center">';
foreach ($random as $value)
{
  $fsize = $count[$value] + 7;
  $name = str_replace(" ",'Ã,·',$value);
  echo '<span style="font-size:' . $fsize . 'pt;">' . $name . '</span> ';
}
echo '</div></td></tr>
</table>';


PS: this code is supplied as is and is without any warranty - if using it makes your forum explode then there is no liability claim on aku or jpdeni


akulion

Configuration:

u can change $count = 2;
to whatever u want to display more newest members

Change this to ur own url :P
http://path-to-peace.net/forum/noava2.gif
u can use the image, found it on an avatars site :up:

You can change this
$numberofposters = 10; // You can change this to however many you want
To display more top posters

this whole part is customizable - its plain HTML so figure it out

<table border="1" width="100%" id="table1" cellpadding="2" style="border-collapse: collapse">
<tr><td  bgcolor="#FF9900" width="150"><font color="#FFFFFF" face="Verdana" size="2"><b>Newest Members</b></font></td><td bgcolor="#660066" width="200"><font color="#FFFFFF" face="Verdana" size="2"><b>Top 10 Posters</b></font></td><td  bgcolor="#336699"><font color="#FFFFFF" face="Verdana" size="2"><b>This Weeks Top Posters</b></font></td></tr><tr>
<td  width="150">

Thats it enjoy

knat

#2
Is there any way to make it not include admin ??

I have like almost 400 post and the one below me has 11  ;D

Edit: Is there anyway to make a 4th row and put this code in there ??

global $db_prefix,$modSettings;

$today = strtotime("24 hours ago");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');

$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);

settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");

echo 'Medlemmer: ', $modSettings['totalMembers'],'<br/>';
echo 'Denne mÃÆ'Ã,Â¥ned: ', $row['month'],'<br/>';
echo 'Denne uge: ', $row['week'],'<br/>';
echo 'Sidste 24 timer: ', $row['today'];


Please help me Aku, my coding skills are not very good  :) You can take a look here and see that it looks a little messy because i dont use sidebars on the oage that i want to use you center block !

akulion

#3
yes its very simple :D

just delete the admin account and VIOLA!

:2funny:

lol just kiddin - as stated its jp's codes

so this might help
http://www.tinyportal.net/smf/index.php?topic=8762.msg71821#msg71821

also look out for them around - they can make code faster than i can make chocolate chip milkshakes!

knat

Sorry Aku but that didnt help me at all   ::)

Is there something i can simply put in to you code so it just dont show the admin in the top poster list.. and in the poster cloud ??

JPDeni

To eliminate admins from the list, change

SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);

to

SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 AND ID_GROUP <> 1 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);


and in the poster cloud area, change


$query = db_query(
    "SELECT posterName
     FROM {$db_prefix}messages
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);

to

$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 ID_GROUP <> 1 AND ID_GROUP <> 2
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);


As for adding the other code --

Merge the two "global" lines -- so that the first line looks like

global $db_prefix, $memberContext, $modSettings;


and, at the end, change


echo '</div></td>
</table>';


to


echo '</div></td><td>';
$today = strtotime("24 hours ago");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');

$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);

settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");

echo 'Medlemmer: ', $modSettings['totalMembers'],'<br/>';
echo 'Denne mÃÆ'Ã,Â¥ned: ', $row['month'],'<br/>';
echo 'Denne uge: ', $row['week'],'<br/>';
echo 'Sidste 24 timer: ', $row['today'];

echo '</td></tr></table>';



Oh, and Aku, you need to close your table row. ;)

knat

Thanks alot .. its very nice of you to help me out this way.. it worked almost like a charm..

only issue is that it didnt remove admin from the Top posters ??

The other things worked fine..

here is my code.. maybe you can see why it still shows my name as the number one top poster

global $db_prefix, $memberContext, $modSettings;



$count = 1;
$users = array();

$request = db_query("
SELECT ID_MEMBER FROM {$db_prefix}members WHERE is_activated = 1 AND ID_GROUP <> 1 AND ID_GROUP <> 2 ORDER BY ID_MEMBER DESC LIMIT ".$count, __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($request)) {
$users[] = intval($row['ID_MEMBER']);
}

loadMemberData($users);
echo'<table border="1" width="100%" id="table1" cellpadding="5" style="border-collapse: collapse">
<tr><td  bgcolor="#FFFFFF" width="10"><font color="#000000" face="Verdana" size="2"><b>Nyeste:</b></font></td><td bgcolor="#FFFFFF" width="150"><font color="#000000" face="Verdana" size="2"><b>Top 6 Aktive</b></font></td><td  bgcolor="#FFFFFF"><font color="#000000" face="Verdana" size="2"><b>Denne uges mest aktive medlemmer:</b></font></td><td  bgcolor="#FFFFFF" width="10"><font color="#000000" face="Verdana" size="2"><b>Statistik:</b></font></td></tr><tr>

<td  width="90">';
$i = 0;
foreach($users as $user_id) {
if ($i > 0) echo '<hr>';
$i++;

loadMemberContext($user_id);

if (!empty($memberContext[$user_id]['avatar']['image']))
echo '<div align="center">'.$memberContext[$user_id]['avatar']['image'].'<BR>'.$memberContext[$user_id]['link'].'</div>';
else
echo '<div align="center"><img src="http://path-to-peace.net/forum/noava2.gif" height=80 widh=80><BR>'.$memberContext[$user_id]['link'].'</div>';
}

$numberofposters = 6; // You can change this to however many you want

require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");
echo'</td><td  width="150" align="middle">';
foreach ($top_posters as $poster)
{
  echo $poster['link'] , ' (', $poster['posts'] , ')<br />';
}
echo'</td><td>';

global $db_prefix;
$count= 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 ID_GROUP <> 1 AND ID_GROUP <> 2
     ORDER BY posterTime DESC
     LIMIT 100", __FILE__, __LINE__);


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

$random = array_rand($count, count($count));
echo '<div style="text-align: center">';
foreach ($random as $value)
{
  $fsize = $count[$value] + 6;
  $name = str_replace(" ",'ÂÃ,·',$value);
  echo '<span style="font-size:' . $fsize . 'pt;">' . $name . '</span> ';
}
echo '</div></td><td width="150">';
$today = strtotime("24 hours ago");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');

$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);

settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");

echo 'Medlemmer: ', $modSettings['totalMembers'],'<br/>';
echo 'Denne mÃÆ'Ã,Â¥ned: ', $row['month'],'<br/>';
echo 'Denne uge: ', $row['week'],'<br/>';
echo 'Sidste 24 timer: ', $row['today'];

echo '</td></tr></table>';

JPDeni

I see. It's the middle one that's the top posters. I thought it was the first one. If you have new admins or global moderators, they won't be listed as new members. :)

The top posters comes from an SSI function, but we can copy it here to do some editing of it. (I get nervous when I edit the SSI.php file directly.)

Change
$numberofposters = 6; // You can change this to however many you want

require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");
echo'</td><td  width="150" align="middle">';
foreach ($top_posters as $poster)
{
  echo $poster['link'] , ' (', $poster['posts'] , ')<br />';
}
echo'</td><td>';


to


$numberofposters = 6; // You can change this to however many you want

$request = db_query("
SELECT ID_MEMBER, realName, posts
FROM {$db_prefix}members
                          WHERE ID_GROUP <> 1
                          AND ID_GROUP <> 2
ORDER BY posts DESC
LIMIT $numberofposters", __FILE__, __LINE__);
$top_posters= array();
while ($row = mysql_fetch_assoc($request))
$top_posters[] = array(
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>',
'posts' => $row['posts']
);
mysql_free_result($request);


echo'</td><td  width="150" align="middle">';
foreach ($top_posters as $poster)
{
  echo $poster['link'] , ' (', $poster['posts'] , ')<br />';
}
echo'</td><td>';

knat

Perfect ! Thanks a million  ;) If i could give you karma i would.. really thank a lot !  ;)

JPDeni

A million? No. Half a million will do. ;)

I'm just glad to help. We're all in this together.