diff options
Diffstat (limited to 'frontends/php/include/triggers.inc.php')
| -rw-r--r-- | frontends/php/include/triggers.inc.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index 7b958382..c156ea5f 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -676,11 +676,12 @@ $expression, $description, $type, $priority, $status, $comments, $url, $deps=array(), $templateid=0) { + if( !validate_expression($expression) ) return false; $triggerid=get_dbid("triggers","triggerid"); - + $result=DBexecute("insert into triggers". " (triggerid,description,type,priority,status,comments,url,value,error,templateid)". " values ($triggerid,".zbx_dbstr($description).",$type,$priority,$status,".zbx_dbstr($comments).",". @@ -711,6 +712,7 @@ $trig_hosts = get_hosts_by_triggerid($triggerid); $trig_host = DBfetch($trig_hosts); + if($result) { $msg = "Added trigger '".$description."'"; @@ -979,10 +981,15 @@ $function = &$arr[ZBX_EXPRESSION_SIMPLE_EXPRESSION_ID + ZBX_SIMPLE_EXPRESSION_FUNCTION_NAME_ID]; $parameter = &$arr[ZBX_EXPRESSION_SIMPLE_EXPRESSION_ID + ZBX_SIMPLE_EXPRESSION_FUNCTION_PARAM_ID]; - $item = DBfetch(DBselect('select i.itemid from items i,hosts h'. + $item_res = DBselect('select i.itemid from items i,hosts h'. ' where i.key_='.zbx_dbstr($key). ' and h.host='.zbx_dbstr($host). - ' and h.hostid=i.hostid')); + ' and h.hostid=i.hostid'); + + while(($item = DBfetch($item_res)) && (!in_node($item['itemid']))){ + } + + if(!$item) return null; $item = $item["itemid"]; |
