2003-10-27 17:49:05 +00:00
|
|
|
<?php
|
|
|
|
// show recent results for a host or user
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once("../inc/db.inc");
|
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/result.inc");
|
2003-10-27 17:49:05 +00:00
|
|
|
|
|
|
|
$results_per_page = 20;
|
|
|
|
|
|
|
|
db_init();
|
|
|
|
$hostid = $_GET["hostid"];
|
|
|
|
$userid = $_GET["userid"];
|
|
|
|
$offset = $_GET["offset"];
|
|
|
|
if (!$offset) $offset=0;
|
2004-01-06 22:09:19 +00:00
|
|
|
|
2003-10-27 17:49:05 +00:00
|
|
|
if ($hostid) {
|
2004-01-06 22:09:19 +00:00
|
|
|
$host = lookup_host($hostid);
|
2003-10-27 17:49:05 +00:00
|
|
|
$type = "host";
|
2004-04-14 21:27:48 +00:00
|
|
|
$link = "<a href=show_host_detail.php?hostid=$hostid>host $hostid</a>";
|
2003-10-27 17:49:05 +00:00
|
|
|
$clause = "hostid=$hostid";
|
|
|
|
} else {
|
2004-04-21 23:25:05 +00:00
|
|
|
$user = get_logged_in_user();
|
2004-01-06 22:09:19 +00:00
|
|
|
if ($userid != $user->id) {
|
|
|
|
echo "No access";
|
|
|
|
exit();
|
|
|
|
}
|
2003-10-27 17:49:05 +00:00
|
|
|
$type = "user";
|
2004-04-14 21:27:48 +00:00
|
|
|
$link = "user";
|
2003-10-27 17:49:05 +00:00
|
|
|
$clause = "userid=$userid";
|
|
|
|
}
|
|
|
|
page_head("Results for $type");
|
2004-04-14 21:27:48 +00:00
|
|
|
echo "<h3>Results for $link</h3>\n";
|
2004-01-06 22:09:19 +00:00
|
|
|
result_table_start(true, false, true);
|
2004-04-09 23:33:50 +00:00
|
|
|
$i = 0;
|
2004-03-24 01:41:49 +00:00
|
|
|
$query = "select * from result where $clause order by id desc limit $offset,".($results_per_page+1);
|
2003-10-27 17:49:05 +00:00
|
|
|
$result = mysql_query($query);
|
2004-03-24 01:41:49 +00:00
|
|
|
$number_of_results = mysql_affected_rows();
|
|
|
|
while ($res = mysql_fetch_object($result) and $i<$results_per_page) {
|
2004-01-06 22:09:19 +00:00
|
|
|
show_result_row($res, true, false, true);
|
2003-10-27 17:49:05 +00:00
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
mysql_free_result($result);
|
|
|
|
echo "</table>\n";
|
2004-03-24 01:41:49 +00:00
|
|
|
|
|
|
|
if ($number_of_results > $results_per_page) {
|
2003-10-27 17:49:05 +00:00
|
|
|
$offset = $offset+$results_per_page;
|
|
|
|
echo "
|
|
|
|
<br><center><a href=results.php?$clause&offset=$offset>Next $results_per_page results</a></center>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
page_tail();
|
|
|
|
?>
|