Exemple #1
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();
}
Exemple #2
0
 if (isset($_REQUEST['actionid'])) {
     $action = get_action_by_actionid($_REQUEST['actionid']);
     $frmAction->addVar('actionid', $_REQUEST['actionid']);
 }
 $left_tab = new CTable();
 $left_tab->setCellPadding(3);
 $left_tab->setCellSpacing(3);
 $left_tab->addOption('border', 0);
 $left_tab->addRow(create_hat(S_ACTION, get_act_action_form($action), null, 'hat_action'));
 $left_tab->addRow(create_hat(S_ACTION_CONDITIONS, get_act_condition_form($action), null, 'hat_conditions'));
 if (isset($_REQUEST['new_condition'])) {
     $left_tab->addRow(create_hat(S_NEW_CONDITION, get_act_new_cond_form($action), null, 'hat_new_cond'));
 }
 $right_tab = new CTable();
 $right_tab->SetCellPadding(3);
 $right_tab->SetCellSpacing(3);
 $right_tab->addOption('border', 0);
 $right_tab->addRow(create_hat(S_ACTION_OPERATIONS, get_act_operations_form($action), null, 'hat_operations'));
 if (isset($_REQUEST['new_operation'])) {
     $right_tab->addRow(create_hat(S_EDIT_OPERATION, get_act_new_oper_form($action), null, 'hat_new_oper'));
 }
 if (isset($_REQUEST['new_opcondition'])) {
     $right_tab->addRow(create_hat(S_NEW . SPACE . S_OPERATION_CONDITION, get_oper_new_cond_form($action), null, 'hat_new_oper_cond'));
 }
 $td_l = new CCol($left_tab);
 $td_l->addOption('valign', 'top');
 $td_r = new CCol($right_tab);
 $td_r->addOption('valign', 'top');
 $outer_table = new CTable();
 $outer_table->addOption('border', 0);
 $outer_table->SetCellPadding(1);
Exemple #3
0
    if (isset($ZBX_PAGE_POST_JS)) {
        foreach ($ZBX_PAGE_POST_JS as $script) {
            echo $script . "\n";
        }
    }
    ?>
}

