2003-03-17 22:37:49 +00:00
|
|
|
<?php
|
2003-03-19 21:01:32 +00:00
|
|
|
// show all the hosts for a user.
|
|
|
|
// if $userid is absent, show hosts of logged-in user
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once("../inc/db.inc");
|
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/host.inc");
|
2004-07-23 01:07:18 +00:00
|
|
|
require_once("../inc/cache.inc");
|
2003-03-17 22:37:49 +00:00
|
|
|
|
|
|
|
db_init();
|
2005-02-15 22:29:32 +00:00
|
|
|
$userid = get_int("userid", true);
|
2005-07-20 12:49:45 +00:00
|
|
|
$user = get_logged_in_user(false);
|
|
|
|
if ($user && $user->id == $userid) {
|
|
|
|
$userid = 0;
|
|
|
|
}
|
2003-03-19 21:01:32 +00:00
|
|
|
if ($userid) {
|
2005-02-15 22:29:32 +00:00
|
|
|
$user = lookup_user_id($userid);
|
|
|
|
if (!$user) {
|
|
|
|
error_page("No such user");
|
|
|
|
}
|
2004-07-23 01:07:18 +00:00
|
|
|
$cache_args = "userid=$userid";
|
2004-11-18 20:01:12 +00:00
|
|
|
$caching=true;
|
|
|
|
start_cache(USER_PAGE_TTL, $cache_args);
|
2004-01-05 23:38:13 +00:00
|
|
|
if ($user->show_hosts) {
|
|
|
|
page_head("Computers belonging to $user->name");
|
2004-05-31 00:50:06 +00:00
|
|
|
user_host_table_start(false);
|
2004-01-05 23:38:13 +00:00
|
|
|
} else {
|
2005-07-20 12:49:45 +00:00
|
|
|
page_head("Computers hidden");
|
|
|
|
echo "This user has chosen not to show information about their computers.\n";
|
|
|
|
page_tail();
|
2004-11-22 19:17:13 +00:00
|
|
|
end_cache(USER_PAGE_TTL, $cache_args);
|
2004-01-05 23:38:13 +00:00
|
|
|
exit();
|
|
|
|
}
|
2003-03-19 21:01:32 +00:00
|
|
|
$private = false;
|
|
|
|
} else {
|
2004-07-23 01:07:18 +00:00
|
|
|
$caching=false;
|
2003-03-19 21:01:32 +00:00
|
|
|
$userid = $user->id;
|
|
|
|
page_head("Your computers");
|
2004-05-31 00:50:06 +00:00
|
|
|
user_host_table_start(true);
|
2003-03-19 21:01:32 +00:00
|
|
|
$private = true;
|
|
|
|
}
|
2003-03-17 22:37:49 +00:00
|
|
|
$i = 1;
|
2005-07-21 06:57:40 +00:00
|
|
|
$result = mysql_query("select * from host where userid=$userid order by rpc_time desc");
|
2003-03-19 21:01:32 +00:00
|
|
|
while ($host = mysql_fetch_object($result)) {
|
2003-12-15 02:31:29 +00:00
|
|
|
show_host_row($host, $i, $private, false);
|
2003-03-17 22:37:49 +00:00
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
mysql_free_result($result);
|
|
|
|
echo "</table>\n";
|
2004-11-18 20:01:12 +00:00
|
|
|
if ($caching) {
|
|
|
|
page_tail(true);
|
2004-11-22 19:17:13 +00:00
|
|
|
end_cache(USER_PAGE_TTL, $cache_args);
|
2004-11-18 20:01:12 +00:00
|
|
|
} else {
|
|
|
|
page_tail();
|
|
|
|
}
|
2003-03-17 22:37:49 +00:00
|
|
|
?>
|