error_page(tra("Limit exceeded - Sorry, first %1 items only", ITEM_LIMIT)); } $cache_args = "sort_by={$sort_by}&offset={$offset}"; $cacheddata = get_cached_data(TOP_PAGES_TTL, $cache_args); if ($cacheddata) { $data = store_to_hosts($cacheddata); } else { $data = get_top_hosts($offset, $sort_by); set_cached_data(TOP_PAGES_TTL, hosts_to_store($data), $cache_args); } // Now display what we've got (either gotten from cache or from DB) // page_head(tra("Top hosts")); top_host_table_start($sort_by); $i = 1 + $offset; $n = sizeof($data); foreach ($data as $host) { show_host_row($host, $i, false, true); $i++; } echo "</table>\n<p>"; if ($offset > 0) { $new_offset = $offset - $hosts_per_page; echo "<a href=top_hosts.php?sort_by={$sort_by}&offset={$new_offset}>" . tra("Previous %1", $hosts_per_page) . "</a> | "; } if ($n == $hosts_per_page) { //If we aren't on the last page $new_offset = $offset + $hosts_per_page; echo "<a href=top_hosts.php?sort_by={$sort_by}&offset={$new_offset}>" . tra("Next %1", $hosts_per_page) . "</a>"; } page_tail();
$private = true; } $now = time(); $old_hosts = 0; $i = 1; $hosts = BoincHost::enum("userid={$userid} order by {$sort_clause}"); foreach ($hosts as $host) { $is_old = false; if ($now - $host->rpc_time > 30 * 86400) { $is_old = true; $old_hosts++; } if (!$show_all && $is_old) { continue; } show_host_row($host, $i, $private, false); $i++; } echo "</table>\n"; if ($old_hosts > 0) { more_or_less($sort, $rev, $show_all); } if ($private) { echo "\r\n\t\t<a href=merge_by_name.php>Merge computers by name</a>\r\n\t"; } if ($caching) { page_tail(true); end_cache(USER_PAGE_TTL, $cache_args); } else { page_tail(); }