0 && DBnum_rows($graph_items) < 1) { return delete_graph($graph["graphid"]); } } return $result; } function move_up_graph_item($gitemid) { if($gitemid<=0) return; $gitem = get_graphitem_by_gitemid($gitemid); $graph = get_graph_by_gitemid($gitemid); $childs = get_graphs_by_templateid($graph["graphid"]); while($child = DBfetch($childs)) { $chd_gitems = get_graphitems_by_graphid($child["graphid"]); while($chd_gitem = DBfetch($chd_gitems)) { if(cmp_graphitems($gitem, $chd_gitem)) continue; // recursion $result = move_up_graph_item($chd_gitem["gitemid"]); if(!$result) return $reslut; break; } } $result = DBexecute("update graphs_items set sortorder=sortorder-1". " where sortorder>0 and gitemid=$gitemid"); if($result) { $item = get_item_by_itemid($gitem["itemid"]); info("Sort order updated for item '".$item["description"]."'". " in graph '".$graph["name"]."'"); } return $result; } function move_down_graph_item($gitemid) { if($gitemid<=0) return; $gitem = get_graphitem_by_gitemid($gitemid); $graph = get_graph_by_gitemid($gitemid); $childs = get_graphs_by_templateid($graph["graphid"]); while($child = DBfetch($childs)) { $chd_gitems = get_graphitems_by_graphid($child["graphid"]); while($chd_gitem = DBfetch($chd_gitems)) { if(cmp_graphitems($gitem, $chd_gitem)) continue; // recursion $result = move_down_graph_item($chd_gitem["gitemid"]); if(!$result) return $reslut; break; } } $result = DBexecute("update graphs_items set sortorder=sortorder+1". " where sortorder<100 and gitemid=$gitemid"); if($result) { $item = get_item_by_itemid($gitem["itemid"]); info("Sort order updated for item '".$item["description"]."'". " in graph '".$graph["name"]."'"); } return $result; } function delete_template_graphs_by_hostid($hostid) { $db_graphs = get_graphs_by_hostid($hostid); while($db_graph = DBfetch($db_graphs)) { if($db_graph["templateid"] == 0) continue; delete_graph($db_graph["graphid"]); } } function sync_graphs_with_templates($hostid) { $host = get_host_by_hostid($hostid); $db_graphs = get_graphs_by_hostid($host["templateid"]); while($db_graph = DBfetch($db_graphs)) { copy_graph_to_host($db_graph["graphid"], $hostid); } } function copy_graph_to_host($graphid, $hostid) { $db_graph = get_graph_by_graphid($graphid); $new_graphid = add_graph($db_graph["name"],$db_graph["width"],$db_graph["height"], $db_graph["yaxistype"],$db_graph["yaxismin"],$db_graph["yaxismax"],$graphid); if(!$new_graphid) return $new_graphid; $result = copy_graphitems_for_host($graphid, $new_graphid, $hostid); if(!$result) { delete_graph($graphid); } return $result; } function copy_graphitems_for_host($src_graphid,$dist_graphid,$hostid) { $src_graphitems=get_graphitems_by_graphid($src_graphid); while($src_graphitem=DBfetch($src_graphitems)) { $src_item=get_item_by_itemid($src_graphitem["itemid"]); $host_items=get_items_by_hostid($hostid); $item_exist=0; while($host_item=DBfetch($host_items)) { if($src_item["key_"]!=$host_item["key_"]) continue; $item_exist=1; $host_itemid=$host_item["itemid"]; $result = add_item_to_graph($dist_graphid,$host_itemid,$src_graphitem["color"], $src_graphitem["drawtype"],$src_graphitem["sortorder"], $src_graphitem["yaxisside"]); if(!$result) return $result; break; } if($item_exist==0) return FALSE; } return TRUE; } function navigation_bar_calc() { $workingperiod = 3600; if(!isset($_REQUEST["period"])) $_REQUEST["period"]=3600; if(!isset($_REQUEST["from"])) $_REQUEST["from"]=0; if(isset($_REQUEST["inc"])) $workingperiod= $_REQUEST["period"]+$_REQUEST["inc"]; if(isset($_REQUEST["dec"])) $workingperiod= $workingperiod-$_REQUEST["dec"]; //if(isset($_REQUEST["inc"])) $_REQUEST["period"]= $_REQUEST["period"]+$_REQUEST["inc"]; //if(isset($_REQUEST["dec"])) $_REQUEST["period"]= $_REQUEST["period"]-$_REQUEST["dec"]; if(isset($_REQUEST["left"])) $_REQUEST["from"]= $_REQUEST["from"]+$_REQUEST["left"]; if(isset($_REQUEST["right"])) $_REQUEST["from"]= $_REQUEST["from"]-$_REQUEST["right"]; //unset($_REQUEST["inc"]); //unset($_REQUEST["dec"]); unset($_REQUEST["left"]); unset($_REQUEST["right"]); if($_REQUEST["from"]<=0) $_REQUEST["from"]=0; if($_REQUEST["period"]<=0) $_REQUEST["period"]=3600; if(isset($_REQUEST["reset"])) { $_REQUEST["period"]=3600; $_REQUEST["from"]=0; $workingperiod=3600; } return $workingperiod; } function navigation_bar($url) { $h1=S_NAVIGATE; $h2=S_PERIOD.SPACE; $h2=$h2.""; $h2=$h2.""; $h2=$h2.""; $h2=$h2.SPACE.S_MOVE.SPACE; $h2=$h2.""; $h2=$h2.""; $h2=$h2.SPACE; $h2=$h2.""; $h2=$h2.SPACE; $h2=$h2.""; $h2=$h2.""; if(isset($_REQUEST["graphid"])&&($_REQUEST["graphid"]!=0)) { $h2=$h2.""; } if(isset($_REQUEST["screenid"])&&($_REQUEST["screenid"]!=0)) { $h2=$h2.""; } if(isset($_REQUEST["itemid"])&&($_REQUEST["itemid"]!=0)) { $h2=$h2.""; } if(isset($_REQUEST["action"])) { $h2=$h2.""; } if(isset($_REQUEST["from"])) { $h2=$h2.""; } if(isset($_REQUEST["fullscreen"])) { $h2=$h2.""; } show_header2($h1,$h2,"
","
"); return; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; echo "
"; echo "".S_PERIOD.":".SPACE; $hour=3600; $a=array(S_1H=>3600,S_2H=>2*3600,S_4H=>4*3600,S_8H=>8*3600,S_12H=>12*3600, S_24H=>24*3600,S_WEEK_SMALL=>7*24*3600,S_MONTH_SMALL=>31*24*3600,S_YEAR_SMALL=>365*24*3600); foreach($a as $label=>$sec) { echo "["; if($_REQUEST["period"]>$sec) { $tmp=$_REQUEST["period"]-$sec; echo("-"); } else { echo "-"; } echo(""); echo($label.""); $tmp=$_REQUEST["period"]+$sec; echo("+"); echo "]".SPACE; } echo("
"); echo "
"; echo "".nbsp(S_KEEP_PERIOD).":".SPACE; if($_REQUEST["keep"] == 1) { echo("[".S_ON_C."]"); } else { echo("[".S_OFF_C."]"); } echo "
"; if(isset($_REQUEST["stime"])) { echo "
" ; echo "".S_MOVE.":".SPACE; $day=24; // $a already defined $a=array("1h"=>1,"2h"=>2,"4h"=>4,"8h"=>8,"12h"=>12, "24h"=>24,"week"=>7*24,"month"=>31*24,"year"=>365*24); foreach($a as $label=>$hours) { echo "["; $stime=$_REQUEST["stime"]; $tmp=mktime(substr($stime,8,2),substr($stime,10,2),0,substr($stime,4,2),substr($stime,6,2),substr($stime,0,4)); $tmp=$tmp-3600*$hours; $tmp=date("YmdHi",$tmp); echo("-"); echo($label); $stime=$_REQUEST["stime"]; $tmp=mktime(substr($stime,8,2),substr($stime,10,2),0,substr($stime,4,2),substr($stime,6,2),substr($stime,0,4)); $tmp=$tmp+3600*$hours; $tmp=date("YmdHi",$tmp); echo("+"); echo "]".SPACE; } echo("
"); } else { echo "
"; echo "".S_MOVE.":".SPACE; $day=24; // $a already defined $a=array("1h"=>1,"2h"=>2,"4h"=>4,"8h"=>8,"12h"=>12, "24h"=>24,"week"=>7*24,"month"=>31*24,"year"=>365*24); foreach($a as $label=>$hours) { echo "["; $tmp=$_REQUEST["from"]+$hours; echo("-"); echo($label); if($_REQUEST["from"]>=$hours) { $tmp=$_REQUEST["from"]-$hours; echo("+"); } else { echo "+"; } echo "]".SPACE; } echo("
"); } echo "
"; echo "
"; echo ""; echo ""; if(isset($_REQUEST["stime"])) { echo ""; } else { echo ""; } echo SPACE; echo ""; echo "
"; echo "
"; } ?>