示例#1
0
function calc_exp($fields, $field, $expression)
{
    if (strpos($expression, '{}') !== false) {
        if (!isset($_REQUEST[$field])) {
            return false;
        }
        if (!is_array($_REQUEST[$field])) {
            $expression = str_replace('{}', '$_REQUEST["' . $field . '"]', $expression);
        }
        if (is_array($_REQUEST[$field])) {
            foreach ($_REQUEST[$field] as $key => $val) {
                if (!preg_match('/^([a-zA-Z0-9_]+)$/', $key)) {
                    return false;
                }
                if (!calc_exp2($fields, str_replace('{}', '$_REQUEST["' . $field . '"]["' . $key . '"]', $expression))) {
                    return false;
                }
            }
            return true;
        }
    }
    return calc_exp2($fields, $expression);
}
示例#2
0
function calc_exp($fields, $field, $expression)
{
    //SDI("$field - expression: ".$expression);
    if (zbx_strstr($expression, '{}') && !isset($_REQUEST[$field])) {
        return FALSE;
    }
    if (zbx_strstr($expression, '{}') && !is_array($_REQUEST[$field])) {
        $expression = str_replace('{}', '$_REQUEST["' . $field . '"]', $expression);
    }
    if (zbx_strstr($expression, '{}') && is_array($_REQUEST[$field])) {
        foreach ($_REQUEST[$field] as $key => $val) {
            if (!ereg('^[a-zA-Z0-9_]+$', $key)) {
                return FALSE;
            }
            $expression2 = str_replace('{}', '$_REQUEST["' . $field . '"]["' . $key . '"]', $expression);
            if (calc_exp2($fields, $field, $expression2) == FALSE) {
                return FALSE;
            }
        }
        return TRUE;
    }
    //SDI("$field - expression: ".$expression);
    return calc_exp2($fields, $field, $expression);
}