// | Based on OLE::Storage_Lite by Kawai, Takanori |
// +----------------------------------------------------------------------+
//
-// $Id: OLE.php,v 1.15 2007/12/18 20:59:11 schmidt Exp $
+// $Id: OLE.php 260165 2008-05-23 16:33:58Z schmidt $
/**
* Creates a new OLE object
* @access public
*/
- function OLE()
+ function __construct()
{
$this->_list = array();
}
$this->sbat = array();
$shortBlockCount = $sbbatBlockCount * $this->bigBlockSize / 4;
$sbatFh = $this->getStream($sbatFirstBlockId);
+ if (!$sbatFh) {
+ // Avoid an infinite loop if ChainedBlockStream.php somehow is
+ // missing
+ return false;
+ }
for ($blockId = 0; $blockId < $shortBlockCount; $blockId++) {
$this->sbat[$blockId] = $this->_readInt4($sbatFh);
}
$pps = new OLE_PPS_File($name);
break;
default:
- continue;
+ continue 2;
}
fseek($fh, 1, SEEK_CUR);
$pps->Type = $type;
* @param string $ascii The ASCII string to transform
* @return string The string in Unicode
*/
- function Asc2Ucs($ascii)
+ static function Asc2Ucs($ascii)
{
$rawname = '';
for ($i = 0; $i < strlen($ascii); $i++) {
- $rawname .= $ascii{$i} . "\x00";
+ $rawname .= $ascii[$i] . "\x00";
}
return $rawname;
}
* @param integer $date A timestamp
* @return string The string for the OLE container
*/
- function LocalDate2OLE($date = null)
+ static function LocalDate2OLE($date = null)
{
if (!isset($date)) {
return "\x00\x00\x00\x00\x00\x00\x00\x00";
$res = '';
for ($i = 0; $i < 4; $i++) {
- $hex = $low_part % 0x100;
+ $hex = ((int)$low_part) % 0x100;
$res .= pack('c', $hex);
$low_part /= 0x100;
}
for ($i = 0; $i < 4; $i++) {
- $hex = $high_part % 0x100;
+ $hex = ((int)$high_part) % 0x100;
$res .= pack('c', $hex);
$high_part /= 0x100;
}
* @access public
* @static
*/
- function OLE2LocalDate($string)
+ static function OLE2LocalDate($string)
{
if (strlen($string) != 8) {
return new PEAR_Error("Expecting 8 byte string");
$factor = pow(2,32);
$high_part = 0;
for ($i = 0; $i < 4; $i++) {
- list(, $high_part) = unpack('C', $string{(7 - $i)});
+ list(, $high_part) = unpack('C', $string[(7 - $i)]);
if ($i < 3) {
$high_part *= 0x100;
}
}
$low_part = 0;
for ($i = 4; $i < 8; $i++) {
- list(, $low_part) = unpack('C', $string{(7 - $i)});
+ list(, $low_part) = unpack('C', $string[(7 - $i)]);
if ($i < 7) {
$low_part *= 0x100;
}
return floor($big_date);
}
}
-?>
+