static public function isFileInsideDirectory($filename, $directory)
    {
        $canonicalDirectory = realpath($directory);
        if (false === $canonicalDirectory) {
            return false;
        }
        $canonicalFilename = realpath($canonicalDirectory . DIRECTORY_SEPARATOR . $filename);
        if (false === $canonicalFilename) {
            return false;
        }
        return 0 === strpos($canonicalFilename, $canonicalDirectory);
    }