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

Recent

Welcome to TinyPortal. Please login or sign up.

June 16, 2024, 12:46:33 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,242
  • Total Topics: 21,223
  • Online today: 180
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 140
  • Total: 140

[Block] Additional Stats

Started by Lord Anubis, March 31, 2008, 05:44:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lord Anubis

Info:

Creates a Stats Block with much more information

Screenshot:

OLD
NEW

This code will add New Members from

  • This Month
  • This Week
  • Today
to the Members section of the stats block

In a PHP block add this code

global $context, $settings, $options, $scripturl, $txt, $user_info, $modSettings;

    $bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet3 = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet4 = '<img src="'.$settings['images_url'].'/tpgoto.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet5 = '<img src="'.$settings['images_url'].'/tpmodule2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

echo'
<div class="smalltext" style="font-family: verdana, arial, sans-serif;">';

       if(isset($context['TPortal']['userbox']['stats']))
   // members stats
            echo '
                 <img src="'.$settings['images_url'].'/icons/members.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=mlist"><b>'.$txt[19].'</b></a>
                 <br />'.$bullet.$txt[488].': ' , isset($modSettings['memberCount']) ? $modSettings['memberCount'] : $modSettings['totalMembers'] , '
                 <br />'.$bullet.$txt['tp-latest']. ': <a href="', $scripturl, '?action=profile;u=', $modSettings['latestMember'], '"><b>', $modSettings['latestRealName'], '</b></a>';
       if(isset($context['TPortal']['userbox']['stats_all']))

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 '<br />',$bullet,'New This Month: ', $row['month'],'<br />';
echo $bullet,'New This Week: ', $row['week'],'<br />';
echo $bullet,'New Today: ', $row['today'];

   // more stats
            echo '
                  <hr /><img src="'.$settings['images_url'].'/icons/info.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=stats"><b>'.$txt['tp-stats'].'</b></a>
                 <br />'.$bullet.$txt[489].': '.$modSettings['totalMessages']. '
  <br />'.$bullet. $txt[490].': '.$modSettings['totalTopics']. '
  <br />'.$bullet.$txt['tp-mostonline-today'].': '.$modSettings['mostOnlineToday'].'
  <br />'.$bullet.$txt['tp-mostonline'].': '.$modSettings['mostOnline'].'<br />
  ('.timeformat($modSettings['mostDate']).')
  ';

       if(isset($context['TPortal']['userbox']['online'])){
   // add online users
            echo '<hr /><img src="'.$settings['images_url'].'/icons/online.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=who"><b>'.$txt[158].'</b></a><br />';

            $online = ssi_whosOnline('array');
   echo $bullet.$txt['tp-users'].': '.$online['num_users'];
   echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
   echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />
<div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';

      foreach($online['users'] as $user){
echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
   }
echo '</div>';
         }
echo '</div>

</div>';


Flash Chat users and E-Arcade users can use this one
Must have Flash Chat Integration Mod installed and E-Arcade

Screenshot:


Upload chat.png and arcade.png to the root of your forum and use a PHP BLOCK



global $context, $settings, $options, $scripturl, $txt, $user_info, $modSettings;

    $bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet3 = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet4 = '<img src="'.$settings['images_url'].'/tpgoto.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet5 = '<img src="'.$settings['images_url'].'/tpmodule2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
echo'

<div class="smalltext" style="font-family: verdana, arial, sans-serif;">';

       if(isset($context['TPortal']['userbox']['stats']))
   // members stats
            echo '
                 <img src="'.$settings['images_url'].'/icons/members.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=mlist"><b>'.$txt[19].'</b></a>
                 <br />'.$bullet.$txt[488].': ' , isset($modSettings['memberCount']) ? $modSettings['memberCount'] : $modSettings['totalMembers'] , '
                 <br />'.$bullet.$txt['tp-latest']. ': <a href="', $scripturl, '?action=profile;u=', $modSettings['latestMember'], '"><b>', $modSettings['latestRealName'], '</b></a>';
       if(isset($context['TPortal']['userbox']['stats_all']))

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 '<br />',$bullet,'New This Month: ', $row['month'],'<br />';
echo $bullet,'New This Week: ', $row['week'],'<br />';
echo $bullet,'New Today: ', $row['today'];

   // more stats
            echo '
                  <hr /><img src="'.$settings['images_url'].'/icons/info.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=stats"><b>'.$txt['tp-stats'].'</b></a>
                 <br />'.$bullet.$txt[489].': '.$modSettings['totalMessages']. '
  <br />'.$bullet. $txt[490].': '.$modSettings['totalTopics']. '
  <br />'.$bullet.$txt['tp-mostonline-today'].': '.$modSettings['mostOnlineToday'].'
  <br />'.$bullet.$txt['tp-mostonline'].': '.$modSettings['mostOnline'].'<br />
  ('.timeformat($modSettings['mostDate']).')
  ';

       if(isset($context['TPortal']['userbox']['online'])){
   // add online users
            echo '<hr /><img src="'.$settings['images_url'].'/icons/online.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=who"><b>'.$txt[158].'</b></a><br />';

            $online = ssi_whosOnline('array');
   echo $bullet.$txt['tp-users'].': '.$online['num_users'];
   echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
  // --- Begin FlashChat Integration ---
   echo '<br />', $bullet, 'In Chat: ', $online['num_chat'];
   // --- End FlashChat Integration ---
   echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />
<div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';

      foreach($online['users'] as $user){
echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
   }
echo '</div>';
      // --- Begin FlashChat Integration ---
echo '
<hr />
<img src="/chat.gif"><a href="'.$scripturl.'?action=chat"><b> Users in Chat</b></a><br />
<div style="width: 100%; ', ($online['num_chat'] > 14 ? 'height: 23ex;overflow: auto;' : ''), '">';
foreach ($online['users_chat'] as $user)
{
echo '
', $bullet2, $user['link'], ' (', (!$user['chat']['room']['public'] ? $txt['fc_private_room'] : $user['chat']['room']['name']), ')
<br />';
}
//   No chat users?
if(empty($online['users_chat']))
   echo '<br />No members in chat';
echo '
</div>';
   // --- End FlashChat Integration ---
         }
