<?php
$page = isset( $_GET['page'] ) ? (int) ($_GET['page'] - 1) : 0;
$template_vars['header'] = array(
'TITLE' => $lang['TOP'],
'CSS' => $css
);
$template->set_vars('header', $template_vars['header']);
$query = "SELECT COUNT(*) FROM `" . CATALOGUE_SITES . "` WHERE `checked` = 1 AND `owner` = 'user' AND `in_today_all` > 0;";
if( !$sql->query($query) )
{
put_error(DBMS_ERROR, htmlspecialchars($sql->error['message']), __LINE__, __FILE__);
}
$total = $sql->result($sql->result, 0);
$maxpage = maxpage($total, $config['catalogue_onpage']);
$limit = limit($page, $config['catalogue_onpage']);
if( !($qresult = $sql->query("SELECT *, ((`in_today_mp` * 100) / `in_today_all` ) AS `mp_percent` FROM `" . CATALOGUE_SITES . "` WHERE `checked` = 1 AND `owner` = 'user' AND `in_today_all` > 0 ORDER BY `in_today_all` DESC, `mp_percent` DESC LIMIT " . $limit . ";")) )
{
put_error(DBMS_ERROR, htmlspecialchars($sql->error['message']), __LINE__, __FILE__);
}
for( $i = 1; $site = $sql->fetch_assoc($qresult); $i++ )
{
$template->set_block_vars('body', 'site', array(
'PLACE' => $page * $config['catalogue_onpage'] + $i,
'LINK_OUT' => gen_uri('out', $site['id']),
'TITLE' => output( $site['title'] ),
'SITE' => output( $site['site'] ),
'DESCRIPTION' => output( $site['description'] ),
'IN' => $site['owner'] == 'user' ? $site['in_today_all'] . '/' . $site['in'] : 'N/A',
'OUT' => $site['out_today'] . '/' . $site['out']
));
}
$pages = pages($page, $maxpage, $config['catalogue_onpage'], 2, '', gen_uri($m));
$template_vars['body'] = array(
'IN' => $lang['IN'],
'OUT' => $lang['OUT'],
'DESCRIPTION' => $lang['DESCRIPTION'],
'PAGES' => $pages,
'BACK_HREF' => gen_uri('index'),
'BACK' => $lang['BACK']
);
$template_vars['footer'] = array(
'SWITCH_VERSION' => switch_version($m, '', $nocache),
'COUNTER' => ''
);
$template->set_vars('body', $template_vars['body']);
$template->set_vars('footer', $template_vars['footer']);
?>