"; echo ""; echo ""; if(isset($hosttemplateid)) { echo ""; } if($hostid!=0) { echo ""; } echo S_TEMPLATE; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_ITEMS; show_table2_h_delimiter(); echo "".S_ADD; echo "".S_UPDATE; echo "".S_DELETE; show_table2_v_delimiter($col++); echo S_TRIGGERS; show_table2_h_delimiter(); echo "".S_ADD; echo "".S_UPDATE; echo "".S_DELETE; show_table2_v_delimiter($col++); echo S_GRAPHS; show_table2_h_delimiter(); echo "".S_ADD; echo "".S_UPDATE; echo "".S_DELETE; show_table2_v_delimiter2($col++); echo ""; if(isset($hosttemplateid)) { echo ""; echo ""; } show_table2_header_end(); } # Insert form for User function insert_user_form($userid,$profile=0) { if(isset($userid)) { $user=get_user_by_userid($userid); $result=DBselect("select u.alias,u.name,u.surname,u.passwd,u.url,u.autologout,u.lang,u.refresh from users u where u.userid=$userid"); $alias=$user["alias"]; $name=$user["name"]; $surname=$user["surname"]; $password=""; $url=$user["url"]; $autologout=$user["autologout"]; $lang=$user["lang"]; $refresh=$user["refresh"]; } else { $alias=""; $name=""; $surname=""; $password=""; $url=""; $autologout="900"; $lang="en_gb"; $refresh="30"; } $col=0; show_form_begin("users.users"); echo S_USER; if($profile==0) echo "
"; else echo ""; echo ""; if(isset($userid)) { echo ""; } if($profile==0) { show_table2_v_delimiter($col++); echo S_ALIAS; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_NAME; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_SURNAME; show_table2_h_delimiter(); echo ""; } show_table2_v_delimiter($col++); echo S_PASSWORD; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo nbsp(S_PASSWORD_ONCE_AGAIN); show_table2_h_delimiter(); echo ""; $languages=array( "en_gb"=>S_ENGLISH_GB, "cn_zh"=>S_CHINESE_CN, "fr_fr"=>S_FRENCH_FR, "de_de"=>S_GERMAN_DE, "it_it"=>S_ITALIAN_IT, "lv_lv"=>S_LATVIAN_LV, "ru_ru"=>S_RUSSIAN_RU, "sp_sp"=>S_SPANISH_SP, "ja_jp"=>S_JAPANESE_JP ); show_table2_v_delimiter($col++); echo S_LANGUAGE; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_AUTO_LOGOUT_IN_SEC; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_URL_AFTER_LOGIN; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_SCREEN_REFRESH; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter2($col++); if($profile==0) { echo ""; if(isset($userid)) { echo ""; } } else { echo ""; } echo ""; show_table2_header_end(); } # Insert form for Item information function insert_item_form() { global $_REQUEST; $description=@iif(isset($_REQUEST["description"]),$_REQUEST["description"],""); $key=@iif(isset($_REQUEST["key"]),$_REQUEST["key"],""); $host=@iif(isset($_REQUEST["host"]),$_REQUEST["host"],""); $port=@iif(isset($_REQUEST["port"]),$_REQUEST["port"],10050); $delay=@iif(isset($_REQUEST["delay"]),$_REQUEST["delay"],30); $history=@iif(isset($_REQUEST["history"]),$_REQUEST["history"],90); $trends=@iif(isset($_REQUEST["trends"]),$_REQUEST["trends"],365); $status=@iif(isset($_REQUEST["status"]),$_REQUEST["status"],0); $type=@iif(isset($_REQUEST["type"]),$_REQUEST["type"],0); $snmp_community=@iif(isset($_REQUEST["snmp_community"]),$_REQUEST["snmp_community"],"public"); $snmp_oid=@iif(isset($_REQUEST["snmp_oid"]),$_REQUEST["snmp_oid"],"interfaces.ifTable.ifEntry.ifInOctets.1"); $value_type=@iif(isset($_REQUEST["value_type"]),$_REQUEST["value_type"],0); $trapper_hosts=@iif(isset($_REQUEST["trapper_hosts"]),$_REQUEST["trapper_hosts"],""); $snmp_port=@iif(isset($_REQUEST["snmp_port"]),$_REQUEST["snmp_port"],161); $units=@iif(isset($_REQUEST["units"]),$_REQUEST["units"],''); $multiplier=@iif(isset($_REQUEST["multiplier"]),$_REQUEST["multiplier"],0); $hostid=@iif(isset($_REQUEST["hostid"]),$_REQUEST["hostid"],0); $delta=@iif(isset($_REQUEST["delta"]),$_REQUEST["delta"],0); $snmpv3_securityname=@iif(isset($_REQUEST["snmpv3_securityname"]),$_REQUEST["snmpv3_securityname"],""); $snmpv3_securitylevel=@iif(isset($_REQUEST["snmpv3_securitylevel"]),$_REQUEST["snmpv3_securitylevel"],0); $snmpv3_authpassphrase=@iif(isset($_REQUEST["snmpv3_authpassphrase"]),$_REQUEST["snmpv3_authpassphrase"],""); $snmpv3_privpassphrase=@iif(isset($_REQUEST["snmpv3_privpassphrase"]),$_REQUEST["snmpv3_privpassphrase"],"") ; $formula=@iif(isset($_REQUEST["formula"]),$_REQUEST["formula"],"1"); $logtimefmt=@iif(isset($_REQUEST["logtimefmt"]),$_REQUEST["logtimefmt"],""); if(isset($_REQUEST["register"])&&($_REQUEST["register"] == "change")) { $result=DBselect("select i.description, i.key_, h.host, h.port, i.delay, i.history, i.status, i.type, i.snmp_community,i.snmp_oid,i.value_type,i.trapper_hosts,i.snmp_port,i.units,i.multiplier,h.hostid,i.delta,i.trends,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,i.logtimefmt from items i,hosts h where i.itemid=".$_REQUEST["itemid"]." and h.hostid=i.hostid"); $row=DBfetch($result); $description=$row["description"]; $key=$row["key_"]; $host=$row["host"]; $port=$row["port"]; $delay=$row["delay"]; $history=$row["history"]; $status=$row["status"]; $type=iif(isset($_REQUEST["type"]),isset($_REQUEST["type"]),$row["type"]); $snmp_community=$row["snmp_community"]; $snmp_oid=$row["snmp_oid"]; $value_type=$row["value_type"]; $trapper_hosts=$row["trapper_hosts"]; $snmp_port=$row["snmp_port"]; $units=$row["units"]; $multiplier=$row["multiplier"]; $hostid=$row["hostid"]; $delta=$row["delta"]; $trends=$row["trends"]; $snmpv3_securityname=$row["snmpv3_securityname"]; $snmpv3_securitylevel=$row["snmpv3_securitylevel"]; $snmpv3_authpassphrase=$row["snmpv3_authpassphrase"]; $snmpv3_privpassphrase=$row["snmpv3_privpassphrase"]; $formula=$row["formula"]; $logtimefmt=$row["logtimefmt"]; } show_form_begin("items.item"); echo S_ITEM; $col=0; show_table2_v_delimiter($col++); echo ""; if(isset($_REQUEST["itemid"])) { echo ""; } echo S_DESCRIPTION; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_HOST; show_table2_h_delimiter(); /* echo "";*/ echo ""; echo ""; ?> "; echo "
"; show_table2_header_end(); } # Insert form for User Groups function insert_usergroups_form($usrgrpid) { global $_REQUEST; $col=0; if(isset($usrgrpid)) { $usrgrp=get_usergroup_by_usrgrpid($usrgrpid); $name=$usrgrp["name"]; } else { $name=""; } show_form_begin("users.groups"); echo S_USER_GROUP; show_table2_v_delimiter($col++); echo "
"; if(isset($usrgrpid)) { echo ""; } echo ""; echo S_GROUP_NAME; show_table2_h_delimiter(); echo ""; /* show_table2_v_delimiter($col++); echo S_USERS; show_table2_h_delimiter(); echo "";*/ show_table2_v_delimiter($col++); echo S_USERS; show_table2_h_delimiter(); $result=DBselect("select distinct userid,alias from users order by alias"); while($row=DBfetch($result)) { if(isset($_REQUEST["usrgrpid"])) { $sql="select count(*) as count from users_groups where userid=".$row["userid"]." and usrgrpid=".$_REQUEST["usrgrpid"]; $result2=DBselect($sql); $row2=DBfetch($result2); if($row2["count"]==0) { echo "".$row["alias"]; } else { echo "".$row["alias"]; } } else { echo "".$row["alias"]; } echo "
"; } show_table2_v_delimiter2(); echo ""; if(isset($_REQUEST["usrgrpid"])) { echo ""; } echo ""; echo "
"; show_table2_header_end(); } # Insert form for User permissions function insert_permissions_form($userid) { show_form_begin("users.users"); echo "New permission"; show_table2_v_delimiter(); echo "
"; if(isset($userid)) { echo ""; } echo S_RESOURCE; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter(); echo S_PERMISSION; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter(); echo "Resource ID (0 for all)"; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter2(); echo ""; show_table2_header_end(); } function insert_login_form() { $frmLogin = new CForm('Login','index.php'); $frmLogin->SetHelp('web.index.login'); $frmLogin->AddRow('Login name', new CTextBox('name')); $frmLogin->AddRow('Password', new CPassBox('password')); $frmLogin->AddBottomRow(new CButton('register','Enter')); $frmLogin->Show(); } # Insert form for Problem function insert_problem_form($problemid) { show_form_begin(); echo "Problem definition"; show_table2_v_delimiter(); echo ""; echo ""; echo "Description"; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter(); echo "Severity"; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter(); echo "Status"; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter2(); echo ""; if(isset($problemid)) { echo ""; echo ""; } show_table2_header_end(); } # Insert form for Trigger function insert_trigger_form($hostid,$triggerid) { $col=0; if(isset($triggerid)) { $trigger=get_trigger_by_triggerid($triggerid); $expression=explode_exp($trigger["expression"],0); $description=htmlspecialchars(stripslashes($trigger["description"])); $priority=$trigger["priority"]; $status=$trigger["status"]; $comments=$trigger["comments"]; $url=$trigger["url"]; } else { $expression=""; $description=""; $priority=0; $status=0; $comments=""; $url=""; } show_form_begin("triggers.trigger"); echo S_TRIGGER; show_table2_v_delimiter($col++); echo ""; if(isset($hostid)) { echo ""; } if(isset($triggerid)) { echo ""; } echo S_NAME; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_EXPRESSION; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_SEVERITY; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_COMMENTS; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_URL; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_DISABLED; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter2(); echo ""; if(isset($triggerid)) { echo ""; } echo ""; if(isset($triggerid)) { show_table2_v_delimiter(); echo "The trigger depends on"; show_table2_h_delimiter(); $sql="select t.triggerid,t.description from triggers t,trigger_depends d where t.triggerid=d.triggerid_up and d.triggerid_down=$triggerid"; $result1=DBselect($sql); echo ""; show_table2_v_delimiter(); echo "New dependency"; show_table2_h_delimiter(); $sql="select t.triggerid,t.description from triggers t where t.triggerid!=$triggerid order by t.description"; $result=DBselect($sql); echo ""; show_table2_v_delimiter2(); if(isset($triggerid)) { echo ""; if(DBnum_rows($result1)>0) { echo ""; } } } echo "
"; show_table2_header_end(); } function insert_graph_form() { global $_REQUEST; $name=@iif(isset($_REQUEST["name"]),$_REQUEST["name"],""); $width=@iif(isset($_REQUEST["width"]),$_REQUEST["width"],900); $height=@iif(isset($_REQUEST["height"]),$_REQUEST["height"],200); $yaxistype=@iif(isset($_REQUEST["yaxistype"]),$_REQUEST["yaxistype"],GRAPH_YAXIS_TYPE_CALCULATED); $yaxismin=@iif(isset($_REQUEST["yaxismin"]),$_REQUEST["yaxismin"],0.00); $yaxismax=@iif(isset($_REQUEST["yaxismax"]),$_REQUEST["yaxismax"],100.00); if(isset($_REQUEST["graphid"])&&!isset($_REQUEST["name"])) { $result=DBselect("select g.graphid,g.name,g.width,g.height,g.yaxistype,g.yaxismin,g.yaxismax from graphs g where graphid=".$_REQUEST["graphid"]); $row=DBfetch($result); $name=$row["name"]; $width=$row["width"]; $height=$row["height"]; $yaxistype=$row["yaxistype"]; $yaxismin=$row["yaxismin"]; $yaxismax=$row["yaxismax"]; } show_form_begin("graphs.graph"); echo S_GRAPH; show_table2_v_delimiter(); echo "
"; if(isset($_REQUEST["graphid"])) { echo ""; } echo S_NAME; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter(); echo S_WIDTH; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter(); echo S_HEIGHT; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter(); echo S_YAXIS_TYPE; show_table2_h_delimiter(); echo ""; if($yaxistype == GRAPH_YAXIS_TYPE_FIXED) { show_table2_v_delimiter(); echo S_YAXIS_MIN_VALUE; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter(); echo S_YAXIS_MAX_VALUE; show_table2_h_delimiter(); echo ""; } else { echo ""; echo ""; } show_table2_v_delimiter2(); echo ""; if(isset($_REQUEST["graphid"])) { echo ""; echo ""; } show_table2_header_end(); } # Insert escalation form function insert_escalation_form($escalationid) { if(isset($escalationid)) { $result=DBselect("select * from escalations where escalationid=$escalationid"); $row=DBfetch($result); $name=$row["name"]; $dflt=$row["dflt"]; } else { $name=""; $dflt=0; } $col=0; show_form_begin("escalations"); echo S_ESCALATION; show_table2_v_delimiter($col++); echo ""; echo ""; if(isset($escalationid)) { echo ""; } echo S_NAME; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_IS_DEFAULT; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter2($col++); echo ""; if(isset($escalationid)) { echo ""; echo ""; } show_table2_header_end(); } # Insert escalation rule form function insert_escalation_rule_form($escalationid,$escalationruleid) { if(isset($escalationruleid)) { $result=DBselect("select * from escalation_rules where escalationruleid=$escalationruleid"); $row=DBfetch($result); $level=$row["level"]; $period=$row["period"]; $delay=$row["delay"]; $actiontype=$row["actiontype"]; } else { $level=1; $period="1-7,00:00-23:59"; $delay=0; $actiontype=0; } $col=0; show_form_begin("escalationrule"); echo S_ESCALATION_RULE; show_table2_v_delimiter($col++); echo ""; echo ""; echo ""; if(isset($escalationruleid)) { echo ""; } echo S_LEVEL; show_table2_h_delimiter(); echo form_input("level",$level,2); show_table2_v_delimiter($col++); echo S_PERIOD; show_table2_h_delimiter(); echo form_input("period",$period,32); show_table2_v_delimiter($col++); echo S_DELAY; show_table2_h_delimiter(); echo form_input("delay",$delay,32); show_table2_v_delimiter($col++); echo S_DO; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter2($col++); echo ""; if(isset($escalationid)) { echo ""; echo ""; } show_table2_header_end(); } # Insert host profile form function insert_host_profile_form($hostid,$readonly=0) { $selected=0; if(isset($hostid)) { $result=DBselect("select * from hosts_profiles where hostid=$hostid"); if(DBnum_rows($result)==1) { $row=DBfetch($result); $selected=1; $devicetype=$row["devicetype"]; $name=$row["name"]; $os=$row["os"]; $serialno=$row["serialno"]; $tag=$row["tag"]; $macaddress=$row["macaddress"]; $hardware=$row["hardware"]; $software=$row["software"]; $contact=$row["contact"]; $location=$row["location"]; $notes=$row["notes"]; } } if($selected==0) { $devicetype=""; $name=""; $os=""; $serialno=""; $tag=""; $macaddress=""; $hardware=""; $software=""; $contact=""; $location=""; $notes=""; } $col=0; show_form_begin("host_profile"); echo S_HOST_PROFILE; show_table2_v_delimiter($col++); echo ""; if(isset($_REQUEST["config"])) { echo ""; } echo ""; echo S_DEVICE_TYPE; show_table2_h_delimiter(); echo form_input("devicetype",$devicetype,64); show_table2_v_delimiter($col++); echo S_NAME; show_table2_h_delimiter(); echo form_input("name",$name,64); show_table2_v_delimiter($col++); echo S_OS; show_table2_h_delimiter(); echo form_input("os",$os,64); show_table2_v_delimiter($col++); echo S_SERIALNO; show_table2_h_delimiter(); echo form_input("serialno",$serialno,64); show_table2_v_delimiter($col++); echo S_TAG; show_table2_h_delimiter(); echo form_input("tag",$tag,64); show_table2_v_delimiter($col++); echo S_MACADDRESS; show_table2_h_delimiter(); echo form_input("macaddress",$macaddress,64); show_table2_v_delimiter($col++); echo S_HARDWARE; show_table2_h_delimiter(); echo form_textarea("hardware",$hardware,50,4); show_table2_v_delimiter($col++); echo S_SOFTWARE; show_table2_h_delimiter(); echo form_textarea("software",$software,50,4); show_table2_v_delimiter($col++); echo S_CONTACT; show_table2_h_delimiter(); echo form_textarea("contact",$contact,50,4); show_table2_v_delimiter($col++); echo S_LOCATION; show_table2_h_delimiter(); echo form_textarea("location",$location,50,4); show_table2_v_delimiter($col++); echo S_NOTES; show_table2_h_delimiter(); echo form_textarea("notes",$notes,50,4); show_table2_v_delimiter2($col++); if($readonly==0) { echo ""; if(isset($hostid)) { echo ""; echo ""; } } else { echo " "; } show_table2_header_end(); } # Insert autoregistration form function insert_autoregistration_form($id) { if(isset($id)) { $result=DBselect("select * from autoreg where id=$id"); $row=DBfetch($result); $pattern=$row["pattern"]; $priority=$row["priority"]; $hostid=$row["hostid"]; $h=get_host_by_hostid($hostid); $host=$h["host"]; } else { $pattern="*"; $priority=10; $hostid=0; $host=""; } $col=0; show_form_begin("autoregistration"); echo S_AUTOREGISTRATION; show_table2_v_delimiter($col++); echo ""; echo ""; if(isset($id)) { echo ""; } echo S_PATTERN; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_PRIORITY; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_HOST; show_table2_h_delimiter(); echo ""; echo ""; echo ""; show_table2_v_delimiter2($col++); echo ""; if(isset($id)) { echo ""; } echo ""; show_table2_header_end(); } function insert_action_form() { global $_REQUEST; $uid=NULL; $frmAction = new CFormTable(S_ACTION,'actionconf.php'); $frmAction->SetHelp('web.actions.action'); if(isset($_REQUEST['form'])) $frmAction->AddVar('form',$_REQUEST['form']); $conditiontype=@iif(isset($_REQUEST["conditiontype"]),$_REQUEST["conditiontype"],0); if(isset($_REQUEST["actionid"])) { $action=get_action_by_actionid($_REQUEST["actionid"]); $frmAction->AddVar('actionid',$_REQUEST["actionid"]); $actionid=$action["actionid"]; $actiontype=$action["actiontype"]; $source=$action["source"]; $delay=$action["delay"]; $uid=$action["userid"]; // Otherwise symbols like ",' will not be shown $subject=htmlspecialchars($action["subject"]); $message=$action["message"]; $recipient=@iif(isset($_REQUEST["recipient"]),$_REQUEST["recipient"],$action["recipient"]); $maxrepeats=$action["maxrepeats"]; $repeatdelay=$action["repeatdelay"]; if(isset($_REQUEST["repeat"])) { $repeat=$_REQUEST["repeat"]; } else if($maxrepeats==0) { $repeat=0; } else { $repeat=1; } $sql="select conditiontype, operator, value from conditions where actionid=".$_REQUEST["actionid"]." order by conditiontype"; $result=DBselect($sql); $i=1; while($condition=DBfetch($result)) { $_REQUEST["conditiontype$i"]=$condition["conditiontype"]; $_REQUEST["conditionop$i"]=$condition["operator"]; $_REQUEST["conditionvalue$i"]=$condition["value"]; $i++; } } else { $source=@iif(isset($_REQUEST["source"]),$_REQUEST["source"],0); $actiontype=@iif(isset($_REQUEST["actiontype"]),$_REQUEST["actiontype"],0); $delay=@iif(isset($_REQUEST["delay"]),$_REQUEST["delay"],30); $subject=@iif(isset($_REQUEST["subject"]),$_REQUEST["subject"],"{TRIGGER.NAME}: {STATUS}"); $message=@iif(isset($_REQUEST["message"]),$_REQUEST["message"],"{TRIGGER.NAME}: {STATUS}"); $scope=@iif(isset($_REQUEST["scope"]),$_REQUEST["scope"],0); $recipient=@iif(isset($_REQUEST["recipient"]),$_REQUEST["recipient"],RECIPIENT_TYPE_GROUP); $severity=@iif(isset($_REQUEST["severity"]),$_REQUEST["severity"],0); $maxrepeats=@iif(isset($_REQUEST["maxrepeats"]),$_REQUEST["maxrepeats"],0); $repeatdelay=@iif(isset($_REQUEST["repeatdelay"]),$_REQUEST["repeatdelay"],600); $repeat=@iif(isset($_REQUEST["repeat"]),$_REQUEST["repeat"],0); if($recipient==RECIPIENT_TYPE_GROUP) $uid=@iif(isset($_REQUEST["usrgrpid"]),$_REQUEST["usrgrpid"],NULL); else $uid=@iif(isset($_REQUEST["userid"]),$_REQUEST["userid"],NULL); } // prepare condition list $cond_el=array(); for($i=1; $i<=1000; $i++) { if(!isset($_REQUEST["conditiontype$i"])) continue; array_push($cond_el, new CCheckBox( "conditionchecked$i", get_condition_desc( $_REQUEST["conditiontype$i"], $_REQUEST["conditionop$i"], $_REQUEST["conditionvalue$i"] ) ), BR ); $frmAction->AddVar("conditiontype$i", $_REQUEST["conditiontype$i"]); $frmAction->AddVar("conditionop$i", $_REQUEST["conditionop$i"]); $frmAction->AddVar("conditionvalue$i", $_REQUEST["conditionvalue$i"]); } if(count($cond_el)==0) array_push($cond_el, S_NO_CONDITIONS_DEFINED); else array_push($cond_el, new CButton('register','delete selected')); // end of condition list preparation $cmbSource = new CComboBox('source', $source); $cmbSource->AddItem(0, S_TRIGGER); $frmAction->AddRow(S_SOURCE, $cmbSource); $frmAction->AddRow(S_CONDITIONS, $cond_el); // prepare new condition $rowCondition=array(); // add condition type $cmbCondType = new CComboBox('conditiontype',$conditiontype,'submit()'); $cmbCondType->AddItem(CONDITION_TYPE_GROUP, S_HOST_GROUP); $cmbCondType->AddItem(CONDITION_TYPE_HOST, S_HOST); $cmbCondType->AddItem(CONDITION_TYPE_TRIGGER, S_TRIGGER); $cmbCondType->AddItem(CONDITION_TYPE_TRIGGER_NAME, S_TRIGGER_NAME); $cmbCondType->AddItem(CONDITION_TYPE_TRIGGER_SEVERITY, S_TRIGGER_SEVERITY); $cmbCondType->AddItem(CONDITION_TYPE_TRIGGER_VALUE, S_TRIGGER_VALUE); $cmbCondType->AddItem(CONDITION_TYPE_TIME_PERIOD, S_TIME_PERIOD); array_push($rowCondition,$cmbCondType); // add condition operation $cmbCondOp = new CComboBox('operator'); if(in_array($conditiontype, array( CONDITION_TYPE_GROUP, CONDITION_TYPE_HOST, CONDITION_TYPE_TRIGGER, CONDITION_TYPE_TRIGGER_SEVERITY, CONDITION_TYPE_TRIGGER_VALUE))) $cmbCondOp->AddItem(CONDITION_OPERATOR_EQUAL, '='); if(in_array($conditiontype,array( CONDITION_TYPE_GROUP, CONDITION_TYPE_HOST, CONDITION_TYPE_TRIGGER, CONDITION_TYPE_TRIGGER_SEVERITY))) $cmbCondOp->AddItem(CONDITION_OPERATOR_NOT_EQUAL, '<>'); if(in_array($conditiontype,array(CONDITION_TYPE_TRIGGER_NAME))) $cmbCondOp->AddItem(CONDITION_OPERATOR_LIKE, 'like'); if(in_array($conditiontype,array(CONDITION_TYPE_TRIGGER_NAME))) $cmbCondOp->AddItem(CONDITION_OPERATOR_NOT_LIKE, 'not like'); if(in_array($conditiontype,array(CONDITION_TYPE_TIME_PERIOD))) $cmbCondOp->AddItem(CONDITION_OPERATOR_IN, 'in'); if(in_array($conditiontype,array(CONDITION_TYPE_TRIGGER_SEVERITY))) $cmbCondOp->AddItem(CONDITION_OPERATOR_MORE_EQUAL, '>='); array_push($rowCondition,$cmbCondOp); // add condition value if($conditiontype == CONDITION_TYPE_GROUP) { $cmbCondVal = new CComboBox('value'); $groups = DBselect("select groupid,name from groups order by name"); while($group = DBfetch($groups)) { $cmbCondVal->AddItem($group["groupid"],$group["name"]); } array_push($rowCondition,$cmbCondVal); } else if($conditiontype == CONDITION_TYPE_HOST) { $frmAction->AddVar('value','0'); $txtCondVal = new CTextBox('host','',20); $txtCondVal->SetReadonly('yes'); $btnSelect = new CButton('btn1','Select',"window.open('popup.php?form=action&field1=value&field2=host','new_win','width=450,height=450,resizable=1,scrollbars=1');"); $btnSelect->SetAccessKey('T'); array_push($rowCondition, $txtCondVal, $btnSelect); // $cmbCondVal = new CComboBox('value'); // $hosts = DBselect("select hostid,host from hosts order by host"); // while($host = DBfetch($hosts)) // { // $cmbCondVal->AddItem($host["hostid"],$host["host"]); // } } else if($conditiontype == CONDITION_TYPE_TRIGGER) { $cmbCondVal = new CComboBox('value'); $triggers = DBselect("select distinct h.host,t.triggerid,t.description from triggers t, functions f,items i, hosts h where t.triggerid=f.triggerid and f.itemid=i.itemid and h.hostid=i.hostid order by h.host"); while($trigger = DBfetch($triggers)) { $cmbCondVal->AddItem($trigger["triggerid"],$trigger["host"].": ".$trigger["description"]); } array_push($rowCondition,$cmbCondVal); } else if($conditiontype == CONDITION_TYPE_TRIGGER_NAME) { array_push($rowCondition, new CTextBox('value', "", 40)); } else if($conditiontype == CONDITION_TYPE_TRIGGER_VALUE) { $cmbCondVal = new CComboBox('value'); $cmbCondVal->AddItem(0,"OFF"); $cmbCondVal->AddItem(1,"ON"); array_push($rowCondition,$cmbCondVal); } else if($conditiontype == CONDITION_TYPE_TIME_PERIOD) { array_push($rowCondition, new CTextBox('value', "1-7,00:00-23:59", 40)); } else if($conditiontype == CONDITION_TYPE_TRIGGER_SEVERITY) { $cmbCondVal = new CComboBox('value'); $cmbCondVal->AddItem(0,S_NOT_CLASSIFIED); $cmbCondVal->AddItem(1,S_INFORMATION); $cmbCondVal->AddItem(2,S_WARNING); $cmbCondVal->AddItem(3,S_AVERAGE); $cmbCondVal->AddItem(4,S_HIGH); $cmbCondVal->AddItem(5,S_DISASTER); array_push($rowCondition,$cmbCondVal); } // add condition button array_push($rowCondition,BR,new CButton('register','add condition')); // end of new condition preparation $frmAction->AddRow(S_CONDITION, $rowCondition); $cmbActionType = new CComboBox('actiontype', $actiontype,'submit()'); $cmbActionType->AddItem(0,S_SEND_MESSAGE); $cmbActionType->AddItem(1,S_REMOTE_COMMAND,'no'); $frmAction->AddRow(S_ACTION_TYPE, $cmbActionType); $cmbRecipient = new CComboBox('recipient', $recipient,'submit()'); $cmbRecipient->AddItem(0,S_SINGLE_USER); $cmbRecipient->AddItem(1,S_USER_GROUP); $frmAction->AddRow(S_SEND_MESSAGE_TO, $cmbRecipient); if($recipient==RECIPIENT_TYPE_GROUP) { $cmbGroups = new CComboBox('usrgrpid', $uid); $sql="select usrgrpid,name from usrgrp order by name"; $groups=DBselect($sql); while($group=DBfetch($groups)) { $cmbGroups->AddItem($group['usrgrpid'],$group['name']); } $frmAction->AddRow(S_GROUP, $cmbGroups); } else { $cmbUser = new CComboBox('userid', $uid); $sql="select userid,alias from users order by alias"; $users=DBselect($sql); while($user=DBfetch($users)) { $cmbUser->AddItem($user['userid'],$user['alias']); } $frmAction->AddRow(S_USER, $cmbUser); } $frmAction->AddRow(S_DELAY_BETWEEN_MESSAGES_IN_SEC, new CTextBox('delay',$delay,5)); $frmAction->AddRow(S_SUBJECT, new CTextBox('subject',$subject,80)); $frmAction->AddRow(S_MESSAGE, new CTextArea('message',$message,77,7)); $cmbRepeat = new CComboBox('repeat',$repeat,'submit()'); $cmbRepeat->AddItem(0,S_NO_REPEATS); $cmbRepeat->AddItem(1,S_REPEAT); $frmAction->AddRow(S_REPEAT, $cmbRepeat); if($repeat>0) { $frmAction->AddRow(S_NUMBER_OF_REPEATS, new CTextBox('maxrepeats',$maxrepeats,2)); $frmAction->AddRow(S_DELAY_BETWEEN_REPEATS, new CTextBox('repeatdelay',$repeatdelay,2)); } $bottomRow = array(); if(isset($actionid)) { array_push($bottomRow,new CButton('register','update')); array_push($bottomRow,SPACE,new CButton('register','delete','return Confirm("Delete selected action?");')); } else { array_push($bottomRow,new CButton('register','add')); } array_push($bottomRow,SPACE,new CButton('register','cancel')); $frmAction->AddBottomRow($bottomRow); $frmAction->Show(); } function insert_media_type_form() { $type=@iif(isset($_REQUEST["type"]),$_REQUEST["type"],0); $description=@iif(isset($_REQUEST["description"]),$_REQUEST["description"],""); $smtp_server=@iif(isset($_REQUEST["smtp_server"]),$_REQUEST["smtp_server"],"localhost"); $smtp_helo=@iif(isset($_REQUEST["smtp_helo"]),$_REQUEST["smtp_helo"],"localhost"); $smtp_email=@iif(isset($_REQUEST["smtp_email"]),$_REQUEST["smtp_email"],"zabbix@localhost"); $exec_path=@iif(isset($_REQUEST["exec_path"]),$_REQUEST["exec_path"],""); if(isset($_REQUEST["register"]) && ($_REQUEST["register"] == "change")) { $result=DBselect("select mediatypeid,type,description,smtp_server,smtp_helo,smtp_email,exec_path from media_type where mediatypeid=".$_REQUEST["mediatypeid"]); $row=DBfetch($result); $mediatypeid=$row["mediatypeid"]; $type=@iif(isset($_REQUEST["type"]),$_REQUEST["type"],$row["type"]); $description=$row["description"]; $smtp_server=$row["smtp_server"]; $smtp_helo=$row["smtp_helo"]; $smtp_email=$row["smtp_email"]; $exec_path=$row["exec_path"]; } show_form_begin("config.medias"); echo S_MEDIA; $col=0; show_table2_v_delimiter($col++); echo ""; if(isset($_REQUEST["mediatypeid"])) { echo ""; } echo ""; echo S_DESCRIPTION; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_TYPE; show_table2_h_delimiter(); echo ""; if($type==0) { echo ""; show_table2_v_delimiter($col++); echo nbsp(S_SMTP_SERVER); show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo nbsp(S_SMTP_HELO); show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo nbsp(S_SMTP_EMAIL); show_table2_h_delimiter(); echo ""; } if($type==1) { echo ""; echo ""; echo ""; show_table2_v_delimiter($col++); echo S_SCRIPT_NAME; show_table2_h_delimiter(); echo ""; } show_table2_v_delimiter2(); echo ""; if(isset($_REQUEST["mediatypeid"])) { echo ""; } echo ""; show_table2_header_end(); } function insert_image_form() { if(!isset($_REQUEST["imageid"])) { $name=""; $imagetype=1; } else { $result=DBselect("select imageid,imagetype,name,image from images where imageid=".$_REQUEST["imageid"]); $row=DBfetch($result); $name=$row["name"]; $imagetype=$row["imagetype"]; $imageid=$row["imageid"]; } $col=0; show_form_begin("config.images"); echo S_IMAGE; show_table2_v_delimiter($col++); # echo ""; echo ""; echo ""; echo ""; if(isset($imageid)) { echo ""; } echo nbsp(S_NAME); show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_TYPE; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_UPLOAD; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter2(); echo ""; if(isset($_REQUEST["imageid"])) { echo ""; } echo ""; show_table2_header_end(); } function insert_screen_form() { global $_REQUEST; if(isset($_REQUEST["screenid"])) { $result=DBselect("select screenid,name,cols,rows from screens g where screenid=".$_REQUEST["screenid"]); $row=DBfetch($result); $name=$row["name"]; $cols=$row["cols"]; $rows=$row["rows"]; } else { $name=""; $cols=1; $rows=1; } show_form_begin("screenconf.screen"); echo S_SCREEN; $col=0; show_table2_v_delimiter($col++); echo ""; if(isset($_REQUEST["screenid"])) { echo ""; } echo S_NAME; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_COLUMNS; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_ROWS; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter2(); echo ""; if(isset($_REQUEST["screenid"])) { echo ""; } echo ""; show_table2_header_end(); } function insert_media_form() { global $_REQUEST; if(isset($_REQUEST["mediaid"])) { $media=get_media_by_mediaid($_REQUEST["mediaid"]); $severity=$media["severity"]; $sendto=$media["sendto"]; $active=$media["active"]; $mediatypeid=$media["mediatypeid"]; $period=$media["period"]; } else { $sendto=""; $severity=63; $mediatypeid=-1; $active=0; $period="1-7,00:00-23:59"; } show_form_begin("media.media"); echo S_NEW_MEDIA; $col=0; show_table2_v_delimiter($col++); echo ""; echo ""; if(isset($_REQUEST["mediaid"])) { echo ""; } echo S_TYPE; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo nbsp(S_SEND_TO); show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo nbsp(S_WHEN_ACTIVE); show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo nbsp(S_USE_IF_SEVERITY); show_table2_h_delimiter(); $checked=iif( (1&$severity) == 1,"checked",""); echo "".S_NOT_CLASSIFIED."
"; $checked=iif( (2&$severity) == 2,"checked",""); echo "".S_INFORMATION."
"; $checked=iif( (4&$severity) == 4,"checked",""); echo "".S_WARNING."
"; $checked=iif( (8&$severity) == 8,"checked",""); echo "".S_AVERAGE."
"; $checked=iif( (16&$severity) ==16,"checked",""); echo "".S_HIGH."
"; $checked=iif( (32&$severity) ==32,"checked",""); echo "".S_DISASTER."
"; show_table2_v_delimiter($col++); echo "Status"; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter2($col++); echo ""; if(isset($_REQUEST["mediaid"])) { // echo ""; echo ""; } echo ""; show_table2_header_end(); } function insert_host_form() { global $_REQUEST; $host=@iif(isset($_REQUEST["host"]),$_REQUEST["host"],""); $port=@iif(isset($_REQUEST["port"]),$_REQUEST["port"],get_profile("HOST_PORT",10050)); $status=@iif(isset($_REQUEST["status"]),$_REQUEST["status"],HOST_STATUS_MONITORED); $useip=@iif(isset($_REQUEST["useip"]),$_REQUEST["useip"],"off"); $newgroup=@iif(isset($_REQUEST["newgroup"]),$_REQUEST["newgroup"],""); $ip=@iif(isset($_REQUEST["ip"]),$_REQUEST["ip"],""); $host_templateid=@iif(isset($_REQUEST["host_templateid"]),$_REQUEST["host_templateid"],""); if($useip!="on") { $useip=""; } else { $useip="checked"; } if(isset($_REQUEST["register"]) && ($_REQUEST["register"] == "change")) { $result=get_host_by_hostid($_REQUEST["hostid"]); $host=$result["host"]; $port=$result["port"]; $status=$result["status"]; $useip=$result["useip"]; $ip=$result["ip"]; if($useip==0) { $useip=""; } else { $useip="checked"; } } else { } echo ""; show_form_begin("hosts.host"); echo S_HOST; $col=0; show_table2_v_delimiter($col++); echo ""; if(isset($_REQUEST["hostid"])) { echo ""; } if(isset($_REQUEST["groupid"])) { echo ""; } echo S_HOST; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_GROUPS; show_table2_h_delimiter(); $result=DBselect("select distinct groupid,name from groups order by name"); while($row=DBfetch($result)) { if(isset($_REQUEST["hostid"])) { $sql="select count(*) as count from hosts_groups where hostid=".$_REQUEST["hostid"]." and groupid=".$row["groupid"]; $result2=DBselect($sql); $row2=DBfetch($result2); if($row2["count"]==0) { echo "".$row["name"]; } else { echo "".$row["name"]; } } else { echo "".$row["name"]; } echo "
"; } echo ""; show_table2_v_delimiter($col++); echo nbsp(S_NEW_GROUP); show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo nbsp(S_USE_IP_ADDRESS); show_table2_h_delimiter(); // onChange does not work on some browsers: MacOS, KDE browser // echo ""; echo ""; if($useip=="checked") { show_table2_v_delimiter($col++); echo S_IP_ADDRESS; show_table2_h_delimiter(); echo ""; } else { echo ""; } show_table2_v_delimiter($col++); echo S_PORT; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); echo S_STATUS; show_table2_h_delimiter(); echo ""; show_table2_v_delimiter($col++); // echo nbsp(S_USE_THE_HOST_AS_A_TEMPLATE); echo nbsp(S_USE_TEMPLATES_OF_THIS_HOST); show_table2_h_delimiter(); echo ""; show_table2_v_delimiter2(); echo ""; if(isset($_REQUEST["hostid"])) { echo ""; echo ""; } echo ""; show_table2_header_end(); } ?>