function see_also_page_template()
 {
     $parent_post_id = array_key_exists('parent', $_GET) ? $_GET['parent'] : 0;
     if (array_key_exists('meta', $_GET)) {
         $meta_id = $_GET['meta'];
     } else {
         if (is_page('video')) {
             $meta_id = get_meta_id_by_key($parent_post_id, 'external_video_url');
         }
     }
     if (empty($meta_id)) {
         show_error_message('missing_meta_param', $parent_post_id);
     }
     $external_url_meta = get_metadata_by_mid('post', $meta_id);
     if (!empty($external_url_meta->meta_value)) {
         echo do_shortcode('[iframe src="' . $external_url_meta->meta_value . '" width="100% height="100%]');
     } else {
         show_error_message('missing_url', $parent_post_id);
     }
 }
Example #2
0
function invalid_url($msg = null)
{
    if (empty($msg)) {
        $msg = _('Zabbix has received an incorrect request.');
    }
    // required global parameters for correct including page_header.php
    global $DB, $ZBX_MESSAGES;
    // backup messages before including page_header.php
    $temp = $ZBX_MESSAGES;
    $ZBX_MESSAGES = null;
    require_once dirname(__FILE__) . '/page_header.php';
    // rollback reseted messages
    $ZBX_MESSAGES = $temp;
    unset_all();
    show_error_message($msg);
    require_once dirname(__FILE__) . '/page_footer.php';
}
** 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.
**/
require_once dirname(__FILE__) . '/include/config.inc.php';
$page['file'] = 'chart.php';
$page['type'] = PAGE_TYPE_IMAGE;
require_once dirname(__FILE__) . '/include/page_header.php';
// VAR	TYPE	OPTIONAL	FLAGS	VALIDATION	EXCEPTION
$fields = array('itemid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), 'screenid' => array(T_ZBX_STR, O_OPT, null, null, null), 'period' => array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD, ZBX_MAX_PERIOD), null), 'stime' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'profileIdx' => array(T_ZBX_STR, O_OPT, null, null, null), 'profileIdx2' => array(T_ZBX_STR, O_OPT, null, null, null), 'updateProfile' => array(T_ZBX_STR, O_OPT, null, null, null), 'from' => array(T_ZBX_INT, O_OPT, null, '{}>=0', null), 'width' => array(T_ZBX_INT, O_OPT, null, '{}>0', null), 'height' => array(T_ZBX_INT, O_OPT, null, '{}>0', null), 'border' => array(T_ZBX_INT, O_OPT, null, IN('0,1'), null));
check_fields($fields);
/*
 * Permissions
 */
if (!DBfetch(DBselect('SELECT i.itemid FROM items i WHERE i.itemid=' . $_REQUEST['itemid']))) {
    show_error_message(_('No items defined.'));
}
$dbItems = API::Item()->get(array('itemids' => $_REQUEST['itemid'], 'webitems' => true, 'nodeids' => get_current_nodeid(true), 'filter' => array('flags' => null)));
if (empty($dbItems)) {
    access_deny();
}
/*
 * Display
 */
$timeline = CScreenBase::calculateTime(array('profileIdx' => get_request('profileIdx', 'web.screens'), 'profileIdx2' => get_request('profileIdx2'), 'updateProfile' => get_request('updateProfile', true), 'period' => get_request('period'), 'stime' => get_request('stime')));
$graph = new CChart();
$graph->setPeriod($timeline['period']);
$graph->setSTime($timeline['stime']);
if (isset($_REQUEST['from'])) {
    $graph->setFrom($_REQUEST['from']);
}
Example #4
0
require_once dirname(__FILE__) . '/include/forms.inc.php';
$page['title'] = _('Scripts');
$page['file'] = 'scripts_exec.php';
define('ZBX_PAGE_NO_MENU', 1);
require_once dirname(__FILE__) . '/include/page_header.php';
// VAR	TYPE	OPTIONAL	FLAGS	VALIDATION	EXCEPTION
$fields = array('hostid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({execute})'), 'scriptid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({execute})'), 'execute' => array(T_ZBX_INT, O_OPT, P_ACT, IN('0,1'), null));
check_fields($fields);
if (isset($_REQUEST['execute'])) {
    $scriptid = get_request('scriptid');
    $hostid = get_request('hostid');
    $data = array('message' => '', 'info' => DBfetch(DBselect('SELECT s.name FROM scripts s WHERE s.scriptid=' . zbx_dbstr($scriptid))));
    $result = API::Script()->execute(array('hostid' => $hostid, 'scriptid' => $scriptid));
    $isErrorExist = false;
    if (empty($result)) {
        $isErrorExist = true;
    } elseif ($result['response'] == 'failed') {
        error($result['value']);
        $isErrorExist = true;
    } else {
        $data['message'] = $result['value'];
    }
    if ($isErrorExist) {
        show_error_message(_('Cannot connect to the trapper port of zabbix server daemon, but it should be available to run the script.'));
    }
    // render view
    $scriptView = new CView('general.script.execute', $data);
    $scriptView->render();
    $scriptView->show();
}
require_once dirname(__FILE__) . '/include/page_footer.php';
Example #5
0
define('ZBX_PAGE_DO_REFRESH', 1);
require_once dirname(__FILE__) . '/include/page_header.php';
$queueModes = [QUEUE_OVERVIEW, QUEUE_OVERVIEW_BY_PROXY, QUEUE_DETAILS];
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = ['config' => [T_ZBX_INT, O_OPT, P_SYS, IN($queueModes), null]];
check_fields($fields);
$config = getRequest('config', CProfile::get('web.queue.config', 0));
CProfile::update('web.queue.config', $config, PROFILE_TYPE_INT);
// fetch data
$zabbixServer = new CZabbixServer($ZBX_SERVER, $ZBX_SERVER_PORT, ZBX_SOCKET_TIMEOUT, ZBX_SOCKET_BYTES_LIMIT);
$queueRequests = [QUEUE_OVERVIEW => CZabbixServer::QUEUE_OVERVIEW, QUEUE_OVERVIEW_BY_PROXY => CZabbixServer::QUEUE_OVERVIEW_BY_PROXY, QUEUE_DETAILS => CZabbixServer::QUEUE_DETAILS];
$queueData = $zabbixServer->getQueue($queueRequests[$config], get_cookie('zbx_sessionid'));
// check for errors error
if ($zabbixServer->getError()) {
    error($zabbixServer->getError());
    show_error_message(_('Cannot display item queue.'));
    require_once dirname(__FILE__) . '/include/page_footer.php';
}
$widget = (new CWidget())->setTitle(_('Queue of items to be updated'))->setControls((new CForm('get'))->cleanItems()->addItem((new CList())->addItem((new CComboBox('config', $config, 'submit();'))->addItem(QUEUE_OVERVIEW, _('Overview'))->addItem(QUEUE_OVERVIEW_BY_PROXY, _('Overview by proxy'))->addItem(QUEUE_DETAILS, _('Details')))));
$table = new CTableInfo();
$severityConfig = select_config();
// overview
if ($config == QUEUE_OVERVIEW) {
    $itemTypes = [ITEM_TYPE_ZABBIX, ITEM_TYPE_ZABBIX_ACTIVE, ITEM_TYPE_SIMPLE, ITEM_TYPE_SNMPV1, ITEM_TYPE_SNMPV2C, ITEM_TYPE_SNMPV3, ITEM_TYPE_INTERNAL, ITEM_TYPE_AGGREGATE, ITEM_TYPE_EXTERNAL, ITEM_TYPE_DB_MONITOR, ITEM_TYPE_IPMI, ITEM_TYPE_SSH, ITEM_TYPE_TELNET, ITEM_TYPE_JMX, ITEM_TYPE_CALCULATED];
    $table->setHeader([_('Items'), _('5 seconds'), _('10 seconds'), _('30 seconds'), _('1 minute'), _('5 minutes'), _('More than 10 minutes')]);
    $queueData = zbx_toHash($queueData, 'itemtype');
    foreach ($itemTypes as $type) {
        if (isset($queueData[$type])) {
            $itemTypeData = $queueData[$type];
        } else {
            $itemTypeData = ['delay5' => 0, 'delay10' => 0, 'delay30' => 0, 'delay60' => 0, 'delay300' => 0, 'delay600' => 0];
Example #6
0
    ob_end_clean();
    redirect(CWebUser::$data['last_page']['url']);
} elseif (hasRequest('update')) {
    $auth_type = getUserAuthenticationType(CWebUser::$data['userid']);
    if ($auth_type != ZBX_AUTH_INTERNAL) {
        $_REQUEST['password1'] = $_REQUEST['password2'] = null;
    } else {
        $_REQUEST['password1'] = getRequest('password1');
        $_REQUEST['password2'] = getRequest('password2');
    }
    if ($_REQUEST['password1'] != $_REQUEST['password2']) {
        show_error_message(_('Cannot update user. Both passwords must be equal.'));
    } elseif (isset($_REQUEST['password1']) && CWebUser::$data['alias'] == ZBX_GUEST_USER && !zbx_empty($_REQUEST['password1'])) {
        show_error_message(_('For guest, password must be empty'));
    } elseif (isset($_REQUEST['password1']) && CWebUser::$data['alias'] != ZBX_GUEST_USER && zbx_empty($_REQUEST['password1'])) {
        show_error_message(_('Password should not be empty'));
    } else {
        $user = array();
        $user['userid'] = CWebUser::$data['userid'];
        $user['alias'] = CWebUser::$data['alias'];
        $user['passwd'] = getRequest('password1');
        $user['url'] = getRequest('url');
        $user['autologin'] = getRequest('autologin', 0);
        $user['autologout'] = hasRequest('autologout_visible') ? getRequest('autologout') : 0;
        $user['theme'] = getRequest('theme');
        $user['refresh'] = getRequest('refresh');
        $user['rows_per_page'] = getRequest('rows_per_page');
        $user['user_groups'] = null;
        $user['user_medias'] = getRequest('user_medias', array());
        if (hasRequest('lang')) {
            $user['lang'] = getRequest('lang');
Example #7
0
     } else {
         $_REQUEST['password1'] = $_REQUEST['password2'] = 'zabbix';
     }
 }
 if ($_REQUEST['password1'] != $_REQUEST['password2']) {
     if (isset($_REQUEST['userid'])) {
         show_error_message(S_CANNOT_UPDATE_USER_BOTH_PASSWORDS);
     } else {
         show_error_message(S_CANNOT_ADD_USER_BOTH_PASSWORDS_MUST);
     }
 } else {
     if (isset($_REQUEST['password1']) && $_REQUEST['alias'] == ZBX_GUEST_USER && !zbx_empty($_REQUEST['password1'])) {
         show_error_message(S_FOR_GUEST_PASSWORD_MUST_BE_EMPTY);
     } else {
         if (isset($_REQUEST['password1']) && $_REQUEST['alias'] != ZBX_GUEST_USER && zbx_empty($_REQUEST['password1'])) {
             show_error_message(S_PASSWORD_SHOULD_NOT_BE_EMPTY);
         } else {
             if (isset($_REQUEST['userid'])) {
                 $action = AUDIT_ACTION_UPDATE;
                 DBstart();
                 $result = update_user($_REQUEST['userid'], $_REQUEST['name'], $_REQUEST['surname'], $_REQUEST['alias'], $_REQUEST['password1'], $_REQUEST['url'], get_request('autologin', 0), get_request('autologout', 0), $_REQUEST['lang'], $_REQUEST['theme'], $_REQUEST['refresh'], $_REQUEST['user_type'], $user_groups, $user_medias);
                 $result = DBend($result);
                 show_messages($result, S_USER_UPDATED, S_CANNOT_UPDATE_USER);
             } else {
                 $action = AUDIT_ACTION_ADD;
                 DBstart();
                 $result = add_user($_REQUEST['name'], $_REQUEST['surname'], $_REQUEST['alias'], $_REQUEST['password1'], $_REQUEST['url'], get_request('autologin', 0), get_request('autologout', 0), $_REQUEST['lang'], $_REQUEST['theme'], $_REQUEST['refresh'], $_REQUEST['user_type'], $user_groups, $user_medias);
                 $result = DBend($result);
                 show_messages($result, S_USER_ADDED, S_CANNOT_ADD_USER);
             }
             if ($result) {
Example #8
0
$dbItems = zbx_toHash($dbItems, 'itemid');
foreach ($items as $item) {
    if (!isset($dbItems[$item['itemid']])) {
        access_deny();
    }
}
/*
 * Validation
 */
$types = array();
foreach ($items as $item) {
    if ($item['type'] == GRAPH_ITEM_SUM) {
        if (!in_array($item['type'], $types)) {
            array_push($types, $item['type']);
        } else {
            show_error_message(_('Cannot display more than one item with type "Graph sum".'));
            break;
        }
    }
}
/*
 * Display
 */
if ($isDataValid) {
    navigation_bar_calc();
    $graph = new CPieGraphDraw(getRequest('graphtype', GRAPH_TYPE_NORMAL));
    $graph->setHeader(getRequest('name', ''));
    if (!empty($_REQUEST['graph3d'])) {
        $graph->switchPie3D();
    }
    $graph->showLegend(getRequest('legend', 0));
Example #9
0
function invalid_url($msg = S_INVALID_URL_PARAMS)
{
    include_once 'include/page_header.php';
    unset_all();
    show_error_message($msg);
    include_once 'include/page_footer.php';
}
Example #10
0
 /**
  * Check if Y axis min value is larger than Y axis max value. Show error instead of graph if true.
  *
  * @param float $min		Y axis min value
  * @param float $max		Y axis max value
  */
 protected function validateMinMax($min, $max)
 {
     if (bccomp($min, $max) == 0 || bccomp($min, $max) == 1) {
         show_error_message(_('Y axis MAX value must be greater than Y axis MIN value.'));
         exit;
     }
 }
Example #11
0
    access_deny();
}
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array('password1' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})&&isset({form})&&({form}!="update")&&isset({change_password})'), 'password2' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})&&isset({form})&&({form}!="update")&&isset({change_password})'), 'lang' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})'), 'theme' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})'), 'autologin' => array(T_ZBX_INT, O_OPT, null, IN('0,1'), null), 'autologout' => array(T_ZBX_INT, O_OPT, null, BETWEEN(90, 10000), null), 'url' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), 'refresh' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 3600), 'isset({save})'), 'change_password' => array(T_ZBX_STR, O_OPT, null, null, null), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_STR, O_OPT, null, null, null));
check_fields($fields);
if (isset($_REQUEST['cancel'])) {
    $url = get_profile('web.menu.view.last', 'index.php');
    redirect($url);
} else {
    if (isset($_REQUEST['save'])) {
        $_REQUEST['password1'] = get_request('password1', null);
        $_REQUEST['password2'] = get_request('password2', null);
        if (isset($_REQUEST['password1']) && $_REQUEST['password1'] == '') {
            show_error_message(S_ONLY_FOR_GUEST_ALLOWED_EMPTY_PASSWORD);
        } else {
            if ($_REQUEST['password1'] == $_REQUEST['password2']) {
                $result = update_user_profile($USER_DETAILS['userid'], $_REQUEST['password1'], $_REQUEST['url'], get_request('autologin', 0), get_request('autologout', 0), $_REQUEST['lang'], $_REQUEST['theme'], $_REQUEST['refresh']);
                show_messages($result, S_USER_UPDATED, S_CANNOT_UPDATE_USER);
                if ($result) {
                    add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_USER, 'User alias [' . $USER_DETAILS['alias'] . '] name [' . $USER_DETAILS['name'] . '] surname [' . $USER_DETAILS['surname'] . '] profile id [' . $USER_DETAILS['userid'] . ']');
                }
            } else {
                show_error_message(S_CANNOT_UPDATE_USER_BOTH_PASSWORDS);
            }
        }
    }
}
show_table_header(S_USER_PROFILE_BIG . ' : ' . $USER_DETAILS['name'] . ' ' . $USER_DETAILS['surname']);
echo '<br>';
insert_user_form($USER_DETAILS['userid'], 1);
include_once 'include/page_footer.php';
Example #12
0
/**
 * Validate periods array for bar reports - time since, time till and color.
 * Automatically set caption if none is set.
 *
 * @param array $periods
 *
 * @return mixed	valid periods array on success or false on failure
 */
