public function _getContent($refresh = false)
 {
     $table = new CTableInfo(_('No web scenarios found.'));
     $table->setHeader(array(_('Website'), _('Links'), _('Broken Links')));
     $data = array();
     // fetch links between HTTP tests and host groups
     $result = DbFetchArray(DBselect('SELECT website.*, sum(status LIKE "2%") as links_ok, sum(status != "" AND NOT status LIKE "2%") as links_404, sum(status = "" OR status is null) as links_unchecked FROM zabbix_spider.website LEFT JOIN zabbix_spider.page ON page.website = Website.aid group by page.website;'));
     foreach ($result as $row) {
         $deadlinks = DbFetchArray(DBselect('SELECT * FROM zabbix_spider.page  WHERE NOT status IS NULL AND status != "200" AND status != "" and website = ' . $row['aid']));
         $deadlink_output = array();
         $link_options = array("target" => "_blank");
         foreach ($deadlinks as $deadlink) {
             $link_link = new CLink($deadlink['url'] == "" ? "root" : substr($deadlink['url'], 0, 50), ($deadlink['url'] == "" || $deadlink['url'][0] == "/" ? $row['url'] : "") . $deadlink['url']);
             $link_link->setTarget("_blank");
             $map_link = new CLink("map", $this->reportUrl . "?pid={$deadlink['aid']}");
             $map_link->setTarget("_blank");
             $info_link = new CLink($deadlink["status"], "http://www.checkupdown.com/status/E{$deadlink['status']}.html");
             $info_link->setTarget("_blank");
             $deadlink_output[] = new CDiv(array($link_link, " [ ", $map_link, " | ", $info_link, " ]"));
         }
         $link_link = new CLink($row['name'], $row['url']);
         $link_link->setTarget("_blank");
         $map_link = new CLink("map", $this->reportUrl . "?wid={$row['aid']}");
         $map_link->setTarget("_blank");
         $table->addRow(array(new CDiv(array($link_link, " [ ", $map_link, " ]")), new CDiv(array(new CSpan($row['links_ok'], 'green'), " / ", new CSpan($row['links_404'], 'red'), " / ", new CSpan($row['links_unchecked'], 'gray'))), new CDiv($deadlink_output)));
     }
     return $table;
 }
 public function toString($destroy = true)
 {
     if (count($this->tabs) == 1) {
         $this->setAttribute('class', 'min-width ui-tabs ui-widget ui-widget-content ui-corner-all widget');
         $header = reset($this->headers);
         $header = new CDiv($header);
         $header->addClass('ui-corner-all ui-widget-header header');
         $header->setAttribute('id', 'tab_' . key($this->headers));
         $this->addItem($header);
         $tab = reset($this->tabs);
         $tab->addClass('ui-tabs ui-tabs-panel ui-widget ui-widget-content ui-corner-all widget');
         $this->addItem($tab);
     } else {
         $headersList = new CList();
         foreach ($this->headers as $id => $header) {
             $tabLink = new CLink($header, '#' . $id, null, null, false);
             $tabLink->setAttribute('id', 'tab_' . $id);
             $headersList->addItem($tabLink);
         }
         $this->addItem($headersList);
         $this->addItem($this->tabs);
         $options = array();
         if (!is_null($this->selectedTab)) {
             $options['selected'] = $this->selectedTab;
         }
         if ($this->rememberTab) {
             $options['cookie'] = array();
         }
         zbx_add_post_js('jQuery("#' . $this->id . '").tabs(' . zbx_jsvalue($options, true) . ').show();');
     }
     return parent::toString($destroy);
 }
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $this->dataId = 'graph_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid'];
     $resourceid = !empty($this->screenitem['real_resourceid']) ? $this->screenitem['real_resourceid'] : $this->screenitem['resourceid'];
     $containerid = 'graph_container_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid'];
     $graphDims = getGraphDims();
     $graphDims['graphHeight'] = $this->screenitem['height'];
     $graphDims['width'] = $this->screenitem['width'];
     // get time control
     $timeControlData = array('id' => $this->getDataId(), 'containerid' => $containerid, 'objDims' => $graphDims, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.screens.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD);
     // host feature
     if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) {
         $newitemid = get_same_item_for_host($resourceid, $this->hostid);
         $resourceid = !empty($newitemid) ? $newitemid : '';
     }
     if ($this->mode == SCREEN_MODE_PREVIEW && !empty($resourceid)) {
         $this->action = 'history.php?action=' . HISTORY_GRAPH . '&itemids[]=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'] . $this->getProfileUrlParams();
     }
     if ($resourceid && $this->mode != SCREEN_MODE_EDIT) {
         if ($this->mode == SCREEN_MODE_PREVIEW) {
             $timeControlData['loadSBox'] = 1;
         }
     }
     $timeControlData['src'] = $resourceid ? 'chart.php?itemids[]=' . $resourceid . '&' . $this->screenitem['url'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] : 'chart3.php?';
     $timeControlData['src'] .= $this->mode == SCREEN_MODE_EDIT ? '&period=3600&stime=' . date(TIMESTAMP_FORMAT, time()) : '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'];
     $timeControlData['src'] .= $this->getProfileUrlParams();
     // output
     if ($this->mode == SCREEN_MODE_JS) {
         return 'timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ')';
     } else {
         if ($this->mode == SCREEN_MODE_SLIDESHOW) {
             insert_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');');
         } else {
             zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');');
         }
         if ($this->mode == SCREEN_MODE_EDIT || $this->mode == SCREEN_MODE_SLIDESHOW) {
             $item = new CDiv();
         } elseif ($this->mode == SCREEN_MODE_PREVIEW) {
             $item = new CLink(null, 'history.php?action=' . HISTORY_GRAPH . '&itemids[]=' . $resourceid . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow']);
         }
         $item->setAttribute('id', $containerid);
         return $this->getOutput($item);
     }
 }
示例#4
0
 function bodyToString($destroy = true)
 {
     $left = new CDiv(null, 'left');
     $left->addItem(new CDiv($this->getList(), 'left_menu'));
     $link1 = new CLink('www.zabbix.com', 'http://www.zabbix.com/', null, null, true);
     $link1->setAttribute('target', '_blank');
     $link2 = new CLink('GPL v2', 'http://www.zabbix.com/license.php', null, null, true);
     $link2->setAttribute('target', '_blank');
     $licence = new CDiv(array($link1, BR(), ' Licensed under ', $link2), 'setup_wizard_licence');
     $left->addItem($licence);
     $right = new CDiv(null, 'right');
     if ($this->getStep() == 0) {
         $right->addItem(new CDiv(null, 'blank_title'));
         $right->addItem(new CDiv($this->getState(), 'blank_under_title'));
         $container = new CDiv(array($left, $right), 'setup_wizard setup_wizard_welcome');
     } else {
         $right->addItem(new CDiv($this->stage[$this->getStep()]['title'], 'setup_title'));
         $right->addItem(new CDiv($this->getState(), 'under_title'));
         $container = new CDiv(array($left, $right), 'setup_wizard');
     }
     if (isset($this->stage[$this->getStep() + 1])) {
         $next = new CSubmit('next[' . $this->getStep() . ']', _('Next') . SPACE . '»');
     } else {
         $next = new CSubmit('finish', _('Finish'));
     }
     if (isset($this->HIDE_CANCEL_BUTTON) && $this->HIDE_CANCEL_BUTTON) {
         $cancel = null;
     } else {
         $cancel = new CDiv(new CSubmit('cancel', _('Cancel')), 'footer_left');
     }
     if ($this->DISABLE_NEXT_BUTTON) {
         $next->setEnabled(false);
     }
     // if the user is not logged in (first setup run) hide the "previous" button on the final step
     if ($this->getStep() && (CWebUser::$data && CWebUser::getType() == USER_TYPE_SUPER_ADMIN || $this->getStep() < 5)) {
         $back = new CSubmit('back[' . $this->getStep() . ']', '&laquo;' . SPACE . _('Previous'));
     } else {
         $back = null;
     }
     $footer = new CDiv(array($cancel, new CDiv(array($back, $next), 'footer_right')), 'footer');
     $container->addItem($footer);
     return parent::bodyToString($destroy) . $container->ToString();
 }
