From 9c27f4f77cc45e6fcf61a4755b4ce4b2506fe8a0 Mon Sep 17 00:00:00 2001 From: Christian Dickmann Date: Mon, 11 Nov 2002 01:23:24 +0000 Subject: [PATCH] make cache (get/set) binary safe --- pear/PEAR/Remote.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pear/PEAR/Remote.php b/pear/PEAR/Remote.php index 5662e9de012..0d1a11556c3 100644 --- a/pear/PEAR/Remote.php +++ b/pear/PEAR/Remote.php @@ -62,10 +62,17 @@ class PEAR_Remote extends PEAR if (!file_exists($filename)) { return null; }; + + $fp = fopen($filename, "rb"); + if ($fp === null) { + return null; + } + $content = fread($fp, filesize($filename)); + fclose($fp); $result = array( 'age' => time() - filemtime($filename), 'lastChange' => filemtime($filename), - 'content' => unserialize(implode('', file($filename))), + 'content' => unserialize($content), ); return $result; } @@ -83,7 +90,7 @@ class PEAR_Remote extends PEAR } $filename = $cachedir.'/xmlrpc_cache_'.$id; - $fp = @fopen($filename, "w"); + $fp = @fopen($filename, "wb"); if ($fp !== null) { fwrite($fp, serialize($data)); fclose($fp);