function validateBarReportPeriods($periods = array())
{
    if (!isset($periods) || !$periods) {
        return false;
    }
    $fields = array('report_timesince', 'report_timetill', 'color');
    $colorValidator = new CColorValidator();
    foreach ($periods as &$period) {
        foreach ($fields as $field) {
            if (!isset($period[$field]) || !$period[$field]) {
                show_error_message(_s('Missing "%1$s" field for period.', $field));
                return false;
            }
        }
        if (!$colorValidator->validate($period['color'])) {
            show_error_message($colorValidator->getError());
            return false;
        }
        if (!validateUnixTime($period['report_timesince'])) {
            show_error_message(_s('Invalid period for field "%1$s".', 'report_timesince'));
            return false;
        }
        if (!validateUnixTime($period['report_timetill'])) {
            show_error_message(_s('Invalid period for field "%1$s".', 'report_timetill'));
            return false;
        }
        if (!isset($period['caption']) || zbx_empty($period['caption'])) {
            $period['caption'] = zbx_date2str(REPORTS_BAR_REPORT_DATE_FORMAT, $period['report_timesince']) . ' - ' . zbx_date2str(REPORTS_BAR_REPORT_DATE_FORMAT, $period['report_timetill']);
        }
    }
    unset($period);
    return $periods;
}
Example #13
0
function fatal_error($msg)
{
    include_once 'include/page_header.php';
    show_error_message($msg);
    include_once 'include/page_footer.php';
}
// header form
$configComboBox = new CComboBox('config', 'screens.php', 'javascript: redirect(this.options[this.selectedIndex].value);');
$configComboBox->addItem('screens.php', _('Screens'));
$configComboBox->addItem('slides.php', _('Slide shows'));
$headerForm = new CForm();
$headerForm->addItem($configComboBox);
if (empty($this->data['screens'])) {
    $screenWidget->addPageHeader(_('SCREENS'), $headerForm);
    $screenWidget->addItem(BR());
    $screenWidget->addItem(new CTableInfo(_('No screens defined.')));
    $screenBuilder = new CScreenBuilder();
    CScreenBuilder::insertScreenStandardJs(array('timeline' => $screenBuilder->timeline));
} elseif (!isset($this->data['screens'][$this->data['elementIdentifier']]) && !$this->data['id_has_been_fetched_from_profile']) {
    // if screen we are searching for does not exist and was not fetched from profile
    $error_msg = $this->data['use_screen_name'] ? _s('Screen with name "%s" does not exist.', $this->data['elementIdentifier']) : _s('Screen with ID "%s" does not exist.', $this->data['elementIdentifier']);
    show_error_message($error_msg);
} else {
    if (!isset($this->data['screens'][$this->data['elementIdentifier']])) {
        // this means id was fetched from profile and this screen does not exist
        // in this case we need to show the first one
        $screen = reset($this->data['screens']);
    } else {
        $screen = $this->data['screens'][$this->data['elementIdentifier']];
    }
    // if elementid is used to fetch an element, saving it in profile
    if (!$this->data['use_screen_name']) {
        CProfile::update('web.screens.elementid', $screen['screenid'], PROFILE_TYPE_ID);
    }
    // page header
    $screenWidget->addPageHeader(_('SCREENS'), array($headerForm, SPACE, get_icon('favourite', array('fav' => 'web.favorite.screenids', 'elname' => 'screenid', 'elid' => $screen['screenid'])), SPACE, get_icon('fullscreen', array('fullscreen' => $this->data['fullscreen']))));
    $screenWidget->addItem(BR());
Example #15
0
            $validateConditions = $conditions;
            if (isset($newCondition['value'])) {
                $newConditionValues = zbx_toArray($newCondition['value']);
                foreach ($newConditionValues as $newValue) {
                    $condition = $newCondition;
                    $condition['value'] = $newValue;
                    $validateConditions[] = $condition;
                }
            }
            if ($validateConditions) {
                CAction::validateConditions($validateConditions);
            }
            $_REQUEST['conditions'] = $validateConditions;
        }
    } catch (APIException $e) {
        show_error_message(_('Cannot add action condition'));
        error($e->getMessage());
    }
} elseif (isset($_REQUEST['add_opcondition']) && isset($_REQUEST['new_opcondition'])) {
    $new_opcondition = $_REQUEST['new_opcondition'];
    try {
        CAction::validateOperationConditions($new_opcondition);
        $new_operation = get_request('new_operation', array());
        if (!isset($new_operation['opconditions'])) {
            $new_operation['opconditions'] = array();
        }
        if (!str_in_array($new_opcondition, $new_operation['opconditions'])) {
            array_push($new_operation['opconditions'], $new_opcondition);
        }
        $_REQUEST['new_operation'] = $new_operation;
        unset($_REQUEST['new_opcondition']);
Example #16
0
**
** 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., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
require_once 'include/config.inc.php';
require_once 'include/graphs.inc.php';
$page['file'] = 'chart6.php';
// $page['title']	= "S_CHART";
$page['type'] = PAGE_TYPE_IMAGE;
include_once 'include/page_header.php';
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array('graphid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), 'period' => array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD, ZBX_MAX_PERIOD), null), 'stime' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'border' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'width' => array(T_ZBX_INT, O_OPT, P_NZERO, '{}>0', null), 'height' => array(T_ZBX_INT, O_OPT, P_NZERO, '{}>0', null), 'graph3d' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'legend' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null));
check_fields($fields);
if (!DBfetch(DBselect('select graphid from graphs where graphid=' . $_REQUEST['graphid']))) {
    show_error_message(S_NO_GRAPH_DEFINED);
}
$options = array('graphids' => $_REQUEST['graphid'], 'select_hosts' => 1, 'extendoutput' => 1);
$db_data = CGraph::get($options);
if (empty($db_data)) {
    access_deny();
} else {
    $db_data = reset($db_data);
}
$host = reset($db_data['hosts']);
$effectiveperiod = navigation_bar_calc();
$graph = new CPie($db_data['graphtype']);
if (isset($_REQUEST['period'])) {
    $graph->setPeriod($_REQUEST['period']);
}
if (isset($_REQUEST['stime'])) {
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
require_once 'include/config.inc.php';
require_once 'include/graphs.inc.php';
$page['file'] = 'chart6.php';
$page['type'] = PAGE_TYPE_IMAGE;
require_once 'include/page_header.php';
// VAR	TYPE	OPTIONAL	FLAGS	VALIDATION	EXCEPTION
$fields = array('graphid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), 'screenid' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'period' => array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD, ZBX_MAX_PERIOD), null), 'stime' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'profileIdx' => array(T_ZBX_STR, O_OPT, null, null, null), 'profileIdx2' => array(T_ZBX_STR, O_OPT, null, null, null), 'updateProfile' => array(T_ZBX_STR, O_OPT, null, null, null), 'border' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'width' => array(T_ZBX_INT, O_OPT, P_NZERO, '{}>0', null), 'height' => array(T_ZBX_INT, O_OPT, P_NZERO, '{}>0', null), 'graph3d' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'legend' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null));
check_fields($fields);
/*
 * Permissions
 */
if (!DBfetch(DBselect('SELECT g.graphid FROM graphs g WHERE g.graphid=' . $_REQUEST['graphid']))) {
    show_error_message(_('No graphs defined.'));
}
$db_data = API::Graph()->get(array('graphids' => $_REQUEST['graphid'], 'selectHosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND));
if (empty($db_data)) {
    access_deny();
} else {
    $db_data = reset($db_data);
}
$host = reset($db_data['hosts']);
/*
 * Display
 */
$timeline = CScreenBase::calculateTime(array('profileIdx' => get_request('profileIdx', 'web.screens'), 'profileIdx2' => get_request('profileIdx2'), 'updateProfile' => get_request('updateProfile', true), 'period' => get_request('period'), 'stime' => get_request('stime')));
$graph = new CPie($db_data['graphtype']);
$graph->setPeriod($timeline['period']);
$graph->setSTime($timeline['stime']);
Example #18
0
                    throw new Exception();
                }
            }
        }
        if ($result) {
            add_audit_ext($auditAction, AUDIT_RESOURCE_TEMPLATE, $templateId, $templateName, 'hosts', null, null);
        }
        unset($_REQUEST['form'], $_REQUEST['templateid']);
        $result = DBend($result);
        if ($result) {
            uncheckTableRows();
        }
        show_messages($result, $messageSuccess, $messageFailed);
    } catch (Exception $e) {
        DBend(false);
        show_error_message($messageFailed);
    }
} elseif (isset($_REQUEST['delete']) && isset($_REQUEST['templateid'])) {
    DBstart();
    $result = API::Template()->massUpdate(array('templates' => zbx_toObject($_REQUEST['templateid'], 'templateid'), 'hosts' => array()));
    if ($result) {
        $result = API::Template()->delete(array(getRequest('templateid')));
    }
    $result = DBend($result);
    if ($result) {
        unset($_REQUEST['form'], $_REQUEST['templateid']);
        uncheckTableRows();
    }
    unset($_REQUEST['delete']);
    show_messages($result, _('Template deleted'), _('Cannot delete template'));
} elseif (isset($_REQUEST['delete_and_clear']) && isset($_REQUEST['templateid'])) {
Example #19
0
function fatal_error($msg)
{
    require_once dirname(__FILE__) . '/page_header.php';
    show_error_message($msg);
    require_once dirname(__FILE__) . '/page_footer.php';
}
Example #20
0
 /**
  * Returns output for preview of graph prototype.
  *
  * @return CTag
  */
 protected function getPreviewOutput()
 {
     $graphPrototype = $this->getGraphPrototype();
     switch ($graphPrototype['graphtype']) {
         case GRAPH_TYPE_NORMAL:
         case GRAPH_TYPE_STACKED:
             $url = 'chart3.php';
             break;
         case GRAPH_TYPE_EXPLODED:
         case GRAPH_TYPE_3D_EXPLODED:
         case GRAPH_TYPE_3D:
         case GRAPH_TYPE_PIE:
             $url = 'chart7.php';
             break;
         default:
             show_error_message(_('Graph prototype not found.'));
             exit;
     }
     $graphPrototypeItems = API::GraphItem()->get(['output' => ['gitemid', 'itemid', 'sortorder', 'flags', 'type', 'calc_fnc', 'drawtype', 'yaxisside', 'color'], 'graphids' => [$graphPrototype['graphid']]]);
     $queryParams = ['items' => $graphPrototypeItems, 'graphtype' => $graphPrototype['graphtype'], 'period' => 3600, 'legend' => $graphPrototype['show_legend'], 'graph3d' => $graphPrototype['show_3d'], 'width' => $this->screenitem['width'], 'height' => $this->screenitem['height'], 'name' => $graphPrototype['name']];
     $url .= '?' . http_build_query($queryParams);
     return new CSpan(new CImg($url));
 }
** 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.
**/
include 'include/views/js/configuration.httpconf.popup.js.php';
$httpPopupWidget = new CWidget();
if (isset($_REQUEST['save'])) {
    $result = true;
    if ((!isset($_REQUEST['stepid']) || isset($_REQUEST['stepid']) && $_REQUEST['name'] !== $_REQUEST['old_name']) && isset($_REQUEST['steps_names'])) {
        foreach ($_REQUEST['steps_names'] as $name) {
            if ($name === $_REQUEST['name']) {
                show_error_message(_s('Step with name "%1$s" already exists.', $name));
                $result = false;
            }
        }
    }
}
if (isset($_REQUEST['save']) && $result) {
    if (!isset($_REQUEST['stepid'])) {
        insert_js('add_httpstep(' . zbx_jsvalue($_REQUEST['dstfrm']) . ',' . zbx_jsvalue($_REQUEST['name']) . ',' . zbx_jsvalue($_REQUEST['timeout']) . ',' . zbx_jsvalue($_REQUEST['url']) . ',' . zbx_jsvalue($_REQUEST['posts']) . ',' . zbx_jsvalue($_REQUEST['variables']) . ',' . zbx_jsvalue($_REQUEST['required']) . ',' . zbx_jsvalue($_REQUEST['status_codes']) . ");\n");
    } else {
        insert_js('update_httpstep(' . zbx_jsvalue($_REQUEST['dstfrm']) . ',' . zbx_jsvalue($_REQUEST['list_name']) . ',' . zbx_jsvalue($_REQUEST['stepid']) . ',' . zbx_jsvalue($_REQUEST['name']) . ',' . zbx_jsvalue($_REQUEST['timeout']) . ',' . zbx_jsvalue($_REQUEST['url']) . ',' . zbx_jsvalue($_REQUEST['posts']) . ',' . zbx_jsvalue($_REQUEST['variables']) . ',' . zbx_jsvalue($_REQUEST['required']) . ',' . zbx_jsvalue($_REQUEST['status_codes']) . ");\n");
    }
} else {
    $httpPopupForm = new CForm();
    $httpPopupForm->addVar('dstfrm', get_request('dstfrm', null));
    $httpPopupForm->addVar('stepid', get_request('stepid', null));
Example #22
0
        DBexecute('UPDATE screens_items SET y=(y-1) WHERE screenid=' . zbx_dbstr($screen['screenid']) . ' AND y>' . zbx_dbstr($rmv_row));
        add_audit_details(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCREEN, $screen['screenid'], $screen['name'], 'Row deleted');
    } else {
        error(_('Screen should contain at least one row and column.'));
        show_error_message(_('Impossible to remove last row and column.'));
    }
} elseif (isset($_REQUEST['rmv_col'])) {
    if ($screen['hsize'] > 1) {
        $rmv_col = get_request('rmv_col', 0);
        DBexecute('UPDATE screens SET hsize=(hsize-1) WHERE screenid=' . zbx_dbstr($screen['screenid']));
        DBexecute('DELETE FROM screens_items WHERE screenid=' . zbx_dbstr($screen['screenid']) . ' AND x=' . zbx_dbstr($rmv_col));
        DBexecute('UPDATE screens_items SET x=(x-1) WHERE screenid=' . zbx_dbstr($screen['screenid']) . ' AND x>' . zbx_dbstr($rmv_col));
        add_audit_details(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_SCREEN, $screen['screenid'], $screen['name'], 'Column deleted');
    } else {
        error(_('Screen should contain at least one row and column.'));
        show_error_message(_('Impossible to remove last row and column.'));
    }
}
/*
 * Display
 */
$data = array('screenid' => get_request('screenid', 0));
// getting updated screen, so we wont have to refresh the page to see changes
$data['screen'] = API::Screen()->get($options);
if (empty($data['screen'])) {
    $data['screen'] = API::TemplateScreen()->get($options);
    if (empty($data['screen'])) {
        access_deny();
    }
}
$data['screen'] = reset($data['screen']);
// IBM_DB2
if (zbx_is_callable(array('db2_connect', 'db2_set_option', 'db2_prepare', 'db2_execute', 'db2_fetch_assoc'))) {
    $ZBX_CONFIG['allowed_db']['IBM_DB2'] = 'IBM DB2';
}
// SQLITE3. The false is here to avoid autoloading of the class.
if (class_exists('SQLite3', false) && zbx_is_callable(array('ftok', 'sem_acquire', 'sem_release', 'sem_get'))) {
    $ZBX_CONFIG['allowed_db']['SQLITE3'] = 'SQLite3';
}
if (count($ZBX_CONFIG['allowed_db']) == 0) {
    $ZBX_CONFIG['allowed_db']['no'] = 'No';
}
/*
 * Setup wizard
 */
global $ZBX_SETUP_WIZARD;
$ZBX_SETUP_WIZARD = new CSetupWizard($ZBX_CONFIG);
zbx_set_post_cookie('ZBX_CONFIG', serialize($ZBX_CONFIG));
require_once dirname(__FILE__) . '/include/page_header.php';
include 'include/views/js/setup.js.php';
/*
 * Check configuration
 */
global $ZBX_CONFIGURATION_FILE;
if (file_exists($ZBX_CONFIGURATION_FILE)) {
    if (isset($_REQUEST['message'])) {
        show_error_message($_REQUEST['message']);
    }
}
$ZBX_SETUP_WIZARD->show();
unset($_POST);
require_once dirname(__FILE__) . '/include/page_footer.php';
            $add['groups'] = zbx_toObject($newHostGroupIds, 'groupid');
        }
        if ($add) {
            $add['hosts'] = $hosts['hosts'];
            $result = API::Host()->massAdd($add);
            if ($result === false) {
                throw new Exception();
            }
        }
        DBend(true);
        show_message(_('Hosts updated'));
        clearCookies(true);
        unset($_REQUEST['massupdate'], $_REQUEST['form'], $_REQUEST['hosts']);
    } catch (Exception $e) {
        DBend(false);
        show_error_message(_('Cannot update hosts'));
    }
    unset($_REQUEST['save']);
} elseif (isset($_REQUEST['save'])) {
    try {
        DBstart();
        if (isset($_REQUEST['hostid']) && $_REQUEST['form'] != 'full_clone') {
            $createNew = false;
            $msgOk = _('Host updated');
            $msgFail = _('Cannot update host');
            $hostOld = API::Host()->get(array('hostids' => get_request('hostid'), 'editable' => true, 'output' => API_OUTPUT_EXTEND));
            $hostOld = reset($hostOld);
        } else {
            $createNew = true;
            $msgOk = _('Host added');
            $msgFail = _('Cannot add host');
            add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, $messageSuccess);
        }
        $result = DBend($result);
        show_messages($result, $messageSuccess, $messageFailed);
    }
} elseif ($config['authentication_type'] == ZBX_AUTH_LDAP) {
    if (hasRequest('update') || hasRequest('test')) {
        // check LDAP login/password
        $ldapValidator = new CLdapAuthValidator(array('conf' => array('host' => $config['ldap_host'], 'port' => $config['ldap_port'], 'base_dn' => $config['ldap_base_dn'], 'bind_dn' => $config['ldap_bind_dn'], 'bind_password' => $config['ldap_bind_password'], 'search_attribute' => $config['ldap_search_attribute'])));
        $login = $ldapValidator->validate(array('user' => getRequest('user', CWebUser::$data['alias']), 'password' => getRequest('user_password', '')));
        if (!$login) {
            error(_('Login name or password is incorrect!'));
        }
        if (hasRequest('update')) {
            if (!$login) {
                show_error_message(_('Cannot change authentication method to LDAP'));
            } else {
                $messageSuccess = $isAuthenticationTypeChanged ? _('Authentication method changed to LDAP') : _('LDAP authentication changed');
                $messageFailed = $isAuthenticationTypeChanged ? _('Cannot change authentication method to LDAP') : _('Cannot change authentication');
                DBstart();
                $result = update_config($config);
                if ($result) {
                    unset($_REQUEST['change_bind_password']);
                    // reset all sessions
                    if ($isAuthenticationTypeChanged) {
                        $result &= DBexecute('UPDATE sessions SET status=' . ZBX_SESSION_PASSIVE . ' WHERE sessionid<>' . zbx_dbstr(CWebUser::$data['sessionid']));
                    }
                    $isAuthenticationTypeChanged = false;
                    add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ZABBIX_CONFIG, $messageSuccess);
                }
                $result = DBend($result);
            $hosts_ids = $_REQUEST['copy_targetid'];
        } else {
            $hosts_ids = array();
            $group_ids = $_REQUEST['copy_targetid'];
            $db_hosts = DBselect('SELECT DISTINCT h.hostid' . ' FROM hosts h,hosts_groups hg' . ' WHERE h.hostid=hg.hostid' . ' AND ' . dbConditionInt('hg.groupid', $group_ids));
            while ($db_host = DBfetch($db_hosts)) {
                $hosts_ids[] = $db_host['hostid'];
            }
        }
        DBstart();
        $go_result = copyItemsToHosts($_REQUEST['group_itemid'], $hosts_ids);
        $go_result = DBend($go_result);
        show_messages($go_result, _('Items copied'), _('Cannot copy items'));
        $_REQUEST['go'] = 'none2';
    } else {
        show_error_message(_('No target selected.'));
    }
} elseif ($_REQUEST['go'] == 'clean_history' && isset($_REQUEST['group_itemid'])) {
    DBstart();
    $go_result = delete_history_by_itemid($_REQUEST['group_itemid']);
    DBexecute('UPDATE items SET lastvalue=null,lastclock=null,prevvalue=null WHERE ' . dbConditionInt('itemid', $_REQUEST['group_itemid']));
    foreach ($_REQUEST['group_itemid'] as $id) {
        if (!($item = get_item_by_itemid($id))) {
            continue;
        }
        $host = get_host_by_hostid($item['hostid']);
        add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ITEM, _('Item') . ' [' . $item['key_'] . '] [' . $id . '] ' . _('Host') . ' [' . $host['host'] . '] ' . _('History cleared'));
    }
    $go_result = DBend($go_result);
    show_messages($go_result, _('History cleared'), $go_result);
} elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['group_itemid'])) {
Example #27
0
            }
            $newMacrosCreated = API::UserMacro()->get(array('globalmacroids' => $newMacrosIds['globalmacroids'], 'globalmacro' => 1, 'output' => API_OUTPUT_EXTEND));
            foreach ($newMacrosCreated as $macro) {
                add_audit_ext(AUDIT_ACTION_ADD, AUDIT_RESOURCE_MACRO, $macro['globalmacroid'], $macro['macro'] . SPACE . RARR . SPACE . $macro['value'], null, null, null);
            }
        }
        // reload macros after updating to properly display them in the form
        $_REQUEST['macros'] = API::UserMacro()->get(array('globalmacro' => true, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true));
        $result = true;
        DBend(true);
        show_message(_('Macros updated'));
    } catch (Exception $e) {
        $result = false;
        DBend(false);
        error($e->getMessage());
        show_error_message(_('Cannot update macros'));
    }
}
/*
 * Display
 */