示例#5
0
    public function toString($destroy = true)
    {
        if (count($this->tabs) == 1) {
            $this->setAttribute('class', 'min-width ui-tabs ui-widget ui-widget-content ui-corner-all widget');
            $header = reset($this->headers);
            $header = new CDiv($header);
            $header->addClass('ui-corner-all ui-widget-header header');
            $header->setAttribute('id', 'tab_' . key($this->headers));
            $this->addItem($header);
            $tab = reset($this->tabs);
            $tab->addClass('ui-tabs ui-tabs-panel ui-widget ui-widget-content ui-corner-all widget');
            $this->addItem($tab);
        } else {
            $headersList = new CList();
            foreach ($this->headers as $id => $header) {
                $tabLink = new CLink($header, '#' . $id, null, null, false);
                $tabLink->setAttribute('id', 'tab_' . $id);
                $headersList->addItem($tabLink);
            }
            $this->addItem($headersList);
            $this->addItem($this->tabs);
            if ($this->selectedTab === null) {
                $activeTab = get_cookie('tab', 0);
                $createEvent = '';
            } else {
                $activeTab = $this->selectedTab;
                $createEvent = 'create: function() { jQuery.cookie("tab", ' . $this->selectedTab . '); },';
            }
            $disabledTabs = $this->disabledTabs === null ? '' : 'disabled: ' . CJs::encodeJson($this->disabledTabs) . ',';
            zbx_add_post_js('
				jQuery("#' . $this->id . '").tabs({
					' . $createEvent . '
					' . $disabledTabs . '
					active: ' . $activeTab . ',
					activate: function(event, ui) {
						jQuery.cookie("tab", ui.newTab.index().toString());
					}
				})
				.css("visibility", "visible");');
        }
        return parent::toString($destroy);
    }
示例#6
0
/**
 * Creates nodes that can be used to display the service configuration tree using the CTree class.
 *
 * @see CTree
 *
 * @param array $services
 * @param array $parentService
 * @param array $service
 * @param array $dependency
 * @param array $tree
 */
function createServiceConfigurationTree(array $services, &$tree, array $parentService = array(), array $service = array(), array $dependency = array())
{
    if (!$service) {
        $caption = new CLink(_('root'), '#');
        $caption->setMenuPopup(CMenuPopupHelper::getServiceConfiguration(null, _('root'), false));
        $serviceNode = array('id' => 0, 'parentid' => 0, 'caption' => $caption, 'trigger' => array(), 'algorithm' => SPACE, 'description' => SPACE);
        $service = $serviceNode;
        $service['serviceid'] = 0;
        $service['dependencies'] = array();
        $service['trigger'] = array();
        // add all top level services as children of "root"
        foreach ($services as $topService) {
            if (!$topService['parent']) {
                $service['dependencies'][] = array('servicedownid' => $topService['serviceid'], 'soft' => 0, 'linkid' => 0);
            }
        }
        $tree = array($serviceNode);
    } else {
        // caption
        $caption = new CLink($service['name'], '#');
        // service is deletable only if it has no hard dependency
        $deletable = true;
        foreach ($service['dependencies'] as $dep) {
            if ($dep['soft'] == 0) {
                $deletable = false;
                break;
            }
        }
        $caption->setMenuPopup(CMenuPopupHelper::getServiceConfiguration($service['serviceid'], $service['name'], $deletable));
        $serviceNode = array('id' => $service['serviceid'], 'caption' => $caption, 'description' => $service['trigger'] ? $service['trigger']['description'] : '-', 'parentid' => $parentService ? $parentService['serviceid'] : 0, 'algorithm' => serviceAlgorythm($service['algorithm']));
    }
    if (!$dependency || !$dependency['soft']) {
        $tree[$serviceNode['id']] = $serviceNode;
        foreach ($service['dependencies'] as $dependency) {
            $childService = $services[$dependency['servicedownid']];
            createServiceConfigurationTree($services, $tree, $service, $childService, $dependency);
        }
    } else {
        $serviceNode['caption'] = new CSpan($serviceNode['caption'], 'service-caption-soft');
        $tree[$serviceNode['id'] . '.' . $dependency['linkid']] = $serviceNode;
    }
}
 function bodyToString($destroy = true)
 {
     $left = new CDiv(null, 'left');
     $left->addItem(new CDiv(null, 'setup_logo'));
     $left->addItem(new CDiv(ZABBIX_VERSION, 'setup_version'));
     $left->addItem(new CDiv($this->getList(), 'left_menu'));
     $link1 = new CLink('www.zabbix.com', 'http://www.zabbix.com/', null, null, true);
     $link1->setAttribute('target', '_blank');
     $link2 = new CLink('GPL v2', 'http://www.zabbix.com/license.php', null, null, true);
     $link2->setAttribute('target', '_blank');
     $licence = new CDiv(array($link1, BR(), ' Licensed under ', $link2), 'setup_wizard_licence');
     $left->addItem($licence);
     $right = new CDiv(null, 'right');
     if ($this->getStep() == 0) {
         $right->addItem(new CDiv(null, 'blank_title'));
         $right->addItem(new CDiv($this->getState(), 'blank_under_title'));
         $container = new CDiv(array($left, $right), 'setup_wizard setup_wizard_welcome');
     } else {
         $right->addItem(new CDiv($this->stage[$this->getStep()]['title'], 'setup_title'));
         $right->addItem(new CDiv($this->getState(), 'under_title'));
         $container = new CDiv(array($left, $right), 'setup_wizard');
     }
     if (isset($this->stage[$this->getStep() + 1])) {
         $next = new CSubmit('next[' . $this->getStep() . ']', _('Next') . ' >>');
     } else {
         $next = new CSubmit('finish', _('Finish'));
     }
     if (isset($this->HIDE_CANCEL_BUTTON) && $this->HIDE_CANCEL_BUTTON) {
         $cancel = null;
     } else {
         $cancel = new CDiv(new CSubmit('cancel', _('Cancel')), 'footer_left');
     }
     if ($this->DISABLE_NEXT_BUTTON) {
         $next->setEnabled(false);
     }
     $footer = new CDiv(array($cancel, new CDiv(array($this->getStep() != 0 ? new CSubmit('back[' . $this->getStep() . ']', '<< ' . _('Previous')) : null, $next), 'footer_right')), 'footer');
     $container->addItem($footer);
     return parent::bodyToString($destroy) . $container->ToString();
 }
 if ($hostInventoryTable['fields'][$inventoryInfo['db_field']]['type'] == DB::FIELD_TYPE_TEXT) {
     $input = new CTextArea('host_inventory[' . $inventoryInfo['db_field'] . ']', $host_inventory[$inventoryInfo['db_field']]);
     $input->addStyle('width: 64em;');
 } else {
     $fieldLength = $hostInventoryTable['fields'][$inventoryInfo['db_field']]['length'];
     $input = new CTextBox('host_inventory[' . $inventoryInfo['db_field'] . ']', $host_inventory[$inventoryInfo['db_field']]);
     $input->setAttribute('maxlength', $fieldLength);
     $input->addStyle('width: ' . ($fieldLength > 64 ? 64 : $fieldLength) . 'em;');
 }
 if ($inventory_mode == HOST_INVENTORY_DISABLED) {
     $input->setAttribute('disabled', 'disabled');
 }
 // link to populating item at the right side (if any)
 if (isset($hostItemsToInventory[$inventoryNo])) {
     $itemName = itemName($hostItemsToInventory[$inventoryNo]);
     $populatingLink = new CLink($itemName, 'items.php?form=update&itemid=' . $hostItemsToInventory[$inventoryNo]['itemid']);
     $populatingLink->setAttribute('title', _s('This field is automatically populated by item "%s".', $itemName));
     $populatingItemCell = array(' &larr; ', $populatingLink);
     $input->addClass('linked_to_item');
     // this will be used for disabling fields via jquery
     if ($inventory_mode == HOST_INVENTORY_AUTOMATIC) {
         $input->setAttribute('disabled', 'disabled');
     }
 } else {
     $populatingItemCell = '';
 }
 $input->addStyle('float: left;');
 $populatingItem = new CSpan($populatingItemCell, 'populating_item');
 if ($inventory_mode != HOST_INVENTORY_AUTOMATIC) {
     // those links are visible only in automatic mode
     $populatingItem->addStyle('display: none');
     $deltaComboBox = new CComboBox('delta', $this->data['delta']);
     $deltaComboBox->addItems($deltaOptions);
 }
 $itemFormList->addRow(_('Store value'), $deltaComboBox, false, 'row_delta');
 // append valuemap to form list
 if ($this->data['limited']) {
     $itemForm->addVar('valuemapid', $this->data['valuemapid']);
     $valuemapComboBox = new CTextBox('valuemap_name', !empty($this->data['valuemaps']) ? $this->data['valuemaps'] : _('As is'), ZBX_TEXTBOX_SMALL_SIZE, 'yes');
 } else {
     $valuemapComboBox = new CComboBox('valuemapid', $this->data['valuemapid']);
     $valuemapComboBox->addItem(0, _('As is'));
     foreach ($this->data['valuemaps'] as $valuemap) {
         $valuemapComboBox->addItem($valuemap['valuemapid'], get_node_name_by_elid($valuemap['valuemapid'], null, NAME_DELIMITER) . CHtml::encode($valuemap['name']));
     }
 }
 $link = new CLink(_('show value mappings'), 'adm.valuemapping.php');
 $link->setAttribute('target', '_blank');
 $itemFormList->addRow(_('Show value'), array($valuemapComboBox, SPACE, $link), null, 'row_valuemap');
 $itemFormList->addRow(_('Allowed hosts'), new CTextBox('trapper_hosts', $this->data['trapper_hosts'], ZBX_TEXTBOX_STANDARD_SIZE), false, 'row_trapper_hosts');
 // append applications to form list
 $itemFormList->addRow(_('New application'), new CTextBox('new_application', $this->data['new_application'], ZBX_TEXTBOX_STANDARD_SIZE), false, null, 'new');
 $applicationComboBox = new CListBox('applications[]', $this->data['applications'], 6);
 $applicationComboBox->addItem(0, '-' . _('None') . '-');
 foreach ($this->data['db_applications'] as $application) {
     $applicationComboBox->addItem($application['applicationid'], CHtml::encode($application['name']));
 }
 $itemFormList->addRow(_('Applications'), $applicationComboBox);
 // append populate host to form list
 if (empty($this->data['parent_discoveryid'])) {
     $itemCloned = isset($_REQUEST['clone']);
     $hostInventoryFieldComboBox = new CComboBox('inventory_link');
示例#10
0
/**
 * Create element with event acknowledges info.
 * If $event has subarray 'acknowledges', returned link will have hint with acknowledges.
 *
 * @param array			$event   event data
 * @param int			$event['acknowledged']
 * @param int			$event['eventid']
 * @param int			$event['objectid']
 * @param array			$event['acknowledges']
 * @param bool|string	$backUrl if true, add backurl param to link with current page file name
 * @param bool			$isLink  if true, return link otherwise span
 * @param array			$params  additional params for link
 *
 * @return array|CLink|CSpan|null|string
 */
function getEventAckState($event, $backUrl = false, $isLink = true, $params = array())
{
    $config = select_config();
    if (!$config['event_ack_enable']) {
        return null;
    }
    if ($isLink) {
        if (!empty($backUrl)) {
            if (is_bool($backUrl)) {
                global $page;
                $backurl = '&backurl=' . $page['file'];
            } else {
                $backurl = '&backurl=' . $backUrl;
            }
        } else {
            $backurl = '';
        }
        $additionalParams = '';
        foreach ($params as $key => $value) {
            $additionalParams .= '&' . $key . '=' . $value;
        }
        if ($event['acknowledged'] == 0) {
            $ack = new CLink(_('No'), 'acknow.php?eventid=' . $event['eventid'] . '&triggerid=' . $event['objectid'] . $backurl . $additionalParams, 'disabled');
        } else {
            $ackLink = new CLink(_('Yes'), 'acknow.php?eventid=' . $event['eventid'] . '&triggerid=' . $event['objectid'] . $backurl . $additionalParams, 'enabled');
            if (is_array($event['acknowledges'])) {
                $ackLinkHints = makeAckTab($event);
                if (!empty($ackLinkHints)) {
                    $ackLink->setHint($ackLinkHints, '', '', false);
                }
                $ack = array($ackLink, ' (' . count($event['acknowledges']) . ')');
            } else {
                $ack = array($ackLink, ' (' . $event['acknowledges'] . ')');
            }
        }
    } else {
        if ($event['acknowledged'] == 0) {
            $ack = new CSpan(_('No'), 'on');
        } else {
            $ack = array(new CSpan(_('Yes'), 'off'), ' (' . (is_array($event['acknowledges']) ? count($event['acknowledges']) : $event['acknowledges']) . ')');
        }
    }
    return $ack;
}
示例#11
0
 /**
  * Tests the delete of a link
  */
 public function testDeleteLink()
 {
     global $AppUI;
     $this->obj->bind($this->post_data);
     $result = $this->obj->store($AppUI);
     $this->assertTrue($result);
     $original_id = $this->obj->link_id;
     $result = $this->obj->delete($AppUI);
     $this->assertTrue($result);
     $link = new CLink();
     $link->load($original_id);
     $this->assertEquals('', $link->link_name);
     $this->assertEquals('', $link->link_url);
 }
$sysmapList->addRow(_('Width'), new CNumericBox('width', $this->data['sysmap']['width'], 5));
$sysmapList->addRow(_('Height'), new CNumericBox('height', $this->data['sysmap']['height'], 5));
// append background image to form list
$imageComboBox = new CComboBox('backgroundid', $this->data['sysmap']['backgroundid']);
$imageComboBox->addItem(0, _('No image'));
foreach ($this->data['images'] as $image) {
    $imageComboBox->addItem($image['imageid'], $image['name']);
}
$sysmapList->addRow(_('Background image'), $imageComboBox);
// append iconmapping to form list
$iconMappingComboBox = new CComboBox('iconmapid', $this->data['sysmap']['iconmapid']);
$iconMappingComboBox->addItem(0, _('<manual>'));
foreach ($this->data['iconMaps'] as $iconMap) {
    $iconMappingComboBox->addItem($iconMap['iconmapid'], $iconMap['name']);
}
$iconMappingsLink = new CLink(_('show icon mappings'), 'adm.iconmapping.php');
$iconMappingsLink->setAttribute('target', '_blank');
$sysmapList->addRow(_('Automatic icon mapping'), array($iconMappingComboBox, SPACE, $iconMappingsLink));
// append multiple checkboxes to form list
$sysmapList->addRow(_('Icon highlight'), new CCheckBox('highlight', $this->data['sysmap']['highlight'], null, 1));
$sysmapList->addRow(_('Mark elements on trigger status change'), new CCheckBox('markelements', $this->data['sysmap']['markelements'], null, 1));
$sysmapList->addRow(_('Expand single problem'), new CCheckBox('expandproblem', $this->data['sysmap']['expandproblem'], null, 1));
$sysmapList->addRow(_('Advanced labels'), new CCheckBox('label_format', $this->data['sysmap']['label_format'], null, 1));
// append hostgroup to form list
$labelTypeHostgroupComboBox = new CComboBox('label_type_hostgroup', $this->data['sysmap']['label_type_hostgroup'], null, $this->data['labelTypesLimited']);
$customLabelHostgroupTextArea = new CTextArea('label_string_hostgroup', $this->data['sysmap']['label_string_hostgroup']);
if ($this->data['sysmap']['label_type_hostgroup'] != MAP_LABEL_TYPE_CUSTOM) {
    $customLabelHostgroupTextArea->addClass('hidden');
}
$sysmapList->addRow(_('Host group label type'), array($labelTypeHostgroupComboBox, BR(), $customLabelHostgroupTextArea));
// append host to form list
$userFormList->addRow(_('Refresh (in seconds)'), new CNumericBox('refresh', $this->data['refresh'], 4));
$userFormList->addRow(_('Rows per page'), new CNumericBox('rows_per_page', $this->data['rows_per_page'], 6));
$userFormList->addRow(_('URL (after login)'), new CTextBox('url', $this->data['url'], ZBX_TEXTBOX_STANDARD_SIZE));
/*
 * Media tab
 */
if (uint_in_array(CWebUser::$data['type'], array(USER_TYPE_ZABBIX_ADMIN, USER_TYPE_SUPER_ADMIN))) {
    $userMediaFormList = new CFormList('userMediaFormList');
    $userForm->addVar('user_medias', $this->data['user_medias']);
    $mediaTableInfo = new CTableInfo(_('No media found.'));
    foreach ($this->data['user_medias'] as $id => $media) {
        if (!isset($media['active']) || !$media['active']) {
            $status = new CLink(_('Enabled'), '#', 'enabled');
            $status->onClick('return create_var("' . $userForm->getName() . '","disable_media",' . $id . ', true);');
        } else {
            $status = new CLink(_('Disabled'), '#', 'disabled');
            $status->onClick('return create_var("' . $userForm->getName() . '","enable_media",' . $id . ', true);');
        }
        $mediaUrl = '?dstfrm=' . $userForm->getName() . '&media=' . $id . '&mediatypeid=' . $media['mediatypeid'] . '&sendto=' . urlencode($media['sendto']) . '&period=' . $media['period'] . '&severity=' . $media['severity'] . '&active=' . $media['active'];
        foreach (getSeverityCaption() as $key => $caption) {
            $mediaActive = $media['severity'] & 1 << $key;
            $mediaSeverity[$key] = new CSpan(mb_substr($caption, 0, 1), $mediaActive ? 'enabled' : null);
            $mediaSeverity[$key]->setHint($caption . ($mediaActive ? ' (on)' : ' (off)'));
        }
        $mediaTableInfo->addRow(array(new CCheckBox('user_medias_to_del[' . $id . ']', null, null, $id), new CSpan($media['description'], 'nowrap'), new CSpan($media['sendto'], 'nowrap'), new CSpan($media['period'], 'nowrap'), $mediaSeverity, $status, new CButton('edit_media', _('Edit'), 'return PopUp("popup_media.php' . $mediaUrl . '", 550, 400);', 'link_menu')));
    }
    $userMediaFormList->addRow(_('Media'), array($mediaTableInfo, new CButton('add_media', _('Add'), 'return PopUp("popup_media.php?dstfrm=' . $userForm->getName() . '", 550, 400);', 'link_menu'), SPACE, SPACE, count($this->data['user_medias']) > 0 ? new CSubmit('del_user_media', _('Delete selected'), null, 'link_menu') : null));
}
/*
 * Profile fields
 */
示例#14
0
function make_favorite_maps()
{
    $favList = new CList(null, 'favorites', _('No maps added.'));
    $fav_sysmaps = CFavorite::get('web.favorite.sysmapids');
    if (!$fav_sysmaps) {
        return $favList;
    }
    $sysmapids = array();
    foreach ($fav_sysmaps as $favorite) {
        $sysmapids[$favorite['value']] = $favorite['value'];
    }
    $sysmaps = API::Map()->get(array('sysmapids' => $sysmapids, 'output' => array('sysmapid', 'name')));
    foreach ($sysmaps as $sysmap) {
        $sysmapid = $sysmap['sysmapid'];
        $link = new CLink(get_node_name_by_elid($sysmapid, null, NAME_DELIMITER) . $sysmap['name'], 'maps.php?sysmapid=' . $sysmapid);
        $link->setTarget('blank');
        $favList->addItem($link, 'nowrap');
    }
    return $favList;
}
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
include dirname(__FILE__) . '/js/configuration.services.child.list.js.php';
$servicesChildWidget = new CWidget();
$servicesChildWidget->addPageHeader(_('IT service dependencies'));
// create form
$servicesChildForm = new CForm();
$servicesChildForm->setName('servicesForm');
if (!empty($this->data['service'])) {
    $servicesChildForm->addVar('serviceid', $this->data['service']['serviceid']);
}
// create table
$servicesChildTable = new CTableInfo(_('No IT services found.'));
$servicesChildTable->setHeader(array(new CCheckBox('all_services', null, "javascript: checkAll('" . $servicesChildForm->getName() . "', 'all_services', 'services');"), _('Service'), _('Status calculation'), _('Trigger')));
$prefix = null;
foreach ($this->data['db_cservices'] as $service) {
    $description = new CLink($service['name'], '#', 'service-name');
    $description->setAttributes(array('id' => 'service-name-' . $service['serviceid'], 'data-name' => $service['name'], 'data-serviceid' => $service['serviceid'], 'data-trigger' => $service['trigger']));
    $cb = new CCheckBox('services[' . $service['serviceid'] . ']', null, null, $service['serviceid']);
    $cb->addClass('service-select');
    $servicesChildTable->addRow(array($cb, array($prefix, $description), serviceAlgorythm($service['algorithm']), $service['trigger']));
}
$servicesChildTable->setFooter(new CCol(new CButton('select', _('Select')), 'right'));
// append table to form
$servicesChildForm->addItem($servicesChildTable);
// append form to widget
$servicesChildWidget->addItem($servicesChildForm);
return $servicesChildWidget;
        $templateList->addRow(_('Web scenarios'), $listBox);
    }
}
$divTabs->addTab('templateTab', _('Template'), $templateList);
// FULL CLONE }
// } TEMPLATE WIDGET
// TEMPLATES{
$tmplList = new CFormList('tmpllist');
// create linked template table
$linkedTemplateTable = new CTable(_('No templates linked.'), 'formElementTable');
$linkedTemplateTable->attr('id', 'linkedTemplateTable');
$linkedTemplateTable->setHeader(array(_('Name'), _('Action')));
$ignoredTemplates = array();
foreach ($this->data['linkedTemplates'] as $template) {
    $tmplList->addVar('templates[]', $template['templateid']);
    $templateLink = new CLink($template['name'], 'templates.php?form=update&templateid=' . $template['templateid']);
    $templateLink->setTarget('_blank');
    $linkedTemplateTable->addRow(array($templateLink, array(new CSubmit('unlink[' . $template['templateid'] . ']', _('Unlink'), null, 'link_menu'), SPACE, SPACE, isset($this->data['original_templates'][$template['templateid']]) ? new CSubmit('unlink_and_clear[' . $template['templateid'] . ']', _('Unlink and clear'), null, 'link_menu') : SPACE)), null, 'conditions_' . $template['templateid']);
    $ignoredTemplates[$template['templateid']] = $template['name'];
}
$tmplList->addRow(_('Linked templates'), new CDiv($linkedTemplateTable, 'template-link-block objectgroup inlineblock border_dotted ui-corner-all'));
// create new linked template table
$newTemplateTable = new CTable(null, 'formElementTable');
$newTemplateTable->attr('id', 'newTemplateTable');
$newTemplateTable->attr('style', 'min-width: 400px;');
$newTemplateTable->addRow(array(new CMultiSelect(array('name' => 'add_templates[]', 'objectName' => 'templates', 'ignored' => $ignoredTemplates, 'popup' => array('parameters' => 'srctbl=templates&srcfld1=hostid&srcfld2=host&dstfrm=' . $frmHost->getName() . '&dstfld1=add_templates_&templated_hosts=1&multiselect=1', 'width' => 450, 'height' => 450)))));
$newTemplateTable->addRow(array(new CSubmit('add_template', _('Add'), null, 'link_menu')));
$tmplList->addRow(_('Link new templates'), new CDiv($newTemplateTable, 'template-link-block objectgroup inlineblock border_dotted ui-corner-all'));
$divTabs->addTab('tmplTab', _('Linked templates'), $tmplList);
// } TEMPLATES
// macros
示例#17
0
function make_latest_issues($params = array())
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY);
    $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array());
    $scripts_by_hosts = get_accessible_scripts_by_hosts($available_hosts);
    $config = select_config();
    $sql_select = '';
    $sql_from = '';
    $sql_where = '';
    $limit = 20;
    if (!empty($params)) {
        if (isset($params['limit'])) {
            $limit = $params['limit'];
        }
        if (isset($params['groupid']) && $params['groupid'] > 0) {
            $sql_select .= ',g.name ';
            $sql_from .= ',groups g ';
            $sql_where .= ' AND g.groupid=hg.groupid ' . ' AND hg.groupid=' . $params['groupid'];
        }
        if (isset($params['hostid']) && $params['hostid'] > 0) {
            $sql_where .= ' AND h.hostid=' . $params['hostid'];
        }
    }
    $table = new CTableInfo();
    $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, isset($params['groupid']) && $params['groupid'] > 0 ? S_GROUP : null, S_HOST, S_ISSUE, S_LAST_CHANGE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
    $sql = 'SELECT DISTINCT t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.value,h.host,h.hostid ' . $sql_select . ' FROM triggers t,hosts h,items i,functions f,hosts_groups hg ' . $sql_from . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.value=' . TRIGGER_VALUE_TRUE . $sql_where . ' ORDER BY t.lastchange DESC';
    $result = DBselect($sql, $limit);
    while ($row = DBfetch($result)) {
        // Check for dependencies
        if (trigger_dependent($row["triggerid"])) {
            continue;
        }
        $host = null;
        $menus = '';
        $host_nodeid = id2nodeid($row['hostid']);
        foreach ($scripts_by_hosts[$row['hostid']] as $id => $script) {
            $script_nodeid = id2nodeid($script['scriptid']);
            if (bccomp($host_nodeid, $script_nodeid) == 0) {
                $menus .= "['" . $script['name'] . "',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $row['hostid'] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
            }
        }
        $menus .= "[" . zbx_jsvalue(S_LINKS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],";
        $menus .= "['" . S_LATEST_DATA . "',\"javascript: redirect('latest.php?groupid=0&hostid=" . $row['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
        $menus = rtrim($menus, ',');
        $menus = "show_popup_menu(event,[[" . zbx_jsvalue(S_TOOLS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus . "],180);";
        $host = new CSpan($row['host'], 'link');
        $host->setAttribute('onclick', 'javascript: ' . $menus);
        $host->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
        $event_sql = 'SELECT DISTINCT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type, t.url ' . ' FROM events e, triggers t ' . ' WHERE e.object=' . EVENT_SOURCE_TRIGGERS . ' AND e.objectid=' . $row['triggerid'] . ' AND t.triggerid=e.objectid ' . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC';
        $res_events = DBSelect($event_sql, 1);
        while ($row_event = DBfetch($res_events)) {
            $ack = NULL;
            if ($config['event_ack_enable']) {
                if ($row_event['acknowledged'] == 1) {
                    $ack_info = make_acktab_by_eventid($row_event['eventid']);
                    $ack_info->setAttribute('style', 'width: auto;');
                    $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_event['eventid'], 'action');
                    $ack->setHint($ack_info);
                } else {
                    $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_event['eventid'], 'on');
                }
            }
            //			$description = expand_trigger_description($row['triggerid']);
            $description = expand_trigger_description_by_data(array_merge($row, array('clock' => $row_event['clock'])), ZBX_FLAG_EVENT);
            //actions
            $actions = get_event_actions_stat_hints($row_event['eventid']);
            $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'events.php?triggerid=' . $row['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $row_event['clock'], 'action');
            if ($row_event['url']) {
                $description = new CLink($description, $row_event['url'], 'action', null, true);
            } else {
                $description = new CSpan($description, 'pointer');
            }
            $description = new CCol($description, get_severity_style($row["priority"]));
            $description->setHint(make_popup_eventlist($row_event['eventid'], $row['type']));
            $table->addRow(array(get_node_name_by_elid($row['triggerid']), $host, $description, $clock, zbx_date2age($row_event['clock']), $ack, $actions));
        }
        unset($row, $description, $actions, $alerts, $hint);
    }
    $table->setFooter(new CCol(S_UPDATED . ': ' . date("H:i:s", time())));
    return $table;
}
示例#18
0
$m = 'links';
if ($canEdit) {
    $titleBlock = new CTitleBlock('', '', $m, "{$m}.{$a}");
    $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new link') . '">', '', '<form action="?m=links&a=addedit&project_id=' . $project_id . '&task_id=' . $task_id . '" method="post" accept-charset="utf-8">', '</form>');
    $titleBlock->show();
}
$page = (int) w2PgetParam($_GET, 'page', 1);
$search = w2PgetParam($_POST, 'search', '');
if (!isset($project_id)) {
    $project_id = (int) w2PgetParam($_POST, 'project_id', 0);
}
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$link_types = w2PgetSysVal('LinkType');
if ($canRead) {
    $link = new CLink();
    $links = $link->getProjectTaskLinksByCategory($AppUI, $project_id, $task_id, $tab - 1, $search);
} else {
    $AppUI->redirect('m=public&a=access_denied');
}
$xpg_pagesize = w2PgetConfig('page_size', 50);
$xpg_min = $xpg_pagesize * ($page - 1);
// This is where we start our record set from
// counts total recs from selection
$xpg_totalrecs = count($links);
echo buildPaginationNav($AppUI, $m, $tab, $xpg_totalrecs, $xpg_pagesize, $page);
?>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
<tr>
	<th nowrap="nowrap">&nbsp;</th>
	<th nowrap="nowrap"><?php 
