Write timestamps to either the fast cache, or the serialized file.

@param array $data An array of timestamps for build files.
@return void
160425
protected function _writeTimestamp($data)
    {
        $data = serialize($data);
        file_put_contents($this->path . static::BUILD_TIME_FILE, $data);
        chmod($this->path . static::BUILD_TIME_FILE, 0644);
    }
532430
public function setCache(array $data) 
    {

        if (!is_writable(preg_replace('/[\/][^\/]+\.[^\/]++$/', null, 
            $this->path))) {
            throw new Exception('Temp directory ' . 
            htmlspecialchars($this->path, ENT_QUOTES, 'UTF-8') . 
            ' seems not writable');
        }    	
        
        if ((!file_exists($this->path) || (time()-filectime($this->path)) > 
            $this->config['expiration_time'])) {
            $handle = @fopen($this->path, 'w+');
            $serialized = @serialize($data);
            
            if (!$handle) {
                throw new Exception("Cache file couldn't be created");
            }
			if (!$serialized) {
                throw new Exception("Cache data couldn't be serialized");
            }            

            fwrite($handle, $serialized);
            fclose($handle);
        }

        return $this;
    }
616221
final public function filePutContents($data, $flags = FILE_APPEND)
	{
		if ($flags & FILE_APPEND) {
			$this->fseek(-1, SEEK_END);
		} else {
			$this->ftruncate();
		}

		if ($flags & LOCK_EX) {
			$this->flock(LOCK_EX);
		}
		if (is_array($data)) {
			$data = join(null, $data);
		}
		$this->fwrite($data);
	}
977037
public function write($key, $data)
    {
        $this->_cachedData[$key] = $data;
        Cache::set('model-metadata', $this->_cachedData, Cache::TTL_ONE_MONTH);
    }
1126949
public function write($data)
    {
        $this->_checkStream();
        if (!@fwrite($this->_stream, $data)) {
            $meta_data = $this->getStatus();
            if (!empty($meta_data['timed_out'])) {
                throw new Client\Exception('Timed out writing data to socket');
            }
            throw new Client\Exception('Error writing data to socket');
        }
    }
381467
protected function write(string $data):void{
		$len = \strlen($data);

		for($i = 0; $i + 1 < $len; $i += 2){
			$c = ((0xff & \ord($data[$i])) << 8) | (0xff & \ord($data[$i + 1]));

			if(0x8140 <= $c && $c <= 0x9FFC){
				$c -= 0x8140;
			}
			elseif(0xE040 <= $c && $c <= 0xEBBF){
				$c -= 0xC140;
			}
			else{
				throw new QRCodeDataException('illegal char at '.($i + 1).' ['.$c.']');
			}

			$this->bitBuffer->put((($c >> 8) & 0xff) * 0xC0 + ($c & 0xff), 13);

		}

		if($i < $len){
			throw new QRCodeDataException('illegal char at '.($i + 1));
		}

	}
378381
public function write($data): void
    {
        $rand = \random_int(0, 28);
        $frame = [
            'fin' => 1,
            'rsv1' => 0,
            'rsv2' => 0,
            'rsv3' => 0,
            'opcode' => 1, // We always send text
            'mask' => 1,
            'len' => \strlen($data),
            'mask_key' => \substr(\md5(\uniqid()), $rand, 4),
            'data' => $data,
        ];

        if (1 === $frame['mask']) {
            for ($i = 0; $i < $frame['len']; ++$i) {
                $frame['data'][$i]
                    = \chr(\ord($frame['data'][$i]) ^ \ord($frame['mask_key'][$i % 4]));
            }
        }

        if ($frame['len'] > 2 ** 16) {
            $len = 127;
        } elseif ($frame['len'] > 125) {
            $len = 126;
        } else {
            $len = $frame['len'];
        }

        $firstByte = ($frame['fin'] << 7) | (($frame['rsv1'] << 7) >> 1) | (($frame['rsv2'] << 7) >> 2) | (($frame['rsv3'] << 7) >> 3) | (($frame['opcode'] << 4) >> 4);
        $secondByte = ($frame['mask'] << 7) | (($len << 1) >> 1);

        $this->socketWrite(\chr($firstByte));
        $this->socketWrite(\chr($secondByte));

        if (126 === $len) {
            $this->socketWrite(\pack('n', $frame['len']));
        } elseif (127 === $len) {
            $higher = $frame['len'] >> 32;
            $lower = ($frame['len'] << 32) >> 32;
            $this->socketWrite(\pack('N', $higher));
            $this->socketWrite(\pack('N', $lower));
        }

        if (1 === $frame['mask']) {
            $this->socketWrite($frame['mask_key']);
        }

        $this->socketWrite($frame['data']);
    }
647029
public function setData($data)
    {
        $resultData = $this->hydrateIfJsonToArray($data);
        if (!empty($resultData)) {
            $this->data = $resultData;
        }
        else {
            $this->data = [];
        }
    }