echo '</div>';
// add arcade users
echo '<div class="smalltext" style="font-family: verdana, arial, sans-serif;">

           
<hr />
<img src="/arcade.png"><a href="'.$scripturl.'?action=arcade"><b> Users in Arcade</b></a><br />';

 
//added code
  echo' <div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';
//   Its ok now bullits have flown by stand up again lol
$online = ssi_whosOnline('array');
$arcade_users = array();
foreach($online['users'] as $user)
{
   
   $result = db_query("
      SELECT url
      FROM {$db_prefix}log_online
      WHERE ID_MEMBER = $user[id]",__FILE__, __LINE__);

   $checkit = mysql_fetch_assoc($result);
   $data = @unserialize($checkit['url']);
   if($data['action']=='arcade')
   {
      echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];  echo '<br />';
      $arcade_users[] = $user;
   }
   unset($data);
}

//   No arcade users?
if(empty($arcade_users))
   echo '<br />No members in the arcade';
// end wdmboard_statsonline

echo'</div>
</div>
</div>';



OR

For users that just want to show arcade users and have E-Arcade installed can use this code
(REMEMBER TO STILL UPLOAD THE arcade.png TO THE ROOT OF YOUR FORUM!!!)

Screenshot:



global $context, $settings, $options, $scripturl, $txt, $user_info, $modSettings;

    $bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet3 = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet4 = '<img src="'.$settings['images_url'].'/tpgoto.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet5 = '<img src="'.$settings['images_url'].'/tpmodule2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
echo'

<div class="smalltext" style="font-family: verdana, arial, sans-serif;">';

       if(isset($context['TPortal']['userbox']['stats']))
   // members stats
            echo '
                 <img src="'.$settings['images_url'].'/icons/members.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=mlist"><b>'.$txt[19].'</b></a>
                 <br />'.$bullet.$txt[488].': ' , isset($modSettings['memberCount']) ? $modSettings['memberCount'] : $modSettings['totalMembers'] , '
                 <br />'.$bullet.$txt['tp-latest']. ': <a href="', $scripturl, '?action=profile;u=', $modSettings['latestMember'], '"><b>', $modSettings['latestRealName'], '</b></a>';
       if(isset($context['TPortal']['userbox']['stats_all']))

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 '<br />',$bullet,'New This Month: ', $row['month'],'<br />';
echo $bullet,'New This Week: ', $row['week'],'<br />';
echo $bullet,'New Today: ', $row['today'];

   // more stats
            echo '
                  <hr /><img src="'.$settings['images_url'].'/icons/info.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=stats"><b>'.$txt['tp-stats'].'</b></a>
                 <br />'.$bullet.$txt[489].': '.$modSettings['totalMessages']. '
  <br />'.$bullet. $txt[490].': '.$modSettings['totalTopics']. '
  <br />'.$bullet.$txt['tp-mostonline-today'].': '.$modSettings['mostOnlineToday'].'
  <br />'.$bullet.$txt['tp-mostonline'].': '.$modSettings['mostOnline'].'<br />
  ('.timeformat($modSettings['mostDate']).')
  ';

       if(isset($context['TPortal']['userbox']['online'])){
   // add online users
            echo '<hr /><img src="'.$settings['images_url'].'/icons/online.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=who"><b>'.$txt[158].'</b></a><br />';

            $online = ssi_whosOnline('array');
   echo $bullet.$txt['tp-users'].': '.$online['num_users'];
   echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
  // --- Begin FlashChat Integration ---
   echo '<br />', $bullet, 'In Chat: ', $online['num_chat'];
   // --- End FlashChat Integration ---
   echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />
<div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';

      foreach($online['users'] as $user){
echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
   }
echo '</div>';
     
         }
echo '</div>';
// add arcade users
echo '<div class="smalltext" style="font-family: verdana, arial, sans-serif;">

           
<hr />
<img src="/arcade.png"><a href="'.$scripturl.'?action=arcade"><b> Users in Arcade</b></a><br />';

 
//added code
  echo' <div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';
