diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-05-09 12:18:11 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-05-09 12:18:11 +0000 |
| commit | 7524ac12a656abc42d6b83a3f7be3ae40d09d3ff (patch) | |
| tree | 475c8217064ac94dc22d7f30f578d5af3a01aae1 /frontends/php/hosts.php | |
| parent | a6b057c94aab1d1dd636fcce5237556164624046 (diff) | |
- [DEV-149] added hosts masss update functionality (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5691 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/hosts.php')
| -rw-r--r-- | frontends/php/hosts.php | 336 |
1 files changed, 222 insertions, 114 deletions
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php index 43b5b2ad..af6957c9 100644 --- a/frontends/php/hosts.php +++ b/frontends/php/hosts.php @@ -19,28 +19,28 @@ **/ ?> <?php - require_once "include/config.inc.php"; - require_once "include/hosts.inc.php"; - require_once "include/forms.inc.php"; + require_once 'include/config.inc.php'; + require_once 'include/hosts.inc.php'; + require_once 'include/forms.inc.php'; - $page["title"] = "S_HOSTS"; - $page["file"] = "hosts.php"; + $page['title'] = "S_HOSTS"; + $page['file'] = 'hosts.php'; $page['hist_arg'] = array('groupid','config','hostid'); -include_once "include/page_header.php"; +include_once 'include/page_header.php'; - $_REQUEST["config"] = get_request("config",get_profile("web.hosts.config",0)); + $_REQUEST['config'] = get_request('config',get_profile('web.hosts.config',0)); $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY); - if(isset($_REQUEST["hostid"]) && $_REQUEST["hostid"] > 0 && !uint_in_array($_REQUEST["hostid"], $available_hosts)) { + if(isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0 && !uint_in_array($_REQUEST['hostid'], $available_hosts)) { access_deny(); } - if(isset($_REQUEST["apphostid"]) && $_REQUEST["apphostid"] > 0 && !uint_in_array($_REQUEST["apphostid"], $available_hosts)) { + if(isset($_REQUEST['apphostid']) && $_REQUEST['apphostid'] > 0 && !uint_in_array($_REQUEST['apphostid'], $available_hosts)) { access_deny(); } - if(isset($_REQUEST["groupid"]) && $_REQUEST["groupid"] > 0){ - if(!uint_in_array($_REQUEST["groupid"], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY))){ + if(isset($_REQUEST['groupid']) && $_REQUEST['groupid'] > 0){ + if(!uint_in_array($_REQUEST['groupid'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY))){ access_deny(); } } @@ -49,81 +49,86 @@ include_once "include/page_header.php"; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields=array( // 0 - hosts; 1 - groups; 2 - linkages; 3 - templates; 4 - applications; 5 - Proxies; 6 - host mass update - "config"=> array(T_ZBX_INT, O_OPT, P_SYS, IN("0,1,2,3,4,5,6"), NULL), + 'config'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1,2,3,4,5'), NULL), /* ARAYS */ - "hosts"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), - "groups"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), - "applications"=>array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), + 'hosts'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), + 'groups'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), + 'applications'=>array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), /* host */ - "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({config})&&({config}==0||{config}==5||{config}==2)&&isset({form})&&({form}=="update")'), - "host"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({config})&&({config}==0||{config}==3||{config}==5)&&isset({save})'), - 'proxy_hostid'=>array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({config})&&({config}==0)&&isset({save})'), - "dns"=> array(T_ZBX_STR, O_OPT, NULL, NULL, '(isset({config})&&({config}==0))&&isset({save})'), - "useip"=> array(T_ZBX_STR, O_OPT, NULL, IN('0,1'), '(isset({config})&&({config}==0))&&isset({save})'), - "ip"=> array(T_ZBX_IP, O_OPT, NULL, NULL, '(isset({config})&&({config}==0))&&isset({save})'), - "port"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'(isset({config})&&({config}==0))&&isset({save})'), - "status"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1,3"), '(isset({config})&&({config}==0))&&isset({save})'), - - "newgroup"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), - "templates"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, NULL), - "clear_templates"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), - - "useprofile"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), - "devicetype"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), - "name"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), - "os"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), - "serialno"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), - "tag"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), - "macaddress"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), - "hardware"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), - "software"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), - "contact"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), - "location"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), - "notes"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})'), + 'hostid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({config})&&({config}==0||{config}==5||{config}==2)&&isset({form})&&({form}=="update")'), + 'host'=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({config})&&({config}==0||{config}==3||{config}==5)&&isset({save})&&!isset({massupdate})'), + 'proxy_hostid'=>array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({config})&&({config}==0)&&isset({save})&&!isset({massupdate})'), + 'dns'=> array(T_ZBX_STR, O_OPT, NULL, NULL, '(isset({config})&&({config}==0))&&isset({save})&&!isset({massupdate})'), + 'useip'=> array(T_ZBX_STR, O_OPT, NULL, IN('0,1'), '(isset({config})&&({config}==0))&&isset({save})&&!isset({massupdate})'), + 'ip'=> array(T_ZBX_IP, O_OPT, NULL, NULL, '(isset({config})&&({config}==0))&&isset({save})&&!isset({massupdate})'), + 'port'=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'(isset({config})&&({config}==0))&&isset({save})&&!isset({massupdate})'), + 'status'=> array(T_ZBX_INT, O_OPT, NULL, IN('0,1,3'), '(isset({config})&&({config}==0))&&isset({save})&&!isset({massupdate})'), + + 'newgroup'=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), + 'templates'=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, NULL), + 'clear_templates'=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), + + 'useprofile'=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), + 'devicetype'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + 'name'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + 'os'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + 'serialno'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + 'tag'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + 'macaddress'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + 'hardware'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + 'software'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + 'contact'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + 'location'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + 'notes'=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({useprofile})&&!isset({massupdate})'), + +/* mass update*/ + 'massupdate'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), + 'visible'=> array(T_ZBX_STR, O_OPT, null, null, null), + /* group */ - "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, '(isset({config})&&({config}==1))&&(isset({form})&&({form}=="update"))'), - "gname"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '(isset({config})&&({config}==1))&&isset({save})'), + 'groupid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, '(isset({config})&&({config}==1))&&(isset({form})&&({form}=="update"))'), + 'gname'=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '(isset({config})&&({config}==1))&&isset({save})'), /* application */ - "applicationid"=>array(T_ZBX_INT,O_OPT, P_SYS, DB_ID, '(isset({config})&&({config}==4))&&(isset({form})&&({form}=="update"))'), - "appname"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, '(isset({config})&&({config}==4))&&isset({save})'), - "apphostid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID.'{}>0', '(isset({config})&&({config}==4))&&isset({save})'), - "apptemplateid"=>array(T_ZBX_INT,O_OPT, NULL, DB_ID, NULL), + 'applicationid'=>array(T_ZBX_INT,O_OPT, P_SYS, DB_ID, '(isset({config})&&({config}==4))&&(isset({form})&&({form}=="update"))'), + 'appname'=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, '(isset({config})&&({config}==4))&&isset({save})'), + 'apphostid'=> array(T_ZBX_INT, O_OPT, NULL, DB_ID.'{}>0', '(isset({config})&&({config}==4))&&isset({save})'), + 'apptemplateid'=>array(T_ZBX_INT,O_OPT, NULL, DB_ID, NULL), /* host linkage form */ - "tname"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({config})&&({config}==2)&&isset({save})'), + 'tname'=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({config})&&({config}==2)&&isset({save})'), /* actions */ - "activate"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), - "disable"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + 'activate'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + 'disable'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), - "add_to_group"=> array(T_ZBX_INT, O_OPT, P_SYS|P_ACT, DB_ID, NULL), - "delete_from_group"=> array(T_ZBX_INT, O_OPT, P_SYS|P_ACT, DB_ID, NULL), + 'add_to_group'=> array(T_ZBX_INT, O_OPT, P_SYS|P_ACT, DB_ID, NULL), + 'delete_from_group'=> array(T_ZBX_INT, O_OPT, P_SYS|P_ACT, DB_ID, NULL), - "unlink"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), - "unlink_and_clear"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + 'unlink'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + 'unlink_and_clear'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), - "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), - "clone"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), - "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), - "delete_and_clear"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), - "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), + 'save'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + 'clone'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + 'delete'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + 'delete_and_clear'=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL), + 'cancel'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), /* other */ - "form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), - "form_refresh"=>array(T_ZBX_STR, O_OPT, NULL, NULL, NULL) + 'form'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), + 'form_refresh'=>array(T_ZBX_STR, O_OPT, NULL, NULL, NULL) ); check_fields($fields); validate_sort_and_sortorder('h.host',ZBX_SORT_UP); - - if($_REQUEST["config"]==4) - validate_group_with_host(PERM_READ_WRITE,array("always_select_first_host","only_current_node"),'web.last.conf.groupid', 'web.last.conf.hostid'); - else if($_REQUEST["config"]==0 || $_REQUEST["config"]==3) + + if($_REQUEST['config']==4) + validate_group_with_host(PERM_READ_WRITE,array('always_select_first_host','only_current_node'),'web.last.conf.groupid', 'web.last.conf.hostid'); + else if($_REQUEST['config']==0 || $_REQUEST['config']==3) validate_group(PERM_READ_WRITE,array(),'web.last.conf.groupid'); - update_profile("web.hosts.config",$_REQUEST["config"]); + update_profile('web.hosts.config',$_REQUEST['config']); ?> <?php @@ -131,10 +136,10 @@ include_once "include/page_header.php"; // Original mod by scricca@vipsnet.net // Modified by Aly /* this code menages operations to unlink 1 template from multiple hosts */ - if ($_REQUEST["config"]==2 && (isset($_REQUEST["unlink"]))){ - $hosts = get_request("hosts",array()); - if(isset($_REQUEST["hostid"])){ - $templateid=$_REQUEST["hostid"]; + if ($_REQUEST['config']==2 && (isset($_REQUEST['unlink']))){ + $hosts = get_request('hosts',array()); + if(isset($_REQUEST['hostid'])){ + $templateid=$_REQUEST['hostid']; $result = false; // Permission check @@ -155,13 +160,13 @@ include_once "include/page_header.php"; 'Status ['.$host['status'].']'); } - unset($_REQUEST["unlink"]); - unset($_REQUEST["hostid"]); - unset($_REQUEST["form"]); + unset($_REQUEST['unlink']); + unset($_REQUEST['hostid']); + unset($_REQUEST['form']); } } /* this code menages operations to link 1 template to multiple hosts */ - if($_REQUEST["config"]==2 && (isset($_REQUEST["save"]))){ + if($_REQUEST['config']==2 && (isset($_REQUEST['save']))){ if(isset($_REQUEST['hostid'])){ $hosts = get_request('hosts',array()); $templateid=$_REQUEST['hostid']; @@ -183,11 +188,11 @@ include_once "include/page_header.php"; $host=get_host_by_hostid($hostid); $templates_tmp=get_templates_by_hostid($hostid); - $templates_tmp[$templateid]=$template_name["host"]; + $templates_tmp[$templateid]=$template_name['host']; $result=update_host($hostid, - $host["host"],$host["port"],$host["status"],$host["useip"],$host["dns"], - $host["ip"],$host['proxy_hostid'],$templates_tmp,null,$host_groups); + $host['host'],$host['port'],$host['status'],$host['useip'],$host['dns'], + $host['ip'],$host['proxy_hostid'],$templates_tmp,null,$host_groups); } $result = DBend(); @@ -200,33 +205,132 @@ include_once "include/page_header.php"; 'Status ['.$host['status'].']'); } - unset($_REQUEST["save"]); - unset($_REQUEST["hostid"]); - unset($_REQUEST["form"]); + unset($_REQUEST['save']); + unset($_REQUEST['hostid']); + unset($_REQUEST['form']); } } //--------- END MOD ------------ /* UNLINK HOST */ - else if(($_REQUEST["config"]==0 || $_REQUEST["config"]==3) && (isset($_REQUEST["unlink"]) || isset($_REQUEST["unlink_and_clear"]))){ + else if(($_REQUEST['config']==0 || $_REQUEST['config']==3) && (isset($_REQUEST['unlink']) || isset($_REQUEST['unlink_and_clear']))){ $_REQUEST['clear_templates'] = get_request('clear_templates', array()); - if(isset($_REQUEST["unlink"])){ - $unlink_templates = array_keys($_REQUEST["unlink"]); + if(isset($_REQUEST['unlink'])){ + $unlink_templates = array_keys($_REQUEST['unlink']); } else{ - $unlink_templates = array_keys($_REQUEST["unlink_and_clear"]); + $unlink_templates = array_keys($_REQUEST['unlink_and_clear']); $_REQUEST['clear_templates'] = array_merge($_REQUEST['clear_templates'],$unlink_templates); } foreach($unlink_templates as $id) unset($_REQUEST['templates'][$id]); } /* CLONE HOST */ - else if(($_REQUEST["config"]==0 || $_REQUEST["config"]==3) && isset($_REQUEST["clone"]) && isset($_REQUEST["hostid"])){ - unset($_REQUEST["hostid"]); - $_REQUEST["form"] = "clone"; + else if(($_REQUEST['config']==0 || $_REQUEST['config']==3) && isset($_REQUEST['clone']) && isset($_REQUEST['hostid'])){ + unset($_REQUEST['hostid']); + $_REQUEST['form'] = 'clone'; + } +/* HOST MASS UPDATE */ + else if($_REQUEST['config']==0 && isset($_REQUEST['massupdate']) && isset($_REQUEST['save'])){ + $useip = get_request('useip',0); + $hosts = get_request('hosts',array()); + $visible = get_request('visible',array()); + + $_REQUEST['groups'] = get_request('groups',array()); + + $_REQUEST['newgroup'] = get_request('newgroup',''); + + $_REQUEST['proxy_hostid'] = get_request('proxy_hostid',0); + $_REQUEST['templates'] = get_request('templates', array()); + + if(count($_REQUEST['groups']) > 0){ + $accessible_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY); + foreach($_REQUEST['groups'] as $gid){ + if(isset($accessible_groups[$gid])) continue; + access_deny(); + } + } + else{ + if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY,get_current_nodeid()))) + access_deny(); + } + + DBstart(); + + foreach($hosts as $id => $hostid){ + + $db_host = get_host_by_hostid($hostid); + $db_templates = get_templates_by_hostid($hostid); + + foreach($db_host as $key){ + if(isset($visible[$key])){ + $db_host[$key] = $_REQUEST[$key]; + } + } + + if(isset($visible['groups'])){ + $db_host['groups'] = $_REQUEST['groups']; + } + else{ + $db_host['groups'] = get_groupids_by_host($hostid); + } + + if(isset($visible['template_table'])){ + foreach($db_templates as $templateid => $name){ + unlink_template($hostid, $templateid, false); + } + $db_host['templates'] = $_REQUEST['templates']; + } + else{ + $db_host['templates'] = $db_templates; + } + + $update = update_host($hostid, + $db_host['host'],$db_host['port'],$db_host['status'],$useip,$db_host['dns'], + $db_host['ip'],$db_host['proxy_hostid'],$db_host['templates'],$_REQUEST['newgroup'],$db_host['groups']); + + $msg_ok = S_HOST_UPDATED; + $msg_fail = S_CANNOT_UPDATE_HOST; + $audit_action = AUDIT_ACTION_UPDATE; + + if($update && isset($visible['useprofile'])){ + + $host_profile=DBfetch(DBselect('SELECT * FROM hosts_profiles WHERE hostid='.$hostid)); + + delete_host_profile($hostid); + + if(get_request('useprofile','no') == 'yes'){ + foreach($host_profile as $key => $value){ + if(isset($visible[$key])){ + $host_profile[$key] = $_REQUEST[$key]; + } + } + + add_host_profile($hostid, + $host_profile['devicetype'],$host_profile['name'],$host_profile['os'], + $host_profile['serialno'],$host_profile['tag'],$host_profile['macaddress'], + $host_profile['hardware'],$host_profile['software'],$host_profile['contact'], + $host_profile['location'],$host_profile['notes']); + } + } + } + + $result = DBend(); + + show_messages($result, $msg_ok, $msg_fail); + if($result){ + add_audit($audit_action,AUDIT_RESOURCE_HOST, + 'Host ['.$db_host['host'].'] IP ['.$db_host['ip'].'] '. + 'Status ['.$db_host['status'].']'); + + unset($_REQUEST['massupdate']); + unset($_REQUEST['form']); + unset($_REQUEST['hosts']); + } + unset($_REQUEST['save']); } /* SAVE HOST */ - else if(($_REQUEST["config"]==0 || $_REQUEST["config"]==3) && isset($_REQUEST["save"])){ - $useip = get_request("useip",0); - $groups=get_request("groups",array()); + else if(($_REQUEST['config']==0 || $_REQUEST['config']==3) && isset($_REQUEST['save'])){ + $useip = get_request('useip',0); + $groups=get_request('groups',array()); if(count($groups) > 0){ $accessible_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY); @@ -245,29 +349,30 @@ include_once "include/page_header.php"; $_REQUEST['proxy_hostid'] = get_request('proxy_hostid',0); if(isset($_REQUEST['hostid'])){ + DBstart(); + if(isset($_REQUEST['clear_templates'])) { foreach($_REQUEST['clear_templates'] as $id){ - unlink_template($_REQUEST["hostid"], $id, false); + unlink_template($_REQUEST['hostid'], $id, false); } } - DBstart(); - update_host($_REQUEST["hostid"], - $_REQUEST["host"],$_REQUEST["port"],$_REQUEST["status"],$useip,$_REQUEST["dns"], - $_REQUEST["ip"],$_REQUEST["proxy_hostid"],$templates,$_REQUEST["newgroup"],$groups); + update_host($_REQUEST['hostid'], + $_REQUEST['host'],$_REQUEST['port'],$_REQUEST['status'],$useip,$_REQUEST['dns'], + $_REQUEST['ip'],$_REQUEST['proxy_hostid'],$templates,$_REQUEST['newgroup'],$groups); $result = DBend(); $msg_ok = S_HOST_UPDATED; $msg_fail = S_CANNOT_UPDATE_HOST; $audit_action = AUDIT_ACTION_UPDATE; - $hostid = $_REQUEST["hostid"]; + $hostid = $_REQUEST['hostid']; } else { DBstart(); $hostid = add_host( - $_REQUEST["host"],$_REQUEST["port"],$_REQUEST["status"],$useip,$_REQUEST["dns"], - $_REQUEST["ip"],$_REQUEST["proxy_hostid"],$templates,$_REQUEST["newgroup"],$groups); + $_REQUEST['host'],$_REQUEST['port'],$_REQUEST['status'],$useip,$_REQUEST['dns'], + $_REQUEST['ip'],$_REQUEST['proxy_hostid'],$templates,$_REQUEST['newgroup'],$groups); $result = DBend()?$hostid:false; $msg_ok = S_HOST_ADDED; @@ -276,17 +381,17 @@ include_once "include/page_header.php"; } if($result){ - update_profile("HOST_PORT",$_REQUEST['port']); + update_profile('HOST_PORT',$_REQUEST['port']); DBstart(); delete_host_profile($hostid); - if(get_request("useprofile","no") == "yes"){ + if(get_request('useprofile','no') == 'yes'){ add_host_profile($hostid, - $_REQUEST["devicetype"],$_REQUEST["name"],$_REQUEST["os"], - $_REQUEST["serialno"],$_REQUEST["tag"],$_REQUEST["macaddress"], - $_REQUEST["hardware"],$_REQUEST["software"],$_REQUEST["contact"], - $_REQUEST["location"],$_REQUEST["notes"]); + $_REQUEST['devicetype'],$_REQUEST['name'],$_REQUEST['os'], + $_REQUEST['serialno'],$_REQUEST['tag'],$_REQUEST['macaddress'], + $_REQUEST['hardware'],$_REQUEST['software'],$_REQUEST['contact'], + $_REQUEST['location'],$_REQUEST['notes']); } $result = DBend(); } @@ -294,13 +399,13 @@ include_once "include/page_header.php"; show_messages($result, $msg_ok, $msg_fail); if($result){ add_audit($audit_action,AUDIT_RESOURCE_HOST, - "Host [".$_REQUEST["host"]."] IP [".$_REQUEST["ip"]."] ". - "Status [".$_REQUEST["status"]."]"); + 'Host ['.$_REQUEST['host'].'] IP ['.$_REQUEST['ip'].'] '. + 'Status ['.$_REQUEST['status'].']'); - unset($_REQUEST["form"]); - unset($_REQUEST["hostid"]); + unset($_REQUEST['form']); + unset($_REQUEST['hostid']); } - unset($_REQUEST["save"]); + unset($_REQUEST['save']); } /* DELETE HOST */ @@ -774,7 +879,10 @@ include_once "include/page_header.php"; if($_REQUEST["config"]==3) $show_only_tmp = 1; - if(isset($_REQUEST["form"])){ + if(isset($_REQUEST['massupdate']) && isset($_REQUEST['hosts'])){ + insert_mass_update_host_form(); + } + else if(isset($_REQUEST["form"])){ insert_host_form($show_only_tmp); } else { @@ -994,6 +1102,8 @@ include_once "include/page_header.php"; $show_only_tmp ? NULL : new CButtonQMessage('disable',S_DISABLE_SELECTED,S_DISABLE_SELECTED_HOSTS_Q), $show_only_tmp ? NULL : SPACE, new CButtonQMessage('delete',S_DELETE_SELECTED,S_DELETE_SELECTED_HOSTS_Q), + $show_only_tmp ? NULL : SPACE, + $show_only_tmp ? NULL : new CButton('massupdate',S_MASS_UPDATE), $show_only_tmp ? SPACE : NULL, $show_only_tmp ? new CButtonQMessage('delete_and_clear',S_DELETE_SELECTED_WITH_LINKED_ELEMENTS,S_DELETE_SELECTED_HOSTS_Q) : NULL ); @@ -1006,8 +1116,8 @@ include_once "include/page_header.php"; } } else if($_REQUEST["config"]==1){ - if(isset($_REQUEST["form"])) - { + + if(isset($_REQUEST["form"])){ insert_hostgroups_form(get_request("groupid",NULL)); } else { @@ -1318,9 +1428,7 @@ include_once "include/page_header.php"; $form->Show(); } } - else if($_REQUEST["config"]==6){ /* Host Mass Update */ - insert_mass_update_host_form(); - } + ?> <?php |