示例#19
0
/**
 * Returns paging line.
 *
 * @param array  $items				list of items
 * @param string $sortorder			the order in which items are sorted ASC or DESC
 * @param CUrl $url					URL object containing arguments and query
 *
 * @return CDiv
 */
function getPagingLine(&$items, $sortorder, CUrl $url)
{
    global $page;
    $rowsPerPage = CWebUser::$data['rows_per_page'];
    $itemsCount = count($items);
    $pagesCount = $itemsCount > 0 ? ceil($itemsCount / $rowsPerPage) : 1;
    $currentPage = getPageNumber();
    if ($currentPage < 1) {
        $currentPage = 1;
    } elseif ($currentPage > $pagesCount) {
        $currentPage = $pagesCount;
    }
    $start = ($currentPage - 1) * $rowsPerPage;
    $tags = [];
    if ($pagesCount > 1) {
        // For MVC pages $page is not set
        if (isset($page['file'])) {
            CProfile::update('web.paging.lastpage', $page['file'], PROFILE_TYPE_STR);
            CProfile::update('web.paging.page', $currentPage, PROFILE_TYPE_INT);
        } elseif (isset($_REQUEST['action'])) {
            CProfile::update('web.paging.lastpage', $_REQUEST['action'], PROFILE_TYPE_STR);
            CProfile::update('web.paging.page', $currentPage, PROFILE_TYPE_INT);
        }
        // viewed pages (better to use not odd)
        $pagingNavRange = 11;
        $endPage = $currentPage + floor($pagingNavRange / 2);
        if ($endPage < $pagingNavRange) {
            $endPage = $pagingNavRange;
        }
        if ($endPage > $pagesCount) {
            $endPage = $pagesCount;
        }
        $startPage = $endPage > $pagingNavRange ? $endPage - $pagingNavRange + 1 : 1;
        if ($startPage > 1) {
            $url->setArgument('page', 1);
            $tags[] = new CLink(_('First'), $url->getUrl());
        }
        if ($currentPage > 1) {
            $url->setArgument('page', $currentPage - 1);
            $tags[] = new CLink((new CSpan())->addClass(ZBX_STYLE_ARROW_LEFT), $url->getUrl());
        }
        for ($p = $startPage; $p <= $endPage; $p++) {
            $url->setArgument('page', $p);
            $link = new CLink($p, $url->getUrl());
            if ($p == $currentPage) {
                $link->addClass(ZBX_STYLE_PAGING_SELECTED);
            }
            $tags[] = $link;
        }
        if ($currentPage < $pagesCount) {
            $url->setArgument('page', $currentPage + 1);
            $tags[] = new CLink((new CSpan())->addClass(ZBX_STYLE_ARROW_RIGHT), $url->getUrl());
        }
        if ($p < $pagesCount) {
            $url->setArgument('page', $pagesCount);
            $tags[] = new CLink(_('Last'), $url->getUrl());
        }
    }
    if ($pagesCount == 1) {
        $table_stats = _s('Displaying %1$s of %2$s found', $itemsCount, $itemsCount);
    } else {
        $config = select_config();
        $end = $start + $rowsPerPage;
        if ($end > $itemsCount) {
            $end = $itemsCount;
        }
        $total = $itemsCount;
        if ($config['search_limit'] < $itemsCount) {
            if ($sortorder == ZBX_SORT_UP) {
                array_pop($items);
            } else {
                array_shift($items);
            }
            $total .= '+';
        }
        $table_stats = _s('Displaying %1$s to %2$s of %3$s found', $start + 1, $end, $total);
    }
    // trim array with items to contain items for current page
    $items = array_slice($items, $start, $rowsPerPage, true);
    return (new CDiv())->addClass(ZBX_STYLE_TABLE_PAGING)->addItem((new CDiv())->addClass(ZBX_STYLE_PAGING_BTN_CONTAINER)->addItem($tags)->addItem((new CDiv())->addClass(ZBX_STYLE_TABLE_STATS)->addItem($table_stats)));
}
if (!$this->data['showsla']) {
    $goodslaTextBox->setAttribute('disabled', 'disabled');
}
$servicesFormList->addRow(_('Calculate SLA, acceptable SLA (in %)'), array($showslaCheckbox, $goodslaTextBox));
// append trigger to form list
$servicesFormList->addRow(_('Trigger'), array(new CTextBox('trigger', $this->data['trigger'], ZBX_TEXTBOX_STANDARD_SIZE, true), new CButton('btn1', _('Select'), 'return PopUp("popup.php?' . 'dstfrm=' . $servicesForm->getName() . '&dstfld1=triggerid' . '&dstfld2=trigger' . '&srctbl=triggers' . '&srcfld1=triggerid' . '&srcfld2=description' . '&real_hosts=1' . '&with_triggers=1");', 'formlist')));
$servicesFormList->addRow(_('Sort order (0->999)'), new CTextBox('sortorder', $this->data['sortorder'], 3, false, 3));
/*
 * Dependencies tab
 */
