Просмотр файла includes/modules/online.php

Размер файла: 1.46Kb
<?php
$page = isset( $_GET['page'] ) ? (int) ($_GET['page'] - 1) : 0;

$template_vars['header'] = array(
'TITLE' => $lang['ONLINE'],
'CSS' => $css
);

$template->set_vars('header', $template_vars['header']);

if( !$sql->query("SELECT COUNT(*) FROM `" . CATALOGUE_SESSIONS . "` WHERE `dt` > UNIX_TIMESTAMP() - 300;") )
{
	put_error(DBMS_ERROR, htmlspecialchars($sql->error['message']), __LINE__, __FILE__);
}

$total = $sql->result($sql->result, 0);

$maxpage = maxpage($total, ONLINE_ONPAGE);
$limit = limit($page, ONLINE_ONPAGE);

if( !$sql->query("SELECT *, INET_NTOA(`ip`) AS `ip` FROM `" . CATALOGUE_SESSIONS . "` WHERE `dt` > UNIX_TIMESTAMP() - 300 LIMIT " . $limit . ";") )
{
	put_error(DBMS_ERROR, htmlspecialchars($sql->error['message']), __LINE__, __FILE__);
}

for( $i = 1; $user = $sql->fetch_assoc(); $i++ )
{
	if( strpos($user['ua'], '/') !== false )
	{
		$user['ua'] = strtok($user['ua'], '/');
	}

	$template->set_block_vars('body', 'online', array(
	'PLACE' => $page * ONLINE_ONPAGE + $i,
	'IP' => $user['ip'],
	'UA' => output( $user['ua'] )
	));
}

$pages = pages($page, $maxpage, ONLINE_ONPAGE, 2, '', gen_uri($m));

$template_vars['body'] = array(
'PAGES' => $pages,
'BACK_HREF' => gen_uri('index'),
'BACK' => $lang['BACK']
);

$template_vars['footer'] = array('SWITCH_VERSION' => switch_version($m, '', $nocache));

$template->set_vars('body', $template_vars['body']);
$template->set_vars('footer', $template_vars['footer']);
?>