Пример #1
0
/**
 * Just like whosOnline except it also logs the online presence.
 *
 * @param string $output_method
 */
function ssi_logOnline($output_method = 'echo')
{
    writeLog();
    if ($output_method != 'echo') {
        return ssi_whosOnline($output_method);
    } else {
        ssi_whosOnline($output_method);
    }
}
Пример #2
0
function TPortal_statsbox()
{
    global $context, $settings, $scripturl, $txt, $modSettings;
    $bullet = '<img src="' . $settings['tp_images_url'] . '/TPdivider.gif" alt=""  style="margin:0 4px 0 0;" />';
    $bullet2 = '<img src="' . $settings['tp_images_url'] . '/TPdivider2.gif" alt="" style="margin:0 4px 0 0;" />';
    echo '
	<div class="tp_statsblock">';
    if (isset($context['TPortal']['userbox']['stats'])) {
        // members stats
        echo '
		<h5 class="mlist"><a href="' . $scripturl . '?action=mlist">' . $txt['members'] . '</a></h5>
		<ul>
			<li>' . $bullet . $txt['total_members'] . ': ', isset($modSettings['memberCount']) ? $modSettings['memberCount'] : $modSettings['totalMembers'], '</li>
			<li>' . $bullet . $txt['tp-latest'] . ': <a href="', $scripturl, '?action=profile;u=', $modSettings['latestMember'], '"><strong>', $modSettings['latestRealName'], '</strong></a></li>
		</ul>';
    }
    if (isset($context['TPortal']['userbox']['stats_all'])) {
        // more stats
        echo '
		<h5 class="stats"><a href="' . $scripturl . '?action=stats">' . $txt['tp-stats'] . '</a></h5>
		<ul>
			<li>' . $bullet . $txt['total_posts'] . ': ' . $modSettings['totalMessages'] . '</li>
			<li>' . $bullet . $txt['total_topics'] . ': ' . $modSettings['totalTopics'] . '</li>
			<li>' . $bullet . $txt['tp-mostonline-today'] . ': ' . $modSettings['mostOnlineToday'] . '</li>
			<li>' . $bullet . $txt['tp-mostonline'] . ': ' . $modSettings['mostOnline'] . '</li>
			<li>(' . timeformat($modSettings['mostDate']) . ')</li>
		</ul>';
    }
    if (isset($context['TPortal']['userbox']['online'])) {
        // add online users
        echo '
		<h5 class="online"><a href="' . $scripturl . '?action=who">' . $txt['online_users'] . '</a></h5>
		<div class="tp_stats_users" style="line-height: 1.3em;">';
        $online = ssi_whosOnline('array');
        echo $bullet . $txt['tp-users'] . ': ' . $online['num_users'] . '<br />
			' . $bullet . $txt['tp-guests'] . ': ' . $online['guests'] . '<br />
			' . $bullet . $txt['tp-total'] . ': ' . $online['total_users'] . '<br />
			<div style="max-height: 23em; overflow: auto;">';
        foreach ($online['users'] as $user) {
            echo $bullet2, $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
            echo '<br />';
        }
        echo '
			</div></div>';
    }
    echo '
	</div>';
}
function sp_whosOnline($parameters, $id, $return_parameters = false)
{
    global $scripturl, $sourcedir, $modSettings, $txt;
    $block_parameters = array('online_today' => 'check');
    if ($return_parameters) {
        return $block_parameters;
    }
    $online_today = !empty($parameters['online_today']);
    $stats = ssi_whosOnline('array');
    echo '
								<ul class="sp_list">
									<li>', sp_embed_image('dot'), ' ', $txt['guests'], ': ', $stats['num_guests'], '</li>';
    if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum'))) {
        echo '
									<li>', sp_embed_image('dot'), ' ', $txt['spiders'], ': ', $stats['num_spiders'], '</li>';
    }
    echo '
									<li>', sp_embed_image('dot'), ' ', $txt['hidden'], ': ', $stats['num_users_hidden'], '</li>
									<li>', sp_embed_image('dot'), ' ', $txt['users'], ': ', $stats['num_users_online'], '</li>';
    if (!empty($stats['users_online'])) {
        echo '
									<li>', sp_embed_image('dot'), ' ', allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '<a href="' . $scripturl . '?action=who">' : '', $txt['online_users'], allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '</a>' : '', ':</li>
								</ul>
								<div class="sp_online_flow">
									<ul class="sp_list">';
        foreach ($stats['users_online'] as $user) {
            echo '
										<li class="sp_list_indent">', sp_embed_image($user['name'] == 'H' ? 'tux' : 'user'), $user['name'] == 'Blue' && ($user['link'] = str_replace('>Blue<', '>Purple<', $user['link'])) ? '' : '', ' ', $user['hidden'] ? '<em>' . $user['link'] . '</em>' : $user['link'], '</li>';
        }
        echo '
									</ul>
								</div>';
    } else {
        echo '
								</ul>
								<br />
								<div class="sp_fullwidth sp_center">', $txt['error_sp_no_online'], '</div>';
    }
    if ($online_today && file_exists($sourcedir . '/Subs-MembersOnlineToday.php')) {
        require_once $sourcedir . '/Subs-MembersOnlineToday.php';
        $membersOnlineTodayOptions = array('sort' => 'login_time', 'reverse_sort' => true, 'period' => 'current_day', 'canview' => 'registered');
        $stats += getMembersOnlineTodayStats($membersOnlineTodayOptions);
        if (empty($stats['num_users_online_today'])) {
            return;
        }
        echo '
								<ul class="sp_list">
									<li>', sp_embed_image('dot'), ' ', $txt['sp-online_today'], ': ', $stats['num_users_online_today'], '</li>
								</ul>
								<div class="sp_online_flow">
									<ul class="sp_list">';
        foreach ($stats['users_online_today'] as $user) {
            echo '
										<li class="sp_list_indent">', sp_embed_image($user['name'] == 'H' ? 'tux' : 'user'), ' ', $user['hidden'] ? '<em>' . $user['link'] . '</em>' : $user['link'], '</li>';
        }
        echo '
									</ul>
								</div>';
    }
}
				<div class="ssi_result"><?php 
