Пример #1
0
    $interfaceTable->addRow(array(_('IP address'), _('DNS name'), _('Connect to'), _('Port')));
    $connectByComboBox = new CRadioButtonList('interface[useip]', $this->data['interface']['useip']);
    $connectByComboBox->addValue(_('IP'), 1);
    $connectByComboBox->addValue(_('DNS'), 0);
    $connectByComboBox->useJQueryStyle();
    $interfaceTable->addRow(array(new CTextBox('interface[ip]', $this->data['interface']['ip'], ZBX_TEXTBOX_SMALL_SIZE, 'no', 64), new CTextBox('interface[dns]', $this->data['interface']['dns'], ZBX_TEXTBOX_SMALL_SIZE, 'no', 64), $connectByComboBox, new CTextBox('interface[port]', $this->data['interface']['port'], 18, 'no', 64)));
    $proxyFormList->addRow(_('Interface'), new CDiv($interfaceTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
}
// append hosts to form list
$hostsTweenBox = new CTweenBox($proxyForm, 'hosts', $this->data['hosts']);
foreach ($this->data['dbHosts'] as $host) {
    // show only normal hosts, and discovered hosts monitored by the current proxy
    // for new proxies display only normal hosts
    if ($this->data['proxyid'] && idcmp($this->data['proxyid'], $host['proxy_hostid']) || $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
        $hostsTweenBox->addItem($host['hostid'], $host['name'], null, empty($host['proxy_hostid']) || !empty($this->data['proxyid']) && bccomp($host['proxy_hostid'], $this->data['proxyid']) == 0 && $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL);
    }
}
$proxyFormList->addRow(_('Hosts'), $hostsTweenBox->get(_('Proxy hosts'), _('Other hosts')));
// append tabs to form
$proxyTab = new CTabView();
$proxyTab->addTab('proxyTab', _('Proxy'), $proxyFormList);
$proxyForm->addItem($proxyTab);
// append buttons to form
if (!empty($this->data['proxyid'])) {
    $proxyForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete proxy?'), url_param('form') . url_param('proxyid')), new CButtonCancel())));
} else {
    $proxyForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), new CButtonCancel()));
}
// append form to widget
$proxyWidget->addItem($proxyForm);
return $proxyWidget;
$hostTB = new CTextBox('host', $host, ZBX_TEXTBOX_STANDARD_SIZE, $isDiscovered);
$hostTB->setAttribute('maxlength', 64);
$hostTB->setAttribute('autofocus', 'autofocus');
$hostList->addRow(_('Host name'), $hostTB);
$visiblenameTB = new CTextBox('visiblename', $visiblename, ZBX_TEXTBOX_STANDARD_SIZE, $isDiscovered);
$visiblenameTB->setAttribute('maxlength', 64);
$hostList->addRow(_('Visible name'), $visiblenameTB);
// groups for normal hosts
if (!$isDiscovered) {
    $grp_tb = new CTweenBox($frmHost, 'groups', $host_groups, 10);
    $all_groups = API::HostGroup()->get(array('editable' => true, 'output' => API_OUTPUT_EXTEND));
    order_result($all_groups, 'name');
    foreach ($all_groups as $group) {
        $grp_tb->addItem($group['groupid'], $group['name']);
    }
    $hostList->addRow(_('Groups'), $grp_tb->get(_('In groups'), _('Other groups')));
    $newgroupTB = new CTextBox('newgroup', $newgroup, ZBX_TEXTBOX_SMALL_SIZE);
    $newgroupTB->setAttribute('maxlength', 64);
    $tmp_label = _('New group');
    if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
        $tmp_label .= SPACE . _('(Only super admins can create groups)');
        $newgroupTB->setReadonly(true);
    }
    $hostList->addRow(SPACE, array(new CLabel($tmp_label, 'newgroup'), BR(), $newgroupTB), null, null, null, 'new');
} else {
    $groupBox = new CComboBox('groups');
    $groupBox->setAttribute('readonly', true);
    $groupBox->setAttribute('size', 10);
    foreach ($dbHost['groups'] as $group) {
        $groupBox->addItem($group['groupid'], $group['name']);
    }
$userGroupFormList = new CFormList('userGroupFormList');
$nameTextBox = new CTextBox('gname', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE);
$nameTextBox->attr('autofocus', 'autofocus');
$userGroupFormList->addRow(_('Group name'), $nameTextBox);
// append groups to form list
$groupsComboBox = new CComboBox('selusrgrp', $this->data['selected_usrgrp'], 'submit()');
$groupsComboBox->addItem(0, _('All'));
foreach ($this->data['usergroups'] as $group) {
    $groupsComboBox->addItem($group['usrgrpid'], $group['name']);
}
// append user tweenbox to form list
$usersTweenBox = new CTweenBox($userGroupForm, 'group_users', $this->data['group_users'], 10);
foreach ($this->data['users'] as $user) {
    $usersTweenBox->addItem($user['userid'], getUserFullname($user));
}
$userGroupFormList->addRow(_('Users'), $usersTweenBox->get(_('In group'), array(_('Other groups'), SPACE, $groupsComboBox)));
// append frontend and user status to from list
$isGranted = isset($data['usrgrpid']) ? granted2update_group($data['usrgrpid']) : true;
if ($isGranted) {
    $frontendComboBox = new CComboBox('gui_access', $this->data['gui_access']);
    $frontendComboBox->addItem(GROUP_GUI_ACCESS_SYSTEM, user_auth_type2str(GROUP_GUI_ACCESS_SYSTEM));
    $frontendComboBox->addItem(GROUP_GUI_ACCESS_INTERNAL, user_auth_type2str(GROUP_GUI_ACCESS_INTERNAL));
    $frontendComboBox->addItem(GROUP_GUI_ACCESS_DISABLED, user_auth_type2str(GROUP_GUI_ACCESS_DISABLED));
    $userGroupFormList->addRow(_('Frontend access'), $frontendComboBox);
    $userGroupFormList->addRow(_('Enabled'), new CCheckBox('users_status', $this->data['users_status'] ? isset($data['usrgrpid']) ? 0 : 1 : 1, null, 1));
    // invert user status 0 - enable, 1 - disable
} else {
    $userGroupForm->addVar('gui_access', $this->data['gui_access']);
    $userGroupForm->addVar('users_status', GROUP_STATUS_ENABLED);
    $userGroupFormList->addRow(_('Frontend access'), new CSpan(user_auth_type2str($this->data['gui_access']), 'text-field green'));
    $userGroupFormList->addRow(_('Enabled'), new CSpan(_('Enabled'), 'text-field green'));
    $groupsComboBox->addItem($group['groupid'], $group['name']);
}
$hostsComboBox = new CTweenBox($hostGroupForm, 'hosts', $this->data['hosts'], 25);
foreach ($this->data['db_hosts'] as $host) {
    if (!isset($this->data['hosts'][$host['hostid']])) {
        $hostsComboBox->addItem($host['hostid'], $host['name']);
    }
}
foreach ($this->data['r_hosts'] as $host) {
    if ($host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
        $hostsComboBox->addItem($host['hostid'], $host['name']);
    } else {
        $hostsComboBox->addItem($host['hostid'], $host['name'], true, false);
    }
}
$hostGroupFormList->addRow(_('Hosts'), $hostsComboBox->get(_('Hosts in'), array(_('Other hosts | Group') . SPACE, $groupsComboBox)));
// append tabs to form
$hostGroupTab = new CTabView();
$hostGroupTab->addTab('hostgroupTab', _('Host group'), $hostGroupFormList);
$hostGroupForm->addItem($hostGroupTab);
// append buttons to form
if ($this->data['groupid'] == 0) {
    $hostGroupForm->addItem(makeFormFooter(new CSubmit('add', _('Add')), new CButtonCancel()));
} else {
    $deleteButton = new CButtonDelete(_('Delete selected group?'), url_param('form') . url_param('groupid'));
    if (!isset($this->data['deletableHostGroups'][$this->data['groupid']])) {
        $deleteButton->attr('disabled', 'disabled');
    }
    $hostGroupForm->addItem(makeFormFooter(new CSubmit('update', _('Update')), array(new CSubmit('clone', _('Clone')), $deleteButton, new CButtonCancel())));
}
$hostGroupWidget->addItem($hostGroupForm);
foreach ($this->data['hosts'] as $host) {
    $hostTweenBox->addItem($host['hostid'], $host['name']);
}
$groupsComboBox = new CComboBox('twb_groupid', $this->data['twb_groupid'], 'submit()');
foreach ($this->data['all_groups'] as $group) {
    $groupsComboBox->addItem($group['groupid'], $group['name']);
}
$hostTable = new CTable(null, 'formElementTable');
$hostTable->addRow($hostTweenBox->get(_('In maintenance'), array(_('Other hosts | Group') . SPACE, $groupsComboBox)));
$hostsAndGroupsFormList->addRow(_('Hosts in maintenance'), $hostTable);
$groupTable = new CTable(null, 'formElementTable');
$groupTweenBox = new CTweenBox($maintenanceForm, 'groupids', $this->data['groupids'], 10);
foreach ($this->data['all_groups'] as $group) {
    $groupTweenBox->addItem($group['groupid'], $group['name']);
}
$groupTable->addRow($groupTweenBox->get(_('In maintenance'), _('Other groups')));
$hostsAndGroupsFormList->addRow(_('Groups in maintenance'), $groupTable);
// append tabs to form
$maintenanceTab = new CTabView();
if (!$this->data['form_refresh']) {
    $maintenanceTab->setSelected(0);
}
$maintenanceTab->addTab('maintenanceTab', _('Maintenance'), $maintenanceFormList);
$maintenanceTab->addTab('periodsTab', _('Periods'), $maintenancePeriodFormList);
$maintenanceTab->addTab('hostTab', _('Hosts & Groups'), $hostsAndGroupsFormList);
$maintenanceForm->addItem($maintenanceTab);
// append buttons to form
if (empty($this->data['maintenanceid'])) {
    $maintenanceForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), new CButtonCancel()));
} else {
    $maintenanceForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete maintenance period?'), url_param('form') . url_param('maintenanceid')), new CButtonCancel())));
}
$proxyForm = (new CForm())->setId('proxyForm')->addVar('proxyid', $data['proxyid'])->addVar('tls_accept', $data['tls_accept']);
if ($data['status'] == HOST_STATUS_PROXY_PASSIVE && array_key_exists('interfaceid', $data)) {
    $proxyForm->addVar('interfaceid', $data['interfaceid']);
}
$interfaceTable = (new CTable())->setHeader([_('IP address'), _('DNS name'), _('Connect to'), _('Port')])->addRow([(new CTextBox('ip', $data['ip'], false, 64))->setWidth(ZBX_TEXTAREA_INTERFACE_IP_WIDTH), (new CTextBox('dns', $data['dns'], false, 64))->setWidth(ZBX_TEXTAREA_INTERFACE_DNS_WIDTH), (new CRadioButtonList('useip', (int) $data['useip']))->addValue(_('IP'), INTERFACE_USE_IP)->addValue(_('DNS'), INTERFACE_USE_DNS)->setModern(true), (new CTextBox('port', $data['port'], false, 64))->setWidth(ZBX_TEXTAREA_INTERFACE_PORT_WIDTH)]);
// append hosts to form list
$hosts_tween_box = new CTweenBox($proxyForm, 'proxy_hostids', $data['proxy_hostids']);
foreach ($data['all_hosts'] as $host) {
    // show only normal hosts, and discovered hosts monitored by the current proxy
    // for new proxies display only normal hosts
    if ($host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL || $data['proxyid'] != 0 && bccomp($data['proxyid'], $host['proxy_hostid']) == 0) {
        $hosts_tween_box->addItem($host['hostid'], $host['name'], null, $host['proxy_hostid'] == 0 || bccomp($host['proxy_hostid'], $data['proxyid']) == 0 && $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL);
    }
}
$proxy_form_list = (new CFormList('proxyFormList'))->addRow(_('Proxy name'), (new CTextBox('host', $data['host'], false, 128))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('autofocus', 'autofocus'))->addRow(_('Proxy mode'), new CComboBox('status', $data['status'], null, [HOST_STATUS_PROXY_ACTIVE => _('Active'), HOST_STATUS_PROXY_PASSIVE => _('Passive')]))->addRow(_('Interface'), (new CDiv($interfaceTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR))->addRow(_('Hosts'), $hosts_tween_box->get(_('Proxy hosts'), _('Other hosts')))->addRow(_('Description'), (new CTextArea('description', $data['description']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH));
// append tabs to form
$proxyTab = (new CTabView())->addTab('proxyTab', _('Proxy'), $proxy_form_list);
// Encryption form list.
$encryption_form_list = (new CFormList('encryption'))->addRow(_('Connections to proxy'), (new CRadioButtonList('tls_connect', (int) $data['tls_connect']))->addValue(_('No encryption'), HOST_ENCRYPTION_NONE)->addValue(_('PSK'), HOST_ENCRYPTION_PSK)->addValue(_('Certificate'), HOST_ENCRYPTION_CERTIFICATE)->setModern(true))->addRow(_('Connections from proxy'), [new CLabel([new CCheckBox('tls_in_none'), _('No encryption')]), BR(), new CLabel([new CCheckBox('tls_in_psk'), _('PSK')]), BR(), new CLabel([new CCheckBox('tls_in_cert'), _('Certificate')])])->addRow(_('PSK identity'), (new CTextBox('tls_psk_identity', $data['tls_psk_identity'], false, 128))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_('PSK'), (new CTextBox('tls_psk', $data['tls_psk'], false, 512))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_('Issuer'), (new CTextBox('tls_issuer', $data['tls_issuer'], false, 1024))->setWidth(ZBX_TEXTAREA_BIG_WIDTH))->addRow(_x('Subject', 'encryption certificate'), (new CTextBox('tls_subject', $data['tls_subject'], false, 1024))->setWidth(ZBX_TEXTAREA_BIG_WIDTH));
$tabs->addTab('proxyTab', _('Proxy'), $proxy_form_list);
$tabs->addTab('encryptionTab', _('Encryption'), $encryption_form_list);
// append buttons to form
$cancelButton = new CRedirectButton(_('Cancel'), 'zabbix.php?action=proxy.list');
if ($data['proxyid'] == 0) {
    $tabs->setFooter(makeFormFooter(new CSubmitButton(_('Add'), 'action', 'proxy.create'), [$cancelButton]));
} else {
    $tabs->setFooter(makeFormFooter(new CSubmitButton(_('Update'), 'action', 'proxy.update'), [(new CSimpleButton(_('Clone')))->setId('clone'), new CRedirectButton(_('Delete'), 'zabbix.php?action=proxy.delete&sid=' . $data['sid'] . '&proxyids[]=' . $data['proxyid'], _('Delete proxy?')), $cancelButton]));
}
$proxyForm->addItem($tabs);
$widget->addItem($proxyForm)->show();
    // then add other host groups that user has permissions to, if not yet added to list
    foreach ($groupsAllowed as $group) {
        if (!in_array($group['groupid'], $groupsInList)) {
            $group_tb->addItem($group['groupid'], $group['name']);
        }
    }
} else {
    /*
     * When cloning a template or creating a new one, don't show read-only host groups in left box
     * show empty or posted groups in case of an error.
     */
    foreach ($groupsAllowed as $group) {
        $group_tb->addItem($group['groupid'], $group['name']);
    }
}
$templateList->addRow(_('Groups'), $group_tb->get(_('In groups'), _('Other groups')));
// FORM ITEM : new group text box [  ]
$newgroupTB = new CTextBox('newgroup', $newgroup);
$newgroupTB->setAttribute('maxlength', 64);
$tmp_label = _('New group');
if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
    $tmp_label .= SPACE . _('(Only super admins can create groups)');
    $newgroupTB->setReadonly(true);
}
$templateList->addRow(SPACE, array($tmp_label, BR(), $newgroupTB), null, null, 'new');
// FORM ITEM : linked Hosts tween box [  ] [  ]
$twb_groupid = get_request('twb_groupid', 0);
if ($twb_groupid == 0) {
    $gr = reset($groupsAllowed);
    $twb_groupid = $gr['groupid'];
}
Пример #8
0
function insert_host_form($show_only_tmp = 0)
{
    global $USER_DETAILS;
    $groups = get_request('groups', array());
    $newgroup = get_request('newgroup', '');
    $host = get_request('host', '');
    $port = get_request('port', get_profile('HOST_PORT', 10050));
    $status = get_request('status', HOST_STATUS_MONITORED);
    $useip = get_request('useip', 0);
    $dns = get_request('dns', '');
    $ip = get_request('ip', '0.0.0.0');
    $proxy_hostid = get_request('proxy_hostid', '');
    $useipmi = get_request('useipmi', 'no');
    $ipmi_ip = get_request('ipmi_ip', '');
    $ipmi_port = get_request('ipmi_port', 623);
    $ipmi_authtype = get_request('ipmi_authtype', -1);
    $ipmi_privilege = get_request('ipmi_privilege', 2);
    $ipmi_username = get_request('ipmi_username', '');
    $ipmi_password = get_request('ipmi_password', '');
    $useprofile = get_request('useprofile', 'no');
    $devicetype = get_request('devicetype', '');
    $name = get_request('name', '');
    $os = get_request('os', '');
    $serialno = get_request('serialno', '');
    $tag = get_request('tag', '');
    $macaddress = get_request('macaddress', '');
    $hardware = get_request('hardware', '');
    $software = get_request('software', '');
    $contact = get_request('contact', '');
    $location = get_request('location', '');
    $notes = get_request('notes', '');
    // BEGIN: HOSTS PROFILE EXTENDED Section
    $useprofile_ext = get_request('useprofile_ext', 'no');
    $ext_host_profiles = get_request('ext_host_profiles', array());
    // END:   HOSTS PROFILE EXTENDED Section
    $templates = get_request('templates', array());
    $clear_templates = get_request('clear_templates', array());
    $frm_title = $show_only_tmp ? S_TEMPLATE : S_HOST;
    if ($_REQUEST['hostid'] > 0) {
        $db_host = get_host_by_hostid($_REQUEST['hostid']);
        $frm_title .= SPACE . ' [' . $db_host['host'] . ']';
        $original_templates = get_templates_by_hostid($_REQUEST['hostid']);
    } else {
        $original_templates = array();
    }
    if ($_REQUEST['hostid'] > 0 && !isset($_REQUEST['form_refresh'])) {
        $proxy_hostid = $db_host['proxy_hostid'];
        $host = $db_host['host'];
        $port = $db_host['port'];
        $status = $db_host['status'];
        $useip = $db_host['useip'];
        $useipmi = $db_host['useipmi'] ? 'yes' : 'no';
        $ip = $db_host['ip'];
        $dns = $db_host['dns'];
        $ipmi_ip = $db_host['ipmi_ip'];
        $ipmi_port = $db_host['ipmi_port'];
        $ipmi_authtype = $db_host['ipmi_authtype'];
        $ipmi_privilege = $db_host['ipmi_privilege'];
        $ipmi_username = $db_host['ipmi_username'];
        $ipmi_password = $db_host['ipmi_password'];
        // add groups
        $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_LIST);
        $db_groups = DBselect('SELECT DISTINCT groupid ' . ' FROM hosts_groups ' . ' WHERE hostid=' . $_REQUEST['hostid'] . ' AND ' . DBcondition('groupid', $available_groups));
        while ($db_group = DBfetch($db_groups)) {
            if (uint_in_array($db_group['groupid'], $groups)) {
                continue;
            }
            $groups[$db_group['groupid']] = $db_group['groupid'];
        }
        // read profile
        $db_profiles = DBselect('SELECT * FROM hosts_profiles WHERE hostid=' . $_REQUEST['hostid']);
        $useprofile = 'no';
        $db_profile = DBfetch($db_profiles);
        if ($db_profile) {
            $useprofile = 'yes';
            $devicetype = $db_profile['devicetype'];
            $name = $db_profile['name'];
            $os = $db_profile['os'];
            $serialno = $db_profile['serialno'];
            $tag = $db_profile['tag'];
            $macaddress = $db_profile['macaddress'];
            $hardware = $db_profile['hardware'];
            $software = $db_profile['software'];
            $contact = $db_profile['contact'];
            $location = $db_profile['location'];
            $notes = $db_profile['notes'];
        }
        // BEGIN: HOSTS PROFILE EXTENDED Section
        $useprofile_ext = 'no';
        $db_profiles_alt = DBselect('SELECT * FROM hosts_profiles_ext		 WHERE hostid=' . $_REQUEST['hostid']);
        if ($ext_host_profiles = DBfetch($db_profiles_alt)) {
            $useprofile_ext = 'yes';
        } else {
            $ext_host_profiles = array();
        }
        // END:   HOSTS PROFILE EXTENDED Section
        $templates = $original_templates;
    }
    $ext_profiles_fields = array('device_alias', 'device_type', 'device_chassis', 'device_os', 'device_os_short', 'device_hw_arch', 'device_serial', 'device_model', 'device_tag', 'device_vendor', 'device_contract', 'device_who', 'device_status', 'device_app_01', 'device_app_02', 'device_app_03', 'device_app_04', 'device_app_05', 'device_url_1', 'device_url_2', 'device_url_3', 'device_networks', 'device_notes', 'device_hardware', 'device_software', 'ip_subnet_mask', 'ip_router', 'ip_macaddress', 'oob_ip', 'oob_subnet_mask', 'oob_router', 'date_hw_buy', 'date_hw_install', 'date_hw_expiry', 'date_hw_decomm', 'site_street_1', 'site_street_2', 'site_street_3', 'site_city', 'site_state', 'site_country', 'site_zip', 'site_rack', 'site_notes', 'poc_1_name', 'poc_1_email', 'poc_1_phone_1', 'poc_1_phone_2', 'poc_1_cell', 'poc_1_screen', 'poc_1_notes', 'poc_2_name', 'poc_2_email', 'poc_2_phone_1', 'poc_2_phone_2', 'poc_2_cell', 'poc_2_screen', 'poc_2_notes');
    foreach ($ext_profiles_fields as $id => $field) {
        if (!isset($ext_host_profiles[$field])) {
            $ext_host_profiles[$field] = '';
        }
    }
    $clear_templates = array_intersect($clear_templates, array_keys($original_templates));
    $clear_templates = array_diff($clear_templates, array_keys($templates));
    asort($templates);
    $frmHost = new CFormTable($frm_title, 'hosts.php');
    $frmHost->setHelp('web.hosts.host.php');
    $frmHost->addVar('config', get_request('config', 0));
    $frmHost->addVar('clear_templates', $clear_templates);
    if ($_REQUEST['hostid'] > 0) {
        $frmHost->addVar('hostid', $_REQUEST['hostid']);
    }
    if ($_REQUEST['groupid'] > 0) {
        $frmHost->addVar('groupid', $_REQUEST['groupid']);
    }
    $frmHost->addRow(S_NAME, new CTextBox('host', $host, 54));
    $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_LIST);
    $grp_tb = new CTweenBox($frmHost, 'groups', $groups, 10);
    $db_groups = DBselect('SELECT DISTINCT groupid,name ' . ' FROM groups ' . ' WHERE ' . DBcondition('groupid', $available_groups) . ' ORDER BY name');
    while ($db_group = DBfetch($db_groups)) {
        $grp_tb->addItem($db_group['groupid'], $db_group['name']);
    }
    $frmHost->addRow(S_GROUPS, $grp_tb->get(S_IN . SPACE . S_GROUPS, S_OTHER . SPACE . S_GROUPS));
    $frmHost->addRow(S_NEW_GROUP, new CTextBox('newgroup', $newgroup), 'new');
    // onchange does not work on some browsers: MacOS, KDE browser
    if ($show_only_tmp) {
        $frmHost->addVar('useip', 0);
        $frmHost->addVar('ip', '0.0.0.0');
        $frmHost->addVar('dns', '');
    } else {
        $frmHost->addRow(S_DNS_NAME, new CTextBox('dns', $dns, '40'));
        if (defined('ZBX_HAVE_IPV6')) {
            $frmHost->addRow(S_IP_ADDRESS, new CTextBox('ip', $ip, '39'));
        } else {
            $frmHost->addRow(S_IP_ADDRESS, new CTextBox('ip', $ip, '15'));
        }
        $cmbConnectBy = new CComboBox('useip', $useip);
        $cmbConnectBy->addItem(0, S_DNS_NAME);
        $cmbConnectBy->addItem(1, S_IP_ADDRESS);
        $frmHost->addRow(S_CONNECT_TO, $cmbConnectBy);
    }
    if ($show_only_tmp) {
        $port = '10050';
        $status = HOST_STATUS_TEMPLATE;
        $frmHost->addVar('port', $port);
        $frmHost->addVar('status', $status);
    } else {
        $frmHost->AddRow(S_AGENT_PORT, new CNumericBox('port', $port, 5));
        //Proxy
        $cmbProxy = new CComboBox('proxy_hostid', $proxy_hostid);
        $cmbProxy->addItem(0, S_NO_PROXY);
        $db_proxies = DBselect('SELECT hostid,host FROM hosts' . ' where status in (' . HOST_STATUS_PROXY . ') and ' . DBin_node('hostid'));
        while ($db_proxy = DBfetch($db_proxies)) {
            $cmbProxy->addItem($db_proxy['hostid'], $db_proxy['host']);
        }
        $frmHost->addRow(S_MONITORED_BY_PROXY, $cmbProxy);
        //----------
        $cmbStatus = new CComboBox('status', $status);
        $cmbStatus->addItem(HOST_STATUS_MONITORED, S_MONITORED);
        $cmbStatus->addItem(HOST_STATUS_NOT_MONITORED, S_NOT_MONITORED);
        $frmHost->addRow(S_STATUS, $cmbStatus);
    }
    $template_table = new CTable();
    $template_table->SetCellPadding(0);
    $template_table->SetCellSpacing(0);
    foreach ($templates as $id => $temp_name) {
        $frmHost->addVar('templates[' . $id . ']', $temp_name);
        $template_table->addRow(array($temp_name, new CButton('unlink[' . $id . ']', S_UNLINK), isset($original_templates[$id]) ? new CButton('unlink_and_clear[' . $id . ']', S_UNLINK_AND_CLEAR) : SPACE));
    }
    $frmHost->addRow(S_LINK_WITH_TEMPLATE, array($template_table, new CButton('add_template', S_ADD, "return PopUp('popup.php?dstfrm=" . $frmHost->GetName() . "&dstfld1=new_template&srctbl=templates&srcfld1=hostid&srcfld2=host" . url_param($templates, false, 'existed_templates') . "',450,450)", 'T')));
    if ($show_only_tmp) {
        $frmHost->addVar('useipmi', $useipmi);
    } else {
        $frmHost->addRow(S_USEIPMI, new CCheckBox('useipmi', $useipmi, 'submit()'));
    }
    if ($useipmi == 'yes') {
        $frmHost->addRow(S_IPMI_IP_ADDRESS, new CTextBox('ipmi_ip', $ipmi_ip, defined('ZBX_HAVE_IPV6') ? 39 : 15));
        $frmHost->addRow(S_IPMI_PORT, new CNumericBox('ipmi_port', $ipmi_port, 5));
        $cmbIPMIAuthtype = new CComboBox('ipmi_authtype', $ipmi_authtype);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_DEFAULT, S_AUTHTYPE_DEFAULT);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_NONE, S_AUTHTYPE_NONE);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD2, S_AUTHTYPE_MD2);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD5, S_AUTHTYPE_MD5);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_STRAIGHT, S_AUTHTYPE_STRAIGHT);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_OEM, S_AUTHTYPE_OEM);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_RMCP_PLUS, S_AUTHTYPE_RMCP_PLUS);
        $frmHost->addRow(S_IPMI_AUTHTYPE, $cmbIPMIAuthtype);
        $cmbIPMIPrivilege = new CComboBox('ipmi_privilege', $ipmi_privilege);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_CALLBACK, S_PRIVILEGE_CALLBACK);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_USER, S_PRIVILEGE_USER);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OPERATOR, S_PRIVILEGE_OPERATOR);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_ADMIN, S_PRIVILEGE_ADMIN);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OEM, S_PRIVILEGE_OEM);
        $frmHost->addRow(S_IPMI_PRIVILEGE, $cmbIPMIPrivilege);
        $frmHost->addRow(S_IPMI_USERNAME, new CTextBox('ipmi_username', $ipmi_username, 16));
        $frmHost->addRow(S_IPMI_PASSWORD, new CTextBox('ipmi_password', $ipmi_password, 20));
    } else {
        $frmHost->addVar('ipmi_ip', $ipmi_ip);
        $frmHost->addVar('ipmi_port', $ipmi_port);
        $frmHost->addVar('ipmi_authtype', $ipmi_authtype);
        $frmHost->addVar('ipmi_privilege', $ipmi_privilege);
        $frmHost->addVar('ipmi_username', $ipmi_username);
        $frmHost->addVar('ipmi_password', $ipmi_password);
    }
    if ($show_only_tmp) {
        $useprofile = 'no';
        $frmHost->addVar('useprofile', $useprofile);
        $useprofile_ext = 'no';
        $frmHost->addVar('useprofile_ext', $useprofile_ext);
    } else {
        $frmHost->addRow(S_USE_PROFILE, new CCheckBox('useprofile', $useprofile, 'submit()'));
        $frmHost->addRow(S_USE_EXTENDED_PROFILE, new CCheckBox('useprofile_ext', $useprofile_ext, 'submit()', 'yes'));
    }
    if ($useprofile == 'yes') {
        $frmHost->addRow(S_DEVICE_TYPE, new CTextBox("devicetype", $devicetype, 61));
        $frmHost->addRow(S_NAME, new CTextBox("name", $name, 61));
        $frmHost->addRow(S_OS, new CTextBox("os", $os, 61));
        $frmHost->addRow(S_SERIALNO, new CTextBox("serialno", $serialno, 61));
        $frmHost->addRow(S_TAG, new CTextBox("tag", $tag, 61));
        $frmHost->addRow(S_MACADDRESS, new CTextBox("macaddress", $macaddress, 61));
        $frmHost->addRow(S_HARDWARE, new CTextArea("hardware", $hardware, 60, 4));
        $frmHost->addRow(S_SOFTWARE, new CTextArea("software", $software, 60, 4));
        $frmHost->addRow(S_CONTACT, new CTextArea("contact", $contact, 60, 4));
        $frmHost->addRow(S_LOCATION, new CTextArea("location", $location, 60, 4));
        $frmHost->addRow(S_NOTES, new CTextArea("notes", $notes, 60, 4));
    } else {
        $frmHost->addVar("devicetype", $devicetype);
        $frmHost->addVar("name", $name);
        $frmHost->addVar("os", $os);
        $frmHost->addVar("serialno", $serialno);
        $frmHost->addVar("tag", $tag);
        $frmHost->addVar("macaddress", $macaddress);
        $frmHost->addVar("hardware", $hardware);
        $frmHost->addVar("software", $software);
        $frmHost->addVar("contact", $contact);
        $frmHost->addVar("location", $location);
        $frmHost->addVar("notes", $notes);
    }
    // 		BEGIN: HOSTS PROFILE EXTENDED Section
    if ($useprofile_ext == "yes") {
        $frmHost->addRow(S_DEVICE_ALIAS, new CTextBox('ext_host_profiles[device_alias]', $ext_host_profiles['device_alias'], 61));
        $frmHost->addRow(S_DEVICE_TYPE, new CTextBox('ext_host_profiles[device_type]', $ext_host_profiles['device_type'], 61));
        $frmHost->addRow(S_DEVICE_CHASSIS, new CTextBox('ext_host_profiles[device_chassis]', $ext_host_profiles['device_chassis'], 61));
        $frmHost->addRow(S_DEVICE_OS, new CTextBox('ext_host_profiles[device_os]', $ext_host_profiles['device_os'], 61));
        $frmHost->addRow(S_DEVICE_OS_SHORT, new CTextBox('ext_host_profiles[device_os_short]', $ext_host_profiles['device_os_short'], 61));
        $frmHost->addRow(S_DEVICE_HW_ARCH, new CTextBox('ext_host_profiles[device_hw_arch]', $ext_host_profiles['device_hw_arch'], 61));
        $frmHost->addRow(S_DEVICE_SERIAL, new CTextBox('ext_host_profiles[device_serial]', $ext_host_profiles['device_serial'], 61));
        $frmHost->addRow(S_DEVICE_MODEL, new CTextBox('ext_host_profiles[device_model]', $ext_host_profiles['device_model'], 61));
        $frmHost->addRow(S_DEVICE_TAG, new CTextBox('ext_host_profiles[device_tag]', $ext_host_profiles['device_tag'], 61));
        $frmHost->addRow(S_DEVICE_VENDOR, new CTextBox('ext_host_profiles[device_vendor]', $ext_host_profiles['device_vendor'], 61));
        $frmHost->addRow(S_DEVICE_CONTRACT, new CTextBox('ext_host_profiles[device_contract]', $ext_host_profiles['device_contract'], 61));
        $frmHost->addRow(S_DEVICE_WHO, new CTextBox('ext_host_profiles[device_who]', $ext_host_profiles['device_who'], 61));
        $frmHost->addRow(S_DEVICE_STATUS, new CTextBox('ext_host_profiles[device_status]', $ext_host_profiles['device_status'], 61));
        $frmHost->addRow(S_DEVICE_APP_01, new CTextBox('ext_host_profiles[device_app_01]', $ext_host_profiles['device_app_01'], 61));
        $frmHost->addRow(S_DEVICE_APP_02, new CTextBox('ext_host_profiles[device_app_02]', $ext_host_profiles['device_app_02'], 61));
        $frmHost->addRow(S_DEVICE_APP_03, new CTextBox('ext_host_profiles[device_app_03]', $ext_host_profiles['device_app_03'], 61));
        $frmHost->addRow(S_DEVICE_APP_04, new CTextBox('ext_host_profiles[device_app_04]', $ext_host_profiles['device_app_04'], 61));
        $frmHost->addRow(S_DEVICE_APP_05, new CTextBox('ext_host_profiles[device_app_05]', $ext_host_profiles['device_app_05'], 61));
        $frmHost->addRow(S_DEVICE_URL_1, new CTextBox('ext_host_profiles[device_url_1]', $ext_host_profiles['device_url_1'], 61));
        $frmHost->addRow(S_DEVICE_URL_2, new CTextBox('ext_host_profiles[device_url_2]', $ext_host_profiles['device_url_2'], 61));
        $frmHost->addRow(S_DEVICE_URL_3, new CTextBox('ext_host_profiles[device_url_3]', $ext_host_profiles['device_url_3'], 61));
        $frmHost->addRow(S_DEVICE_NETWORKS, new CTextArea('ext_host_profiles[device_networks]', $ext_host_profiles['device_networks'], 50, 5));
        $frmHost->addRow(S_DEVICE_NOTES, new CTextArea('ext_host_profiles[device_notes]', $ext_host_profiles['device_notes'], 50, 5));
        $frmHost->addRow(S_DEVICE_HARDWARE, new CTextArea('ext_host_profiles[device_hardware]', $ext_host_profiles['device_hardware'], 50, 5));
        $frmHost->addRow(S_DEVICE_SOFTWARE, new CTextArea('ext_host_profiles[device_software]', $ext_host_profiles['device_software'], 50, 5));
        $frmHost->addRow(S_IP_SUBNET_MASK, new CTextBox('ext_host_profiles[ip_subnet_mask]', $ext_host_profiles['ip_subnet_mask'], 61));
        $frmHost->addRow(S_IP_ROUTER, new CTextBox('ext_host_profiles[ip_router]', $ext_host_profiles['ip_router'], 61));
        $frmHost->addRow(S_IP_MACADDRESS, new CTextBox('ext_host_profiles[ip_macaddress]', $ext_host_profiles['ip_macaddress'], 61));
        $frmHost->addRow(S_OOB_IP, new CTextBox('ext_host_profiles[oob_ip]', $ext_host_profiles['oob_ip'], 61));
        $frmHost->addRow(S_OOB_SUBNET_MASK, new CTextBox('ext_host_profiles[oob_subnet_mask]', $ext_host_profiles['oob_subnet_mask'], 61));
        $frmHost->addRow(S_OOB_ROUTER, new CTextBox('ext_host_profiles[oob_router]', $ext_host_profiles['oob_router'], 61));
        $frmHost->addRow(S_DATE_HW_BUY, new CTextBox('ext_host_profiles[date_hw_buy]', $ext_host_profiles['date_hw_buy'], 15));
        $frmHost->addRow(S_DATE_HW_INSTALL, new CTextBox('ext_host_profiles[date_hw_install]', $ext_host_profiles['date_hw_install'], 15));
        $frmHost->addRow(S_DATE_HW_EXPIRY, new CTextBox('ext_host_profiles[date_hw_expiry]', $ext_host_profiles['date_hw_expiry'], 15));
        $frmHost->addRow(S_DATE_HW_DECOMM, new CTextBox('ext_host_profiles[date_hw_decomm]', $ext_host_profiles['date_hw_decomm'], 15));
        $frmHost->addRow(S_SITE_STREET_1, new CTextBox('ext_host_profiles[site_street_1]', $ext_host_profiles['site_street_1'], 61));
        $frmHost->addRow(S_SITE_STREET_2, new CTextBox('ext_host_profiles[site_street_2]', $ext_host_profiles['site_street_2'], 61));
        $frmHost->addRow(S_SITE_STREET_3, new CTextBox('ext_host_profiles[site_street_3]', $ext_host_profiles['site_street_3'], 61));
        $frmHost->addRow(S_SITE_CITY, new CTextBox('ext_host_profiles[site_city]', $ext_host_profiles['site_city'], 61));
        $frmHost->addRow(S_SITE_STATE, new CTextBox('ext_host_profiles[site_state]', $ext_host_profiles['site_state'], 61));
        $frmHost->addRow(S_SITE_COUNTRY, new CTextBox('ext_host_profiles[site_country]', $ext_host_profiles['site_country'], 61));
        $frmHost->addRow(S_SITE_ZIP, new CTextBox('ext_host_profiles[site_zip]', $ext_host_profiles['site_zip'], 61));
        $frmHost->addRow(S_SITE_RACK, new CTextBox('ext_host_profiles[site_rack]', $ext_host_profiles['site_rack'], 61));
        $frmHost->addRow(S_SITE_NOTES, new CTextArea('ext_host_profiles[site_notes]', $ext_host_profiles['site_notes'], 50, 5));
        $frmHost->addRow(S_POC_1_NAME, new CTextBox('ext_host_profiles[poc_1_name]', $ext_host_profiles['poc_1_name'], 61));
        $frmHost->addRow(S_POC_1_EMAIL, new CTextBox('ext_host_profiles[poc_1_email]', $ext_host_profiles['poc_1_email'], 61));
        $frmHost->addRow(S_POC_1_PHONE_1, new CTextBox('ext_host_profiles[poc_1_phone_1]', $ext_host_profiles['poc_1_phone_1'], 61));
        $frmHost->addRow(S_POC_1_PHONE_2, new CTextBox('ext_host_profiles[poc_1_phone_2]', $ext_host_profiles['poc_1_phone_2'], 61));
        $frmHost->addRow(S_POC_1_CELL, new CTextBox('ext_host_profiles[poc_1_cell]', $ext_host_profiles['poc_1_cell'], 61));
        $frmHost->addRow(S_POC_1_SCREEN, new CTextBox('ext_host_profiles[poc_1_screen]', $ext_host_profiles['poc_1_screen'], 61));
        $frmHost->addRow(S_POC_1_NOTES, new CTextArea('ext_host_profiles[poc_1_notes]', $ext_host_profiles['poc_1_notes'], 50, 5));
        $frmHost->addRow(S_POC_2_NAME, new CTextBox('ext_host_profiles[poc_2_name]', $ext_host_profiles['poc_2_name'], 61));
        $frmHost->addRow(S_POC_2_EMAIL, new CTextBox('ext_host_profiles[poc_2_email]', $ext_host_profiles['poc_2_email'], 61));
        $frmHost->addRow(S_POC_2_PHONE_1, new CTextBox('ext_host_profiles[poc_2_phone_1]', $ext_host_profiles['poc_2_phone_1'], 61));
        $frmHost->addRow(S_POC_2_PHONE_2, new CTextBox('ext_host_profiles[poc_2_phone_2]', $ext_host_profiles['poc_2_phone_2'], 61));
        $frmHost->addRow(S_POC_2_CELL, new CTextBox('ext_host_profiles[poc_2_cell]', $ext_host_profiles['poc_2_cell'], 61));
        $frmHost->addRow(S_POC_2_SCREEN, new CTextBox('ext_host_profiles[poc_2_screen]', $ext_host_profiles['poc_2_screen'], 61));
        $frmHost->addRow(S_POC_2_NOTES, new CTextArea('ext_host_profiles[poc_2_notes]', $ext_host_profiles['poc_2_notes'], 50, 5));
    } else {
        $frmHost->addVar('ext_host_profiles[device_alias]', $ext_host_profiles['device_alias']);
        $frmHost->addVar('ext_host_profiles[device_type]', $ext_host_profiles['device_type']);
        $frmHost->addVar('ext_host_profiles[device_chassis]', $ext_host_profiles['device_chassis']);
        $frmHost->addVar('ext_host_profiles[device_os]', $ext_host_profiles['device_os']);
        $frmHost->addVar('ext_host_profiles[device_os_short]', $ext_host_profiles['device_os_short']);
        $frmHost->addVar('ext_host_profiles[device_hw_arch]', $ext_host_profiles['device_hw_arch']);
        $frmHost->addVar('ext_host_profiles[device_serial]', $ext_host_profiles['device_serial']);
        $frmHost->addVar('ext_host_profiles[device_model]', $ext_host_profiles['device_model']);
        $frmHost->addVar('ext_host_profiles[device_tag]', $ext_host_profiles['device_tag']);
        $frmHost->addVar('ext_host_profiles[device_vendor]', $ext_host_profiles['device_vendor']);
        $frmHost->addVar('ext_host_profiles[device_contract]', $ext_host_profiles['device_contract']);
        $frmHost->addVar('ext_host_profiles[device_who]', $ext_host_profiles['device_who']);
        $frmHost->addVar('ext_host_profiles[device_status]', $ext_host_profiles['device_status']);
        $frmHost->addVar('ext_host_profiles[device_app_01]', $ext_host_profiles['device_app_01']);
        $frmHost->addVar('ext_host_profiles[device_app_02]', $ext_host_profiles['device_app_02']);
        $frmHost->addVar('ext_host_profiles[device_app_03]', $ext_host_profiles['device_app_03']);
        $frmHost->addVar('ext_host_profiles[device_app_04]', $ext_host_profiles['device_app_04']);
        $frmHost->addVar('ext_host_profiles[device_app_05]', $ext_host_profiles['device_app_05']);
        $frmHost->addVar('ext_host_profiles[device_url_1]', $ext_host_profiles['device_url_1']);
        $frmHost->addVar('ext_host_profiles[device_url_2]', $ext_host_profiles['device_url_2']);
        $frmHost->addVar('ext_host_profiles[device_url_3]', $ext_host_profiles['device_url_3']);
        $frmHost->addVar('ext_host_profiles[device_networks]', $ext_host_profiles['device_networks']);
        $frmHost->addVar('ext_host_profiles[device_notes]', $ext_host_profiles['device_notes']);
        $frmHost->addVar('ext_host_profiles[device_hardware]', $ext_host_profiles['device_hardware']);
        $frmHost->addVar('ext_host_profiles[device_software]', $ext_host_profiles['device_software']);
        $frmHost->addVar('ext_host_profiles[ip_subnet_mask]', $ext_host_profiles['ip_subnet_mask']);
        $frmHost->addVar('ext_host_profiles[ip_router]', $ext_host_profiles['ip_router']);
        $frmHost->addVar('ext_host_profiles[ip_macaddress]', $ext_host_profiles['ip_macaddress']);
        $frmHost->addVar('ext_host_profiles[oob_ip]', $ext_host_profiles['oob_ip']);
        $frmHost->addVar('ext_host_profiles[oob_subnet_mask]', $ext_host_profiles['oob_subnet_mask']);
        $frmHost->addVar('ext_host_profiles[oob_router]', $ext_host_profiles['oob_router']);
        $frmHost->addVar('ext_host_profiles[date_hw_buy]', $ext_host_profiles['date_hw_buy']);
        $frmHost->addVar('ext_host_profiles[date_hw_install]', $ext_host_profiles['date_hw_install']);
        $frmHost->addVar('ext_host_profiles[date_hw_expiry]', $ext_host_profiles['date_hw_expiry']);
        $frmHost->addVar('ext_host_profiles[date_hw_decomm]', $ext_host_profiles['date_hw_decomm']);
        $frmHost->addVar('ext_host_profiles[site_street_1]', $ext_host_profiles['site_street_1']);
        $frmHost->addVar('ext_host_profiles[site_street_2]', $ext_host_profiles['site_street_2']);
        $frmHost->addVar('ext_host_profiles[site_street_3]', $ext_host_profiles['site_street_3']);
        $frmHost->addVar('ext_host_profiles[site_city]', $ext_host_profiles['site_city']);
        $frmHost->addVar('ext_host_profiles[site_state]', $ext_host_profiles['site_state']);
        $frmHost->addVar('ext_host_profiles[site_country]', $ext_host_profiles['site_country']);
        $frmHost->addVar('ext_host_profiles[site_zip]', $ext_host_profiles['site_zip']);
        $frmHost->addVar('ext_host_profiles[site_rack]', $ext_host_profiles['site_rack']);
        $frmHost->addVar('ext_host_profiles[site_notes]', $ext_host_profiles['site_notes']);
        $frmHost->addVar('ext_host_profiles[poc_1_name]', $ext_host_profiles['poc_1_name']);
        $frmHost->addVar('ext_host_profiles[poc_1_email]', $ext_host_profiles['poc_1_email']);
        $frmHost->addVar('ext_host_profiles[poc_1_phone_1]', $ext_host_profiles['poc_1_phone_1']);
        $frmHost->addVar('ext_host_profiles[poc_1_phone_2]', $ext_host_profiles['poc_1_phone_2']);
        $frmHost->addVar('ext_host_profiles[poc_1_cell]', $ext_host_profiles['poc_1_cell']);
        $frmHost->addVar('ext_host_profiles[poc_1_screen]', $ext_host_profiles['poc_1_screen']);
        $frmHost->addVar('ext_host_profiles[poc_1_notes]', $ext_host_profiles['poc_1_notes']);
        $frmHost->addVar('ext_host_profiles[poc_2_name]', $ext_host_profiles['poc_2_name']);
        $frmHost->addVar('ext_host_profiles[poc_2_email]', $ext_host_profiles['poc_2_email']);
        $frmHost->addVar('ext_host_profiles[poc_2_phone_1]', $ext_host_profiles['poc_2_phone_1']);
        $frmHost->addVar('ext_host_profiles[poc_2_phone_2]', $ext_host_profiles['poc_2_phone_2']);
        $frmHost->addVar('ext_host_profiles[poc_2_cell]', $ext_host_profiles['poc_2_cell']);
        $frmHost->addVar('ext_host_profiles[poc_2_screen]', $ext_host_profiles['poc_2_screen']);
        $frmHost->addVar('ext_host_profiles[poc_2_notes]', $ext_host_profiles['poc_2_notes']);
    }
    // 		END:   HOSTS PROFILE EXTENDED Section
    if ($_REQUEST['form'] == 'full_clone') {
        // Host items
        $items_lbx = new CListBox('items', null, 8);
        $items_lbx->addOption('disabled', 'disabled');
        $sql = 'SELECT * ' . ' FROM items ' . ' WHERE hostid=' . $_REQUEST['hostid'] . ' AND templateid=0 ' . ' ORDER BY description';
        $host_items_res = DBselect($sql);
        while ($host_item = DBfetch($host_items_res)) {
            $item_description = item_description($host_item);
            $items_lbx->addItem($host_item['itemid'], $item_description);
        }
        if ($items_lbx->ItemsCount() < 1) {
            $items_lbx->addOption('style', 'width: 200px;');
        }
        $frmHost->addRow(S_ITEMS, $items_lbx);
        // Host triggers
        $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array($_REQUEST['hostid']), PERM_RES_IDS_ARRAY);
        $trig_lbx = new CListBox('triggers', null, 8);
        $trig_lbx->addOption('disabled', 'disabled');
        $sql = 'SELECT DISTINCT t.* ' . ' FROM triggers t, items i, functions f' . ' WHERE i.hostid=' . $_REQUEST['hostid'] . ' AND f.itemid=i.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.templateid=0 ' . ' ORDER BY t.description';
        $host_trig_res = DBselect($sql);
        while ($host_trig = DBfetch($host_trig_res)) {
            $trig_description = expand_trigger_description($host_trig["triggerid"]);
            $trig_lbx->addItem($host_trig['triggerid'], $trig_description);
        }
        if ($trig_lbx->ItemsCount() < 1) {
            $trig_lbx->addOption('style', 'width: 200px;');
        }
        $frmHost->addRow(S_TRIGGERS, $trig_lbx);
        // Host graphs
        $available_graphs = get_accessible_graphs(PERM_READ_ONLY, array($_REQUEST['hostid']), PERM_RES_IDS_ARRAY);
        $graphs_lbx = new CListBox('graphs', null, 8);
        $graphs_lbx->addOption('disabled', 'disabled');
        $def_items = array();
        $sql = 'SELECT DISTINCT g.* ' . ' FROM graphs g, graphs_items gi,items i ' . ' WHERE ' . DBcondition('g.graphid', $available_graphs) . ' AND gi.graphid=g.graphid ' . ' AND g.templateid=0 ' . ' AND i.itemid=gi.itemid ' . ' AND i.hostid=' . $_REQUEST['hostid'] . ' ORDER BY g.name';
        $host_graph_res = DBselect($sql);
        while ($host_graph = DBfetch($host_graph_res)) {
            $graphs_lbx->addItem($host_graph['graphid'], $host_graph['name']);
        }
        if ($graphs_lbx->ItemsCount() < 1) {
            $graphs_lbx->addOption('style', 'width: 200px;');
        }
        $frmHost->addRow(S_GRAPHS, $graphs_lbx);
    }
    $frmHost->addItemToBottomRow(new CButton("save", S_SAVE));
    if ($_REQUEST['hostid'] > 0 && $_REQUEST['form'] != 'full_clone') {
        $frmHost->addItemToBottomRow(SPACE);
        $frmHost->addItemToBottomRow(new CButton("clone", S_CLONE));
        $frmHost->addItemToBottomRow(SPACE);
        $frmHost->addItemToBottomRow(new CButton("full_clone", S_FULL_CLONE));
        $frmHost->addItemToBottomRow(SPACE);
        $frmHost->addItemToBottomRow(new CButtonDelete(S_DELETE_SELECTED_HOST_Q, url_param("form") . url_param("config") . url_param("hostid") . url_param('groupid')));
        if ($show_only_tmp) {
            $frmHost->addItemToBottomRow(SPACE);
            $frmHost->addItemToBottomRow(new CButtonQMessage('delete_and_clear', 'Delete AND clear', S_DELETE_SELECTED_HOSTS_Q, url_param("form") . url_param("config") . url_param("hostid") . url_param('groupid')));
        }
    }
    $frmHost->addItemToBottomRow(SPACE);
    $frmHost->addItemToBottomRow(new CButtonCancel(url_param("config") . url_param('groupid')));
    $frmHost->Show();
}
require_once dirname(__FILE__) . '/js/configuration.host.edit.js.php';
// create form
$hostForm = new CForm();
$hostForm->setName('hostForm');
$hostForm->addVar('go', 'massupdate');
foreach ($this->data['hosts'] as $hostid) {
    $hostForm->addVar('hosts[' . $hostid . ']', $hostid);
}
// create form list
$hostFormList = new CFormList('hostFormList');
// append groups to form list
$groupTweenBox = new CTweenBox($hostForm, 'groups', $this->data['groups'], 6);
foreach ($this->data['all_groups'] as $group) {
    $groupTweenBox->addItem($group['groupid'], $group['name']);
}
$hostFormList->addRow(array(_('Replace host groups'), SPACE, new CVisibilityBox('visible[groups]', isset($this->data['visible']['groups']), $groupTweenBox->getName(), _('Original'))), $groupTweenBox->get(_('In groups'), _('Other groups')));
$hostFormList->addRow(array(_('New host group'), SPACE, new CVisibilityBox('visible[newgroup]', isset($this->data['visible']['newgroup']), 'newgroup', _('Original'))), new CTextBox('newgroup', $this->data['newgroup'], ZBX_TEXTBOX_STANDARD_SIZE, 'no', 64), null, null, 'new');
// append proxy to form list
$proxyComboBox = new CComboBox('proxy_hostid', $this->data['proxy_hostid']);
$proxyComboBox->addItem(0, _('(no proxy)'));
foreach ($this->data['proxies'] as $proxie) {
    $proxyComboBox->addItem($proxie['hostid'], $proxie['host']);
}
$hostFormList->addRow(array(_('Monitored by proxy'), SPACE, new CVisibilityBox('visible[proxy_hostid]', isset($this->data['visible']['proxy_hostid']), 'proxy_hostid', _('Original'))), $proxyComboBox);
// append status to form list
$statusComboBox = new CComboBox('status', $this->data['status']);
$statusComboBox->addItem(HOST_STATUS_MONITORED, _('Monitored'));
$statusComboBox->addItem(HOST_STATUS_NOT_MONITORED, _('Not monitored'));
$hostFormList->addRow(array(_('Status'), SPACE, new CVisibilityBox('visible[status]', isset($this->data['visible']['status']), 'status', _('Original'))), $statusComboBox);
// append templates table to from list
$templatesTable = new CTable(_('No templates defined.'), 'formElementTable');
Пример #10
0
$cmbGroups->addItem(0, S_ALL_S);
$sql = 'SELECT usrgrpid, name FROM usrgrp WHERE ' . DBin_node('usrgrpid') . ' ORDER BY name';
$result = DBselect($sql);
while ($row = DBfetch($result)) {
    $cmbGroups->addItem($row['usrgrpid'], $row['name']);
}
$comboform->addItem($cmbGroups);
show_table_header(S_USERS, $comboform);
// -
// create user twinbox +
$form = new CForm('users.php');
$form->addOption('id', 'users');
$user_tb = new CTweenBox($form, 'usersid', null, 10);
$from = '';
$where = '';
if ($groupid > 0) {
    $from = ', users_groups g ';
    $where = ' AND u.userid=g.userid AND g.usrgrpid=' . $groupid;
}
$sql = 'SELECT u.userid, u.alias FROM users u ' . $from . ' WHERE ' . DBin_node('u.userid') . $where . ' ORDER BY name';
$result = DBselect($sql);
while ($row = DBfetch($result)) {
    $user_tb->addItem($row['userid'], $row['alias'], false);
}
$form->addItem($user_tb->get('asdasda', 'asdasdasdas'));
// -
$button = new CButton('select', S_SELECT, 'add_users("' . $dstfrm . '")');
$button->setType('button');
$form->addItem($button);
$form->show();
include_once "include/page_footer.php";
Пример #11
0
function insert_template_form()
{
    global $USER_DETAILS;
    $groups = get_request('groups', array());
    $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_WRITE);
    $newgroup = get_request('newgroup', '');
    $host = get_request('host', '');
    $port = get_request('port', get_profile('HOST_PORT', 10050));
    $status = get_request('status', HOST_STATUS_MONITORED);
    $useip = get_request('useip', 0);
    $dns = get_request('dns', '');
    $ip = get_request('ip', '0.0.0.0');
    $proxy_hostid = get_request('proxy_hostid', '');
    $useipmi = get_request('useipmi', 'no');
    $ipmi_ip = get_request('ipmi_ip', '');
    $ipmi_port = get_request('ipmi_port', 623);
    $ipmi_authtype = get_request('ipmi_authtype', -1);
    $ipmi_privilege = get_request('ipmi_privilege', 2);
    $ipmi_username = get_request('ipmi_username', '');
    $ipmi_password = get_request('ipmi_password', '');
    $useprofile = get_request('useprofile', 'no');
    $devicetype = get_request('devicetype', '');
    $name = get_request('name', '');
    $os = get_request('os', '');
    $serialno = get_request('serialno', '');
    $tag = get_request('tag', '');
    $macaddress = get_request('macaddress', '');
    $hardware = get_request('hardware', '');
    $software = get_request('software', '');
    $contact = get_request('contact', '');
    $location = get_request('location', '');
    $notes = get_request('notes', '');
    $templates = get_request('templates', array());
    $clear_templates = get_request('clear_templates', array());
    $frm_title = S_TEMPLATE;
    if ($_REQUEST['hostid'] > 0) {
        $db_host = get_host_by_hostid($_REQUEST['hostid']);
        $frm_title .= SPACE . ' [' . $db_host['host'] . ']';
        $original_templates = get_templates_by_hostid($_REQUEST['hostid']);
    } else {
        $original_templates = array();
    }
    if ($_REQUEST['hostid'] > 0 && !isset($_REQUEST['form_refresh'])) {
        $proxy_hostid = $db_host['proxy_hostid'];
        $host = $db_host['host'];
        $port = $db_host['port'];
        $status = $db_host['status'];
        $useip = $db_host['useip'];
        $useipmi = $db_host['useipmi'] ? 'yes' : 'no';
        $ip = $db_host['ip'];
        $dns = $db_host['dns'];
        $ipmi_ip = $db_host['ipmi_ip'];
        $ipmi_port = $db_host['ipmi_port'];
        $ipmi_authtype = $db_host['ipmi_authtype'];
        $ipmi_privilege = $db_host['ipmi_privilege'];
        $ipmi_username = $db_host['ipmi_username'];
        $ipmi_password = $db_host['ipmi_password'];
        // add groups
        $db_groups = DBselect('SELECT DISTINCT groupid ' . ' FROM hosts_groups ' . ' WHERE hostid=' . $_REQUEST['hostid'] . ' AND ' . DBcondition('groupid', $available_groups));
        while ($db_group = DBfetch($db_groups)) {
            if (uint_in_array($db_group['groupid'], $groups)) {
                continue;
            }
            $groups[$db_group['groupid']] = $db_group['groupid'];
        }
        $templates = $original_templates;
    }
    $clear_templates = array_intersect($clear_templates, array_keys($original_templates));
    $clear_templates = array_diff($clear_templates, array_keys($templates));
    asort($templates);
    $frmHost = new CFormTable($frm_title, 'hosts.php');
    $frmHost->setHelp('web.hosts.host.php');
    $frmHost->addVar('config', get_request('config', 0));
    $frmHost->addVar('clear_templates', $clear_templates);
    if ($_REQUEST['hostid'] > 0) {
        $frmHost->addVar('hostid', $_REQUEST['hostid']);
    }
    if ($_REQUEST['groupid'] > 0) {
        $frmHost->addVar('groupid', $_REQUEST['groupid']);
    }
    $frmHost->addRow(S_NAME, new CTextBox('host', $host, 54));
    $grp_tb = new CTweenBox($frmHost, 'groups', $groups, 10);
    $db_groups = DBselect('SELECT DISTINCT groupid,name ' . ' FROM groups ' . ' WHERE ' . DBcondition('groupid', $available_groups) . ' ORDER BY name');
    while ($db_group = DBfetch($db_groups)) {
        $grp_tb->addItem($db_group['groupid'], $db_group['name']);
    }
    $frmHost->addRow(S_GROUPS, $grp_tb->get(S_IN . SPACE . S_GROUPS, S_OTHER . SPACE . S_GROUPS));
    $frmHost->addRow(S_NEW_GROUP, new CTextBox('newgroup', $newgroup), 'new');
    // onchange does not work on some browsers: MacOS, KDE browser
    $frmHost->addVar('useip', 0);
    $frmHost->addVar('ip', '0.0.0.0');
    $frmHost->addVar('dns', '');
    $port = '10050';
    $status = HOST_STATUS_TEMPLATE;
    $frmHost->addVar('port', $port);
    $frmHost->addVar('status', $status);
    $template_table = new CTable();
    $template_table->SetCellPadding(0);
    $template_table->SetCellSpacing(0);
    foreach ($templates as $id => $temp_name) {
        $frmHost->addVar('templates[' . $id . ']', $temp_name);
        $template_table->addRow(array($temp_name, new CButton('unlink[' . $id . ']', S_UNLINK), isset($original_templates[$id]) ? new CButton('unlink_and_clear[' . $id . ']', S_UNLINK_AND_CLEAR) : SPACE));
    }
    $frmHost->addRow(S_LINK_WITH_TEMPLATE, array($template_table, new CButton('add_template', S_ADD, "return PopUp('popup.php?dstfrm=" . $frmHost->GetName() . "&dstfld1=new_template&srctbl=templates&srcfld1=hostid&srcfld2=host" . url_param($templates, false, 'existed_templates') . "',450,450)", 'T')));
    $frmHost->addVar('useipmi', $useipmi);
    $frmHost->addVar('ipmi_ip', $ipmi_ip);
    $frmHost->addVar('ipmi_port', $ipmi_port);
    $frmHost->addVar('ipmi_authtype', $ipmi_authtype);
    $frmHost->addVar('ipmi_privilege', $ipmi_privilege);
    $frmHost->addVar('ipmi_username', $ipmi_username);
    $frmHost->addVar('ipmi_password', $ipmi_password);
    $useprofile = 'no';
    $frmHost->addVar('useprofile', $useprofile);
    $useprofile_ext = 'no';
    $frmHost->addVar('useprofile_ext', $useprofile_ext);
    if ($_REQUEST['form'] == 'full_clone') {
        // Host items
        $items_lbx = new CListBox('items', null, 8);
        $items_lbx->setAttribute('disabled', 'disabled');
        $sql = 'SELECT * ' . ' FROM items ' . ' WHERE hostid=' . $_REQUEST['hostid'] . ' AND templateid=0 ' . ' ORDER BY description';
        $host_items_res = DBselect($sql);
        while ($host_item = DBfetch($host_items_res)) {
            $item_description = item_description($host_item);
            $items_lbx->addItem($host_item['itemid'], $item_description);
        }
        if ($items_lbx->ItemsCount() < 1) {
            $items_lbx->setAttribute('style', 'width: 200px;');
        }
        $frmHost->addRow(S_ITEMS, $items_lbx);
        // Host triggers
        $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array($_REQUEST['hostid']), PERM_RES_IDS_ARRAY);
        $trig_lbx = new CListBox('triggers', null, 8);
        $trig_lbx->setAttribute('disabled', 'disabled');
        $sql = 'SELECT DISTINCT t.* ' . ' FROM triggers t, items i, functions f' . ' WHERE i.hostid=' . $_REQUEST['hostid'] . ' AND f.itemid=i.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.templateid=0 ' . ' ORDER BY t.description';
        $host_trig_res = DBselect($sql);
        while ($host_trig = DBfetch($host_trig_res)) {
            $trig_description = expand_trigger_description($host_trig["triggerid"]);
            $trig_lbx->addItem($host_trig['triggerid'], $trig_description);
        }
        if ($trig_lbx->ItemsCount() < 1) {
            $trig_lbx->setAttribute('style', 'width: 200px;');
        }
        $frmHost->addRow(S_TRIGGERS, $trig_lbx);
        // Host graphs
        $available_graphs = get_accessible_graphs(PERM_READ_ONLY, array($_REQUEST['hostid']), PERM_RES_IDS_ARRAY);
        $graphs_lbx = new CListBox('graphs', null, 8);
        $graphs_lbx->setAttribute('disabled', 'disabled');
        $def_items = array();
        $sql = 'SELECT DISTINCT g.* ' . ' FROM graphs g, graphs_items gi,items i ' . ' WHERE ' . DBcondition('g.graphid', $available_graphs) . ' AND gi.graphid=g.graphid ' . ' AND g.templateid=0 ' . ' AND i.itemid=gi.itemid ' . ' AND i.hostid=' . $_REQUEST['hostid'] . ' ORDER BY g.name';
        $host_graph_res = DBselect($sql);
        while ($host_graph = DBfetch($host_graph_res)) {
            $graphs_lbx->addItem($host_graph['graphid'], $host_graph['name']);
        }
        if ($graphs_lbx->ItemsCount() < 1) {
            $graphs_lbx->setAttribute('style', 'width: 200px;');
        }
        $frmHost->addRow(S_GRAPHS, $graphs_lbx);
    }
    $frmHost->addItemToBottomRow(new CButton("save", S_SAVE));
    if ($_REQUEST['hostid'] > 0 && $_REQUEST['form'] != 'full_clone') {
        $frmHost->addItemToBottomRow(SPACE);
        $frmHost->addItemToBottomRow(new CButton("clone", S_CLONE));
        $frmHost->addItemToBottomRow(SPACE);
        $frmHost->addItemToBottomRow(new CButton("full_clone", S_FULL_CLONE));
        $frmHost->addItemToBottomRow(SPACE);
        $frmHost->addItemToBottomRow(new CButtonDelete(S_DELETE_SELECTED_HOST_Q, url_param("form") . url_param("config") . url_param("hostid") . url_param('groupid')));
        $frmHost->addItemToBottomRow(SPACE);
        $frmHost->addItemToBottomRow(new CButtonQMessage('delete_and_clear', 'Delete AND clear', S_DELETE_SELECTED_HOSTS_Q, url_param("form") . url_param("config") . url_param("hostid") . url_param('groupid')));
    }
    $frmHost->addItemToBottomRow(SPACE);
    $frmHost->addItemToBottomRow(new CButtonCancel(url_param("config") . url_param('groupid')));
    $frmHost->show();
}
Пример #12
0
function insert_host_form()
{
    global $USER_DETAILS;
    $host_groups = get_request('groups', array());
    if (isset($_REQUEST['groupid']) && $_REQUEST['groupid'] > 0 && empty($host_groups)) {
        array_push($host_groups, $_REQUEST['groupid']);
    }
    $newgroup = get_request('newgroup', '');
    $host = get_request('host', '');
    $port = get_request('port', CProfile::get('HOST_PORT', 10050));
    $status = get_request('status', HOST_STATUS_MONITORED);
    $useip = get_request('useip', 1);
    $dns = get_request('dns', '');
    $ip = get_request('ip', '0.0.0.0');
    $proxy_hostid = get_request('proxy_hostid', '');
    $useipmi = get_request('useipmi', 'no');
    $ipmi_ip = get_request('ipmi_ip', '');
    $ipmi_port = get_request('ipmi_port', 623);
    $ipmi_authtype = get_request('ipmi_authtype', -1);
    $ipmi_privilege = get_request('ipmi_privilege', 2);
    $ipmi_username = get_request('ipmi_username', '');
    $ipmi_password = get_request('ipmi_password', '');
    $useprofile = get_request('useprofile', 'no');
    $devicetype = get_request('devicetype', '');
    $name = get_request('name', '');
    $os = get_request('os', '');
    $serialno = get_request('serialno', '');
    $tag = get_request('tag', '');
    $macaddress = get_request('macaddress', '');
    $hardware = get_request('hardware', '');
    $software = get_request('software', '');
    $contact = get_request('contact', '');
    $location = get_request('location', '');
    $notes = get_request('notes', '');
    $_REQUEST['hostid'] = get_request('hostid', 0);
    // BEGIN: HOSTS PROFILE EXTENDED Section
    $useprofile_ext = get_request('useprofile_ext', 'no');
    $ext_host_profiles = get_request('ext_host_profiles', array());
    // END:   HOSTS PROFILE EXTENDED Section
    $templates = get_request('templates', array());
    $clear_templates = get_request('clear_templates', array());
    $frm_title = S_HOST;
    if ($_REQUEST['hostid'] > 0) {
        $db_host = get_host_by_hostid($_REQUEST['hostid']);
        $frm_title .= SPACE . ' [' . $db_host['host'] . ']';
        $original_templates = get_templates_by_hostid($_REQUEST['hostid']);
    } else {
        $original_templates = array();
    }
    if ($_REQUEST['hostid'] > 0 && !isset($_REQUEST['form_refresh'])) {
        $proxy_hostid = $db_host['proxy_hostid'];
        $host = $db_host['host'];
        $port = $db_host['port'];
        $status = $db_host['status'];
        $useip = $db_host['useip'];
        $useipmi = $db_host['useipmi'] ? 'yes' : 'no';
        $ip = $db_host['ip'];
        $dns = $db_host['dns'];
        $ipmi_ip = $db_host['ipmi_ip'];
        $ipmi_port = $db_host['ipmi_port'];
        $ipmi_authtype = $db_host['ipmi_authtype'];
        $ipmi_privilege = $db_host['ipmi_privilege'];
        $ipmi_username = $db_host['ipmi_username'];
        $ipmi_password = $db_host['ipmi_password'];
        // add groups
        $options = array('hostids' => $_REQUEST['hostid']);
        $host_groups = CHostGroup::get($options);
        $host_groups = zbx_objectValues($host_groups, 'groupid');
        // read profile
        $db_profiles = DBselect('SELECT * FROM hosts_profiles WHERE hostid=' . $_REQUEST['hostid']);
        $useprofile = 'no';
        $db_profile = DBfetch($db_profiles);
        if ($db_profile) {
            $useprofile = 'yes';
            $devicetype = $db_profile['devicetype'];
            $name = $db_profile['name'];
            $os = $db_profile['os'];
            $serialno = $db_profile['serialno'];
            $tag = $db_profile['tag'];
            $macaddress = $db_profile['macaddress'];
            $hardware = $db_profile['hardware'];
            $software = $db_profile['software'];
            $contact = $db_profile['contact'];
            $location = $db_profile['location'];
            $notes = $db_profile['notes'];
        }
        // BEGIN: HOSTS PROFILE EXTENDED Section
        $useprofile_ext = 'no';
        $db_profiles_alt = DBselect('SELECT * FROM hosts_profiles_ext WHERE hostid=' . $_REQUEST['hostid']);
        if ($ext_host_profiles = DBfetch($db_profiles_alt)) {
            $useprofile_ext = 'yes';
        } else {
            $ext_host_profiles = array();
        }
        // END:   HOSTS PROFILE EXTENDED Section
        $templates = $original_templates;
    }
    $ext_profiles_fields = array('device_alias' => S_DEVICE_ALIAS, 'device_type' => S_DEVICE_TYPE, 'device_chassis' => S_DEVICE_CHASSIS, 'device_os' => S_DEVICE_OS, 'device_os_short' => S_DEVICE_OS_SHORT, 'device_hw_arch' => S_DEVICE_HW_ARCH, 'device_serial' => S_DEVICE_SERIAL, 'device_model' => S_DEVICE_MODEL, 'device_tag' => S_DEVICE_TAG, 'device_vendor' => S_DEVICE_VENDOR, 'device_contract' => S_DEVICE_CONTRACT, 'device_who' => S_DEVICE_WHO, 'device_status' => S_DEVICE_STATUS, 'device_app_01' => S_DEVICE_APP_01, 'device_app_02' => S_DEVICE_APP_02, 'device_app_03' => S_DEVICE_APP_03, 'device_app_04' => S_DEVICE_APP_04, 'device_app_05' => S_DEVICE_APP_05, 'device_url_1' => S_DEVICE_URL_1, 'device_url_2' => S_DEVICE_URL_2, 'device_url_3' => S_DEVICE_URL_3, 'device_networks' => S_DEVICE_NETWORKS, 'device_notes' => S_DEVICE_NOTES, 'device_hardware' => S_DEVICE_HARDWARE, 'device_software' => S_DEVICE_SOFTWARE, 'ip_subnet_mask' => S_IP_SUBNET_MASK, 'ip_router' => S_IP_ROUTER, 'ip_macaddress' => S_IP_MACADDRESS, 'oob_ip' => S_OOB_IP, 'oob_subnet_mask' => S_OOB_SUBNET_MASK, 'oob_router' => S_OOB_ROUTER, 'date_hw_buy' => S_DATE_HW_BUY, 'date_hw_install' => S_DATE_HW_INSTALL, 'date_hw_expiry' => S_DATE_HW_EXPIRY, 'date_hw_decomm' => S_DATE_HW_DECOMM, 'site_street_1' => S_SITE_STREET_1, 'site_street_2' => S_SITE_STREET_2, 'site_street_3' => S_SITE_STREET_3, 'site_city' => S_SITE_CITY, 'site_state' => S_SITE_STATE, 'site_country' => S_SITE_COUNTRY, 'site_zip' => S_SITE_ZIP, 'site_rack' => S_SITE_RACK, 'site_notes' => S_SITE_NOTES, 'poc_1_name' => S_POC_1_NAME, 'poc_1_email' => S_POC_1_EMAIL, 'poc_1_phone_1' => S_POC_1_PHONE_1, 'poc_1_phone_2' => S_POC_1_PHONE_2, 'poc_1_cell' => S_POC_1_CELL, 'poc_1_screen' => S_POC_1_SCREEN, 'poc_1_notes' => S_POC_1_NOTES, 'poc_2_name' => S_POC_2_NAME, 'poc_2_email' => S_POC_2_EMAIL, 'poc_2_phone_1' => S_POC_2_PHONE_1, 'poc_2_phone_2' => S_POC_2_PHONE_2, 'poc_2_cell' => S_POC_2_CELL, 'poc_2_screen' => S_POC_2_SCREEN, 'poc_2_notes' => S_POC_2_NOTES);
    foreach ($ext_profiles_fields as $field => $caption) {
        if (!isset($ext_host_profiles[$field])) {
            $ext_host_profiles[$field] = '';
        }
    }
    $clear_templates = array_intersect($clear_templates, array_keys($original_templates));
    $clear_templates = array_diff($clear_templates, array_keys($templates));
    natcasesort($templates);
    $frmHost = new CForm('hosts.php', 'post');
    $frmHost->setName('web.hosts.host.php.');
    //		$frmHost->setHelp('web.hosts.host.php');
    //		$frmHost->addVar('config',get_request('config',0));
    $frmHost->addVar('form', get_request('form', 1));
    $from_rfr = get_request('form_refresh', 0);
    $frmHost->addVar('form_refresh', $from_rfr + 1);
    $frmHost->addVar('clear_templates', $clear_templates);
    // HOST WIDGET {
    $host_tbl = new CTable('', 'tablestripped');
    $host_tbl->setOddRowClass('form_odd_row');
    $host_tbl->setEvenRowClass('form_even_row');
    if ($_REQUEST['hostid'] > 0) {
        $frmHost->addVar('hostid', $_REQUEST['hostid']);
    }
    if ($_REQUEST['groupid'] > 0) {
        $frmHost->addVar('groupid', $_REQUEST['groupid']);
    }
    $host_tbl->addRow(array(S_NAME, new CTextBox('host', $host, 54)));
    $grp_tb = new CTweenBox($frmHost, 'groups', $host_groups, 10);
    $all_groups = CHostGroup::get(array('editable' => 1, 'extendoutput' => 1));
    order_result($all_groups, 'name');
    foreach ($all_groups as $group) {
        $grp_tb->addItem($group['groupid'], $group['name']);
    }
    $host_tbl->addRow(array(S_GROUPS, $grp_tb->get(S_IN_GROUPS, S_OTHER_GROUPS)));
    $host_tbl->addRow(array(S_NEW_GROUP, new CTextBox('newgroup', $newgroup)));
    // onchange does not work on some browsers: MacOS, KDE browser
    $host_tbl->addRow(array(S_DNS_NAME, new CTextBox('dns', $dns, '40')));
    if (defined('ZBX_HAVE_IPV6')) {
        $host_tbl->addRow(array(S_IP_ADDRESS, new CTextBox('ip', $ip, '39')));
    } else {
        $host_tbl->addRow(array(S_IP_ADDRESS, new CTextBox('ip', $ip, '15')));
    }
    $cmbConnectBy = new CComboBox('useip', $useip);
    $cmbConnectBy->addItem(0, S_DNS_NAME);
    $cmbConnectBy->addItem(1, S_IP_ADDRESS);
    $host_tbl->addRow(array(S_CONNECT_TO, $cmbConnectBy));
    $host_tbl->addRow(array(S_AGENT_PORT, new CNumericBox('port', $port, 5)));
    //Proxy
    $cmbProxy = new CComboBox('proxy_hostid', $proxy_hostid);
    $cmbProxy->addItem(0, S_NO_PROXY);
    $options = array('extendoutput' => 1);
    $db_proxies = CProxy::get($options);
    order_result($db_proxies, 'host');
    foreach ($db_proxies as $proxy) {
        $cmbProxy->addItem($proxy['proxyid'], $proxy['host']);
    }
    $host_tbl->addRow(array(S_MONITORED_BY_PROXY, $cmbProxy));
    //----------
    $cmbStatus = new CComboBox('status', $status);
    $cmbStatus->addItem(HOST_STATUS_MONITORED, S_MONITORED);
    $cmbStatus->addItem(HOST_STATUS_NOT_MONITORED, S_NOT_MONITORED);
    $host_tbl->addRow(array(S_STATUS, $cmbStatus));
    $host_tbl->addRow(array(S_USEIPMI, new CCheckBox('useipmi', $useipmi, 'submit()')));
    if ($useipmi == 'yes') {
        $host_tbl->addRow(array(S_IPMI_IP_ADDRESS, new CTextBox('ipmi_ip', $ipmi_ip, defined('ZBX_HAVE_IPV6') ? 39 : 15)));
        $host_tbl->addRow(array(S_IPMI_PORT, new CNumericBox('ipmi_port', $ipmi_port, 5)));
        $cmbIPMIAuthtype = new CComboBox('ipmi_authtype', $ipmi_authtype);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_DEFAULT, S_AUTHTYPE_DEFAULT);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_NONE, S_AUTHTYPE_NONE);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD2, S_AUTHTYPE_MD2);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_MD5, S_AUTHTYPE_MD5);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_STRAIGHT, S_AUTHTYPE_STRAIGHT);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_OEM, S_AUTHTYPE_OEM);
        $cmbIPMIAuthtype->addItem(IPMI_AUTHTYPE_RMCP_PLUS, S_AUTHTYPE_RMCP_PLUS);
        $host_tbl->addRow(array(S_IPMI_AUTHTYPE, $cmbIPMIAuthtype));
        $cmbIPMIPrivilege = new CComboBox('ipmi_privilege', $ipmi_privilege);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_CALLBACK, S_PRIVILEGE_CALLBACK);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_USER, S_PRIVILEGE_USER);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OPERATOR, S_PRIVILEGE_OPERATOR);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_ADMIN, S_PRIVILEGE_ADMIN);
        $cmbIPMIPrivilege->addItem(IPMI_PRIVILEGE_OEM, S_PRIVILEGE_OEM);
        $host_tbl->addRow(array(S_IPMI_PRIVILEGE, $cmbIPMIPrivilege));
        $host_tbl->addRow(array(S_IPMI_USERNAME, new CTextBox('ipmi_username', $ipmi_username, 16)));
        $host_tbl->addRow(array(S_IPMI_PASSWORD, new CTextBox('ipmi_password', $ipmi_password, 20)));
    } else {
        $frmHost->addVar('ipmi_ip', $ipmi_ip);
        $frmHost->addVar('ipmi_port', $ipmi_port);
        $frmHost->addVar('ipmi_authtype', $ipmi_authtype);
        $frmHost->addVar('ipmi_privilege', $ipmi_privilege);
        $frmHost->addVar('ipmi_username', $ipmi_username);
        $frmHost->addVar('ipmi_password', $ipmi_password);
    }
    if ($_REQUEST['form'] == 'full_clone') {
        // Host items
        $options = array('inherited' => 0, 'hostids' => $_REQUEST['hostid'], 'output' => API_OUTPUT_EXTEND, 'webitems' => 1);
        $host_items = CItem::get($options);
        if (!empty($host_items)) {
            $items_lbx = new CListBox('items', null, 8);
            $items_lbx->setAttribute('disabled', 'disabled');
            order_result($host_items, 'description');
            foreach ($host_items as $hitem) {
                $items_lbx->addItem($hitem['itemid'], item_description($hitem));
            }
            $host_tbl->addRow(array(S_ITEMS, $items_lbx));
        }
        // Host triggers
        $options = array('inherited' => 0, 'hostids' => $_REQUEST['hostid'], 'output' => API_OUTPUT_EXTEND, 'expandDescription' => true);
        $host_triggers = CTrigger::get($options);
        if (!empty($host_triggers)) {
            $trig_lbx = new CListBox('triggers', null, 8);
            $trig_lbx->setAttribute('disabled', 'disabled');
            order_result($host_triggers, 'description');
            foreach ($host_triggers as $htrigger) {
                $trig_lbx->addItem($htrigger['triggerid'], $htrigger['description']);
            }
            $host_tbl->addRow(array(S_TRIGGERS, $trig_lbx));
        }
        // Host graphs
        $options = array('inherited' => 0, 'hostids' => $_REQUEST['hostid'], 'select_hosts' => API_OUTPUT_REFER, 'output' => API_OUTPUT_EXTEND);
        $host_graphs = CGraph::get($options);
        if (!empty($host_graphs)) {
            $graphs_lbx = new CListBox('graphs', null, 8);
            $graphs_lbx->setAttribute('disabled', 'disabled');
            order_result($host_graphs, 'name');
            foreach ($host_graphs as $hgraph) {
                if (count($hgraph['hosts']) > 1) {
                    continue;
                }
                $graphs_lbx->addItem($hgraph['graphid'], $hgraph['name']);
            }
            if ($graphs_lbx->ItemsCount() > 1) {
                $host_tbl->addRow(array(S_GRAPHS, $graphs_lbx));
            }
        }
    }
    $host_footer = array();
    $host_footer[] = new CButton('save', S_SAVE);
    if ($_REQUEST['hostid'] > 0 && $_REQUEST['form'] != 'full_clone') {
        array_push($host_footer, SPACE, new CButton('clone', S_CLONE), SPACE, new CButton('full_clone', S_FULL_CLONE), SPACE, new CButtonDelete(S_DELETE_SELECTED_HOST_Q, url_param('form') . url_param('hostid') . url_param('groupid')));
    }
    array_push($host_footer, SPACE, new CButtonCancel(url_param('groupid')));
    $host_footer = new CCol($host_footer);
    $host_footer->setColSpan(2);
    $host_tbl->setFooter($host_footer);
    $host_wdgt = new CWidget();
    $host_wdgt->setClass('header');
    $host_wdgt->addHeader($frm_title);
    $host_wdgt->addItem($host_tbl);
    // } HOST WIDGET
    // TEMPLATES{
    $template_tbl = new CTableInfo(S_NO_TEMPLATES_LINKED, 'tablestripped');
    $template_tbl->setOddRowClass('form_odd_row');
    $template_tbl->setEvenRowClass('form_even_row');
    foreach ($templates as $id => $temp_name) {
        $frmHost->addVar('templates[' . $id . ']', $temp_name);
        $template_tbl->addRow(new CCol(array(new CCheckBox('templates_rem[' . $id . ']', 'no', null, $id), $temp_name)));
    }
    $footer = new CCol(array(new CButton('add_template', S_ADD, "return PopUp('popup.php?dstfrm=" . $frmHost->getName() . "&dstfld1=new_template&srctbl=templates&srcfld1=hostid&srcfld2=host" . url_param($templates, false, 'existed_templates') . "',450,450)", 'T'), SPACE, new CButton('unlink', S_UNLINK), SPACE, new CButton('unlink_and_clear', S_UNLINK_AND_CLEAR)));
    //$footer->setColSpan(2);
    $template_tbl->setFooter($footer);
    $template_wdgt = new CWidget();
    $template_wdgt->setClass('header');
    $template_wdgt->addHeader(S_LINKED_TEMPLATES);
    $template_wdgt->addItem($template_tbl);
    // } TEMPLATES
    // MACROS WIDGET {
    $macros_wdgt = get_macros_widget($_REQUEST['hostid']);
    // } MACROS WIDGET
    // PROFILE WIDGET {
    $profile_tbl = new CTable('', 'tablestripped');
    $profile_tbl->setOddRowClass('form_odd_row');
    $profile_tbl->setEvenRowClass('form_even_row');
    $profile_tbl->addRow(array(S_USE_PROFILE, new CCheckBox('useprofile', $useprofile, 'submit()')));
    if ($useprofile == 'yes') {
        $profile_tbl->addRow(array(S_DEVICE_TYPE, new CTextBox('devicetype', $devicetype, 61)));
        $profile_tbl->addRow(array(S_NAME, new CTextBox('name', $name, 61)));
        $profile_tbl->addRow(array(S_OS, new CTextBox('os', $os, 61)));
        $profile_tbl->addRow(array(S_SERIALNO, new CTextBox('serialno', $serialno, 61)));
        $profile_tbl->addRow(array(S_TAG, new CTextBox('tag', $tag, 61)));
        $profile_tbl->addRow(array(S_MACADDRESS, new CTextBox('macaddress', $macaddress, 61)));
        $profile_tbl->addRow(array(S_HARDWARE, new CTextArea('hardware', $hardware, 60, 4)));
        $profile_tbl->addRow(array(S_SOFTWARE, new CTextArea('software', $software, 60, 4)));
        $profile_tbl->addRow(array(S_CONTACT, new CTextArea('contact', $contact, 60, 4)));
        $profile_tbl->addRow(array(S_LOCATION, new CTextArea('location', $location, 60, 4)));
        $profile_tbl->addRow(array(S_NOTES, new CTextArea('notes', $notes, 60, 4)));
    } else {
        $frmHost->addVar('devicetype', $devicetype);
        $frmHost->addVar('name', $name);
        $frmHost->addVar('os', $os);
        $frmHost->addVar('serialno', $serialno);
        $frmHost->addVar('tag', $tag);
        $frmHost->addVar('macaddress', $macaddress);
        $frmHost->addVar('hardware', $hardware);
        $frmHost->addVar('software', $software);
        $frmHost->addVar('contact', $contact);
        $frmHost->addVar('location', $location);
        $frmHost->addVar('notes', $notes);
    }
    $profile_wdgt = new CWidget();
    $profile_wdgt->setClass('header');
    $profile_wdgt->addHeader(S_PROFILE);
    $profile_wdgt->addItem($profile_tbl);
    // } PROFILE WIDGET
    // EXT PROFILE WIDGET {
    $ext_profile_tbl = new CTable('', 'tablestripped');
    $ext_profile_tbl->setOddRowClass('form_odd_row');
    $ext_profile_tbl->setEvenRowClass('form_even_row');
    $ext_profile_tbl->addRow(array(S_USE_EXTENDED_PROFILE, new CCheckBox('useprofile_ext', $useprofile_ext, 'submit()', 'yes')));
    foreach ($ext_profiles_fields as $prof_field => $caption) {
        if ($useprofile_ext == 'yes') {
            $ext_profile_tbl->addRow(array($caption, new CTextBox('ext_host_profiles[' . $prof_field . ']', $ext_host_profiles[$prof_field], 40)));
        } else {
            $frmHost->addVar('ext_host_profiles[' . $prof_field . ']', $ext_host_profiles[$prof_field]);
        }
    }
    $ext_profile_wdgt = new CWidget();
    $ext_profile_wdgt->setClass('header');
    $ext_profile_wdgt->addHeader(S_EXTENDED_HOST_PROFILE);
    $ext_profile_wdgt->addItem($ext_profile_tbl);
    // } EXT PROFILE WIDGET
    $left_table = new CTable();
    $left_table->setCellPadding(4);
    $left_table->setCellSpacing(4);
    $left_table->addRow($host_wdgt);
    $right_table = new CTable();
    $right_table->setCellPadding(4);
    $right_table->setCellSpacing(4);
    $right_table->addRow($template_wdgt);
    $right_table->addRow($macros_wdgt);
    $right_table->addRow($profile_wdgt);
    $right_table->addRow($ext_profile_wdgt);
    $td_l = new CCol($left_table);
    $td_l->setAttribute('valign', 'top');
    $td_r = new CCol($right_table);
    $td_r->setAttribute('valign', 'top');
    $outer_table = new CTable();
    $outer_table->addRow(array($td_l, $td_r));
    $frmHost->addItem($outer_table);
    return $frmHost;
}
Пример #13
0
 // TEMPLATE WIDGET {
 $template_tbl = new CTable('', 'tablestripped');
 $template_tbl->setOddRowClass('form_odd_row');
 $template_tbl->setEvenRowClass('form_even_row');
 // FORM ITEM : Template name text box [  ]
 $template_tbl->addRow(array(S_NAME, new CTextBox('template_name', $template_name, 54)));
 // FORM ITEM : Groups tween box [  ] [  ]
 // get all Groups
 $group_tb = new CTweenBox($frmHost, 'groups', $groups, 10);
 $options = array('editable' => 1, 'extendoutput' => 1);
 $all_groups = CHostGroup::get($options);
 order_result($all_groups, 'name');
 foreach ($all_groups as $gnum => $group) {
     $group_tb->addItem($group['groupid'], $group['name']);
 }
 $template_tbl->addRow(array(S_GROUPS, $group_tb->get(S_IN . SPACE . S_GROUPS, S_OTHER . SPACE . S_GROUPS)));
 // FORM ITEM : new group text box [  ]
 $template_tbl->addRow(array(S_NEW_GROUP, new CTextBox('newgroup', $newgroup)));
 // FORM ITEM : linked Hosts tween box [  ] [  ]
 // $options = array('editable' => 1, 'extendoutput' => 1);
 // $twb_groups = CHostGroup::get($options);
 $twb_groupid = get_request('twb_groupid', 0);
 if ($twb_groupid == 0) {
     $gr = reset($all_groups);
     $twb_groupid = $gr['groupid'];
 }
 $cmbGroups = new CComboBox('twb_groupid', $twb_groupid, 'submit()');
 foreach ($all_groups as $gnum => $group) {
     $cmbGroups->addItem($group['groupid'], $group['name']);
 }
 $host_tb = new CTweenBox($frmHost, 'hosts', $hosts_linked_to, 25);
