Verifica se o arquivo especificado já está ofuscado.

@param  string $obfuscated_file
@return true
517803
public function isObfuscatedFile(string $obfuscated_file) : bool
    {
        $contents = \file_get_contents($obfuscated_file);
        if ($contents === false) {
            // não foi possível ler o arquivo
            return false;
        }

        if (empty(preg_match('#<\?php#', $contents)) == false
         && empty(preg_match('#x28#', $contents)) == false
         && empty(preg_match('#x29#', $contents)) == false
         && empty(preg_match('#eval#', $contents)) == false
        ) {
            return true;
        }

        return false;
    }
494686
public static function uploadFileToBlob($FILE_DESCRIPTOR, $SAFETY_CHECK=true)
    {
        global $CFG, $CONTEXT, $LINK, $PDOX;

        $test_key = self::isTestKey($CONTEXT->key);

        if( $FILE_DESCRIPTOR['error'] == 1) return false;

        if( $FILE_DESCRIPTOR['error'] == 0)
        {
            $filename = basename($FILE_DESCRIPTOR['name']);
            if ( $SAFETY_CHECK && ! self::safeFileSuffix($filename) ) {
                return false;
            }

            $blob_id = null;
            $blob_name = null;
            $sha256 = hash_file('sha256', $FILE_DESCRIPTOR['tmp_name']);

            // Check if the blob is in the single instance store
            $stmt = $PDOX->queryDie(
                "SELECT blob_id FROM {$CFG->dbprefix}blob_blob WHERE blob_sha256 = :SHA",
                array(":SHA" => $sha256)
            );
            $row = $stmt->fetch(\PDO::FETCH_ASSOC);
            if ( $row !== false ) {
                error_log("Already had instance of $filename");
                $blob_id = $row['blob_id']+0;  // Make sure the id is an integer
            }

            // Don't store test_key (i.e. 12345) as new blobs on disk
            if (! $blob_id && isset($CFG->dataroot) && $CFG->dataroot ) {
                $blob_folder = BlobUtil::mkdirSha256($sha256);
                if ( $blob_folder ) {
                    $blob_name =  $blob_folder . '/' . $sha256;
                    if ( file_exists( $blob_name ) ) {
                        error_log("Already had file on disk $filename => $blob_name");
                    } else if ( $test_key ) { // Don't add to the disk
                        $blob_name = null;
                    } else { // Put the file into the blob space if we can
                        if ( ! (move_uploaded_file($FILE_DESCRIPTOR['tmp_name'],$blob_name))) {
                            error_log("Move fail $filename to $blob_name ");
                            $blob_name = null;
                        }
                    }
                }
            }

            // If not on disk store in the single instance table
            if (! $blob_id && ! $blob_name ) {
                $fp = fopen($FILE_DESCRIPTOR['tmp_name'], "rb");
                $stmt = $PDOX->prepare("INSERT INTO {$CFG->dbprefix}blob_blob
                    (blob_sha256, content, created_at)
                    VALUES (?, ?, NOW())");

                $stmt->bindParam(1, $sha256);
                $stmt->bindParam(2, $fp, \PDO::PARAM_LOB);
                // $stmt->bindParam(5, $data, \PDO::PARAM_LOB);
                $PDOX->beginTransaction();
                $stmt->execute();
                $blob_id = 0+$PDOX->lastInsertId();
                $PDOX->commit();
                fclose($fp);
            }

            // Blob is safe somewhere, insert the file record with pointers
            if ( $blob_id || $blob_name ) {
                $stmt = $PDOX->prepare("INSERT INTO {$CFG->dbprefix}blob_file
                    (context_id, link_id, file_sha256, file_name, contenttype, path, blob_id, created_at)
                    VALUES (:CID, :LID, :SHA, :NAME, :TYPE, :PATH, :BID, NOW())");
                $stmt->execute(array(
                    ":CID" => $CONTEXT->id,
                    ":LID" => $LINK->id,
                    ":SHA" => $sha256,
                    ":NAME" => $filename,
                    ":TYPE" => $FILE_DESCRIPTOR['type'],
                    ":PATH" => $blob_name,
                    ":BID" => $blob_id
                ));
                $id = 0+$PDOX->lastInsertId();
                return array($id, $sha256);
            }

            // Somehow we were unable to store the blob
            error_log("Error: Unable to store blob $filename ".$CONTEXT->id."\n");
            return false;
        }
        return false;
    }
171462
public static boolean isModifed(File file, long lastModifyTime) {
		if (null == file || false == file.exists()) {
			return true;
		}
		return file.lastModified() != lastModifyTime;
	}
1331581
private function prepareAutoloaderFile()
    {
        $plain_name      = pathinfo($this->getPlainPath(), PATHINFO_BASENAME);
        $obfuscated_name = pathinfo($this->getObfuscatedPath(), PATHINFO_BASENAME);

        $autoloader = $this->getPlainPath() . DIRECTORY_SEPARATOR . 'autoloader.php';
        $contents = file_get_contents($autoloader);
        $contents = str_replace($obfuscated_name, $plain_name, $contents);
        return (file_put_contents($autoloader, $contents) !== false);
    }
1325657
protected function isPartOfJoomla($file)
    {
        foreach (static::$joomlaPaths as $joomlaPath) {
            $file = realpath($file);

            if (strpos($file, $joomlaPath) === 0) {
                return true;
            }
        }

        return false;
    }
643418
protected function isNotModified($request, $file)
    {
        $modifiedSince = $request->getHeaderLine('If-Modified-Since');
        if (!$modifiedSince) {
            return false;
        }

        return strtotime($modifiedSince) === $file->lastChange();
    }
87616
public function ignoredByGlob($file)
    {
        $lfile = $file;
        if (strpos($lfile, './') === 0) {
            $lfile = substr($lfile, 2);
        }
        foreach ($this->ignoreFile as $line) {
            if (strpos($lfile, $line) === 0) {
                return true;
            }
        }
        return false;
    }
1261133
protected function pbCheck( $copyright_file ) {
		$result = $this->getZipContent( $copyright_file );

		foreach ( $result->body->div->div->p as $node ) {

			if ( strpos( $node->a['href'][0], 'pressbooks.com', 0 ) ) {
				$this->isPbEpub = true;
			}
		}
		// applies to PB generated EPUBs with PB_SECRET_SAUCE
		// @see createCopyright() in export/epub/class-pb-epub201.php
		if ( 'copyright-page' === $result->body->div[0]->attributes()->id[0] && 'ugc' === $result->body->div->div->attributes()->class[0] ) {
			$this->isPbEpub = true;
		}
	}
120936
public function readConfig($file = 'config.php')
    {
        $orig_file = $file;

        if (strpos($file, '.php') != strlen($file) - 4) {
            $file .= '.php';
        }

        if (strpos($file, '/') === false) {
            $file = getcwd().'/'.$this->config_location.'/'.$file;
        }

        if (file_exists($file)) {
            // some tricky thing to make config be read in some cases it could not in simple way
            unset($config);

            $config = &$this->config;
            $this->config_files_loaded[] = $file;
            include $file;

            unset($config);

            return true;
        }

        return false;
    }
351609
def assert_secure_file(file):
    """"""
    if not is_secure_file(file):
        msg = """
        File {0} can be read by other users.
        This is not secure. Please run 'chmod 600 "{0}"'"""
        raise SecurityError(dedent(msg).replace('\n', ' ').format(file))
    return True
1289535
public function checkType(\Nette\Http\FileUpload $file) {
		if(\Nette\Utils\Arrays::searchKey($this->getMimeTypes(), $file->getContentType()) !== false) {
			return true;
		} else {
			// Pokud se nepodaří ověřit mimetype, ověříme alespoň koncovku.
			if(array_search($this->getExtension($file->getName()), array_unique($this->getMimeTypes())) !== false) {
				return true;
			} else {
				return false;
			}
		}
	}
211838
function checkIfFileWasUpdated($file)
    {
        $absoluteFilePath = ROOTPATH . $file;
        if (file_exists($absoluteFilePath)) {
            $fileExtension = pathinfo($file, PATHINFO_EXTENSION);
            $fileName = pathinfo($file, PATHINFO_FILENAME);
            $fileFullName = pathinfo($file, PATHINFO_BASENAME);
            $minifiedFileName = substr($file, 0, -strlen($fileFullName)) . $fileName . '.minified.' . $fileExtension;
            $changeDate = filectime($absoluteFilePath);
            $changeDateMinified = file_exists(ROOTPATH . $minifiedFileName) ? filectime(ROOTPATH . $minifiedFileName)
                : 0;
            if ($changeDateMinified == 0 || $changeDate < $changeDateMinified) {
                return $minifiedFileName;
            }
        }

        return null;
    }
46334
protected function isValidFile($file): bool
    {
        // If there's no file we can't do anything with it...
        if (empty($file)) {
            return false;
        }

        // If the file doesn't exist, no need to try and get it.
        if (!file_exists($file)) {
            // We should probably log here...
            return false;
        }

        // If we can't read the file... Why try...
        if (!is_readable($file)) {
            // We should probably log or something here...
            return false;
        }

        return true;
    }
871973
def should_obfuscate_filename(self):
        """"""

        for pattern in self.args.hide_file_names:
            try:
                compiled = re.compile(pattern, re.IGNORECASE)
                if compiled.search(self.entity):
                    return True
            except re.error as ex:
                log.warning(u('Regex error ({msg}) for hide_file_names pattern: {pattern}').format(
                    msg=u(ex),
                    pattern=u(pattern),
                ))
        return False
552909
private function isCovered($file)
    {
        return in_array($file, $this->includedFiles)
            && !in_array($file, $this->excludedFiles)
            && isset($this->covered[$file]);
    }
616544
public static function isHttps($trust_proxy_headers = false){
        // Verifique o cabeçalho HTTPS padrão
        if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
           return isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off';
        }
        // Verifique os cabeçalhos de proxy, se permitido
        return $trust_proxy_headers && isset($_SERVER['X-FORWARDED-PROTO']) && $_SERVER['X-FORWARDED-PROTO'] == 'https';
        // Padrão para não SSL
        return false;
    }
258208
public function file_contains_php($file)
    {
        $contents = file_get_contents($file);
        $position = strpos($contents, '<?php');
        return $position !== false;
    }