public function assure(&$value, $operator, $operand) { if (!is_int($value)) { $int = filter_var($value, FILTER_VALIDATE_INT); if (false === $int) { throw new \InvalidArgumentException('invalid type given'); } $value = $int; } if ($operator && !checkCondition($value, $operator, $operand)) { throw new \InvalidArgumentException("Value should be {$operator} {$operand}"); } }
function getEncodings($fn_video_type, $fn_aspect, $fn_vinfo, $hd_overwrite) { global $config, $conn; $encodings = array(); $sql = "SELECT * FROM encoding_avs" . " WHERE video_type = '" . mysql_real_escape_string($fn_video_type) . "'" . " AND (aspect = 'all' OR aspect = '" . mysql_real_escape_string($fn_aspect) . "')" . " ORDER BY encode_seq DESC" . ""; $i = 1; $rs = array(); $rs = $conn->execute($sql); while (!$rs->EOF) { $row = array(); $row = $rs->fields; $sql = "SELECT * FROM encoding_condition" . " WHERE video_type = '" . mysql_real_escape_string($row['video_type']) . "'" . " AND aspect = '" . mysql_real_escape_string($row['aspect']) . "'" . " AND encode_seq = " . (int) $row['encode_seq'] . ""; $cond = true; $rsc = array(); $rsc = $conn->execute($sql); while (!$rsc->EOF && $cond) { $cRow = array(); $cRow = $rsc->fields; if (!checkCondition($cRow['condition_type'], $cRow['condition_operator'], $cRow['condition_value'], $fn_vinfo)) { $cond = false; } $rsc->MoveNext(); } if ($cond || $hd_overwrite) { $encodings[] = $row; } $rs->MoveNext(); } return $encodings; }