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
|
|
|
|
|
|
|
$user = get_logged_in_user();
|
|
|
|
|
2003-10-27 17:49:05 +00:00
|
|
|
if ($hostid) {
|
2004-01-06 22:09:19 +00:00
|
|
|
$host = lookup_host($hostid);
|
2004-01-08 00:09:26 +00:00
|
|
|
// if (!$host || $host->userid != $user->id) {
|
|
|
|
// echo "No access";
|
|
|
|
// exit();
|
|
|
|
// }
|
2003-10-27 17:49:05 +00:00
|
|
|
$type = "host";
|
|
|
|
$clause = "hostid=$hostid";
|
|
|
|
} else {
|
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";
|
|
|
|
$clause = "userid=$userid";
|
|
|
|
}
|
|
|
|
page_head("Results for $type");
|
|
|
|
echo "<h3>Results for $type</h3>\n";
|
2004-01-06 22:09:19 +00:00
|
|
|
result_table_start(true, false, true);
|
2003-10-27 17:49:05 +00:00
|
|
|
$i = 1;
|
|
|
|
$query = "select * from result where $clause order by id desc limit $results_per_page offset $offset";
|
|
|
|
$result = mysql_query($query);
|
|
|
|
while ($res = mysql_fetch_object($result)) {
|
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";
|
|
|
|
if ($i > $results_per_page) {
|
|
|
|
$offset = $offset+$results_per_page;
|
|
|
|
echo "
|
|
|
|
<br><center><a href=results.php?$clause&offset=$offset>Next $results_per_page results</a></center>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
page_tail();
|
|
|
|
?>
|