SimplePortal

Customization => Custom Coding => Topic started by: fdr77 on September 18, 2010, 09:17:34 AM

Title: is possible this block?
Post by: fdr77 on September 18, 2010, 09:17:34 AM
is possible this block?
statistic and user on line together
Title: Re: is possible this block?
Post by: falco on September 19, 2010, 08:49:57 AM
That is Tiny Portal.
Title: Re: is possible this block?
Post by: fdr77 on September 19, 2010, 11:44:19 AM
you wanted to know if such a thing was possible.
Or on the forum I post count total, total users, total posts.
you can create a block with 24 hours in open discussion and responses in 24 hours?
Thank you
Title: Re: is possible this block?
Post by: fdr77 on September 22, 2010, 09:46:49 AM
I managed . Copy the code maybe someone interested. You can see if maybe something is wrong
Code: [Select]
sp_userInfo(array(), $id);
echo '<hr />';
sp_boardStats(array('averages' => 0), $id);
echo '<hr />';
echo '
<b>Utenti on line :</b> ',
sp_whosOnline(array(), $id);
echo '<hr />';
global $db_prefix, $user_info, $modSettings, $context;

// Load the users online today.
$date = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']) - ($modSettings['time_offset'] * 3600);

$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
$time_fmt = '%I:%M' . $s . ' %p';
else
$time_fmt = '%H:%M' . $s;

$result = db_query("
SELECT
mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))
WHERE mem.lastLogin >= $midnight
LIMIT 20", __FILE__, __LINE__);

$context['num_hidden_users_online_today'] = 0;
$context['users_online_today'] = array();
$context['list_users_online_today'] = array();

while ($row = mysql_fetch_assoc($result))
{
if (empty($row['showOnline']))
{
$context['num_hidden_users_online_today'] = $context['num_hidden_users_online_today'] + 1;
if (!$user_info['is_admin']) continue;
}

$userday = strftime('%d', forum_time(true));
$loginday = strftime('%d', forum_time(true, $row['lastLogin']));
$yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];

$lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
$title = ' title="' . $lastLogin . '"';

// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . ' style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . '>' . $row['realName'] . '</a>';

$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
{
$link = '<b>' . $link . '</b>';
}