ssi_randomMember('day');
flush();
?>
</div>
			</div>

			<div class="ssi_preview" id="ssi_whosOnline">
				<h2>Who's Online Function</h2>
				<p>This function shows who are online inside the forum.</p>

				<h3>Code</h3>
				<div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_whosOnline(); ?&gt;</code>
				<h3>Result</h3>
				<div class="ssi_result"><?php 
ssi_whosOnline();
flush();
?>
</div>

				<h2>Log Online Presence</h2>
				<p>This function logs the SSI page's visitor, then shows the Who's Online list. In other words, this function shows who are online inside and outside the forum.</p>

				<h3>Code</h3>
				<div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_logOnline(); ?&gt;</code>
				<h3>Result</h3>
				<div class="ssi_result"><?php 
ssi_logOnline();
flush();
?>
</div>
/**
 * Who's online block, shows count of users online names
 *
 * @param mixed[] $parameters
 *		'online_today' => shows all users that were online today (requires user online today addon)
 * @param int $id - not used in this block
 * @param boolean $return_parameters if true returns the configuration options for the block
 */
function sp_whosOnline($parameters, $id, $return_parameters = false)
{
    global $scripturl, $modSettings, $txt, $context;
    $block_parameters = array('online_today' => 'check');
    if ($return_parameters) {
        return $block_parameters;
    }
    // Interface with the online today addon?
    $online_today = !empty($parameters['online_today']);
    loadLanguage('index', '', false, true);
    $stats = ssi_whosOnline('array');
    echo '
								<ul class="sp_list">
									<li ', sp_embed_class('dot'), '> ', $txt['guests'], ': ', $stats['num_guests'], '</li>';
    // Spiders
    if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum'))) {
        echo '
									<li ', sp_embed_class('dot'), '> ', $txt['spiders'], ': ', $stats['num_spiders'], '</li>';
    }
    echo '
									<li ', sp_embed_class('dot'), '> ', $txt['hidden'], ': ', $stats['num_users_hidden'], '</li>
									<li ', sp_embed_class('dot'), '> ', $txt['users'], ': ', $stats['num_users_online'], '</li>';
    // Show the users online, if any
    if (!empty($stats['users_online'])) {
        echo '
									<li ', sp_embed_class('dot'), '> ', allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '<a href="' . $scripturl . '?action=who">' : '', $txt['online_users'], allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '</a>' : '', ':</li>
								</ul>
								<div class="sp_online_flow">
									<ul class="sp_list">';
        foreach ($stats['users_online'] as $user) {
            echo '
										<li ', sp_embed_class($user['name'] == 'H' ? 'tux' : 'user', '', 'sp_list_indent'), '>', $user['hidden'] ? '<em>' . $user['link'] . '</em>' : $user['link'], '</li>';
        }
        echo '
									</ul>
								</div>';
    } else {
        echo '
								</ul>
								<br />
								<div class="sp_fullwidth centertext">', $txt['error_sp_no_online'], '</div>';
    }
    // Does the online today addon exist
    if ($online_today && !empty($modSettings['onlinetoday']) && file_exists(SUBSDIR . '/OnlineToday.class.php')) {
        require_once SUBSDIR . '/OnlineToday.class.php';
        $context['info_center_callbacks'] = array();
        Online_Today_Integrate::get();
        if (empty($context['num_onlinetoday'])) {
            return;
        }
        echo '
								<ul class="sp_list">
									<li ', sp_embed_class('dot'), '> ', $txt['sp-online_today'], ': ', $context['num_onlinetoday'], '</li>
								</ul>
								<div class="sp_online_flow">
									<ul class="sp_list">';
        foreach ($context['onlinetoday'] as $user) {
            echo '
										<li ', sp_embed_class('user', '', 'sp_list_indent'), '>', $user, '</li>';
        }
        echo '
									</ul>
								</div>';
    }
}
 /**
  * Short description
  *
  * Long description
  *
  * @param
  * @return
  */
 protected function show_whosOnline()
 {
     try {
         $this->loadSSI();
     } catch (Exception $e) {
         throw new \Exception($e->getMessage());
     }
     if ('echo' == $this->output_method) {
         ob_start();
         ssi_whosOnline($this->output_method);
         $this->data = ob_get_contents();
         ob_end_clean();
     } else {
         $this->data = ssi_whosOnline($this->output_method);
     }
 }