Exemplo n.º 1
0
 /**
  * Load the graph theme from the database.
  */
 public function applyGraphTheme()
 {
     $themes = DB::find('graph_theme', ['theme' => getUserTheme(CWebUser::$data)]);
     if ($themes) {
         $this->graphtheme = $themes[0];
     }
 }
 /**
  * Load the graph theme from the database.
  */
 public function applyGraphTheme()
 {
     $theme = DB::find('graph_theme', array('theme' => getUserTheme(CWebUser::$data)));
     $theme = reset($theme);
     if ($theme) {
         $this->graphtheme = $theme;
     }
 }
 protected function doAction()
 {
     $data = ['theme' => getUserTheme(CWebUser::$data), 'messages' => []];
     if (CSession::keyExists('messages')) {
         $data['messages'] = CSession::getValue('messages');
         CSession::unsetValue(['messages']);
     }
     $this->setResponse(new CControllerResponseData($data));
 }
Exemplo n.º 4
0
 public function applyGraphTheme($description = null)
 {
     global $USER_DETAILS;
     if (!is_null($description)) {
         $sql_where = ' AND gt.description=' . zbx_dbstr($description);
     } else {
         $css = getUserTheme($USER_DETAILS);
         if ($css == 'css_od.css') {
             $css = 'css_bb.css';
         }
         $sql_where = ' AND gt.theme=' . zbx_dbstr($css);
     }
     $sql = 'SELECT gt.* ' . ' FROM graph_theme gt ' . ' WHERE ' . DBin_node('gt.graphthemeid') . $sql_where;
     //SDI($sql);
     $res = DBselect($sql);
     if ($theme = DBfetch($res)) {
         $this->graphtheme = $theme;
     }
 }
Exemplo n.º 5
0
    public function preload()
    {
        $id = $this->getAttribute('id');
        if (empty($id)) {
            $id = 'img' . uniqid();
            $this->setAttribute('id', $id);
        }
        insert_js('jQuery(' . CJs::encodeJson($this->toString()) . ').load(function() {
				var parent = jQuery("#' . $id . 'preloader").parent();
				jQuery("#' . $id . 'preloader").remove();
				jQuery(parent).append(jQuery(this));
			});', true);
        $this->addClass('preloader');
        $this->setAttribute('id', $id . 'preloader');
        $this->setAttribute('src', 'styles/themes/' . getUserTheme(CWebUser::$data) . '/images/preloader.gif');
    }