$context['users_online_today'][$row['lastLogin'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'hidden' => empty($row['showOnline']),
);

$context['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = empty($row['showOnline']) ? '<i>' . $link . '</i>' : $link;
}
mysql_free_result($result);

krsort($context['users_online_today']);
krsort($context['list_users_online_today']);

$context['num_users_online_today'] = count($context['users_online_today']);

if (!empty($context['users_online_today']))
{
echo '
<b>Utenti on line nelle 24 ore :</b> ', $context['num_users_online_today'], '
<ul>';

foreach ($context['list_users_online_today'] as $user)
echo '
<li>', $user, '</li>';

echo '
</ul>';
}
else
echo 'Nessun utente on line oggi.';


 
global $context, $scripturl, $boarddir, $txt;
global $db_prefix;
echo '
<b>Compleanni :</b><br> ';
require_once($boarddir.'/SSI.php');

//number of days before birthday is shown
$number_of_days = 5;

$last_year = date('U') - (365 * 24 * 60 * 60);

$low_date = strftime('%Y-%m-%d', forum_time(false) - 24 * 3600);
$high_date = strftime('%Y-%m-%d', forum_time(false) + $number_of_days * 24 * 3600);

if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
  $allyear_part = "birthdate BETWEEN '0004" . substr($low_date, 4) . "' AND '0004-12-31'
                   OR birthdate BETWEEN '0004-01-01' AND '0004" . substr($high_date, 4) . "'";
else
  $allyear_part = "birthdate BETWEEN '0004" . substr($low_date, 4) . "' AND '0004" . substr($high_date, 4) . "'";

$year_low = (int) substr($low_date, 0, 4);
$year_high = (int) substr($high_date, 0, 4);

$query= db_query("
                           SELECT ID_MEMBER, realName, YEAR(birthdate) AS birthYear, birthdate
                           FROM {$db_prefix}members
                           WHERE YEAR(birthdate) != '0001'
                           AND ({$allyear_part}
                           OR DATE_FORMAT(birthdate, '{$year_low}-%m-%d') BETWEEN '$low_date' AND '$high_date'" . ($year_low == $year_high ? '' : "
                           OR DATE_FORMAT(birthdate, '{$year_high}-%m-%d') BETWEEN '$low_date' AND '$high_date'") . ")
                           AND lastLogin > '{$last_year}'
                          ORDER BY memberName", __FILE__, __LINE__);


if(db_affected_rows() != 0)
{
  $birthdays = array();
  $member = array();
  while ($row = mysql_fetch_assoc($query))
  {
    $day = substr($row['birthdate'],8,2);
    $month = substr($row['birthdate'],5,2);
    $birthdays[$row['realName']] =  $month . $day;
    $member[$row['realName']] =  $row['ID_MEMBER'];
  }
  echo '<table>';
  asort($birthdays);
  $yesterday = 0;
  foreach ($birthdays as $key => $value)
  {
    if ($value <> $yesterday)
    {
      if (substr($value,0,2) == date("m"))
        $showdate = date("M") . ' ' . substr($value,2,2);
      else
        $showdate = date("M",time() + ($number_of_days * 24 * 3600)) . ' ' .  substr($value,2,2);
      if ($yesterday > 0)
        echo '</td></tr>';
      echo '<tr valign="top"><td>' , $showdate , '</td><td>';
    }
    echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a><br />';
    $yesterday = $value;
  }
  echo '</td></tr></table>';
}
else
  echo 'Non ci sono compleanni nei prossimi ' . $number_of_days . ' giorni';

for this
Title: Re: is possible this block?
Post by: fdr77 on September 22, 2010, 09:48:42 AM
and this
Code: [Select]
echo '
<b>Utenti on line :</b> ',
sp_whosOnline(array(), $id);
echo '<hr />';
sp_boardStats(array('averages' => 0), $id);
echo '<hr />';

global $context, $scripturl, $boarddir, $txt;
global $db_prefix;
echo '
<b>Compleanni :</b><br> ';
require_once($boarddir.'/SSI.php');

//number of days before birthday is shown
$number_of_days = 5;

$last_year = date('U') - (365 * 24 * 60 * 60);

$low_date = strftime('%Y-%m-%d', forum_time(false) - 24 * 3600);
$high_date = strftime('%Y-%m-%d', forum_time(false) + $number_of_days * 24 * 3600);

if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
  $allyear_part = "birthdate BETWEEN '0004" . substr($low_date, 4) . "' AND '0004-12-31'
                   OR birthdate BETWEEN '0004-01-01' AND '0004" . substr($high_date, 4) . "'";
else
  $allyear_part = "birthdate BETWEEN '0004" . substr($low_date, 4) . "' AND '0004" . substr($high_date, 4) . "'";

$year_low = (int) substr($low_date, 0, 4);
$year_high = (int) substr($high_date, 0, 4);

$query= db_query("
                           SELECT ID_MEMBER, realName, YEAR(birthdate) AS birthYear, birthdate
                           FROM {$db_prefix}members
                           WHERE YEAR(birthdate) != '0001'
                           AND ({$allyear_part}
                           OR DATE_FORMAT(birthdate, '{$year_low}-%m-%d') BETWEEN '$low_date' AND '$high_date'" . ($year_low == $year_high ? '' : "
                           OR DATE_FORMAT(birthdate, '{$year_high}-%m-%d') BETWEEN '$low_date' AND '$high_date'") . ")
                           AND lastLogin > '{$last_year}'
                          ORDER BY memberName", __FILE__, __LINE__);


if(db_affected_rows() != 0)
{
  $birthdays = array();
  $member = array();
  while ($row = mysql_fetch_assoc($query))
  {
    $day = substr($row['birthdate'],8,2);
    $month = substr($row['birthdate'],5,2);
    $birthdays[$row['realName']] =  $month . $day;
    $member[$row['realName']] =  $row['ID_MEMBER'];
  }
  echo '<table>';
  asort($birthdays);
  $yesterday = 0;
  foreach ($birthdays as $key => $value)
  {
    if ($value <> $yesterday)
    {
      if (substr($value,0,2) == date("m"))
        $showdate = date("M") . ' ' . substr($value,2,2);
      else
        $showdate = date("M",time() + ($number_of_days * 24 * 3600)) . ' ' .  substr($value,2,2);
      if ($yesterday > 0)
        echo '</td></tr>';
      echo '<tr valign="top"><td>' , $showdate , '</td><td>';
    }
    echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a><br />';
    $yesterday = $value;
  }
  echo '</td></tr></table>';
}
else
  echo 'Non ci sono compleanni nei prossimi ' . $number_of_days . ' giorni';

for this
Title: Re: is possible this block?
Post by: fdr77 on September 22, 2010, 09:55:14 AM
Having regard to the help received , I hope I have done something useful to all
Title: Re: is possible this block?
Post by: bumbo on September 26, 2010, 03:33:47 AM
I managed . Copy the code maybe someone interested. You can see if maybe something is wrong
Code: [Select]
sp_userInfo(array(), $id);
echo '<hr />';
sp_boardStats(array('averages' => 0), $id);
echo '<hr />';
echo '
<b>Utenti on line :</b> ',
sp_whosOnline(array(), $id);
echo '<hr />';
global $db_prefix, $user_info, $modSettings, $context;

// Load the users online today.
$date = @getdate(forum_time(false));
$midnight = mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']) - ($modSettings['time_offset'] * 3600);

$s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
$time_fmt = '%I:%M' . $s . ' %p';
else
$time_fmt = '%H:%M' . $s;

$result = db_query("
SELECT
mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP, mg.groupName
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))
WHERE mem.lastLogin >= $midnight
LIMIT 20", __FILE__, __LINE__);

$context['num_hidden_users_online_today'] = 0;
$context['users_online_today'] = array();
$context['list_users_online_today'] = array();

while ($row = mysql_fetch_assoc($result))
{
if (empty($row['showOnline']))
{
$context['num_hidden_users_online_today'] = $context['num_hidden_users_online_today'] + 1;
if (!$user_info['is_admin']) continue;
}

$userday = strftime('%d', forum_time(true));
$loginday = strftime('%d', forum_time(true, $row['lastLogin']));
$yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];

$lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
$title = ' title="' . $lastLogin . '"';

// Some basic color coding...
if (!empty($row['onlineColor']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . ' style="color: ' . $row['onlineColor'] . ';">' . $row['realName'] . '</a>';
else
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"' . $title . '>' . $row['realName'] . '</a>';

$is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
if ($is_buddy)
{
$link = '<b>' . $link . '</b>';
}

$context['users_online_today'][$row['lastLogin'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => $link,
'is_buddy' => $is_buddy,
'hidden' => empty($row['showOnline']),
);

$context['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = empty($row['showOnline']) ? '<i>' . $link . '</i>' : $link;
}
mysql_free_result($result);

krsort($context['users_online_today']);
krsort($context['list_users_online_today']);

$context['num_users_online_today'] = count($context['users_online_today']);

if (!empty($context['users_online_today']))
{
echo '
<b>Utenti on line nelle 24 ore :</b> ', $context['num_users_online_today'], '
<ul>';

foreach ($context['list_users_online_today'] as $user)
echo '
<li>', $user, '</li>';

echo '
</ul>';
}
else
echo 'Nessun utente on line oggi.';


 
global $context, $scripturl, $boarddir, $txt;
global $db_prefix;
echo '
<b>Compleanni :</b><br> ';
require_once($boarddir.'/SSI.php');

//number of days before birthday is shown
$number_of_days = 5;

$last_year = date('U') - (365 * 24 * 60 * 60);

$low_date = strftime('%Y-%m-%d', forum_time(false) - 24 * 3600);
$high_date = strftime('%Y-%m-%d', forum_time(false) + $number_of_days * 24 * 3600);

if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
  $allyear_part = "birthdate BETWEEN '0004" . substr($low_date, 4) . "' AND '0004-12-31'
                   OR birthdate BETWEEN '0004-01-01' AND '0004" . substr($high_date, 4) . "'";
else
  $allyear_part = "birthdate BETWEEN '0004" . substr($low_date, 4) . "' AND '0004" . substr($high_date, 4) . "'";

$year_low = (int) substr($low_date, 0, 4);
$year_high = (int) substr($high_date, 0, 4);

$query= db_query("
                           SELECT ID_MEMBER, realName, YEAR(birthdate) AS birthYear, birthdate
                           FROM {$db_prefix}members
                           WHERE YEAR(birthdate) != '0001'
                           AND ({$allyear_part}
                           OR DATE_FORMAT(birthdate, '{$year_low}-%m-%d') BETWEEN '$low_date' AND '$high_date'" . ($year_low == $year_high ? '' : "
                           OR DATE_FORMAT(birthdate, '{$year_high}-%m-%d') BETWEEN '$low_date' AND '$high_date'") . ")
                           AND lastLogin > '{$last_year}'
                          ORDER BY memberName", __FILE__, __LINE__);


if(db_affected_rows() != 0)
{
  $birthdays = array();
  $member = array();
  while ($row = mysql_fetch_assoc($query))
  {
    $day = substr($row['birthdate'],8,2);
    $month = substr($row['birthdate'],5,2);
    $birthdays[$row['realName']] =  $month . $day;
    $member[$row['realName']] =  $row['ID_MEMBER'];
  }
  echo '<table>';
  asort($birthdays);
  $yesterday = 0;
  foreach ($birthdays as $key => $value)
  {
    if ($value <> $yesterday)
    {
      if (substr($value,0,2) == date("m"))
        $showdate = date("M") . ' ' . substr($value,2,2);
      else
        $showdate = date("M",time() + ($number_of_days * 24 * 3600)) . ' ' .  substr($value,2,2);
      if ($yesterday > 0)
        echo '</td></tr>';
      echo '<tr valign="top"><td>' , $showdate , '</td><td>';
    }
    echo '<a class="normaltext" href="' . $scripturl . '?action=profile;u=' . $member[$key] . '">' . $key . '</a><br />';
    $yesterday = $value;
  }
  echo '</td></tr></table>';
}
else
  echo 'Non ci sono compleanni nei prossimi ' . $number_of_days . ' giorni';

for this

Congratulations masters, this I like it ... only if he could explain where to paste this to your work and how? I'm just a beginner and do not cope very well. Thanks in advance. :thumbsup:rcwc
Title: Re: is possible this block?
Post by: fdr77 on October 03, 2010, 10:10:42 AM
 take a php block and paste it there only for smf 1.1.11 and SP 2.3.2
Title: Re: is possible this block?
Post by: dirtymind on October 04, 2010, 10:14:08 AM
this is mine  ;)
Title: Re: is possible this block?
Post by: Deezel on October 27, 2010, 07:21:57 AM
this is mine  ;)
Mind sharing the code for that one...looks great!
SimplePortal 2.3.8 © 2008-2024, SimplePortal