Пример #14
0
 }
 $clear_templates = array_intersect($clear_templates, array_keys($original_templates));
 $clear_templates = array_diff($clear_templates, array_keys($templates));
 asort($templates);
 $frmHost->addVar('clear_templates', $clear_templates);
 // FORM ITEM : Template name text box [  ]
 $frmHost->addRow(S_NAME, new CTextBox('template_name', $template_name, 54));
 // FORM ITEM : Groups tween box [  ] [  ]
 // get all Groups
 $group_tb = new CTweenBox($frmHost, 'groups', $groups, 10);
 $options = array('editable' => 1, 'extendoutput' => 1);
 $all_groups = CHostGroup::get($options);
 foreach ($all_groups as $groupid => $group) {
     $group_tb->addItem($groupid, $group['name']);
 }
 $frmHost->addRow(S_GROUPS, $group_tb->get(S_IN . SPACE . S_GROUPS, S_OTHER . SPACE . S_GROUPS));
 // FORM ITEM : new group text box [  ]
 $frmHost->addRow(S_NEW_GROUP, new CTextBox('newgroup', $newgroup), 'new');
 // FORM ITEM : linked Hosts tween box [  ] [  ]
 $options = array('editable' => 1, 'extendoutput' => 1, 'real_hosts' => 1);
 $twb_groups = CHostGroup::get($options);
 $twb_groupid = get_request('twb_groupid', 0);
 if ($twb_groupid == 0) {
     $gr = reset($twb_groups);
     $twb_groupid = $gr['groupid'];
 }
 $cmbGroups = new CComboBox('twb_groupid', $twb_groupid, 'submit()');
 foreach ($twb_groups as $groupid => $group) {
     $cmbGroups->addItem($groupid, $group['name']);
 }
 $host_tb = new CTweenBox($frmHost, 'hosts', $hosts_linked_to, 25);