$servicesChildTable = new CTable(_('No dependencies defined.'), 'formElementTable');
$servicesChildTable->setAttribute('style', 'min-width:500px;');
$servicesChildTable->setAttribute('id', 'service_children');
$servicesChildTable->setHeader(array(_('Services'), _('Soft'), _('Trigger'), _('Action')));
foreach ($this->data['children'] as $child) {
    $childrenLink = new CLink($child['name'], 'services.php?form=1&serviceid=' . $child['serviceid']);
    $childrenLink->setAttribute('target', '_blank');
    $row = new CRow(array(array($childrenLink, new CVar('children[' . $child['serviceid'] . '][name]', $child['name']), new CVar('children[' . $child['serviceid'] . '][serviceid]', $child['serviceid'])), new CCheckBox('children[' . $child['serviceid'] . '][soft]', isset($child['soft']) && !empty($child['soft']) ? 'checked' : 'no', null, 1), !empty($child['trigger']) ? $child['trigger'] : '-', new CButton('remove', _('Remove'), 'javascript: removeDependentChild(\'' . $child['serviceid'] . '\');', 'link_menu')));
    $row->setAttribute('id', 'children_' . $child['serviceid']);
    $servicesChildTable->addRow($row);
}
$servicesDependenciesFormList = new CFormList('servicesDependensiesFormList');
$servicesDependenciesFormList->addRow(_('Depends on'), new CDiv(array($servicesChildTable, new CButton('add_child_service', _('Add'), "javascript: openWinCentered('services.php?cservices=1" . url_param('serviceid') . "', 'ZBX_Services_List', 640, 520, 'scrollbars=1, toolbar=0, menubar=0, resizable=0');", 'link_menu')), 'objectgroup inlineblock border_dotted ui-corner-all'));
/*
 * Service times tab
 */