$form = new CForm();
$form->cleanItems();
$cmbConf = new CComboBox('configDropDown', 'adm.macros.php', 'redirect(this.options[this.selectedIndex].value);');
$cmbConf->addItems(array('adm.gui.php' => _('GUI'), 'adm.housekeeper.php' => _('Housekeeping'), 'adm.images.php' => _('Images'), 'adm.iconmapping.php' => _('Icon mapping'), 'adm.regexps.php' => _('Regular expressions'), 'adm.macros.php' => _('Macros'), 'adm.valuemapping.php' => _('Value mapping'), 'adm.workingtime.php' => _('Working time'), 'adm.triggerseverities.php' => _('Trigger severities'), 'adm.triggerdisplayoptions.php' => _('Trigger displaying options'), 'adm.other.php' => _('Other')));
$form->addItem($cmbConf);
$cnf_wdgt = new CWidget();
$cnf_wdgt->addPageHeader(_('CONFIGURATION OF MACROS'), $form);
$data = array();
$data['form_refresh'] = get_request('form_refresh', 0);
$data['macros'] = array();
Example #28
0
            $result = API::Image()->update(['imageid' => getRequest('imageid'), 'name' => getRequest('name'), 'image' => $image]);
            $audit_action = 'Image [' . getRequest('name') . '] updated';
        } else {
            $result = API::Image()->create(['name' => $_REQUEST['name'], 'imagetype' => $_REQUEST['imagetype'], 'image' => $image]);
            $audit_action = 'Image [' . $_REQUEST['name'] . '] added';
        }
        if ($result) {
            add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_IMAGE, $audit_action);
            unset($_REQUEST['form']);
        }
        $result = DBend($result);
        show_messages($result, $msgOk, $msgFail);
    } catch (Exception $e) {
        DBend(false);
        error($e->getMessage());
        show_error_message($msgFail);
    }
} elseif (isset($_REQUEST['delete']) && isset($_REQUEST['imageid'])) {
    DBstart();
    $image = get_image_by_imageid($_REQUEST['imageid']);
    $result = API::Image()->delete([getRequest('imageid')]);
    if ($result) {
        add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_IMAGE, 'Image [' . $image['name'] . '] deleted');
        unset($_REQUEST['form'], $image, $_REQUEST['imageid']);
    }
    $result = DBend($result);
    show_messages($result, _('Image deleted'), _('Cannot delete image'));
}
/*
 * Display
 */