Exemplo n.º 6
0
// construct menu
$main_menu = array();
$sub_menus = array();
$denied_page_requested = zbx_construct_menu($main_menu, $sub_menus, $page);
// render the "Deny access" page
if ($denied_page_requested) {
    access_deny(ACCESS_DENY_PAGE);
}
if ($page['type'] == PAGE_TYPE_HTML) {
    $pageHeader = new CPageHeader($pageTitle);
    $pageHeader->addCssInit();
    $css = ZBX_DEFAULT_THEME;
    if (!ZBX_PAGE_NO_THEME) {
        if (!empty($DB['DB'])) {
            $config = select_config();
            $css = getUserTheme(CWebUser::$data);
            $severityCss = <<<CSS
.disaster { background: #{$config['severity_color_5']} !important; }
.high { background: #{$config['severity_color_4']} !important; }
.average { background: #{$config['severity_color_3']} !important; }
.warning { background: #{$config['severity_color_2']} !important; }
.information { background: #{$config['severity_color_1']} !important; }
.not_classified { background: #{$config['severity_color_0']} !important; }
CSS;
            $pageHeader->addStyle($severityCss);
            // perform Zabbix server check only for standard pages
            if ((!defined('ZBX_PAGE_NO_MENU') || defined('ZBX_PAGE_FULLSCREEN')) && $config['server_check_interval'] && !empty($ZBX_SERVER) && !empty($ZBX_SERVER_PORT)) {
                $page['scripts'][] = 'servercheck.js';
            }
        }
    }
							+ '&ymax_itemid=' + jQuery('#ymax_itemid').val()
							+ '&showworkperiod=' + (jQuery('#show_work_period').is(':checked') ? 1 : 0)
							+ '&showtriggers=' + (jQuery('#show_triggers').is(':checked') ? 1 : 0);
			<?php 
}
?>

			jQuery('#itemsTable tr.sortable').find('*[name]').each(function(index, value) {
				if (!jQuery.isEmptyObject(value) && value.name != null) {
					src += '&' + value.name + '=' + value.value;
				}
			});

			jQuery('#previewTab img')
				.attr('src', 'styles/themes/<?php 
echo getUserTheme(CWebUser::$data);
?>
/images/preloader.gif')
				.width(80)
				.height(12);
			jQuery('<img />').attr('src', name + '?period=3600' + src).load(function() {
				jQuery('#previewChar img').remove();
				jQuery('#previewChar').append(jQuery(this));
			});
		});
	});

	<?php 
if (!empty($this->data['templateid'])) {
    ?>
		jQuery(document).ready(function() {
Exemplo n.º 8
0
    <title><?php 
    echo $page_title;
    ?>
</title>
	<meta name="Author" content="ZABBIX SIA" />
	<link rel="shortcut icon" href="images/general/zabbix.ico" />
	<link rel="stylesheet" type="text/css" href="css.css" />
<!--[if IE 6]>
	<script type="text/javascript" src="js/ie6fix.js"></script>
	<link rel="stylesheet" type="text/css" href="styles/ie.css" />
<![endif]-->

<?php 
    if (isset($DB['DB']) && !is_null($DB['DB'])) {
        $config = select_config();
        $css = getUserTheme($USER_DETAILS);
        $config = select_config();
        if ($css) {
            print '<link rel="stylesheet" type="text/css" href="styles/' . $css . '" />' . "\n";
            print '<!--[if IE 6]><link rel="stylesheet" type="text/css" href="styles/ie_' . $css . '" /><![endif]-->' . "\n";
        }
    }
    if ($page['file'] == 'sysmap.php') {
        print '<link rel="stylesheet" type="text/css" href="imgstore.php?css=1&output=css" />';
    }
    ?>
<script type="text/javascript">	var PHP_TZ_OFFSET = <?php 
    echo date('Z');
    ?>
;</script>
<?php 
Exemplo n.º 9
0
/**
 * Renders an "access denied" message and stops the execution of the script.
 *
 * The $mode parameters controls the layout of the message for logged in users:
 * - ACCESS_DENY_OBJECT     - render the message when denying access to a specific object
 * - ACCESS_DENY_PAGE       - render a complete access denied page
 *
 * If visitor is without any access permission then layout of the message is same as in ACCESS_DENY_PAGE mode.
 *
 * @param int $mode
 */
function access_deny($mode = ACCESS_DENY_OBJECT)
{
    // deny access to an object
    if ($mode == ACCESS_DENY_OBJECT && CWebUser::isLoggedIn()) {
        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'] : ''))->removeArgument('sid');
        $url = urlencode($url->toString());
        // if the user is logged in - render the access denied message
        if (CWebUser::isLoggedIn()) {
            $data = ['header' => _('Access denied'), 'messages' => [_s('You are logged in as "%1$s".', CWebUser::$data['alias']) . ' ' . _('You have no permissions to access this page.'), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.')], 'buttons' => []];
            // display the login button only for guest users
            if (CWebUser::isGuest()) {
                $data['buttons'][] = (new CButton('login', _('Login')))->onClick('javascript: document.location = "index.php?request=' . $url . '";');
            }
            $data['buttons'][] = (new CButton('back', _('Go to dashboard')))->onClick('javascript: document.location = "zabbix.php?action=dashboard.view"');
        } else {
            $data = ['header' => _('You are not logged in'), 'messages' => [_('You must login to view this page.'), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.')], 'buttons' => [(new CButton('login', _('Login')))->onClick('javascript: document.location = "index.php?request=' . $url . '";')]];
        }
        $data['theme'] = getUserTheme(CWebUser::$data);
        (new CView('general.warning', $data))->render();
        exit;
    }
}
Exemplo n.º 10
0
/*
 * Display
 */
$start_time = microtime(true);
$sizeX = 900;
$sizeY = 300;
$shiftX = 12;
$shiftYup = 25;
$shiftYdown = 25 + 15 * 3;
if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) {
    $im = imagecreatetruecolor($sizeX + $shiftX + 61, $sizeY + $shiftYup + $shiftYdown + 10);
} else {
    $im = imagecreate($sizeX + $shiftX + 61, $sizeY + $shiftYup + $shiftYdown + 10);
}
$graphtheme = ['theme' => 'blue-theme', 'textcolor' => '1F2C33', 'highlightcolor' => 'E33734', 'backgroundcolor' => 'FFFFFF', 'graphcolor' => 'FFFFFF', 'gridcolor' => 'CCD5D9', 'maingridcolor' => 'ACBBC2', 'gridbordercolor' => 'ACBBC2', 'nonworktimecolor' => 'EBEBEB', 'leftpercentilecolor' => '429E47', 'righttpercentilecolor' => 'E33734'];
$themes = DB::find('graph_theme', ['theme' => getUserTheme(CWebUser::$data)]);
if ($themes) {
    $graphtheme = $themes[0];
}
$black = get_color($im, '000000');
$green = get_color($im, '34AF67');
$red = get_color($im, 'D64E4E');
$grey = get_color($im, '969696', 50);
$backgroundcolor = get_color($im, $graphtheme['backgroundcolor']);
$gridcolor = get_color($im, $graphtheme['gridcolor']);
$textcolor = get_color($im, $graphtheme['textcolor']);
$highlightcolor = get_color($im, $graphtheme['highlightcolor']);
$x = imagesx($im);
$y = imagesy($im);
imagefilledrectangle($im, 0, 0, $x, $y, $backgroundcolor);
$d = zbx_date2str(_x('Y', DATE_FORMAT_CONTEXT));
Exemplo n.º 11
0
// construct menu
$main_menu = [];
$sub_menus = [];
$denied_page_requested = zbx_construct_menu($main_menu, $sub_menus, $page);
// render the "Deny access" page
if ($denied_page_requested) {
    access_deny(ACCESS_DENY_PAGE);
}
if ($page['type'] == PAGE_TYPE_HTML) {
    $pageHeader = new CPageHeader($pageTitle);
    $theme = ZBX_DEFAULT_THEME;
    if (!ZBX_PAGE_NO_THEME) {
        global $DB;
        if (!empty($DB['DB'])) {
            $config = select_config();
            $theme = getUserTheme(CWebUser::$data);
            $pageHeader->addStyle(getTriggerSeverityCss($config));
            // perform Zabbix server check only for standard pages
            if ((!defined('ZBX_PAGE_NO_MENU') || defined('ZBX_PAGE_FULLSCREEN')) && $config['server_check_interval'] && !empty($ZBX_SERVER) && !empty($ZBX_SERVER_PORT)) {
                $page['scripts'][] = 'servercheck.js';
            }
        }
    }
    $pageHeader->addCssFile('styles/' . CHtml::encode($theme) . '.css');
    if ($page['file'] == 'sysmap.php') {
        $pageHeader->addCssFile('imgstore.php?css=1&output=css');
    }
    $pageHeader->addJsFile('js/browsers.js');
    $pageHeader->addJsBeforeScripts('var PHP_TZ_OFFSET = ' . date('Z') . ';');
    // show GUI messages in pages with menus and in fullscreen mode
    $showGuiMessaging = !defined('ZBX_PAGE_NO_MENU') || $_REQUEST['fullscreen'] == 1 ? 1 : 0;
Exemplo n.º 12
0
function get_items_data_overview($hostids, $view_style = null)
{
    global $USER_DETAILS;
    if (is_null($view_style)) {
        $view_style = CProfile::get('web.overview.view.style', STYLE_TOP);
    }
    $table = new CTableInfo(S_NO_ITEMS_DEFINED);
    // COpt::profiling_start('prepare_data');
    $result = DBselect('SELECT DISTINCT h.hostid, h.host,i.itemid, i.key_, i.value_type, i.lastvalue, i.units, ' . ' i.description, t.priority, i.valuemapid, t.value as tr_value, t.triggerid ' . ' FROM hosts h, items i ' . ' LEFT JOIN functions f on f.itemid=i.itemid ' . ' LEFT JOIN triggers t on t.triggerid=f.triggerid and t.status=' . TRIGGER_STATUS_ENABLED . ' WHERE ' . DBcondition('h.hostid', $hostids) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' ORDER BY i.description,i.itemid');
    unset($items);
    unset($hosts);
    // get rid of warnings about $triggers undefined
    $items = array();
    while ($row = DBfetch($result)) {
        $descr = item_description($row);
        $row['host'] = get_node_name_by_elid($row['hostid'], null, ': ') . $row['host'];
        $hosts[zbx_strtolower($row['host'])] = $row['host'];
        // A little tricky check for attempt to overwrite active trigger (value=1) with
        // inactive or active trigger with lower priority.
        if (!isset($items[$descr][$row['host']]) || ($items[$descr][$row['host']]['tr_value'] == TRIGGER_VALUE_FALSE && $row['tr_value'] == TRIGGER_VALUE_TRUE || ($items[$descr][$row['host']]['tr_value'] == TRIGGER_VALUE_FALSE || $row['tr_value'] == TRIGGER_VALUE_TRUE) && $row['priority'] > $items[$descr][$row['host']]['severity'])) {
            $items[$descr][$row['host']] = array('itemid' => $row['itemid'], 'value_type' => $row['value_type'], 'lastvalue' => $row['lastvalue'], 'units' => $row['units'], 'description' => $row['description'], 'valuemapid' => $row['valuemapid'], 'severity' => $row['priority'], 'tr_value' => $row['tr_value'], 'triggerid' => $row['triggerid']);
        }
    }
    if (!isset($hosts)) {
        return $table;
    }
    ksort($hosts, SORT_STRING);
    // COpt::profiling_stop('prepare_data');
    // COpt::profiling_start('prepare_table');
    $css = getUserTheme($USER_DETAILS);
    $vTextColor = $css == 'css_od.css' ? '&color=white' : '';
    if ($view_style == STYLE_TOP) {
        $header = array(new CCol(S_ITEMS, 'center'));
        foreach ($hosts as $hostname) {
            $header = array_merge($header, array(new CImg('vtext.php?text=' . $hostname . $vTextColor)));
        }
        $table->SetHeader($header, 'vertical_header');
        $curr_rime = time();
        foreach ($items as $descr => $ithosts) {
            $table_row = array(nbsp($descr));
            foreach ($hosts as $hostname) {
                $table_row = get_item_data_overview_cells($table_row, $ithosts, $hostname);
            }
            $table->AddRow($table_row);
        }
    } else {
        $header = array(new CCol(S_HOSTS, 'center'));
        foreach ($items as $descr => $ithosts) {
            $header = array_merge($header, array(new CImg('vtext.php?text=' . $descr . $vTextColor)));
        }
        $table->SetHeader($header, 'vertical_header');
        $curr_rime = time();
        foreach ($hosts as $hostname) {
            $table_row = array(nbsp($hostname));
            foreach ($items as $descr => $ithosts) {
                $table_row = get_item_data_overview_cells($table_row, $ithosts, $hostname);
            }
            $table->AddRow($table_row);
        }
    }
    // COpt::profiling_stop('prepare_table');
    return $table;
}
Exemplo n.º 13
0
}
// if a guest or a non-super admin user is logged in
if (CWebUser::$data && CWebUser::getType() < USER_TYPE_SUPER_ADMIN) {
    // on the last step of the setup we always have a guest user logged in;
    // when he presses the "Finish" button he must be redirected to the login screen
    if (CWebUser::isGuest() && CSession::getValue('step') == 5 && hasRequest('finish')) {
        CSession::clear();
        redirect('index.php');
    } elseif (!(CWebUser::isGuest() && CSession::getValue('step') == 5)) {
        access_deny(ACCESS_DENY_PAGE);
    }
} elseif (hasRequest('cancel') || hasRequest('finish')) {
    CSession::clear();
    redirect('index.php');
}
$theme = CWebUser::$data ? getUserTheme(CWebUser::$data) : ZBX_DEFAULT_THEME;
DBclose();
/*
 * Setup wizard
 */
$ZBX_SETUP_WIZARD = new CSetupWizard();
// if init fails due to missing configuration, set user as guest with default en_GB language
if (!CWebUser::$data) {
    CWebUser::setDefault();
}
// page title
(new CPageHeader(_('Installation')))->addCssFile('styles/' . CHtml::encode($theme) . '.css')->addJsFile('js/browsers.js')->addJsFile('jsLoader.php?ver=' . ZABBIX_VERSION . '&amp;lang=' . CWebUser::$data['lang'])->display();
/*
 * Displaying
 */
$link = (new CLink('GPL v2', 'http://www.zabbix.com/license.php'))->setTarget('_blank')->addClass(ZBX_STYLE_GREY)->addClass(ZBX_STYLE_LINK_ALT);
**
** 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.
**/
global $DB, $ZBX_SERVER, $ZBX_SERVER_NAME, $ZBX_SERVER_PORT;
$page_title = $data['page']['title'];
if (isset($ZBX_SERVER_NAME) && $ZBX_SERVER_NAME !== '') {
    $page_title = $ZBX_SERVER_NAME . NAME_DELIMITER . $page_title;
}
$pageHeader = new CPageHeader($page_title);
$scripts = [];
$theme = ZBX_DEFAULT_THEME;
if (!empty($DB['DB'])) {
    $config = select_config();
    $theme = getUserTheme($data['user']);
    $pageHeader->addStyle(getTriggerSeverityCss($config));
    // perform Zabbix server check only for standard pages
    if ($config['server_check_interval'] && !empty($ZBX_SERVER) && !empty($ZBX_SERVER_PORT)) {
        $scripts[] = 'servercheck.js';
    }
}
$pageHeader->addCssFile('styles/' . CHtml::encode($theme) . '.css');
$pageHeader->addJsFile('js/browsers.js');
$pageHeader->addJsBeforeScripts('var PHP_TZ_OFFSET = ' . date('Z') . ';');
// show GUI messages in pages with menus and in fullscreen mode
$showGuiMessaging = !defined('ZBX_PAGE_NO_MENU') || $_REQUEST['fullscreen'] == 1 ? 1 : 0;
$path = 'jsLoader.php?ver=' . ZABBIX_VERSION . '&amp;lang=' . $data['user']['lang'] . '&showGuiMessaging=' . $showGuiMessaging;
$pageHeader->addJsFile($path);
if ($scripts) {
    $pageHeader->addJsFile('jsLoader.php?' . 'files[]=' . implode('&amp;files[]=', $scripts));
Exemplo n.º 15
0
function get_triggers_overview($hostids, $view_style = null)
{
    global $USER_DETAILS;
    if (is_null($view_style)) {
        $view_style = CProfile::get('web.overview.view.style', STYLE_TOP);
    }
    $table = new CTableInfo(S_NO_TRIGGERS_DEFINED);
    $options = array('hostids' => $hostids, 'monitored' => 1, 'expandData' => 1, 'skipDependent' => 1, 'output' => API_OUTPUT_EXTEND, 'sortfield' => 'description');
    $db_triggers = CTrigger::get($options);
    unset($triggers);
    unset($hosts);
    $triggers = array();
    foreach ($db_triggers as $tnum => $row) {
        $row['host'] = get_node_name_by_elid($row['hostid'], null, ': ') . $row['host'];
        $row['description'] = expand_trigger_description_constants($row['description'], $row);
        $hosts[zbx_strtolower($row['host'])] = $row['host'];
        // A little tricky check for attempt to overwrite active trigger (value=1) with
        // inactive or active trigger with lower priority.
        if (!isset($triggers[$row['description']][$row['host']]) || ($triggers[$row['description']][$row['host']]['value'] == TRIGGER_VALUE_FALSE && $row['value'] == TRIGGER_VALUE_TRUE || ($triggers[$row['description']][$row['host']]['value'] == TRIGGER_VALUE_FALSE || $row['value'] == TRIGGER_VALUE_TRUE) && $row['priority'] > $triggers[$row['description']][$row['host']]['priority'])) {
            $triggers[$row['description']][$row['host']] = array('hostid' => $row['hostid'], 'triggerid' => $row['triggerid'], 'value' => $row['value'], 'lastchange' => $row['lastchange'], 'priority' => $row['priority']);
        }
    }
    if (!isset($hosts)) {
        return $table;
    }
    ksort($hosts);
    $css = getUserTheme($USER_DETAILS);
    $vTextColor = $css == 'css_od.css' ? '&color=white' : '';
    if ($view_style == STYLE_TOP) {
        $header = array(new CCol(S_TRIGGERS, 'center'));
        foreach ($hosts as $hostname) {
            $header = array_merge($header, array(new CCol(array(new CImg('vtext.php?text=' . $hostname . $vTextColor)), 'hosts')));
        }
        $table->setHeader($header, 'vertical_header');
        foreach ($triggers as $descr => $trhosts) {
            $table_row = array(nbsp($descr));
            foreach ($hosts as $hostname) {
                $table_row = get_trigger_overview_cells($table_row, $trhosts, $hostname);
            }
            $table->addRow($table_row);
        }
    } else {
        $header = array(new CCol(S_HOSTS, 'center'));
        foreach ($triggers as $descr => $trhosts) {
            $descr = array(new CImg('vtext.php?text=' . $descr . $vTextColor));
            array_push($header, $descr);
        }
        $table->setHeader($header, 'vertical_header');
        foreach ($hosts as $hostname) {
            $table_row = array(nbsp($hostname));
            foreach ($triggers as $descr => $trhosts) {
                $table_row = get_trigger_overview_cells($table_row, $trhosts, $hostname);
            }
            $table->addRow($table_row);
        }
    }
    return $table;
}