21
21
require_once("../inc/user.inc");
22
22
require_once("../inc/host.inc");
23
23
require_once("../inc/boinc_db.inc");
24
require_once("../inc/translation.inc");
26
25
$config = get_config();
27
26
$hosts_per_page = parse_config($config, "<hosts_per_page>");
62
61
if (!$offset) $offset=0;
63
62
if ($offset % $hosts_per_page) $offset = 0;
65
if ($offset < ITEM_LIMIT) {
66
$cache_args = "sort_by=$sort_by&offset=$offset";
67
$cacheddata=get_cached_data(TOP_PAGES_TTL,$cache_args);
68
if ($cacheddata){ //If we have got the data in cache
69
$data = store_to_hosts($cacheddata); // use the cached data
70
} else { //if not do queries etc to generate new data
71
$data = get_top_hosts($offset,$sort_by);
72
set_cache_data(hosts_to_store($data),$cache_args); //save data in cache
64
if ($offset >= ITEM_LIMIT) {
65
error_page(tra("Limit exceeded - Sorry, first %1 items only", ITEM_LIMIT));
68
$cache_args = "sort_by=$sort_by&offset=$offset";
69
$cacheddata = get_cached_data(TOP_PAGES_TTL, $cache_args);
71
$data = store_to_hosts($cacheddata);
75
error_page("Limit exceeded - Sorry, first ".ITEM_LIMIT." items only");
79
//Now display what we've got (either gotten from cache or from DB)
73
$data = get_top_hosts($offset,$sort_by);
74
set_cache_data(hosts_to_store($data), $cache_args);
78
// Now display what we've got (either gotten from cache or from DB)
80
80
page_head(tra("Top hosts"));
81
81
top_host_table_start($sort_by);
88
88
echo "</table>\n<p>";
90
90
$new_offset = $offset - $hosts_per_page;
91
echo "<a href=top_hosts.php?sort_by=$sort_by&offset=$new_offset>Previous ".$hosts_per_page."</a> | ";
91
echo "<a href=top_hosts.php?sort_by=$sort_by&offset=$new_offset>".tra("Previous %1", $hosts_per_page)."</a> | ";
94
94
if ($n==$hosts_per_page){ //If we aren't on the last page
95
95
$new_offset = $offset + $hosts_per_page;
96
echo "<a href=top_hosts.php?sort_by=$sort_by&offset=$new_offset>Next ".$hosts_per_page."</a>";
96
echo "<a href=top_hosts.php?sort_by=$sort_by&offset=$new_offset>".tra("Next %1", $hosts_per_page)."</a>";