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
|
|
|
|
2004-08-25 19:04:47 +00:00
|
|
|
$config = get_config();
|
2004-11-12 22:50:58 +00:00
|
|
|
if (!parse_bool($config, "show_results")) {
|
2004-07-02 19:17:53 +00:00
|
|
|
page_head("Temporarily disabled");
|
|
|
|
page_tail();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
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);
|
2005-02-07 06:24:14 +00:00
|
|
|
$type = "computer";
|
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";
|
|
|
|
$clause = "userid=$userid";
|
|
|
|
}
|
|
|
|
page_head("Results for $type");
|
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 "
|
2004-12-18 17:18:42 +00:00
|
|
|
<br><center><a href=\"results.php?$clause&offset=$offset\">Next $results_per_page results</a></center>
|
2003-10-27 17:49:05 +00:00
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
page_tail();
|
|
|
|
?>
|