2003-10-27 17:49:05 +00:00
|
|
|
<?php
|
2005-02-19 08:06:53 +00:00
|
|
|
// show recent results for a host or user
|
2003-10-27 17:49:05 +00:00
|
|
|
|
2005-02-19 08:06:53 +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
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
$config = get_config();
|
|
|
|
if (!parse_bool($config, "show_results")) {
|
|
|
|
page_head("Temporarily disabled");
|
|
|
|
page_tail();
|
|
|
|
exit();
|
|
|
|
}
|
2004-07-02 19:17:53 +00:00
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
$results_per_page = 20;
|
2003-10-27 17:49:05 +00:00
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
db_init();
|
|
|
|
$hostid = get_int("hostid", true);
|
|
|
|
$userid = get_int("userid", true);
|
|
|
|
$offset = get_int("offset", true);
|
|
|
|
if (!$offset) $offset=0;
|
2004-01-06 22:09:19 +00:00
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
if ($hostid) {
|
|
|
|
$host = lookup_host($hostid);
|
|
|
|
$type = "computer";
|
|
|
|
$clause = "hostid=$hostid";
|
|
|
|
} else {
|
|
|
|
$user = get_logged_in_user();
|
|
|
|
if ($userid != $user->id) {
|
|
|
|
error_page("No access");
|
2003-10-27 17:49:05 +00:00
|
|
|
}
|
2005-02-19 08:06:53 +00:00
|
|
|
$type = "user";
|
|
|
|
$clause = "userid=$userid";
|
|
|
|
}
|
|
|
|
page_head("Results for $type");
|
|
|
|
result_table_start(true, false, true);
|
|
|
|
$i = 0;
|
|
|
|
$query = "select * from result where $clause order by id desc limit $offset,".($results_per_page+1);
|
|
|
|
$result = mysql_query($query);
|
|
|
|
$number_of_results = mysql_affected_rows();
|
2006-05-04 04:29:28 +00:00
|
|
|
echo show_result_navigation(
|
|
|
|
$clause, $number_of_results, $offset, $results_per_page
|
|
|
|
);
|
2005-02-19 08:06:53 +00:00
|
|
|
while ($res = mysql_fetch_object($result) and $i<$results_per_page) {
|
|
|
|
show_result_row($res, true, false, true);
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
mysql_free_result($result);
|
|
|
|
echo "</table>\n";
|
2004-03-24 01:41:49 +00:00
|
|
|
|
2006-05-04 04:29:28 +00:00
|
|
|
echo show_result_navigation(
|
|
|
|
$clause, $number_of_results, $offset, $results_per_page
|
|
|
|
);
|
2003-10-27 17:49:05 +00:00
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
page_tail();
|
2003-10-27 17:49:05 +00:00
|
|
|
?>
|