From 7f6f1d7092477edde9431cea7c3703ee72ef5eb5 Mon Sep 17 00:00:00 2001 From: Matthieu Codron Date: Mon, 29 Apr 2013 11:10:00 +0200 Subject: [PATCH] correct floIcon to work on big-endian architectures all unpacks where machine byte order dependant (by the use of S and L pack codes) using respectively v and V seems to correct the issue. should fix #255, #294 --- libs/floIcon.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/floIcon.php b/libs/floIcon.php index c35ca0f9da..708fbdd397 100644 --- a/libs/floIcon.php +++ b/libs/floIcon.php @@ -288,7 +288,7 @@ function getBestImage($height = 32, $width = 32) { function readICO($file, $offset = 0) { if (file_exists($file) && filesize($file) > 0 && $filePointer = fopen($file, "r")) { fseek($filePointer, $offset); - $header = unpack("SReserved/SType/SCount", fread($filePointer, 6)); + $header = unpack("vReserved/vType/vCount", fread($filePointer, 6)); for ($t = 0; $t < $header["Count"]; $t++) { $newImage = new floIconImage(); $newImage->readImageFromICO($filePointer, 6 + ($t * 16)); @@ -778,14 +778,14 @@ function readImageFromICO($filePointer, $entryOffset) { // Get the entry. fseek($filePointer, $entryOffset); $this->_entryIconFormat = fread($filePointer, 16); - $this->_entry = unpack("CWidth/CHeight/CColorCount/CReserved/SPlanes/SBitCount/LSizeInBytes/LFileOffset", $this->_entryIconFormat); + $this->_entry = unpack("CWidth/CHeight/CColorCount/CReserved/vPlanes/vBitCount/VSizeInBytes/VFileOffset", $this->_entryIconFormat); // Position the file pointer. fseek($filePointer, $this->_entry["FileOffset"]); // Get the header. $this->_headerIconFormat = fread($filePointer, 40); - $this->_header = unpack("LSize/LWidth/LHeight/SPlanes/SBitCount/LCompression/LImageSize/LXpixelsPerM/LYpixelsPerM/LColorsUsed/LColorsImportant", $this->_headerIconFormat); + $this->_header = unpack("VSize/VWidth/VHeight/vPlanes/vBitCount/VCompression/VImageSize/VXpixelsPerM/VYpixelsPerM/VColorsUsed/VColorsImportant", $this->_headerIconFormat); // Get the image. $this->_imageIconFormat = @fread($filePointer, $this->_entry["SizeInBytes"] - strlen($this->_headerIconFormat));