From 36f804cfecab25c55e71e3d2f20ffbc35ee5a5fb Mon Sep 17 00:00:00 2001 From: hugetoad Date: Thu, 29 Mar 2001 17:47:53 +0000 Subject: config.inc moved to include/. Added .htaccess file to prevent read access to config.inc. PHP pages updated with new path to the file. git-svn-id: svn://svn.zabbix.com/trunk@14 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/actions.html | 2 +- frontends/php/alarms.html | 2 +- frontends/php/alerts.html | 2 +- frontends/php/chart.html | 2 +- frontends/php/config.html | 2 +- frontends/php/config.inc | 1165 -------------------------------------- frontends/php/history.html | 2 +- frontends/php/hosts.html | 2 +- frontends/php/include/.htaccess | 7 + frontends/php/include/config.inc | 1165 ++++++++++++++++++++++++++++++++++++++ frontends/php/index.html | 2 +- frontends/php/items.html | 2 +- frontends/php/latest.html | 2 +- frontends/php/latestalarms.html | 2 +- frontends/php/media.html | 2 +- frontends/php/queue.html | 2 +- frontends/php/tr_status.html | 2 +- frontends/php/triggers.html | 2 +- frontends/php/users.html | 2 +- 19 files changed, 1188 insertions(+), 1181 deletions(-) delete mode 100644 frontends/php/config.inc create mode 100644 frontends/php/include/.htaccess create mode 100644 frontends/php/include/config.inc (limited to 'frontends/php') diff --git a/frontends/php/actions.html b/frontends/php/actions.html index 155f8bc7..3440775f 100644 --- a/frontends/php/actions.html +++ b/frontends/php/actions.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/alarms.html b/frontends/php/alarms.html index 5a9020ba..08757bb4 100644 --- a/frontends/php/alarms.html +++ b/frontends/php/alarms.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/alerts.html b/frontends/php/alerts.html index 85ae9907..c152fc50 100644 --- a/frontends/php/alerts.html +++ b/frontends/php/alerts.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/chart.html b/frontends/php/chart.html index 03756ae5..e4e20602 100644 --- a/frontends/php/chart.html +++ b/frontends/php/chart.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/config.inc b/frontends/php/config.inc deleted file mode 100644 index 75c48082..00000000 --- a/frontends/php/config.inc +++ /dev/null @@ -1,1165 +0,0 @@ - - - - - - -"; - } -?> - <? echo $title; ?> - - - - - - - -
- - - - - - - - - - - - - - - -
- - LATEST VALUES - - - - STATUS OF TRIGGERS - - - - QUEUE - - - - ALARMS - - - - ALERTS - -
- - CONFIG - - - - USERS - - - - HOSTS - - - - ITEMS - - - - TRIGGERS - -
-
- -
-$from and clock<$till order by clock",$mysql); - - echo "
";
-		while($row=mysql_fetch_row($result))
-		{
-			$clock=$row[0];
-			$value=$row[1];
-			echo date("Y-m-d H:i:s",$clock);
-			echo "\t$clock\t$value\n";
-		}
-	}
- 
-
-	# Translate {10}>10 to something like localhost:procload.last(0)>10
-
-	function	explode_exp ($expression, $html)
-	{
-		global	$mysql;
-
-#		echo "EXPRESSION:",$expression,"
"; - - $functionid=''; - $exp=''; - for($i=0;$i".$row1[0].":".$row1[1].".".$row1[2]."(".$row1[3].")}"; - } - continue; - } - if($state == "FUNCTIONID") - { - $functionid=$functionid.$expression[$i]; - continue; - } - $exp=$exp.$expression[$i]; - } -# echo "EXP:",$exp,"
"; - return $exp; - } - - # Translate localhost:procload.last(0)>10 to {12}>10 - - function implode_exp ($expression, $triggerid) - { - global $mysql; - - $exp=''; - for($i=0;$i"; -# echo "KEY:$key
"; -# echo "FUNCTION:$function
"; -# echo "PARAMETER:$parameter
"; - $state=''; - - $sql="select i.itemid from items i,hosts h where i.key_='$key' and h.host='$host' and h.hostid=i.hostid"; -# echo $sql,"
"; - $res=mysql_query($sql,$mysql); - $row=mysql_fetch_row($res); - - $itemid=$row[0]; -# echo "ITEMID:$itemid
"; - -# $sql="select functionid from functions where function='$function' and parameter=$parameter"; -# echo $sql,"
"; -# $res=mysql_query($sql,$mysql); -# $row=mysql_fetch_row($res); - -# if($row) -# { -# $functionid=$row[0]; -# } -# else -# { - $sql="insert into functions (functionid,itemid,triggerid,function,parameter) values (NULL,$itemid,$triggerid,'$function',$parameter)"; -# echo $sql,"
"; - $res=mysql_query($sql,$mysql); - $functionid=mysql_insert_id($mysql); -# } -# echo "FUNCTIONID:$functionid
"; - - $exp=$exp.'{'.$functionid.'}'; - - continue; - } - if($expression[$i] == '(') - { - if($state == "FUNCTION") - { - $state='PARAMETER'; - continue; - } - } - if($expression[$i] == ')') - { - if($state == "PARAMETER") - { - $state=''; - continue; - } - } - if($expression[$i] == ':') - { - $state="KEY"; - continue; - } - if($expression[$i] == '.') - { - if($state == "KEY") - { - $state="FUNCTION"; - continue; - } - } - if($state == "HOST") - { - $host=$host.$expression[$i]; - continue; - } - if($state == "KEY") - { - $key=$key.$expression[$i]; - continue; - } - if($state == "FUNCTION") - { - $function=$function.$expression[$i]; - continue; - } - if($state == "PARAMETER") - { - $parameter=$parameter.$expression[$i]; - continue; - } - $exp=$exp.$expression[$i]; - } - return $exp; - } - - # Update Trigger status - - function update_trigger_status($triggerid,$status) - { - global $mysql; - - $sql="update triggers set istrue=$status where triggerid=$triggerid"; - $result=mysql_query($sql,$mysql); - } - - # Update Item status - - function update_item_status($itemid,$status) - { - global $mysql; - - $sql="update items set status=$status where itemid=$itemid"; - $result=mysql_query($sql,$mysql); - } - - # Update Host status - - function update_host_status($hostid,$status) - { - global $mysql; - - $sql="update hosts set status=$status where hostid=$hostid"; - $result=mysql_query($sql,$mysql); - } - - # Update Item definition - - function update_item($itemid,$description,$key,$hostid,$delay,$history,$status) - { - global $mysql; - - $sql="update items set description='$description',key_='$key',hostid=$hostid,delay=$delay,history=$history,lastdelete=0,nextcheck=0,status=$status where itemid=$itemid"; - $result=mysql_query($sql,$mysql); - } - - # Add Action - - function add_action( $triggerid, $userid, $good, $delay, $subject, $message ) - { - global $mysql; - - $sql="insert into actions (actionid,triggerid,userid,good,delay,nextcheck,subject,message) values (NULL,$triggerid,$userid,$good,$delay,0,'$subject','$message')"; - $result=mysql_query($sql,$mysql); - } - - # Update Action - - function update_action( $actionid, $userid, $good, $delay, $subject, $message ) - { - global $mysql; - - $sql="update actions set userid=$userid,good=$good,delay=$delay,nextcheck=0,subject='$subject',message='$message' where actionid=$actionid"; - $result=mysql_query($sql,$mysql); - } - - # Delete Action by userid - - function delete_actions_by_userid( $userid ) - { - global $mysql; - - $sql="delete from actions where userid=$userid"; - $result=mysql_query($sql,$mysql); - } - - # Delete Action - - function delete_action( $actionid ) - { - global $mysql; - - $sql="delete from actions where actionid=$actionid"; - $result=mysql_query($sql,$mysql); - } - - # Delete from History - - function delete_history_by_itemid( $itemid ) - { - global $mysql; - - - $sql="delete from history where itemid=$itemid"; - $result=mysql_query($sql,$mysql); - } - - # Add Item definition - - function add_item($description,$key,$hostid,$delay,$history,$status) - { - global $mysql; - - $sql="insert into items (itemid,description,key_,hostid,delay,history,lastdelete,nextcheck,status) values (NULL,'$description','$key',$hostid,$delay,$history,0,0,$status)"; - $result=mysql_query($sql,$mysql); - return mysql_insert_id($mysql); - } - - # Delete Function definition - - function delete_function_by_triggerid($triggerid) - { - global $mysql; - - $sql="delete from functions where triggerid=$triggerid"; - $result=mysql_query($sql,$mysql); - } - - # Delete Function and Trigger definitions by itemid - - function delete_triggers_functions_by_itemid($itemid) - { - global $mysql; - - $sql="select triggerid from functions where itemid=$itemid"; - $result=mysql_query($sql,$mysql); - while($row=mysql_fetch_row($result)) - { - delete_function_by_triggerid($row[0]); - } - - $sql="delete from functions where itemid=$itemid"; - $result=mysql_query($sql,$mysql); - } - - # Delete Item definition - - function delete_item($itemid) - { - global $mysql; - - $sql="delete from items where itemid=$itemid"; - $result=mysql_query($sql,$mysql); - - delete_triggers_functions_by_itemid($itemid); - delete_history_by_itemid($itemid); - } - - # Add alarm - - function add_alarm($triggerid,$istrue) - { - global $mysql; - - $now=mktime(); - $sql="insert into alarms(triggerid,clock,istrue) values($triggerid,$now,$istrue)"; - $result=mysql_query($sql,$mysql); - } - - # Add Trigger definition - - function add_trigger($expression,$description,$priority,$istrue,$comments) - { - global $mysql; - - $sql="insert into triggers (triggerid,description,priority,istrue,comments) values (NULL,'$description',$priority,$istrue,'$comments')"; -# echo $sql,"
"; - $result=mysql_query($sql,$mysql); - - $triggerid=mysql_insert_id($mysql); - - $expression=implode_exp($expression,$triggerid); - $sql="update triggers set expression='$expression' where triggerid=$triggerid"; -# echo $sql,"
"; - $result=mysql_query($sql,$mysql); - } - - # Delete Trigger definition - - function delete_trigger($triggerid) - { - global $mysql; - - $sql="delete from triggers where triggerid=$triggerid"; - $result=mysql_query($sql,$mysql); - - delete_function_by_triggerid($triggerid); - } - - # Update Trigger definition - - function update_trigger($triggerid,$expression,$description,$priority,$istrue,$comments) - { - global $mysql; - - delete_trigger($triggerid); - - $triggerid=add_trigger($expression,$description,$priority,$istrue,$comments); - } - - # Add User definition - - function add_user($name,$surname,$alias) - { - global $mysql; - - $sql="insert into users (userid,name,surname,alias) values (NULL,'$name','$surname','$alias')"; - $result=mysql_query($sql,$mysql); - - return $result; - } - - # Add Items and Triggers from template - - function add_from_templates($hostid,$platformid,$host) - { - global $mysql; - - $result=mysql_query("select itemtemplateid,description,key_,delay from items_template where platformid=$platformid",$mysql); - while($row=mysql_fetch_row($result)) - { - $itemtemplateid=$row[0]; - $description=$row[1]; - $key=$row[2]; - $delay=$row[3]; - - $itemid=add_item($description,$key,$hostid,$delay,24*3600,0); - - $result2=mysql_query("select triggertemplateid,description,expression from triggers_template where itemtemplateid=$itemtemplateid",$mysql); - while($row2=mysql_fetch_row($result2)) - { - $itemtemplateid=$row2[0]; - $description=$row2[1]; - $expression=$row2[2]; - - for($i=0;$i"; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo " "; - cr(); - } - - function show_table2_h_delimiter() - { - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo " "; - cr(); - } - - function show_table_v_delimiter() - { - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - } - - function show_table2_v_delimiter() - { - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - } - - function show_table2_v_delimiter2() - { - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - } - - - - function show_table2_header_begin() - { - echo "
"; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo "
"; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo "
"; - cr(); - echo " "; - cr(); - } - - function show_table_header_begin() - { - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo "
"; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo ""; - cr(); - echo "
"; - cr(); - echo " "; - cr(); - } - - function show_table2_header_end() - { - echo " "; - cr(); - echo "
"; - cr(); - echo "
"; - cr(); - echo ""; - cr(); - } - - function show_table_header_end() - { - echo "
"; - cr(); - echo "
"; - cr(); - echo "
"; - cr(); - } - - function show_table_header($title) - { - show_table_header_begin(); - cr(); - echo $title; - cr(); - show_table_header_end(); - cr(); - } - - # Show History Graph - - function show_history($itemid,$from,$period) - { - if (!isset($from)) - { - $from=0; - $till="NOW"; - } - else - { - $till=time(NULL)-$from*3600; - $till=date("d M - H:i:s",$till); - } - - echo "
"; - - if (!isset($period)) - { - $period=3600; - show_table_header("TILL $till (LAST HOUR)"); - } - else - { - $tmp=$period/3600; - show_table_header("TILL $till ($tmp HOURs)"); - } - echo("
"); - echo ""; - echo("
"); - - - // Start of <<< WEEK >>> - $tmp=$from+12*14; - echo("["); - echo("Week back] "); - - // Start of <<< 12h >>> - $tmp=$from+12; - echo("["); - echo("12h back] "); - // End of <<< 12h >>> - - // HOUR BACK - $tmp=$from+1; - echo("["); - echo("1h back] "); - - // Start of --- - $tmp=$period+3600; - echo("["); - echo("+1h] "); - - if ($period>3600) - { - $tmp=$period-3600; - echo("["); - echo("-1h] "); - } - else - { - echo("[-1h]"); - } - // End of ------ - - if ($from>0) // HOUR FORWARD - { - $tmp=$from-1; - echo("["); - echo("1h forward] "); - } - else - { - echo("[1h forward]"); - } - - - if ($From>0) // 12h FORWARD - { - $tmp=$from-12; - echo("["); - echo("12h forward] "); - } - else - { - echo("[12h forward]"); - } - - if ($From>0) // WEEK Forward - { - $tmp=$from-12*14; - echo("["); - echo("Week forward] "); - } - else - { - echo("[Week forward]"); - } - - echo("\n"); - } - - # Show history - function show_freehist($itemid,$period) - { - - echo "
"; - show_table2_header_begin(); - echo "Choose period"; - - show_table2_v_delimiter(); - echo "
"; - echo ""; - echo "Period in seconds"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter(); - echo "From (in hours)"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter2(); - echo "Press "; - echo " to see graph"; - - show_table2_header_end(); - - show_footer(); - } - - # Show in plain text - function show_plaintxt($itemid,$period) - { - show_table2_header_begin(); - echo "Data in plain text format"; - - show_table2_v_delimiter(); - echo ""; - echo ""; - echo ""; - echo "From: (yyyy/mm/dd - HH:MM)"; - show_table2_h_delimiter(); - echo "/"; - echo "/"; - echo " - "; - echo ":"; - echo ""; - - show_table2_v_delimiter(); - echo "Till: (yyyy/mm/dd - HH:MM)"; - show_table2_h_delimiter(); - echo "/"; - echo "/"; - echo " - "; - echo ":"; - echo ""; - - show_table2_v_delimiter2(); - echo "Press to see data in "; - echo ""; - - show_table2_header_end(); - - show_footer(); - } - - # Insert form for Item information - function insert_item_form($itemid) - { - global $mysql; - - if(isset($itemid)) - { - mysql_select_db("monitor"); - $result=mysql_query("select i.description, i.key_, h.host, h.port, i.delay, i.history, i.status from items i,hosts h where i.itemid=$itemid and h.hostid=i.hostid",$mysql); - $row=mysql_fetch_row($result); - - $description=$row[0]; - $key=$row[1]; - $host=$row[2]; - $port=$row[3]; - $delay=$row[4]; - $history=$row[5]; - $status=$row[6]; - } - if( !isset($port) ) - { - $port=10000; - } - if( !isset($delay) ) - { - $delay=30; - } - if( !isset($history) ) - { - $history=30*24*3600; - } - if( !isset($status) ) - { - $status=0; - } - - echo "
"; - - show_table2_header_begin(); - echo "Item configuration"; - - show_table2_v_delimiter(); - echo ""; - echo ""; - echo "Description"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter(); - echo "Host"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter(); - echo "Key"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter(); - echo "Delay"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter(); - echo "History"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter(); - echo "Status"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter2(); - echo ""; - if(isset($itemid)) - { - echo ""; - echo ""; - } - - show_table2_header_end(); -?> - - - - -
- - - - -"; - - show_table2_header_begin(); - echo "Trigger configuration"; - - show_table2_v_delimiter(); - echo "
"; - echo ""; - echo "Description"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter(); - echo "Expression"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter(); - echo "Priority"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter(); - echo "Comments"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter(); - echo "Disabled"; - show_table2_h_delimiter(); - echo ""; - - show_table2_v_delimiter2(); - echo ""; - if(isset($triggerid)) - { - echo ""; - echo ""; - } - show_table2_header_end(); - } - - - function show_footer() - { - echo ""; - echo ""; - echo "
"; - echo ""; - echo ""; - echo "
"; - echo ""; - echo "ZABBIX Copyright 2000,2001 by Alexei Vladishev"; - echo ""; - echo "
"; - echo "
"; - } -?> diff --git a/frontends/php/history.html b/frontends/php/history.html index 3259bee1..483bc928 100644 --- a/frontends/php/history.html +++ b/frontends/php/history.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/include/.htaccess b/frontends/php/include/.htaccess new file mode 100644 index 00000000..89b8ddb2 --- /dev/null +++ b/frontends/php/include/.htaccess @@ -0,0 +1,7 @@ +Order Deny,Allow +Deny from All + + +Order Deny,Allow +Deny from All + diff --git a/frontends/php/include/config.inc b/frontends/php/include/config.inc new file mode 100644 index 00000000..75c48082 --- /dev/null +++ b/frontends/php/include/config.inc @@ -0,0 +1,1165 @@ + + + + + + +"; + } +?> + <? echo $title; ?> + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + LATEST VALUES + + + + STATUS OF TRIGGERS + + + + QUEUE + + + + ALARMS + + + + ALERTS + +
+ + CONFIG + + + + USERS + + + + HOSTS + + + + ITEMS + + + + TRIGGERS + +
+
+ +
+$from and clock<$till order by clock",$mysql); + + echo "
";
+		while($row=mysql_fetch_row($result))
+		{
+			$clock=$row[0];
+			$value=$row[1];
+			echo date("Y-m-d H:i:s",$clock);
+			echo "\t$clock\t$value\n";
+		}
+	}
+ 
+
+	# Translate {10}>10 to something like localhost:procload.last(0)>10
+
+	function	explode_exp ($expression, $html)
+	{
+		global	$mysql;
+
+#		echo "EXPRESSION:",$expression,"
"; + + $functionid=''; + $exp=''; + for($i=0;$i".$row1[0].":".$row1[1].".".$row1[2]."(".$row1[3].")}"; + } + continue; + } + if($state == "FUNCTIONID") + { + $functionid=$functionid.$expression[$i]; + continue; + } + $exp=$exp.$expression[$i]; + } +# echo "EXP:",$exp,"
"; + return $exp; + } + + # Translate localhost:procload.last(0)>10 to {12}>10 + + function implode_exp ($expression, $triggerid) + { + global $mysql; + + $exp=''; + for($i=0;$i"; +# echo "KEY:$key
"; +# echo "FUNCTION:$function
"; +# echo "PARAMETER:$parameter
"; + $state=''; + + $sql="select i.itemid from items i,hosts h where i.key_='$key' and h.host='$host' and h.hostid=i.hostid"; +# echo $sql,"
"; + $res=mysql_query($sql,$mysql); + $row=mysql_fetch_row($res); + + $itemid=$row[0]; +# echo "ITEMID:$itemid
"; + +# $sql="select functionid from functions where function='$function' and parameter=$parameter"; +# echo $sql,"
"; +# $res=mysql_query($sql,$mysql); +# $row=mysql_fetch_row($res); + +# if($row) +# { +# $functionid=$row[0]; +# } +# else +# { + $sql="insert into functions (functionid,itemid,triggerid,function,parameter) values (NULL,$itemid,$triggerid,'$function',$parameter)"; +# echo $sql,"
"; + $res=mysql_query($sql,$mysql); + $functionid=mysql_insert_id($mysql); +# } +# echo "FUNCTIONID:$functionid
"; + + $exp=$exp.'{'.$functionid.'}'; + + continue; + } + if($expression[$i] == '(') + { + if($state == "FUNCTION") + { + $state='PARAMETER'; + continue; + } + } + if($expression[$i] == ')') + { + if($state == "PARAMETER") + { + $state=''; + continue; + } + } + if($expression[$i] == ':') + { + $state="KEY"; + continue; + } + if($expression[$i] == '.') + { + if($state == "KEY") + { + $state="FUNCTION"; + continue; + } + } + if($state == "HOST") + { + $host=$host.$expression[$i]; + continue; + } + if($state == "KEY") + { + $key=$key.$expression[$i]; + continue; + } + if($state == "FUNCTION") + { + $function=$function.$expression[$i]; + continue; + } + if($state == "PARAMETER") + { + $parameter=$parameter.$expression[$i]; + continue; + } + $exp=$exp.$expression[$i]; + } + return $exp; + } + + # Update Trigger status + + function update_trigger_status($triggerid,$status) + { + global $mysql; + + $sql="update triggers set istrue=$status where triggerid=$triggerid"; + $result=mysql_query($sql,$mysql); + } + + # Update Item status + + function update_item_status($itemid,$status) + { + global $mysql; + + $sql="update items set status=$status where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + } + + # Update Host status + + function update_host_status($hostid,$status) + { + global $mysql; + + $sql="update hosts set status=$status where hostid=$hostid"; + $result=mysql_query($sql,$mysql); + } + + # Update Item definition + + function update_item($itemid,$description,$key,$hostid,$delay,$history,$status) + { + global $mysql; + + $sql="update items set description='$description',key_='$key',hostid=$hostid,delay=$delay,history=$history,lastdelete=0,nextcheck=0,status=$status where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + } + + # Add Action + + function add_action( $triggerid, $userid, $good, $delay, $subject, $message ) + { + global $mysql; + + $sql="insert into actions (actionid,triggerid,userid,good,delay,nextcheck,subject,message) values (NULL,$triggerid,$userid,$good,$delay,0,'$subject','$message')"; + $result=mysql_query($sql,$mysql); + } + + # Update Action + + function update_action( $actionid, $userid, $good, $delay, $subject, $message ) + { + global $mysql; + + $sql="update actions set userid=$userid,good=$good,delay=$delay,nextcheck=0,subject='$subject',message='$message' where actionid=$actionid"; + $result=mysql_query($sql,$mysql); + } + + # Delete Action by userid + + function delete_actions_by_userid( $userid ) + { + global $mysql; + + $sql="delete from actions where userid=$userid"; + $result=mysql_query($sql,$mysql); + } + + # Delete Action + + function delete_action( $actionid ) + { + global $mysql; + + $sql="delete from actions where actionid=$actionid"; + $result=mysql_query($sql,$mysql); + } + + # Delete from History + + function delete_history_by_itemid( $itemid ) + { + global $mysql; + + + $sql="delete from history where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + } + + # Add Item definition + + function add_item($description,$key,$hostid,$delay,$history,$status) + { + global $mysql; + + $sql="insert into items (itemid,description,key_,hostid,delay,history,lastdelete,nextcheck,status) values (NULL,'$description','$key',$hostid,$delay,$history,0,0,$status)"; + $result=mysql_query($sql,$mysql); + return mysql_insert_id($mysql); + } + + # Delete Function definition + + function delete_function_by_triggerid($triggerid) + { + global $mysql; + + $sql="delete from functions where triggerid=$triggerid"; + $result=mysql_query($sql,$mysql); + } + + # Delete Function and Trigger definitions by itemid + + function delete_triggers_functions_by_itemid($itemid) + { + global $mysql; + + $sql="select triggerid from functions where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + while($row=mysql_fetch_row($result)) + { + delete_function_by_triggerid($row[0]); + } + + $sql="delete from functions where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + } + + # Delete Item definition + + function delete_item($itemid) + { + global $mysql; + + $sql="delete from items where itemid=$itemid"; + $result=mysql_query($sql,$mysql); + + delete_triggers_functions_by_itemid($itemid); + delete_history_by_itemid($itemid); + } + + # Add alarm + + function add_alarm($triggerid,$istrue) + { + global $mysql; + + $now=mktime(); + $sql="insert into alarms(triggerid,clock,istrue) values($triggerid,$now,$istrue)"; + $result=mysql_query($sql,$mysql); + } + + # Add Trigger definition + + function add_trigger($expression,$description,$priority,$istrue,$comments) + { + global $mysql; + + $sql="insert into triggers (triggerid,description,priority,istrue,comments) values (NULL,'$description',$priority,$istrue,'$comments')"; +# echo $sql,"
"; + $result=mysql_query($sql,$mysql); + + $triggerid=mysql_insert_id($mysql); + + $expression=implode_exp($expression,$triggerid); + $sql="update triggers set expression='$expression' where triggerid=$triggerid"; +# echo $sql,"
"; + $result=mysql_query($sql,$mysql); + } + + # Delete Trigger definition + + function delete_trigger($triggerid) + { + global $mysql; + + $sql="delete from triggers where triggerid=$triggerid"; + $result=mysql_query($sql,$mysql); + + delete_function_by_triggerid($triggerid); + } + + # Update Trigger definition + + function update_trigger($triggerid,$expression,$description,$priority,$istrue,$comments) + { + global $mysql; + + delete_trigger($triggerid); + + $triggerid=add_trigger($expression,$description,$priority,$istrue,$comments); + } + + # Add User definition + + function add_user($name,$surname,$alias) + { + global $mysql; + + $sql="insert into users (userid,name,surname,alias) values (NULL,'$name','$surname','$alias')"; + $result=mysql_query($sql,$mysql); + + return $result; + } + + # Add Items and Triggers from template + + function add_from_templates($hostid,$platformid,$host) + { + global $mysql; + + $result=mysql_query("select itemtemplateid,description,key_,delay from items_template where platformid=$platformid",$mysql); + while($row=mysql_fetch_row($result)) + { + $itemtemplateid=$row[0]; + $description=$row[1]; + $key=$row[2]; + $delay=$row[3]; + + $itemid=add_item($description,$key,$hostid,$delay,24*3600,0); + + $result2=mysql_query("select triggertemplateid,description,expression from triggers_template where itemtemplateid=$itemtemplateid",$mysql); + while($row2=mysql_fetch_row($result2)) + { + $itemtemplateid=$row2[0]; + $description=$row2[1]; + $expression=$row2[2]; + + for($i=0;$i"; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo " "; + cr(); + } + + function show_table2_h_delimiter() + { + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo " "; + cr(); + } + + function show_table_v_delimiter() + { + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + } + + function show_table2_v_delimiter() + { + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + } + + function show_table2_v_delimiter2() + { + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + } + + + + function show_table2_header_begin() + { + echo "
"; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo "
"; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo "
"; + cr(); + echo " "; + cr(); + } + + function show_table_header_begin() + { + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo "
"; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo ""; + cr(); + echo "
"; + cr(); + echo " "; + cr(); + } + + function show_table2_header_end() + { + echo " "; + cr(); + echo "
"; + cr(); + echo "
"; + cr(); + echo ""; + cr(); + } + + function show_table_header_end() + { + echo "
"; + cr(); + echo "
"; + cr(); + echo "
"; + cr(); + } + + function show_table_header($title) + { + show_table_header_begin(); + cr(); + echo $title; + cr(); + show_table_header_end(); + cr(); + } + + # Show History Graph + + function show_history($itemid,$from,$period) + { + if (!isset($from)) + { + $from=0; + $till="NOW"; + } + else + { + $till=time(NULL)-$from*3600; + $till=date("d M - H:i:s",$till); + } + + echo "
"; + + if (!isset($period)) + { + $period=3600; + show_table_header("TILL $till (LAST HOUR)"); + } + else + { + $tmp=$period/3600; + show_table_header("TILL $till ($tmp HOURs)"); + } + echo("
"); + echo ""; + echo("
"); + + + // Start of <<< WEEK >>> + $tmp=$from+12*14; + echo("["); + echo("Week back] "); + + // Start of <<< 12h >>> + $tmp=$from+12; + echo("["); + echo("12h back] "); + // End of <<< 12h >>> + + // HOUR BACK + $tmp=$from+1; + echo("["); + echo("1h back] "); + + // Start of --- + $tmp=$period+3600; + echo("["); + echo("+1h] "); + + if ($period>3600) + { + $tmp=$period-3600; + echo("["); + echo("-1h] "); + } + else + { + echo("[-1h]"); + } + // End of ------ + + if ($from>0) // HOUR FORWARD + { + $tmp=$from-1; + echo("["); + echo("1h forward] "); + } + else + { + echo("[1h forward]"); + } + + + if ($From>0) // 12h FORWARD + { + $tmp=$from-12; + echo("["); + echo("12h forward] "); + } + else + { + echo("[12h forward]"); + } + + if ($From>0) // WEEK Forward + { + $tmp=$from-12*14; + echo("["); + echo("Week forward] "); + } + else + { + echo("[Week forward]"); + } + + echo("\n"); + } + + # Show history + function show_freehist($itemid,$period) + { + + echo "
"; + show_table2_header_begin(); + echo "Choose period"; + + show_table2_v_delimiter(); + echo ""; + echo ""; + echo "Period in seconds"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "From (in hours)"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter2(); + echo "Press "; + echo " to see graph"; + + show_table2_header_end(); + + show_footer(); + } + + # Show in plain text + function show_plaintxt($itemid,$period) + { + show_table2_header_begin(); + echo "Data in plain text format"; + + show_table2_v_delimiter(); + echo ""; + echo ""; + echo ""; + echo "From: (yyyy/mm/dd - HH:MM)"; + show_table2_h_delimiter(); + echo "/"; + echo "/"; + echo " - "; + echo ":"; + echo ""; + + show_table2_v_delimiter(); + echo "Till: (yyyy/mm/dd - HH:MM)"; + show_table2_h_delimiter(); + echo "/"; + echo "/"; + echo " - "; + echo ":"; + echo ""; + + show_table2_v_delimiter2(); + echo "Press to see data in "; + echo ""; + + show_table2_header_end(); + + show_footer(); + } + + # Insert form for Item information + function insert_item_form($itemid) + { + global $mysql; + + if(isset($itemid)) + { + mysql_select_db("monitor"); + $result=mysql_query("select i.description, i.key_, h.host, h.port, i.delay, i.history, i.status from items i,hosts h where i.itemid=$itemid and h.hostid=i.hostid",$mysql); + $row=mysql_fetch_row($result); + + $description=$row[0]; + $key=$row[1]; + $host=$row[2]; + $port=$row[3]; + $delay=$row[4]; + $history=$row[5]; + $status=$row[6]; + } + if( !isset($port) ) + { + $port=10000; + } + if( !isset($delay) ) + { + $delay=30; + } + if( !isset($history) ) + { + $history=30*24*3600; + } + if( !isset($status) ) + { + $status=0; + } + + echo "
"; + + show_table2_header_begin(); + echo "Item configuration"; + + show_table2_v_delimiter(); + echo ""; + echo ""; + echo "Description"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Host"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Key"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Delay"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "History"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Status"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter2(); + echo ""; + if(isset($itemid)) + { + echo ""; + echo ""; + } + + show_table2_header_end(); +?> + + + + +
+ + + + +"; + + show_table2_header_begin(); + echo "Trigger configuration"; + + show_table2_v_delimiter(); + echo "
"; + echo ""; + echo "Description"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Expression"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Priority"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Comments"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter(); + echo "Disabled"; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter2(); + echo ""; + if(isset($triggerid)) + { + echo ""; + echo ""; + } + show_table2_header_end(); + } + + + function show_footer() + { + echo ""; + echo ""; + echo "
"; + echo ""; + echo ""; + echo "
"; + echo ""; + echo "ZABBIX Copyright 2000,2001 by Alexei Vladishev"; + echo ""; + echo "
"; + echo "
"; + } +?> diff --git a/frontends/php/index.html b/frontends/php/index.html index 9ffb1c35..e441e95b 100644 --- a/frontends/php/index.html +++ b/frontends/php/index.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/items.html b/frontends/php/items.html index e24256af..079f9b50 100644 --- a/frontends/php/items.html +++ b/frontends/php/items.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/latest.html b/frontends/php/latest.html index 54c0f175..0567a22a 100644 --- a/frontends/php/latest.html +++ b/frontends/php/latest.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/latestalarms.html b/frontends/php/latestalarms.html index 5598e66d..79f06cc1 100644 --- a/frontends/php/latestalarms.html +++ b/frontends/php/latestalarms.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/media.html b/frontends/php/media.html index 96c51ea1..3169a391 100644 --- a/frontends/php/media.html +++ b/frontends/php/media.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/queue.html b/frontends/php/queue.html index baa374d8..61c3b8e6 100644 --- a/frontends/php/queue.html +++ b/frontends/php/queue.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/tr_status.html b/frontends/php/tr_status.html index 69120809..291c69a6 100644 --- a/frontends/php/tr_status.html +++ b/frontends/php/tr_status.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/triggers.html b/frontends/php/triggers.html index b8d73c0c..cbe10f61 100644 --- a/frontends/php/triggers.html +++ b/frontends/php/triggers.html @@ -1,5 +1,5 @@ diff --git a/frontends/php/users.html b/frontends/php/users.html index 5fde27b2..8848d449 100644 --- a/frontends/php/users.html +++ b/frontends/php/users.html @@ -1,5 +1,5 @@ -- cgit