try{
	chkbx_range_ext.init();
}
catch(e){
	throw('Checkbox extension failed!');
}
-->
</script>
<?php 
    //SDI(SBR.'SELECTS: '.$DB['SELECT_COUNT'].SPACE.SPACE.'EXECUTE: '.$DB['EXECUTE_COUNT'].SPACE.SPACE.'TOTAL: '.($DB['EXECUTE_COUNT']+$DB['SELECT_COUNT']));
    if (!defined('ZBX_PAGE_NO_MENU') && !defined('ZBX_PAGE_NO_FOOTER')) {
        $table = new CTable(NULL, "page_footer");
        $table->SetCellSpacing(0);
        $table->SetCellPadding(1);
        $table->AddRow(array(new CCol(new CLink(S_ZABBIX_VER . SPACE . S_COPYRIGHT_BY . SPACE . S_SIA_ZABBIX, "http://www.zabbix.com", "highlight", null, true), "page_footer_l"), new CCol(array(new CSpan(SPACE . SPACE . "|" . SPACE . SPACE, "divider"), new CSpan($USER_DETAILS['userid'] == 0 ? S_NOT_CONNECTED : S_CONNECTED_AS . SPACE . "'" . $USER_DETAILS["alias"] . "'" . (ZBX_DISTRIBUTED ? SPACE . S_FROM_SMALL . SPACE . "'" . $USER_DETAILS["node"]['name'] . "'" : ''), 'footer_sign')), "page_footer_r")));
        $table->Show();
    }
    COpt::profiling_stop("page");
    COpt::profiling_stop("script");
    echo "</body>\n";
    echo "</html>\n";
}
exit;
Exemple #4
0
    $cmbResource->addItem(AUDIT_RESOURCE_SCENARIO, S_SCENARIO);
    $cmbResource->addItem(AUDIT_RESOURCE_DISCOVERY_RULE, S_DISCOVERY_RULE);
    $cmbResource->addItem(AUDIT_RESOURCE_SLIDESHOW, S_SLIDESHOW);
    $cmbResource->addItem(AUDIT_RESOURCE_SCRIPT, S_SCRIPT);
    $cmbResource->addItem(AUDIT_RESOURCE_PROXY, S_PROXY);
    $cmbResource->addItem(AUDIT_RESOURCE_MAINTENANCE, S_MAINTENANCE);
    $cmbResource->addItem(AUDIT_RESOURCE_REGEXP, S_REGULAR_EXPRESSION);
    $filterForm->addRow(S_RESOURCE, $cmbResource);
}
//*
$clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
$clndr_icon->AddAction('onclick', "javascript: var pos = getPosition(this); pos.top+=10; pos.left+=16; CLNDR['audit_since'].clndr.clndrshow(pos.top,pos.left);");
$filtertimetab = new CTable();
$filtertimetab->AddOption('width', '10%');
$filtertimetab->SetCellPadding(0);
$filtertimetab->SetCellSpacing(0);
$filtertimetab->AddRow(array(S_FROM, new CNumericBox('filter_since_day', $_REQUEST['filter_timesince'] > 0 ? date('d', $_REQUEST['filter_timesince']) : '', 2), '/', new CNumericBox('filter_since_month', $_REQUEST['filter_timesince'] > 0 ? date('m', $_REQUEST['filter_timesince']) : '', 2), '/', new CNumericBox('filter_since_year', $_REQUEST['filter_timesince'] > 0 ? date('Y', $_REQUEST['filter_timesince']) : '', 4), new CNumericBox('filter_since_hour', $_REQUEST['filter_timesince'] > 0 ? date('H', $_REQUEST['filter_timesince']) : '', 2), ':', new CNumericBox('filter_since_minute', $_REQUEST['filter_timesince'] > 0 ? date('i', $_REQUEST['filter_timesince']) : '', 2), $clndr_icon));
zbx_add_post_js('create_calendar(null,["filter_since_day","filter_since_month","filter_since_year","filter_since_hour","filter_since_minute"],"audit_since");');
$clndr_icon->AddAction('onclick', "javascript: var pos = getPosition(this); pos.top+=10; pos.left+=16; CLNDR['audit_till'].clndr.clndrshow(pos.top,pos.left);");
$filtertimetab->AddRow(array(S_TILL, new CNumericBox('filter_till_day', $_REQUEST['filter_timetill'] > 0 ? date('d', $_REQUEST['filter_timetill']) : '', 2), '/', new CNumericBox('filter_till_month', $_REQUEST['filter_timetill'] > 0 ? date('m', $_REQUEST['filter_timetill']) : '', 2), '/', new CNumericBox('filter_till_year', $_REQUEST['filter_timetill'] > 0 ? date('Y', $_REQUEST['filter_timetill']) : '', 4), new CNumericBox('filter_till_hour', $_REQUEST['filter_timetill'] > 0 ? date('H', $_REQUEST['filter_timetill']) : '', 2), ':', new CNumericBox('filter_till_minute', $_REQUEST['filter_timetill'] > 0 ? date('i', $_REQUEST['filter_timetill']) : '', 2), $clndr_icon));
zbx_add_post_js('create_calendar(null,["filter_till_day","filter_till_month","filter_till_year","filter_till_hour","filter_till_minute"],"audit_till");');
zbx_add_post_js('addListener($("filter_icon"),"click",CLNDR[\'audit_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'audit_since\'].clndr));' . 'addListener($("filter_icon"),"click",CLNDR[\'audit_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'audit_till\'].clndr));');
$row_count++;
$filterForm->addRow(S_PERIOD, $filtertimetab);
//*/
$reset = new CButton("filter_rst", S_RESET);
$reset->SetType('button');
$reset->SetAction('javascript: var uri = new Curl(location.href); uri.setArgument("filter_rst",1); location.href = uri.getUrl();');
$filterForm->AddItemToBottomRow(new CButton("filter_set", S_FILTER));
$filterForm->AddItemToBottomRow($reset);
$navigation = array(new CSpan(array('&laquo; ', $prev), 'textcolorstyles'), new CSpan(' | ', 'divider'), new CSpan(array($next, ' &raquo;'), 'textcolorstyles'));
Exemple #5
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();
}
Exemple #6
0
     $right_tab = new CTable();
     $right_tab->setCellPadding(3);
     $right_tab->setCellSpacing(3);
     $right_tab->addOption('border', 0);
     $right_tab->addRow(create_hat(S_EXPRESSIONS, get_expressions_tab(), null, 'hat_expressions', get_profile('web.config.hats.hat_expressions.state', 1)));
     if (isset($_REQUEST['new_expression'])) {
         $right_tab->addRow(create_hat(S_NEW_EXPRESSION, get_expression_form(), null, 'hat_new_expression', get_profile('web.config.hats.hat_new_expression.state', 1)));
     }
     $td_l = new CCol($left_tab);
     $td_l->AddOption('valign', 'top');
     $td_r = new CCol($right_tab);
     $td_r->AddOption('valign', 'top');
     $outer_table = new CTable();
     $outer_table->AddOption('border', 0);
     $outer_table->SetCellPadding(1);
     $outer_table->SetCellSpacing(1);
     $outer_table->AddRow(array($td_l, $td_r));
     $frmRegExp->Additem($outer_table);
     show_messages();
     $frmRegExp->Show();
 } else {
     echo SBR;
     show_table_header(S_REGULAR_EXPRESSIONS);
     // ----
     $regexps = array();
     $regexpids = array();
     $sql = 'SELECT re.* ' . ' FROM regexps re ' . ' WHERE ' . DBin_node('re.regexpid') . ' ORDER BY re.name';
     $db_regexps = DBselect($sql);
     while ($regexp = DBfetch($db_regexps)) {
         $regexp['expressions'] = array();
         $regexps[$regexp['regexpid']] = $regexp;
Exemple #7
0
     if (!isset($hosts_linked_to[$db_hostid])) {
         // add all except selected hosts
         $host_tb->addItem($db_hostid, get_node_name_by_elid($db_hostid) . $db_host['host']);
     }
 }
 // select selected hosts and add them
 $params = array('hostids' => $hosts_linked_to, 'order' => 'host', 'editable' => 1, 'extendoutput' => 1);
 $db_hosts = CHost::get($params);
 foreach ($db_hosts as $hostid => $db_host) {
     $host_tb->addItem($hostid, get_node_name_by_elid($hostid) . $db_host['host']);
 }
 $frmHost->addRow(S_HOSTS, $host_tb->Get(S_HOSTS . SPACE . S_IN, array(S_OTHER . SPACE . S_HOSTS . SPACE . '|' . SPACE . S_GROUP . SPACE, $cmbGroups)));
 // FORM ITEM : linked Template table
 $template_table = new CTable();
 $template_table->SetCellPadding(0);
 $template_table->SetCellSpacing(0);
 foreach ($templates as $tid => $tname) {
     $frmHost->addVar('templates[' . $tid . ']', $tname);
     $template_table->addRow(array($tname, new CButton('unlink[' . $tid . ']', S_UNLINK), isset($original_templates[$tid]) ? new CButton('unlink_and_clear[' . $tid . ']', 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')));
 // <<<--- FULL CLONE --->>>
 if ($_REQUEST['form'] == 'full_clone') {
     // FORM ITEM : Template items
     $items_lbx = new CListBox('items', null, 8);
     $items_lbx->setAttribute('disabled', 'disabled');
     $options = array('editable' => 1, 'hostids' => $templateid, 'extendoutput' => 1);
     $template_items = CItem::get($options);
     if (empty($template_items)) {
         $items_lbx->setAttribute('style', 'width: 200px;');
     } else {