添加到 trunk

+YUCHENG HU+

git-svn-id: https://svn.code.sf.net/p/hawebs/svn@355 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
YuCheng Hu
2010-06-17 19:23:53 +00:00
parent 9a7141047d
commit 9584fe092f
654 changed files with 5047462 additions and 414 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,200 @@
<?php
/*
* Project: MagpieRSS: a simple RSS integration tool
* File: rss_cache.inc, a simple, rolling(no GC), cache
* for RSS objects, keyed on URL.
* Author: Kellan Elliott-McCrea <[email protected]>
* Version: 0.51
* License: GPL
*
* The lastest version of MagpieRSS can be obtained from:
* http://magpierss.sourceforge.net
*
* For questions, help, comments, discussion, etc., please join the
* Magpie mailing list:
* http://lists.sourceforge.net/lists/listinfo/magpierss-general
*
*/
class RSSCache {
var $BASE_CACHE = './cache'; // where the cache files are stored
var $MAX_AGE = 3600; // when are files stale, default one hour
var $ERROR = ""; // accumulate error messages
function RSSCache ($base='', $age='') {
if ( $base ) {
$this->BASE_CACHE = $base;
}
if ( $age ) {
$this->MAX_AGE = $age;
}
// attempt to make the cache directory
if ( ! file_exists( $this->BASE_CACHE ) ) {
$status = @mkdir( $this->BASE_CACHE, 0755 );
// if make failed
if ( ! $status ) {
$this->error(
"Cache couldn't make dir '" . $this->BASE_CACHE . "'."
);
}
}
}
/*=======================================================================*\
Function: set
Purpose: add an item to the cache, keyed on url
Input: url from wich the rss file was fetched
Output: true on sucess
\*=======================================================================*/
function set ($url, $rss) {
$this->ERROR = "";
$cache_file = $this->file_name( $url );
$fp = @fopen( $cache_file, 'w' );
if ( ! $fp ) {
$this->error(
"Cache unable to open file for writing: $cache_file"
);
return 0;
}
$data = $this->serialize( $rss );
fwrite( $fp, $data );
fclose( $fp );
return $cache_file;
}
/*=======================================================================*\
Function: get
Purpose: fetch an item from the cache
Input: url from wich the rss file was fetched
Output: cached object on HIT, false on MISS
\*=======================================================================*/
function get ($url) {
$this->ERROR = "";
$cache_file = $this->file_name( $url );
if ( ! file_exists( $cache_file ) ) {
$this->debug(
"Cache doesn't contain: $url (cache file: $cache_file)"
);
return 0;
}
$fp = @fopen($cache_file, 'r');
if ( ! $fp ) {
$this->error(
"Failed to open cache file for reading: $cache_file"
);
return 0;
}
if ($filesize = filesize($cache_file) ) {
$data = fread( $fp, filesize($cache_file) );
$rss = $this->unserialize( $data );
return $rss;
}
return 0;
}
/*=======================================================================*\
Function: check_cache
Purpose: check a url for membership in the cache
and whether the object is older then MAX_AGE (ie. STALE)
Input: url from wich the rss file was fetched
Output: cached object on HIT, false on MISS
\*=======================================================================*/
function check_cache ( $url ) {
$this->ERROR = "";
$filename = $this->file_name( $url );
if ( file_exists( $filename ) ) {
// find how long ago the file was added to the cache
// and whether that is longer then MAX_AGE
$mtime = filemtime( $filename );
$age = time() - $mtime;
if ( $this->MAX_AGE > $age ) {
// object exists and is current
return 'HIT';
}
else {
// object exists but is old
return 'STALE';
}
}
else {
// object does not exist
return 'MISS';
}
}
function cache_age( $cache_key ) {
$filename = $this->file_name( $url );
if ( file_exists( $filename ) ) {
$mtime = filemtime( $filename );
$age = time() - $mtime;
return $age;
}
else {
return -1;
}
}
/*=======================================================================*\
Function: serialize
\*=======================================================================*/
function serialize ( $rss ) {
return serialize( $rss );
}
/*=======================================================================*\
Function: unserialize
\*=======================================================================*/
function unserialize ( $data ) {
return unserialize( $data );
}
/*=======================================================================*\
Function: file_name
Purpose: map url to location in cache
Input: url from wich the rss file was fetched
Output: a file name
\*=======================================================================*/
function file_name ($url) {
$filename = md5( $url );
return join( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) );
}
/*=======================================================================*\
Function: error
Purpose: register error
\*=======================================================================*/
function error ($errormsg, $lvl=E_USER_WARNING) {
// append PHP's error message if track_errors enabled
if ( isset($php_errormsg) ) {
$errormsg .= " ($php_errormsg)";
}
$this->ERROR = $errormsg;
if ( MAGPIE_DEBUG ) {
trigger_error( $errormsg, $lvl);
}
else {
error_log( $errormsg, 0);
}
}
function debug ($debugmsg, $lvl=E_USER_NOTICE) {
if ( MAGPIE_DEBUG ) {
$this->error("MagpieRSS [debug] $debugmsg", $lvl);
}
}
}
?>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,67 @@
<?php
/*
* Project: MagpieRSS: a simple RSS integration tool
* File: rss_utils.inc, utility methods for working with RSS
* Author: Kellan Elliott-McCrea <[email protected]>
* Version: 0.51
* License: GPL
*
* The lastest version of MagpieRSS can be obtained from:
* http://magpierss.sourceforge.net
*
* For questions, help, comments, discussion, etc., please join the
* Magpie mailing list:
* [email protected]
*/
/*======================================================================*\
Function: parse_w3cdtf
Purpose: parse a W3CDTF date into unix epoch
NOTE: http://www.w3.org/TR/NOTE-datetime
\*======================================================================*/
function parse_w3cdtf ( $date_str ) {
# regex to match wc3dtf
$pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
if ( preg_match( $pat, $date_str, $match ) ) {
list( $year, $month, $day, $hours, $minutes, $seconds) =
array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
# calc epoch for current date assuming GMT
$epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
$offset = 0;
if ( $match[10] == 'Z' ) {
# zulu time, aka GMT
}
else {
list( $tz_mod, $tz_hour, $tz_min ) =
array( $match[8], $match[9], $match[10]);
# zero out the variables
if ( ! $tz_hour ) { $tz_hour = 0; }
if ( ! $tz_min ) { $tz_min = 0; }
$offset_secs = (($tz_hour*60)+$tz_min)*60;
# is timezone ahead of GMT? then subtract offset
#
if ( $tz_mod == '+' ) {
$offset_secs = $offset_secs * -1;
}
$offset = $offset_secs;
}
$epoch = $epoch + $offset;
return $epoch;
}
else {
return -1;
}
}
?>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,86 @@
<?php
/**
* Contains information for a SOAP fault.
* Mainly used for returning faults from deployed functions
* in a server instance.
* @author Dietrich Ayala <[email protected]>
* @version $Id: class.soap_fault.php,v 1.12 2005/07/27 19:24:42 snichol Exp $
* @access public
*/
class soap_fault extends nusoap_base {
/**
* The fault code (client|server)
* @var string
* @access private
*/
var $faultcode;
/**
* The fault actor
* @var string
* @access private
*/
var $faultactor;
/**
* The fault string, a description of the fault
* @var string
* @access private
*/
var $faultstring;
/**
* The fault detail, typically a string or array of string
* @var mixed
* @access private
*/
var $faultdetail;
/**
* constructor
*
* @param string $faultcode (client | server)
* @param string $faultactor only used when msg routed between multiple actors
* @param string $faultstring human readable error message
* @param mixed $faultdetail detail, typically a string or array of string
*/
function soap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
parent::nusoap_base();
$this->faultcode = $faultcode;
$this->faultactor = $faultactor;
$this->faultstring = $faultstring;
$this->faultdetail = $faultdetail;
}
/**
* serialize a fault
*
* @return string The serialization of the fault instance.
* @access public
*/
function serialize(){
$ns_string = '';
foreach($this->namespaces as $k => $v){
$ns_string .= "\n xmlns:$k=\"$v\"";
}
$return_msg =
'<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'.
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n".
'<SOAP-ENV:Body>'.
'<SOAP-ENV:Fault>'.
$this->serialize_val($this->faultcode, 'faultcode').
$this->serialize_val($this->faultactor, 'faultactor').
$this->serialize_val($this->faultstring, 'faultstring').
$this->serialize_val($this->faultdetail, 'detail').
'</SOAP-ENV:Fault>'.
'</SOAP-ENV:Body>'.
'</SOAP-ENV:Envelope>';
return $return_msg;
}
}
?>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,107 @@
<?php
/**
* For creating serializable abstractions of native PHP types. This class
* allows element name/namespace, XSD type, and XML attributes to be
* associated with a value. This is extremely useful when WSDL is not
* used, but is also useful when WSDL is used with polymorphic types, including
* xsd:anyType and user-defined types.
*
* @author Dietrich Ayala <[email protected]>
* @version $Id: class.soap_val.php,v 1.9 2005/07/27 19:24:42 snichol Exp $
* @access public
*/
class soapval extends nusoap_base {
/**
* The XML element name
*
* @var string
* @access private
*/
var $name;
/**
* The XML type name (string or false)
*
* @var mixed
* @access private
*/
var $type;
/**
* The PHP value
*
* @var mixed
* @access private
*/
var $value;
/**
* The XML element namespace (string or false)
*
* @var mixed
* @access private
*/
var $element_ns;
/**
* The XML type namespace (string or false)
*
* @var mixed
* @access private
*/
var $type_ns;
/**
* The XML element attributes (array or false)
*
* @var mixed
* @access private
*/
var $attributes;
/**
* constructor
*
* @param string $name optional name
* @param mixed $type optional type name
* @param mixed $value optional value
* @param mixed $element_ns optional namespace of value
* @param mixed $type_ns optional namespace of type
* @param mixed $attributes associative array of attributes to add to element serialization
* @access public
*/
function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
parent::nusoap_base();
$this->name = $name;
$this->type = $type;
$this->value = $value;
$this->element_ns = $element_ns;
$this->type_ns = $type_ns;
$this->attributes = $attributes;
}
/**
* return serialized value
*
* @param string $use The WSDL use value (encoded|literal)
* @return string XML data
* @access public
*/
function serialize($use='encoded') {
return $this->serialize_val($this->value,$this->name,$this->type,$this->element_ns,$this->type_ns,$this->attributes,$use);
}
/**
* decodes a soapval object into a PHP native type
*
* @return mixed
* @access public
*/
function decode(){
return $this->value;
}
}
?>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,184 @@
<?php
/**
* caches instances of the wsdl class
*
* @author Scott Nichol <[email protected]>
* @author Ingo Fischer <[email protected]>
* @version $Id: class.wsdlcache.php,v 1.5 2005/05/20 17:58:17 snichol Exp $
* @access public
*/
class wsdlcache {
/**
* @var resource
* @access private
*/
var $fplock;
/**
* @var integer
* @access private
*/
var $cache_lifetime;
/**
* @var string
* @access private
*/
var $cache_dir;
/**
* @var string
* @access public
*/
var $debug_str = '';
/**
* constructor
*
* @param string $cache_dir directory for cache-files
* @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
* @access public
*/
function wsdlcache($cache_dir='.', $cache_lifetime=0) {
$this->fplock = array();
$this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
$this->cache_lifetime = $cache_lifetime;
}
/**
* creates the filename used to cache a wsdl instance
*
* @param string $wsdl The URL of the wsdl instance
* @return string The filename used to cache the instance
* @access private
*/
function createFilename($wsdl) {
return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
}
/**
* adds debug data to the class level debug string
*
* @param string $string debug data
* @access private
*/
function debug($string){
$this->debug_str .= get_class($this).": $string\n";
}
/**
* gets a wsdl instance from the cache
*
* @param string $wsdl The URL of the wsdl instance
* @return object wsdl The cached wsdl instance, null if the instance is not in the cache
* @access public
*/
function get($wsdl) {
$filename = $this->createFilename($wsdl);
if ($this->obtainMutex($filename, "r")) {
// check for expired WSDL that must be removed from the cache
if ($this->cache_lifetime > 0) {
if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
unlink($filename);
$this->debug("Expired $wsdl ($filename) from cache");
$this->releaseMutex($filename);
return null;
}
}
// see what there is to return
$fp = @fopen($filename, "r");
if ($fp) {
$s = implode("", @file($filename));
fclose($fp);
$this->debug("Got $wsdl ($filename) from cache");
} else {
$s = null;
$this->debug("$wsdl ($filename) not in cache");
}
$this->releaseMutex($filename);
return (!is_null($s)) ? unserialize($s) : null;
} else {
$this->debug("Unable to obtain mutex for $filename in get");
}
return null;
}
/**
* obtains the local mutex
*
* @param string $filename The Filename of the Cache to lock
* @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode
* @return boolean Lock successfully obtained ?!
* @access private
*/
function obtainMutex($filename, $mode) {
if (isset($this->fplock[md5($filename)])) {
$this->debug("Lock for $filename already exists");
return false;
}
$this->fplock[md5($filename)] = fopen($filename.".lock", "w");
if ($mode == "r") {
return flock($this->fplock[md5($filename)], LOCK_SH);
} else {
return flock($this->fplock[md5($filename)], LOCK_EX);
}
}
/**
* adds a wsdl instance to the cache
*
* @param object wsdl $wsdl_instance The wsdl instance to add
* @return boolean WSDL successfully cached
* @access public
*/
function put($wsdl_instance) {
$filename = $this->createFilename($wsdl_instance->wsdl);
$s = serialize($wsdl_instance);
if ($this->obtainMutex($filename, "w")) {
$fp = fopen($filename, "w");
fputs($fp, $s);
fclose($fp);
$this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
$this->releaseMutex($filename);
return true;
} else {
$this->debug("Unable to obtain mutex for $filename in put");
}
return false;
}
/**
* releases the local mutex
*
* @param string $filename The Filename of the Cache to lock
* @return boolean Lock successfully released
* @access private
*/
function releaseMutex($filename) {
$ret = flock($this->fplock[md5($filename)], LOCK_UN);
fclose($this->fplock[md5($filename)]);
unset($this->fplock[md5($filename)]);
if (! $ret) {
$this->debug("Not able to release lock for $filename");
}
return $ret;
}
/**
* removes a wsdl instance from the cache
*
* @param string $wsdl The URL of the wsdl instance
* @return boolean Whether there was an instance to remove
* @access public
*/
function remove($wsdl) {
$filename = $this->createFilename($wsdl);
// ignore errors obtaining mutex
$this->obtainMutex($filename, "w");
$ret = unlink($filename);
$this->debug("Removed ($ret) $wsdl ($filename) from cache");
$this->releaseMutex($filename);
return $ret;
}
}
?>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,40 @@
<?PHP
require_once "Excel/class.writeexcel_workbook.inc.php";
require_once "Excel/class.writeexcel_worksheet.inc.php";
require_once "Excel/functions.writeexcel_utility.inc.php";
class Excel_Workbook extends writeexcel_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
*/
function Excel_Workbook($filename = '') {
$this->_filename = $filename;
$this->writeexcel_workbook($filename);
}
/**
* Send HTTP headers for the Excel file.
*
* @param string $filename The filename to use for HTTP headers
* @access public
*/
function send($filename) { // attachment
global $pref_lang;
$this->_tmpfilename = $filename;
/* if ($pref_lang == "ru") {
header ('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">');
} else {
header ('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">');
}
*/ header("Content-type: application/x-msexcel");
header("Content-Disposition: inline; filename=$filename");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
}
}
?>
@@ -0,0 +1,208 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This 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 software 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 software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, [email protected]
*/
class writeexcel_biffwriter {
var $byte_order;
var $BIFF_version;
var $_byte_order;
var $_data;
var $_datasize;
var $_limit;
/*
* Constructor
*/
function writeexcel_biffwriter() {
$this->byte_order = '';
$this->BIFF_version = 0x0500;
$this->_byte_order = '';
$this->_data = false;
$this->_datasize = 0;
$this->_limit = 2080;
$this->_set_byte_order();
}
/*
* Determine the byte order and store it as class data to avoid
* recalculating it for each call to new().
*/
function _set_byte_order() {
$this->byteorder=0;
// Check if "pack" gives the required IEEE 64bit float
$teststr = pack("d", 1.2345);
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
if ($number == $teststr) {
$this->byte_order = 0; // Little Endian
} elseif ($number == strrev($teststr)) {
$this->byte_order = 1; // Big Endian
} else {
// Give up
trigger_error("Required floating point format not supported ".
"on this platform. See the portability section ".
"of the documentation.", E_USER_ERROR);
}
$this->_byte_order = $this->byte_order;
}
/*
* General storage function
*/
function _prepend($data) {
if (func_num_args()>1) {
trigger_error("writeexcel_biffwriter::_prepend() ".
"called with more than one argument", E_USER_ERROR);
}
if ($this->_debug) {
print "*** writeexcel_biffwriter::_prepend() called:";
for ($c=0;$c<strlen($data);$c++) {
if ($c%16==0) {
print "\n";
}
printf("%02X ", ord($data[$c]));
}
print "\n";
}
if (strlen($data) > $this->_limit) {
$data = $this->_add_continue($data);
}
$this->_data = $data . $this->_data;
$this->_datasize += strlen($data);
}
/*
* General storage function
*/
function _append($data) {
if (func_num_args()>1) {
trigger_error("writeexcel_biffwriter::_append() ".
"called with more than one argument", E_USER_ERROR);
}
if ($this->_debug) {
print "*** writeexcel_biffwriter::_append() called:";
for ($c=0;$c<strlen($data);$c++) {
if ($c%16==0) {
print "\n";
}
printf("%02X ", ord($data[$c]));
}
print "\n";
}
if (strlen($data) > $this->_limit) {
$data = $this->_add_continue($data);
}
$this->_data = $this->_data . $data;
$this->_datasize += strlen($data);
}
/*
* Writes Excel BOF record to indicate the beginning of a stream or
* sub-stream in the BIFF file.
*
* $type = 0x0005, Workbook
* $type = 0x0010, Worksheet
*/
function _store_bof($type) {
$record = 0x0809; // Record identifier
$length = 0x0008; // Number of bytes to follow
$version = $this->BIFF_version;
// According to the SDK $build and $year should be set to zero.
// However, this throws a warning in Excel 5. So, use these
// magic numbers.
$build = 0x096C;
$year = 0x07C9;
$header = pack("vv", $record, $length);
$data = pack("vvvv", $version, $type, $build, $year);
$this->_prepend($header . $data);
}
/*
* Writes Excel EOF record to indicate the end of a BIFF stream.
*/
function _store_eof() {
$record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow
$header = pack("vv", $record, $length);
$this->_append($header);
}
/*
* 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 take a long BIFF record and inserts CONTINUE records as
* necessary.
*/
function _add_continue($data) {
$limit = $this->_limit;
$record = 0x003C; // Record identifier
// The first 2080/8224 bytes remain intact. However, we have to change
// the length field of the record.
$tmp = substr($data, 0, $limit);
$data = substr($data, $limit);
$tmp = substr($tmp, 0, 2) . pack ("v", $limit-4) . substr($tmp, 4);
// Strip out chunks of 2080/8224 bytes +4 for the header.
while (strlen($data) > $limit) {
$header = pack("vv", $record, $limit);
$tmp .= $header;
$tmp .= substr($data, 0, $limit);
$data = substr($data, $limit);
}
// Mop up the last of the data
$header = pack("vv", $record, strlen($data));
$tmp .= $header;
$tmp .= $data;
return $tmp;
}
}
?>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,54 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This 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 software 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 software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, [email protected]
*/
require_once "class.writeexcel_workbook.inc.php";
require_once "class.ole_pps_root.php";
require_once "class.ole_pps_file.php";
class writeexcel_workbookbig extends writeexcel_workbook {
function writeexcel_workbookbig($filename) {
$this->writeexcel_workbook($filename);
}
function _store_OLE_file() {
$file=new ole_pps_file(asc2ucs("Book"));
$file->append($this->_data);
for ($c=0;$c<sizeof($this->_worksheets);$c++) {
$worksheet=&$this->_worksheets[$c];
while ($data=$worksheet->get_data()) {
$file->append($data);
}
}
$ole=new ole_pps_root(false, false, array($file));
$ole->save($this->_filename);
}
}
?>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,271 @@
<?php
/*
* Copyleft 2002 Johann Hanne
*
* This 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 software 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 software; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the Spreadsheet::WriteExcel Perl package ported to PHP
* Spreadsheet::WriteExcel was written by John McNamara, [email protected]
*/
/*
* Converts numeric $row/$col notation to an Excel cell reference string in
* A1 notation.
*/
function xl_rowcol_to_cell($row, $col, $row_abs=false, $col_abs=false) {
$row_abs = $row_abs ? '$' : '';
$col_abs = $col_abs ? '$' : '';
$int = floor($col / 26);
$frac = $col % 26;
$chr1 = ''; // Most significant character in AA1
if ($int > 0) {
$chr1 = chr(ord('A') + $int - 1);
}
$chr2 = chr(ord('A') + $frac);
// Zero index to 1-index
$row++;
return $col_abs.$chr1.$chr2.$row_abs.$row;
}
/*
* Converts an Excel cell reference string in A1 notation
* to numeric $row/$col notation.
*
* Returns: array($row, $col, $row_absolute, $col_absolute)
*
* The $row_absolute and $col_absolute parameters aren't documented because
* they are mainly used internally and aren't very useful to the user.
*/
function xl_cell_to_rowcol($cell) {
preg_match('/(\$?)([A-I]?[A-Z])(\$?)(\d+)/', $cell, $reg);
$col_abs = ($reg[1] == "") ? 0 : 1;
$col = $reg[2];
$row_abs = ($reg[3] == "") ? 0 : 1;
$row = $reg[4];
// Convert base26 column string to number
// All your Base are belong to us.
$chars = preg_split('//', $col, -1, PREG_SPLIT_NO_EMPTY);
$expn = 0;
$col = 0;
while (sizeof($chars)>0) {
$char = array_pop($chars); // Least significant character first
$col += (ord($char) - ord('A') + 1) * pow(26, $expn);
$expn++;
}
// Convert 1-index to zero-index
$row--;
$col--;
return array($row, $col, $row_abs, $col_abs);
}
/*
* Increments the row number of an Excel cell reference string
* in A1 notation.
* For example C4 to C5
*
* Returns: a cell reference string in A1 notation.
*/
function xl_inc_row($cell) {
list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
return xl_rowcol_to_cell(++$row, $col, $row_abs, $col_abs);
}
/*
* Decrements the row number of an Excel cell reference string
* in A1 notation.
* For example C4 to C3
*
* Returns: a cell reference string in A1 notation.
*/
function xl_dec_row($cell) {
list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
return xl_rowcol_to_cell(--$row, $col, $row_abs, $col_abs);
}
/*
* Increments the column number of an Excel cell reference string
* in A1 notation.
* For example C3 to D3
*
* Returns: a cell reference string in A1 notation.
*/
function xl_inc_col($cell) {
list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
return xl_rowcol_to_cell($row, ++$col, $row_abs, $col_abs);
}
/*
* Decrements the column number of an Excel cell reference string
* in A1 notation.
* For example C3 to B3
*
* Returns: a cell reference string in A1 notation.
*/
function xl_dec_col($cell) {
list($row, $col, $row_abs, $col_abs) = xl_cell_to_rowcol($cell);
return xl_rowcol_to_cell($row, --$col, $row_abs, $col_abs);
}
function xl_date_list($year, $month=1, $day=1,
$hour=0, $minute=0, $second=0) {
$monthdays=array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
// Leap years since 1900 (year is dividable by 4)
$leapyears=floor(($year-1900)/4);
// Non-leap years since 1900 (year is dividable by 100)
$nonleapyears=floor(($year-1900)/100);
// Non-non-leap years since 1900 (year is dividable by 400)
// (Yes, it MUST be "1600", not "1900")
$nonnonleapyears=floor(($year-1600)/400);
// Don't count the leap day of the specified year if it didn't
// happen yet (i.e. before 1 March)
//
// Please note that $leapyears becomes -1 for dates before 1 March 1900;
// this is not logical, but later we will add a day for Excel's
// phantasie leap day in 1900 without checking if the date is actually
// after 28 February 1900; so these two logic errors "neutralize"
// each other
if ($year%4==0 && $month<3) {
$leapyears--;
}
$days=365*($year-1900)+$leapyears-$nonleapyears+$nonnonleapyears;
for ($c=1;$c<$month;$c++) {
$days+=$monthdays[$c-1];
}
// Excel actually wants the days since 31 December 1899, not since
// 1 January 1900; this will also add this extra day
$days+=$day;
// Excel treats 1900 erroneously as a leap year, so we must
// add one day
//
// Please note that we DON'T have to check if the date is after
// 28 February 1900, because for such dates $leapyears is -1
// (see above)
$days++;
return (float)($days+($hour*3600+$minute*60+$second)/86400);
}
function xl_parse_time($time) {
if (preg_match('/(\d{1,2}):(\d\d):?((?:\d\d)(?:\.\d+)?)?(?:\s+)?(am|pm)?/i', $time, $reg)) {
$hours = $reg[1];
$minutes = $reg[2];
$seconds = $reg[3] || 0;
$meridian = strtolower($reg[4]) || '';
// Normalise midnight and midday
if ($hours == 12 && $meridian != '') {
$hours = 0;
}
// Add 12 hours to the pm times. Note: 12.00 pm has been set to 0.00.
if ($meridian == 'pm') {
$hours += 12;
}
// Calculate the time as a fraction of 24 hours in seconds
return (float)(($hours*3600+$minutes*60+$seconds)/86400);
} else {
return false; // Not a valid time string
}
}
/*
* Automagically converts almost any date/time string to an Excel date.
* This function will always only be as good as strtotime() is.
*/
function xl_parse_date($date) {
$unixtime=strtotime($date);
$year=date("Y", $unixtime);
$month=date("m", $unixtime);
$day=date("d", $unixtime);
$hour=date("H", $unixtime);
$minute=date("i", $unixtime);
$second=date("s", $unixtime);
// Convert to Excel date
return xl_date_list($year, $month, $day, $hour, $minute, $second);
}
/*
* Dummy function to be "compatible" to Spreadsheet::WriteExcel
*/
function xl_parse_date_init() {
// Erm... do nothing...
// strtotime() doesn't require anything to be initialized
// (do not ask me how to set the timezone...)
}
/*
* xl_decode_date_EU() and xl_decode_date_US() are mapped
* to xl_parse_date(); there seems to be no PHP function that
* differentiates between EU and US dates; I've never seen
* somebody using dd/mm/yyyy anyway, it always should be one of:
* - yyyy-mm-dd (international)
* - dd.mm.yyyy (european)
* - mm/dd/yyyy (english/US/british?)
*/
function xl_decode_date_EU($date) {
return xl_parse_date($date);
}
function xl_decode_date_US($date) {
return xl_parse_date($date);
}
function xl_date_1904($exceldate) {
if ($exceldate < 1462) {
// date is before 1904
$exceldate = 0;
} else {
$exceldate -= 1462;
}
return $exceldate;
}
?>
@@ -0,0 +1,101 @@
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// See scriptaculous.js for full license.
var Builder = {
NODEMAP: {
AREA: 'map',
CAPTION: 'table',
COL: 'table',
COLGROUP: 'table',
LEGEND: 'fieldset',
OPTGROUP: 'select',
OPTION: 'select',
PARAM: 'object',
TBODY: 'table',
TD: 'table',
TFOOT: 'table',
TH: 'table',
THEAD: 'table',
TR: 'table'
},
// note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
// due to a Firefox bug
node: function(elementName) {
elementName = elementName.toUpperCase();
// try innerHTML approach
var parentTag = this.NODEMAP[elementName] || 'div';
var parentElement = document.createElement(parentTag);
try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
} catch(e) {}
var element = parentElement.firstChild || null;
// see if browser added wrapping tags
if(element && (element.tagName != elementName))
element = element.getElementsByTagName(elementName)[0];
// fallback to createElement approach
if(!element) element = document.createElement(elementName);
// abort if nothing could be created
if(!element) return;
// attributes (or text)
if(arguments[1])
if(this._isStringOrNumber(arguments[1]) ||
(arguments[1] instanceof Array)) {
this._children(element, arguments[1]);
} else {
var attrs = this._attributes(arguments[1]);
if(attrs.length) {
try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
parentElement.innerHTML = "<" +elementName + " " +
attrs + "></" + elementName + ">";
} catch(e) {}
element = parentElement.firstChild || null;
// workaround firefox 1.0.X bug
if(!element) {
element = document.createElement(elementName);
for(attr in arguments[1])
element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
}
if(element.tagName != elementName)
element = parentElement.getElementsByTagName(elementName)[0];
}
}
// text, or array of children
if(arguments[2])
this._children(element, arguments[2]);
return element;
},
_text: function(text) {
return document.createTextNode(text);
},
_attributes: function(attributes) {
var attrs = [];
for(attribute in attributes)
attrs.push((attribute=='className' ? 'class' : attribute) +
'="' + attributes[attribute].toString().escapeHTML() + '"');
return attrs.join(" ");
},
_children: function(element, children) {
if(typeof children=='object') { // array can hold nodes and text
children.flatten().each( function(e) {
if(typeof e=='object')
element.appendChild(e)
else
if(Builder._isStringOrNumber(e))
element.appendChild(Builder._text(e));
});
} else
if(Builder._isStringOrNumber(children))
element.appendChild(Builder._text(children));
},
_isStringOrNumber: function(param) {
return(typeof param=='string' || typeof param=='number');
}
}
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More