mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Merging the Limesurvey 1.91+ branch of queXS in to the trunk
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
|
||||
|
||||
/**
|
||||
* Constants for OLE package
|
||||
*/
|
||||
* Constants for OLE package
|
||||
*/
|
||||
define('OLE_PPS_TYPE_ROOT', 5);
|
||||
define('OLE_PPS_TYPE_DIR', 1);
|
||||
define('OLE_PPS_TYPE_FILE', 2);
|
||||
@@ -35,43 +35,43 @@ require_once($homedir.'/classes/pear/PEAR.php');
|
||||
require_once $homedir.'/classes/pear/OLE/PPS.php';
|
||||
|
||||
/**
|
||||
* OLE package base class.
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
* OLE package base class.
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
class OLE extends PEAR
|
||||
{
|
||||
/**
|
||||
* The file handle for reading an OLE container
|
||||
* @var resource
|
||||
*/
|
||||
* The file handle for reading an OLE container
|
||||
* @var resource
|
||||
*/
|
||||
var $_file_handle;
|
||||
|
||||
/**
|
||||
* Array of PPS's found on the OLE container
|
||||
* @var array
|
||||
*/
|
||||
* Array of PPS's found on the OLE container
|
||||
* @var array
|
||||
*/
|
||||
var $_list;
|
||||
|
||||
/**
|
||||
* Creates a new OLE object
|
||||
* Remember to use ampersand when creating an OLE object ($my_ole =& new OLE();)
|
||||
* @access public
|
||||
*/
|
||||
* Creates a new OLE object
|
||||
* Remember to use ampersand when creating an OLE object ($my_ole =& new OLE();)
|
||||
* @access public
|
||||
*/
|
||||
function OLE()
|
||||
{
|
||||
$this->_list = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an OLE container from the contents of the file given.
|
||||
*
|
||||
* @acces public
|
||||
* @param string $file
|
||||
* @return mixed true on success, PEAR_Error on failure
|
||||
*/
|
||||
* Reads an OLE container from the contents of the file given.
|
||||
*
|
||||
* @acces public
|
||||
* @param string $file
|
||||
* @return mixed true on success, PEAR_Error on failure
|
||||
*/
|
||||
function read($file)
|
||||
{
|
||||
/* consider storing offsets as constants */
|
||||
@@ -122,25 +122,25 @@ class OLE extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor (using PEAR)
|
||||
* Just closes the file handle on the OLE file.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
* Destructor (using PEAR)
|
||||
* Just closes the file handle on the OLE file.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _OLE()
|
||||
{
|
||||
fclose($this->_file_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information about all PPS's on the OLE container from the PPS WK's
|
||||
* creates an OLE_PPS object for each one.
|
||||
*
|
||||
* @access private
|
||||
* @param integer $pps_wk_start Position inside the OLE file where PPS WK's start
|
||||
* @param integer $big_block_size Size of big blobks in the OLE file
|
||||
* @return mixed true on success, PEAR_Error on failure
|
||||
*/
|
||||
* Gets information about all PPS's on the OLE container from the PPS WK's
|
||||
* creates an OLE_PPS object for each one.
|
||||
*
|
||||
* @access private
|
||||
* @param integer $pps_wk_start Position inside the OLE file where PPS WK's start
|
||||
* @param integer $big_block_size Size of big blobks in the OLE file
|
||||
* @return mixed true on success, PEAR_Error on failure
|
||||
*/
|
||||
function _readPpsWks($pps_wk_start, $big_block_size)
|
||||
{
|
||||
$pointer = ($pps_wk_start + 1) * $big_block_size;
|
||||
@@ -149,7 +149,7 @@ class OLE extends PEAR
|
||||
fseek($this->_file_handle, $pointer);
|
||||
$pps_wk = fread($this->_file_handle, OLE_PPS_SIZE);
|
||||
if (strlen($pps_wk) != OLE_PPS_SIZE) {
|
||||
break; // Excel likes to add a trailing byte sometimes
|
||||
break; // Excel likes to add a trailing byte sometimes
|
||||
//return $this->raiseError("PPS at $pointer seems too short: ".strlen($pps_wk));
|
||||
}
|
||||
$name_length = unpack("c", substr($pps_wk, 64, 2)); // FIXME (2 bytes??)
|
||||
@@ -157,8 +157,8 @@ class OLE extends PEAR
|
||||
$name = substr($pps_wk, 0, $name_length);
|
||||
$type = unpack("c", substr($pps_wk, 66, 1));
|
||||
if (($type[''] != OLE_PPS_TYPE_ROOT) and
|
||||
($type[''] != OLE_PPS_TYPE_DIR) and
|
||||
($type[''] != OLE_PPS_TYPE_FILE))
|
||||
($type[''] != OLE_PPS_TYPE_DIR) and
|
||||
($type[''] != OLE_PPS_TYPE_FILE))
|
||||
{
|
||||
return $this->raiseError("PPS at $pointer has unknown type: {$type['']}");
|
||||
}
|
||||
@@ -174,9 +174,9 @@ class OLE extends PEAR
|
||||
// _data member will point to position in file!!
|
||||
// OLE_PPS object is created with an empty children array!!
|
||||
$this->_list[] = new OLE_PPS(null, '', $type[''], $prev[''], $next[''],
|
||||
$dir[''], OLE::OLE2LocalDate($time_1st),
|
||||
OLE::OLE2LocalDate($time_2nd),
|
||||
($start_block[''] + 1) * $big_block_size, array());
|
||||
$dir[''], OLE::OLE2LocalDate($time_1st),
|
||||
OLE::OLE2LocalDate($time_2nd),
|
||||
($start_block[''] + 1) * $big_block_size, array());
|
||||
// give it a size
|
||||
$this->_list[count($this->_list) - 1]->Size = $size[''];
|
||||
// check if the PPS tree (starting from root) is complete
|
||||
@@ -186,15 +186,15 @@ class OLE extends PEAR
|
||||
$pointer += OLE_PPS_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* It checks whether the PPS tree is complete (all PPS's read)
|
||||
* starting with the given PPS (not necessarily root)
|
||||
*
|
||||
* @access private
|
||||
* @param integer $index The index of the PPS from which we are checking
|
||||
* @return boolean Whether the PPS tree for the given PPS is complete
|
||||
*/
|
||||
* It checks whether the PPS tree is complete (all PPS's read)
|
||||
* starting with the given PPS (not necessarily root)
|
||||
*
|
||||
* @access private
|
||||
* @param integer $index The index of the PPS from which we are checking
|
||||
* @return boolean Whether the PPS tree for the given PPS is complete
|
||||
*/
|
||||
function _ppsTreeComplete($index)
|
||||
{
|
||||
if ($this->_list[$index]->NextPps != -1) {
|
||||
@@ -216,14 +216,14 @@ class OLE extends PEAR
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a PPS is a File PPS or not.
|
||||
* If there is no PPS for the index given, it will return false.
|
||||
*
|
||||
* @access public
|
||||
* @param integer $index The index for the PPS
|
||||
* @return bool true if it's a File PPS, false otherwise
|
||||
*/
|
||||
/**
|
||||
* Checks whether a PPS is a File PPS or not.
|
||||
* If there is no PPS for the index given, it will return false.
|
||||
*
|
||||
* @access public
|
||||
* @param integer $index The index for the PPS
|
||||
* @return bool true if it's a File PPS, false otherwise
|
||||
*/
|
||||
function isFile($index)
|
||||
{
|
||||
if (isset($this->_list[$index])) {
|
||||
@@ -232,14 +232,14 @@ class OLE extends PEAR
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a PPS is a Root PPS or not.
|
||||
* If there is no PPS for the index given, it will return false.
|
||||
*
|
||||
* @access public
|
||||
* @param integer $index The index for the PPS.
|
||||
* @return bool true if it's a Root PPS, false otherwise
|
||||
*/
|
||||
/**
|
||||
* Checks whether a PPS is a Root PPS or not.
|
||||
* If there is no PPS for the index given, it will return false.
|
||||
*
|
||||
* @access public
|
||||
* @param integer $index The index for the PPS.
|
||||
* @return bool true if it's a Root PPS, false otherwise
|
||||
*/
|
||||
function isRoot($index)
|
||||
{
|
||||
if (isset($this->_list[$index])) {
|
||||
@@ -248,28 +248,28 @@ class OLE extends PEAR
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the total number of PPS's found in the OLE container.
|
||||
*
|
||||
* @access public
|
||||
* @return integer The total number of PPS's found in the OLE container
|
||||
*/
|
||||
/**
|
||||
* Gives the total number of PPS's found in the OLE container.
|
||||
*
|
||||
* @access public
|
||||
* @return integer The total number of PPS's found in the OLE container
|
||||
*/
|
||||
function ppsTotal()
|
||||
{
|
||||
return count($this->_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets data from a PPS
|
||||
* If there is no PPS for the index given, it will return an empty string.
|
||||
*
|
||||
* @access public
|
||||
* @param integer $index The index for the PPS
|
||||
* @param integer $position The position from which to start reading
|
||||
* (relative to the PPS)
|
||||
* @param integer $length The amount of bytes to read (at most)
|
||||
* @return string The binary string containing the data requested
|
||||
*/
|
||||
* Gets data from a PPS
|
||||
* If there is no PPS for the index given, it will return an empty string.
|
||||
*
|
||||
* @access public
|
||||
* @param integer $index The index for the PPS
|
||||
* @param integer $position The position from which to start reading
|
||||
* (relative to the PPS)
|
||||
* @param integer $length The amount of bytes to read (at most)
|
||||
* @return string The binary string containing the data requested
|
||||
*/
|
||||
function getData($index, $position, $length)
|
||||
{
|
||||
// if position is not valid return empty string
|
||||
@@ -280,15 +280,15 @@ class OLE extends PEAR
|
||||
fseek($this->_file_handle, $this->_list[$index]->_data + $position);
|
||||
return fread($this->_file_handle, $length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the data length from a PPS
|
||||
* If there is no PPS for the index given, it will return 0.
|
||||
*
|
||||
* @access public
|
||||
* @param integer $index The index for the PPS
|
||||
* @return integer The amount of bytes in data the PPS has
|
||||
*/
|
||||
* Gets the data length from a PPS
|
||||
* If there is no PPS for the index given, it will return 0.
|
||||
*
|
||||
* @access public
|
||||
* @param integer $index The index for the PPS
|
||||
* @return integer The amount of bytes in data the PPS has
|
||||
*/
|
||||
function getDataLength($index)
|
||||
{
|
||||
if (isset($this->_list[$index])) {
|
||||
@@ -298,13 +298,13 @@ class OLE extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to transform ASCII text to Unicode
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param string $ascii The ASCII string to transform
|
||||
* @return string The string in Unicode
|
||||
*/
|
||||
* Utility function to transform ASCII text to Unicode
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param string $ascii The ASCII string to transform
|
||||
* @return string The string in Unicode
|
||||
*/
|
||||
static function Asc2Ucs($ascii)
|
||||
{
|
||||
$rawname = '';
|
||||
@@ -315,14 +315,14 @@ class OLE extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function
|
||||
* Returns a string for the OLE container with the date given
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param integer $date A timestamp
|
||||
* @return string The string for the OLE container
|
||||
*/
|
||||
* Utility function
|
||||
* Returns a string for the OLE container with the date given
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param integer $date A timestamp
|
||||
* @return string The string for the OLE container
|
||||
*/
|
||||
static function LocalDate2OLE($date = null)
|
||||
{
|
||||
if (!isset($date)) {
|
||||
@@ -336,7 +336,7 @@ class OLE extends PEAR
|
||||
$days = 134774;
|
||||
// calculate seconds
|
||||
$big_date = $days*24*3600 + gmmktime(date("H",$date),date("i",$date),date("s",$date),
|
||||
date("m",$date),date("d",$date),date("Y",$date));
|
||||
date("m",$date),date("d",$date),date("Y",$date));
|
||||
// multiply just to make MS happy
|
||||
$big_date *= 10000000;
|
||||
|
||||
@@ -363,13 +363,13 @@ class OLE extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a timestamp from an OLE container's date
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param integer $string A binary string with the encoded date
|
||||
* @return string The timestamp corresponding to the string
|
||||
*/
|
||||
* Returns a timestamp from an OLE container's date
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param integer $string A binary string with the encoded date
|
||||
* @return string The timestamp corresponding to the string
|
||||
*/
|
||||
static function OLE2LocalDate($string)
|
||||
{
|
||||
if (strlen($string) != 8) {
|
||||
@@ -399,10 +399,10 @@ class OLE extends PEAR
|
||||
$big_date = ($high_part*$factor) + $low_part;
|
||||
// translate to seconds
|
||||
$big_date /= 10000000;
|
||||
|
||||
|
||||
// days from 1-1-1601 until the beggining of UNIX era
|
||||
$days = 134774;
|
||||
|
||||
|
||||
// translate to seconds from beggining of UNIX era
|
||||
$big_date -= $days*24*3600;
|
||||
return floor($big_date);
|
||||
|
||||
@@ -24,100 +24,100 @@ require_once($homedir.'/classes/pear/PEAR.php');
|
||||
require_once($homedir.'/classes/pear/OLE/OLE.php');
|
||||
|
||||
/**
|
||||
* Class for creating PPS's for OLE containers
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
* Class for creating PPS's for OLE containers
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
class OLE_PPS extends PEAR
|
||||
{
|
||||
/**
|
||||
* The PPS index
|
||||
* @var integer
|
||||
*/
|
||||
* The PPS index
|
||||
* @var integer
|
||||
*/
|
||||
var $No;
|
||||
|
||||
/**
|
||||
* The PPS name (in Unicode)
|
||||
* @var string
|
||||
*/
|
||||
* The PPS name (in Unicode)
|
||||
* @var string
|
||||
*/
|
||||
var $Name;
|
||||
|
||||
|
||||
/**
|
||||
* The PPS type. Dir, Root or File
|
||||
* @var integer
|
||||
*/
|
||||
* The PPS type. Dir, Root or File
|
||||
* @var integer
|
||||
*/
|
||||
var $Type;
|
||||
|
||||
|
||||
/**
|
||||
* The index of the previous PPS
|
||||
* @var integer
|
||||
*/
|
||||
* The index of the previous PPS
|
||||
* @var integer
|
||||
*/
|
||||
var $PrevPps;
|
||||
|
||||
|
||||
/**
|
||||
* The index of the next PPS
|
||||
* @var integer
|
||||
*/
|
||||
* The index of the next PPS
|
||||
* @var integer
|
||||
*/
|
||||
var $NextPps;
|
||||
|
||||
|
||||
/**
|
||||
* The index of it's first child if this is a Dir or Root PPS
|
||||
* @var integer
|
||||
*/
|
||||
* The index of it's first child if this is a Dir or Root PPS
|
||||
* @var integer
|
||||
*/
|
||||
var $DirPps;
|
||||
|
||||
|
||||
/**
|
||||
* A timestamp
|
||||
* @var integer
|
||||
*/
|
||||
* A timestamp
|
||||
* @var integer
|
||||
*/
|
||||
var $Time1st;
|
||||
|
||||
/**
|
||||
* A timestamp
|
||||
* @var integer
|
||||
*/
|
||||
* A timestamp
|
||||
* @var integer
|
||||
*/
|
||||
var $Time2nd;
|
||||
|
||||
/**
|
||||
* Starting block (small or big) for this PPS's data inside the container
|
||||
* @var integer
|
||||
*/
|
||||
* Starting block (small or big) for this PPS's data inside the container
|
||||
* @var integer
|
||||
*/
|
||||
var $_StartBlock;
|
||||
|
||||
/**
|
||||
* The size of the PPS's data (in bytes)
|
||||
* @var integer
|
||||
*/
|
||||
* The size of the PPS's data (in bytes)
|
||||
* @var integer
|
||||
*/
|
||||
var $Size;
|
||||
|
||||
/**
|
||||
* The PPS's data (only used if it's not using a temporary file)
|
||||
* @var string
|
||||
*/
|
||||
* The PPS's data (only used if it's not using a temporary file)
|
||||
* @var string
|
||||
*/
|
||||
var $_data;
|
||||
|
||||
/**
|
||||
* Array of child PPS's (only used by Root and Dir PPS's)
|
||||
* @var array
|
||||
*/
|
||||
* Array of child PPS's (only used by Root and Dir PPS's)
|
||||
* @var array
|
||||
*/
|
||||
var $children = array();
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*
|
||||
* @access public
|
||||
* @param integer $No The PPS index
|
||||
* @param string $name The PPS name (in Unicode)
|
||||
* @param integer $type The PPS type. Dir, Root or File
|
||||
* @param integer $prev The index of the previous PPS
|
||||
* @param integer $next The index of the next PPS
|
||||
* @param integer $dir The index of it's first child if this is a Dir or Root PPS
|
||||
* @param integer $time_1st A timestamp
|
||||
* @param integer $time_2nd A timestamp
|
||||
* @param array $children Array containing children PPS for this PPS
|
||||
*/
|
||||
* The constructor
|
||||
*
|
||||
* @access public
|
||||
* @param integer $No The PPS index
|
||||
* @param string $name The PPS name (in Unicode)
|
||||
* @param integer $type The PPS type. Dir, Root or File
|
||||
* @param integer $prev The index of the previous PPS
|
||||
* @param integer $next The index of the next PPS
|
||||
* @param integer $dir The index of it's first child if this is a Dir or Root PPS
|
||||
* @param integer $time_1st A timestamp
|
||||
* @param integer $time_2nd A timestamp
|
||||
* @param array $children Array containing children PPS for this PPS
|
||||
*/
|
||||
function OLE_PPS($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
|
||||
{
|
||||
$this->No = $No;
|
||||
@@ -139,11 +139,11 @@ class OLE_PPS extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of data saved for this PPS
|
||||
*
|
||||
* @access private
|
||||
* @return integer The amount of data (in bytes)
|
||||
*/
|
||||
* Returns the amount of data saved for this PPS
|
||||
*
|
||||
* @access private
|
||||
* @return integer The amount of data (in bytes)
|
||||
*/
|
||||
function _DataLen()
|
||||
{
|
||||
if (!isset($this->_data)) {
|
||||
@@ -161,11 +161,11 @@ class OLE_PPS extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string with the PPS's WK (What is a WK?)
|
||||
*
|
||||
* @access private
|
||||
* @return string The binary string
|
||||
*/
|
||||
* Returns a string with the PPS's WK (What is a WK?)
|
||||
*
|
||||
* @access private
|
||||
* @return string The binary string
|
||||
*/
|
||||
function _getPpsWk()
|
||||
{
|
||||
$ret = $this->Name;
|
||||
@@ -173,35 +173,35 @@ class OLE_PPS extends PEAR
|
||||
$ret .= "\x00";
|
||||
}
|
||||
$ret .= pack("v", strlen($this->Name) + 2) // 66
|
||||
. pack("c", $this->Type) // 67
|
||||
. pack("c", 0x00) //UK // 68
|
||||
. pack("V", $this->PrevPps) //Prev // 72
|
||||
. pack("V", $this->NextPps) //Next // 76
|
||||
. pack("V", $this->DirPps) //Dir // 80
|
||||
. "\x00\x09\x02\x00" // 84
|
||||
. "\x00\x00\x00\x00" // 88
|
||||
. "\xc0\x00\x00\x00" // 92
|
||||
. "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root
|
||||
. "\x00\x00\x00\x00" // 100
|
||||
. OLE::LocalDate2OLE($this->Time1st) // 108
|
||||
. OLE::LocalDate2OLE($this->Time2nd) // 116
|
||||
. pack("V", isset($this->_StartBlock)?
|
||||
$this->_StartBlock:0) // 120
|
||||
. pack("V", $this->Size) // 124
|
||||
. pack("V", 0); // 128
|
||||
. pack("c", $this->Type) // 67
|
||||
. pack("c", 0x00) //UK // 68
|
||||
. pack("V", $this->PrevPps) //Prev // 72
|
||||
. pack("V", $this->NextPps) //Next // 76
|
||||
. pack("V", $this->DirPps) //Dir // 80
|
||||
. "\x00\x09\x02\x00" // 84
|
||||
. "\x00\x00\x00\x00" // 88
|
||||
. "\xc0\x00\x00\x00" // 92
|
||||
. "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root
|
||||
. "\x00\x00\x00\x00" // 100
|
||||
. OLE::LocalDate2OLE($this->Time1st) // 108
|
||||
. OLE::LocalDate2OLE($this->Time2nd) // 116
|
||||
. pack("V", isset($this->_StartBlock)?
|
||||
$this->_StartBlock:0) // 120
|
||||
. pack("V", $this->Size) // 124
|
||||
. pack("V", 0); // 128
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates index and pointers to previous, next and children PPS's for this
|
||||
* PPS. I don't think it'll work with Dir PPS's.
|
||||
*
|
||||
* @access private
|
||||
* @param array &$pps_array Reference to the array of PPS's for the whole OLE
|
||||
* container
|
||||
* @return integer The index for this PPS
|
||||
*/
|
||||
function _savePpsSetPnt(&$pps_array)
|
||||
* Updates index and pointers to previous, next and children PPS's for this
|
||||
* PPS. I don't think it'll work with Dir PPS's.
|
||||
*
|
||||
* @access private
|
||||
* @param array &$pps_array Reference to the array of PPS's for the whole OLE
|
||||
* container
|
||||
* @return integer The index for this PPS
|
||||
*/
|
||||
function _savePpsSetPnt(&$pps_array)
|
||||
{
|
||||
$pps_array[count($pps_array)] = &$this;
|
||||
$this->No = count($pps_array) - 1;
|
||||
|
||||
@@ -23,50 +23,50 @@ if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}
|
||||
require_once ($homedir.'/classes/pear/OLE/PPS.php');
|
||||
|
||||
/**
|
||||
* Class for creating File PPS's for OLE containers
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
* Class for creating File PPS's for OLE containers
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
class OLE_PPS_File extends OLE_PPS
|
||||
{
|
||||
/**
|
||||
* The temporary dir for storing the OLE file
|
||||
* @var string
|
||||
*/
|
||||
* The temporary dir for storing the OLE file
|
||||
* @var string
|
||||
*/
|
||||
var $_tmp_dir;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The name of the file (in Unicode)
|
||||
* @see OLE::Asc2Ucs()
|
||||
*/
|
||||
* The constructor
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The name of the file (in Unicode)
|
||||
* @see OLE::Asc2Ucs()
|
||||
*/
|
||||
function OLE_PPS_File($name)
|
||||
{
|
||||
$this->_tmp_dir = '';
|
||||
$this->OLE_PPS(
|
||||
null,
|
||||
$name,
|
||||
OLE_PPS_TYPE_FILE,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$name,
|
||||
OLE_PPS_TYPE_FILE,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'',
|
||||
array());
|
||||
array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the temp dir used for storing the OLE file
|
||||
*
|
||||
* @access public
|
||||
* @param string $dir The dir to be used as temp dir
|
||||
* @return true if given dir is valid, false otherwise
|
||||
*/
|
||||
* Sets the temp dir used for storing the OLE file
|
||||
*
|
||||
* @access public
|
||||
* @param string $dir The dir to be used as temp dir
|
||||
* @return true if given dir is valid, false otherwise
|
||||
*/
|
||||
function setTempDir($dir)
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
@@ -77,11 +77,11 @@ class OLE_PPS_File extends OLE_PPS
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization method. Has to be called right after OLE_PPS_File().
|
||||
*
|
||||
* @access public
|
||||
* @return mixed true on success. PEAR_Error on failure
|
||||
*/
|
||||
* Initialization method. Has to be called right after OLE_PPS_File().
|
||||
*
|
||||
* @access public
|
||||
* @return mixed true on success. PEAR_Error on failure
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_File");
|
||||
@@ -94,13 +94,13 @@ class OLE_PPS_File extends OLE_PPS
|
||||
fseek($this->_PPS_FILE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Append data to PPS
|
||||
*
|
||||
* @access public
|
||||
* @param string $data The data to append
|
||||
*/
|
||||
* Append data to PPS
|
||||
*
|
||||
* @access public
|
||||
* @param string $data The data to append
|
||||
*/
|
||||
function append($data)
|
||||
{
|
||||
if ($this->_PPS_FILE) {
|
||||
|
||||
@@ -23,50 +23,50 @@ if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}
|
||||
require_once ($homedir.'/classes/pear/OLE/PPS.php');
|
||||
|
||||
/**
|
||||
* Class for creating Root PPS's for OLE containers
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
* Class for creating Root PPS's for OLE containers
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
class OLE_PPS_Root extends OLE_PPS
|
||||
{
|
||||
/**
|
||||
* The temporary dir for storing the OLE file
|
||||
* @var string
|
||||
*/
|
||||
* The temporary dir for storing the OLE file
|
||||
* @var string
|
||||
*/
|
||||
var $_tmp_dir;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param integer $time_1st A timestamp
|
||||
* @param integer $time_2nd A timestamp
|
||||
*/
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param integer $time_1st A timestamp
|
||||
* @param integer $time_2nd A timestamp
|
||||
*/
|
||||
function OLE_PPS_Root($time_1st, $time_2nd, $raChild)
|
||||
{
|
||||
$this->_tmp_dir = '';
|
||||
$this->OLE_PPS(
|
||||
null,
|
||||
OLE::Asc2Ucs('Root Entry'),
|
||||
OLE_PPS_TYPE_ROOT,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$time_1st,
|
||||
$time_2nd,
|
||||
null,
|
||||
$raChild);
|
||||
null,
|
||||
OLE::Asc2Ucs('Root Entry'),
|
||||
OLE_PPS_TYPE_ROOT,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$time_1st,
|
||||
$time_2nd,
|
||||
null,
|
||||
$raChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the temp dir used for storing the OLE file
|
||||
*
|
||||
* @access public
|
||||
* @param string $dir The dir to be used as temp dir
|
||||
* @return true if given dir is valid, false otherwise
|
||||
*/
|
||||
* Sets the temp dir used for storing the OLE file
|
||||
*
|
||||
* @access public
|
||||
* @param string $dir The dir to be used as temp dir
|
||||
* @return true if given dir is valid, false otherwise
|
||||
*/
|
||||
function setTempDir($dir)
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
@@ -77,22 +77,22 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for saving the whole OLE container (including files).
|
||||
* In fact, if called with an empty argument (or '-'), it saves to a
|
||||
* temporary file and then outputs it's contents to stdout.
|
||||
*
|
||||
* @param string $filename The name of the file where to save the OLE container
|
||||
* @access public
|
||||
* @return mixed true on success, PEAR_Error on failure
|
||||
*/
|
||||
* Method for saving the whole OLE container (including files).
|
||||
* In fact, if called with an empty argument (or '-'), it saves to a
|
||||
* temporary file and then outputs it's contents to stdout.
|
||||
*
|
||||
* @param string $filename The name of the file where to save the OLE container
|
||||
* @access public
|
||||
* @return mixed true on success, PEAR_Error on failure
|
||||
*/
|
||||
function save($filename)
|
||||
{
|
||||
// Initial Setting for saving
|
||||
$this->_BIG_BLOCK_SIZE = pow(2,
|
||||
((isset($this->_BIG_BLOCK_SIZE))? $this->_adjust2($this->_BIG_BLOCK_SIZE) : 9));
|
||||
$this->_SMALL_BLOCK_SIZE= pow(2,
|
||||
((isset($this->_SMALL_BLOCK_SIZE))? $this->_adjust2($this->_SMALL_BLOCK_SIZE): 6));
|
||||
|
||||
((isset($this->_BIG_BLOCK_SIZE))? $this->_adjust2($this->_BIG_BLOCK_SIZE) : 9));
|
||||
$this->_SMALL_BLOCK_SIZE= pow(2,
|
||||
((isset($this->_SMALL_BLOCK_SIZE))? $this->_adjust2($this->_SMALL_BLOCK_SIZE): 6));
|
||||
|
||||
// Open temp file if we are sending output to stdout
|
||||
if (($filename == '-') or ($filename == ''))
|
||||
{
|
||||
@@ -116,10 +116,10 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo);
|
||||
// Save Header
|
||||
$this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt);
|
||||
|
||||
|
||||
// Make Small Data string (write SBD)
|
||||
$this->_data = $this->_makeSmallData($aList);
|
||||
|
||||
|
||||
// Write BB
|
||||
$this->_saveBigData($iSBDcnt, $aList);
|
||||
// Write PPS
|
||||
@@ -142,13 +142,13 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate some numbers
|
||||
*
|
||||
* @access private
|
||||
* @param array $raList Reference to an array of PPS's
|
||||
* @return array The array of numbers
|
||||
*/
|
||||
function _calcSize(&$raList)
|
||||
* Calculate some numbers
|
||||
*
|
||||
* @access private
|
||||
* @param array $raList Reference to an array of PPS's
|
||||
* @return array The array of numbers
|
||||
*/
|
||||
function _calcSize(&$raList)
|
||||
{
|
||||
// Calculate Basic Setting
|
||||
list($iSBDcnt, $iBBcnt, $iPPScnt) = array(0,0,0);
|
||||
@@ -159,11 +159,11 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
$raList[$i]->Size = $raList[$i]->_DataLen();
|
||||
if($raList[$i]->Size < OLE_DATA_SIZE_SMALL) {
|
||||
$iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
|
||||
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
|
||||
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
|
||||
}
|
||||
else {
|
||||
$iBBcnt += (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
|
||||
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
|
||||
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,22 +171,22 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
$iSlCnt = floor($this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE);
|
||||
$iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt)? 1:0);
|
||||
$iBBcnt += (floor($iSmallLen / $this->_BIG_BLOCK_SIZE) +
|
||||
(( $iSmallLen % $this->_BIG_BLOCK_SIZE)? 1: 0));
|
||||
(( $iSmallLen % $this->_BIG_BLOCK_SIZE)? 1: 0));
|
||||
$iCnt = count($raList);
|
||||
$iBdCnt = $this->_BIG_BLOCK_SIZE / OLE_PPS_SIZE;
|
||||
$iPPScnt = (floor($iCnt/$iBdCnt) + (($iCnt % $iBdCnt)? 1: 0));
|
||||
|
||||
|
||||
return array($iSBDcnt, $iBBcnt, $iPPScnt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for caculating a magic value for block sizes
|
||||
*
|
||||
* @access private
|
||||
* @param integer $i2 The argument
|
||||
* @see save()
|
||||
* @return integer
|
||||
*/
|
||||
* Helper function for caculating a magic value for block sizes
|
||||
*
|
||||
* @access private
|
||||
* @param integer $i2 The argument
|
||||
* @see save()
|
||||
* @return integer
|
||||
*/
|
||||
function _adjust2($i2)
|
||||
{
|
||||
$iWk = log($i2)/log(2);
|
||||
@@ -194,27 +194,27 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
}
|
||||
|
||||
/**
|
||||
* Save OLE header
|
||||
*
|
||||
* @access private
|
||||
* @param integer $iSBDcnt
|
||||
* @param integer $iBBcnt
|
||||
* @param integer $iPPScnt
|
||||
*/
|
||||
* Save OLE header
|
||||
*
|
||||
* @access private
|
||||
* @param integer $iSBDcnt
|
||||
* @param integer $iBBcnt
|
||||
* @param integer $iPPScnt
|
||||
*/
|
||||
function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt)
|
||||
{
|
||||
$FILE = $this->_FILEH_;
|
||||
|
||||
|
||||
// Calculate Basic Setting
|
||||
$iBlCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE;
|
||||
$i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE;
|
||||
|
||||
|
||||
$iBdExL = 0;
|
||||
$iAll = $iBBcnt + $iPPScnt + $iSBDcnt;
|
||||
$iAllW = $iAll;
|
||||
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0);
|
||||
$iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0);
|
||||
|
||||
|
||||
// Calculate BD count
|
||||
if ($iBdCnt >$i1stBdL)
|
||||
{
|
||||
@@ -229,7 +229,7 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Save Header
|
||||
fwrite($FILE,
|
||||
"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1"
|
||||
@@ -245,49 +245,49 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
. pack("v", 0)
|
||||
. "\x00\x00\x00\x00"
|
||||
. "\x00\x00\x00\x00"
|
||||
. pack("V", $iBdCnt)
|
||||
. pack("V", $iBdCnt)
|
||||
. pack("V", $iBBcnt+$iSBDcnt) //ROOT START
|
||||
. pack("V", 0)
|
||||
. pack("V", 0x1000)
|
||||
. pack("V", 0) //Small Block Depot
|
||||
. pack("V", 1)
|
||||
);
|
||||
// Extra BDList Start, Count
|
||||
if ($iBdCnt < $i1stBdL)
|
||||
{
|
||||
fwrite($FILE,
|
||||
);
|
||||
// Extra BDList Start, Count
|
||||
if ($iBdCnt < $i1stBdL)
|
||||
{
|
||||
fwrite($FILE,
|
||||
pack("V", -2). // Extra BDList Start
|
||||
pack("V", 0) // Extra BDList Count
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL));
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL));
|
||||
}
|
||||
|
||||
// BDList
|
||||
for ($i=0; $i<$i1stBdL and $i < $iBdCnt; $i++) {
|
||||
fwrite($FILE, pack("V", $iAll+$i));
|
||||
}
|
||||
if ($i < $i1stBdL)
|
||||
{
|
||||
for ($j = 0; $j < ($i1stBdL-$i); $j++) {
|
||||
fwrite($FILE, (pack("V", -1)));
|
||||
}
|
||||
}
|
||||
// BDList
|
||||
for ($i=0; $i<$i1stBdL and $i < $iBdCnt; $i++) {
|
||||
fwrite($FILE, pack("V", $iAll+$i));
|
||||
}
|
||||
if ($i < $i1stBdL)
|
||||
{
|
||||
for ($j = 0; $j < ($i1stBdL-$i); $j++) {
|
||||
fwrite($FILE, (pack("V", -1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saving big data (PPS's with data bigger than OLE_DATA_SIZE_SMALL)
|
||||
*
|
||||
* @access private
|
||||
* @param integer $iStBlk
|
||||
* @param array &$raList Reference to array of PPS's
|
||||
*/
|
||||
* Saving big data (PPS's with data bigger than OLE_DATA_SIZE_SMALL)
|
||||
*
|
||||
* @access private
|
||||
* @param integer $iStBlk
|
||||
* @param array &$raList Reference to array of PPS's
|
||||
*/
|
||||
function _saveBigData($iStBlk, &$raList)
|
||||
{
|
||||
$FILE = $this->_FILEH_;
|
||||
|
||||
|
||||
// cycle through PPS's
|
||||
for ($i = 0; $i < count($raList); $i++)
|
||||
{
|
||||
@@ -295,7 +295,7 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
{
|
||||
$raList[$i]->Size = $raList[$i]->_DataLen();
|
||||
if(($raList[$i]->Size >= OLE_DATA_SIZE_SMALL) or
|
||||
(($raList[$i]->Type == OLE_PPS_TYPE_ROOT) and isset($raList[$i]->_data)))
|
||||
(($raList[$i]->Type == OLE_PPS_TYPE_ROOT) and isset($raList[$i]->_data)))
|
||||
{
|
||||
// Write Data
|
||||
if(isset($raList[$i]->_PPS_FILE))
|
||||
@@ -311,7 +311,7 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
else {
|
||||
fwrite($FILE, $raList[$i]->_data);
|
||||
}
|
||||
|
||||
|
||||
if ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)
|
||||
{
|
||||
for ($j = 0; $j < ($this->_BIG_BLOCK_SIZE - ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)); $j++) {
|
||||
@@ -320,9 +320,9 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
}
|
||||
// Set For PPS
|
||||
$raList[$i]->_StartBlock = $iStBlk;
|
||||
$iStBlk +=
|
||||
(floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
|
||||
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
|
||||
$iStBlk +=
|
||||
(floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
|
||||
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
|
||||
}
|
||||
// Close file for each PPS, and unlink it
|
||||
if (isset($raList[$i]->_PPS_FILE))
|
||||
@@ -336,17 +336,17 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
}
|
||||
|
||||
/**
|
||||
* get small data (PPS's with data smaller than OLE_DATA_SIZE_SMALL)
|
||||
*
|
||||
* @access private
|
||||
* @param array &$raList Reference to array of PPS's
|
||||
*/
|
||||
* get small data (PPS's with data smaller than OLE_DATA_SIZE_SMALL)
|
||||
*
|
||||
* @access private
|
||||
* @param array &$raList Reference to array of PPS's
|
||||
*/
|
||||
function _makeSmallData(&$raList)
|
||||
{
|
||||
$sRes = '';
|
||||
$FILE = $this->_FILEH_;
|
||||
$iSmBlk = 0;
|
||||
|
||||
|
||||
for ($i = 0; $i < count($raList); $i++)
|
||||
{
|
||||
// Make SBD, small data string
|
||||
@@ -358,13 +358,13 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
if ($raList[$i]->Size < OLE_DATA_SIZE_SMALL)
|
||||
{
|
||||
$iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
|
||||
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
|
||||
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
|
||||
// Add to SBD
|
||||
for ($j = 0; $j < ($iSmbCnt-1); $j++) {
|
||||
fwrite($FILE, pack("V", $j+$iSmBlk+1));
|
||||
}
|
||||
fwrite($FILE, pack("V", -2));
|
||||
|
||||
|
||||
// Add to Data String(this will be written for RootEntry)
|
||||
if ($raList[$i]->_PPS_FILE)
|
||||
{
|
||||
@@ -399,12 +399,12 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves all the PPS's WKs
|
||||
*
|
||||
* @access private
|
||||
* @param array $raList Reference to an array with all PPS's
|
||||
*/
|
||||
function _savePps(&$raList)
|
||||
* Saves all the PPS's WKs
|
||||
*
|
||||
* @access private
|
||||
* @param array $raList Reference to an array with all PPS's
|
||||
*/
|
||||
function _savePps(&$raList)
|
||||
{
|
||||
// Save each PPS WK
|
||||
for ($i = 0; $i < count($raList); $i++) {
|
||||
@@ -422,20 +422,20 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
}
|
||||
|
||||
/**
|
||||
* Saving Big Block Depot
|
||||
*
|
||||
* @access private
|
||||
* @param integer $iSbdSize
|
||||
* @param integer $iBsize
|
||||
* @param integer $iPpsCnt
|
||||
*/
|
||||
function _saveBbd($iSbdSize, $iBsize, $iPpsCnt)
|
||||
* Saving Big Block Depot
|
||||
*
|
||||
* @access private
|
||||
* @param integer $iSbdSize
|
||||
* @param integer $iBsize
|
||||
* @param integer $iPpsCnt
|
||||
*/
|
||||
function _saveBbd($iSbdSize, $iBsize, $iPpsCnt)
|
||||
{
|
||||
$FILE = $this->_FILEH_;
|
||||
// Calculate Basic Setting
|
||||
$iBbCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE;
|
||||
$i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE;
|
||||
|
||||
|
||||
$iBdExL = 0;
|
||||
$iAll = $iBsize + $iPpsCnt + $iSbdSize;
|
||||
$iAllW = $iAll;
|
||||
@@ -455,7 +455,7 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Making BD
|
||||
// Set for SBD
|
||||
if ($iSbdSize > 0)
|
||||
@@ -470,7 +470,7 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
fwrite($FILE, pack("V", $i+$iSbdSize+1));
|
||||
}
|
||||
fwrite($FILE, pack("V", -2));
|
||||
|
||||
|
||||
// Set for PPS
|
||||
for ($i = 0; $i<($iPpsCnt-1); $i++) {
|
||||
fwrite($FILE, pack("V", $i+$iSbdSize+$iBsize+1));
|
||||
@@ -509,7 +509,7 @@ class OLE_PPS_Root extends OLE_PPS
|
||||
if (($iBdCnt-$i1stBdL) % ($iBbCnt-1))
|
||||
{
|
||||
for ($i = 0; $i < (($iBbCnt-1) - (($iBdCnt-$i1stBdL) % ($iBbCnt-1))); $i++) {
|
||||
fwrite($FILE, pack("V", -1));
|
||||
fwrite($FILE, pack("V", -1));
|
||||
}
|
||||
}
|
||||
fwrite($FILE, pack("V", -2));
|
||||
|
||||
@@ -40,7 +40,7 @@ define('PEAR_ERROR_CALLBACK', 16);
|
||||
define('PEAR_ERROR_EXCEPTION', 32);
|
||||
/**#@-*/
|
||||
define('PEAR_ZE2', (function_exists('version_compare') &&
|
||||
version_compare(zend_version(), "2-dev", "ge")));
|
||||
version_compare(zend_version(), "2-dev", "ge")));
|
||||
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||
define('OS_WINDOWS', true);
|
||||
@@ -216,17 +216,17 @@ class PEAR
|
||||
// {{{ getStaticProperty()
|
||||
|
||||
/**
|
||||
* If you have a class that's mostly/entirely static, and you need static
|
||||
* properties, you can use this method to simulate them. Eg. in your method(s)
|
||||
* do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
|
||||
* You MUST use a reference, or they will not persist!
|
||||
*
|
||||
* @access public
|
||||
* @param string $class The calling classname, to prevent clashes
|
||||
* @param string $var The variable to retrieve.
|
||||
* @return mixed A reference to the variable. If not set it will be
|
||||
* auto initialised to NULL.
|
||||
*/
|
||||
* If you have a class that's mostly/entirely static, and you need static
|
||||
* properties, you can use this method to simulate them. Eg. in your method(s)
|
||||
* do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
|
||||
* You MUST use a reference, or they will not persist!
|
||||
*
|
||||
* @access public
|
||||
* @param string $class The calling classname, to prevent clashes
|
||||
* @param string $var The variable to retrieve.
|
||||
* @return mixed A reference to the variable. If not set it will be
|
||||
* auto initialised to NULL.
|
||||
*/
|
||||
function &getStaticProperty($class, $var)
|
||||
{
|
||||
static $properties;
|
||||
@@ -237,14 +237,14 @@ class PEAR
|
||||
// {{{ registerShutdownFunc()
|
||||
|
||||
/**
|
||||
* Use this function to register a shutdown method for static
|
||||
* classes.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $func The function name (or array of class/method) to call
|
||||
* @param mixed $args The arguments to pass to the function
|
||||
* @return void
|
||||
*/
|
||||
* Use this function to register a shutdown method for static
|
||||
* classes.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $func The function name (or array of class/method) to call
|
||||
* @param mixed $args The arguments to pass to the function
|
||||
* @return void
|
||||
*/
|
||||
function registerShutdownFunc($func, $args = array())
|
||||
{
|
||||
$GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
|
||||
@@ -263,7 +263,7 @@ class PEAR
|
||||
* $code is an integer and $obj->getCode() == $code
|
||||
* @access public
|
||||
* @return bool true if parameter is an error
|
||||
*/
|
||||
*/
|
||||
function isError($data, $code = null)
|
||||
{
|
||||
if ($data instanceof PEAR_Error) {
|
||||
@@ -510,12 +510,12 @@ class PEAR
|
||||
* @since PHP 4.0.5
|
||||
*/
|
||||
function &raiseError($message = null,
|
||||
$code = null,
|
||||
$mode = null,
|
||||
$options = null,
|
||||
$userinfo = null,
|
||||
$error_class = null,
|
||||
$skipmsg = false)
|
||||
$code = null,
|
||||
$mode = null,
|
||||
$options = null,
|
||||
$userinfo = null,
|
||||
$error_class = null,
|
||||
$skipmsg = false)
|
||||
{
|
||||
// The error is yet a PEAR error object
|
||||
if (is_object($message)) {
|
||||
@@ -528,8 +528,8 @@ class PEAR
|
||||
|
||||
if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
|
||||
if ($exp[0] == "*" ||
|
||||
(is_int(reset($exp)) && in_array($code, $exp)) ||
|
||||
(is_string(reset($exp)) && in_array($message, $exp))) {
|
||||
(is_int(reset($exp)) && in_array($code, $exp)) ||
|
||||
(is_string(reset($exp)) && in_array($message, $exp))) {
|
||||
$mode = PEAR_ERROR_RETURN;
|
||||
}
|
||||
}
|
||||
@@ -539,7 +539,7 @@ class PEAR
|
||||
if (isset($this) && isset($this->_default_error_mode)) {
|
||||
$mode = $this->_default_error_mode;
|
||||
$options = $this->_default_error_options;
|
||||
// Global error handler
|
||||
// Global error handler
|
||||
} elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
|
||||
$mode = $GLOBALS['_PEAR_default_error_mode'];
|
||||
$options = $GLOBALS['_PEAR_default_error_options'];
|
||||
@@ -573,8 +573,8 @@ class PEAR
|
||||
*
|
||||
*/
|
||||
function &throwError($message = null,
|
||||
$code = null,
|
||||
$userinfo = null)
|
||||
$code = null,
|
||||
$userinfo = null)
|
||||
{
|
||||
if (isset($this) && is_a($this, 'PEAR')) {
|
||||
$a = &$this->raiseError($message, $code, null, null, $userinfo);
|
||||
@@ -696,12 +696,12 @@ class PEAR
|
||||
// {{{ popErrorHandling()
|
||||
|
||||
/**
|
||||
* Pop the last error handler used
|
||||
*
|
||||
* @return bool Always true
|
||||
*
|
||||
* @see PEAR::pushErrorHandling
|
||||
*/
|
||||
* Pop the last error handler used
|
||||
*
|
||||
* @return bool Always true
|
||||
*
|
||||
* @see PEAR::pushErrorHandling
|
||||
*/
|
||||
function popErrorHandling()
|
||||
{
|
||||
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
|
||||
@@ -720,12 +720,12 @@ class PEAR
|
||||
// {{{ loadExtension()
|
||||
|
||||
/**
|
||||
* OS independant PHP extension load. Remember to take care
|
||||
* on the correct extension name for case sensitive OSes.
|
||||
*
|
||||
* @param string $ext The extension name
|
||||
* @return bool Success or not on the dl() call
|
||||
*/
|
||||
* OS independant PHP extension load. Remember to take care
|
||||
* on the correct extension name for case sensitive OSes.
|
||||
*
|
||||
* @param string $ext The extension name
|
||||
* @return bool Success or not on the dl() call
|
||||
*/
|
||||
function loadExtension($ext)
|
||||
{
|
||||
if (!extension_loaded($ext)) {
|
||||
@@ -758,7 +758,7 @@ function _PEAR_call_destructors()
|
||||
{
|
||||
global $_PEAR_destructor_object_list;
|
||||
if (is_array($_PEAR_destructor_object_list) &&
|
||||
sizeof($_PEAR_destructor_object_list))
|
||||
sizeof($_PEAR_destructor_object_list))
|
||||
{
|
||||
reset($_PEAR_destructor_object_list);
|
||||
if (@PEAR::getStaticProperty('PEAR', 'destructlifo')) {
|
||||
@@ -843,7 +843,7 @@ class PEAR_Error
|
||||
*
|
||||
*/
|
||||
function PEAR_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
if ($mode === null) {
|
||||
$mode = PEAR_ERROR_RETURN;
|
||||
@@ -952,10 +952,10 @@ class PEAR_Error
|
||||
* @return int error code
|
||||
* @access public
|
||||
*/
|
||||
function getCode()
|
||||
{
|
||||
function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getType()
|
||||
@@ -1045,22 +1045,22 @@ class PEAR_Error
|
||||
function toString() {
|
||||
$modes = array();
|
||||
$levels = array(E_USER_NOTICE => 'notice',
|
||||
E_USER_WARNING => 'warning',
|
||||
E_USER_ERROR => 'error');
|
||||
E_USER_WARNING => 'warning',
|
||||
E_USER_ERROR => 'error');
|
||||
if ($this->mode & PEAR_ERROR_CALLBACK) {
|
||||
if (is_array($this->callback)) {
|
||||
$callback = (is_object($this->callback[0]) ?
|
||||
strtolower(get_class($this->callback[0])) :
|
||||
$this->callback[0]) . '::' .
|
||||
$this->callback[1];
|
||||
strtolower(get_class($this->callback[0])) :
|
||||
$this->callback[0]) . '::' .
|
||||
$this->callback[1];
|
||||
} else {
|
||||
$callback = $this->callback;
|
||||
}
|
||||
return sprintf('[%s: message="%s" code=%d mode=callback '.
|
||||
'callback=%s prefix="%s" info="%s"]',
|
||||
strtolower(get_class($this)), $this->message, $this->code,
|
||||
$callback, $this->error_message_prefix,
|
||||
$this->userinfo);
|
||||
strtolower(get_class($this)), $this->message, $this->code,
|
||||
$callback, $this->error_message_prefix,
|
||||
$this->userinfo);
|
||||
}
|
||||
if ($this->mode & PEAR_ERROR_PRINT) {
|
||||
$modes[] = 'print';
|
||||
@@ -1076,10 +1076,10 @@ class PEAR_Error
|
||||
}
|
||||
return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
|
||||
'prefix="%s" info="%s"]',
|
||||
strtolower(get_class($this)), $this->message, $this->code,
|
||||
implode("|", $modes), $levels[$this->level],
|
||||
$this->error_message_prefix,
|
||||
$this->userinfo);
|
||||
strtolower(get_class($this)), $this->message, $this->code,
|
||||
implode("|", $modes), $levels[$this->level],
|
||||
$this->error_message_prefix,
|
||||
$this->userinfo);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
<?php
|
||||
/*
|
||||
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
|
||||
*
|
||||
* PERL Spreadsheet::WriteExcel module.
|
||||
*
|
||||
* The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
* <jmcnamara@cpan.org>
|
||||
*
|
||||
* I _DO_ maintain this code, and John McNamara has nothing to do with the
|
||||
* porting of this code to PHP. Any questions directly related to this
|
||||
* class library should be directed to me.
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
|
||||
*
|
||||
* PERL Spreadsheet::WriteExcel module.
|
||||
*
|
||||
* The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
* <jmcnamara@cpan.org>
|
||||
*
|
||||
* I _DO_ maintain this code, and John McNamara has nothing to do with the
|
||||
* porting of this code to PHP. Any questions directly related to this
|
||||
* class library should be directed to me.
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}
|
||||
require_once $homedir.'/classes/pear/PEAR.php';
|
||||
require_once $homedir.'/classes/pear/Spreadsheet/Excel/Writer/Workbook.php';
|
||||
|
||||
/**
|
||||
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@rezebra.com>
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@rezebra.com>
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
|
||||
class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
|
||||
{
|
||||
/**
|
||||
* The constructor. It just creates a Workbook
|
||||
*
|
||||
* @param string $filename The optional filename for the Workbook.
|
||||
* @return Spreadsheet_Excel_Writer_Workbook The Workbook created
|
||||
*/
|
||||
* The constructor. It just creates a Workbook
|
||||
*
|
||||
* @param string $filename The optional filename for the Workbook.
|
||||
* @return Spreadsheet_Excel_Writer_Workbook The Workbook created
|
||||
*/
|
||||
function Spreadsheet_Excel_Writer($filename = '')
|
||||
{
|
||||
$this->_filename = $filename;
|
||||
@@ -58,11 +58,11 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
|
||||
}
|
||||
|
||||
/**
|
||||
* Send HTTP headers for the Excel file.
|
||||
*
|
||||
* @param string $filename The filename to use for HTTP headers
|
||||
* @access public
|
||||
*/
|
||||
* Send HTTP headers for the Excel file.
|
||||
*
|
||||
* @param string $filename The filename to use for HTTP headers
|
||||
* @access public
|
||||
*/
|
||||
function send($filename)
|
||||
{
|
||||
header("Content-type: application/vnd.ms-excel");
|
||||
@@ -73,15 +73,15 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for writing formulas
|
||||
* Converts a cell's coordinates to the A1 format.
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param integer $row Row for the cell to convert (0-indexed).
|
||||
* @param integer $col Column for the cell to convert (0-indexed).
|
||||
* @return string The cell identifier in A1 format
|
||||
*/
|
||||
* Utility function for writing formulas
|
||||
* Converts a cell's coordinates to the A1 format.
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param integer $row Row for the cell to convert (0-indexed).
|
||||
* @param integer $col Column for the cell to convert (0-indexed).
|
||||
* @return string The cell identifier in A1 format
|
||||
*/
|
||||
function rowcolToCell($row, $col)
|
||||
{
|
||||
if ($col > 255) { //maximum column value exceeded
|
||||
|
||||
@@ -1,95 +1,95 @@
|
||||
<?php
|
||||
/*
|
||||
* Module written/ported by Xavier Noguer <xnoguer@php.net>
|
||||
*
|
||||
* The majority of this is _NOT_ my code. I simply ported it from the
|
||||
* PERL Spreadsheet::WriteExcel module.
|
||||
*
|
||||
* The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
* <jmcnamara@cpan.org>
|
||||
*
|
||||
* I _DO_ maintain this code, and John McNamara has nothing to do with the
|
||||
* porting of this code to PHP. Any questions directly related to this
|
||||
* class library should be directed to me.
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@php.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
* Module written/ported by Xavier Noguer <xnoguer@php.net>
|
||||
*
|
||||
* The majority of this is _NOT_ my code. I simply ported it from the
|
||||
* PERL Spreadsheet::WriteExcel module.
|
||||
*
|
||||
* The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
* <jmcnamara@cpan.org>
|
||||
*
|
||||
* I _DO_ maintain this code, and John McNamara has nothing to do with the
|
||||
* porting of this code to PHP. Any questions directly related to this
|
||||
* class library should be directed to me.
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@php.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}
|
||||
require_once $homedir.'/classes/pear/PEAR.php';
|
||||
|
||||
/**
|
||||
* Class for writing Excel BIFF records.
|
||||
*
|
||||
* From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation):
|
||||
*
|
||||
* BIFF (BInary File Format) is the file format in which Excel documents are
|
||||
* saved on disk. A BIFF file is a complete description of an Excel document.
|
||||
* BIFF files consist of sequences of variable-length records. There are many
|
||||
* different types of BIFF records. For example, one record type describes a
|
||||
* formula entered into a cell; one describes the size and location of a
|
||||
* window into a document; another describes a picture format.
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
* Class for writing Excel BIFF records.
|
||||
*
|
||||
* From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation):
|
||||
*
|
||||
* BIFF (BInary File Format) is the file format in which Excel documents are
|
||||
* saved on disk. A BIFF file is a complete description of an Excel document.
|
||||
* BIFF files consist of sequences of variable-length records. There are many
|
||||
* different types of BIFF records. For example, one record type describes a
|
||||
* formula entered into a cell; one describes the size and location of a
|
||||
* window into a document; another describes a picture format.
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
|
||||
class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||
{
|
||||
/**
|
||||
* The BIFF/Excel version (5).
|
||||
* @var integer
|
||||
*/
|
||||
* The BIFF/Excel version (5).
|
||||
* @var integer
|
||||
*/
|
||||
var $_BIFF_version = 0x0500;
|
||||
|
||||
/**
|
||||
* The byte order of this architecture. 0 => little endian, 1 => big endian
|
||||
* @var integer
|
||||
*/
|
||||
* The byte order of this architecture. 0 => little endian, 1 => big endian
|
||||
* @var integer
|
||||
*/
|
||||
var $_byte_order;
|
||||
|
||||
/**
|
||||
* The string containing the data of the BIFF stream
|
||||
* @var string
|
||||
*/
|
||||
* The string containing the data of the BIFF stream
|
||||
* @var string
|
||||
*/
|
||||
var $_data;
|
||||
|
||||
/**
|
||||
* The size of the data in bytes. Should be the same as strlen($this->_data)
|
||||
* @var integer
|
||||
*/
|
||||
* The size of the data in bytes. Should be the same as strlen($this->_data)
|
||||
* @var integer
|
||||
*/
|
||||
var $_datasize;
|
||||
|
||||
/**
|
||||
* The maximun length for a BIFF record. See _addContinue()
|
||||
* @var integer
|
||||
* @see _addContinue()
|
||||
*/
|
||||
* The maximun length for a BIFF record. See _addContinue()
|
||||
* @var integer
|
||||
* @see _addContinue()
|
||||
*/
|
||||
var $_limit;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function Spreadsheet_Excel_Writer_BIFFwriter()
|
||||
{
|
||||
$this->_byte_order = '';
|
||||
@@ -101,11 +101,11 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the byte order and store it as class data to avoid
|
||||
* recalculating it for each call to new().
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
* Determine the byte order and store it as class data to avoid
|
||||
* recalculating it for each call to new().
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _setByteOrder()
|
||||
{
|
||||
// Check if "pack" gives the required IEEE 64bit float
|
||||
@@ -124,11 +124,11 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* General storage function
|
||||
*
|
||||
* @param string $data binary data to prepend
|
||||
* @access private
|
||||
*/
|
||||
* General storage function
|
||||
*
|
||||
* @param string $data binary data to prepend
|
||||
* @access private
|
||||
*/
|
||||
function _prepend($data)
|
||||
{
|
||||
if (strlen($data) > $this->_limit) {
|
||||
@@ -139,11 +139,11 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* General storage function
|
||||
*
|
||||
* @param string $data binary data to append
|
||||
* @access private
|
||||
*/
|
||||
* General storage function
|
||||
*
|
||||
* @param string $data binary data to append
|
||||
* @access private
|
||||
*/
|
||||
function _append($data)
|
||||
{
|
||||
if (strlen($data) > $this->_limit) {
|
||||
@@ -154,13 +154,13 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Excel BOF record to indicate the beginning of a stream or
|
||||
* sub-stream in the BIFF file.
|
||||
*
|
||||
* @param integer $type Type of BIFF file to write: 0x0005 Workbook,
|
||||
* 0x0010 Worksheet.
|
||||
* @access private
|
||||
*/
|
||||
* Writes Excel BOF record to indicate the beginning of a stream or
|
||||
* sub-stream in the BIFF file.
|
||||
*
|
||||
* @param integer $type Type of BIFF file to write: 0x0005 Workbook,
|
||||
* 0x0010 Worksheet.
|
||||
* @access private
|
||||
*/
|
||||
function _storeBof($type)
|
||||
{
|
||||
$record = 0x0809; // Record identifier
|
||||
@@ -186,10 +186,10 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Excel EOF record to indicate the end of a BIFF stream.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
* Writes Excel EOF record to indicate the end of a BIFF stream.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _storeEof()
|
||||
{
|
||||
$record = 0x000A; // Record identifier
|
||||
@@ -199,17 +199,17 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
|
||||
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits
|
||||
* must be split up into CONTINUE blocks.
|
||||
*
|
||||
* This function takes a long BIFF record and inserts CONTINUE records as
|
||||
* necessary.
|
||||
*
|
||||
* @param string $data The original binary data to be written
|
||||
* @return string A very convenient string of continue blocks
|
||||
* @access private
|
||||
*/
|
||||
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
|
||||
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits
|
||||
* must be split up into CONTINUE blocks.
|
||||
*
|
||||
* This function takes a long BIFF record and inserts CONTINUE records as
|
||||
* necessary.
|
||||
*
|
||||
* @param string $data The original binary data to be written
|
||||
* @return string A very convenient string of continue blocks
|
||||
* @access private
|
||||
*/
|
||||
function _addContinue($data)
|
||||
{
|
||||
$limit = $this->_limit;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,26 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
* Module written by Herman Kuiper <herman@ozuzo.net>
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
* Module written by Herman Kuiper <herman@ozuzo.net>
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
//require_once('PEAR.php');
|
||||
|
||||
@@ -39,32 +39,32 @@ define("OP_GTE", 0x06);
|
||||
define("OP_LTE", 0x07);
|
||||
|
||||
/**
|
||||
* Baseclass for generating Excel DV records (validations)
|
||||
*
|
||||
* @author Herman Kuiper
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
* Baseclass for generating Excel DV records (validations)
|
||||
*
|
||||
* @author Herman Kuiper
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
class Spreadsheet_Excel_Writer_Validator
|
||||
{
|
||||
var $_type;
|
||||
var $_style;
|
||||
var $_fixedList;
|
||||
var $_blank;
|
||||
var $_incell;
|
||||
var $_showprompt;
|
||||
var $_showerror;
|
||||
var $_title_prompt;
|
||||
var $_descr_prompt;
|
||||
var $_title_error;
|
||||
var $_descr_error;
|
||||
var $_operator;
|
||||
var $_formula1;
|
||||
var $_formula2;
|
||||
var $_type;
|
||||
var $_style;
|
||||
var $_fixedList;
|
||||
var $_blank;
|
||||
var $_incell;
|
||||
var $_showprompt;
|
||||
var $_showerror;
|
||||
var $_title_prompt;
|
||||
var $_descr_prompt;
|
||||
var $_title_error;
|
||||
var $_descr_error;
|
||||
var $_operator;
|
||||
var $_formula1;
|
||||
var $_formula2;
|
||||
/**
|
||||
* The parser from the workbook. Used to parse validation formulas also
|
||||
* @var Spreadsheet_Excel_Writer_Parser
|
||||
*/
|
||||
* The parser from the workbook. Used to parse validation formulas also
|
||||
* @var Spreadsheet_Excel_Writer_Parser
|
||||
*/
|
||||
var $_parser;
|
||||
|
||||
function Spreadsheet_Excel_Writer_Validator(&$parser)
|
||||
@@ -86,29 +86,29 @@ class Spreadsheet_Excel_Writer_Validator
|
||||
$this->_formula2 = '';
|
||||
}
|
||||
|
||||
function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true)
|
||||
{
|
||||
$this->_showprompt = $showPrompt;
|
||||
$this->_title_prompt = $promptTitle;
|
||||
$this->_descr_prompt = $promptDescription;
|
||||
}
|
||||
function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true)
|
||||
{
|
||||
$this->_showprompt = $showPrompt;
|
||||
$this->_title_prompt = $promptTitle;
|
||||
$this->_descr_prompt = $promptDescription;
|
||||
}
|
||||
|
||||
function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true)
|
||||
{
|
||||
$this->_showerror = $showError;
|
||||
$this->_title_error = $errorTitle;
|
||||
$this->_descr_error = $errorDescription;
|
||||
}
|
||||
function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true)
|
||||
{
|
||||
$this->_showerror = $showError;
|
||||
$this->_title_error = $errorTitle;
|
||||
$this->_descr_error = $errorDescription;
|
||||
}
|
||||
|
||||
function allowBlank()
|
||||
{
|
||||
$this->_blank = true;
|
||||
}
|
||||
function allowBlank()
|
||||
{
|
||||
$this->_blank = true;
|
||||
}
|
||||
|
||||
function onInvalidStop()
|
||||
{
|
||||
$this->_style = 0x00;
|
||||
}
|
||||
function onInvalidStop()
|
||||
{
|
||||
$this->_style = 0x00;
|
||||
}
|
||||
|
||||
function onInvalidWarn()
|
||||
{
|
||||
@@ -169,62 +169,62 @@ class Spreadsheet_Excel_Writer_Validator
|
||||
if ($this->_showerror) {
|
||||
$options |= 0x80000;
|
||||
}
|
||||
$options |= $this->_operator << 20;
|
||||
$options |= $this->_operator << 20;
|
||||
|
||||
return $options;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
function _getData()
|
||||
{
|
||||
$title_prompt_len = strlen($this->_title_prompt);
|
||||
$descr_prompt_len = strlen($this->_descr_prompt);
|
||||
$title_error_len = strlen($this->_title_error);
|
||||
$descr_error_len = strlen($this->_descr_error);
|
||||
function _getData()
|
||||
{
|
||||
$title_prompt_len = strlen($this->_title_prompt);
|
||||
$descr_prompt_len = strlen($this->_descr_prompt);
|
||||
$title_error_len = strlen($this->_title_error);
|
||||
$descr_error_len = strlen($this->_descr_error);
|
||||
|
||||
$formula1_size = strlen($this->_formula1);
|
||||
$formula2_size = strlen($this->_formula2);
|
||||
$formula1_size = strlen($this->_formula1);
|
||||
$formula2_size = strlen($this->_formula2);
|
||||
|
||||
$data = pack("V", $this->_getOptions());
|
||||
$data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt;
|
||||
$data .= pack("vC", $title_error_len, 0x00) . $this->_title_error;
|
||||
$data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt;
|
||||
$data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error;
|
||||
$data = pack("V", $this->_getOptions());
|
||||
$data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt;
|
||||
$data .= pack("vC", $title_error_len, 0x00) . $this->_title_error;
|
||||
$data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt;
|
||||
$data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error;
|
||||
|
||||
$data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1;
|
||||
$data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2;
|
||||
$data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1;
|
||||
$data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2;
|
||||
|
||||
return $data;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation
|
||||
{
|
||||
function Spreadsheet_Excel_Writer_Validation_list()
|
||||
{
|
||||
parent::Spreadsheet_Excel_Writer_Validation();
|
||||
$this->_type = 0x03;
|
||||
}
|
||||
{
|
||||
function Spreadsheet_Excel_Writer_Validation_list()
|
||||
{
|
||||
parent::Spreadsheet_Excel_Writer_Validation();
|
||||
$this->_type = 0x03;
|
||||
}
|
||||
|
||||
function setList($source, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
$this->_fixedList = true;
|
||||
function setList($source, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
$this->_fixedList = true;
|
||||
|
||||
$source = implode("\x00", $source);
|
||||
$this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source;
|
||||
}
|
||||
$source = implode("\x00", $source);
|
||||
$this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source;
|
||||
}
|
||||
|
||||
function setRow($row, $col1, $col2, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
//$this->_formula1 = ...;
|
||||
}
|
||||
function setRow($row, $col1, $col2, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
//$this->_formula1 = ...;
|
||||
}
|
||||
|
||||
function setCol($col, $row1, $row2, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
//$this->_formula1 = ...;
|
||||
}
|
||||
}*/
|
||||
function setCol($col, $row1, $row2, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
//$this->_formula1 = ...;
|
||||
}
|
||||
}*/
|
||||
|
||||
?>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user