Determine if a file type is allowed

@param  string $ext
@return boolean
516794
public function isAllowed($ext)
    {
        $disallowed = ((count($this->disallowedTypes) > 0) && (in_array(strtolower($ext), $this->disallowedTypes)));
        $allowed    = ((count($this->allowedTypes) == 0) ||
            ((count($this->allowedTypes) > 0) && (in_array(strtolower($ext), $this->allowedTypes))));

        return ((!$disallowed) && ($allowed));
    }
512151
public function isValidExtension($extension)
    {
        $valid_page_types = implode('|', Grav::instance()['config']->get('system.pages.types'));

        // Strip the file extension for valid page types
        if (preg_match('/(' . $valid_page_types . ')/', $extension)) {
            return true;
        }
        return false;
    }
1135566
protected function checkFileType($filename) {

        if ( $this->config['allow_ext'] == '*' ) {
            return true;
        }
		$_ext = strtolower(self::getFileExt($filename));
        $_allow_ext = explode("|", $this->config['allow_ext']);
		if ( !in_array($_ext, $_allow_ext) ) {
			$this->errNum = 5;
            return false;
		}
        return true;
	}
655895
protected function allowed($ext) {
        $allowed = 'jpg,gif,png,bmp,jpeg,zip,rar,7z,tar,gz,bz2,doc,docx,txt,ppt,pptx,xls,xlsx,pdf,mp3,avi,mp4,flv,swf,apk';
        $allowed = explode(',', $allowed);

        return in_array(ltrim($ext, '.'), $allowed);
    }
310023
public function AllowFileExtension($Extension) {
      if ($Extension === NULL)
         $this->_AllowedFileExtensions = array();
		elseif (is_array($Extension))
			$this->_AllowedFileExtensions = array_merge($this->_AllowedFileExtensions, $Extension);
		else
			$this->_AllowedFileExtensions[] = $Extension;
	}
643459
public function hasExtensions($requirements)
	{
		$files      = $this->getFlatListOfFiles();
		$extensions = $this->getFlatListOfExtensions();
		foreach ($requirements as $type => $constraint)
		{
			if (is_numeric($constraint))
			{
				if (!array_key_exists($type, $extensions) || $extensions[$type] < $constraint)
				{
					return false;
				}
			}
			else if (is_callable($constraint))
			{
				if (call_user_func_array($constraint, [$extensions, $files]) === false)
				{
					return false;
				}
			}
		}

		return true;
	}
1361565
public function checkExt($ext) {
		if (is_string($ext)) {
			$ext = explode(',', $ext);
		}
		$extension = strtolower(pathinfo($this->getInfo('name'), PATHINFO_EXTENSION));
		if (!in_array($extension, $ext)) {
			return false;
		}
		return true;
	}
491224
public static function nativeSupport(string $ext = '')
    {
        $support = static::$nativeSupport;
        if (!$support) {
            $support['mbstring'] = function_exists('mb_strlen');
            $support['intl'] = function_exists('intl_error_name');
            static::$nativeSupport = $support;
        }
        if ($ext) {
            return !empty($support[$ext]);
        }
        return $support;
    }
899675
public function acceptsMimeType($ext)
    {
        if ($this->getAllowedMimeTypes() && !in_array($ext, $this->getAllowedMimeTypes())) {
            return false;
        }

        if ($this->getRejectedMimeTypes() && in_array($ext, $this->getRejectedMimeTypes())) {
            return false;
        }

        return true;
    }
377244
protected function _addExt($file, $ext)
    {
        if (substr($file, strlen($ext) * -1) !== $ext) {
            $file .= $ext;
        }

        return $file;
    }
1021494
public function validExt($filename){
        $exts = $this->config['ext'];
        $ext = $this->getExtension($filename);
        if(array_search($ext,$exts)===false){
            return false;
        }else{
            return true;
        }


    }
123721
public function findMimeType($ext = null) {
		if (empty($ext)) {
			return null;
		}
		return $this->find('all', ['conditions' => [$this->getAlias() . '.ext' => $ext]])->first();
	}
229117
public function getAllowedMaxFileSize($ext = null)
    {

        // Check if there is any defined instance max file sizes
        if (empty($this->allowedMaxFileSize)) {
            // Set default max file sizes if there isn't
            $fileSize = Config::inst()->get(__CLASS__, 'default_max_file_size');
            if ($fileSize) {
                $this->setAllowedMaxFileSize($fileSize);
            } else {
                // When no default is present, use maximum set by PHP
                $maxUpload = File::ini2bytes(ini_get('upload_max_filesize'));
                $maxPost = File::ini2bytes(ini_get('post_max_size'));
                $this->setAllowedMaxFileSize(min($maxUpload, $maxPost));
            }
        }

        if ($ext !== null) {
            $ext = strtolower($ext);
            if (isset($this->allowedMaxFileSize[$ext])) {
                return $this->allowedMaxFileSize[$ext];
            }

            $category = File::get_app_category($ext);
            if ($category && isset($this->allowedMaxFileSize['[' . $category . ']'])) {
                return $this->allowedMaxFileSize['[' . $category . ']'];
            }
        }

        return (isset($this->allowedMaxFileSize['*'])) ? $this->allowedMaxFileSize['*'] : false;
    }
77954
public function accept( File $file ) : bool
    {
        if ( $this->extension ){
            $ext = $file->getExtension();
            if ( $ext != $this->extension ){
                return FALSE;
            }
        }

        $suffix = $this->extension ? '.' . $this->extension : NULL;
        $name = $suffix ? $file->getName($suffix) : $file->getName();

        if ( preg_match( $this->pattern, $name ) ){
            return TRUE;
        }

        return FALSE;
    }
519118
public function isValidExtension()
    {
        return !count($this->allowedExtensions)
            || in_array($this->getFileExtension(), $this->allowedExtensions, true);
    }
655967
private static function isFileValid($filename, $mimeType, $allowedExts, $allowedMimeTypes) {
    // Skip if the allowed extensions or mime types are missing.
    if (!$allowedExts || !$allowedMimeTypes) {
      return false;
    }

    // Get extension.
    $extension = end($filename);

    return in_array(strtolower($mimeType), $allowedMimeTypes) && in_array(strtolower($extension), $allowedExts, true);
  }
482966
protected function validateFileType($name)
    {
        $extension = strtolower(File::extension($name));

        $allowedFileTypes = FileDefinitions::get('defaultExtensions');

        if (!in_array($extension, $allowedFileTypes)) {
            return false;
        }

        return true;
    }