Example #1
0
function AW($f)
{
    if (AD($f, 'I') !== AI) {
        if (BA($f, 1, 2) == 'BB') {
            $g = $f;
        } else {
            $g = 'BB' . $f;
        }
    } elseif (AD($f, 'BE') !== AI) {
        $g = 'BB' . H('BE', 'I', $f);
    } elseif (AD($f, 'BE') === AI) {
        P::Q();
        $h = P::$c->BQ($f);
        if (BR($h) == 1) {
            return AI;
        } elseif (BR($h) == 3) {
            $g = $h[1];
        } else {
            return AI;
        }
    } else {
        $g = $f;
    }
    if (BV($g)) {
        $i = new \BW($g);
        if ($g != $i->BX()) {
            return AI;
        } else {
            return $g;
        }
    } else {
        return AI;
    }
}
Example #2
0
function show_report2_header($config, &$PAGE_GROUPS, &$PAGE_HOSTS)
{
    global $USER_DETAILS;
    $available_groups = $PAGE_GROUPS['groupids'];
    $available_hosts = $PAGE_HOSTS['hostids'];
    //	$available_groups = $PAGE_GROUPS['groupids'];
    //	$available_hosts = $PAGE_HOSTS['hostids'];
    $r_form = new CForm();
    $r_form->setMethod('get');
    $cmbConf = new CComboBox('config', $config, 'submit()');
    $cmbConf->addItem(0, S_BY_HOST);
    $cmbConf->addItem(1, S_BY_TRIGGER_TEMPLATE);
    $r_form->addItem(array(S_MODE . SPACE, $cmbConf, SPACE));
    $cmbGroups = new CComboBox('groupid', $PAGE_GROUPS['selected'], 'javascript: submit();');
    $cmbHosts = new CComboBox('hostid', $PAGE_HOSTS['selected'], 'javascript: submit();');
    foreach ($PAGE_GROUPS['groups'] as $groupid => $name) {
        $cmbGroups->addItem($groupid, get_node_name_by_elid($groupid) . $name);
    }
    foreach ($PAGE_HOSTS['hosts'] as $hostid => $name) {
        $cmbHosts->addItem($hostid, get_node_name_by_elid($hostid) . $name);
    }
    $r_form->addItem(array(S_GROUP . SPACE, $cmbGroups));
    $r_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts));
    if (1 == $config) {
        $cmbTrigs = new CComboBox('tpl_triggerid', get_request('tpl_triggerid', 0), 'submit()');
        $cmbHGrps = new CComboBox('hostgroupid', get_request('hostgroupid', 0), 'submit()');
        $cmbTrigs->addItem(0, S_ALL_SMALL);
        $cmbHGrps->addItem(0, S_ALL_SMALL);
    }
    if (0 == $config) {
        show_table_header(S_AVAILABILITY_REPORT_BIG, $r_form);
    } else {
        $sql_cond = ' AND h.hostid=ht.hostid ';
        if ($_REQUEST['hostid'] > 0) {
            $sql_cond .= ' AND ht.templateid=' . $_REQUEST['hostid'];
        }
        if (isset($_REQUEST['tpl_triggerid']) && $_REQUEST['tpl_triggerid'] > 0) {
            $sql_cond .= ' AND t.templateid=' . $_REQUEST['tpl_triggerid'];
        }
        $result = DBselect('SELECT DISTINCT g.groupid,g.name ' . ' FROM triggers t,hosts h,items i,functions f, hosts_templates ht, groups g, hosts_groups hg ' . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid' . ' AND g.groupid=hg.groupid ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND t.triggerid=f.triggerid ' . ' AND ' . DBin_node('t.triggerid') . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND h.status=' . HOST_STATUS_MONITORED . $sql_cond . ' ORDER BY g.name');
        while ($row = DBfetch($result)) {
            $cmbHGrps->addItem($row['groupid'], get_node_name_by_elid($row['groupid']) . $row['name']);
        }
        $sql_cond = $_REQUEST['hostid'] > 0 ? ' AND h.hostid=' . $_REQUEST['hostid'] : ' AND ' . DBcondition('h.hostid', $available_hosts);
        $sql = 'SELECT DISTINCT t.triggerid,t.description ' . ' FROM triggers t,hosts h,items i,functions f ' . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND t.triggerid=f.triggerid ' . ' AND h.status=' . HOST_STATUS_TEMPLATE . ' AND ' . DBin_node('t.triggerid') . ' AND i.status=' . ITEM_STATUS_ACTIVE . $sql_cond . ' ORDER BY t.description';
        $result = DBselect($sql);
        while ($row = DBfetch($result)) {
            $cmbTrigs->addItem($row['triggerid'], get_node_name_by_elid($row['triggerid']) . expand_trigger_description($row['triggerid']));
        }
        $rr_form = new CForm();
        $rr_form->setMethod('get');
        $rr_form->addVar('config', $config);
        $rr_form->addVar('groupid', $_REQUEST['groupid']);
        $rr_form->addVar('hostid', $_REQUEST['hostid']);
        $rr_form->addItem(array(S_TRIGGER . SPACE, $cmbTrigs, BR(), S_FILTER, SPACE, S_HOST_GROUP . SPACE, $cmbHGrps));
        show_table_header(S_AVAILABILITY_REPORT_BIG, array($r_form, $rr_form));
    }
}
Example #3
0
 public function get($caption_l = null, $caption_r = null)
 {
     if (empty($caption_l)) {
         $caption_l = _('In');
     }
     if (empty($caption_r)) {
         $caption_r = _('Other');
     }
     $grp_tab = (new CTable())->addClass('tweenBoxTable')->setAttribute('name', $this->name)->setId('id', zbx_formatDomId($this->name))->setCellSpacing(0)->setCellPadding(0);
     if (!is_null($caption_l) || !is_null($caption_r)) {
         $grp_tab->addRow([$caption_l, '', $caption_r]);
     }
     $add_btn = (new CButton('add', (new CSpan())->addClass('arrow-left')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('moveListBoxSelectedItem("' . $this->varname . '", "' . $this->id_r . '", "' . $this->id_l . '", "add");');
     $rmv_btn = (new CButton('remove', (new CSpan())->addClass('arrow-right')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('moveListBoxSelectedItem("' . $this->varname . '", "' . $this->id_l . '", "' . $this->id_r . '", "rmv");');
     $grp_tab->addRow([$this->lbox, (new CCol([$add_btn, BR(), $rmv_btn]))->addClass(ZBX_STYLE_CENTER), $this->rbox]);
     return $grp_tab;
 }
Example #4
0
    public function index()
    {
        SubMenu('系统升级');
        $available = 0;
        if (file_exists($this->update_path . 'upgrade.php') and file_exists($this->update_path . 'version.php')) {
            $available = 1;
        }
        ShowTips('<ul><li>请严格按升级说明进行系统升级, 升级说明一般随附在升级包中.</li>
		<li>升级过程一般是先将升级包解压后, 设置FTP工具以 <span class=note>二进制方式</span> 上传到网站替换原文件, 然后在后台运行升级程序.</li>
		<li>安全建议: <span class=note>升级完成后删除upgrade目录下的所有文件</span>.</li>
		</ul>', '升级提示');
        BR(2);
        TableHeader('升级操作');
        if ($available) {
            include $this->update_path . 'version.php';
            $new = str_replace('.', '', $NewVersion);
            $old = str_replace('.', '', APP_VERSION);
            if (intval($new) <= intval($old)) {
                $output = '<font class=red>您现在正在使用的版本高于或等于升级程序中的版本, 无需升级!</font><BR>';
            } else {
                $output = '<form><input type="submit" value="运行升级程序" class="save" id="doupgrade"></form>';
            }
            TableRow(array('当前使用中的版本是: <span id="version">' . APP_VERSION . '</span>', '正要升级到的版本是: <font class=red>' . $NewVersion . '</font>'));
            TableRow("<center><br>{$output}<br></center>");
        } else {
            TableRow('<center><br><br><b><span class=note>暂无可用的升级程序!</span></b><br><br><br></center>');
        }
        TableFooter();
        echo '<script type="text/javascript">
			$(function(){
				$("#doupgrade").click(function(e){
					var _me=$(this);

					showDialog("确定运行升级程序吗?<BR>建议在升级前备份网站数据.", "确认操作", function(){
						ajax("' . BURL('upgrade/ajax') . '", {}, function(data){
							$("#version").html("' . $NewVersion . '");
							_me.parent().parent().html("<br><font class=blueb>升级已完成!</font><br><br>");
						});
					});

					e.preventDefault();
				});
			});
		</script>';
    }
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $image = new CImg('map.php?noedit=1&sysmapid=' . $this->screenitem['resourceid'] . '&width=' . $this->screenitem['width'] . '&height=' . $this->screenitem['height'] . '&curtime=' . time());
     $image->setAttribute('id', 'map_' . $this->screenitem['screenitemid']);
     if ($this->mode == SCREEN_MODE_PREVIEW) {
         $sysmap = API::Map()->get(array('sysmapids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'selectSelements' => API_OUTPUT_EXTEND, 'selectLinks' => API_OUTPUT_EXTEND, 'expandUrls' => true, 'nopermissions' => true, 'preservekeys' => true));
         $sysmap = reset($sysmap);
         $actionMap = getActionMapBySysmap($sysmap);
         $image->setMap($actionMap->getName());
         $output = array($actionMap, $image);
     } elseif ($this->mode == SCREEN_MODE_EDIT) {
         $output = array($image, BR(), new CLink(_('Change'), $this->action));
     } else {
         $output = array($image);
     }
     $this->insertFlickerfreeJs();
     $div = new CDiv($output, 'map-container flickerfreescreen', $this->getScreenId());
     $div->setAttribute('data-timestamp', $this->timestamp);
     $div->addStyle('position: relative;');
     return $div;
 }
Example #6
0
    function index($path)
    {
        //获取统计数据
        $comms = APP::$DB->getOne("SELECT COUNT(cid) AS nums FROM " . TABLE_PREFIX . "comment WHERE readed = 0");
        SubMenu('欢迎进入 ' . APP_NAME . ' 管理中心', array(array('查看留言', 'comments'), array('管理客人', 'guests'), array('管理记录', 'messages'), array('管理客服', 'users')));
        $welcome = '<ul><li>欢迎 <font class=orange>' . $this->admin['fullname'] . '</font> 进入后台管理面板! 为了确保系统安全, 请在关闭前点击 <a href="#" class="logout">退出</a> 安全离开!</li>
		<li>隐私保护: <span class="note2">' . APP_NAME . '[商业版] 郑重承诺, 您在使用本系统时, WeLive开发商不会收集您的任何信息</span>.</li>
		<li>您在使用 ' . APP_NAME . '[商业版] 时有任何问题, 请访问: <a href="http://bbs.iimei.com//" target="_blank">我美网BBS</a>!</li></ul>';
        ShowTips($welcome, '系统信息');
        BR(2);
        TableHeader('客服操作技巧说明');
        TableRow('<font class=grey>1)</font>&nbsp;&nbsp;将代码 <span class=note>&lt;script type="text/javascript" charset="UTF-8" src="' . BASEURL . 'welive.js"&gt;&lt;/script&gt;</span> 插入网页代码的&lt;head&gt;&lt;/head&gt;内来调用(显示)客服小面板.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp任意网站、任何编码格式的页面均可调用, 包括淘宝, ECShop等商城系统. <span class=note>请勿修改版权, 修改版权将导致无法使用!</span>');
        TableRow('<font class=grey>2)</font>&nbsp;&nbsp;客服窗口中, 按 Ctrl + Alt, 在客服交流区与当前客人小窗口间切换.');
        TableRow('<font class=grey>3)</font>&nbsp;&nbsp;客服窗口中, 按 Ctrl + 下箭头 或 Esc键, 关闭当前客人小窗口. 如果小窗口都关闭了, 自动切换到客服交流区.');
        TableRow('<font class=grey>4)</font>&nbsp;&nbsp;客服窗口中, 按 Ctrl + 上箭头, 展开关闭的客人小窗口.');
        TableRow('<font class=grey>5)</font>&nbsp;&nbsp;客服窗口中, 按 Ctrl + 左或右箭头, 在已展开的客人小窗口间切换.');
        TableRow('<font class=grey>6)</font>&nbsp;&nbsp;客服窗口中, 客人被踢出或禁言后, 刷新页面仍可重新进入客服, 即此两项操作仅作用于当前对话.');
        TableRow('<font class=grey>7)</font>&nbsp;&nbsp;WeLive默认安装后, 前台客服小面板不会自动展开, 即不会进入客服. 如何希望自动展开, 可打开根目录下的welive.js文件, 修改 <span class=note>welive_auto=0</span> 代码中的0为N秒.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp那么, 当用户浏览器打开页面并停留N秒后, 客服小面板将自动展开, 即进入客服. 如果无客服在线, 将自动显示留言板.');
        TableRow('<font class=grey>8)</font>&nbsp;&nbsp;在客服窗口中的客服交流区, 管理员可发送特殊指令: system die --- Socket服务将中止(<span class=note>慎用</span>);&nbsp;&nbsp;all --- 显示所有连接数;&nbsp;&nbsp;admin --- 显示所有客服及其客人数;&nbsp;&nbsp;guest --- 显示客人数');
        TableFooter();
        $info_total = $comms['nums'];
        //更新顶部提示信息
        echo '<script type="text/javascript">
			$(function(){
				var info_total = ' . $info_total . ';

				if(info_total > 0){
					$("#topuser dl#info_all").removeClass("none");
					$("#topuser #info_total").html(info_total);
					$("#topuser #info_comms").html(info_total).attr("class", "orangeb");

				}

				//将统计数据保存为cookie. 注: header已发送, 此页面不能使用php保存cookie
				setCookie("' . COOKIE_KEY . 'backinfos", info_total, 365);
			});
		</script>';
    }
 public function get($caption_l = null, $caption_r = null)
 {
     if (empty($caption_l)) {
         $caption_l = _('In');
     }
     if (empty($caption_r)) {
         $caption_r = _('Other');
     }
     $grp_tab = new CTable();
     $grp_tab->attr('name', $this->name);
     $grp_tab->attr('id', zbx_formatDomId($this->name));
     $grp_tab->setCellSpacing(0);
     $grp_tab->setCellPadding(0);
     if (!is_null($caption_l) || !is_null($caption_r)) {
         $grp_tab->addRow(array($caption_l, SPACE, $caption_r));
     }
     $add_btn = new CButton('add', ' &laquo; ', null, 'formlist');
     $add_btn->setAttribute('onclick', 'javascript: moveListBoxSelectedItem("' . $this->form->getName() . '", "' . $this->varname . '", "' . $this->id_r . '", "' . $this->id_l . '", "add");');
     $rmv_btn = new CButton('remove', ' &raquo; ', null, 'formlist');
     $rmv_btn->setAttribute('onclick', 'javascript: moveListBoxSelectedItem("' . $this->form->getName() . '", "' . $this->varname . '", "' . $this->id_l . '", "' . $this->id_r . '", "rmv");');
     $grp_tab->addRow(array($this->lbox, new CCol(array($add_btn, BR(), $rmv_btn), 'top'), $this->rbox));
     return $grp_tab;
 }
Example #8
0
//HOSTS
// SPACE added to extend CB width in Chrome
$cbMain = new CCheckBox('maintenance', $maintenance, null, '1');
if (!$filterEnable) {
    $cbMain->setAttribute('disabled', 'disabled');
}
$dashForm->addRow(S_HOSTS, array($cbMain, S_SHOW_HOSTS_IN_MAINTENANCE));
// Trigger
$severity = zbx_toHash($severity);
$trgSeverities = array();
$severities = array(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER);
foreach ($severities as $snum => $sever) {
    $cb = new CCheckBox('trgSeverity[' . $sever . ']', isset($severity[$sever]), '', 1);
    $cb->setEnabled($filterEnable);
    $trgSeverities[] = array($cb, getSeverityCaption($sever));
    $trgSeverities[] = BR();
}
array_pop($trgSeverities);
$dashForm->addRow(S_TRIGGERS_WITH_SEVERITY, $trgSeverities);
$config = select_config();
$cb = new CComboBox('extAck', $extAck);
$cb->addItems(array(EXTACK_OPTION_ALL => S_O_ALL, EXTACK_OPTION_BOTH => S_O_SEPARATED, EXTACK_OPTION_UNACK => S_O_UNACKNOWLEDGED_ONLY));
$cb->setEnabled($filterEnable && $config['event_ack_enable']);
if (!$config['event_ack_enable']) {
    $cb->setAttribute('title', S_EVENT_ACKNOWLEDGING_DISABLED);
}
$dashForm->addRow(S_PROBLEM_DISPLAY, $cb);
//-----
$dashForm->addItemToBottomRow(new CButton('save', S_SAVE));
$dashboard_wdgt->addItem($dashForm);
$dashboard_wdgt->show();
Example #9
0
 $menu_trigger_conf = 'null';
 if ($admin_links) {
     $menu_trigger_conf = "['" . S_CONFIGURATION_OF_TRIGGERS . "',\"javascript:\n\t\t\t\tredirect('triggers.php?form=update&triggerid=" . $trigger['triggerid'] . '&switch_node=' . id2nodeid($trigger['triggerid']) . "')\",\n\t\t\t\tnull, {'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}]";
 }
 $menu_trigger_url = 'null';
 if (!zbx_empty($trigger['url'])) {
     $menu_trigger_url = "['" . S_URL . "',\"javascript: window.location.href='" . $trigger['url'] . "'\",\n\t\t\t\tnull, {'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}]";
 }
 $description->addAction('onclick', "javascript: create_mon_trigger_menu(event, new Array({'triggerid': '" . $trigger['triggerid'] . "', 'lastchange': '" . $trigger['lastchange'] . "'}, " . $menu_trigger_conf . ", " . $menu_trigger_url . ")," . zbx_jsvalue($items, true) . ");");
 // }}} trigger description js menu
 if ($_REQUEST['show_details']) {
     $font = new CTag('font', 'yes');
     $font->setAttribute('color', '#000');
     $font->setAttribute('size', '-2');
     $font->addItem(explode_exp($trigger['expression'], 1, false, true));
     $description = array($description, BR(), $font);
 }
 // DEPENDENCIES {{{
 if (!empty($trigger['dependencies'])) {
     $dep_table = new CTableInfo();
     $dep_table->setAttribute('style', 'width: 200px;');
     $dep_table->addRow(bold(S_DEPENDS_ON . ':'));
     foreach ($trigger['dependencies'] as $dep) {
         $dep_table->addRow(' - ' . expand_trigger_description($dep['triggerid']));
     }
     $img = new Cimg('images/general/down_icon.png', 'DEP_UP');
     $img->setAttribute('style', 'vertical-align: middle; border: 0px;');
     $img->setHint($dep_table);
     $description = array($img, SPACE, $description);
 }
 $dependency = false;
$itemFormList = new CFormList('itemFormList');
// append type to form list
$copyTypeComboBox = new CComboBox('copy_type', $this->data['copy_type'], 'submit()');
$copyTypeComboBox->addItem(0, _('Hosts'));
$copyTypeComboBox->addItem(1, _('Host groups'));
$itemFormList->addRow(_('Target type'), $copyTypeComboBox);
// append targets to form list
$targetList = array();
if ($this->data['copy_type'] == 0) {
    $groupComboBox = new CComboBox('copy_groupid', $this->data['copy_groupid'], 'submit()');
    foreach ($this->data['groups'] as $group) {
        $groupComboBox->addItem($group['groupid'], $group['name']);
    }
    $itemFormList->addRow(_('Group'), $groupComboBox);
    foreach ($this->data['hosts'] as $host) {
        array_push($targetList, array(new CCheckBox('copy_targetid[' . $host['hostid'] . ']', uint_in_array($host['hostid'], $this->data['copy_targetid']), null, $host['hostid']), SPACE, $host['name'], BR()));
    }
} else {
    foreach ($this->data['groups'] as $group) {
        array_push($targetList, array(new CCheckBox('copy_targetid[' . $group['groupid'] . ']', uint_in_array($group['groupid'], $this->data['copy_targetid']), null, $group['groupid']), SPACE, $group['name'], BR()));
    }
}
$itemFormList->addRow(_('Target'), !empty($targetList) ? $targetList : SPACE);
// append tabs to form
$itemTab = new CTabView();
$itemTab->addTab('itemTab', count($this->data['group_itemid']) . ' ' . _('elements copy to ...'), $itemFormList);
$itemForm->addItem($itemTab);
// append buttons to form
$itemForm->addItem(makeFormFooter(new CSubmit('copy', _('Copy')), new CButtonCancel(url_param('groupid') . url_param('hostid') . url_param('config'))));
$itemWidget->addItem($itemForm);
return $itemWidget;
/*
** Zabbix
** Copyright (C) 2001-2014 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** 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.
**/
$screenWidget = new CWidget();
$screenWidget->addPageHeader(_('CONFIGURATION OF SCREENS'));
$screenWidget->addHeader($this->data['screen']['name']);
if (!empty($this->data['screen']['templateid'])) {
    $screenWidget->addItem(get_header_host_table('screens', $this->data['screen']['templateid']));
}
$screenWidget->addItem(BR());
$screenBuilder = new CScreenBuilder(array('isFlickerfree' => false, 'screen' => $this->data['screen'], 'mode' => SCREEN_MODE_EDIT, 'updateProfile' => false));
$screenWidget->addItem($screenBuilder->show());
$screenBuilder->insertInitScreenJs($this->data['screenid']);
$screenBuilder->insertProcessObjectsJs();
return $screenWidget;
**/
$widget = (new CWidget())->setTitle(_('Actions'))->setControls((new CForm('get'))->cleanItems()->addItem((new CList())->addItem([_('Event source'), SPACE, new CComboBox('eventsource', $data['eventsource'], 'submit()', [EVENT_SOURCE_TRIGGERS => _('Triggers'), EVENT_SOURCE_DISCOVERY => _('Discovery'), EVENT_SOURCE_AUTO_REGISTRATION => _('Auto registration'), EVENT_SOURCE_INTERNAL => _x('Internal', 'event source')])])->addItem(new CSubmit('form', _('Create action')))));
// create form
$actionForm = (new CForm())->setName('actionForm');
// create table
$actionTable = (new CTableInfo())->setHeader([(new CColHeader((new CCheckBox('all_items'))->onClick("checkAll('" . $actionForm->getName() . "', 'all_items', 'g_actionid');")))->addClass(ZBX_STYLE_CELL_WIDTH), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Conditions'), _('Operations'), make_sorting_header(_('Status'), 'status', $this->data['sort'], $this->data['sortorder'])]);
if ($this->data['actions']) {
    $actionConditionStringValues = actionConditionValueToString($this->data['actions'], $this->data['config']);
    $actionOperationDescriptions = getActionOperationDescriptions($this->data['actions']);
    foreach ($this->data['actions'] as $aIdx => $action) {
        $conditions = [];
        $operations = [];
        order_result($action['filter']['conditions'], 'conditiontype', ZBX_SORT_DOWN);
        foreach ($action['filter']['conditions'] as $cIdx => $condition) {
            $conditions[] = getConditionDescription($condition['conditiontype'], $condition['operator'], $actionConditionStringValues[$aIdx][$cIdx]);
            $conditions[] = BR();
        }
        sortOperations($data['eventsource'], $action['operations']);
        foreach ($action['operations'] as $oIdx => $operation) {
            $operations[] = $actionOperationDescriptions[$aIdx][$oIdx];
        }
        if ($action['status'] == ACTION_STATUS_DISABLED) {
            $status = (new CLink(_('Disabled'), 'actionconf.php?action=action.massenable&g_actionid[]=' . $action['actionid'] . url_param('eventsource')))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(ZBX_STYLE_RED)->addSID();
        } else {
            $status = (new CLink(_('Enabled'), 'actionconf.php?action=action.massdisable&g_actionid[]=' . $action['actionid'] . url_param('eventsource')))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(ZBX_STYLE_GREEN)->addSID();
        }
        $actionTable->addRow([new CCheckBox('g_actionid[' . $action['actionid'] . ']', $action['actionid']), new CLink($action['name'], 'actionconf.php?form=update&actionid=' . $action['actionid']), $conditions, $operations, $status]);
    }
}
// append table to form
$actionForm->addItem([$actionTable, $this->data['paging'], new CActionButtonList('action', 'g_actionid', ['action.massenable' => ['name' => _('Enable'), 'confirm' => _('Enable selected actions?')], 'action.massdisable' => ['name' => _('Disable'), 'confirm' => _('Disable selected actions?')], 'action.massdelete' => ['name' => _('Delete'), 'confirm' => _('Delete selected actions?')]])]);
    foreach ($this->data['groups'] as $group) {
        if (empty($this->data['filter_groupid'])) {
            $this->data['filter_groupid'] = $group['groupid'];
        }
        $groupComboBox->addItem($group['groupid'], $group['name']);
    }
    $triggersFormList->addRow(_('Group'), $groupComboBox);
}
// append targets to form list
$targets = array();
if ($this->data['copy_type'] == 0) {
    foreach ($this->data['hosts'] as $host) {
        array_push($targets, array(new CCheckBox('copy_targetid[' . $host['hostid'] . ']', uint_in_array($host['hostid'], $this->data['copy_targetid']), null, $host['hostid']), SPACE, $host['name'], BR()));
    }
} else {
    foreach ($this->data['groups'] as $group) {
        array_push($targets, array(new CCheckBox('copy_targetid[' . $group['groupid'] . ']', uint_in_array($group['groupid'], $this->data['copy_targetid']), null, $group['groupid']), SPACE, $group['name'], BR()));
    }
}
if (empty($targets)) {
    array_push($targets, BR());
}
$triggersFormList->addRow(_('Target'), $targets);
// append tabs to form
$triggersTab = new CTabView();
$triggersTab->addTab('triggersTab', count($this->data['elements']) . SPACE . _('elements copy to ...'), $triggersFormList);
$triggersForm->addItem($triggersTab);
// append buttons to form
$triggersForm->addItem(makeFormFooter(new CSubmit('copy', _('Copy')), new CButtonCancel(url_param('groupid') . url_param('hostid') . url_param('config'))));
$triggersWidget->addItem($triggersForm);
return $triggersWidget;
Example #14
0
                if (isset($summary[$alert['userid']]['medias'][$alert['mediatypeid']])) {
                    $summary[$alert['userid']]['medias'][$alert['mediatypeid']]++;
                } else {
                    $summary[$alert['userid']]['medias'][$alert['mediatypeid']] = 1;
                }
            }
            next($alerts);
        }
        foreach ($summary as $s) {
            if ($s['total'] == 0) {
                array_push($row, '');
            } else {
                array_push($row, [$s['total'], $media_type == 0 ? SPACE . '(' . implode('/', $s['medias']) . ')' : '']);
            }
        }
        $table->addRow($row);
    }
    $widget->addItem($table)->show();
    if ($media_type == 0) {
        echo BR();
        $links = [];
        foreach ($media_types as $id => $description) {
            $links[] = new CLink($description, 'zabbix.php?action=mediatype.edit&mediatypeid=' . $id);
            $links[] = SPACE . '/' . SPACE;
        }
        array_pop($links);
        $linksDiv = new CDiv([SPACE . _('all') . SPACE . '(' . SPACE, $links, SPACE . ')']);
        $linksDiv->show();
    }
}
require_once dirname(__FILE__) . '/include/page_footer.php';
 $session = $this->data['usersSessions'][$userId];
 // online time
 if ($session['lastaccess']) {
     $onlineTime = $user['autologout'] == 0 || ZBX_USER_ONLINE_TIME < $user['autologout'] ? ZBX_USER_ONLINE_TIME : $user['autologout'];
     $online = $session['lastaccess'] + $onlineTime >= time() ? new CCol(_('Yes') . ' (' . date('r', $session['lastaccess']) . ')', 'enabled') : new CCol(_('No') . ' (' . date('r', $session['lastaccess']) . ')', 'disabled');
 } else {
     $online = new CCol(_('No'), 'disabled');
 }
 // blocked
 $blocked = $user['attempt_failed'] >= ZBX_LOGIN_ATTEMPTS ? new CLink(_('Blocked'), 'users.php?go=unblock&group_userid' . SQUAREBRACKETS . '=' . $userId, 'on') : new CSpan(_('Ok'), 'green');
 // user groups
 order_result($user['usrgrps'], 'name');
 $usersGroups = array();
 foreach ($user['usrgrps'] as $userGroup) {
     $usersGroups[] = new CLink($userGroup['name'], 'usergrps.php?form=update&usrgrpid=' . $userGroup['usrgrpid']);
     $usersGroups[] = BR();
 }
 array_pop($usersGroups);
 // user type style
 $userTypeStyle = 'enabled';
 if ($user['type'] == USER_TYPE_ZABBIX_ADMIN) {
     $userTypeStyle = 'orange';
 }
 if ($user['type'] == USER_TYPE_SUPER_ADMIN) {
     $userTypeStyle = 'disabled';
 }
 // gui access style
 $guiAccessStyle = 'green';
 if ($user['gui_access'] == GROUP_GUI_ACCESS_INTERNAL) {
     $guiAccessStyle = 'orange';
 }
Example #16
0
     if (!isset($users_sessions[$db_ses['userid']])) {
         $users_sessions[$db_ses['userid']] = $db_ses;
     }
     if (isset($users_sessions[$db_ses['userid']]) && $users_sessions[$db_ses['userid']]['lastaccess'] < $db_ses['lastaccess']) {
         $users_sessions[$db_ses['userid']] = $db_ses;
     }
 }
 $users_groups = array();
 $sql = 'SELECT g.name, ug.usrgrpid, ug.userid ' . ' FROM usrgrp g, users_groups ug ' . ' WHERE g.usrgrpid=ug.usrgrpid ' . ' AND ' . DBcondition('ug.userid', $userids);
 $db_groups = DBselect($sql);
 while ($db_group = DBfetch($db_groups)) {
     if (!isset($users_groups[$db_group['userid']])) {
         $users_groups[$db_group['userid']] = array();
     }
     if (!empty($users_groups[$db_group['userid']])) {
         $users_groups[$db_group['userid']][] = BR();
     }
     $users_groups[$db_group['userid']][] = new CLink($db_group['name'], 'users.php?form=update&config=1&usrgrpid=' . $db_group['usrgrpid'] . '#form');
 }
 foreach ($userids as $id => $userid) {
     $user =& $users[$userid];
     //Log Out 10min or Autologout time
     $online_time = $user['autologout'] == 0 || ZBX_USER_ONLINE_TIME < $user['autologout'] ? ZBX_USER_ONLINE_TIME : $user['autologout'];
     $online = new CCol(S_NO, 'disabled');
     if (isset($users_sessions[$userid])) {
         $session =& $users_sessions[$userid];
         if (ZBX_SESSION_ACTIVE == $session['status'] && $session['lastaccess'] + $online_time >= time()) {
             $online = new CCol(S_YES . ' (' . date('r', $session['lastaccess']) . ')', 'enabled');
         } else {
             $online = new CCol(S_NO . ' (' . date('r', $session['lastaccess']) . ')', 'disabled');
         }
Example #17
0
$media = get_request('media', -1);
$sendto = get_request('sendto', '');
$mediatypeid = get_request('mediatypeid', 0);
$active = get_request('active', 0);
$period = get_request('period', '1-7,00:00-23:59');
$frmMedia = new CFormTable(S_NEW_MEDIA);
$frmMedia->SetHelp("web.media.php");
$frmMedia->AddVar("media", $media);
$frmMedia->AddVar("dstfrm", $_REQUEST["dstfrm"]);
$cmbType = new CComboBox("mediatypeid", $mediatypeid);
$types = DBselect('SELECT mediatypeid,description ' . ' FROM media_type' . ' WHERE ' . DBin_node('mediatypeid') . ' ORDER BY type');
while ($type = DBfetch($types)) {
    $cmbType->AddItem($type["mediatypeid"], get_node_name_by_elid($type["mediatypeid"]) . $type["description"]);
}
$frmMedia->AddRow(S_TYPE, $cmbType);
$frmMedia->AddRow(S_SEND_TO, new CTextBox("sendto", $sendto, 20));
$frmMedia->AddRow(S_WHEN_ACTIVE, new CTextBox("period", $period, 48));
$frm_row = array();
for ($i = 0; $i <= 5; $i++) {
    array_push($frm_row, array(new CCheckBox("severity[{$i}]", str_in_array($i, $severity) ? 'yes' : 'no', null, $i), get_severity_description($i)), BR());
}
$frmMedia->AddRow(S_USE_IF_SEVERITY, $frm_row);
$cmbStat = new CComboBox("active", $active);
$cmbStat->AddItem(0, S_ENABLED);
$cmbStat->AddItem(1, S_DISABLED);
$frmMedia->AddRow("Status", $cmbStat);
$frmMedia->AddItemToBottomRow(new CButton("add", $media > -1 ? S_SAVE : S_ADD));
$frmMedia->AddItemToBottomRow(SPACE);
$frmMedia->AddItemToBottomRow(new CButtonCancel(null, 'close_window();'));
$frmMedia->Show();
include_once "include/page_footer.php";
Example #18
0
function get_actions_hint_by_eventid($eventid, $status = null)
{
    $tab_hint = new CTableInfo(_('No actions found.'));
    $tab_hint->setAttribute('style', 'width: 300px;');
    $tab_hint->setHeader(array(is_show_all_nodes() ? _('Nodes') : null, _('User'), _('Details'), _('Status')));
    $sql = 'SELECT a.alertid,mt.description,u.alias,u.name,u.surname,a.subject,a.message,a.sendto,a.status,a.retries,a.alerttype' . ' FROM events e,alerts a' . ' LEFT JOIN users u ON u.userid=a.userid' . ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid' . ' WHERE a.eventid=' . zbx_dbstr($eventid) . (is_null($status) ? '' : ' AND a.status=' . $status) . ' AND e.eventid=a.eventid' . ' AND a.alerttype IN (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . andDbNode('a.alertid') . ' ORDER BY a.alertid';
    $result = DBselect($sql, 30);
    while ($row = DBfetch($result)) {
        if ($row['status'] == ALERT_STATUS_SENT) {
            $status = new CSpan(_('Sent'), 'green');
        } elseif ($row['status'] == ALERT_STATUS_NOT_SENT) {
            $status = new CSpan(_('In progress'), 'orange');
        } else {
            $status = new CSpan(_('not sent'), 'red');
        }
        switch ($row['alerttype']) {
            case ALERT_TYPE_MESSAGE:
                $message = empty($row['description']) ? '-' : $row['description'];
                break;
            case ALERT_TYPE_COMMAND:
                $message = array(bold(_('Command') . NAME_DELIMITER));
                $msg = explode("\n", $row['message']);
                foreach ($msg as $m) {
                    array_push($message, BR(), $m);
                }
                break;
            default:
                $message = '-';
        }
        if (!$row['alias']) {
            $row['alias'] = ' - ';
        } else {
            $fullname = '';
            if ($row['name']) {
                $fullname = $row['name'];
            }
            if ($row['surname']) {
                $fullname .= $fullname ? ' ' . $row['surname'] : $row['surname'];
            }
            if ($fullname) {
                $row['alias'] .= ' (' . $fullname . ')';
            }
        }
        $tab_hint->addRow(array(get_node_name_by_elid($row['alertid']), $row['alias'], $message, $status));
    }
    return $tab_hint;
}
Example #19
0
                 $style = 'unknown';
                 $url = 'templates.php?form=update&templateid=' . $hostid . '&groupid=' . $groupid;
                 break;
             default:
                 $style = null;
                 $url = 'hosts.php?form=update&hostid=' . $hostid . '&groupid=' . $groupid;
                 break;
         }
         $hosts_output[] = new CLink($host['host'], $url, $style);
         $hosts_output[] = ', ';
     }
     array_pop($hosts_output);
     foreach ($group['hosts'] as $hostid => $host) {
         $host['status'] == HOST_STATUS_TEMPLATE ? $tpl_count++ : $host_count++;
     }
     $table->addRow(array(new CCheckBox('groups[' . $groupid . ']', NULL, NULL, $groupid), new CLink($group['name'], 'hostgroups.php?form=update&groupid=' . $groupid), array(array(new CLink(S_HOSTS, 'hosts.php?groupid=' . $groupid), ' (' . $host_count . ')'), BR(), array(new CLink(S_TEMPLATES, 'templates.php?groupid=' . $groupid, 'unknown'), ' (' . $tpl_count . ')')), new CCol(empty($hosts_output) ? '-' : $hosts_output, 'wraptext')));
 }
 $row_count = $table->getNumRows();
 //----- GO ------
 $goBox = new CComboBox('go');
 $goBox->addItem('activate', S_ACTIVATE_SELECTED);
 $goBox->addItem('disable', S_DISABLE_SELECTED);
 $goBox->addItem('delete', S_DELETE_SELECTED);
 // goButton name is necessary!!!
 $goButton = new CButton('goButton', S_GO . ' (0)');
 $goButton->setAttribute('id', 'goButton');
 zbx_add_post_js('chkbxRange.pageGoName = "groups";');
 $table->setFooter(new CCol(array($goBox, $goButton)));
 //----
 $form->addItem($table);
 $form->show();
Example #20
0
function get_actions_hint_by_eventid($eventid, $status = NULL)
{
    $hostids = array();
    $sql = 'SELECT DISTINCT i.hostid ' . ' FROM events e, functions f, items i ' . ' WHERE e.eventid=' . $eventid . ' AND e.objectid=' . EVENT_SOURCE_TRIGGERS . ' AND f.triggerid=' . $_REQUEST['triggerid'] . ' AND i.itemid=f.itemid';
    if ($host = DBfetch(DBselect($sql, 1))) {
        $hostids[$host['hostid']] = $host['hostid'];
    }
    $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $hostids);
    $tab_hint = new CTableInfo(S_NO_ACTIONS_FOUND);
    $tab_hint->addOption('style', 'width: 300px;');
    $tab_hint->SetHeader(array(is_show_subnodes() ? S_NODES : null, S_USER, S_DETAILS, S_STATUS));
    /*			
    	$sql = 'SELECT DISTINCT a.alertid,mt.description,a.sendto,a.status,u.alias,a.retries '.
    			' FROM events e,users u,alerts a'.
    			' left join media_type mt on mt.mediatypeid=a.mediatypeid'.
    			' WHERE a.eventid='.$eventid.
    				(is_null($status)?'':' AND a.status='.$status).
    				' AND e.eventid = a.eventid'.
    				' AND a.alerttype IN ('.ALERT_TYPE_MESSAGE.','.ALERT_TYPE_COMMAND.')'.
    				' AND '.DBcondition('e.objectid',$available_triggers).
    				' AND '.DBin_node('a.alertid').
    				' AND u.userid=a.userid '.
    			' ORDER BY mt.description';
    //*/
    $sql = 'SELECT DISTINCT a.alertid,mt.description,u.alias,a.subject,a.message,a.sendto,a.status,a.retries,a.alerttype ' . ' FROM events e,alerts a ' . ' LEFT JOIN users u ON u.userid=a.userid ' . ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid' . ' WHERE a.eventid=' . $eventid . (is_null($status) ? '' : ' AND a.status=' . $status) . ' AND e.eventid = a.eventid' . ' AND a.alerttype IN (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND ' . DBcondition('e.objectid', $available_triggers) . ' AND ' . DBin_node('a.alertid') . ' ORDER BY a.alertid';
    $result = DBselect($sql, 30);
    while ($row = DBfetch($result)) {
        if ($row["status"] == ALERT_STATUS_SENT) {
            $status = new CSpan(S_SENT, "green");
            $retries = new CSpan(SPACE, "green");
        } else {
            if ($row["status"] == ALERT_STATUS_NOT_SENT) {
                $status = new CSpan(S_IN_PROGRESS, "orange");
                $retries = new CSpan(ALERT_MAX_RETRIES - $row["retries"], "orange");
            } else {
                $status = new CSpan(S_NOT_SENT, "red");
                $retries = new CSpan(0, "red");
            }
        }
        switch ($row['alerttype']) {
            case ALERT_TYPE_MESSAGE:
                $message = empty($row['description']) ? '-' : $row['description'];
                break;
            case ALERT_TYPE_COMMAND:
                $message = array(bold(S_COMMAND . ':'));
                $msg = explode("\n", $row['message']);
                foreach ($msg as $m) {
                    array_push($message, BR(), $m);
                }
                break;
            default:
                $message = '-';
        }
        $tab_hint->addRow(array(get_node_name_by_elid($row['alertid']), empty($row['alias']) ? ' - ' : $row['alias'], $message, $status));
    }
    return $tab_hint;
}
$imageComboBoxForm->addItem($imageComboBox);
$this->data['widget']->addHeader(_('Images'), $imageComboBoxForm);
// form
$imageForm = new CForm();
$imageForm->setName('imageForm');
$imageForm->addItem(BR());
$imageTable = new CTable(_('No images found.'), 'header_wide padding_standard');
$count = 0;
$imageRow = new CRow();
foreach ($this->data['images'] as $image) {
    $img = $image['imagetype'] == IMAGE_TYPE_BACKGROUND ? new CLink(new CImg('imgstore.php?width=200&height=200&iconid=' . $image['imageid'], 'no image'), 'image.php?imageid=' . $image['imageid']) : new CImg('imgstore.php?iconid=' . $image['imageid'], 'no image');
    $nodeName = $this->data['displayNodes'] ? new CSpan($image['nodename'], 'unknown') : null;
    $name = new CLink($image['name'], 'adm.images.php?form=update&imageid=' . $image['imageid']);
    $imgColumn = new CCol();
    $imgColumn->setAttribute('align', 'center');
    $imgColumn->addItem(array($img, BR(), $nodeName, $name), 'center');
    $imageRow->addItem($imgColumn);
    $count++;
    if ($count % 4 == 0) {
        $imageTable->addRow($imageRow);
        $imageRow = new CRow();
    }
}
if ($count > 0) {
    while ($count % 4 != 0) {
        $imageRow->addItem(SPACE);
        $count++;
    }
    $imageTable->addRow($imageRow);
}
$imageForm->addItem($imageTable);
if (!$isDiscovered) {
    $grp_tb = new CTweenBox($frmHost, 'groups', $host_groups, 10);
    $all_groups = API::HostGroup()->get(array('editable' => true, 'output' => API_OUTPUT_EXTEND));
    order_result($all_groups, 'name');
    foreach ($all_groups as $group) {
        $grp_tb->addItem($group['groupid'], $group['name']);
    }
    $hostList->addRow(_('Groups'), $grp_tb->get(_('In groups'), _('Other groups')));
    $newgroupTB = new CTextBox('newgroup', $newgroup, ZBX_TEXTBOX_SMALL_SIZE);
    $newgroupTB->setAttribute('maxlength', 64);
    $tmp_label = _('New group');
    if (CWebUser::$data['type'] != USER_TYPE_SUPER_ADMIN) {
        $tmp_label .= SPACE . _('(Only super admins can create groups)');
        $newgroupTB->setReadonly(true);
    }
    $hostList->addRow(SPACE, array(new CLabel($tmp_label, 'newgroup'), BR(), $newgroupTB), null, null, null, 'new');
} else {
    $groupBox = new CComboBox('groups');
    $groupBox->setAttribute('readonly', true);
    $groupBox->setAttribute('size', 10);
    foreach ($dbHost['groups'] as $group) {
        $groupBox->addItem($group['groupid'], $group['name']);
    }
    $hostList->addRow(_('Groups'), $groupBox);
}
// interfaces for normal hosts
if (!$isDiscovered) {
    if (empty($interfaces)) {
        $script = 'hostInterfacesManager.addNew("agent");';
    } else {
        $json = new CJSON();
Example #23
0
 function stage6()
 {
     $this->setConfig('ZBX_CONFIG_FILE_CORRECT', true);
     $config = new CConfigFile(Z::getInstance()->getRootDir() . CConfigFile::CONFIG_FILE_PATH);
     $config->config = array('DB' => array('TYPE' => $this->getConfig('DB_TYPE'), 'SERVER' => $this->getConfig('DB_SERVER'), 'PORT' => $this->getConfig('DB_PORT'), 'DATABASE' => $this->getConfig('DB_DATABASE'), 'USER' => $this->getConfig('DB_USER'), 'PASSWORD' => $this->getConfig('DB_PASSWORD'), 'SCHEMA' => $this->getConfig('DB_SCHEMA')), 'ZBX_SERVER' => $this->getConfig('ZBX_SERVER'), 'ZBX_SERVER_PORT' => $this->getConfig('ZBX_SERVER_PORT'), 'ZBX_SERVER_NAME' => $this->getConfig('ZBX_SERVER_NAME'));
     $config->save();
     try {
         $error = false;
         $config->load();
         if ($config->config['DB']['TYPE'] != $this->getConfig('DB_TYPE')) {
             $error = true;
         } elseif ($config->config['DB']['SERVER'] != $this->getConfig('DB_SERVER')) {
             $error = true;
         } elseif ($config->config['DB']['PORT'] != $this->getConfig('DB_PORT')) {
             $error = true;
         } elseif ($config->config['DB']['DATABASE'] != $this->getConfig('DB_DATABASE')) {
             $error = true;
         } elseif ($config->config['DB']['USER'] != $this->getConfig('DB_USER')) {
             $error = true;
         } elseif ($config->config['DB']['PASSWORD'] != $this->getConfig('DB_PASSWORD')) {
             $error = true;
         } elseif ($this->getConfig('DB_TYPE') == ZBX_DB_DB2 && $config->config['DB']['SCHEMA'] != $this->getConfig('DB_SCHEMA')) {
             $error = true;
         } elseif ($config->config['ZBX_SERVER'] != $this->getConfig('ZBX_SERVER')) {
             $error = true;
         } elseif ($config->config['ZBX_SERVER_PORT'] != $this->getConfig('ZBX_SERVER_PORT')) {
             $error = true;
         } elseif ($config->config['ZBX_SERVER_NAME'] != $this->getConfig('ZBX_SERVER_NAME')) {
             $error = true;
         }
         $error_text = 'Unable to overwrite the existing configuration file. ';
     } catch (ConfigFileException $e) {
         $error = true;
         $error_text = 'Unable to create the configuration file. ';
     }
     clear_messages();
     if ($error) {
         $this->setConfig('ZBX_CONFIG_FILE_CORRECT', false);
     }
     $this->DISABLE_NEXT_BUTTON = !$this->getConfig('ZBX_CONFIG_FILE_CORRECT', false);
     $this->HIDE_CANCEL_BUTTON = !$this->DISABLE_NEXT_BUTTON;
     $table = array('Configuration file', BR(), '"' . Z::getInstance()->getRootDir() . CConfigFile::CONFIG_FILE_PATH . '"', BR(), 'created: ', $this->getConfig('ZBX_CONFIG_FILE_CORRECT', false) ? new CSpan(_('OK'), 'ok') : new CSpan(_('Fail'), 'fail'));
     return array($table, BR(), BR(), $this->DISABLE_NEXT_BUTTON ? array(new CSubmit('retry', _('Retry')), BR(), BR()) : null, !$this->getConfig('ZBX_CONFIG_FILE_CORRECT', false) ? array($error_text, BR(), 'Please install it manually, or fix permissions on the conf directory.', BR(), BR(), 'Press the "Download configuration file" button, download the configuration file ', 'and save it as ', BR(), '"' . Z::getInstance()->getRootDir() . CConfigFile::CONFIG_FILE_PATH . '"', BR(), BR(), new CSubmit('save_config', 'Download configuration file'), BR(), BR()) : array('Congratulations on successful installation of Zabbix frontend.', BR(), BR()), 'When done, press the ' . ($this->DISABLE_NEXT_BUTTON ? '"Retry"' : '"Finish"') . ' button');
 }
Example #24
0
/**
 * Renders an "access denied" message and stops the execution of the script.
 *
 * The $mode parameters controls the layout of the message:
 * - ACCESS_DENY_OBJECT     - render the message when denying access to a specific object
 * - ACCESS_DENY_PAGE       - render a complete access denied page
 *
 * @param int $mode
 */
function access_deny($mode = ACCESS_DENY_OBJECT)
{
    // deny access to an object
    if ($mode == ACCESS_DENY_OBJECT) {
        require_once dirname(__FILE__) . '/page_header.php';
        show_error_message(_('No permissions to referred object or it does not exist!'));
        require_once dirname(__FILE__) . '/page_footer.php';
    } else {
        // url to redirect the user to after he loggs in
        $url = new CUrl(!empty($_REQUEST['request']) ? $_REQUEST['request'] : '');
        $url->setArgument('sid', null);
        $url = urlencode($url->toString());
        // if the user is logged in - render the access denied message
        if (CWebUser::isLoggedIn()) {
            $header = _('Access denied.');
            $message = array(_('Your are logged in as'), ' ', bold(CWebUser::$data['alias']), '. ', _('You have no permissions to access this page.'), BR(), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.'));
            $buttons = array();
            // display the login button only for guest users
            if (CWebUser::isGuest()) {
                $buttons[] = new CButton('login', _('Login'), 'javascript: document.location = "index.php?request=' . $url . '";', 'formlist');
            }
            $buttons[] = new CButton('back', _('Go to dashboard'), 'javascript: document.location = "dashboard.php"', 'formlist');
        } else {
            $header = _('You are not logged in.');
            $message = array(_('You must login to view this page.'), BR(), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.'));
            $buttons = array(new CButton('login', _('Login'), 'javascript: document.location = "index.php?request=' . $url . '";', 'formlist'));
        }
        $warning = new CWarning($header, $message);
        $warning->setButtons($buttons);
        $warningView = new CView('general.warning', array('warning' => $warning));
        $warningView->render();
        exit;
    }
}
// getting inventory fields to make a drop down
$inventoryFields = getHostInventories(true);
// 'true' means list should be ordered by title
$inventoryFieldsComboBox = new CComboBox('groupby', $_REQUEST['groupby'], 'submit()');
$inventoryFieldsComboBox->addItem('', _('not selected'));
foreach ($inventoryFields as $inventoryField) {
    $inventoryFieldsComboBox->addItem($inventoryField['db_field'], $inventoryField['title'], $_REQUEST['groupby'] === $inventoryField['db_field'] ? 'yes' : null);
    if ($_REQUEST['groupby'] === $inventoryField['db_field']) {
        $groupFieldTitle = $inventoryField['title'];
    }
}
$r_form = new CForm('get');
$r_form->addItem(array(_('Group'), SPACE, $pageFilter->getGroupsCB(true), SPACE));
$r_form->addItem(array(_('Grouping by'), SPACE, $inventoryFieldsComboBox));
$hostinvent_wdgt->addHeader(_('Hosts'), $r_form);
$hostinvent_wdgt->addItem(BR());
$table = new CTableInfo(_('No hosts defined.'));
$table->setHeader(array(make_sorting_header($groupFieldTitle === '' ? _('Field') : $groupFieldTitle, 'inventory_field'), make_sorting_header(_('Host count'), 'host_count')));
// to show a report, we will need a host group and a field to aggregate
if ($pageFilter->groupsSelected && $groupFieldTitle !== '') {
    $options = array('output' => array('hostid', 'name'), 'selectInventory' => array($_REQUEST['groupby']), 'withInventory' => true);
    if ($pageFilter->groupid > 0) {
        $options['groupids'] = $pageFilter->groupid;
    }
    $hosts = API::Host()->get($options);
    // aggregating data by chosen field value
    $report = array();
    foreach ($hosts as $host) {
        if ($host['inventory'][$_REQUEST['groupby']] !== '') {
            $lowerValue = zbx_strtolower($host['inventory'][$_REQUEST['groupby']]);
            if (!isset($report[$lowerValue])) {
 /**
  * Process screen with particular screen objects.
  *
  * @return CTable
  */
 public function show()
 {
     if (empty($this->screen)) {
         return new CTableInfo(_('No screens defined.'));
     }
     $skipedFields = array();
     $screenitems = array();
     $emptyScreenColumns = array();
     // calculate table columns and rows
     foreach ($this->screen['screenitems'] as $screenitem) {
         $screenitems[] = $screenitem;
         for ($i = 0; $i < $screenitem['rowspan'] || $i == 0; $i++) {
             for ($j = 0; $j < $screenitem['colspan'] || $j == 0; $j++) {
                 if ($i != 0 || $j != 0) {
                     if (!isset($skipedFields[$screenitem['y'] + $i])) {
                         $skipedFields[$screenitem['y'] + $i] = array();
                     }
                     $skipedFields[$screenitem['y'] + $i][$screenitem['x'] + $j] = 1;
                 }
             }
         }
     }
     // create screen table
     $screenTable = new CTable();
     $screenTable->setAttribute('class', in_array($this->mode, array(SCREEN_MODE_PREVIEW, SCREEN_MODE_SLIDESHOW)) ? 'screen_view' : 'screen_edit');
     $screenTable->setAttribute('id', 'iframe');
     // action top row
     if ($this->mode == SCREEN_MODE_EDIT) {
         $newColumns = array(new CCol(new CImg('images/general/zero.png', 'zero', 1, 1)));
         for ($i = 0, $size = $this->screen['hsize'] + 1; $i < $size; $i++) {
             $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
             $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&add_col=' . $i . '";');
             array_push($newColumns, new CCol($icon));
         }
         $screenTable->addRow($newColumns);
     }
     for ($r = 0; $r < $this->screen['vsize']; $r++) {
         $newColumns = array();
         $emptyScreenRow = true;
         // action left cell
         if ($this->mode == SCREEN_MODE_EDIT) {
             $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
             $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&add_row=' . $r . '";');
             array_push($newColumns, new CCol($icon));
         }
         for ($c = 0; $c < $this->screen['hsize']; $c++) {
             if (isset($skipedFields[$r][$c])) {
                 continue;
             }
             // screen item
             $isEditForm = false;
             $screenitem = array();
             foreach ($screenitems as $tmprow) {
                 if ($tmprow['x'] == $c && $tmprow['y'] == $r) {
                     $screenitem = $tmprow;
                     break;
                 }
             }
             if (empty($screenitem)) {
                 $screenitem = array('screenitemid' => 0, 'resourcetype' => 0, 'resourceid' => 0, 'width' => 0, 'height' => 0, 'colspan' => 1, 'rowspan' => 1, 'elements' => 0, 'valign' => VALIGN_DEFAULT, 'halign' => HALIGN_DEFAULT, 'style' => 0, 'url' => '', 'dynamic' => 0, 'sort_triggers' => SCREEN_SORT_TRIGGERS_DATE_DESC);
             }
             if (!empty($screenitem['screenitemid'])) {
                 $emptyScreenRow = false;
                 $emptyScreenColumns[$c] = 1;
             }
             // action
             if ($this->mode == SCREEN_MODE_EDIT && $screenitem['screenitemid'] != 0) {
                 $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitem['screenitemid'];
             } elseif ($this->mode == SCREEN_MODE_EDIT && $screenitem['screenitemid'] == 0) {
                 $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r;
             } else {
                 $action = null;
             }
             // edit form cell
             if ($this->mode == SCREEN_MODE_EDIT && (isset($_REQUEST['form']) && $_REQUEST['form'] == 'update') && (isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r || isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitem['screenitemid']) == 0)) {
                 $screenView = new CView('configuration.screen.constructor.edit', array('screen' => $this->screen));
                 $item = $screenView->render();
                 $isEditForm = true;
             } elseif (!empty($screenitem['screenitemid']) && isset($screenitem['resourcetype'])) {
                 $screenBase = CScreenBuilder::getScreen(array('isFlickerfree' => $this->isFlickerfree, 'pageFile' => $this->pageFile, 'mode' => $this->mode, 'timestamp' => $this->timestamp, 'hostid' => $this->hostid, 'profileIdx' => $this->profileIdx, 'profileIdx2' => $this->profileIdx2, 'updateProfile' => $this->updateProfile, 'timeline' => $this->timeline, 'resourcetype' => $screenitem['resourcetype'], 'screenitem' => $screenitem));
                 if (!empty($screenBase)) {
                     if ($this->mode == SCREEN_MODE_EDIT && !empty($screenitem['screenitemid'])) {
                         $screenBase->action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitem['screenitemid'];
                     } elseif ($this->mode == SCREEN_MODE_EDIT && empty($screenitem['screenitemid'])) {
                         $screenBase->action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r;
                     }
                     $item = $screenBase->get();
                 } else {
                     $item = null;
                 }
             } else {
                 $item = array(SPACE);
                 if ($this->mode == SCREEN_MODE_EDIT) {
                     array_push($item, BR(), new CLink(_('Change'), $action, 'empty_change_link'));
                 }
             }
             // align
             $halign = 'def';
             if ($screenitem['halign'] == HALIGN_CENTER) {
                 $halign = 'cntr';
             }
             if ($screenitem['halign'] == HALIGN_LEFT) {
                 $halign = 'left';
             }
             if ($screenitem['halign'] == HALIGN_RIGHT) {
                 $halign = 'right';
             }
             $valign = 'def';
             if ($screenitem['valign'] == VALIGN_MIDDLE) {
                 $valign = 'mdl';
             }
             if ($screenitem['valign'] == VALIGN_TOP) {
                 $valign = 'top';
             }
             if ($screenitem['valign'] == VALIGN_BOTTOM) {
                 $valign = 'bttm';
             }
             if ($this->mode == SCREEN_MODE_EDIT && !$isEditForm) {
                 $item = new CDiv($item, 'draggable');
                 $item->setAttribute('id', 'position_' . $r . '_' . $c);
                 $item->setAttribute('data-xcoord', $c);
                 $item->setAttribute('data-ycoord', $r);
             }
             // colspan/rowspan
             $newColumn = new CCol($item, $halign . '_' . $valign . ' screenitem');
             if (!empty($screenitem['colspan'])) {
                 $newColumn->setColSpan($screenitem['colspan']);
             }
             if (!empty($screenitem['rowspan'])) {
                 $newColumn->setRowSpan($screenitem['rowspan']);
             }
             array_push($newColumns, $newColumn);
         }
         // action right cell
         if ($this->mode == SCREEN_MODE_EDIT) {
             $icon = new CImg('images/general/minus.png', null, null, null, 'pointer');
             if ($emptyScreenRow) {
                 $removeRowLink = 'javascript: location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_row=' . $r . '";';
             } else {
                 $removeRowLink = 'javascript: if (Confirm("' . _('This screen-row is not empty. Delete it?') . '")) {' . ' location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_row=' . $r . '"; }';
             }
             $icon->addAction('onclick', $removeRowLink);
             array_push($newColumns, new CCol($icon));
         }
         $screenTable->addRow(new CRow($newColumns));
     }
     // action bottom row
     if ($this->mode == SCREEN_MODE_EDIT) {
         $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
         $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&add_row=' . $this->screen['vsize'] . '";');
         $newColumns = array(new CCol($icon));
         for ($i = 0; $i < $this->screen['hsize']; $i++) {
             $icon = new CImg('images/general/minus.png', null, null, null, 'pointer');
             if (isset($emptyScreenColumns[$i])) {
                 $removeColumnLink = 'javascript: if (Confirm("' . _('This screen-column is not empty. Delete it?') . '")) {' . ' location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_col=' . $i . '"; }';
             } else {
                 $removeColumnLink = 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&rmv_col=' . $i . '";';
             }
             $icon->addAction('onclick', $removeColumnLink);
             array_push($newColumns, new CCol($icon));
         }
         array_push($newColumns, new CCol(new CImg('images/general/zero.png', 'zero', 1, 1)));
         $screenTable->addRow($newColumns);
     }
     return $screenTable;
 }
Example #27
0
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array('period' => array(T_ZBX_STR, O_OPT, P_SYS | P_NZERO, IN('"day","week","month","year"'), NULL));
check_fields($fields);
$rprt_wdgt = new CWidget();
$_REQUEST['period'] = getRequest('period', 'day');
$admin_links = CWebUser::$data['type'] == USER_TYPE_ZABBIX_ADMIN || CWebUser::$data['type'] == USER_TYPE_SUPER_ADMIN;
$form = new CForm('get');
$cmbPeriod = new CComboBox('period', $_REQUEST['period'], 'submit()');
$cmbPeriod->addItem('day', _('Day'));
$cmbPeriod->addItem('week', _('Week'));
$cmbPeriod->addItem('month', _('Month'));
$cmbPeriod->addItem('year', _('Year'));
$form->addItem($cmbPeriod);
$rprt_wdgt->addPageHeader(_('MOST BUSY TRIGGERS TOP 100'));
$rprt_wdgt->addHeader(_('Report'), $form);
$rprt_wdgt->addItem(BR());
$table = new CTableInfo(_('No triggers found.'));
$table->setHeader(array(_('Host'), _('Trigger'), _('Severity'), _('Number of status changes')));
switch ($_REQUEST['period']) {
    case 'week':
        $time_dif = SEC_PER_WEEK;
        break;
    case 'month':
        $time_dif = SEC_PER_MONTH;
        break;
    case 'year':
        $time_dif = SEC_PER_YEAR;
        break;
    case 'day':
    default:
        $time_dif = SEC_PER_DAY;
 /**
  * Checks for databases support.
  *
  * @return array
  */
 public function checkPhpDatabases()
 {
     $current = array();
     $databases = $this->getSupportedDatabases();
     foreach ($databases as $database => $name) {
         $current[] = $name;
         $current[] = BR();
     }
     return array('name' => _('PHP databases support'), 'current' => empty($current) ? _('off') : new CSpan($current), 'required' => null, 'result' => $current ? self::CHECK_OK : self::CHECK_FATAL, 'error' => _('At least one of MySQL, PostgreSQL, Oracle, SQLite3 or IBM DB2 should be supported.'));
 }
Example #29
0
            $problemTrigger['description'] = $triggers[$problemTrigger['triggerid']]['description'];
        }
        unset($problemTrigger);
    }
    unset($serviceSla);
    $treeData = array();
    createServiceMonitoringTree($services, $slaData, $period, $treeData);
    $tree = new CServiceTree('service_status_tree', $treeData, array('caption' => _('Service'), 'status' => _('Status'), 'reason' => _('Reason'), 'sla' => _('Problem time'), 'sla2' => nbsp(_('SLA') . ' / ' . _('Acceptable SLA'))));
    if ($tree) {
        // creates form for choosing a preset interval
        $r_form = new CForm();
        $r_form->setAttribute('class', 'nowrap');
        $r_form->setMethod('get');
        $r_form->setAttribute('name', 'period_choice');
        $r_form->addVar('fullscreen', $_REQUEST['fullscreen']);
        $period_combo = new CComboBox('period', $period, 'javascript: submit();');
        foreach ($periods as $key => $val) {
            $period_combo->addItem($key, $val);
        }
        $r_form->addItem(array(_('Period') . SPACE, $period_combo));
        $srv_wdgt = new CWidget('hat_services', 'service-list service-mon');
        $srv_wdgt->addPageHeader(_('IT SERVICES'), get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen'])));
        $srv_wdgt->addHeader(_('IT services'), $r_form);
        $srv_wdgt->addItem(BR());
        $srv_wdgt->addItem($tree->getHTML());
        $srv_wdgt->show();
    } else {
        error(_('Cannot format Tree. Check logic structure in service links.'));
    }
}
require_once dirname(__FILE__) . '/include/page_footer.php';
Example #30
0
    public function index()
    {
        $this->PrintInstructions();
        echo '<form method="post" action="' . BURL('database/operate') . '" name="tables">
		<input type="hidden" name="dbaction" value="">';
        TableHeader('数据库列表');
        TableRow(array('选择', '表名称', '记录数', '数据大小', '索引大小', '空闲', '操作', '', '', ''), 'tr0');
        $recordsize = $datasize = $indexsize = $freesize = 0;
        $gettables = APP::$DB->query("SHOW TABLE STATUS LIKE '" . substr(TABLE_PREFIX, 0, -1) . "\\_%'");
        while ($tableinfo = APP::$DB->fetch($gettables)) {
            TableRow(array('<input type="checkbox" name="tablenames[]" value="' . $tableinfo['Name'] . '">', $tableinfo['Name'], $tableinfo['Rows'], DisplayFilesize($tableinfo['Data_length']), DisplayFilesize($tableinfo['Index_length']), Iif($tableinfo['Data_free'] > 0, '<b>' . DisplayFilesize($tableinfo['Data_free']) . '</b>', 0), '<a href="' . BURL('database/operate?dbaction=checktable&tablename=' . $tableinfo['Name']) . '">查错</a>', '<a href="' . BURL('database/operate?dbaction=optimizetable&tablename=' . $tableinfo['Name']) . '">优化</a>', '<a href="' . BURL('database/operate?dbaction=repairtable&tablename=' . $tableinfo['Name']) . '">修复</a>', '<a href="' . BURL('database/operate?dbaction=backuptable&tablename=' . $tableinfo['Name']) . '">备份</a>'));
            $recordsize += $tableinfo['Rows'];
            $datasize += $tableinfo['Data_length'];
            $indexsize += $tableinfo['Index_length'];
            $freesize += $tableinfo['Data_free'];
        }
        TableRow(array('<input type="checkbox" id="checkAll" for="tablenames[]">&nbsp;<label for="checkAll"><B>全选</B></label>', '系统当前共有: ' . APP::$DB->result_nums . ' 个表', $recordsize, DisplayFilesize($datasize), DisplayFilesize($indexsize), DisplayFilesize($freesize), '<input type="submit" value="查错" onclick="document.forms[\'tables\'].dbaction.value = \'checkall\';" class="cancel">', '<input type="submit" value="优化" onclick="document.forms[\'tables\'].dbaction.value = \'optimizeall\';" class="cancel">', '<input type="submit" value="修复" onclick="document.forms[\'tables\'].dbaction.value = \'repairall\';" class="cancel">', '<input type="submit" value="备份" onclick="document.forms[\'tables\'].dbaction.value = \'backupall\';" class="cancel">'), 'tr2');
        TableFooter();
        BR(2);
        $this->DisplayBackups();
        echo '<script type="text/javascript">
			$(function(){
				$("#main a.ajax").click(function(e){
					var _me=$(this);
					showDialog("确定删除数据库备份文件: " + _me.attr("file") + " 吗?", "确认操作", function(){
						ajax("' . BURL('database/ajax?action=delete') . '", {file: _me.attr("file")}, function(data){
							_me.parent().parent().hide();
						});
					});
					e.preventDefault();
				});

				$("#main a.restore").click(function(e){
					var _me=$(this);
					showDialog("确定恢复备份文件到数据库吗?<br><br><span class=red>注: 数据库中现有数据将被替换.</span>", "确认操作", function(){
						document.location="' . BURL('database/restore') . '" + "&file=" + _me.attr("file");
					});
					e.preventDefault();
				});
			});
		</script>';
    }