diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2003-03-23 09:21:41 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2003-03-23 09:21:41 +0000 |
| commit | daa5481f0be02ef2aafba98cb9b8cd80a3ec5387 (patch) | |
| tree | 449477321d479805a2da303d49018febe27a0277 /frontends/php | |
| parent | c5fe18e5fcf909aee06437c7a89a2adcc2a25bd0 (diff) | |
| download | zabbix-daa5481f0be02ef2aafba98cb9b8cd80a3ec5387.tar.gz zabbix-daa5481f0be02ef2aafba98cb9b8cd80a3ec5387.tar.xz zabbix-daa5481f0be02ef2aafba98cb9b8cd80a3ec5387.zip | |
Support for screen builder. Thanks to Arturs Aboltins. (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@714 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/include/config.inc.php | 59 | ||||
| -rw-r--r-- | frontends/php/screenconf.php | 130 | ||||
| -rw-r--r-- | frontends/php/screenedit.php | 150 | ||||
| -rw-r--r-- | frontends/php/screens.php | 114 |
4 files changed, 453 insertions, 0 deletions
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 24b5de9e..d9cd38cd 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -3912,4 +3912,63 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; } } + + function add_screen($name,$cols,$rows) + { + global $ERROR_MSG; + + if(!check_right("Screen","A",0)) + { + $ERROR_MSG="Insufficient permissions"; + return 0; + } + + $sql="insert into screens (name,cols,rows) values ('$name',$cols,$rows)"; + return DBexecute($sql); + } + + function update_screen($scid,$name,$cols,$rows) + { + global $ERROR_MSG; + + if(!check_right("Screen","U",0)) + { + $ERROR_MSG="Insufficient permissions"; + return 0; + } + + $sql="update screens set name='$name',cols=$cols,rows=$rows where scid=$scid"; + return DBexecute($sql); + } + + function delete_screen($scid) + { + $sql="delete from screens_items where scid=$scid"; + $result=DBexecute($sql); + if(!$result) + { + return $result; + } + $sql="delete from screens where scid=$scid"; + return DBexecute($sql); + } + + function add_screen_item($scid,$x,$y,$graphid,$width,$height) + { + $sql="insert into screens_items (scid,x,y,graphid,width,height) values ($scid,$x,$y,$graphid,$width,$height)"; + return DBexecute($sql); + } + + function update_screen_item($scitemid,$graphid,$width,$height) + { + $sql="update screens_items set graphid=$graphid,width=$width,height=$height where scitemid=$scitemid"; + return DBexecute($sql); + } + + + function delete_screen_item($scitemid) + { + $sql="delete from screens_items where scitemid=$scitemid"; + return DBexecute($sql); + } ?> diff --git a/frontends/php/screenconf.php b/frontends/php/screenconf.php new file mode 100644 index 00000000..0817181e --- /dev/null +++ b/frontends/php/screenconf.php @@ -0,0 +1,130 @@ +<?php + include "include/config.inc.php"; + $page["title"] = "Screens"; + $page["file"] = "screenconf.php"; + show_header($page["title"],0,0); +?> + +<?php + show_table_header("CONFIGURATION OF SCREENS"); + echo "<br>"; +?> + +<?php + if(!check_right("Screen","U",0)) + { +// show_table_header("<font color=\"AA0000\">No permissions !</font>"); +// show_footer(); +// exit; + } +?> + +<?php + if(isset($HTTP_GET_VARS["register"])) + { + if($HTTP_GET_VARS["register"]=="add") + { + $result=add_screen($HTTP_GET_VARS["name"],$HTTP_GET_VARS["cols"],$HTTP_GET_VARS["rows"]); + show_messages($result,"Screen added","Cannot add screen"); + } + if($HTTP_GET_VARS["register"]=="update") + { + $result=update_screen($HTTP_GET_VARS["scid"],$HTTP_GET_VARS["name"],$HTTP_GET_VARS["cols"],$HTTP_GET_VARS["rows"]); + show_messages($result,"Screen updated","Cannot update screen"); + } + if($HTTP_GET_VARS["register"]=="delete") + { + $result=delete_screen($HTTP_GET_VARS["scid"]); + show_messages($result,"Screen deleted","Cannot delete screen"); + unset($HTTP_GET_VARS["scid"]); + } + } +?> + +<?php + show_table_header("SCREENS"); + echo "<TABLE BORDER=0 COLS=4 WIDTH=100% BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>"; + echo "<TD WIDTH=5% NOSAVE><B>Id</B></TD>"; + echo "<TD WIDTH=10% NOSAVE><B>Name</B></TD>"; + echo "<TD WIDTH=10% NOSAVE><B>Columns</B></TD>"; + echo "<TD WIDTH=10% NOSAVE><B>Rows</B></TD>"; + echo "<TD WIDTH=10% NOSAVE><B>Actions</B></TD>"; + echo "</TR>"; + + $result=DBselect("select scid,name,cols,rows from screens order by name"); + $col=0; + while($row=DBfetch($result)) + { + if(!check_right("Screen","R",$row["scid"])) + { + continue; + } + if($col++%2==0) { echo "<TR BGCOLOR=#EEEEEE>"; } + else { echo "<TR BGCOLOR=#DDDDDD>"; } + + echo "<TD>".$row["scid"]."</TD>"; + echo "<TD><a href=\"screenedit.php?scid=".$row["scid"]."\">".$row["name"]."</a></TD>"; + echo "<TD>".$row["cols"]."</TD>"; + echo "<TD>".$row["rows"]."</TD>"; + echo "<TD><A HREF=\"screenconf.php?scid=".$row["scid"]."#form\">Change</A> - "; + echo "<A HREF=\"screenconf.php?register=delete&scid=".$row["scid"]."\">Delete</A></TD>"; + echo "</TR>"; + } + echo "</TABLE>"; +?> + +<?php + echo "<a name=\"form\"></a>"; + + if(isset($HTTP_GET_VARS["scid"])) + { + $result=DBselect("select scid,name,cols,rows from screens g where scid=".$HTTP_GET_VARS["scid"]); + $row=DBfetch($result); + $name=$row["name"]; + $cols=$row["cols"]; + $rows=$row["rows"]; + } + else + { + $name=""; + $cols=1; + $rows=1; + } + + echo "<br>"; + show_table2_header_begin(); + echo "New screen"; + + show_table2_v_delimiter(); + echo "<form method=\"get\" action=\"screenconf.php\">"; + if(isset($HTTP_GET_VARS["scid"])) + { + echo "<input class=\"biginput\" name=\"scid\" type=\"hidden\" value=".$HTTP_GET_VARS["scid"].">"; + } + echo "Name"; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"name\" value=\"$name\" size=32>"; + + show_table2_v_delimiter(); + echo "Columns"; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"cols\" size=5 value=\"$cols\">"; + + show_table2_v_delimiter(); + echo "Rows"; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"rows\" size=5 value=\"$rows\">"; + + show_table2_v_delimiter2(); + echo "<input type=\"submit\" name=\"register\" value=\"add\">"; + if(isset($HTTP_GET_VARS["scid"])) + { + echo "<input type=\"submit\" name=\"register\" value=\"update\">"; + } + + show_table2_header_end(); +?> + +<?php + show_footer(); +?> diff --git a/frontends/php/screenedit.php b/frontends/php/screenedit.php new file mode 100644 index 00000000..6f7e82e2 --- /dev/null +++ b/frontends/php/screenedit.php @@ -0,0 +1,150 @@ +<?php + include "include/config.inc.php"; + $page["title"] = "Configuration of screen"; + $page["file"] = "screenedit.php"; + show_header($page["title"],0,0); +?> + +<?php + show_table_header("CONFIGURATION OF SCREEN"); + echo "<br>"; +?> + +<?php + if(!check_right("Screen","R",$HTTP_GET_VARS["scid"])) + { + show_table_header("<font color=\"AA0000\">No permissions !</font>"); + show_footer(); + exit; + } +?> + +<?php + if(isset($HTTP_GET_VARS["register"])) + { + if($HTTP_GET_VARS["register"]=="add") + { + $result=add_screen_item($HTTP_GET_VARS["scid"],$HTTP_GET_VARS["x"],$HTTP_GET_VARS["y"],$HTTP_GET_VARS["graphid"],$HTTP_GET_VARS["width"],$HTTP_GET_VARS["height"]); + show_messages($result,"Item added","Cannot add item"); + } + if($HTTP_GET_VARS["register"]=="delete") + { + $result=delete_screen_item($HTTP_GET_VARS["scitemid"]); + show_messages($result,"Item deleted","Cannot delete item"); + unset($gitemid); + } + if($HTTP_GET_VARS["register"]=="update") + { + $result=update_screen_item($HTTP_GET_VARS["scitemid"],$HTTP_GET_VARS["graphid"],$HTTP_GET_VARS["width"],$HTTP_GET_VARS["height"]); + show_messages($result,"Item updated","Cannot update item"); + } + + } +?> + +<?php + $scid=$HTTP_GET_VARS["scid"]; + $result=DBselect("select name,cols,rows from screens where scid=$scid"); + $row=DBfetch($result); + show_table_header($row["name"]); + echo "<TABLE BORDER=1 COLS=".$row["cols"]." align=center WIDTH=100% BGCOLOR=\"#CCCCCC\""; + for($r=0;$r<$row["rows"];$r++) + { + echo "<TR>"; + for($c=0;$c<$row["cols"];$c++) + { + echo "<TD align=\"center\">\n"; + + echo "<a name=\"form\"></a>"; + echo "<form method=\"get\" action=\"screenedit.php\">"; + $iresult=DBSelect("select * from screens_items where scid=$scid and x=$c and y=$r"); + if($iresult) + { + $irow=DBfetch($iresult); + $scitemid=$irow["scitemid"]; + $graphid=$irow["graphid"]; + $width=$irow["width"]; + $height=$irow["height"]; + } + else + { + $scitemid=0; + $graphid=0; + $width=100; + $height=50; + } + + if(($HTTP_GET_VARS["register"]=="edit")&&($HTTP_GET_VARS["x"]==$c)&&($HTTP_GET_VARS["y"]==$r)) + { + show_table2_header_begin(); + echo "Screen item configuration"; + show_table2_v_delimiter(); + echo "<input name=\"scid\" type=\"hidden\" value=$scid>"; + echo "<input name=\"x\" type=\"hidden\" value=$c>"; + echo "<input name=\"y\" type=\"hidden\" value=$r>"; + echo "<input name=\"scitemid\" type=\"hidden\" value=$scitemid>"; + + echo "Graph name"; + show_table2_h_delimiter(); + + if($graphid!=0) + { + $result=DBselect("select name from graphs where graphid=$graphid"); + if($result) $name=DBget_field($result,0,0); + else $name="(none)"; + } + else $name="(none)"; + + $result=DBselect("select graphid,name from graphs"); + echo "<select name=\"graphid\" size=1>"; + echo "<OPTION VALUE='$graphid'>$name"; + + for($i=0;$i<DBnum_rows($result);$i++) + { + $name_=DBget_field($result,$i,1); + $graphid_=DBget_field($result,$i,0); + echo "<OPTION VALUE='$graphid_'>$name_"; + } + echo "</SELECT>"; + + show_table2_v_delimiter(); + echo "Width"; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"width\" size=5 value=\"$width\">"; + show_table2_v_delimiter(); + echo "Height"; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"height\" size=5 value=\"$height\">"; + + show_table2_v_delimiter2(); + echo "<input type=\"submit\" name=\"register\" value=\"add\">"; + if($scitemid!=0) + { + echo "<input type=\"submit\" name=\"register\" value=\"update\">"; + } + echo "<input type=\"submit\" name=\"register\" value=\"delete\">"; + + show_table2_header_end(); + } + else if($graphid!=0) + { + echo "<a href=screenedit.php?register=edit&scid=$scid&x=$c&y=$r><img src='chart2.php?graphid=$graphid&width=$width&height=$height&period=3600'></a>"; + } + else + { + echo "<a href=screenedit.php?register=edit&scid=$scid&x=$c&y=$r>Empty</a>"; + } + echo "</form>\n"; + + echo "</TD>"; + } + echo "</TR>\n"; + } + echo "</TABLE>"; + + +?> + +<?php + show_footer(); +?> diff --git a/frontends/php/screens.php b/frontends/php/screens.php new file mode 100644 index 00000000..9628f5d0 --- /dev/null +++ b/frontends/php/screens.php @@ -0,0 +1,114 @@ +<?php + include "include/config.inc.php"; + $page["title"] = "User defined screens"; + $page["file"] = "screens.php"; + + $nomenu=0; + if(isset($HTTP_GET_VARS["fullscreen"])) + { + $nomenu=1; + } + if(isset($HTTP_GET_VARS["scid"])) + { + show_header($page["title"],60,$nomenu); + } + else + { + show_header($page["title"],0,$nomenu); + } +?> + +<?php + if(!isset($HTTP_GET_VARS["fullscreen"])) + { + show_table_header_begin(); + echo "SCREENS"; + + show_table_v_delimiter(); + + echo "<font size=2>"; + + $result=DBselect("select scid,name,cols,rows from screens order by name"); + while($row=DBfetch($result)) + { + if(!check_right("Screen","R",$row["scid"])) + { + continue; + } + if( isset($HTTP_GET_VARS["scid"]) && ($HTTP_GET_VARS["scid"] == $row["scid"]) ) + { + echo "<b>["; + } + echo "<a href='screens.php?scid=".$row["scid"]."'>".$row["name"]."</a>"; + if(isset($HTTP_GET_VARS["scid"]) && ($HTTP_GET_VARS["scid"] == $row["scid"]) ) + { + echo "]</b>"; + } + echo " "; + } + + if(DBnum_rows($result) == 0) + { + echo "No screens to display"; + } + + echo "</font>"; + show_table_header_end(); + echo "<br>"; + } + +?> + +<?php + if(isset($HTTP_GET_VARS["scid"])) + { + $scid=$HTTP_GET_VARS["scid"]; + $result=DBselect("select name,cols,rows from screens where scid=$scid"); + $row=DBfetch($result); + echo "<TABLE BORDER=1 COLS=".$row["cols"]." align=center WIDTH=100% BGCOLOR=\"#FFFFFF\""; + for($r=0;$r<$row["rows"];$r++) + { + echo "<TR>"; + for($c=0;$c<$row["cols"];$c++) + { + echo "<TD align=\"center\">\n"; + + echo "<a name=\"form\"></a>"; + echo "<form method=\"get\" action=\"screenedit.php\">"; + $iresult=DBSelect("select * from screens_items where scid=$scid and x=$c and y=$r"); + if($iresult) + { + $irow=DBfetch($iresult); + $scitemid=$irow["scitemid"]; + $graphid=$irow["graphid"]; + $width=$irow["width"]; + $height=$irow["height"]; + } + else + { + $scitemid=0; + $graphid=0; + $width=100; + $height=50; + } + + if($graphid!=0) + { + echo "<a href=charts.php?graphid=$graphid><img src='chart2.php?graphid=$graphid&width=$width&height=$height&period=3600' border=0></a>"; + } + echo "</form>\n"; + echo "</TD>"; + } + echo "</TR>\n"; + } + echo "</TABLE>"; + } + else + { + show_table_header("Please select screen to display"); + } +?> + +<?php + show_footer(); +?> |
