diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-03-21 14:44:38 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-03-21 14:44:38 +0000 |
| commit | 07ea4eb6c1927b132fc294271841066c11ab2955 (patch) | |
| tree | 05a082481c5e15b9faa047878a75e503e0b1ba15 /frontends/php | |
| parent | d76992f73658df06227395e4a79c4366294efebe (diff) | |
- developed remote commads execution on specific actions (Eugene)
- added "URL" module for screens (Eugene)
- fix some bugs
- clean code
git-svn-id: svn://svn.zabbix.com/trunk@2703 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/actionconf.php | 112 | ||||
| -rw-r--r-- | frontends/php/config.php | 3 | ||||
| -rw-r--r-- | frontends/php/css.css | 5 | ||||
| -rw-r--r-- | frontends/php/include/actions.inc.php | 70 | ||||
| -rw-r--r-- | frontends/php/include/classes/ciframe.inc.php | 89 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 3 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 106 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 1 | ||||
| -rw-r--r-- | frontends/php/include/screens.inc.php | 53 | ||||
| -rw-r--r-- | frontends/php/screenedit.php | 4 | ||||
| -rw-r--r-- | frontends/php/services.php | 19 | ||||
| -rw-r--r-- | frontends/php/users.php | 4 |
13 files changed, 334 insertions, 139 deletions
diff --git a/frontends/php/actionconf.php b/frontends/php/actionconf.php index 72e8c03d..9407e812 100644 --- a/frontends/php/actionconf.php +++ b/frontends/php/actionconf.php @@ -28,28 +28,29 @@ ?> <?php - $_REQUEST["actiontype"] = get_request("actiontype",0); + if(!check_anyright("Configuration of Zabbix","U")) + { + show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>"); + show_page_footer(); + exit; + } + + $_REQUEST["actiontype"] = get_request("actiontype",get_profile("web.actionconf.actiontype",0)); - update_profile("web.menu.config.last",$page["file"]); -// if(($_REQUEST["triggerid"]!=0)&&!check_right_on_trigger("U",$_REQUEST["triggerid"])) -// { -// show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>"); -// show_page_footer(); -// exit; -// } ?> <?php // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields=array( - "actiontype"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), NULL), + "actiontype"=> array(T_ZBX_INT, O_MAND, NULL, IN("0,1"), NULL), "actionid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), "source"=> array(T_ZBX_INT, O_OPT, NULL, IN("0"), 'isset({save})'), "recipient"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), 'isset({save})'), "userid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, 'isset({save})'), "delay"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'isset({save})'), - "subject"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'), - "message"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'), + "subject"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '{actiontype}==0&&isset({save})'), + "message"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '{actiontype}==0&&isset({save})'), + "scripts"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '{actiontype}==1&&isset({save})'), "repeat"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), 'isset({save})'), "status"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), 'isset({save})'), @@ -90,6 +91,11 @@ ?> <?php + update_profile("web.actionconf.actiontype",$_REQUEST["actiontype"]); + update_profile("web.menu.config.last",$page["file"]); +?> + +<?php if(isset($_REQUEST["save"])) { if($_REQUEST["repeat"]==0) @@ -101,15 +107,19 @@ if(isset($_REQUEST["actionid"])) { $actionid=$_REQUEST["actionid"]; - $result = update_action($actionid, $_REQUEST['userid'], $_REQUEST["delay"], + $result = update_action($actionid, + $_REQUEST['actiontype'],$_REQUEST['userid'],$_REQUEST["delay"], $_REQUEST["subject"], $_REQUEST["message"],$_REQUEST["recipient"], - $_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"],$_REQUEST["status"]); + $_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"],$_REQUEST["status"], + $_REQUEST["scripts"]); show_messages($result,S_ACTION_UPDATED,S_CANNOT_UPDATE_ACTION); } else { - $actionid=add_action($_REQUEST['userid'], $_REQUEST["delay"], + $actionid=add_action( + $_REQUEST['actiontype'],$_REQUEST['userid'],$_REQUEST["delay"], $_REQUEST["subject"],$_REQUEST["message"],$_REQUEST["recipient"], - $_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"],$_REQUEST["status"]); + $_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"],$_REQUEST["status"], + $_REQUEST["scripts"]); $result=$actionid; show_messages($result,S_ACTION_ADDED,S_CANNOT_ADD_ACTION); @@ -124,18 +134,13 @@ if(isset($_REQUEST["conditions"])) foreach($_REQUEST["conditions"] as $val) add_action_condition($actionid,$val["type"],$val["operator"],$val["value"]); - if($_REQUEST["recipient"] == RECIPIENT_TYPE_USER) - { - $user=get_user_by_userid($_REQUEST["userid"]); - add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_ACTION, - "User [".$user["alias"]."] subject [".$_REQUEST["subject"]."]"); - } + if($_REQUEST["actiontype"] == ACTION_TYPE_MESSAGE) + $msg = "subject [".$_REQUEST["subject"]."]"; else - { - $group=get_usergroup_by_groupid($_REQUEST["userid"]); - add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_ACTION, - "User [".$group["name"]."] subject [".$_REQUEST["subject"]."]"); - } + $msg = "command [".$_REQUEST["scripts"]."]"; + + add_audit(!isset($_REQUEST["actionid"]) ? AUDIT_ACTION_ADD : AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_ACTION, $msg); + unset($_REQUEST["form"]); } } @@ -218,8 +223,8 @@ $form = new CForm(); $cmbType = new CComboBox("actiontype",$_REQUEST["actiontype"],"submit()"); - $cmbType->AddItem(0,S_SEND_MESSAGE); - $cmbType->AddItem(1,S_REMOTE_COMMAND,NULL,'no'); + $cmbType->AddItem(ACTION_TYPE_MESSAGE,S_SEND_MESSAGE); + $cmbType->AddItem(ACTION_TYPE_COMMAND,S_REMOTE_COMMAND); $form->AddItem($cmbType); $form->AddItem(SPACE."|".SPACE); @@ -237,18 +242,14 @@ "CheckAll('".$form->GetName()."','all_items');"), S_SOURCE ), - S_CONDITIONS,S_SEND_MESSAGE_TO, - S_DELAY,S_SUBJECT,S_REPEATS,S_STATUS)); + S_CONDITIONS, + $_REQUEST["actiontype"] == ACTION_TYPE_MESSAGE ? S_SEND_MESSAGE_TO : S_REMOTE_COMMAND, + S_DELAY, + $_REQUEST["actiontype"] == ACTION_TYPE_MESSAGE ? S_SUBJECT : NULL, + S_REPEATS, + S_STATUS)); - if(isset($_REQUEST["actiontype"])&&($_REQUEST["actiontype"]==1)) - { - $sql="select * from actions where actiontype=1 order by actiontype, source"; - } - else - { - $sql="select * from actions where actiontype=0 order by actiontype, source"; - } - $result=DBselect($sql); + $result=DBselect("select * from actions where actiontype=".$_REQUEST["actiontype"]." order by actiontype, source"); while($row=DBfetch($result)) { $conditions=""; @@ -259,28 +260,37 @@ $conditions=$conditions.get_condition_desc($condition["conditiontype"], $condition["operator"],$condition["value"]).BR; } - - if($row["recipient"] == RECIPIENT_TYPE_USER) - { - $user=get_user_by_userid($row["userid"]); - $recipient=$user["alias"]; - } - else + + + if($_REQUEST["actiontype"] == ACTION_TYPE_MESSAGE) + { + if($row["recipient"] == RECIPIENT_TYPE_USER) + { + $user=get_user_by_userid($row["userid"]); + $recipient=$user["alias"]; + } + else + { + $groupd=get_usergroup_by_groupid($row["userid"]); + $recipient=$groupd["name"]; + } + $subject = htmlspecialchars($row["subject"]); + }elseif($_REQUEST["actiontype"] == ACTION_TYPE_COMMAND) { - $groupd=get_usergroup_by_groupid($row["userid"]); - $recipient=$groupd["name"]; + $recipient = nl2br(htmlspecialchars($row["scripts"])); + $subject = NULL; } if($row["status"] == ACTION_STATUS_DISABLED) { $status= new CLink(S_DISABLED, - "actionconf.php?group_enable=1&g_actionid%5B%5D=".$row["actionid"], + "actionconf.php?group_enable=1&g_actionid%5B%5D=".$row["actionid"].url_param("actiontype"), 'disabled'); } else if($row["status"] == ACTION_STATUS_ENABLED) { $status= new CLink(S_ENABLED, - "actionconf.php?group_disable=1&g_actionid%5B%5D=".$row["actionid"], + "actionconf.php?group_disable=1&g_actionid%5B%5D=".$row["actionid"].url_param("actiontype"), 'enabled'); } @@ -300,7 +310,7 @@ $conditions, $recipient, htmlspecialchars($row["delay"]), - htmlspecialchars($row["subject"]), + $subject, $row["maxrepeats"] == 0 ? S_NO_REPEATS : $row["maxrepeats"], $status )); diff --git a/frontends/php/config.php b/frontends/php/config.php index d9ea9843..7844628c 100644 --- a/frontends/php/config.php +++ b/frontends/php/config.php @@ -32,8 +32,7 @@ <?php if(!check_anyright("Configuration of Zabbix","U")) { - show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font ->"); + show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>"); show_page_footer(); exit; } diff --git a/frontends/php/css.css b/frontends/php/css.css index 8762efff..c051ca17 100644 --- a/frontends/php/css.css +++ b/frontends/php/css.css @@ -156,6 +156,7 @@ table.screen_edit td text-align: center; vertical-align: middle; } + table.screen_edit td.def_def { text-align: center; vertical-align: middle; } table.screen_edit td.def_top { text-align: center; vertical-align: top; } table.screen_edit td.def_mdl { text-align: center; vertical-align: middle; } @@ -188,6 +189,10 @@ table.screen_view td vertical-align: middle; } +table.screen_view iframe { + border: 0px; +} + table.screen_view td.def_def { text-align: center; vertical-align: middle; } table.screen_view td.def_top { text-align: center; vertical-align: top; } table.screen_view td.def_mdl { text-align: center; vertical-align: middle; } diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index 25a64cb0..c9c49b80 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -36,7 +36,7 @@ # Add Action - function add_action($id,$delay,$subject,$message,$recipient,$maxrepeats,$repeatdelay,$status) + function add_action($actiontype,$userid,$delay,$subject,$message,$recipient,$maxrepeats,$repeatdelay,$status,$scripts) { // if(!check_right_on_trigger("A",$triggerid)) // { @@ -44,24 +44,46 @@ // return 0; // } - $sql="insert into actions (userid,delay,nextcheck,subject,message,recipient,". - "maxrepeats,repeatdelay,status) values ($id,$delay,0,".zbx_dbstr($subject).",". - zbx_dbstr($message).",$recipient,$maxrepeats,$repeatdelay,$status)"; + if($actiontype == ACTION_TYPE_MESSAGE) + { + $scripts = ""; + } + elseif($actiontype == ACTION_TYPE_COMMAND) + { + $subject = $message = ""; + $userid = 0; + $recipient = 0; + if(!check_commands($scripts)) return FALSE; + } + $sql="insert into actions (actiontype,userid,delay,nextcheck,subject,message,recipient,". + "maxrepeats,repeatdelay,status,scripts) values ($actiontype,$userid,$delay,0,".zbx_dbstr($subject).",". + zbx_dbstr($message).",$recipient,$maxrepeats,$repeatdelay,$status,".zbx_dbstr($scripts).")"; $result=DBexecute($sql); return DBinsert_id($result,"actions","actionid"); } # Update Action - function update_action($actionid, $id, $delay, $subject, $message, $recipient, $maxrepeats, $repeatdelay, $status) + function update_action($actionid,$actiontype,$userid,$delay,$subject,$message,$recipient,$maxrepeats,$repeatdelay,$status,$scripts) { // if(!check_right_on_trigger("U",$triggerid)) // { // error("Insufficient permissions"); // return 0; // } + if($actiontype == ACTION_TYPE_MESSAGE) + { + $scripts = ""; + } + elseif($actiontype == ACTION_TYPE_COMMAND) + { + $subject = $message = ""; + $userid = 0; + $recipient = 0; + if(!check_commands($scripts)) return FALSE; + } - $result=DBexecute("update actions set userid=$id,delay=$delay,nextcheck=0,subject=".zbx_dbstr($subject).",message=".zbx_dbstr($message).",recipient=$recipient,maxrepeats=$maxrepeats, repeatdelay=$repeatdelay,status=$status where actionid=$actionid"); + $result=DBexecute("update actions set actiontype=$actiontype,userid=$userid,delay=$delay,nextcheck=0,subject=".zbx_dbstr($subject).",message=".zbx_dbstr($message).",recipient=$recipient,maxrepeats=$maxrepeats, repeatdelay=$repeatdelay,status=$status,scripts=".zbx_dbstr($scripts)." where actionid=$actionid"); return $result; } @@ -145,10 +167,10 @@ $message=str_replace("{".$host_template["host"].":", "{".$host["host"].":", $action["message"]); - add_action($row2["triggerid"], $action["userid"], $action["good"], + add_action($action["actiontype"],$row2["triggerid"], $action["userid"], $action["good"], $action["delay"], $action["subject"], $message, $action["scope"], $action["severity"], $action["recipient"], $action["maxrepeats"], - $action["repeatdelay"]); + $action["repeatdelay"],$action["scripts"]); } } } @@ -242,7 +264,7 @@ { $host=get_host_by_hostid($row["hostid"]); $message=str_replace("{".$host_template["host"].":", "{".$host["host"].":", $action["message"]); - update_action($row3["actionid"], $row2["triggerid"], $action["userid"], $action["good"], $action["delay"], $action["subject"], $message, $action["scope"], $action["severity"], $action["recipient"], $action["maxrepeats"],$action["repeatdelay"]); + update_action($row3["actionid"], $action["actiontype"],$row2["triggerid"], $action["userid"], $action["good"], $action["delay"], $action["subject"], $message, $action["scope"], $action["severity"], $action["recipient"], $action["maxrepeats"],$action["repeatdelay"],$action["scripts"]); } } @@ -343,4 +365,34 @@ { return DBexecute("update actions set status=$status where actionid=$actionid"); } + + function check_commands($commands) + { + $cmd_list = split("\n",$commands); + foreach($cmd_list as $cmd) + { + $cmd = trim($cmd, "\x00..\x1F"); + if(!ereg("^([a-zA-Z0-9]{1,})(:|#)(([a-zA-Z]\:|/){0,1}([a-zA-Z0-9_\.\\/]{3,}))$",$cmd,$cmd_items)){ + error("incorrect command: '$cmd'"); + return FALSE; + } + if($cmd_items[2] == "#") + { // group + if(DBnum_rows(DBselect("select groupid from groups where name=".zbx_dbstr($cmd_items[1])))!=1) + { + error("Uncnown group name: '".$cmd_items[1]."' in command ".$cmd."'"); + return FALSE; + } + } + elseif($cmd_items[2] == ":") + { // host + if(DBnum_rows(DBselect("select hostid from hosts where host=".zbx_dbstr($cmd_items[1])))!=1) + { + error("Uncnown host name '".$cmd_items[1]."' in command '".$cmd."'"); + return FALSE; + } + } + } + return TRUE; + } ?> diff --git a/frontends/php/include/classes/ciframe.inc.php b/frontends/php/include/classes/ciframe.inc.php new file mode 100644 index 00000000..9e9b4376 --- /dev/null +++ b/frontends/php/include/classes/ciframe.inc.php @@ -0,0 +1,89 @@ +<?php +/* +** ZABBIX +** Copyright (C) 2000-2005 SIA Zabbix +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +**/ +?> +<?php + class CIFrame extends CTag + { +/* public */ + function CIFrame($src=NULL,$width="100%",$height="100%",$scrolling="no") + { + parent::CTag("iframe","yes"); + + $this->tag_start= ""; + $this->tag_end = ""; + $this->tag_body_start = ""; + $this->tag_body_end = ""; + + $this->SetSrc($src); + $this->SetWidth($width); + $this->SetHeight($height); + $this->SetScrolling($scrolling); + } + function SetSrc($value=NULL) + { + if(is_null($value)) + { + return $this->DelOption("src"); + } + elseif(!is_string($value)) + { + return $this->error("Incorrect value for SetSrc [$value]"); + } + return $this->AddOption("src",$value); + } + function SetWidth($value) + { + if(is_null($value)) + { + return $this->DelOption("width"); + } + elseif(!is_string($value)) + { + return $this->error("Incorrect value for SetWidth [$value]"); + } + + $this->AddOption("width",$value); + } + function SetHeight($value) + { + if(is_null($value)) + { + return $this->DelOption("height"); + } + elseif(!is_string($value)) + { + return $this->error("Incorrect value for SetHeight [$value]"); + } + + $this->AddOption("height",$value); + } + function SetScrolling($value) + { + if(is_null($value)) $value = 'no'; + + if($value=='no' && $value=='yes' && $value=='auto') + { + return $this->error("Incorrect value for SetScrolling [$value]"); + } + + $this->AddOption("scrolling",$value); + } + } +?> diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index e1f4ce3a..283143d2 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -83,6 +83,7 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!! include_once("include/classes/cformtable.inc.php"); include_once("include/classes/cmap.inc.php"); include_once("include/classes/cflash.inc.php"); + include_once("include/classes/ciframe.inc.php"); // Include Tactical Overview modules include_once("include/classes/chostsinfo.mod.php"); @@ -1145,7 +1146,7 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!! } $table->AddRow(array( - new CCol(new CLink(new CImg("images/general/zabbix.png","ZABBIX")), + new CCol(new CLink(new CImg("images/general/zabbix.png","ZABBIX"),"http://www.zabbix.com"), "page_header_l"), new CCol($col_r, "page_header_r"))); @@ -3075,4 +3076,5 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!! </script> "; } + ?> diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 816d6b7d..0bdf2d0a 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -143,6 +143,9 @@ define("ACTION_STATUS_ENABLED",0); define("ACTION_STATUS_DISABLED",1); + define("ACTION_TYPE_MESSAGE",0); + define("ACTION_TYPE_COMMAND",1); + define("TRIGGER_STATUS_ENABLED",0); define("TRIGGER_STATUS_DISABLED",1); define("TRIGGER_STATUS_UNKNOWN",2); diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 0e4aa9b3..f3dc8ee7 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -1173,6 +1173,7 @@ $maxrepeats = $action["maxrepeats"]; $repeatdelay = $action["repeatdelay"]; $status = $action["status"]; + $scripts = $action["scripts"]; if(isset($_REQUEST["repeat"])) { @@ -1203,7 +1204,7 @@ else { $source = get_request("source",0); - $actiontype = get_request("actiontype",0); + $actiontype = get_request("actiontype",ACTION_TYPE_MESSAGE); $delay = get_request("delay",30); $subject = get_request("subject","{TRIGGER.NAME}: {STATUS}"); @@ -1215,14 +1216,17 @@ $repeatdelay = get_request("repeatdelay",600); $repeat = get_request("repeat",0); $status = get_request("status",ACTION_STATUS_ENABLED); - - if($recipient==RECIPIENT_TYPE_GROUP) - $uid = get_request("usrgrpid",NULL); - else - $uid = get_request("userid",NULL); + $uid = get_request("userid",0); + $scripts = get_request("scripts",""); } + $cmbActionType = new CComboBox('actiontype', $actiontype,'submit()'); + $cmbActionType->AddItem(ACTION_TYPE_MESSAGE,S_SEND_MESSAGE); + $cmbActionType->AddItem(ACTION_TYPE_COMMAND,S_REMOTE_COMMAND); + $frmAction->AddRow(S_ACTION_TYPE, $cmbActionType); + + // prepare condition list $cond_el=array(); $i=0; @@ -1369,50 +1373,57 @@ // 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,NULL,'no'); - - $frmAction->AddRow(S_ACTION_TYPE, $cmbActionType); + $frmAction->AddRow( + $actiontype == ACTION_TYPE_MESSAGE ? S_DELAY_BETWEEN_MESSAGES_IN_SEC : S_DELAY_BETWEEN_EXECUTIONS_IN_SEC, + new CTextBox('delay',$delay,5)); - $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) + if($actiontype == ACTION_TYPE_MESSAGE) { - - $cmbGroups = new CComboBox('userid', $uid); - - $sql="select usrgrpid,name from usrgrp order by name"; - $groups=DBselect($sql); - while($group=DBfetch($groups)) + $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->AddItem($group['usrgrpid'],$group['name']); + + $cmbGroups = new CComboBox('userid', $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_GROUP, $cmbGroups); + $frmAction->AddRow(S_USER, $cmbUser); + } + $frmAction->AddRow(S_SUBJECT, new CTextBox('subject',$subject,80)); + $frmAction->AddRow(S_MESSAGE, new CTextArea('message',$message,77,7)); + $frmAction->AddVar("scripts",$scripts); } 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_REMOTE_COMMAND, new CTextArea('scripts',$scripts,77,7)); + $frmAction->AddVar("recipient",$recipient); + $frmAction->AddVar("userid",$uid); + $frmAction->AddVar("subject",$subject); + $frmAction->AddVar("message",$message); } - $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); @@ -1648,6 +1659,7 @@ $valign = $irow["valign"]; $halign = $irow["halign"]; $style = $irow["style"]; + $url = $irow["url"]; } else { @@ -1661,9 +1673,9 @@ $valign = get_request("valign", VALIGN_DEFAULT); $halign = get_request("halign", HALIGN_DEFAULT); $style = get_request("style", 0); + $url = get_request("url", ""); } - $form->AddVar("screenid",$_REQUEST["screenid"]); $cmbRes = new CCombobox("resource",$resource,"submit()"); @@ -1678,7 +1690,7 @@ $cmbRes->AddItem(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, S_TRIGGERS_OVERVIEW); $cmbRes->AddItem(SCREEN_RESOURCE_DATA_OVERVIEW, S_DATA_OVERVIEW); $cmbRes->AddItem(SCREEN_RESOURCE_CLOCK, S_CLOCK); -// $cmbRes->AddItem(SCREEN_RESOURCE_URL, S_URL); + $cmbRes->AddItem(SCREEN_RESOURCE_URL, S_URL); $form->AddRow(S_RESOURCE,$cmbRes); if($resource == SCREEN_RESOURCE_GRAPH) @@ -1821,7 +1833,12 @@ $form->AddVar("style", 0); } - if(in_array($resource,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_CLOCK))) + if(in_array($resource,array(SCREEN_RESOURCE_URL))) + { + $form->AddRow(S_URL, new CTextBox("url",$url,60)); + } + + if(in_array($resource,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_CLOCK,SCREEN_RESOURCE_URL))) { $form->AddRow(S_WIDTH, new CTextBox("width",$width,5)); $form->AddRow(S_HEIGHT, new CTextBox("height",$height,5)); @@ -1832,7 +1849,8 @@ $form->AddVar("height", 0); } - if(in_array($resource,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_MAP,SCREEN_RESOURCE_CLOCK))) + if(in_array($resource,array(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_SIMPLE_GRAPH,SCREEN_RESOURCE_MAP, + SCREEN_RESOURCE_CLOCK,SCREEN_RESOURCE_URL))) { $cmbHalign = new CComboBox("halign",$halign); $cmbHalign->AddItem(HALIGN_CENTER, S_CENTER); diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 1c59a4c6..a37fd3eb 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -81,6 +81,7 @@ "S_USER"=> "User", "S_ON_OR_OFF"=> "ON or OFF", "S_DELAY_BETWEEN_MESSAGES_IN_SEC"=> "Delay between messages (in sec)", + "S_DELAY_BETWEEN_EXECUTIONS_IN_SEC"=> "Delay between executions (in sec)", "S_MESSAGE"=> "Message", "S_THIS_TRIGGER_ONLY"=> "This trigger only", "S_ALL_TRIGGERS_OF_THIS_HOST"=> "All triggers of this host", diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php index 8ade536d..30698be7 100644 --- a/frontends/php/include/screens.inc.php +++ b/frontends/php/include/screens.inc.php @@ -54,18 +54,19 @@ return DBexecute("delete from screens where screenid=$screenid"); } - function add_screen_item($resource,$screenid,$x,$y,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style) + function add_screen_item($resource,$screenid,$x,$y,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,$url) { $sql="delete from screens_items where screenid=$screenid and x=$x and y=$y"; DBexecute($sql); - $sql="insert into screens_items (resource,screenid,x,y,resourceid,width,height,colspan,rowspan,elements,valign,halign,style)". - " values ($resource,$screenid,$x,$y,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style)"; + $sql="insert into screens_items (resource,screenid,x,y,resourceid,width,height,colspan,rowspan,elements,valign,halign,style,url)". + " values ($resource,$screenid,$x,$y,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,". + zbx_dbstr($url).")"; return DBexecute($sql); } - function update_screen_item($screenitemid,$resource,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style) + function update_screen_item($screenitemid,$resource,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,$url) { - $sql="update screens_items set resource=$resource,resourceid=$resourceid,width=$width,height=$height,colspan=$colspan,rowspan=$rowspan,elements=$elements,valign=$valign,halign=$halign,style=$style where screenitemid=$screenitemid"; + $sql="update screens_items set resource=$resource,resourceid=$resourceid,width=$width,height=$height,colspan=$colspan,rowspan=$rowspan,elements=$elements,valign=$valign,halign=$halign,style=$style,url=".zbx_dbstr($url)." where screenitemid=$screenitemid"; return DBexecute($sql); } @@ -171,6 +172,7 @@ $valign = $irow["valign"]; $halign = $irow["halign"]; $style = $irow["style"]; + $url = $irow["url"]; } else { @@ -186,16 +188,16 @@ $valign = VALIGN_DEFAULT; $halign = HALIGN_DEFAULT; $style = 0; + $url = ""; } - if($editmode == 1 && $screenitemid!=0) - $url = "screenedit.php?form=update".url_param("screenid"). + $action = "screenedit.php?form=update".url_param("screenid"). "&screenitemid=$screenitemid#form"; elseif ($editmode == 1 && $screenitemid==0) - $url = "screenedit.php?form=update".url_param("screenid")."&x=$c&y=$r#form"; + $action = "screenedit.php?form=update".url_param("screenid")."&x=$c&y=$r#form"; else - $url = NULL; + $action = NULL; if($editmode == 1 && isset($_REQUEST["form"]) && isset($_REQUEST["x"]) && $_REQUEST["x"]==$c && @@ -211,25 +213,25 @@ elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_GRAPH) ) { if($editmode == 0) - $url = "charts.php?graphid=$resourceid".url_param("period"). + $action = "charts.php?graphid=$resourceid".url_param("period"). url_param("inc").url_param("dec"); $item = new CLink( new CImg("chart2.php?graphid=$resourceid&width=$width&height=$height". "&period=$effectiveperiod".url_param("stime").url_param("from")), - $url + $action ); } elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_SIMPLE_GRAPH) ) { if($editmode == 0) - $url = "history.php?action=showhistory&itemid=$resourceid". + $action = "history.php?action=showhistory&itemid=$resourceid". url_param("period").url_param("inc").url_param("dec"); $item = new CLink( new CImg("chart.php?itemid=$resourceid&width=$width&height=$height". "&period=$effectiveperiod".url_param("stime").url_param("from")), - $url + $action ); } elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_MAP) ) @@ -242,52 +244,57 @@ $image_map->SetMap($action_map->GetName()); $item = array($action_map,$image_map); } else { - $item = new CLink($image_map, $url); + $item = new CLink($image_map, $action); } } elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_PLAIN_TEXT) ) { $item = array(get_screen_plaintext($resourceid,$elements)); - if($editmode == 1) array_push($item,new CLink(S_CHANGE,$url)); + if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); } elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_HOSTS_INFO) ) { $item = array(new CHostsInfo($style)); - if($editmode == 1) array_push($item,new CLink(S_CHANGE,$url)); + if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); } elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_TRIGGERS_INFO) ) { $item = array(new CTriggersInfo($style)); - if($editmode == 1) array_push($item,new CLink(S_CHANGE,$url)); + if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); } elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_SERVER_INFO) ) { $item = array(new CServerInfo()); - if($editmode == 1) array_push($item,new CLink(S_CHANGE,$url)); + if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); } elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_CLOCK) ) { - $item = new CFlashClock($width, $height, $style, $url); + $item = new CFlashClock($width, $height, $style, $action); } elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_SCREEN) ) { $item = array(get_screen($resourceid, 2, $effectiveperiod)); - if($editmode == 1) array_push($item,new CLink(S_CHANGE,$url)); + if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); } elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_TRIGGERS_OVERVIEW) ) { $item = array(get_triggers_overview($resourceid)); - if($editmode == 1) array_push($item,new CLink(S_CHANGE,$url)); + if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); } elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_DATA_OVERVIEW) ) { $item = array(get_items_data_overview($resourceid)); - if($editmode == 1) array_push($item,new CLink(S_CHANGE,$url)); + if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action)); + } + elseif( ($screenitemid!=0) && ($resource==SCREEN_RESOURCE_URL) ) + { + $item = array(new CIFrame($url,$width,$height,"auto")); + if($editmode == 1) array_push($item,BR,new CLink(S_CHANGE,$action)); } else { $item = array(SPACE); - if($editmode == 1) array_push($item,BR,new CLink(S_CHANGE,$url)); + if($editmode == 1) array_push($item,BR,new CLink(S_CHANGE,$action)); } $str_halign = "def"; diff --git a/frontends/php/screenedit.php b/frontends/php/screenedit.php index 0ce45d8c..a2e67199 100644 --- a/frontends/php/screenedit.php +++ b/frontends/php/screenedit.php @@ -49,7 +49,7 @@ $_REQUEST["resource"],$_REQUEST["resourceid"],$_REQUEST["width"], $_REQUEST["height"],$_REQUEST["colspan"],$_REQUEST["rowspan"], $_REQUEST["elements"],$_REQUEST["valign"], - $_REQUEST["halign"],$_REQUEST["style"]); + $_REQUEST["halign"],$_REQUEST["style"],$_REQUEST["url"]); show_messages($result, S_ITEM_UPDATED, S_CANNOT_UPDATE_ITEM); } @@ -60,7 +60,7 @@ $_REQUEST["x"],$_REQUEST["y"],$_REQUEST["resourceid"], $_REQUEST["width"],$_REQUEST["height"],$_REQUEST["colspan"], $_REQUEST["rowspan"],$_REQUEST["elements"],$_REQUEST["valign"], - $_REQUEST["halign"],$_REQUEST["style"]); + $_REQUEST["halign"],$_REQUEST["style"],$_REQUEST["url"]); show_messages($result, S_ITEM_ADDED, S_CANNOT_ADD_ITEM); } diff --git a/frontends/php/services.php b/frontends/php/services.php index 28ab683e..225dafb2 100644 --- a/frontends/php/services.php +++ b/frontends/php/services.php @@ -365,20 +365,29 @@ $soft = get_request("soft",1); } - $cmbServices = new CComboBox("serviceupid",$serviceupid); - $result=DBselect("select serviceid,triggerid,name from services order by name"); + $frmLink->AddVar("serviceupid",$_REQUEST["serviceid"]); + + $service = get_service_by_serviceid($_REQUEST["serviceid"]); + $name = $service["name"]; + if(isset($service["triggerid"])) + $name .= ": ".expand_trigger_description($service["triggerid"]); + $frmLink->AddRow(S_SERVICE_1, new CTextBox("service",$name,60,NULL,'yes')); + + $cmbServices = new CComboBox("servicedownid",$servicedownid); + $result=DBselect("select serviceid,triggerid,name from services where serviceid<>$serviceupid order by name"); while($row=Dbfetch($result)) { + if(DBnum_rows(DBselect("select linkid from services_links". + " where servicedownid<>$servicedownid and serviceupid=$serviceupid and servicedownid=".$row["serviceid"]))) + continue; + $name = $row["name"]; if(isset($row["triggerid"])) $name .= ": ".expand_trigger_description($row["triggerid"]); $cmbServices->AddItem($row["serviceid"],$name); } - $frmLink->AddRow(S_SERVICE_1, $cmbServices); - $cmbServices->SetName("servicedownid"); - $cmbServices->SetValue($servicedownid); $frmLink->AddRow(S_SERVICE_2, $cmbServices); $frmLink->AddRow(S_SOFT_LINK_Q, new CCheckBox("soft",$soft)); diff --git a/frontends/php/users.php b/frontends/php/users.php index 0c00d1ee..6274e5d5 100644 --- a/frontends/php/users.php +++ b/frontends/php/users.php @@ -225,9 +225,9 @@ " where userid=".$db_user["userid"]." and lastaccess-600<".time()); $db_ses_cnt=DBfetch($db_sessions); if($db_ses_cnt["count"]>0) - $online=new CCol(S_YES,"on"); + $online=new CCol(S_YES,"enabled"); else - $online=new CCol(S_NO,"off"); + $online=new CCol(S_NO,"disabled"); if(check_right("User","U",$db_user["userid"])) { |
