encrypt file, origin file is remain.
@param  string $filename
@return boolean true for success
519938
static public function encryptFile($filename)
	{
	    $value = file_get_contents($filename);
	    
	    if (strpos($value, '<?php') !== false) {
	        $bfile = pathinfo($filename, PATHINFO_FILENAME);
	        $ext   = pathinfo($filename, PATHINFO_EXTENSION);
	        $bfile .= '.encrypt.' . $ext;
	        
	        $encrypt = Crypt::instance()->encrypt($value);
	        
	        return file_put_contents($bfile, $encrypt);
	    }
	    
	    return true;
	}
683136
public static function checkFileName($fileName)
    {
        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");

        if (is_null($fileName) || !strlen($fileName) || substr($fileName,-1,1)=="." || false!==strpos($fileName, "..")) {
            return false;
        }

        if (preg_match(CKFINDER_REGEX_INVALID_FILE, $fileName)) {
            return false;
        }

        if ($_config->getDisallowUnsafeCharacters()) {
            if (strpos($fileName, ";") !== false) {
                return false;
            }
        }

        return true;
    }
548542
public function loadMerchantPrivateKey($filename) {
		$cert = @file_get_contents($filename);
		if($cert === FALSE) {
			return FALSE;
		}
		return $this->useMerchantPrivateKey($cert);
	}
1102914
public function useFilename($filename)
    {
        $this->filename = $this->sanitizeFilename($filename);
        $this->hash_filename = false;

        return $this;
    }
847163
private function tryRemoveWithLock(string $fileName): bool
    {
        if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
            // On Windows, unlinking a locked/opened file will not work, so we just attempt the delete straight away.
            // In the worst case, the unlink will just fail due to concurrent access and the caller needs to deal with that.
            return unlink($fileName);
        }
        $file = fopen($fileName, 'rb');
        if ($file === false) {
            return false;
        }

        $result = false;
        if (flock($file, LOCK_EX) !== false) {
            $result = unlink($fileName);
            flock($file, LOCK_UN);
        }
        fclose($file);

        return $result;
    }
862462
public function open($fileName)
	{
		$this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir();

		$this->_zip = new PclZip($fileName);

		return true;
	}
1056336
public function equals( $fileName )
	{
		$toCompare	= FS_File_Reader::load( $fileName );
		$thisFile	= FS_File_Reader::load( $this->fileName );
		return( $thisFile == $toCompare );
	}
16786
public static function save($key, string $filename = ''): bool
    {
        if ($key instanceof KeyPair) {
            return self::saveKeyFile(
                $filename,
                $key->getSecretKey()->getRawKeyMaterial()
            );
        }
        return self::saveKeyFile($filename, $key->getRawKeyMaterial());
    }
10262
public function isFile($filename)
    {
        $absolutePath = $this->parser->absoluteFilePath($filename);

        return file_exists($absolutePath) && is_file($absolutePath) ? $absolutePath : null;
    }
140557
private function isEnvironmentFilename(string $filename): bool
    {
        $filenameEnding = substr($filename, strpos($filename, '.'));
        foreach ($this->environments as $environment) {
            if ($filenameEnding === '.' . $environment . '.php') {
                return true;
            }
        }
        return false;
    }
1121423
protected function loadCompiledFile($filename)
    {
        if (!file_exists($filename)) {
            return false;
        }

        $cache = include $filename;
        if (
            !\is_array($cache)
            || !isset($cache['checksum'], $cache['data'], $cache['@class'])
            || $cache['@class'] !== \get_class($this)
        ) {
            return false;
        }

        // Load real file if cache isn't up to date (or is invalid).
        if ($cache['checksum'] !== $this->checksum()) {
            return false;
        }

        $this->createObject($cache['data']);
        $this->timestamp = $cache['timestamp'] ?? 0;

        $this->finalizeObject();

        return true;
    }
737997
public static function fileExists($fileName)
    {
        $fp = @fopen($fileName, 'r', true);
        if (is_resource($fp)) {
            fclose($fp);
            return true;
        }
        return false;
    }
1155391
private function hasValidExtension($filename)
    {
        // Current extension
        $extension = mb_strtolower(pathinfo($filename, \PATHINFO_EXTENSION), 'UTF-8');

        // Make sure all extensions are in lowercase
        foreach ($this->extensions as &$expected) {
            $expected = mb_strtolower($expected, 'UTF-8');
        }

        return in_array($extension, $this->extensions);
	}
123145
public function hasFile($filename)
    {
        return is_file($filename = $this->outDir.DIRECTORY_SEPARATOR.$filename) ? true : false;
    }
733296
public static function valid($filename = null)
	{
		if (!$filename)
		{
			return false;
		}

		if (preg_match("/^\s*http[s]{0,1}:/i", $filename))
		{
			return false;
		}
		if (preg_match("/^\s*[\/]{0,1}index.php\?/i", $filename))
		{
			return false;
		}
		// Disallow windows drive letter
		if (preg_match("/^\s*[.]:/", $filename))
		{
			return false;
		}
		// Disallow \
		if (strpos($filename, '\\'))
		{
			return false;
		}
		// Disallow ..
		if (strpos($filename, '..'))
		{
			return false;
		}

		return true;
	}
1118952
protected function zipEpub( $filename ) {

		$zip = new \PclZip( $filename );

		// Open Publication Structure 2.0.1
		// mimetype must be uncompressed, unencrypted, and the first file in the ZIP archive
		$list = $zip->create( $this->tmpDir . '/mimetype', PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_REMOVE_ALL_PATH );
		if ( 0 === absint( $list ) ) {
			return false;
		}

		$files = [];
		foreach ( new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $this->tmpDir ) ) as $file ) {
			if ( ! $file->isFile() ) {
				continue;
			}
			if ( 'mimetype' === $file->getFilename() ) {
				continue;
			}
			$files[] = $file->getPathname();
		}

		$list = $zip->add( $files, '', $this->tmpDir );
		if ( 0 === absint( $list ) ) {
			return false;
		}

		return true;
	}
605837
public function open($filename)
    {
        $this->filename = $filename;
        return $this->zipArchive->open($filename, ZIPARCHIVE::CREATE);
    }