Example #29
0
                $isValid = $triggerFunctionValidator->validate(['function' => $expressionData['function'], 'functionName' => $expressionData['functionName'], 'functionParamList' => $expressionData['functionParamList'], 'valueType' => $data['itemValueType']]);
                if (!$isValid) {
                    unset($data['insert']);
                    throw new Exception($triggerFunctionValidator->getError());
                }
            } else {
                unset($data['insert']);
                throw new Exception($triggerExpression->error);
            }
            // quote function param
            if (isset($data['insert'])) {
                foreach ($data['params'] as $pnum => $param) {
                    $data['params'][$pnum] = quoteFunctionParam($param);
                }
            }
        } else {
            unset($data['insert']);
            throw new Exception(_('Item not selected'));
        }
    } catch (Exception $e) {
        error($e->getMessage());
        show_error_message(_('Cannot insert trigger expression'));
    }
} elseif (hasErrorMesssages()) {
    show_messages();
}
// render view
$expressionView = new CView('configuration.triggers.expression', $data);
$expressionView->render();
$expressionView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
function invalid_url($msg = null)
{
    if (empty($msg)) {
        $msg = _('Zabbix has received an incorrect request.');
    }
    require_once dirname(__FILE__) . '/page_header.php';
    unset_all();
    show_error_message($msg);
    require_once dirname(__FILE__) . '/page_footer.php';
}