static function checkStringLength($value, $range, &$code) { return $code = self::_numberInRange(CoreUtils::length($value), $range); }
/** * Construct an instance of the class * * @param string $pattern * @param string $modifiers * @param string $delimiter * * @return RegExp */ public function __construct(string $pattern, string $modifiers = '', string $delimiter = '~') { $this->_delimiter = $delimiter[0] ?? '~'; $this->_pattern = $pattern; $this->_modifiers = CoreUtils::length($modifiers) ? $modifiers : ''; }
/** * Function to process uploaded images * * Checks the $_FILES array for an item named $key, * checks if file is an image, and it's mime type * can be found in $allowedMimeTypes, and finally * checks if the size is at least $minwidth by $minheight, * then moves it to the requested $path. * * @param string $key * @param string $path * @param array|null $allowedMimeTypes * @param int $minwidth * @param int|null $minheight * * @return null */ static function processUploadedImage($key, $path, $allowedMimeTypes, $minwidth, $minheight = null) { if (!isset($minheight)) { $minheight = $minwidth; } if (!isset($_FILES[$key])) { return self::grabImage($path, $allowedMimeTypes, $minwidth, $minheight); } $file = $_FILES[$key]; $tmp = $file['tmp_name']; if (CoreUtils::length($tmp) < 1) { Response::fail('File upload failed; Reason unknown'); } list($width, $height) = Image::checkType($tmp, $allowedMimeTypes); CoreUtils::createUploadFolder($path); if (!move_uploaded_file($tmp, $path)) { @unlink($tmp); Response::fail('File upload failed; Writing image file was unsuccessful'); } Image::checkSize($path, $width, $height, $minwidth, $minheight); }