//   Its ok now bullits have flown by stand up again lol
$online = ssi_whosOnline('array');
$arcade_users = array();
foreach($online['users'] as $user)
{
   
   $result = db_query("
      SELECT url
      FROM {$db_prefix}log_online
      WHERE ID_MEMBER = $user[id]",__FILE__, __LINE__);

   $checkit = mysql_fetch_assoc($result);
   $data = @unserialize($checkit['url']);
   if($data['action']=='arcade')
   {
      echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];  echo '<br />';
      $arcade_users[] = $user;
   }
   unset($data);
}

//   No arcade users?
if(empty($arcade_users))
   echo '<br />No members in the arcade';
// end wdmboard_statsonline

echo'</div>
</div>
</div>';


Thanks to making this code possible goes out to:
Bloc - Overall  stats template from old versions of TP
JPDeni - New members section
Daniel15 - FlashChat users
WDM2005 - Arcade users

Lord Anubis

Flash Chat users can use this one

Screenshot:




What you need to do download the chat.png at the bottom of this post and upload it to the root of your site.

then in a php block add this code

global $context, $settings, $options, $scripturl, $txt, $user_info, $modSettings;

    $bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet3 = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet4 = '<img src="'.$settings['images_url'].'/tpgoto.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet5 = '<img src="'.$settings['images_url'].'/tpmodule2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
echo'

<div class="smalltext" style="font-family: verdana, arial, sans-serif;">';

       if(isset($context['TPortal']['userbox']['stats']))
   // members stats
            echo '
                 <img src="'.$settings['images_url'].'/icons/members.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=mlist"><b>'.$txt[19].'</b></a>
                 <br />'.$bullet.$txt[488].': ' , isset($modSettings['memberCount']) ? $modSettings['memberCount'] : $modSettings['totalMembers'] , '
                 <br />'.$bullet.$txt['tp-latest']. ': <a href="', $scripturl, '?action=profile;u=', $modSettings['latestMember'], '"><b>', $modSettings['latestRealName'], '</b></a>';
       if(isset($context['TPortal']['userbox']['stats_all']))

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 '<br />',$bullet,'New This Month: ', $row['month'],'<br />';
echo $bullet,'New This Week: ', $row['week'],'<br />';
echo $bullet,'New Today: ', $row['today'];

   // more stats
            echo '
                  <hr /><img src="'.$settings['images_url'].'/icons/info.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=stats"><b>'.$txt['tp-stats'].'</b></a>
                 <br />'.$bullet.$txt[489].': '.$modSettings['totalMessages']. '
  <br />'.$bullet. $txt[490].': '.$modSettings['totalTopics']. '
  <br />'.$bullet.$txt['tp-mostonline-today'].': '.$modSettings['mostOnlineToday'].'
  <br />'.$bullet.$txt['tp-mostonline'].': '.$modSettings['mostOnline'].'<br />
  ('.timeformat($modSettings['mostDate']).')
  ';

       if(isset($context['TPortal']['userbox']['online'])){
   // add online users
            echo '<hr /><img src="'.$settings['images_url'].'/icons/online.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=who"><b>'.$txt[158].'</b></a><br />';

            $online = ssi_whosOnline('array');
   echo $bullet.$txt['tp-users'].': '.$online['num_users'];
   echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
  // --- Begin FlashChat Integration ---
   echo '<br />', $bullet, 'In Chat: ', $online['num_chat'];
   // --- End FlashChat Integration ---
   echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />
<div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';

      foreach($online['users'] as $user){
echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
echo '<br />';
   }
echo '</div>';
      // --- Begin FlashChat Integration ---
echo '
<hr />
<img src="/chat.png"><a href="'.$scripturl.'?action=chat"> <b>Users in Chat</b></a><br />
<div style="width: 100%; ', ($online['num_chat'] > 14 ? 'height: 23ex;overflow: auto;' : ''), '">';
foreach ($online['users_chat'] as $user)
{
echo '
', $bullet2, $user['link'], ' (', (!$user['chat']['room']['public'] ? $txt['fc_private_room'] : $user['chat']['room']['name']), ')
<br />';
}
echo '
</div>';
   // --- End FlashChat Integration ---
         }
echo '</div>

</div>';

RoarinRow

#2
Very cool, thanks!!   8)

SMF 2.0 RC3
TP 1.0 beta 5-1
Wordpress 3.0

Lord Anubis

Your welcome they are both built off of code that is on here, just modified a bit :)

Smoky

neat m'lord  :coolsmiley: :buck2:

Rafferty

#5
Database Error

Lord Anubis

Well that tells me alot...I have tested this on 3 forums so I think you might not have copied and pasted the whole thing

Rafferty

Sorry, I dont know what Im talking about most the time LoL.

This is the error I get:

Table 'xxxxxx.members' doesn't exist
File: /home/www/xxxxxxxx/forum/Sources/Load.php(1901) : eval()'d code(35) : eval()'d code
Line: 32

Lord Anubis

Did you copy the entire code and put it in a PHP block?

platinumUWE

ty very much very cool great job  ;)