$page["title"] = "Configuration of items";
$page["file"] = "items.php";
include "include/config.inc.php";
show_header($page["title"],0,0);
?>
if(!check_right("Host","U",0))
{
show_table_header("No permissions !");
show_footer();
exit;
}
?>
if(isset($HTTP_GET_VARS["register"]))
{
if($HTTP_GET_VARS["register"]=="update")
{
$result=update_item($HTTP_GET_VARS["itemid"],$HTTP_GET_VARS["description"],$HTTP_GET_VARS["key"],$HTTP_GET_VARS["hostid"],$HTTP_GET_VARS["delay"],$HTTP_GET_VARS["history"],$HTTP_GET_VARS["status"],$HTTP_GET_VARS["type"],$HTTP_GET_VARS["snmp_community"],$HTTP_GET_VARS["snmp_oid"],$HTTP_GET_VARS["value_type"],$HTTP_GET_VARS["trapper_hosts"]);
show_messages($result,"Item updated","Cannot update item");
unset($itemid);
}
if($HTTP_GET_VARS["register"]=="changestatus")
{
$result=update_item_status($HTTP_GET_VARS["itemid"],$HTTP_GET_VARS["status"]);
show_messages($result,"Status of item changed","Cannot change item status");
unset($HTTP_GET_VARS["itemid"]);
}
if($HTTP_GET_VARS["register"]=="add")
{
$result=add_item($HTTP_GET_VARS["description"],$HTTP_GET_VARS["key"],$HTTP_GET_VARS["hostid"],$HTTP_GET_VARS["delay"],$HTTP_GET_VARS["history"],$HTTP_GET_VARS["status"],$HTTP_GET_VARS["type"],$HTTP_GET_VARS["snmp_community"],$HTTP_GET_VARS["snmp_oid"],$HTTP_GET_VARS["value_type"],$HTTP_GET_VARS["trapper_hosts"]);
show_messages($result,"Item added","Cannot add item");
unset($HTTP_GET_VARS["itemid"]);
}
if($HTTP_GET_VARS["register"]=="delete")
{
$result=delete_item($HTTP_GET_VARS["itemid"]);
show_messages($result,"Item deleted","Cannot delete item");
unset($itemid);
}
}
?>
show_table_header_begin();
echo "CONFIGURATION OF ITEMS";
show_table_v_delimiter();
?>
$result=DBselect("select hostid,host from hosts order by host");
while($row=DBfetch($result))
{
if(!check_right("Host","R",$row["hostid"]))
{
continue;
}
if(isset($HTTP_GET_VARS["hostid"]) && ($HTTP_GET_VARS["hostid"] == $row["hostid"]))
{
echo "[";
}
echo "".$row["host"]."";
if(isset($HTTP_GET_VARS["hostid"]) && ($HTTP_GET_VARS["hostid"] == $row["hostid"]))
{
echo "]";
}
echo " ";
}
show_table_header_end();
$lasthost="";
if(isset($HTTP_GET_VARS["hostid"])&&!isset($HTTP_GET_VARS["itemid"]))
{
$result=DBselect("select h.host,i.key_,i.itemid,i.description,h.port,i.delay,i.history,i.lastvalue,i.lastclock,i.status,i.lastdelete,i.nextcheck,h.hostid from hosts h,items i where h.hostid=i.hostid and h.hostid=".$HTTP_GET_VARS["hostid"]." order by h.host,i.key_,i.description");
$col=0;
while($row=DBfetch($result))
{
if(!check_right("Item","R",$row["itemid"]))
{
continue;
}
if($lasthost != $row["host"])
{
if($lasthost != "")
{
echo "
";
}
echo "
";
show_table_header("".$row["host"]."");
echo "
| Id | "; echo "Host | "; echo "Key | "; echo "Description | "; echo "Delay | "; echo "History | "; echo "Shortname | "; echo "Status | "; echo "Actions | "; echo "|
| ".$row["itemid"]." | "; echo "".$row["host"]." | "; echo "".$row["key_"]." | "; echo "".$row["description"]." | "; echo "".$row["delay"]." | "; echo "".$row["history"]." | "; echo "".$row["host"].":".$row["key_"]." | "; echo ""; if(isset($HTTP_GET_VARS["hostid"])) { switch($row["status"]) { case 0: echo "Active"; break; case 1: echo "Not active"; break; case 2: echo "Trapper"; break; case 3: echo "Not supported"; break; default: echo "$status Unknown"; } } else { switch($row["status"]) { case 0: echo "Active"; break; case 1: echo "Not active"; break; case 2: echo "Trapper"; break; case 3: echo "Not supported"; break; default: echo "$status Unknown"; } } echo " | "; if(check_right("Item","U",$row["itemid"])) { echo "Change | "; } else { echo "Change | "; } echo "