function show_messages($bool = TRUE, $okmsg = NULL, $errmsg = NULL)
{
    global $page, $ZBX_MESSAGES;
    if (!defined('PAGE_HEADER_LOADED')) {
        return;
    }
    if (defined('ZBX_API_REQUEST')) {
        return;
    }
    if (!isset($page['type'])) {
        $page['type'] = PAGE_TYPE_HTML;
    }
    $message = array();
    $width = 0;
    $height = 0;
    $img_space = null;
    if (!$bool && !is_null($errmsg)) {
        $msg = S_CONFIG_ERROR_HEAD . ': ' . $errmsg;
    } else {
        if ($bool && !is_null($okmsg)) {
            $msg = $okmsg;
        }
    }
    $api_errors = CZBXAPI::resetErrors();
    if (!empty($api_errors)) {
        error($api_errors);
    }
    if (isset($msg)) {
        switch ($page['type']) {
            case PAGE_TYPE_IMAGE:
                array_push($message, array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68), 'font' => 2));
                $width = max($width, ImageFontWidth(2) * zbx_strlen($msg) + 1);
                $height += imagefontheight(2) + 1;
                break;
            case PAGE_TYPE_XML:
                echo htmlspecialchars($msg) . "\n";
                break;
                //				case PAGE_TYPE_JS: break;
            //				case PAGE_TYPE_JS: break;
            case PAGE_TYPE_HTML:
            default:
                $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr');
                $msg_tab->setCellPadding(0);
                $msg_tab->setCellSpacing(0);
                $row = array();
                $msg_col = new CCol(bold($msg), 'msg_main msg');
                $msg_col->setAttribute('id', 'page_msg');
                $row[] = $msg_col;
                if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
                    $msg_details = new CDiv(S_DETAILS, 'blacklink');
                    $msg_details->setAttribute('onclick', "javascript: ShowHide('msg_messages', IE?'block':'table');");
                    $msg_details->setAttribute('title', S_MAXIMIZE . '/' . S_MINIMIZE);
                    array_unshift($row, new CCol($msg_details, 'clr'));
                }
                $msg_tab->addRow($row);
                $msg_tab->show();
                $img_space = new CImg('images/general/tree/zero.gif', 'space', '100', '2');
                break;
        }
    }
    if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
        if ($page['type'] == PAGE_TYPE_IMAGE) {
            $msg_font = 2;
            foreach ($ZBX_MESSAGES as $msg) {
                if ($msg['type'] == 'error') {
                    array_push($message, array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55), 'font' => $msg_font));
                } else {
                    array_push($message, array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55), 'font' => $msg_font));
                }
                $width = max($width, imagefontwidth($msg_font) * zbx_strlen($msg['message']) + 1);
                $height += imagefontheight($msg_font) + 1;
            }
        } else {
            if ($page['type'] == PAGE_TYPE_XML) {
                foreach ($ZBX_MESSAGES as $msg) {
                    echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n";
                }
            } else {
                $lst_error = new CList(null, 'messages');
                foreach ($ZBX_MESSAGES as $msg) {
                    $lst_error->addItem($msg['message'], $msg['type']);
                    $bool = $bool && 'error' != zbx_strtolower($msg['type']);
                }
                //message scroll if needed
                $msg_show = 6;
                $msg_count = count($ZBX_MESSAGES);
                if ($msg_count > $msg_show) {
                    $msg_count = $msg_show;
                    $msg_count = $msg_count * 16;
                    $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;');
                }
                $tab = new CTable(null, $bool ? 'msgok' : 'msgerr');
                $tab->setCellPadding(0);
                $tab->setCellSpacing(0);
                $tab->setAttribute('id', 'msg_messages');
                $tab->setAttribute('style', 'width: 100%;');
                if (isset($msg_tab) && $bool) {
                    $tab->setAttribute('style', 'display: none;');
                }
                $tab->addRow(new CCol($lst_error, 'msg'));
                $tab->Show();
                //---
            }
        }
        $ZBX_MESSAGES = null;
    }
    if (!is_null($img_space)) {
        print unpack_object($img_space);
    }
    if ($page['type'] == PAGE_TYPE_IMAGE && count($message) > 0) {
        $width += 2;
        $height += 2;
        $canvas = imagecreate($width, $height);
        imagefilledrectangle($canvas, 0, 0, $width, $height, imagecolorallocate($canvas, 255, 255, 255));
        foreach ($message as $id => $msg) {
            $message[$id]['y'] = 1 + (isset($previd) ? $message[$previd]['y'] + $message[$previd]['h'] : 0);
            $message[$id]['h'] = imagefontheight($msg['font']);
            imagestring($canvas, $msg['font'], 1, $message[$id]['y'], $msg['text'], imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B']));
            $previd = $id;
        }
        imageOut($canvas);
        imagedestroy($canvas);
    }
}
Beispiel #2
0
    
    		$page_menu->addItem($search_div);
    //*/
    $page_menu->show();
}
//------------------------------------- <HISTORY> ---------------------------------------
if (isset($page['hist_arg']) && $USER_DETAILS['alias'] != ZBX_GUEST_USER && $page['type'] == PAGE_TYPE_HTML && !defined('ZBX_PAGE_NO_MENU')) {
    $table = new CTable();
    $table->setClass('history');
    $table->setCellSpacing(0);
    $table->setCellPadding(0);
    $history = get_user_history();
    $tr = new CRow(new CCol('History:', 'caption'));
    $tr->addItem($history);
    $table->addRow($tr);
    $table->Show();
} else {
    if ($page['type'] == PAGE_TYPE_HTML && !defined('ZBX_PAGE_NO_MENU')) {
        echo SBR;
    }
}
//------------------------------------ </HISTORY> ---------------------------------------
unset($ZBX_MENU);
unset($table, $top_page_row, $menu_table, $node_form);
unset($main_menu_row);
unset($db_nodes, $node_data);
unset($sub_menu_table, $sub_menu_rows);
if ($denyed_page_requested) {
    access_deny();
}
if (version_compare(phpversion(), '5.1.0RC1', '>=') && $page['type'] == PAGE_TYPE_HTML) {
Beispiel #3
0
$rep_tab->addOption('border', 0);
// --------------
switch ($config) {
    case 1:
        $rep_form = bar_report_form();
        break;
    case 2:
        $rep_form = bar_report_form2();
        break;
    case 3:
        $rep_form = bar_report_form3();
        break;
    default:
        $rep_form = bar_report_form();
}
$form = create_filter(S_REPORTS, NULL, $rep_form, 'report_form', get_profile('web.report6.filter.state', 1));
$form->Show();
if (isset($_REQUEST['report_show'])) {
    $src = 'chart_bar.php?config=' . $_REQUEST['config'] . url_param('title') . url_param('xlabel') . url_param('ylabel') . url_param('scaletype') . url_param('avgperiod') . url_param('showlegend') . url_param('sorttype') . url_param('report_timesince') . url_param('report_timetill') . url_param('periods') . url_param('items') . url_param('hostids') . url_param('groupids') . url_param('palette') . url_param('palettetype');
    $rep_tab->addRow(create_hat(S_REPORT, new CImg($src, 'report'), null, 'hat_report', get_profile('web.report6.hats.hat_report.state', 1)));
}
$outer_table = new CTable();
$outer_table->addOption('border', 0);
$outer_table->addOption('width', '100%');
$outer_table->setCellPadding(1);
$outer_table->setCellSpacing(1);
$tmp_row = new CRow($rep_tab);
$tmp_row->addOption('align', 'center');
$outer_table->addRow($tmp_row);
$outer_table->Show();
include_once 'include/page_footer.php';