$servicesTimeFormList = new CFormList('servicesTimeFormList');
$servicesTimeTable = new CTable(_('No times defined. Work 24x7.'), 'formElementTable');
$servicesTimeTable->setAttribute('style', 'min-width: 500px;');
$servicesTimeTable->setHeader(array(_('Type'), _('Interval'), _('Note'), _('Action')));
$i = 0;
示例#21
0
    ?>
<body class="<?php 
    echo $css;
    ?>
">
<div id="message-global-wrap"><div id="message-global"></div></div>
<?php 
}
define('PAGE_HEADER_LOADED', 1);
if (defined('ZBX_PAGE_NO_HEADER')) {
    return null;
}
if (!defined('ZBX_PAGE_NO_MENU')) {
    $help = new CLink(_('Help'), 'http://www.zabbix.com/documentation/', 'small_font', null, 'nosid');
    $help->setTarget('_blank');
    $support = new CLink(_('Get support'), 'http://www.zabbix.com/support.php', 'small_font', null, 'nosid');
    $support->setTarget('_blank');
    $printview = new CLink(_('Print'), '', 'small_font print-link', null, 'nosid');
    $page_header_r_col = array($help, '|', $support, '|', $printview, '|');
    if (!CWebUser::isGuest()) {
        array_push($page_header_r_col, new CLink(_('Profile'), 'profile.php', 'small_font', null, 'nosid'), '|');
    }
    if (isset(CWebUser::$data['debug_mode']) && CWebUser::$data['debug_mode'] == GROUP_DEBUG_MODE_ENABLED) {
        $debug = new CLink(_('Debug'), '#debug', 'small_font', null, 'nosid');
        $d_script = " if (!isset('state', this)) { this.state = 'none'; }" . " if (this.state == 'none') { this.state = 'block'; }" . " else { this.state = 'none'; }" . " showHideByName('zbx_debug_info', this.state);";
        $debug->setAttribute('onclick', 'javascript: ' . $d_script);
        array_push($page_header_r_col, $debug, '|');
    }
    if (CWebUser::isGuest()) {
        $page_header_r_col[] = array(new CLink(_('Login'), 'index.php?reconnect=1', 'small_font', null, null));
    } else {
示例#22
0
 /**
  * Tests the delete of a link
  */
 public function testDelete()
 {
     $this->obj->bind($this->post_data);
     $result = $this->obj->store();
     $this->assertTrue($result);
     $original_id = $this->obj->link_id;
     $result = $this->obj->delete();
     $item = new CLink();
     $item->overrideDatabase($this->mockDB);
     $this->mockDB->stageHash(array('link_name' => '', 'link_url' => ''));
     $item->load($original_id);
     $this->assertTrue(is_a($item, 'CLink'));
     $this->assertEquals('', $item->link_name);
     $this->assertEquals('', $item->link_url);
 }
$mediaTypeForm = new CForm();
$mediaTypeForm->setName('mediaTypeForm');
$mediaTypeForm->addVar('form', $this->data['form']);
$mediaTypeForm->addVar('mediatypeid', $this->data['mediatypeid']);
// create form list
$mediaTypeFormList = new CFormList('mediaTypeFormList');
$nameTextBox = new CTextBox('description', $this->data['description'], ZBX_TEXTBOX_STANDARD_SIZE, false, 100);
$nameTextBox->attr('autofocus', 'autofocus');
$mediaTypeFormList->addRow(_('Name'), $nameTextBox);
// append type to form list
$cmbType = new CComboBox('type', $this->data['type'], 'submit()');
$cmbType->addItems(array(MEDIA_TYPE_EMAIL => _('Email'), MEDIA_TYPE_EXEC => _('Script'), MEDIA_TYPE_SMS => _('SMS'), MEDIA_TYPE_JABBER => _('Jabber')));
$cmbType->addItemsInGroup(_('Commercial'), array(MEDIA_TYPE_EZ_TEXTING => _('Ez Texting')));
$cmbTypeRow = array($cmbType);
if ($this->data['type'] == MEDIA_TYPE_EZ_TEXTING) {
    $ez_texting_link = new CLink('https://app.eztexting.com', 'https://app.eztexting.com/', null, null, 'nosid');
    $ez_texting_link->setTarget('_blank');
    $cmbTypeRow[] = $ez_texting_link;
}
$mediaTypeFormList->addRow(_('Type'), $cmbTypeRow);
// append others fields to form list
if ($this->data['type'] == MEDIA_TYPE_EMAIL) {
    $mediaTypeFormList->addRow(_('SMTP server'), new CTextBox('smtp_server', $this->data['smtp_server'], ZBX_TEXTBOX_STANDARD_SIZE));
    $mediaTypeFormList->addRow(_('SMTP helo'), new CTextBox('smtp_helo', $this->data['smtp_helo'], ZBX_TEXTBOX_STANDARD_SIZE));
    $mediaTypeFormList->addRow(_('SMTP email'), new CTextBox('smtp_email', $this->data['smtp_email'], ZBX_TEXTBOX_STANDARD_SIZE));
} elseif ($this->data['type'] == MEDIA_TYPE_SMS) {
    $mediaTypeFormList->addRow(_('GSM modem'), new CTextBox('gsm_modem', $this->data['gsm_modem'], ZBX_TEXTBOX_STANDARD_SIZE));
} elseif ($this->data['type'] == MEDIA_TYPE_EXEC) {
    $mediaTypeFormList->addRow(_('Script name'), new CTextBox('exec_path', $this->data['exec_path'], ZBX_TEXTBOX_STANDARD_SIZE));
} elseif ($this->data['type'] == MEDIA_TYPE_JABBER || $this->data['type'] == MEDIA_TYPE_EZ_TEXTING) {
    // create password field
function make_hint_row($type, $instance)
{
    $state = $instance['state'];
    if ($type == "other" && $instance["stuck_state"] == 1) {
        $state = "stuck";
    }
    $r = new CRow();
    if (in_array($type, array("poweron", "poweroff", "suspend"))) {
        $r->addItem(new CCheckBox("hostids[]", null, null, $instance['hostid']));
    }
    $hostScripts = API::Script()->getScriptsByHosts(zbx_objectValues(array($instance['host']), 'hostid'));
    $hostSpan = new CSpan(nbsp($instance['name']), 'link_menu menu-host');
    $hostSpan->setAttribute('data-menu', hostMenuData($instance['host'], $hostScripts[$instance['hostid']]));
    $r->addItem($hostSpan);
    $r->addItem(new CCol($state, get_item_level($state)));
    $r->addItem($instance['cpu']);
    $r->addItem($instance['memory']);
    $r->addItem($instance['main_interface']);
    if ($type == "other" && $instance["stuck_state"] == 1) {
        $question = $instance['stuck_question'];
        $json = new CJSON();
        $choiceinfos = $json->decode($instance['stuck_choices'], true);
        $answer_form = new CForm();
        $answer_form->setAction('#');
        $answer_form->setAttribute('id', "answer");
        $answer_form->addVar("driver", "vsphere");
        $answer_form->addVar("hostids[]", $instance['hostid']);
        $instancename = $instance['host']['host'];
        $answer_button = new CButton('answer', _('Answer'), "return checkAnswer('answer', 'choice', '{$instancename}', 'Execute');");
        $choice_table = new CTableInfo();
        foreach ($choiceinfos as $choice) {
            $radio = new CRadioButton('choice', $choice['key']);
            $label = new CLabel($choice['label']);
            $choice_table->addRow(new CRow(array($radio, $label)));
        }
        $answer_form->addItem($choice_table);
        $answer_form->addItem($answer_button);
        $question_span = new CSpan($question);
        $question_span->setHint($answer_form);
        $question_col = new CCol($question_span, 'warning');
        $r->addItem($question_col);
    } else {
        if ($type == "poweron") {
            $ssh_link = new CLink(_('connect'), "gateone.php?hostid={$instance['hostid']}");
            $ssh_link->setTarget("_blank");
            $r->addItem($ssh_link);
        }
    }
    return $r;
}
示例#25
0
 $sql_dep = 'SELECT * FROM trigger_depends WHERE triggerid_up=' . $row['triggerid'];
 $dep_res = DBselect($sql_dep);
 while ($dep_row = DBfetch($dep_res)) {
     $dep_table->addRow(SPACE . '-' . SPACE . expand_trigger_description($dep_row['triggerid_down']));
     $dependency = true;
 }
 if ($dependency) {
     $img = new Cimg('images/general/up_icon.png', 'DEP_UP');
     $img->setAttribute('style', 'vertical-align: middle; border: 0px;');
     $img->setHint($dep_table);
     $description = array($img, SPACE, $description);
 }
 unset($img, $dep_table, $dependency);
 //------------------------
 if (time(NULL) - $row['lastchange'] < TRIGGER_BLINK_PERIOD) {
     $tr_status = new CLink(trigger_value2str($row['value']));
     $tr_status->setAttribute('name', 'blink');
 } else {
     $tr_status = trigger_value2str($row['value']);
 }
 $value = new CSpan($tr_status, get_trigger_value_style($row['value']));
 if ($_REQUEST['show_actions']) {
     $actions = array(new CLink(S_CHANGE, 'triggers.php?form=update&triggerid=' . $row['triggerid'] . url_param('hostid'), 'action'));
 } else {
     $actions = NULL;
 }
 // JS menu
 $host = null;
 if ($_REQUEST['hostid'] < 1) {
     $menus = '';
     $host_nodeid = id2nodeid($row['hostid']);
示例#26
0
function insert_graph_form()
{
    $frmGraph = new CFormTable(S_GRAPH, null, 'post');
    $frmGraph->SetName('frm_graph');
    $frmGraph->SetHelp("web.graphs.graph.php");
    $frmGraph->SetMethod('post');
    $items = get_request('items', array());
    if (isset($_REQUEST['graphid'])) {
        $frmGraph->addVar('graphid', $_REQUEST['graphid']);
        $result = DBselect('SELECT * FROM graphs WHERE graphid=' . $_REQUEST['graphid']);
        $row = DBfetch($result);
        $frmGraph->SetTitle(S_GRAPH . ' "' . $row['name'] . '"');
    }
    if (isset($_REQUEST['graphid']) && !isset($_REQUEST['form_refresh'])) {
        $name = $row['name'];
        $width = $row['width'];
        $height = $row['height'];
        $ymin_type = $row["ymin_type"];
        $ymax_type = $row["ymax_type"];
        $yaxismin = $row['yaxismin'];
        $yaxismax = $row['yaxismax'];
        $ymin_itemid = $row["ymin_itemid"];
        $ymax_itemid = $row["ymax_itemid"];
        $showworkperiod = $row['show_work_period'];
        $showtriggers = $row['show_triggers'];
        $graphtype = $row['graphtype'];
        $legend = $row['show_legend'];
        $graph3d = $row['show_3d'];
        $percent_left = $row['percent_left'];
        $percent_right = $row['percent_right'];
        $db_items = DBselect('SELECT * FROM graphs_items WHERE graphid=' . $_REQUEST['graphid']);
        while ($item = DBfetch($db_items)) {
            array_push($items, array('itemid' => $item['itemid'], 'drawtype' => $item['drawtype'], 'sortorder' => $item['sortorder'], 'color' => $item['color'], 'yaxisside' => $item['yaxisside'], 'calc_fnc' => $item['calc_fnc'], 'type' => $item['type'], 'periods_cnt' => $item['periods_cnt']));
        }
    } else {
        $name = get_request('name', '');
        $graphtype = get_request('graphtype', GRAPH_TYPE_NORMAL);
        if ($graphtype == GRAPH_TYPE_PIE || $graphtype == GRAPH_TYPE_EXPLODED) {
            $width = get_request('width', 400);
            $height = get_request('height', 300);
        } else {
            $width = get_request('width', 900);
            $height = get_request('height', 200);
        }
        $ymin_type = get_request("ymin_type", GRAPH_YAXIS_TYPE_CALCULATED);
        $ymax_type = get_request("ymax_type", GRAPH_YAXIS_TYPE_CALCULATED);
        $yaxismin = get_request("yaxismin", 0.0);
        $yaxismax = get_request("yaxismax", 100.0);
        $ymin_itemid = get_request("ymin_itemid", 0);
        $ymax_itemid = get_request("ymax_itemid", 0);
        $showworkperiod = get_request('showworkperiod', 0);
        $showtriggers = get_request('showtriggers', 0);
        $legend = get_request('legend', 0);
        $graph3d = get_request('graph3d', 0);
        $visible = get_request('visible');
        $percent_left = 0;
        $percent_right = 0;
        if (isset($visible['percent_left'])) {
            $percent_left = get_request('percent_left', 0);
        }
        if (isset($visible['percent_right'])) {
            $percent_right = get_request('percent_right', 0);
        }
    }
    /* reinit $_REQUEST */
    $_REQUEST['items'] = $items;
    $_REQUEST['name'] = $name;
    $_REQUEST['width'] = $width;
    $_REQUEST['height'] = $height;
    $_REQUEST['ymin_type'] = $ymin_type;
    $_REQUEST['ymax_type'] = $ymax_type;
    $_REQUEST['yaxismin'] = $yaxismin;
    $_REQUEST['yaxismax'] = $yaxismax;
    $_REQUEST['ymin_itemid'] = $ymin_itemid;
    $_REQUEST['ymax_itemid'] = $ymax_itemid;
    $_REQUEST['showworkperiod'] = $showworkperiod;
    $_REQUEST['showtriggers'] = $showtriggers;
    $_REQUEST['graphtype'] = $graphtype;
    $_REQUEST['legend'] = $legend;
    $_REQUEST['graph3d'] = $graph3d;
    $_REQUEST['percent_left'] = $percent_left;
    $_REQUEST['percent_right'] = $percent_right;
    /********************/
    if ($graphtype != GRAPH_TYPE_NORMAL) {
        foreach ($items as $gid => $gitem) {
            if ($gitem['type'] != GRAPH_ITEM_AGGREGATED) {
                continue;
            }
            unset($items[$gid]);
        }
    }
    asort_by_key($items, 'sortorder');
    $group_gid = get_request('group_gid', array());
    $frmGraph->addVar('ymin_itemid', $ymin_itemid);
    $frmGraph->addVar('ymax_itemid', $ymax_itemid);
    $frmGraph->addRow(S_NAME, new CTextBox('name', $name, 32));
    $g_width = new CNumericBox('width', $width, 5);
    $g_width->addoption('onblur', 'javascript: submit();');
    $frmGraph->addRow(S_WIDTH, $g_width);
    $g_height = new CNumericBox('height', $height, 5);
    $g_height->addoption('onblur', 'javascript: submit();');
    $frmGraph->addRow(S_HEIGHT, $g_height);
    $cmbGType = new CComboBox('graphtype', $graphtype, 'graphs.submit(this)');
    $cmbGType->addItem(GRAPH_TYPE_NORMAL, S_NORMAL);
    $cmbGType->addItem(GRAPH_TYPE_STACKED, S_STACKED);
    $cmbGType->addItem(GRAPH_TYPE_PIE, S_PIE);
    $cmbGType->addItem(GRAPH_TYPE_EXPLODED, S_EXPLODED);
    zbx_add_post_js('graphs.graphtype = ' . $graphtype . ";\n");
    $frmGraph->addRow(S_GRAPH_TYPE, $cmbGType);
    if ($graphtype == GRAPH_TYPE_NORMAL || $graphtype == GRAPH_TYPE_STACKED) {
        $frmGraph->addRow(S_SHOW_WORKING_TIME, new CCheckBox('showworkperiod', $showworkperiod, null, 1));
        $frmGraph->addRow(S_SHOW_TRIGGERS, new CCheckBox('showtriggers', $showtriggers, null, 1));
        if ($graphtype == GRAPH_TYPE_NORMAL) {
            $percent_left = sprintf("%2.2f", $percent_left);
            $percent_right = sprintf("%2.2f", $percent_right);
            $pr_left_input = new CTextBox('percent_left', $percent_left, '5');
            $pr_left_chkbx = new CCheckBox('visible[percent_left]', 1, "javascript: ShowHide('percent_left');", 1);
            if ($percent_left == 0) {
                $pr_left_input->addOption('style', 'display: none;');
                $pr_left_chkbx->SetChecked(0);
            }
            $pr_right_input = new CTextBox('percent_right', $percent_right, '5');
            $pr_right_chkbx = new CCheckBox('visible[percent_right]', 1, "javascript: ShowHide('percent_right');", 1);
            if ($percent_right == 0) {
                $pr_right_input->addOption('style', 'display: none;');
                $pr_right_chkbx->SetChecked(0);
            }
            $frmGraph->addRow(S_PERCENTILE_LINE . ' (' . S_LEFT . ')', array($pr_left_chkbx, $pr_left_input));
            $frmGraph->addRow(S_PERCENTILE_LINE . ' (' . S_RIGHT . ')', array($pr_right_chkbx, $pr_right_input));
        }
        $yaxis_min = array();
        $cmbYType = new CComboBox('ymin_type', $ymin_type, 'javascript: submit();');
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_CALCULATED, S_CALCULATED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_FIXED, S_FIXED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, S_ITEM);
        $yaxis_min[] = $cmbYType;
        if ($ymin_type == GRAPH_YAXIS_TYPE_FIXED) {
            $yaxis_min[] = new CTextBox("yaxismin", $yaxismin, 9);
        } else {
            if ($ymin_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
                $frmGraph->addVar('yaxismin', $yaxismin);
                $ymin_name = '';
                if ($ymin_itemid > 0) {
                    $min_host = get_host_by_itemid($ymin_itemid);
                    $min_item = get_item_by_itemid($ymin_itemid);
                    $ymin_name = $min_host['host'] . ':' . item_description($min_item);
                }
                $yaxis_min[] = new CTextBox("ymin_name", $ymin_name, 80, 'yes');
                $yaxis_min[] = new CButton('yaxis_min', S_SELECT, 'javascript: ' . "return PopUp('popup.php?dstfrm=" . $frmGraph->getName() . "&dstfld1=ymin_itemid" . "&dstfld2=ymin_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');");
            } else {
                $frmGraph->addVar('yaxismin', $yaxismin);
            }
        }
        $frmGraph->addRow(S_YAXIS_MIN_VALUE, $yaxis_min);
        $yaxis_max = array();
        $cmbYType = new CComboBox("ymax_type", $ymax_type, "submit()");
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_CALCULATED, S_CALCULATED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_FIXED, S_FIXED);
        $cmbYType->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, S_ITEM);
        $yaxis_max[] = $cmbYType;
        if ($ymax_type == GRAPH_YAXIS_TYPE_FIXED) {
            $yaxis_max[] = new CTextBox("yaxismax", $yaxismax, 9);
        } else {
            if ($ymax_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
                $frmGraph->addVar('yaxismax', $yaxismax);
                $ymax_name = '';
                if ($ymax_itemid > 0) {
                    $max_host = get_host_by_itemid($ymax_itemid);
                    $max_item = get_item_by_itemid($ymax_itemid);
                    $ymax_name = $max_host['host'] . ':' . item_description($max_item);
                }
                $yaxis_max[] = new CTextBox("ymax_name", $ymax_name, 80, 'yes');
                $yaxis_max[] = new CButton('yaxis_max', S_SELECT, 'javascript: ' . "return PopUp('popup.php?dstfrm=" . $frmGraph->getName() . "&dstfld1=ymax_itemid" . "&dstfld2=ymax_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');");
            } else {
                $frmGraph->addVar('yaxismax', $yaxismax);
            }
        }
        $frmGraph->addRow(S_YAXIS_MAX_VALUE, $yaxis_max);
    } else {
        $frmGraph->addRow(S_3D_VIEW, new CCheckBox('graph3d', $graph3d, 'javascript: graphs.submit(this);', 1));
        $frmGraph->addRow(S_LEGEND, new CCheckBox('legend', $legend, 'javascript: graphs.submit(this);', 1));
    }
    $only_hostid = null;
    $monitored_hosts = null;
    if (count($items)) {
        $frmGraph->addVar('items', $items);
        $items_table = new CTableInfo();
        foreach ($items as $gid => $gitem) {
            if ($graphtype == GRAPH_TYPE_STACKED && $gitem['type'] == GRAPH_ITEM_AGGREGATED) {
                continue;
            }
            $host = get_host_by_itemid($gitem['itemid']);
            $item = get_item_by_itemid($gitem['itemid']);
            if ($host['status'] == HOST_STATUS_TEMPLATE) {
                $only_hostid = $host['hostid'];
            } else {
                $monitored_hosts = 1;
            }
            if ($gitem['type'] == GRAPH_ITEM_AGGREGATED) {
                $color = '-';
            } else {
                $color = new CColorCell(null, $gitem['color']);
            }
            $do_up = new CLink(S_UP, '#', 'action');
            $do_up->OnClick("return create_var('" . $frmGraph->GetName() . "','move_up'," . $gid . ", true);");
            $do_down = new CLink(S_DOWN, '#', 'action');
            $do_down->OnClick("return create_var('" . $frmGraph->GetName() . "','move_down'," . $gid . ", true);");
            $description = new CLink($host['host'] . ': ' . item_description($item), '#', 'action');
            $description->OnClick('return PopUp("popup_gitem.php?list_name=items&dstfrm=' . $frmGraph->GetName() . url_param($only_hostid, false, 'only_hostid') . url_param($monitored_hosts, false, 'monitored_hosts') . url_param($graphtype, false, 'graphtype') . url_param($gitem, false) . url_param($gid, false, 'gid') . url_param(get_request('graphid', 0), false, 'graphid') . '",550,400,"graph_item_form");');
            if ($graphtype == GRAPH_TYPE_PIE || $graphtype == GRAPH_TYPE_EXPLODED) {
                $items_table->addRow(array(new CCheckBox('group_gid[' . $gid . ']', isset($group_gid[$gid])), $gitem['sortorder'], $description, graph_item_calc_fnc2str($gitem["calc_fnc"], $gitem["type"]), graph_item_type2str($gitem['type'], $gitem["periods_cnt"]), $color, array($do_up, SPACE . "|" . SPACE, $do_down)));
            } else {
                $items_table->addRow(array(new CCheckBox('group_gid[' . $gid . ']', isset($group_gid[$gid])), $gitem['sortorder'], $description, graph_item_calc_fnc2str($gitem["calc_fnc"], $gitem["type"]), graph_item_type2str($gitem['type'], $gitem["periods_cnt"]), graph_item_drawtype2str($gitem["drawtype"], $gitem["type"]), $color, array($do_up, SPACE . "|" . SPACE, $do_down)));
            }
        }
        $dedlete_button = new CButton('delete_item', S_DELETE_SELECTED);
    } else {
        $items_table = $dedlete_button = null;
    }
    $frmGraph->addRow(S_ITEMS, array($items_table, new CButton('add_item', S_ADD, "return PopUp('popup_gitem.php?dstfrm=" . $frmGraph->GetName() . url_param($only_hostid, false, 'only_hostid') . url_param($monitored_hosts, false, 'monitored_hosts') . url_param($graphtype, false, 'graphtype') . "',550,400,'graph_item_form');"), $dedlete_button));
    unset($items_table, $dedlete_button);
    $frmGraph->addItemToBottomRow(new CButton("save", S_SAVE));
    if (isset($_REQUEST["graphid"])) {
        $frmGraph->addItemToBottomRow(SPACE);
        $frmGraph->addItemToBottomRow(new CButton("clone", S_CLONE));
        $frmGraph->addItemToBottomRow(SPACE);
        $frmGraph->addItemToBottomRow(new CButtonDelete(S_DELETE_GRAPH_Q, url_param("graphid") . url_param('groupid') . url_param("hostid")));
    }
    $frmGraph->addItemToBottomRow(SPACE);
    $frmGraph->addItemToBottomRow(new CButtonCancel(url_param('groupid') . url_param("hostid")));
    $frmGraph->Show();
}
// append dependencies to form list
if (empty($this->data['parent_discoveryid'])) {
    $dependenciesTable = new CTable(_('No dependencies defined.'), 'formElementTable');
    $dependenciesTable->setAttribute('style', 'min-width: 500px;');
    $dependenciesTable->setAttribute('id', 'dependenciesTable');
    $dependenciesTable->setHeader(array(_('Name'), _('Action')));
    foreach ($this->data['dependencies'] as $dependency) {
        $triggersForm->addVar('dependencies[]', $dependency['triggerid'], 'dependencies_' . $dependency['triggerid']);
        $hostNames = array();
        foreach ($dependency['hosts'] as $host) {
            $hostNames[] = CHtml::encode($host['name']);
            $hostNames[] = ', ';
        }
        array_pop($hostNames);
        if ($dependency['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
            $description = new CLink(array($hostNames, NAME_DELIMITER, CHtml::encode($dependency['description'])), 'triggers.php?form=update&hostid=' . $dependency['hostid'] . '&triggerid=' . $dependency['triggerid']);
            $description->setAttribute('target', '_blank');
        } else {
            $description = array($hostNames, NAME_DELIMITER, $dependency['description']);
        }
        $row = new CRow(array($description, new CButton('remove', _('Remove'), 'javascript: removeDependency(\'' . $dependency['triggerid'] . '\');', 'link_menu')));
        $row->setAttribute('id', 'dependency_' . $dependency['triggerid']);
        $dependenciesTable->addRow($row);
    }
    $dependenciesDiv = new CDiv(array($dependenciesTable, new CButton('btn1', _('Add'), 'return PopUp("popup.php?' . 'dstfrm=massupdate' . '&dstact=add_dependency' . '&reference=deptrigger' . '&dstfld1=new_dependency' . '&srctbl=triggers' . '&objname=triggers' . '&srcfld1=triggerid' . '&multiselect=1' . '&with_triggers=1", 1000, 700);', 'link_menu')), 'objectgroup inlineblock border_dotted ui-corner-all');
    $dependenciesDiv->setAttribute('id', 'dependencies_div');
    $triggersFormList->addRow(array(_('Replace dependencies'), SPACE, new CVisibilityBox('visible[dependencies]', isset($this->data['visible']['dependencies']), 'dependencies_div', _('Original'))), $dependenciesDiv);
}
// append tabs to form
$triggersTab = new CTabView();
$triggersTab->addTab('triggersTab', _('Mass update'), $triggersFormList);
示例#28
0
<?php

/* FILES $Id: do_link_aed.php 6149 2012-01-09 11:58:40Z ajdonnison $ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
//addlink sql
$link_id = intval(dPgetParam($_POST, 'link_id', 0));
$del = intval(dPgetParam($_POST, 'del', 0));
$not = (int) dPgetParam($_POST, 'notify', '0');
if ($not != '0') {
    $not = '1';
}
$obj = new CLink();
if ($link_id) {
    $obj->_message = 'updated';
} else {
    $obj->_message = 'added';
}
$obj->link_date = date('Y-m-d H:i:s');
$obj->link_category = intval(dPgetParam($_POST, 'link_category', 0));
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
// prepare (and translate) the module name ready for the suffix
$AppUI->setMsg('Link');
// delete the link
if ($del) {
    $obj->load($link_id);
    if ($msg = $obj->delete()) {
示例#29
0
<?php 
    if (isset($page['scripts']) && is_array($page['scripts'])) {
        foreach ($page['scripts'] as $id => $script) {
            print '    <script type="text/javascript" src="js/' . $script . '"></script>' . "\n";
        }
    }
    ?>
</head>
<body onload="zbxCallPostScripts();">
<?php 
}
define('PAGE_HEADER_LOADED', 1);
if (isset($_REQUEST['print'])) {
    define('ZBX_PAGE_NO_MENU', 1);
    $req = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'print') - 1);
    $link = new CLink(bold('&laquo;' . S_BACK_BIG), $req, 'small_font');
    $link->setAttribute('style', 'padding-left: 10px;');
    $printview = new CDiv($link, 'printless');
    $printview->setAttribute('style', 'border: 1px #333 dotted;');
    $printview->Show();
}
if (!defined('ZBX_PAGE_NO_MENU')) {
    COpt::compare_files_with_menu($ZBX_MENU);
    $help = new CLink(S_HELP, 'http://www.zabbix.com/documentation.php', 'small_font', null, 'nosid');
    $help->setTarget('_blank');
    $support = new CLink(S_GET_SUPPORT, 'http://www.zabbix.com/support.php', 'small_font', null, 'nosid');
    $support->setTarget('_blank');
    $printview = new CLink(S_PRINT, $_SERVER['REQUEST_URI'] . (empty($_GET) ? '?' : '&') . 'print=1', 'small_font', null, 'nosid');
    $page_header_r_col = array($help, '|', $support, '|', $printview);
    if ($USER_DETAILS['alias'] != ZBX_GUEST_USER) {
        $page_header_r_col[] = array('|');
示例#30
0
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $this->dataId = 'graph_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid'];
     $resourceId = isset($this->screenitem['real_resourceid']) ? $this->screenitem['real_resourceid'] : $this->screenitem['resourceid'];
     $containerId = 'graph_container_' . $this->screenitem['screenitemid'] . '_' . $this->screenitem['screenid'];
     $graphDims = getGraphDims($resourceId);
     $graphDims['graphHeight'] = $this->screenitem['height'];
     $graphDims['width'] = $this->screenitem['width'];
     $graph = getGraphByGraphId($resourceId);
     $graphId = $graph['graphid'];
     $legend = $graph['show_legend'];
     $graph3d = $graph['show_3d'];
     if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && $this->hostid) {
         // get host
         $hosts = API::Host()->get(['hostids' => $this->hostid, 'output' => ['hostid', 'name']]);
         $host = reset($hosts);
         // get graph
         $graph = API::Graph()->get(['graphids' => $resourceId, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => ['hostid'], 'selectGraphItems' => API_OUTPUT_EXTEND]);
         $graph = reset($graph);
         // if items from one host we change them, or set calculated if not exist on that host
         if (count($graph['hosts']) == 1) {
             if ($graph['ymax_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymax_itemid']) {
                 $newDynamic = getSameGraphItemsForHost([['itemid' => $graph['ymax_itemid']]], $this->hostid, false);
                 $newDynamic = reset($newDynamic);
                 if (isset($newDynamic['itemid']) && $newDynamic['itemid'] > 0) {
                     $graph['ymax_itemid'] = $newDynamic['itemid'];
                 } else {
                     $graph['ymax_type'] = GRAPH_YAXIS_TYPE_CALCULATED;
                 }
             }
             if ($graph['ymin_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymin_itemid']) {
                 $newDynamic = getSameGraphItemsForHost([['itemid' => $graph['ymin_itemid']]], $this->hostid, false);
                 $newDynamic = reset($newDynamic);
                 if (isset($newDynamic['itemid']) && $newDynamic['itemid'] > 0) {
                     $graph['ymin_itemid'] = $newDynamic['itemid'];
                 } else {
                     $graph['ymin_type'] = GRAPH_YAXIS_TYPE_CALCULATED;
                 }
             }
         }
         // get url
         $this->screenitem['url'] = $graph['graphtype'] == GRAPH_TYPE_PIE || $graph['graphtype'] == GRAPH_TYPE_EXPLODED ? 'chart7.php' : 'chart3.php';
         $this->screenitem['url'] = new CUrl($this->screenitem['url']);
         foreach ($graph as $name => $value) {
             if ($name == 'width' || $name == 'height') {
                 continue;
             }
             $this->screenitem['url']->setArgument($name, $value);
         }
         $newGraphItems = getSameGraphItemsForHost($graph['gitems'], $this->hostid, false);
         foreach ($newGraphItems as $newGraphItem) {
             unset($newGraphItem['gitemid'], $newGraphItem['graphid']);
             foreach ($newGraphItem as $name => $value) {
                 $this->screenitem['url']->setArgument('items[' . $newGraphItem['itemid'] . '][' . $name . ']', $value);
             }
         }
         $this->screenitem['url']->setArgument('name', $host['name'] . NAME_DELIMITER . $graph['name']);
         $this->screenitem['url'] = $this->screenitem['url']->getUrl();
     }
     // get time control
     $timeControlData = ['id' => $this->getDataId(), 'containerid' => $containerId, 'objDims' => $graphDims, 'loadSBox' => 0, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.screens.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD];
     $isDefault = false;
     if ($graphDims['graphtype'] == GRAPH_TYPE_PIE || $graphDims['graphtype'] == GRAPH_TYPE_EXPLODED) {
         if ($this->screenitem['dynamic'] == SCREEN_SIMPLE_ITEM || $this->screenitem['url'] === '') {
             $this->screenitem['url'] = 'chart6.php?graphid=' . $resourceId . '&screenid=' . $this->screenitem['screenid'];
             $isDefault = true;
         }
         $this->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_graphid($resourceId));
         $timeControlData['src'] = $this->screenitem['url'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] . '&legend=' . $legend . '&graph3d=' . $graph3d . $this->getProfileUrlParams();
         $timeControlData['src'] .= $this->mode == SCREEN_MODE_EDIT ? '&period=3600&stime=' . date(TIMESTAMP_FORMAT, time()) : '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'];
     } else {
         if ($this->screenitem['dynamic'] == SCREEN_SIMPLE_ITEM || $this->screenitem['url'] === '') {
             $this->screenitem['url'] = 'chart2.php?graphid=' . $resourceId . '&screenid=' . $this->screenitem['screenid'];
             $isDefault = true;
         }
         if ($this->mode != SCREEN_MODE_EDIT && $graphId) {
             if ($this->mode == SCREEN_MODE_PREVIEW) {
                 $timeControlData['loadSBox'] = 1;
             }
         }
         $timeControlData['src'] = $this->screenitem['url'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] . '&legend=' . $legend . $this->getProfileUrlParams();
         $timeControlData['src'] .= $this->mode == SCREEN_MODE_EDIT ? '&period=3600&stime=' . date(TIMESTAMP_FORMAT, time()) : '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow'];
     }
     // output
     if ($this->mode == SCREEN_MODE_JS) {
         return 'timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ')';
     } else {
         if ($this->mode == SCREEN_MODE_SLIDESHOW) {
             insert_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');');
         } else {
             zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');');
         }
         if ($this->mode == SCREEN_MODE_EDIT || $this->mode == SCREEN_MODE_SLIDESHOW || !$isDefault) {
             $item = new CDiv();
         } elseif ($this->mode == SCREEN_MODE_PREVIEW) {
             $item = new CLink(null, 'charts.php?graphid=' . $resourceId . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stimeNow']);
         }
         $item->setId($containerId);
         return $this->getOutput($item);
     }
 }