1195147
public function write($key, $content, $timestamp = null)
    {
        if (!isset($this->cacheDirectory)) {
            return;
        }

        $this->loadCacheMetaData();
        $this->metaData[$key] = $timestamp;
        $this->dirty = true;

        if (!is_dir($this->cacheDirectory)) {
            mkdir($this->cacheDirectory, 0775, true);
        }
        file_put_contents($this->cacheDirectory . '/' . $key, serialize($content));
    }
837896
public function write(string $data) : void
    {
        $this->buffer .= $data;

        if (strlen($this->buffer) >= $this->size) {
            $this->flush();
        }
    }
1373567
public function unserialize($data)
    {
        $dates = unserialize($data);
        $this->setFrom($dates['from']);
        $this->setTo($dates['to']);
    }
184351
public function save(array $data)
    {
        if (!$this->getModel()->isSingle()) {
            $id = $data['id'] ?? $this->id;
            $this->id = $id;
        }

        $columns = $this->data;
        foreach ($columns as $key => $column) {
            if (array_key_exists($key, $data)) {
                $column->setValue($data[$key]);
            } else {
                $column->setValue(null);
            }
        }

        $yaml = Yaml::dump($this->getData(), 5, 4, YAML::DUMP_MULTI_LINE_LITERAL_BLOCK | YAML::DUMP_OBJECT_AS_MAP);

        $fs = new Filesystem();
        $fs->dumpFile($this->getContentFilePath(), $yaml);
    }
786646
public function write($data)
    {
        $post_date_string = $data['post_date']->format('Y-m-d H:i:s');
        $slug = $this->generateSlug($data['title']);
        $filename = $data['post_date']->format('Y-m-d') . '-' . $slug;

		$headerData = [
			'title' => $data['title'],
			'date' => $post_date_string,
			'layout' => 'post',
			'slug' => $slug,
			'categories' => $data['categories'],
			'tags' => $data['tags'],
		];

		$dumper = new YamlDumper();
		$header = '---' . PHP_EOL . $dumper->dump($headerData, 2) . '---' . PHP_EOL;

        $filename = $this->destinationFolder . $filename;
        if ($this->isMarkdownEnabled()) {
            $filename .= '.md';
            $data['content'] = $this->toMarkdown($data['content']);
        } else {
            $filename .= '.html';
        }
        file_put_contents($filename, $header . PHP_EOL . $data['content']);
    }
1239611
private function saveCache(array $data)
    {
        $this->cache = $data; // Save new data in object to avoid useless I/O access
        $opt = '';
        if (ForumEnv::get('FEATHER_DEBUG')) {
            $opt = JSON_PRETTY_PRINT;
        }
        return file_put_contents($this->getCacheFile(), json_encode($data, $opt));
    }
507772
function _write($data)
    {
        if ($this->_hashedDirectoryLevel > 0) {
            $hash = md5($this->_fileName);
            $root = $this->_cacheDir;
            for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
                if (!(@is_dir($root))) {
					if (@mkdir($root))
					{
						@chmod($root, $this->_hashedDirectoryUmask);
						if (! is_null($this->_hashedDirectoryGroup))
							@chgrp($root, $this->_hashedDirectoryGroup);
					}
                }
            }
        }
		// if both _cacheFileMode and _cacheFileGroup is null, then we don't need to call
		// file_exists (see below: if ($is_newfile) ...)
		$is_newfile = (! is_null($this->_cacheFileMode) || !is_null($this->_cacheFileGroup)) 
			&& ! @file_exists($this->_file);
        $fp = @fopen($this->_file, "wb");
        if ($fp) {
            if ($this->_fileLocking) @flock($fp, LOCK_EX);
			if ($is_newfile)
			{
				if (! is_null($this->_cacheFileMode))
					@chmod($this->_file, $this->_cacheFileMode);
				if (! is_null($this->_cacheFileGroup))
					@chgrp($this->_file, $this->_cacheFileGroup);
			}
            if ($this->_readControl) {
                @fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
            }
            $mqr = get_magic_quotes_runtime();
            if ($mqr) {
                set_magic_quotes_runtime(0);
            }
            @fwrite($fp, $data);
            if ($mqr) {
                set_magic_quotes_runtime($mqr);
            }
            if ($this->_fileLocking) @flock($fp, LOCK_UN);
            @fclose($fp);
            return true;
        }      
        return $this->raiseError('Cache_Lite : Unable to write cache file : '.$this->_file, -1);
    }
136161
public function save($data): void
    {
        if (\is_string($data)) {
            // Make sure that the string is valid data.
            try {
                $this->formatter->decode($data);
            } catch (RuntimeException $e) {
                throw new RuntimeException(sprintf("Failed to save file '%s': %s", $this->getFilePath(), $e->getMessage()), $e->getCode(), $e);
            }
            $encoded = $data;
        } else {
            $encoded = $this->formatter->encode($data);
        }

        parent::save($encoded);
    }
741106
public function setDataFromArray(array $data)
    {
        foreach ($data as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (method_exists($this, $method)) {
                $this->$method($value);
            }
        }
    }