public function parseValue($name, $value)
 {
     if (is_array($value)) {
         foreach ($value as $key => $item) {
             if (is_null($item)) {
                 continue;
             }
             $this->parseValue($name . '[' . $key . ']', $item);
         }
         return null;
     }
     if (strpos($value, "\n") === false) {
         $hiddenVar = new CInput('hidden', $name, $value, null, $this->element_id);
         $hiddenVar->removeAttribute('class');
     } else {
         $hiddenVar = new CTextArea($name, $value);
         $hiddenVar->setAttribute('class', 'hidden');
     }
     $this->var_container[] = $hiddenVar;
 }
Esempio n. 2
0
function insert_item_form()
{
    global $USER_DETAILS;
    $frmItem = new CFormTable(S_ITEM, 'items.php', 'post');
    $frmItem->setAttribute('style', 'visibility: hidden;');
    $frmItem->setHelp('web.items.item.php');
    $hostid = get_request('form_hostid', 0);
    $description = get_request('description', '');
    $key = get_request('key', '');
    $host = get_request('host', null);
    $delay = get_request('delay', 30);
    $history = get_request('history', 90);
    $status = get_request('status', 0);
    $type = get_request('type', 0);
    $snmp_community = get_request('snmp_community', 'public');
    $snmp_oid = get_request('snmp_oid', 'interfaces.ifTable.ifEntry.ifInOctets.1');
    $snmp_port = get_request('snmp_port', 161);
    $value_type = get_request('value_type', ITEM_VALUE_TYPE_UINT64);
    $data_type = get_request('data_type', ITEM_DATA_TYPE_DECIMAL);
    $trapper_hosts = get_request('trapper_hosts', '');
    $units = get_request('units', '');
    $valuemapid = get_request('valuemapid', 0);
    $params = get_request('params', '');
    $multiplier = get_request('multiplier', 0);
    $delta = get_request('delta', 0);
    $trends = get_request('trends', 365);
    $new_application = get_request('new_application', '');
    $applications = get_request('applications', array());
    $delay_flex = get_request('delay_flex', array());
    $snmpv3_securityname = get_request('snmpv3_securityname', '');
    $snmpv3_securitylevel = get_request('snmpv3_securitylevel', 0);
    $snmpv3_authpassphrase = get_request('snmpv3_authpassphrase', '');
    $snmpv3_privpassphrase = get_request('snmpv3_privpassphrase', '');
    $ipmi_sensor = get_request('ipmi_sensor', '');
    $authtype = get_request('authtype', 0);
    $username = get_request('username', '');
    $password = get_request('password', '');
    $publickey = get_request('publickey', '');
    $privatekey = get_request('privatekey', '');
    $formula = get_request('formula', '1');
    $logtimefmt = get_request('logtimefmt', '');
    $add_groupid = get_request('add_groupid', get_request('groupid', 0));
    $limited = null;
    $types = item_type2str();
    // http items only for internal processes
    unset($types[ITEM_TYPE_HTTPTEST]);
    if (isset($_REQUEST['itemid'])) {
        $frmItem->addVar('itemid', $_REQUEST['itemid']);
        $options = array('itemids' => $_REQUEST['itemid'], 'output' => API_OUTPUT_EXTEND);
        $item_data = CItem::get($options);
        $item_data = reset($item_data);
        $hostid = $hostid > 0 ? $hostid : $item_data['hostid'];
        $limited = $item_data['templateid'] == 0 && $item_data['type'] != ITEM_TYPE_HTTPTEST ? null : 'yes';
        $item_data['snmp_port'] = $item_data['snmp_port'] == '0' ? 161 : $item_data['snmp_port'];
    }
    if (is_null($host)) {
        if ($hostid > 0) {
            $options = array('hostids' => $hostid, 'output' => API_OUTPUT_EXTEND, 'templated_hosts' => 1);
            $host_info = CHost::get($options);
            $host_info = reset($host_info);
            $host = $host_info['host'];
        } else {
            $host = S_NOT_SELECTED_SMALL;
        }
    }
    if (isset($_REQUEST['itemid']) && !isset($_REQUEST['form_refresh']) || isset($limited)) {
        $description = $item_data['description'];
        $key = $item_data['key_'];
        //			$host			= $item_data['host'];
        $type = $item_data['type'];
        $snmp_community = $item_data['snmp_community'];
        $snmp_oid = $item_data['snmp_oid'];
        $snmp_port = $item_data['snmp_port'];
        $value_type = $item_data['value_type'];
        $data_type = $item_data['data_type'];
        $trapper_hosts = $item_data['trapper_hosts'];
        $units = $item_data['units'];
        $valuemapid = $item_data['valuemapid'];
        $multiplier = $item_data['multiplier'];
        $hostid = $item_data['hostid'];
        $params = $item_data['params'];
        $snmpv3_securityname = $item_data['snmpv3_securityname'];
        $snmpv3_securitylevel = $item_data['snmpv3_securitylevel'];
        $snmpv3_authpassphrase = $item_data['snmpv3_authpassphrase'];
        $snmpv3_privpassphrase = $item_data['snmpv3_privpassphrase'];
        $ipmi_sensor = $item_data['ipmi_sensor'];
        $authtype = $item_data['authtype'];
        $username = $item_data['username'];
        $password = $item_data['password'];
        $publickey = $item_data['publickey'];
        $privatekey = $item_data['privatekey'];
        $formula = $item_data['formula'];
        $logtimefmt = $item_data['logtimefmt'];
        $new_application = get_request('new_application', '');
        if (!isset($limited) || !isset($_REQUEST['form_refresh'])) {
            $delay = $item_data['delay'];
            $history = $item_data['history'];
            $status = $item_data['status'];
            $delta = $item_data['delta'];
            $trends = $item_data['trends'];
            $db_delay_flex = $item_data['delay_flex'];
            if (isset($db_delay_flex)) {
                $arr_of_dellays = explode(';', $db_delay_flex);
                foreach ($arr_of_dellays as $one_db_delay) {
                    $arr_of_delay = explode('/', $one_db_delay);
                    if (!isset($arr_of_delay[0]) || !isset($arr_of_delay[1])) {
                        continue;
                    }
                    array_push($delay_flex, array('delay' => $arr_of_delay[0], 'period' => $arr_of_delay[1]));
                }
            }
            $applications = array_unique(zbx_array_merge($applications, get_applications_by_itemid($_REQUEST['itemid'])));
        }
    }
    $securityLevelVisibility = array();
    $valueTypeVisibility = array();
    $authTypeVisibility = array();
    $typeVisibility = array();
    $delay_flex_el = array();
    //if($type != ITEM_TYPE_TRAPPER){
    $i = 0;
    foreach ($delay_flex as $val) {
        if (!isset($val['delay']) && !isset($val['period'])) {
            continue;
        }
        array_push($delay_flex_el, array(new CCheckBox('rem_delay_flex[' . $i . ']', 'no', null, $i), $val['delay'], SPACE . S_SEC_AT . SPACE, $val['period']), BR());
        $frmItem->addVar('delay_flex[' . $i . '][delay]', $val['delay']);
        $frmItem->addVar('delay_flex[' . $i . '][period]', $val['period']);
        foreach ($types as $it => $caption) {
            if ($it == ITEM_TYPE_TRAPPER || $it == ITEM_TYPE_ZABBIX_ACTIVE) {
                continue;
            }
            zbx_subarray_push($typeVisibility, $it, 'delay_flex[' . $i . '][delay]');
            zbx_subarray_push($typeVisibility, $it, 'delay_flex[' . $i . '][period]');
            zbx_subarray_push($typeVisibility, $it, 'rem_delay_flex[' . $i . ']');
        }
        $i++;
        if ($i >= 7) {
            break;
        }
        /* limit count of intervals
         * 7 intervals by 30 symbols = 210 characters
         * db storage field is 256
         */
    }
    //}
    array_push($delay_flex_el, count($delay_flex_el) == 0 ? S_NO_FLEXIBLE_INTERVALS : new CButton('del_delay_flex', S_DELETE_SELECTED));
    if (count($applications) == 0) {
        array_push($applications, 0);
    }
    if (isset($_REQUEST['itemid'])) {
        $caption = array();
        $itemid = $_REQUEST['itemid'];
        do {
            $sql = 'SELECT i.itemid, i.templateid, h.host' . ' FROM items i, hosts h' . ' WHERE i.itemid=' . $itemid . ' AND h.hostid=i.hostid';
            $itemFromDb = DBfetch(DBselect($sql));
            if ($itemFromDb) {
                if ($_REQUEST['itemid'] == $itemid) {
                    $caption[] = SPACE;
                    $caption[] = $itemFromDb['host'];
                } else {
                    $caption[] = ' : ';
                    $caption[] = new CLink($itemFromDb['host'], 'items.php?form=update&itemid=' . $itemFromDb['itemid'], 'highlight underline');
                }
                $itemid = $itemFromDb['templateid'];
            } else {
                break;
            }
        } while ($itemid != 0);
        $caption[] = S_ITEM . ' "';
        $caption = array_reverse($caption);
        $caption[] = ': ';
        $caption[] = $item_data['description'];
        $caption[] = '"';
        $frmItem->setTitle($caption);
    } else {
        $frmItem->setTitle(S_ITEM . " {$host} : {$description}");
    }
    $frmItem->addVar('form_hostid', $hostid);
    $frmItem->addRow(S_HOST, array(new CTextBox('host', $host, 32, true), new CButton('btn_host', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmItem->getName() . "&dstfld1=host&dstfld2=form_hostid&srctbl=hosts_and_templates&srcfld1=host&srcfld2=hostid',450,450);", 'H')));
    $frmItem->addRow(S_DESCRIPTION, new CTextBox('description', $description, 40, $limited));
    if (isset($limited)) {
        $frmItem->addRow(S_TYPE, new CTextBox('typename', item_type2str($type), 40, 'yes'));
        $frmItem->addVar('type', $type);
    } else {
        $cmbType = new CComboBox('type', $type);
        $cmbType->addItems($types);
        $frmItem->addRow(S_TYPE, $cmbType);
    }
    $row = new CRow(array(new CCol(S_SNMP_OID, 'form_row_l'), new CCol(new CTextBox('snmp_oid', $snmp_oid, 40, $limited), 'form_row_r')));
    $row->setAttribute('id', 'row_snmp_oid');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'snmp_oid');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'snmp_oid');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'snmp_oid');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'row_snmp_oid');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'row_snmp_oid');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'row_snmp_oid');
    $row = new CRow(array(new CCol(S_SNMP_COMMUNITY, 'form_row_l'), new CCol(new CTextBox('snmp_community', $snmp_community, 16), 'form_row_r')));
    $row->setAttribute('id', 'row_snmp_community');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'snmp_community');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'snmp_community');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'row_snmp_community');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'row_snmp_community');
    $row = new CRow(array(new CCol(S_SNMPV3_SECURITY_NAME, 'form_row_l'), new CCol(new CTextBox('snmpv3_securityname', $snmpv3_securityname, 64), 'form_row_r')));
    $row->setAttribute('id', 'row_snmpv3_securityname');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'snmpv3_securityname');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'row_snmpv3_securityname');
    $cmbSecLevel = new CComboBox('snmpv3_securitylevel', $snmpv3_securitylevel);
    $cmbSecLevel->addItem(ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV, 'noAuthNoPriv');
    $cmbSecLevel->addItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV, 'authNoPriv');
    $cmbSecLevel->addItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'authPriv');
    $row = new CRow(array(new CCol(S_SNMPV3_SECURITY_LEVEL, 'form_row_l'), new CCol($cmbSecLevel, 'form_row_r')));
    $row->setAttribute('id', 'row_snmpv3_securitylevel');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'snmpv3_securitylevel');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'row_snmpv3_securitylevel');
    $row = new CRow(array(new CCol(S_SNMPV3_AUTH_PASSPHRASE, 'form_row_l'), new CCol(new CTextBox('snmpv3_authpassphrase', $snmpv3_authpassphrase, 64), 'form_row_r')));
    $row->setAttribute('id', 'row_snmpv3_authpassphrase');
    $frmItem->addRow($row);
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV, 'snmpv3_authpassphrase');
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV, 'row_snmpv3_authpassphrase');
    $row = new CRow(array(new CCol(S_SNMPV3_PRIV_PASSPHRASE, 'form_row_l'), new CCol(new CTextBox('snmpv3_privpassphrase', $snmpv3_privpassphrase, 64), 'form_row_r')));
    $row->setAttribute('id', 'row_snmpv3_privpassphrase');
    $frmItem->addRow($row);
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'snmpv3_privpassphrase');
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'row_snmpv3_privpassphrase');
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'snmpv3_authpassphrase');
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'row_snmpv3_authpassphrase');
    $row = new CRow(array(new CCol(S_SNMP_PORT, 'form_row_l'), new CCol(new CNumericBox('snmp_port', $snmp_port, 5), 'form_row_r')));
    $row->setAttribute('id', 'row_snmp_port');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'snmp_port');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'snmp_port');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'snmp_port');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV1, 'row_snmp_port');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV2C, 'row_snmp_port');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SNMPV3, 'row_snmp_port');
    $row = new CRow(array(new CCol(S_IPMI_SENSOR, 'form_row_l'), new CCol(new CTextBox('ipmi_sensor', $ipmi_sensor, 64, $limited), 'form_row_r')));
    $row->setAttribute('id', 'row_ipmi_sensor');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_IPMI, 'ipmi_sensor');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_IPMI, 'row_ipmi_sensor');
    if (isset($limited)) {
        $btnSelect = null;
    } else {
        $btnSelect = new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmItem->getName() . "&dstfld1=key&srctbl=help_items&srcfld1=key_&itemtype=" . $type . "');", 'T');
    }
    $frmItem->addRow(S_KEY, array(new CTextBox('key', $key, 40, $limited), $btnSelect));
    foreach ($types as $it => $ilabel) {
        switch ($it) {
            case ITEM_TYPE_DB_MONITOR:
                zbx_subarray_push($typeVisibility, $it, array('id' => 'key', 'defaultValue' => 'db.odbc.select[<unique short description>]'));
                zbx_subarray_push($typeVisibility, $it, array('id' => 'params_dbmonitor', 'defaultValue' => "DSN=<database source name>\nuser=<user name>\npassword=<password>\nsql=<query>"));
                break;
            case ITEM_TYPE_SSH:
                zbx_subarray_push($typeVisibility, $it, array('id' => 'key', 'defaultValue' => 'ssh.run[<unique short description>,<ip>,<port>,<encoding>]'));
                break;
            case ITEM_TYPE_TELNET:
                zbx_subarray_push($typeVisibility, $it, array('id' => 'key', 'defaultValue' => 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]'));
                break;
            default:
                zbx_subarray_push($typeVisibility, $it, array('id' => 'key', 'defaultValue' => ''));
        }
    }
    /*
    ITEM_TYPE_DB_MONITOR $key = 'db.odbc.select[<unique short description>]'; $params = "DSN=<database source name>\nuser=<user name>\npassword=<password>\nsql=<query>";
    ITEM_TYPE_SSH $key = 'ssh.run[<unique short description>,<ip>,<port>,<encoding>]'; $params = '';
    ITEM_TYPE_TELNET $key = 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]'; $params = '';
    ITEM_TYPE_CALCULATED $key = ''; $params = '';
    //*/
    $cmbAuthType = new CComboBox('authtype', $authtype);
    $cmbAuthType->addItem(ITEM_AUTHTYPE_PASSWORD, S_PASSWORD);
    $cmbAuthType->addItem(ITEM_AUTHTYPE_PUBLICKEY, S_PUBLIC_KEY);
    $row = new CRow(array(new CCol(S_AUTHENTICATION_METHOD, 'form_row_l'), new CCol($cmbAuthType, 'form_row_r')));
    $row->setAttribute('id', 'row_authtype');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'authtype');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'row_authtype');
    $row = new CRow(array(new CCol(S_USER_NAME, 'form_row_l'), new CCol(new CTextBox('username', $username, 16), 'form_row_r')));
    $row->setAttribute('id', 'row_username');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'username');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'row_username');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'username');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'row_username');
    $row = new CRow(array(new CCol(S_PUBLIC_KEY_FILE, 'form_row_l'), new CCol(new CTextBox('publickey', $publickey, 16), 'form_row_r')));
    $row->setAttribute('id', 'row_publickey');
    $frmItem->addRow($row);
    zbx_subarray_push($authTypeVisibility, ITEM_AUTHTYPE_PUBLICKEY, 'publickey');
    zbx_subarray_push($authTypeVisibility, ITEM_AUTHTYPE_PUBLICKEY, 'row_publickey');
    $row = new CRow(array(new CCol(S_PRIVATE_KEY_FILE, 'form_row_l'), new CCol(new CTextBox('privatekey', $privatekey, 16), 'form_row_r')));
    $row->setAttribute('id', 'row_privatekey');
    $frmItem->addRow($row);
    zbx_subarray_push($authTypeVisibility, ITEM_AUTHTYPE_PUBLICKEY, 'privatekey');
    zbx_subarray_push($authTypeVisibility, ITEM_AUTHTYPE_PUBLICKEY, 'row_privatekey');
    $row = new CRow(array(new CCol(S_PASSWORD, 'form_row_l'), new CCol(new CTextBox('password', $password, 16), 'form_row_r')));
    $row->setAttribute('id', 'row_password');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'password');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'row_password');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'password');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'row_password');
    $spanEC = new CSpan(S_EXECUTED_SCRIPT);
    $spanEC->setAttribute('id', 'label_executed_script');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'label_executed_script');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'label_executed_script');
    $spanP = new CSpan(S_PARAMS);
    $spanP->setAttribute('id', 'label_params');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_DB_MONITOR, 'label_params');
    $spanF = new CSpan(S_FORMULA);
    $spanF->setAttribute('id', 'label_formula');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_CALCULATED, 'label_formula');
    $params_script = new CTextArea('params', $params, 60, 4);
    $params_script->setAttribute('id', 'params_script');
    $params_dbmonitor = new CTextArea('params', $params, 60, 4);
    $params_dbmonitor->setAttribute('id', 'params_dbmonitor');
    $params_calculted = new CTextArea('params', $params, 60, 4);
    $params_calculted->setAttribute('id', 'params_calculted');
    $row = new CRow(array(new CCol(array($spanEC, $spanP, $spanF), 'form_row_l'), new CCol(array($params_script, $params_dbmonitor, $params_calculted), 'form_row_r')));
    $row->setAttribute('id', 'row_params');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'params_script');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_SSH, 'row_params');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'params_script');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TELNET, 'row_params');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_DB_MONITOR, 'params_dbmonitor');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_DB_MONITOR, 'row_params');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_CALCULATED, 'params_calculted');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_CALCULATED, 'row_params');
    /*
    ITEM_TYPE_DB_MONITOR $key = 'db.odbc.select[<unique short description>]'; $params = "DSN=<database source name>\nuser=<user name>\npassword=<password>\nsql=<query>";
    ITEM_TYPE_SSH $key = 'ssh.run[<unique short description>,<ip>,<port>,<encoding>]'; $params = '';
    ITEM_TYPE_TELNET $key = 'telnet.run[<unique short description>,<ip>,<port>,<encoding>]'; $params = '';
    ITEM_TYPE_CALCULATED $key = ''; $params = '';
    //*/
    if (isset($limited)) {
        $frmItem->addVar('value_type', $value_type);
        $cmbValType = new CTextBox('value_type_name', item_value_type2str($value_type), 40, 'yes');
    } else {
        $cmbValType = new CComboBox('value_type', $value_type);
        $cmbValType->addItem(ITEM_VALUE_TYPE_UINT64, S_NUMERIC_UNSIGNED);
        $cmbValType->addItem(ITEM_VALUE_TYPE_FLOAT, S_NUMERIC_FLOAT);
        $cmbValType->addItem(ITEM_VALUE_TYPE_STR, S_CHARACTER);
        $cmbValType->addItem(ITEM_VALUE_TYPE_LOG, S_LOG);
        $cmbValType->addItem(ITEM_VALUE_TYPE_TEXT, S_TEXT);
    }
    $frmItem->addRow(S_TYPE_OF_INFORMATION, $cmbValType);
    if (isset($limited)) {
        $frmItem->addVar('data_type', $data_type);
        $cmbDataType = new CTextBox('data_type_name', item_data_type2str($data_type), 20, 'yes');
    } else {
        $cmbDataType = new CComboBox('data_type', $data_type);
        $cmbDataType->addItem(ITEM_DATA_TYPE_DECIMAL, item_data_type2str(ITEM_DATA_TYPE_DECIMAL));
        $cmbDataType->addItem(ITEM_DATA_TYPE_OCTAL, item_data_type2str(ITEM_DATA_TYPE_OCTAL));
        $cmbDataType->addItem(ITEM_DATA_TYPE_HEXADECIMAL, item_data_type2str(ITEM_DATA_TYPE_HEXADECIMAL));
    }
    $row = new CRow(array(new CCol(S_DATA_TYPE, 'form_row_l'), new CCol($cmbDataType, 'form_row_r')));
    $row->setAttribute('id', 'row_data_type');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'data_type');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_data_type');
    $row = new CRow(array(new CCol(S_UNITS, 'form_row_l'), new CCol(new CTextBox('units', $units, 40, $limited), 'form_row_r')));
    $row->setAttribute('id', 'row_units');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'units');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'row_units');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'units');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_units');
    $mltpbox = array();
    if (isset($limited)) {
        $frmItem->addVar('multiplier', $multiplier);
        $mcb = new CCheckBox('multiplier', $multiplier == 1 ? 'yes' : 'no');
        $mcb->setAttribute('disabled', 'disabled');
        $mltpbox[] = $mcb;
        if ($multiplier) {
            $mltpbox[] = SPACE;
            $ctb = new CTextBox('formula', $formula, 10, 1);
            $ctb->setAttribute('style', 'text-align: right;');
            $mltpbox[] = $ctb;
        } else {
            $frmItem->addVar('formula', $formula);
        }
    } else {
        $mltpbox[] = new CCheckBox('multiplier', $multiplier == 1 ? 'yes' : 'no', 'var editbx = document.getElementById(\'formula\'); if(editbx) editbx.disabled = !this.checked;', 1);
        $mltpbox[] = SPACE;
        $ctb = new CTextBox('formula', $formula, 10);
        $ctb->setAttribute('style', 'text-align: right;');
        $mltpbox[] = $ctb;
    }
    $row = new CRow(array(new CCol(S_USE_CUSTOM_MULTIPLIER, 'form_row_l'), new CCol($mltpbox, 'form_row_r')));
    $row->setAttribute('id', 'row_multiplier');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'multiplier');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'row_multiplier');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'multiplier');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_multiplier');
    $row = new CRow(array(new CCol(S_UPDATE_INTERVAL_IN_SEC, 'form_row_l'), new CCol(new CNumericBox('delay', $delay, 5), 'form_row_r')));
    $row->setAttribute('id', 'row_delay');
    $frmItem->addRow($row);
    foreach ($types as $it => $ilabel) {
        if ($it == ITEM_TYPE_TRAPPER) {
            continue;
        }
        zbx_subarray_push($typeVisibility, $it, 'delay');
        zbx_subarray_push($typeVisibility, $it, 'row_delay');
    }
    $row = new CRow(array(new CCol(S_FLEXIBLE_INTERVALS, 'form_row_l'), new CCol($delay_flex_el, 'form_row_r')));
    $row->setAttribute('id', 'row_flex_intervals');
    $frmItem->addRow($row);
    $row = new CRow(array(new CCol(S_NEW_FLEXIBLE_INTERVAL, 'form_row_l'), new CCol(array(S_DELAY, SPACE, new CNumericBox('new_delay_flex[delay]', '50', 5), S_PERIOD, SPACE, new CTextBox('new_delay_flex[period]', '1-7,00:00-23:59', 27), BR(), new CButton('add_delay_flex', S_ADD)), 'form_row_r')), 'new');
    $row->setAttribute('id', 'row_new_delay_flex');
    $frmItem->addRow($row);
    foreach ($types as $it => $ilabel) {
        if ($it == ITEM_TYPE_TRAPPER || $it == ITEM_TYPE_ZABBIX_ACTIVE) {
            continue;
        }
        zbx_subarray_push($typeVisibility, $it, 'row_flex_intervals');
        zbx_subarray_push($typeVisibility, $it, 'row_new_delay_flex');
        zbx_subarray_push($typeVisibility, $it, 'new_delay_flex[delay]');
        zbx_subarray_push($typeVisibility, $it, 'new_delay_flex[period]');
        zbx_subarray_push($typeVisibility, $it, 'add_delay_flex');
    }
    $frmItem->addRow(S_KEEP_HISTORY_IN_DAYS, array(new CNumericBox('history', $history, 8), !isset($_REQUEST['itemid']) ? null : new CButtonQMessage('del_history', S_CLEAR_HISTORY, S_HISTORY_CLEARING_CAN_TAKE_A_LONG_TIME_CONTINUE_Q)));
    $row = new CRow(array(new CCol(S_KEEP_TRENDS_IN_DAYS, 'form_row_l'), new CCol(new CNumericBox('trends', $trends, 8), 'form_row_r')));
    $row->setAttribute('id', 'row_trends');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'trends');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'row_trends');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'trends');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_trends');
    $cmbStatus = new CComboBox('status', $status);
    foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED, ITEM_STATUS_NOTSUPPORTED) as $st) {
        $cmbStatus->addItem($st, item_status2str($st));
    }
    $frmItem->addRow(S_STATUS, $cmbStatus);
    $row = new CRow(array(new CCol(S_LOG_TIME_FORMAT, 'form_row_l'), new CCol(new CTextBox('logtimefmt', $logtimefmt, 16, $limited), 'form_row_r')));
    $row->setAttribute('id', 'row_logtimefmt');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_LOG, 'logtimefmt');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_LOG, 'row_logtimefmt');
    $cmbDelta = new CComboBox('delta', $delta);
    $cmbDelta->addItem(0, S_AS_IS);
    $cmbDelta->addItem(1, S_DELTA_SPEED_PER_SECOND);
    $cmbDelta->addItem(2, S_DELTA_SIMPLE_CHANGE);
    $row = new CRow(array(new CCol(S_STORE_VALUE, 'form_row_l'), new CCol($cmbDelta, 'form_row_r')));
    $row->setAttribute('id', 'row_delta');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'delta');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'row_delta');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'delta');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_delta');
    if (isset($limited)) {
        $frmItem->addVar('valuemapid', $valuemapid);
        $map_name = S_AS_IS;
        if ($map_data = DBfetch(DBselect('SELECT name FROM valuemaps WHERE valuemapid=' . $valuemapid))) {
            $map_name = $map_data['name'];
        }
        $cmbMap = new CTextBox('valuemap_name', $map_name, 20, 'yes');
    } else {
        $cmbMap = new CComboBox('valuemapid', $valuemapid);
        $cmbMap->addItem(0, S_AS_IS);
        $db_valuemaps = DBselect('SELECT * FROM valuemaps WHERE ' . DBin_node('valuemapid'));
        while ($db_valuemap = DBfetch($db_valuemaps)) {
            $cmbMap->addItem($db_valuemap['valuemapid'], get_node_name_by_elid($db_valuemap['valuemapid'], null, ': ') . $db_valuemap['name']);
        }
    }
    $link = new CLink(S_SHOW_VALUE_MAPPINGS, 'config.php?config=6');
    $link->setAttribute('target', '_blank');
    $row = new CRow(array(new CCol(S_SHOW_VALUE), new CCol(array($cmbMap, SPACE, $link))));
    $row->setAttribute('id', 'row_valuemap');
    $frmItem->addRow($row);
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'valuemapid');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'row_valuemap');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_FLOAT, 'valuemap_name');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'valuemapid');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'row_valuemap');
    zbx_subarray_push($valueTypeVisibility, ITEM_VALUE_TYPE_UINT64, 'valuemap_name');
    $row = new CRow(array(new CCol(S_ALLOWED_HOSTS, 'form_row_l'), new CCol(new CTextBox('trapper_hosts', $trapper_hosts, 40), 'form_row_r')));
    $row->setAttribute('id', 'row_trapper_hosts');
    $frmItem->addRow($row);
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TRAPPER, 'trapper_hosts');
    zbx_subarray_push($typeVisibility, ITEM_TYPE_TRAPPER, 'row_trapper_hosts');
    $new_app = new CTextBox('new_application', $new_application, 40);
    $frmItem->addRow(S_NEW_APPLICATION, $new_app, 'new');
    $cmbApps = new CListBox('applications[]', $applications, 6);
    $cmbApps->addItem(0, '-' . S_NONE . '-');
    $sql = 'SELECT DISTINCT applicationid,name ' . ' FROM applications ' . ' WHERE hostid=' . $hostid . ' ORDER BY name';
    $db_applications = DBselect($sql);
    while ($db_app = DBfetch($db_applications)) {
        $cmbApps->addItem($db_app['applicationid'], $db_app['name']);
    }
    $frmItem->addRow(S_APPLICATIONS, $cmbApps);
    $frmRow = array(new CButton('save', S_SAVE));
    if (isset($_REQUEST['itemid'])) {
        array_push($frmRow, SPACE, new CButton('clone', S_CLONE));
        if (!isset($limited)) {
            array_push($frmRow, SPACE, new CButtonDelete(S_DELETE_SELECTED_ITEM_Q, url_param('form') . url_param('groupid') . url_param('itemid')));
        }
    }
    array_push($frmRow, SPACE, new CButtonCancel(url_param('groupid')));
    $frmItem->addSpanRow($frmRow, 'form_row_last');
    // GROUP OPERATIONS
    $cmbGroups = new CComboBox('add_groupid', $add_groupid);
    $groups = CHostGroup::get(array('editable' => 1, 'output' => API_OUTPUT_EXTEND));
    order_result($groups, 'name');
    foreach ($groups as $group) {
        $cmbGroups->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']);
    }
    $frmItem->addRow(S_GROUP, $cmbGroups);
    $cmbAction = new CComboBox('action');
    $cmbAction->addItem('add to group', S_ADD_TO_GROUP);
    if (isset($_REQUEST['itemid'])) {
        $cmbAction->addItem('update in group', S_UPDATE_IN_GROUP);
        $cmbAction->addItem('delete FROM group', S_DELETE_FROM_GROUP);
    }
    $frmItem->addItemToBottomRow(array($cmbAction, SPACE, new CButton('register', S_DO)));
    $json = new CJSON();
    zbx_add_post_js("var valueTypeSwitcher = new CViewSwitcher('value_type', 'change', " . zbx_jsvalue($valueTypeVisibility, true) . ");");
    zbx_add_post_js("var authTypeSwitcher = new CViewSwitcher('authtype', 'change', " . zbx_jsvalue($authTypeVisibility, true) . ");");
    zbx_add_post_js("var typeSwitcher = new CViewSwitcher('type', 'change', " . zbx_jsvalue($typeVisibility, true) . (isset($_REQUEST['itemid']) ? ', true' : '') . ');');
    zbx_add_post_js("var securityLevelSwitcher = new CViewSwitcher('snmpv3_securitylevel', 'change', " . zbx_jsvalue($securityLevelVisibility, true) . ");");
    zbx_add_post_js("var multpStat = document.getElementById('multiplier'); if(multpStat && multpStat.onclick) multpStat.onclick();");
    zbx_add_post_js("var mnFrmTbl = document.getElementById('web.items.item.php'); if(mnFrmTbl) mnFrmTbl.style.visibility = 'visible';");
    return $frmItem;
}