static function match($data, $condition, $fields) { $match = true; $ops = array("eq", "neq", "lt", "gt", "like", "nlike", "starts", "oneof"); foreach (explode("||", $condition) as $filter) { $filter = explode("|", $filter); if (count($filter) != 3 or !isset($data[$filter[0]]) or !in_array($filter[1], $ops)) { continue; } $f_value = $filter[2]; if (in_array($fields[$filter[0]]["SIMPLE_TYPE"], array("date", "dateselect", "time", "datetime"))) { $f_value = self::datetime_to_int($f_value); } $f_value = sgsml::scalarize((array) $f_value, $fields[$filter[0]]); $value = sgsml::scalarize($data[$filter[0]]["data"], $fields[$filter[0]]); if (sys_contains($f_value, "@")) { $key = substr(trim($f_value, "|"), 1, -1); if (!empty($_SESSION[$key])) { $f_value = str_replace("@" . $key . "@", $_SESSION[$key], $f_value); } } if ($filter[1] == "oneof") { $f_value = explode(",", $f_value); } switch ($filter[1]) { case "neq": $match = $value != $f_value; break; case "oneof": $match = in_array($value, $f_value); break; case "lt": $match = $value < $f_value; break; case "gt": $match = $value > $f_value; break; case "like": $match = sys_contains($value, $f_value); break; case "nlike": $match = !sys_contains($value, $f_value); break; case "starts": $match = sys_strbegins($value, $f_value); break; default: $match = $value == $f_value; break; } if (!$match) { return false; } } return $match; }