/*!
\private
\static
Stores the string data \a $data into the file \a $filename.
\return \c true if successful.
509685
static function storeString( $filename, $data )
    {
        $file = @fopen( $filename, 'w' );
        if ( $file )
        {
            fwrite( $file, $data );
            fclose( $file );

            eZPackage::applyStorageFilePermissions( $filename );

            eZDebugSetting::writeNotice( 'kernel-ezpackage-store',
                                         "Stored file $filename",
                                         'eZPackage::storeString' );
            return true;
        }
        else
        {
            eZDebug::writeError( "Failed to write package '$filename'" );
        }
        return false;
    }
1096781
function read($filename){
		$filename = md5($filename);
		$filepath = $this->getConfig('cache_path').$filename.'.tmp';
		
		if(!file_exists($filepath)){
			return FALSE;
		}
		
		if ( ! $fp = @fopen($filepath, 'r')){
			return FALSE;
		}
		flock($fp, LOCK_SH);

		$cache = '';
		if (filesize($filepath) > 0)
		{
			$cache = fread($fp, filesize($filepath));
		}

		flock($fp, LOCK_UN);
		fclose($fp);

		// Strip out the embedded timestamp
		if ( ! preg_match("/(\d+T_SKY-->)/", $cache, $match))
		{
			return FALSE;
		}
		// Has the file expired? If so we'll delete it.
		if (time() >= trim(str_replace('TS--->', '', $match['1'])))
		{
			if (is_writable($filepath))
			{
				@unlink($filepath);
				return FALSE;
			}
		}

		// Display the cache
		return str_replace($match['0'], '', $cache);
	}
1042433
public function create($data = [])
    {
        // Create a random hash
        $hash = $this->hash();

        // Store the file in the tokens storage
        $data = array_merge($data, ['token' => $hash, 'timestamp' => time()]);
        $stored = file_put_contents($this->path($hash), json_encode($data));

        // Return the data or false in case of failure
        return ($stored)? $data : false;
    }
465232
public static function dump(string $filename, $data, array $options = []): bool
    {
        return file_put_contents($filename, self::encode($data, $options)) !== false;
    }
1313834
public static function push($key, $data)
    {
        if (is_callable($data)) {
            $content = $data();
        } else {
            $content = $data;
        }

        static::$with_meta = true;

        $cache = static::get($key);

        static::$with_meta = false;

        if (is_array($cache['content'])) {
            array_push($cache['content'], $content);
        } else {
            $cache['content'] .= $content;
        }

        return (bool) file_put_contents(
            static::makeHashFilename($key),
            serialize($cache)
        );
    }
791749
public static function write($filename, $data, $permission = 0777, $flags = LOCK_EX, $relative = true) {
		// if we have relative path we convert it to full path
		if ($relative && $filename[0] == '.') {
			$path = \Application::get('application.path_full');
			$info = pathinfo($filename);
			$filename = realpath($path . $info['dirname']) . DIRECTORY_SEPARATOR . $info['basename'];
		}
		// write file
		if (file_put_contents($filename, $data, $flags) !== false) {
			@chmod($filename, $permission);
			return true;
		}
		return false;
	}
421888
public function put($data)
    {
        if (empty($data) or !is_array($data))
        {
            return false;
        }
        if ($this->db->insert($data, $this->table))
        {
            $lastInsertId = $this->db->lastInsertId();
            if ($lastInsertId == 0)
            {
                return true;
            }
            else
            {
                return $lastInsertId;
            }
        }
        else
        {
            return false;
        }
    }
825248
protected function _encodeFile( $fileName, $data )
    {
        $_filePath = dirname( $fileName );

        if ( !is_dir( $_filePath ) )
        {
            if ( false === @mkdir( $_filePath, 0777, true ) && !is_dir( $_filePath ) )
            {
                return false;
            }
        }
        elseif ( !is_writable( $_filePath ) )
        {
            return false;
        }

        $_tempFile = tempnam( $_filePath, basename( $fileName ) );

        if ( false !== file_put_contents( $_tempFile, json_encode( $data ) ) && @rename( $_tempFile, $fileName ) )
        {
            @chmod( $fileName, 0666 & ~umask() );

            return true;
        }

        return false;
    }
434127
public static function download($data){
        if (is_array($data)) {
            if (isset($data['filename'])) static::$force_dl = $data['filename'];
            if (isset($data['charset'])) static::charset($data['charset']);
            if (isset($data['mime'])) static::type($data['mime']);
            if (isset($data['body'])) static::body($data['body']);
        } else static::$force_dl = $data;
    }
1364782
public function append($data)
	{
		$bites = file_put_contents($this->path, $data, FILE_APPEND | LOCK_EX);

		return $bites !== false;
	}
1041494
public function stream_write($data)
    {
        if ($this->fileHandle === null) {
            return false;
        }
        self::restore();
        $length = fwrite($this->fileHandle, $data);
        self::register();
        return $length;
    }
1107598
static function write($filename, $contents, $overwriteExisting = true) {
        if (file_exists($filename) && self::isWritable($filename)) {
            if ($overwriteExisting) unlink($filename);
        }

        file_put_contents($filename, $contents);
    }
1111242
protected function saveStringToStorage($string, $fileName)
    {
        $file = $this->getQueueStorage()->getFile($fileName);

        $file->write((string) $string);

        return $file->getPrefix();
    }
647692
public function put($data = [])
	{
		if (empty($data))
			return false;

		$this->setData();

		$data = (array) $data;

		foreach ($data as $name => $value)
			$this->_request[$name] = $_REQUEST[$name] = $this->sanitize($value);

		return $this->_request;
	}
1226081
static function isWriteable( $filename )
    {
        if ( eZSys::osType() != 'win32' )
            return is_writable( $filename );

        /* PHP function is_writable() doesn't work correctly on Windows NT descendants.
         * So we have to use the following hack on those OSes.
         */
        if ( !( $fd = @fopen( $filename, 'a' ) ) )
            return FALSE;

        fclose( $fd );

        return TRUE;
    }
992649
public static function php($data, $fileName) {
        $filePath = Config::getx('path_temp') . $fileName.'.php';
        $result = file_put_contents($filePath, "<?php\nreturn " . var_export($data, true) . ";");
        return $result;
    }
355844
function characet($data, $targetCharset) {
		
		if (!empty($data)) {
			$fileType = $this->fileCharset;
			if (strcasecmp($fileType, $targetCharset) != 0) {
				$data = mb_convert_encoding($data, $targetCharset, $fileType);
				//				$data = iconv($fileType, $targetCharset.'//IGNORE', $data);
			}
		}


		return $data;
	}