Example #1
0
function insert_httptest_form()
{
    $form = new CFormTable(S_SCENARIO, null, 'post');
    $form->SetHelp("web.webmon.httpconf.php");
    if ($_REQUEST['groupid'] > 0) {
        $form->addVar('groupid', $_REQUEST['groupid']);
    }
    $form->addVar('hostid', $_REQUEST['hostid']);
    if (isset($_REQUEST["httptestid"])) {
        $form->addVar("httptestid", $_REQUEST["httptestid"]);
    }
    $name = get_request('name', '');
    $application = get_request('application', '');
    $delay = get_request('delay', 60);
    $status = get_request('status', HTTPTEST_STATUS_ACTIVE);
    $agent = get_request('agent', '');
    $macros = get_request('macros', array());
    $steps = get_request('steps', array());
    if (isset($_REQUEST["httptestid"]) && !isset($_REQUEST["form_refresh"]) || isset($limited)) {
        $httptest_data = DBfetch(DBselect("SELECT wt.*, a.name as application " . " FROM httptest wt,applications a WHERE wt.httptestid=" . $_REQUEST["httptestid"] . " AND a.applicationid=wt.applicationid"));
        $name = $httptest_data['name'];
        $application = $httptest_data['application'];
        $delay = $httptest_data['delay'];
        $status = $httptest_data['status'];
        $agent = $httptest_data['agent'];
        $macros = $httptest_data['macros'];
        $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'] . '",200,300,"application");')));
    $form->addRow(S_NAME, new CTextBox('name', $name, 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
    $cmbAgent->addItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.18) Gecko/20081029 Firefox/2.0.0.18', 'Mozilla Firefox 2.0.0.18 on Windows XP');
    $cmbAgent->addItem('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.18) Gecko/20081029 Firefox/2.0.0.18', 'Mozilla Firefox 2.0.0.18 on Linux');
    // FF 3.0
    $cmbAgent->addItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1', 'Mozilla Firefox 3.0.1 on Windows XP');
    $cmbAgent->addItem('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1', 'Mozilla Firefox 3.0.1 on Linux');
    // OP 9.0
    $cmbAgent->addItem('Opera/9.02 (Windows NT 5.1; U; en)', 'Opera 9.02 on Windows XP');
    $cmbAgent->addItem('Opera/9.02 (X11; Linux i686; U; en)', 'Opera 9.02 on Linux');
    // OP 9.6
    $cmbAgent->addItem('Opera/9.61 (Windows NT 5.1; U; en) Presto/2.1.1', 'Opera 9.61 on Windows XP');
    $cmbAgent->addItem('Opera/9.61 (X11; Linux i686; U; en) Presto/2.1.1', 'Opera 9.61 on Linux');
    // SF 3.1
    $cmbAgent->addItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Version/3.1.2 Safari/525.21', 'Safari 3.1.2 on Windows XP');
    $cmbAgent->addItem('Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/527.2+ (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1', 'Safari 3.1.2 on Intel Mac OS X 10.5.4');
    $cmbAgent->addItem('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');
    $cmbAgent->addItem('Lynx/2.8.4rel.1 libwww-FM/2.14', 'Lynx 2.8.4rel.1 on Linux');
    $cmbAgent->addItem('Googlebot/2.1 (+http://www.google.com/bot.html)', 'Googlebot');
    $form->addRow(S_AGENT, $cmbAgent);
    $cmbStatus = new CComboBox("status", $status);
    foreach (array(HTTPTEST_STATUS_ACTIVE, HTTPTEST_STATUS_DISABLED) as $st) {
        $cmbStatus->addItem($st, httptest_status2str($st));
    }
    $form->addRow(S_STATUS, $cmbStatus);
    $form->addRow(S_VARIABLES, new CTextArea('macros', $macros, 84, 5));
    $tblSteps = new CTableInfo();
    $tblSteps->SetHeader(array(S_NAME, S_TIMEOUT, S_URL, S_REQUIRED, S_STATUS, SPACE));
    if (count($steps) > 0) {
        $first = min(array_keys($steps));
        $last = max(array_keys($steps));
    }
    foreach ($steps as $stepid => $s) {
        if (!isset($s['name'])) {
            $s['name'] = '';
        }
        if (!isset($s['timeout'])) {
            $s['timeout'] = 15;
        }
        if (!isset($s['url'])) {
            $s['url'] = '';
        }
        if (!isset($s['posts'])) {
            $s['posts'] = '';
        }
        if (!isset($s['required'])) {
            $s['required'] = '';
        }
        $up = null;
        if ($stepid != $first) {
            $up = new CLink(S_UP, '#', 'action');
            $up->OnClick("return create_var('" . $form->GetName() . "','move_up'," . $stepid . ", true);");
        }
        $down = null;
        if ($stepid != $last) {
            $down = new CLink(S_DOWN, '#', 'action');
            $down->OnClick("return create_var('" . $form->GetName() . "','move_down'," . $stepid . ", true);");
        }
        $name = new CLink($s['name'], '#', 'action');
        $name->OnClick('return PopUp("popup_httpstep.php?dstfrm=' . $form->GetName() . '&list_name=steps&stepid=' . $stepid . url_param($s['name'], false, 'name') . url_param($s['timeout'], false, 'timeout') . url_param($s['url'], false, 'url') . url_param($s['posts'], false, 'posts') . url_param($s['required'], false, 'required') . url_param($s['status_codes'], false, 'status_codes') . '");');
        if (strlen($s['url']) > 70) {
            $url = new CTag('span', 'yes', substr($s['url'], 0, 35) . SPACE . '...' . SPACE . substr($s['url'], strlen($s['url']) - 25, 25));
            $url->SetHint($s['url']);
        } else {
            $url = $s['url'];
        }
        $tblSteps->addRow(array(array(new CCheckBox('sel_step[]', null, null, $stepid), $name), $s['timeout'] . SPACE . S_SEC_SMALL, $url, $s['required'], $s['status_codes'], array($up, isset($up) && isset($down) ? SPACE : null, $down)));
    }
    $form->addVar('steps', $steps);
    $form->addRow(S_STEPS, array(count($steps) > 0 ? array($tblSteps, BR()) : null, new CButton('add_step', S_ADD, 'return PopUp("popup_httpstep.php?dstfrm=' . $form->GetName() . '");'), count($steps) > 0 ? new CButton('del_sel_step', S_DELETE_SELECTED) : null));
    $form->addItemToBottomRow(new CButton("save", S_SAVE));
    if (isset($_REQUEST["httptestid"])) {
        $form->addItemToBottomRow(SPACE);
        $form->addItemToBottomRow(new CButton("clone", S_CLONE));
        $form->addItemToBottomRow(SPACE);
        $form->addItemToBottomRow(new CButtonDelete(S_DELETE_SCENARIO_Q, url_param("form") . url_param("httptestid") . url_param('hostid')));
    }
    $form->addItemToBottomRow(SPACE);
    $form->addItemToBottomRow(new CButtonCancel());
    $form->Show();
}
// 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'));
$agentComboBox->addItemsInGroup(_('Google Chrome'), array('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.8 (KHTML, like Gecko) Chrome/17.0.940.0 Safari/535.8' => 'Google Chrome 17', 'Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.36 Safari/535.7' => 'Google Chrome 16', 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.872.0 Safari/535.2' => 'Google Chrome 15', 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Ubuntu/11.04 Chromium/14.0.825.0 Chrome/14.0.825.0 Safari/535.1' => 'Google Chrome 14', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_3) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.32 Safari/535.1' => 'Google Chrome 13', 'Mozilla/5.0 (Windows NT 6.1; en-US) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.750.0 Safari/534.30' => 'Google Chrome 12'));
$agentComboBox->addItemsInGroup(_('Others'), array('Mozilla/5.0 (X11; Linux 3.1.0-rc9+; en_US) KHTML/4.7.2 (like Gecko) Konqueror/4.7' => 'Konqueror 4.7', 'Mozilla/5.0 (compatible; Konqueror/4.6; Linux) KHTML/4.6.0 (like Gecko)' => 'Konqueror 4.6', 'Lynx/2.8.7rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.8r' => 'Lynx 2.8.7rel.1', 'Lynx/2.8.4rel.1 libwww-FM/2.14' => 'Lynx 2.8.4rel.1', 'Links (2.3pre1; Linux 2.6.35.10 i686; 225x51)' => 'Links 2.3pre1', 'Links (2.2; Linux 2.6.37.6-0.7-desktop i686; 225x51)' => 'Links 2.2', 'Googlebot/2.1 (+http://www.google.com/bot.html)' => 'Googlebot'));
$httpFormList->addRow(_('Agent'), $agentComboBox);
// append HTTP proxy to form list
$httpProxyTextBox = new CTextBox('http_proxy', $this->data['http_proxy'], ZBX_TEXTBOX_STANDARD_SIZE, 'no', 255);
$httpProxyTextBox->setAttribute('placeholder', 'http://[username[:password]@]proxy.example.com[:port]');
$httpFormList->addRow(_('HTTP proxy'), $httpProxyTextBox);
// append status to form list
$httpFormList->addRow(_('Variables'), new CTextArea('variables', $this->data['variables']));
$httpFormList->addRow(_('Enabled'), new CCheckBox('status', !$this->data['status']));
/*
Example #3
0
     $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
 $cmbAgent->addItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.18) Gecko/20081029 Firefox/2.0.0.18', 'Mozilla Firefox 2.0.0.18 on Windows XP');
 $cmbAgent->addItem('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.18) Gecko/20081029 Firefox/2.0.0.18', 'Mozilla Firefox 2.0.0.18 on Linux');
 // FF 3.0
 $cmbAgent->addItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1', 'Mozilla Firefox 3.0.1 on Windows XP');
 $cmbAgent->addItem('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1', 'Mozilla Firefox 3.0.1 on Linux');
 // OP 9.0
 $cmbAgent->addItem('Opera/9.02 (Windows NT 5.1; U; en)', 'Opera 9.02 on Windows XP');