$agentComboBox = new CComboBox('agent', $this->data['agent']);
$userAgentsAll = userAgents();
$userAgentsAll[_('Others')][ZBX_AGENT_OTHER] = _('other') . ' ...';
foreach ($userAgentsAll as $userAgentGroup => $userAgents) {
    $agentComboBox->addItemsInGroup($userAgentGroup, $userAgents);
}
$httpFormList->addRow(_('Agent'), $agentComboBox);
$httpFormList->addRow(_('User agent string'), (new CTextBox('agent_other', $this->data['agent_other']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH), 'row_agent_other');
// append HTTP proxy to form list
$httpFormList->addRow(_('HTTP proxy'), (new CTextBox('http_proxy', $this->data['http_proxy'], false, 255))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('placeholder', 'http://[user[:password]@]proxy.example.com[:port]'))->addRow(_('Variables'), (new CTextArea('variables', $this->data['variables']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('Headers'), (new CTextArea('headers', $this->data['headers']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('Enabled'), (new CCheckBox('status'))->setChecked(!$this->data['status']));
/*
 * Authentication tab
 */
$httpAuthenticationFormList = new CFormList('httpAuthenticationFormList');
// Authentication type
$httpAuthenticationFormList->addRow(_('HTTP authentication'), new CComboBox('authentication', $this->data['authentication'], null, httptest_authentications()));
$httpAuthenticationFormList->addRow(_('User'), (new CTextBox('http_user', $this->data['http_user'], false, 64))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('Password'), (new CTextBox('http_password', $this->data['http_password'], false, 64))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('SSL verify peer'), (new CCheckBox('verify_peer'))->setChecked($this->data['verify_peer'] == 1))->addRow(_('SSL verify host'), (new CCheckBox('verify_host'))->setChecked($this->data['verify_host'] == 1))->addRow(_('SSL certificate file'), (new CTextBox('ssl_cert_file', $this->data['ssl_cert_file'], false, 255))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('SSL key file'), (new CTextBox('ssl_key_file', $this->data['ssl_key_file'], false, 255))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH))->addRow(_('SSL key password'), (new CTextBox('ssl_key_password', $this->data['ssl_key_password'], false, 64))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH));
/*
 * Step tab
 */
$httpStepFormList = new CFormList('httpFormList');
$stepsTable = (new CTable())->setId('httpStepTable')->setHeader([(new CColHeader())->setWidth('15'), (new CColHeader())->setWidth('15'), (new CColHeader(_('Name')))->setWidth('150'), (new CColHeader(_('Timeout')))->setWidth('50'), (new CColHeader(_('URL')))->setWidth('200'), (new CColHeader(_('Required')))->setWidth('75'), (new CColHeader(_('Status codes')))->addClass(ZBX_STYLE_NOWRAP)->setWidth('90'), (new CColHeader(_('Action')))->setWidth('50')]);
$i = 1;
foreach ($this->data['steps'] as $stepid => $step) {
    if (!isset($step['name'])) {
        $step['name'] = '';
    }
    if (!isset($step['timeout'])) {
        $step['timeout'] = 15;
    }
    if (!isset($step['url'])) {
if (!$this->data['templated']) {
    $nameTextBox->attr('autofocus', 'autofocus');
}
$httpFormList->addRow(_('Name'), $nameTextBox);
// Application
if ($this->data['application_list']) {
    $applications = zbx_array_merge(array(''), $this->data['application_list']);
    $httpFormList->addRow(_('Application'), new CComboBox('applicationid', $this->data['applicationid'], null, $applications));
} else {
    $httpFormList->addRow(_('Application'), new CSpan(_('No applications found.')));
}
// New application
$httpFormList->addRow(_('New application'), new CTextBox('new_application', $this->data['new_application'], ZBX_TEXTBOX_STANDARD_SIZE), false, null, 'new');
// Authentication
$authenticationComboBox = new CComboBox('authentication', $this->data['authentication'], 'submit();');
$authenticationComboBox->addItems(httptest_authentications());
$httpFormList->addRow(_('Authentication'), $authenticationComboBox);
if (in_array($this->data['authentication'], array(HTTPTEST_AUTH_BASIC, HTTPTEST_AUTH_NTLM))) {
    $httpFormList->addRow(_('User'), new CTextBox('http_user', $this->data['http_user'], ZBX_TEXTBOX_STANDARD_SIZE, 'no', 64));
    $httpFormList->addRow(_('Password'), new CTextBox('http_password', $this->data['http_password'], ZBX_TEXTBOX_STANDARD_SIZE, 'no', 64));
}
// update interval
$httpFormList->addRow(_('Update interval (in sec)'), new CNumericBox('delay', $this->data['delay'], 5));
// number of retries
$httpFormList->addRow(_('Retries'), new CNumericBox('retries', $this->data['retries'], 2));
// append http agents to form list - http://www.useragentstring.com
$agentComboBox = new CEditableComboBox('agent', $this->data['agent'], ZBX_TEXTBOX_STANDARD_SIZE);
$agentComboBox->addItemsInGroup(_('Internet Explorer'), array('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)' => 'Internet Explorer 10.0', 'Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)' => 'Internet Explorer 9.0', 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)' => 'Internet Explorer 8.0', 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)' => 'Internet Explorer 7.0', 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1)' => 'Internet Explorer 6.0'));
$agentComboBox->addItemsInGroup(_('Mozilla Firefox'), array('Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0' => 'Mozilla Firefox 8.0', 'Mozilla/5.0 (X11; Linux i686; rv:7.0) Gecko/20100101 Firefox/7.0' => 'Mozilla Firefox 7.0', 'Mozilla/5.0 (X11; Linux i686; rv:6.0) Gecko/20100101 Firefox/6.0' => 'Mozilla Firefox 6.0', 'Mozilla/5.0 (X11; U; Linux i586; de; rv:5.0) Gecko/20100101 Firefox/5.0' => 'Mozilla Firefox 5.0', 'Mozilla/5.0 (X11; U; Linux x86_64; pl-PL; rv:2.0) Gecko/20110307 Firefox/4.0' => 'Mozilla Firefox 4.0', 'Mozilla/6.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:2.0.0.0) Gecko/20061028 Firefox/3.0' => 'Mozilla Firefox 3.0', 'Mozilla/5.0 (X11;U;Linux i686;en-US;rv:1.8.1) Gecko/2006101022 Firefox/2.0' => 'Mozilla Firefox 2.0'));
$agentComboBox->addItemsInGroup(_('Opera'), array('Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00' => 'Opera 12.00', 'Opera/9.80 (X11; Linux x86_64; U; pl) Presto/2.7.62 Version/11.00' => 'Opera 11.00', 'Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.2.15 Version/10.00' => 'Opera 10.00', 'Opera/9.00 (X11; Linux i686; U; pl)' => 'Opera 9.00'));
$agentComboBox->addItemsInGroup(_('Safari'), array('Mozilla/5.0 (X11; U; Linux x86_64; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/531.2+' => 'Safari 5.0', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; ru-RU) AppleWebKit/528.16 (KHTML, like Gecko) Version/4.0 Safari/528.16' => 'Safari 4.0', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; sv-SE) AppleWebKit/523.13 (KHTML, like Gecko) Version/3.0 Safari/523.13' => 'Safari 3.0', 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_1 like Mac OS X; fr-fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Mobile/5F136' => 'Safari on iPhone'));
$httpTable = (new CTableInfo())->setHeader([(new CColHeader((new CCheckBox('all_httptests'))->onClick("checkAll('" . $httpForm->getName() . "', 'all_httptests', 'group_httptestid');")))->addClass(ZBX_STYLE_CELL_WIDTH), $this->data['hostid'] == 0 ? make_sorting_header(_('Host'), 'hostname', $this->data['sort'], $this->data['sortorder']) : null, make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Number of steps'), _('Update interval'), _('Attempts'), _('Authentication'), _('HTTP proxy'), _('Application'), make_sorting_header(_('Status'), 'status', $this->data['sort'], $this->data['sortorder']), $this->data['showInfoColumn'] ? _('Info') : null]);
$httpTestsLastData = $this->data['httpTestsLastData'];
$httpTests = $this->data['httpTests'];
foreach ($httpTests as $httpTestId => $httpTest) {
    $name = [];
    if (isset($this->data['parentTemplates'][$httpTestId])) {
        $template = $this->data['parentTemplates'][$httpTestId];
        $name[] = (new CLink($template['name'], '?groupid=0&hostid=' . $template['id']))->addClass(ZBX_STYLE_LINK_ALT)->addClass(ZBX_STYLE_GREY);
        $name[] = NAME_DELIMITER;
    }
    $name[] = new CLink($httpTest['name'], '?form=update' . '&httptestid=' . $httpTestId . '&hostid=' . $httpTest['hostid']);
    if ($this->data['showInfoColumn']) {
        if ($httpTest['status'] == HTTPTEST_STATUS_ACTIVE && isset($httpTestsLastData[$httpTestId]) && $httpTestsLastData[$httpTestId]['lastfailedstep']) {
            $lastData = $httpTestsLastData[$httpTestId];
            $failedStep = $lastData['failedstep'];
            $errorMessage = $failedStep ? _s('Step "%1$s" [%2$s of %3$s] failed: %4$s', $failedStep['name'], $failedStep['no'], $httpTest['stepscnt'], $lastData['error'] === null ? _('Unknown error') : $lastData['error']) : _s('Unknown step failed: %1$s', $lastData['error']);
            $infoIcon = makeErrorIcon($errorMessage);
        } else {
            $infoIcon = '';
        }
    } else {
        $infoIcon = null;
    }
    $httpTable->addRow([new CCheckBox('group_httptestid[' . $httpTest['httptestid'] . ']', $httpTest['httptestid']), $this->data['hostid'] > 0 ? null : $httpTest['hostname'], $name, $httpTest['stepscnt'], convertUnitsS($httpTest['delay']), $httpTest['retries'], httptest_authentications($httpTest['authentication']), $httpTest['http_proxy'] !== '' ? _('Yes') : _('No'), $httpTest['applicationid'] != 0 ? $httpTest['application_name'] : '', (new CLink(httptest_status2str($httpTest['status']), '?group_httptestid[]=' . $httpTest['httptestid'] . '&hostid=' . $httpTest['hostid'] . '&action=' . ($httpTest['status'] == HTTPTEST_STATUS_DISABLED ? 'httptest.massenable' : 'httptest.massdisable')))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(httptest_status2style($httpTest['status']))->addSID(), $infoIcon]);
}
zbx_add_post_js('cookie.prefix = "' . $this->data['hostid'] . '";');
// append table to form
$httpForm->addItem([$httpTable, $this->data['paging'], new CActionButtonList('action', 'group_httptestid', ['httptest.massenable' => ['name' => _('Enable'), 'confirm' => _('Enable selected web scenarios?')], 'httptest.massdisable' => ['name' => _('Disable'), 'confirm' => _('Disable selected web scenarios?')], 'httptest.massclearhistory' => ['name' => _('Clear history'), 'confirm' => _('Delete history of selected web scenarios?')], 'httptest.massdelete' => ['name' => _('Delete'), 'confirm' => _('Delete selected web scenarios?')]], $this->data['hostid'])]);
// append form to widget
$widget->addItem($httpForm);
return $widget;
    }
    $name[] = new CLink($httpTest['name'], '?form=update' . '&httptestid=' . $httpTestId . '&hostid=' . $httpTest['hostid']);
    if ($this->data['showInfoColumn']) {
        if ($httpTest['status'] == HTTPTEST_STATUS_ACTIVE && isset($httpTestsLastData[$httpTestId]) && $httpTestsLastData[$httpTestId]['lastfailedstep']) {
            $lastData = $httpTestsLastData[$httpTestId];
            $failedStep = $lastData['failedstep'];
            $errorMessage = $failedStep ? _s('Step "%1$s" [%2$s of %3$s] failed: %4$s', $failedStep['name'], $failedStep['no'], $httpTest['stepscnt'], $lastData['error'] === null ? _('Unknown error') : $lastData['error']) : _s('Unknown step failed: %1$s', $lastData['error']);
            $infoIcon = new CDiv(SPACE, 'status_icon iconerror');
            $infoIcon->setHint($errorMessage, 'on');
        } else {
            $infoIcon = '';
        }
    } else {
        $infoIcon = null;
    }
    $httpTable->addRow(array(new CCheckBox('group_httptestid[' . $httpTest['httptestid'] . ']', null, null, $httpTest['httptestid']), $this->data['hostid'] > 0 ? null : $httpTest['hostname'], $name, $httpTest['stepscnt'], $httpTest['delay'], $httpTest['retries'], httptest_authentications($httpTest['authentication']), $httpTest['http_proxy'] !== '' ? _('Yes') : _('No'), $httpTest['applicationid'] != 0 ? $httpTest['application_name'] : '-', new CLink(httptest_status2str($httpTest['status']), '?group_httptestid[]=' . $httpTest['httptestid'] . '&hostid=' . $httpTest['hostid'] . '&action=' . ($httpTest['status'] == HTTPTEST_STATUS_DISABLED ? 'httptest.massenable' : 'httptest.massdisable'), httptest_status2style($httpTest['status'])), $infoIcon));
}
// create go buttons
$goComboBox = new CComboBox('action');
$goOption = new CComboItem('httptest.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected web scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('httptest.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected web scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('httptest.massclearhistory', _('Clear history for selected'));
$goOption->setAttribute('confirm', _('Delete history of selected web scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('httptest.massdelete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected web scenarios?'));
$goComboBox->addItem($goOption);
Esempio n. 5
0
     $status = $httptest_data['status'];
     $agent = $httptest_data['agent'];
     $macros = $httptest_data['macros'];
     $authentication = $httptest_data['authentication'];
     $http_user = $httptest_data['http_user'];
     $http_password = $httptest_data['http_password'];
     $steps = array();
     $db_steps = DBselect('SELECT * FROM httpstep WHERE httptestid=' . $_REQUEST["httptestid"] . ' ORDER BY no');
     while ($step_data = DBfetch($db_steps)) {
         $steps[] = $step_data;
     }
 }
 $form->addRow(S_APPLICATION, array(new CTextBox('application', $application, 40), SPACE, new CButton('select_app', S_SELECT, 'return PopUp("popup.php?dstfrm=' . $form->getName() . '&dstfld1=application&srctbl=applications' . '&srcfld1=name&only_hostid=' . $_REQUEST['hostid'] . '",500,600,"application");')));
 $form->addRow(S_NAME, new CTextBox('name', $name, 40));
 $cmbAuth = new CComboBox('authentication', $authentication, 'submit();');
 $cmbAuth->addItems(httptest_authentications());
 $form->addRow(S_AUTHENTICATION, $cmbAuth);
 if (in_array($authentication, array(HTTPTEST_AUTH_BASIC, HTTPTEST_AUTH_NTLM))) {
     $form->addRow(S_USER, new CTextBox('http_user', $http_user, 32));
     $form->addRow(S_PASSWORD, new CTextBox('http_password', $http_password, 40));
 }
 $form->addRow(S_UPDATE_INTERVAL_IN_SEC, new CNumericBox('delay', $delay, 5));
 $cmbAgent = new CEditableComboBox('agent', $agent, 80);
 // IE6
 $cmbAgent->addItem('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)', 'Internet Explorer 6.0 on Windows XP SP2 with .NET Framework 2.0 installed');
 // IE7
 $cmbAgent->addItem('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)', 'Internet Explorer 7.0 on Windows XP SP3 with .NET Framework 3.5 installed');
 // FF 1.5
 $cmbAgent->addItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7', 'Mozilla Firefox 1.5.0.7 on Windows XP');
 $cmbAgent->addItem('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7', 'Mozilla Firefox 1.5.0.7 on Linux');
 // FF 2.0