Пример #1
0
function check_fields(&$fields, $show_messages = true)
{
    global $system_fields;
    $err = ZBX_VALID_OK;
    $fields = array_merge($fields, $system_fields);
    foreach ($fields as $field => $checks) {
        $err |= check_field($fields, $field, $checks);
    }
    unset_not_in_list($fields);
    unset_if_zero($fields);
    if ($err != ZBX_VALID_OK) {
        unset_action_vars($fields);
    }
    $fields = null;
    if ($err & ZBX_VALID_ERROR) {
        invalid_url();
    }
    if ($show_messages) {
        show_messages();
    }
    return $err == ZBX_VALID_OK ? 1 : 0;
}
Пример #2
0
function check_fields(&$fields, $show_messages = true)
{
    // VAR	TYPE	OPTIONAL	FLAGS	VALIDATION	EXCEPTION
    $system_fields = array('sid' => array(T_ZBX_STR, O_OPT, P_SYS, HEX(), null), 'triggers_hash' => array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY, null), 'print' => array(T_ZBX_INT, O_OPT, P_SYS, IN('1'), null), 'page' => array(T_ZBX_INT, O_OPT, P_SYS, null, null), 'ddreset' => array(T_ZBX_INT, O_OPT, P_SYS, null, null));
    $fields = zbx_array_merge($system_fields, $fields);
    $err = ZBX_VALID_OK;
    foreach ($fields as $field => $checks) {
        $err |= check_field($fields, $field, $checks);
    }
    unset_not_in_list($fields);
    unset_if_zero($fields);
    if ($err != ZBX_VALID_OK) {
        unset_action_vars($fields);
    }
    $fields = null;
    if ($err & ZBX_VALID_ERROR) {
        invalid_url();
    }
    if ($show_messages && $err != ZBX_VALID_OK) {
        show_messages($err == ZBX_VALID_OK, null, _('Page received incorrect data'));
    }
    return $err == ZBX_VALID_OK;
}