validate mime type file

@param stirng $path image file path

@return boolean
430771
public function validate($path, array $mimeTypes = [])
    {
        if (empty($mimeTypes)) {
            $mimeTypes = $this->mimeTypes;
        }

        return in_array(self::getType($path), $mimeTypes);
    }
164121
function is_file($path)
    {
        $result = $this->_get_stat_cache_prop($path, 'type');
        if ($result === false) {
            return false;
        }
        return $result === NET_SFTP_TYPE_REGULAR;
    }
1205412
function is_dir($path) {

        // be sure path is utf-8
        $item = $this->gpi($path);

        if ($item === false) {
            return false;
        } else {
            return ($item['resourcetype'] == 'collection');
        }
    }
759186
public static function is_svg( $file_path ) {
		if ( ! isset( $file_path ) || '' === $file_path || ! file_exists( $file_path ) ) {
			return false;
		}

		if ( TextHelper::ends_with( strtolower($file_path), '.svg' ) ) {
			return true;
		}

		/**
		 * Try reading mime type.
		 *
		 * SVG images are not allowed by default in WordPress, so we have to pass a default mime
		 * type for SVG images.
		 */
		$mime = wp_check_filetype_and_ext( $file_path, basename( $file_path ), array(
			'svg' => 'image/svg+xml',
		) );

		return in_array( $mime['type'], array(
			'image/svg+xml',
			'text/html',
			'text/plain',
			'image/svg',
		) );
	}
1348218
protected static function validatePath($path)
    {
        if (realpath($path) === false) {
            throw new Exception(
                'Path "' . $path . '" does not exist.'
            );
        }

        if (is_dir($path) === false || is_writable($path) === false) {
            throw new Exception(
                'Make sure path "' . $path . '" exists and that it\'s writable.'
            );
        }

        // Make full usable with trailing slash
        $path = realpath($path) . DIRECTORY_SEPARATOR;

        return $path;
    }
569507
public static function mime($path)
    {
        $mime = false;

        if (is_readable($path)) {
            if (function_exists('finfo_open')) {
                $buffer = file_get_contents($path, false, null, -1, 5012);

                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                $mime = finfo_buffer($finfo, $buffer);
                finfo_close($finfo);

                $buffer = null;
            } elseif (function_exists('mime_content_type')) {
                $mime = mime_content_type($path);
            }
        }

        if ($mime !== false && strpos($mime, 'application/') === 0) {
            $size = filesize($path);
            $mime = $size >= 0 && $size < 2 ? 'text/plain' : $mime;
        }

        return $mime;
    }
108116
public function isValidSolrPath($path)
    {
        $path = trim($path);

        if ((!empty($path)) && (preg_match('/^[^*?"<>|:#]*$/', $path))) {
            return true;
        }

        return false;
    }
1159492
public static function getFromFile($path)
    {
        if (!($path instanceof File))
            $path = new File($path);

        $ext = $path->getExtension();
        $path = $path->getFullPath();

        $type = new FileType($ext ?? "", "");
        if (empty($type->getMimeType()) && file_exists($path))
            $type->setMimeType(mime_content_type($path));

        return $type;
    }
793223
function filetype($path)
    {
        $type = $this->_get_stat_cache_prop($path, 'type');
        if ($type === false) {
            return false;
        }

        switch ($type) {
            case NET_SFTP_TYPE_BLOCK_DEVICE:
                return 'block';
            case NET_SFTP_TYPE_CHAR_DEVICE:
                return 'char';
            case NET_SFTP_TYPE_DIRECTORY:
                return 'dir';
            case NET_SFTP_TYPE_FIFO:
                return 'fifo';
            case NET_SFTP_TYPE_REGULAR:
                return 'file';
            case NET_SFTP_TYPE_SYMLINK:
                return 'link';
            default:
                return false;
        }
    }
1059827
protected function is_valid_file($path) {
        global $CFG;

        $realpath = realpath($path);

        // Additional theme directory.
        $addthemedirectory = core_component::get_plugin_types()['theme'];
        $addrealroot = realpath($addthemedirectory);

        // Original theme directory.
        $themedirectory = $CFG->dirroot . "/theme";
        $realroot = realpath($themedirectory);

        // File should end in .scss and must be in sites theme directory, else ignore it.
        $pathvalid = $realpath !== false;
        $pathvalid = $pathvalid && (substr($path, -5) === '.scss');
        $pathvalid = $pathvalid && (strpos($realpath, $realroot) === 0 || strpos($realpath, $addrealroot) === 0);
        return $pathvalid;
    }
1314925
private static function getMimeTypeOfFile($path)
    {
        $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mime     = finfo_file($fileInfo, $path);
        finfo_close($fileInfo);

        return $mime;
    }
258626
public function isLargeFile(string $path): bool
    {
        if (!$this->opt->isStatFiles()) {
            return false;
        }
        $stat = stat($path);
        return $stat['size'] > $this->opt->getLargeFileSize();
    }
718115
public function check_mime_detection()
    {
        $errors = array();
        $files  = array(
            'program/resources/tinymce/video.png' => 'image/png',
            'program/resources/blank.tiff'        => 'image/tiff',
            'program/resources/blocked.gif'       => 'image/gif',
        );

        foreach ($files as $path => $expected) {
            $mimetype = rcube_mime::file_content_type(INSTALL_PATH . $path, basename($path));
            if ($mimetype != $expected) {
                $errors[] = array($path, $mimetype, $expected);
            }
        }

        return $errors;
    }
740724
public static function isFile(string $path) : bool
    {
        try {
            return ErrorCatcher::run(static function() use ($path) {
                return is_file($path);
            });
        } catch (\ErrorException $e) {
            throw new IoException('Error checking if ' . $path . ' is a file', 0, $e);
        }
    }
1031745
protected function checkMime($file, $mime)
    {
        if (is_string($mime)) {
            $mime = explode(',', $mime);
        }

        if (!in_array(strtolower($this->getMime($file)), $mime)) {
            return false;
        }

        return true;
    }
110966
private function validatePath(string $path): bool
    {
        if (! $this->fileSystem->has($path)) {
            throw new FileNotFoundException(sprintf('The source file "%s" does not exist.', $path));
        }
        if ($this->fileSystem->get($path)->getType() === 'dir') {
            return false;
        }
        return true;
    }
695630
protected static function mimetypeInternalDetect($path)
    {
        $pinfo = pathinfo($path);
        $ext   = isset($pinfo['extension']) ? strtolower($pinfo['extension']) : '';

        return isset(elFinderVolumeDriver::$mimetypes[$ext]) ? elFinderVolumeDriver::$mimetypes[$ext] : 'unknown';

    }