code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231 values | license stringclasses 13 values | size int64 1 2.01M |
|---|---|---|---|---|---|
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
// Original file header of ParseXL (used as the base for this class):
// --------------------------------------------------------------------------------
// Adapted from Excel_Spreadsheet_Reader developed by users bizon153,
// trex005, and mmp11 (SourceForge.net)
// http://sourceforge.net/projects/phpexcelreader/
// Primary changes made by canyoncasa (dvc) for ParseXL 1.00 ...
// Modelled moreso after Perl Excel Parse/Write modules
// Added Parse_Excel_Spreadsheet object
// Reads a whole worksheet or tab as row,column array or as
// associated hash of indexed rows and named column fields
// Added variables for worksheet (tab) indexes and names
// Added an object call for loading individual woorksheets
// Changed default indexing defaults to 0 based arrays
// Fixed date/time and percent formats
// Includes patches found at SourceForge...
// unicode patch by nobody
// unpack("d") machine depedency patch by matchy
// boundsheet utf16 patch by bjaenichen
// Renamed functions for shorter names
// General code cleanup and rigor, including <80 column width
// Included a testcase Excel file and PHP example calls
// Code works for PHP 5.x
// Primary changes made by canyoncasa (dvc) for ParseXL 1.10 ...
// http://sourceforge.net/tracker/index.php?func=detail&aid=1466964&group_id=99160&atid=623334
// Decoding of formula conditions, results, and tokens.
// Support for user-defined named cells added as an array "namedcells"
// Patch code for user-defined named cells supports single cells only.
// NOTE: this patch only works for BIFF8 as BIFF5-7 use a different
// external sheet reference structure
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_Excel5
*
* This class uses {@link http://sourceforge.net/projects/phpexcelreader/parseXL}
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
{
// ParseXL definitions
const XLS_BIFF8 = 0x0600;
const XLS_BIFF7 = 0x0500;
const XLS_WorkbookGlobals = 0x0005;
const XLS_Worksheet = 0x0010;
// record identifiers
const XLS_Type_FORMULA = 0x0006;
const XLS_Type_EOF = 0x000a;
const XLS_Type_PROTECT = 0x0012;
const XLS_Type_OBJECTPROTECT = 0x0063;
const XLS_Type_SCENPROTECT = 0x00dd;
const XLS_Type_PASSWORD = 0x0013;
const XLS_Type_HEADER = 0x0014;
const XLS_Type_FOOTER = 0x0015;
const XLS_Type_EXTERNSHEET = 0x0017;
const XLS_Type_DEFINEDNAME = 0x0018;
const XLS_Type_VERTICALPAGEBREAKS = 0x001a;
const XLS_Type_HORIZONTALPAGEBREAKS = 0x001b;
const XLS_Type_NOTE = 0x001c;
const XLS_Type_SELECTION = 0x001d;
const XLS_Type_DATEMODE = 0x0022;
const XLS_Type_EXTERNNAME = 0x0023;
const XLS_Type_LEFTMARGIN = 0x0026;
const XLS_Type_RIGHTMARGIN = 0x0027;
const XLS_Type_TOPMARGIN = 0x0028;
const XLS_Type_BOTTOMMARGIN = 0x0029;
const XLS_Type_PRINTGRIDLINES = 0x002b;
const XLS_Type_FILEPASS = 0x002f;
const XLS_Type_FONT = 0x0031;
const XLS_Type_CONTINUE = 0x003c;
const XLS_Type_PANE = 0x0041;
const XLS_Type_CODEPAGE = 0x0042;
const XLS_Type_DEFCOLWIDTH = 0x0055;
const XLS_Type_OBJ = 0x005d;
const XLS_Type_COLINFO = 0x007d;
const XLS_Type_IMDATA = 0x007f;
const XLS_Type_SHEETPR = 0x0081;
const XLS_Type_HCENTER = 0x0083;
const XLS_Type_VCENTER = 0x0084;
const XLS_Type_SHEET = 0x0085;
const XLS_Type_PALETTE = 0x0092;
const XLS_Type_SCL = 0x00a0;
const XLS_Type_PAGESETUP = 0x00a1;
const XLS_Type_MULRK = 0x00bd;
const XLS_Type_MULBLANK = 0x00be;
const XLS_Type_DBCELL = 0x00d7;
const XLS_Type_XF = 0x00e0;
const XLS_Type_MERGEDCELLS = 0x00e5;
const XLS_Type_MSODRAWINGGROUP = 0x00eb;
const XLS_Type_MSODRAWING = 0x00ec;
const XLS_Type_SST = 0x00fc;
const XLS_Type_LABELSST = 0x00fd;
const XLS_Type_EXTSST = 0x00ff;
const XLS_Type_EXTERNALBOOK = 0x01ae;
const XLS_Type_DATAVALIDATIONS = 0x01b2;
const XLS_Type_TXO = 0x01b6;
const XLS_Type_HYPERLINK = 0x01b8;
const XLS_Type_DATAVALIDATION = 0x01be;
const XLS_Type_DIMENSION = 0x0200;
const XLS_Type_BLANK = 0x0201;
const XLS_Type_NUMBER = 0x0203;
const XLS_Type_LABEL = 0x0204;
const XLS_Type_BOOLERR = 0x0205;
const XLS_Type_STRING = 0x0207;
const XLS_Type_ROW = 0x0208;
const XLS_Type_INDEX = 0x020b;
const XLS_Type_ARRAY = 0x0221;
const XLS_Type_DEFAULTROWHEIGHT = 0x0225;
const XLS_Type_WINDOW2 = 0x023e;
const XLS_Type_RK = 0x027e;
const XLS_Type_STYLE = 0x0293;
const XLS_Type_FORMAT = 0x041e;
const XLS_Type_SHAREDFMLA = 0x04bc;
const XLS_Type_BOF = 0x0809;
const XLS_Type_SHEETPROTECTION = 0x0867;
const XLS_Type_RANGEPROTECTION = 0x0868;
const XLS_Type_SHEETLAYOUT = 0x0862;
const XLS_Type_XFEXT = 0x087d;
const XLS_Type_UNKNOWN = 0xffff;
/**
* Read data only?
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
* or whether it should read both data and formatting
*
* @var boolean
*/
private $_readDataOnly = false;
/**
* Restrict which sheets should be loaded?
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
*
* @var array of string
*/
private $_loadSheetsOnly = null;
/**
* PHPExcel_Reader_IReadFilter instance
*
* @var PHPExcel_Reader_IReadFilter
*/
private $_readFilter = null;
/**
* Summary Information stream data.
*
* @var string
*/
private $_summaryInformation;
/**
* Extended Summary Information stream data.
*
* @var string
*/
private $_documentSummaryInformation;
/**
* User-Defined Properties stream data.
*
* @var string
*/
private $_userDefinedProperties;
/**
* Workbook stream data. (Includes workbook globals substream as well as sheet substreams)
*
* @var string
*/
private $_data;
/**
* Size in bytes of $this->_data
*
* @var int
*/
private $_dataSize;
/**
* Current position in stream
*
* @var integer
*/
private $_pos;
/**
* Workbook to be returned by the reader.
*
* @var PHPExcel
*/
private $_phpExcel;
/**
* Worksheet that is currently being built by the reader.
*
* @var PHPExcel_Worksheet
*/
private $_phpSheet;
/**
* BIFF version
*
* @var int
*/
private $_version;
/**
* Codepage set in the Excel file being read. Only important for BIFF5 (Excel 5.0 - Excel 95)
* For BIFF8 (Excel 97 - Excel 2003) this will always have the value 'UTF-16LE'
*
* @var string
*/
private $_codepage;
/**
* Shared formats
*
* @var array
*/
private $_formats;
/**
* Shared fonts
*
* @var array
*/
private $_objFonts;
/**
* Color palette
*
* @var array
*/
private $_palette;
/**
* Worksheets
*
* @var array
*/
private $_sheets;
/**
* External books
*
* @var array
*/
private $_externalBooks;
/**
* REF structures. Only applies to BIFF8.
*
* @var array
*/
private $_ref;
/**
* External names
*
* @var array
*/
private $_externalNames;
/**
* Defined names
*
* @var array
*/
private $_definedname;
/**
* Shared strings. Only applies to BIFF8.
*
* @var array
*/
private $_sst;
/**
* Panes are frozen? (in sheet currently being read). See WINDOW2 record.
*
* @var boolean
*/
private $_frozen;
/**
* Fit printout to number of pages? (in sheet currently being read). See SHEETPR record.
*
* @var boolean
*/
private $_isFitToPages;
/**
* Objects. One OBJ record contributes with one entry.
*
* @var array
*/
private $_objs;
/**
* Text Objects. One TXO record corresponds with one entry.
*
* @var array
*/
private $_textObjects;
/**
* Cell Annotations (BIFF8)
*
* @var array
*/
private $_cellNotes;
/**
* The combined MSODRAWINGGROUP data
*
* @var string
*/
private $_drawingGroupData;
/**
* The combined MSODRAWING data (per sheet)
*
* @var string
*/
private $_drawingData;
/**
* Keep track of XF index
*
* @var int
*/
private $_xfIndex;
/**
* Mapping of XF index (that is a cell XF) to final index in cellXf collection
*
* @var array
*/
private $_mapCellXfIndex;
/**
* Mapping of XF index (that is a style XF) to final index in cellStyleXf collection
*
* @var array
*/
private $_mapCellStyleXfIndex;
/**
* The shared formulas in a sheet. One SHAREDFMLA record contributes with one value.
*
* @var array
*/
private $_sharedFormulas;
/**
* The shared formula parts in a sheet. One FORMULA record contributes with one value if it
* refers to a shared formula.
*
* @var array
*/
private $_sharedFormulaParts;
/**
* Read data only?
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
* If false (the default) it will read data and formatting.
*
* @return boolean
*/
public function getReadDataOnly()
{
return $this->_readDataOnly;
}
/**
* Set read data only
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
*
* @param boolean $pValue
*
* @return PHPExcel_Reader_Excel5
*/
public function setReadDataOnly($pValue = false)
{
$this->_readDataOnly = $pValue;
return $this;
}
/**
* Get which sheets to load
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
* indicating that all worksheets in the workbook should be loaded.
*
* @return mixed
*/
public function getLoadSheetsOnly()
{
return $this->_loadSheetsOnly;
}
/**
* Set which sheets to load
*
* @param mixed $value
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
* If NULL, then it tells the Reader to read all worksheets in the workbook
*
* @return PHPExcel_Reader_Excel5
*/
public function setLoadSheetsOnly($value = null)
{
$this->_loadSheetsOnly = is_array($value) ?
$value : array($value);
return $this;
}
/**
* Set all sheets to load
* Tells the Reader to load all worksheets from the workbook.
*
* @return PHPExcel_Reader_Excel5
*/
public function setLoadAllSheets()
{
$this->_loadSheetsOnly = null;
return $this;
}
/**
* Read filter
*
* @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter() {
return $this->_readFilter;
}
/**
* Set read filter
*
* @param PHPExcel_Reader_IReadFilter $pValue
* @return PHPExcel_Reader_Excel5
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
$this->_readFilter = $pValue;
return $this;
}
/**
* Create a new PHPExcel_Reader_Excel5 instance
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
try {
// Use ParseXL for the hard work.
$ole = new PHPExcel_Shared_OLERead();
// get excel data
$res = $ole->read($pFilename);
return true;
} catch (Exception $e) {
return false;
}
}
/**
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
* @param string $pFilename
* @throws Exception
*/
public function listWorksheetNames($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetNames = array();
// Read the OLE file
$this->_loadOLE($pFilename);
// total byte size of Excel data (workbook global substream + sheet substreams)
$this->_dataSize = strlen($this->_data);
$this->_pos = 0;
$this->_sheets = array();
// Parse Workbook Global Substream
while ($this->_pos < $this->_dataSize) {
$code = self::_GetInt2d($this->_data, $this->_pos);
switch ($code) {
case self::XLS_Type_BOF: $this->_readBof(); break;
case self::XLS_Type_SHEET: $this->_readSheet(); break;
case self::XLS_Type_EOF: $this->_readDefault(); break 2;
default: $this->_readDefault(); break;
}
}
foreach ($this->_sheets as $sheet) {
if ($sheet['sheetType'] != 0x00) {
// 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module
continue;
}
$worksheetNames[] = $sheet['name'];
}
return $worksheetNames;
}
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
*/
public function load($pFilename)
{
// Read the OLE file
$this->_loadOLE($pFilename);
// Initialisations
$this->_phpExcel = new PHPExcel;
$this->_phpExcel->removeSheetByIndex(0); // remove 1st sheet
if (!$this->_readDataOnly) {
$this->_phpExcel->removeCellStyleXfByIndex(0); // remove the default style
$this->_phpExcel->removeCellXfByIndex(0); // remove the default style
}
// Read the summary information stream (containing meta data)
$this->_readSummaryInformation();
// Read the Additional document summary information stream (containing application-specific meta data)
$this->_readDocumentSummaryInformation();
// total byte size of Excel data (workbook global substream + sheet substreams)
$this->_dataSize = strlen($this->_data);
// initialize
$this->_pos = 0;
$this->_codepage = 'CP1252';
$this->_formats = array();
$this->_objFonts = array();
$this->_palette = array();
$this->_sheets = array();
$this->_externalBooks = array();
$this->_ref = array();
$this->_definedname = array();
$this->_sst = array();
$this->_drawingGroupData = '';
$this->_xfIndex = '';
$this->_mapCellXfIndex = array();
$this->_mapCellStyleXfIndex = array();
// Parse Workbook Global Substream
while ($this->_pos < $this->_dataSize) {
$code = self::_GetInt2d($this->_data, $this->_pos);
switch ($code) {
case self::XLS_Type_BOF: $this->_readBof(); break;
case self::XLS_Type_FILEPASS: $this->_readFilepass(); break;
case self::XLS_Type_CODEPAGE: $this->_readCodepage(); break;
case self::XLS_Type_DATEMODE: $this->_readDateMode(); break;
case self::XLS_Type_FONT: $this->_readFont(); break;
case self::XLS_Type_FORMAT: $this->_readFormat(); break;
case self::XLS_Type_XF: $this->_readXf(); break;
case self::XLS_Type_XFEXT: $this->_readXfExt(); break;
case self::XLS_Type_STYLE: $this->_readStyle(); break;
case self::XLS_Type_PALETTE: $this->_readPalette(); break;
case self::XLS_Type_SHEET: $this->_readSheet(); break;
case self::XLS_Type_EXTERNALBOOK: $this->_readExternalBook(); break;
case self::XLS_Type_EXTERNNAME: $this->_readExternName(); break;
case self::XLS_Type_EXTERNSHEET: $this->_readExternSheet(); break;
case self::XLS_Type_DEFINEDNAME: $this->_readDefinedName(); break;
case self::XLS_Type_MSODRAWINGGROUP: $this->_readMsoDrawingGroup(); break;
case self::XLS_Type_SST: $this->_readSst(); break;
case self::XLS_Type_EOF: $this->_readDefault(); break 2;
default: $this->_readDefault(); break;
}
}
// Resolve indexed colors for font, fill, and border colors
// Cannot be resolved already in XF record, because PALETTE record comes afterwards
if (!$this->_readDataOnly) {
foreach ($this->_objFonts as $objFont) {
if (isset($objFont->colorIndex)) {
$color = self::_readColor($objFont->colorIndex,$this->_palette,$this->_version);
$objFont->getColor()->setRGB($color['rgb']);
}
}
foreach ($this->_phpExcel->getCellXfCollection() as $objStyle) {
// fill start and end color
$fill = $objStyle->getFill();
if (isset($fill->startcolorIndex)) {
$startColor = self::_readColor($fill->startcolorIndex,$this->_palette,$this->_version);
$fill->getStartColor()->setRGB($startColor['rgb']);
}
if (isset($fill->endcolorIndex)) {
$endColor = self::_readColor($fill->endcolorIndex,$this->_palette,$this->_version);
$fill->getEndColor()->setRGB($endColor['rgb']);
}
// border colors
$top = $objStyle->getBorders()->getTop();
$right = $objStyle->getBorders()->getRight();
$bottom = $objStyle->getBorders()->getBottom();
$left = $objStyle->getBorders()->getLeft();
$diagonal = $objStyle->getBorders()->getDiagonal();
if (isset($top->colorIndex)) {
$borderTopColor = self::_readColor($top->colorIndex,$this->_palette,$this->_version);
$top->getColor()->setRGB($borderTopColor['rgb']);
}
if (isset($right->colorIndex)) {
$borderRightColor = self::_readColor($right->colorIndex,$this->_palette,$this->_version);
$right->getColor()->setRGB($borderRightColor['rgb']);
}
if (isset($bottom->colorIndex)) {
$borderBottomColor = self::_readColor($bottom->colorIndex,$this->_palette,$this->_version);
$bottom->getColor()->setRGB($borderBottomColor['rgb']);
}
if (isset($left->colorIndex)) {
$borderLeftColor = self::_readColor($left->colorIndex,$this->_palette,$this->_version);
$left->getColor()->setRGB($borderLeftColor['rgb']);
}
if (isset($diagonal->colorIndex)) {
$borderDiagonalColor = self::_readColor($diagonal->colorIndex,$this->_palette,$this->_version);
$diagonal->getColor()->setRGB($borderDiagonalColor['rgb']);
}
}
}
// treat MSODRAWINGGROUP records, workbook-level Escher
if (!$this->_readDataOnly && $this->_drawingGroupData) {
$escherWorkbook = new PHPExcel_Shared_Escher();
$reader = new PHPExcel_Reader_Excel5_Escher($escherWorkbook);
$escherWorkbook = $reader->load($this->_drawingGroupData);
// debug Escher stream
//$debug = new Debug_Escher(new PHPExcel_Shared_Escher());
//$debug->load($this->_drawingGroupData);
}
// Parse the individual sheets
foreach ($this->_sheets as $sheet) {
if ($sheet['sheetType'] != 0x00) {
// 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module
continue;
}
// check if sheet should be skipped
if (isset($this->_loadSheetsOnly) && !in_array($sheet['name'], $this->_loadSheetsOnly)) {
continue;
}
// add sheet to PHPExcel object
$this->_phpSheet = $this->_phpExcel->createSheet();
$this->_phpSheet->setTitle($sheet['name']);
$this->_phpSheet->setSheetState($sheet['sheetState']);
$this->_pos = $sheet['offset'];
// Initialize isFitToPages. May change after reading SHEETPR record.
$this->_isFitToPages = false;
// Initialize drawingData
$this->_drawingData = '';
// Initialize objs
$this->_objs = array();
// Initialize shared formula parts
$this->_sharedFormulaParts = array();
// Initialize shared formulas
$this->_sharedFormulas = array();
// Initialize text objs
$this->_textObjects = array();
// Initialize cell annotations
$this->_cellNotes = array();
$this->textObjRef = -1;
while ($this->_pos <= $this->_dataSize - 4) {
$code = self::_GetInt2d($this->_data, $this->_pos);
switch ($code) {
case self::XLS_Type_BOF: $this->_readBof(); break;
case self::XLS_Type_PRINTGRIDLINES: $this->_readPrintGridlines(); break;
case self::XLS_Type_DEFAULTROWHEIGHT: $this->_readDefaultRowHeight(); break;
case self::XLS_Type_SHEETPR: $this->_readSheetPr(); break;
case self::XLS_Type_HORIZONTALPAGEBREAKS: $this->_readHorizontalPageBreaks(); break;
case self::XLS_Type_VERTICALPAGEBREAKS: $this->_readVerticalPageBreaks(); break;
case self::XLS_Type_HEADER: $this->_readHeader(); break;
case self::XLS_Type_FOOTER: $this->_readFooter(); break;
case self::XLS_Type_HCENTER: $this->_readHcenter(); break;
case self::XLS_Type_VCENTER: $this->_readVcenter(); break;
case self::XLS_Type_LEFTMARGIN: $this->_readLeftMargin(); break;
case self::XLS_Type_RIGHTMARGIN: $this->_readRightMargin(); break;
case self::XLS_Type_TOPMARGIN: $this->_readTopMargin(); break;
case self::XLS_Type_BOTTOMMARGIN: $this->_readBottomMargin(); break;
case self::XLS_Type_PAGESETUP: $this->_readPageSetup(); break;
case self::XLS_Type_PROTECT: $this->_readProtect(); break;
case self::XLS_Type_SCENPROTECT: $this->_readScenProtect(); break;
case self::XLS_Type_OBJECTPROTECT: $this->_readObjectProtect(); break;
case self::XLS_Type_PASSWORD: $this->_readPassword(); break;
case self::XLS_Type_DEFCOLWIDTH: $this->_readDefColWidth(); break;
case self::XLS_Type_COLINFO: $this->_readColInfo(); break;
case self::XLS_Type_DIMENSION: $this->_readDefault(); break;
case self::XLS_Type_ROW: $this->_readRow(); break;
case self::XLS_Type_DBCELL: $this->_readDefault(); break;
case self::XLS_Type_RK: $this->_readRk(); break;
case self::XLS_Type_LABELSST: $this->_readLabelSst(); break;
case self::XLS_Type_MULRK: $this->_readMulRk(); break;
case self::XLS_Type_NUMBER: $this->_readNumber(); break;
case self::XLS_Type_FORMULA: $this->_readFormula(); break;
case self::XLS_Type_SHAREDFMLA: $this->_readSharedFmla(); break;
case self::XLS_Type_BOOLERR: $this->_readBoolErr(); break;
case self::XLS_Type_MULBLANK: $this->_readMulBlank(); break;
case self::XLS_Type_LABEL: $this->_readLabel(); break;
case self::XLS_Type_BLANK: $this->_readBlank(); break;
case self::XLS_Type_MSODRAWING: $this->_readMsoDrawing(); break;
case self::XLS_Type_OBJ: $this->_readObj(); break;
case self::XLS_Type_WINDOW2: $this->_readWindow2(); break;
case self::XLS_Type_SCL: $this->_readScl(); break;
case self::XLS_Type_PANE: $this->_readPane(); break;
case self::XLS_Type_SELECTION: $this->_readSelection(); break;
case self::XLS_Type_MERGEDCELLS: $this->_readMergedCells(); break;
case self::XLS_Type_HYPERLINK: $this->_readHyperLink(); break;
case self::XLS_Type_DATAVALIDATIONS: $this->_readDataValidations(); break;
case self::XLS_Type_DATAVALIDATION: $this->_readDataValidation(); break;
case self::XLS_Type_SHEETLAYOUT: $this->_readSheetLayout(); break;
case self::XLS_Type_SHEETPROTECTION: $this->_readSheetProtection(); break;
case self::XLS_Type_RANGEPROTECTION: $this->_readRangeProtection(); break;
case self::XLS_Type_NOTE: $this->_readNote(); break;
//case self::XLS_Type_IMDATA: $this->_readImData(); break;
case self::XLS_Type_TXO: $this->_readTextObject(); break;
case self::XLS_Type_CONTINUE: $this->_readContinue(); break;
case self::XLS_Type_EOF: $this->_readDefault(); break 2;
default: $this->_readDefault(); break;
}
}
// treat MSODRAWING records, sheet-level Escher
if (!$this->_readDataOnly && $this->_drawingData) {
$escherWorksheet = new PHPExcel_Shared_Escher();
$reader = new PHPExcel_Reader_Excel5_Escher($escherWorksheet);
$escherWorksheet = $reader->load($this->_drawingData);
// debug Escher stream
//$debug = new Debug_Escher(new PHPExcel_Shared_Escher());
//$debug->load($this->_drawingData);
// get all spContainers in one long array, so they can be mapped to OBJ records
$allSpContainers = $escherWorksheet->getDgContainer()->getSpgrContainer()->getAllSpContainers();
}
// treat OBJ records
foreach ($this->_objs as $n => $obj) {
// echo '<hr /><b>Object</b> reference is ',$n,'<br />';
// var_dump($obj);
// echo '<br />';
// the first shape container never has a corresponding OBJ record, hence $n + 1
$spContainer = $allSpContainers[$n + 1];
// we skip all spContainers that are a part of a group shape since we cannot yet handle those
if ($spContainer->getNestingLevel() > 1) {
continue;
}
// calculate the width and height of the shape
list($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($spContainer->getStartCoordinates());
list($endColumn, $endRow) = PHPExcel_Cell::coordinateFromString($spContainer->getEndCoordinates());
$startOffsetX = $spContainer->getStartOffsetX();
$startOffsetY = $spContainer->getStartOffsetY();
$endOffsetX = $spContainer->getEndOffsetX();
$endOffsetY = $spContainer->getEndOffsetY();
$width = PHPExcel_Shared_Excel5::getDistanceX($this->_phpSheet, $startColumn, $startOffsetX, $endColumn, $endOffsetX);
$height = PHPExcel_Shared_Excel5::getDistanceY($this->_phpSheet, $startRow, $startOffsetY, $endRow, $endOffsetY);
// calculate offsetX and offsetY of the shape
$offsetX = $startOffsetX * PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, $startColumn) / 1024;
$offsetY = $startOffsetY * PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $startRow) / 256;
switch ($obj['otObjType']) {
case 0x19:
// Note
// echo 'Cell Annotation Object<br />';
// echo 'Object ID is ',$obj['idObjID'],'<br />';
//
if (isset($this->_cellNotes[$obj['idObjID']])) {
$cellNote = $this->_cellNotes[$obj['idObjID']];
// echo '_cellNotes[',$obj['idObjID'],']: ';
// var_dump($cellNote);
// echo '<br />';
//
if (isset($this->_textObjects[$obj['idObjID']])) {
$textObject = $this->_textObjects[$obj['idObjID']];
// echo '_textObject: ';
// var_dump($textObject);
// echo '<br />';
//
$this->_cellNotes[$obj['idObjID']]['objTextData'] = $textObject;
$text = $textObject['text'];
}
// echo $text,'<br />';
}
break;
case 0x08:
// echo 'Picture Object<br />';
// picture
// get index to BSE entry (1-based)
$BSEindex = $spContainer->getOPT(0x0104);
$BSECollection = $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection();
$BSE = $BSECollection[$BSEindex - 1];
$blipType = $BSE->getBlipType();
// need check because some blip types are not supported by Escher reader such as EMF
if ($blip = $BSE->getBlip()) {
$ih = imagecreatefromstring($blip->getData());
$drawing = new PHPExcel_Worksheet_MemoryDrawing();
$drawing->setImageResource($ih);
// width, height, offsetX, offsetY
$drawing->setResizeProportional(false);
$drawing->setWidth($width);
$drawing->setHeight($height);
$drawing->setOffsetX($offsetX);
$drawing->setOffsetY($offsetY);
switch ($blipType) {
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
$drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
$drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_JPEG);
break;
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG:
$drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG);
$drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_PNG);
break;
}
$drawing->setWorksheet($this->_phpSheet);
$drawing->setCoordinates($spContainer->getStartCoordinates());
}
break;
default:
// other object type
break;
}
}
// treat SHAREDFMLA records
if ($this->_version == self::XLS_BIFF8) {
foreach ($this->_sharedFormulaParts as $cell => $baseCell) {
list($column, $row) = PHPExcel_Cell::coordinateFromString($cell);
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle()) ) {
$formula = $this->_getFormulaFromStructure($this->_sharedFormulas[$baseCell], $cell);
$this->_phpSheet->getCell($cell)->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
}
}
}
if (count($this->_cellNotes) > 0) {
foreach($this->_cellNotes as $note => $noteDetails) {
// echo '<b>Cell annotation ',$note,'</b><br />';
// var_dump($noteDetails);
// echo '<br />';
$cellAddress = str_replace('$','',$noteDetails['cellRef']);
$this->_phpSheet->getComment( $cellAddress )
->setAuthor( $noteDetails['author'] )
->setText($this->_parseRichText($noteDetails['objTextData']['text']) );
}
}
}
// add the named ranges (defined names)
foreach ($this->_definedname as $definedName) {
if ($definedName['isBuiltInName']) {
switch ($definedName['name']) {
case pack('C', 0x06):
// print area
// in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2
$ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma?
$extractedRanges = array();
foreach ($ranges as $range) {
// $range should look like one of these
// Foo!$C$7:$J$66
// Bar!$A$1:$IV$2
$explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark?
$sheetName = $explodes[0];
if (count($explodes) == 2) {
$extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66
}
}
if ($docSheet = $this->_phpExcel->getSheetByName($sheetName)) {
$docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges)); // C7:J66,A1:IV2
}
break;
case pack('C', 0x07):
// print titles (repeating rows)
// Assuming BIFF8, there are 3 cases
// 1. repeating rows
// formula looks like this: Sheet!$A$1:$IV$2
// rows 1-2 repeat
// 2. repeating columns
// formula looks like this: Sheet!$A$1:$B$65536
// columns A-B repeat
// 3. both repeating rows and repeating columns
// formula looks like this: Sheet!$A$1:$B$65536,Sheet!$A$1:$IV$2
$ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma?
foreach ($ranges as $range) {
// $range should look like this one of these
// Sheet!$A$1:$B$65536
// Sheet!$A$1:$IV$2
$explodes = explode('!', $range);
if (count($explodes) == 2) {
if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) {
$extractedRange = $explodes[1];
$extractedRange = str_replace('$', '', $extractedRange);
$coordinateStrings = explode(':', $extractedRange);
if (count($coordinateStrings) == 2) {
list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[0]);
list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[1]);
if ($firstColumn == 'A' and $lastColumn == 'IV') {
// then we have repeating rows
$docSheet->getPageSetup()->setRowsToRepeatAtTop(array($firstRow, $lastRow));
} elseif ($firstRow == 1 and $lastRow == 65536) {
// then we have repeating columns
$docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($firstColumn, $lastColumn));
}
}
}
}
}
break;
}
} else {
// Extract range
$explodes = explode('!', $definedName['formula']);
if (count($explodes) == 2) {
if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) {
$extractedRange = $explodes[1];
$extractedRange = str_replace('$', '', $extractedRange);
$localOnly = ($definedName['scope'] == 0) ? false : true;
$scope = ($definedName['scope'] == 0) ?
null : $this->_phpExcel->getSheetByName($this->_sheets[$definedName['scope'] - 1]['name']);
$this->_phpExcel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, $localOnly, $scope) );
}
}
}
}
return $this->_phpExcel;
}
/**
* Use OLE reader to extract the relevant data streams from the OLE file
*
* @param string $pFilename
*/
private function _loadOLE($pFilename)
{
// OLE reader
$ole = new PHPExcel_Shared_OLERead();
// get excel data,
$res = $ole->read($pFilename);
// Get workbook data: workbook stream + sheet streams
$this->_data = $ole->getStream($ole->wrkbook);
// Get summary information data
$this->_summaryInformation = $ole->getStream($ole->summaryInformation);
// Get additional document summary information data
$this->_documentSummaryInformation = $ole->getStream($ole->documentSummaryInformation);
// Get user-defined property data
// $this->_userDefinedProperties = $ole->getUserDefinedProperties();
}
/**
* Read summary information
*/
private function _readSummaryInformation()
{
if (!isset($this->_summaryInformation)) {
return;
}
// offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
// offset: 2; size: 2;
// offset: 4; size: 2; OS version
// offset: 6; size: 2; OS indicator
// offset: 8; size: 16
// offset: 24; size: 4; section count
$secCount = self::_GetInt4d($this->_summaryInformation, 24);
// offset: 28; size: 16; first section's class id: e0 85 9f f2 f9 4f 68 10 ab 91 08 00 2b 27 b3 d9
// offset: 44; size: 4
$secOffset = self::_GetInt4d($this->_summaryInformation, 44);
// section header
// offset: $secOffset; size: 4; section length
$secLength = self::_GetInt4d($this->_summaryInformation, $secOffset);
// offset: $secOffset+4; size: 4; property count
$countProperties = self::_GetInt4d($this->_summaryInformation, $secOffset+4);
// initialize code page (used to resolve string values)
$codePage = 'CP1252';
// offset: ($secOffset+8); size: var
// loop through property decarations and properties
for ($i = 0; $i < $countProperties; ++$i) {
// offset: ($secOffset+8) + (8 * $i); size: 4; property ID
$id = self::_GetInt4d($this->_summaryInformation, ($secOffset+8) + (8 * $i));
// Use value of property id as appropriate
// offset: ($secOffset+12) + (8 * $i); size: 4; offset from beginning of section (48)
$offset = self::_GetInt4d($this->_summaryInformation, ($secOffset+12) + (8 * $i));
$type = self::_GetInt4d($this->_summaryInformation, $secOffset + $offset);
// initialize property value
$value = null;
// extract property value based on property type
switch ($type) {
case 0x02: // 2 byte signed integer
$value = self::_GetInt2d($this->_summaryInformation, $secOffset + 4 + $offset);
break;
case 0x03: // 4 byte signed integer
$value = self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset);
break;
case 0x13: // 4 byte unsigned integer
// not needed yet, fix later if necessary
break;
case 0x1E: // null-terminated string prepended by dword string length
$byteLength = self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset);
$value = substr($this->_summaryInformation, $secOffset + 8 + $offset, $byteLength);
$value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage);
$value = rtrim($value);
break;
case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
// PHP-time
$value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_summaryInformation, $secOffset + 4 + $offset, 8));
break;
case 0x47: // Clipboard format
// not needed yet, fix later if necessary
break;
}
switch ($id) {
case 0x01: // Code Page
$codePage = PHPExcel_Shared_CodePage::NumberToName($value);
break;
case 0x02: // Title
$this->_phpExcel->getProperties()->setTitle($value);
break;
case 0x03: // Subject
$this->_phpExcel->getProperties()->setSubject($value);
break;
case 0x04: // Author (Creator)
$this->_phpExcel->getProperties()->setCreator($value);
break;
case 0x05: // Keywords
$this->_phpExcel->getProperties()->setKeywords($value);
break;
case 0x06: // Comments (Description)
$this->_phpExcel->getProperties()->setDescription($value);
break;
case 0x07: // Template
// Not supported by PHPExcel
break;
case 0x08: // Last Saved By (LastModifiedBy)
$this->_phpExcel->getProperties()->setLastModifiedBy($value);
break;
case 0x09: // Revision
// Not supported by PHPExcel
break;
case 0x0A: // Total Editing Time
// Not supported by PHPExcel
break;
case 0x0B: // Last Printed
// Not supported by PHPExcel
break;
case 0x0C: // Created Date/Time
$this->_phpExcel->getProperties()->setCreated($value);
break;
case 0x0D: // Modified Date/Time
$this->_phpExcel->getProperties()->setModified($value);
break;
case 0x0E: // Number of Pages
// Not supported by PHPExcel
break;
case 0x0F: // Number of Words
// Not supported by PHPExcel
break;
case 0x10: // Number of Characters
// Not supported by PHPExcel
break;
case 0x11: // Thumbnail
// Not supported by PHPExcel
break;
case 0x12: // Name of creating application
// Not supported by PHPExcel
break;
case 0x13: // Security
// Not supported by PHPExcel
break;
}
}
}
/**
* Read additional document summary information
*/
private function _readDocumentSummaryInformation()
{
if (!isset($this->_documentSummaryInformation)) {
return;
}
// offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
// offset: 2; size: 2;
// offset: 4; size: 2; OS version
// offset: 6; size: 2; OS indicator
// offset: 8; size: 16
// offset: 24; size: 4; section count
$secCount = self::_GetInt4d($this->_documentSummaryInformation, 24);
// echo '$secCount = ',$secCount,'<br />';
// offset: 28; size: 16; first section's class id: 02 d5 cd d5 9c 2e 1b 10 93 97 08 00 2b 2c f9 ae
// offset: 44; size: 4; first section offset
$secOffset = self::_GetInt4d($this->_documentSummaryInformation, 44);
// echo '$secOffset = ',$secOffset,'<br />';
// section header
// offset: $secOffset; size: 4; section length
$secLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset);
// echo '$secLength = ',$secLength,'<br />';
// offset: $secOffset+4; size: 4; property count
$countProperties = self::_GetInt4d($this->_documentSummaryInformation, $secOffset+4);
// echo '$countProperties = ',$countProperties,'<br />';
// initialize code page (used to resolve string values)
$codePage = 'CP1252';
// offset: ($secOffset+8); size: var
// loop through property decarations and properties
for ($i = 0; $i < $countProperties; ++$i) {
// echo 'Property ',$i,'<br />';
// offset: ($secOffset+8) + (8 * $i); size: 4; property ID
$id = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+8) + (8 * $i));
// echo 'ID is ',$id,'<br />';
// Use value of property id as appropriate
// offset: 60 + 8 * $i; size: 4; offset from beginning of section (48)
$offset = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+12) + (8 * $i));
$type = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + $offset);
// echo 'Type is ',$type,', ';
// initialize property value
$value = null;
// extract property value based on property type
switch ($type) {
case 0x02: // 2 byte signed integer
$value = self::_GetInt2d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
break;
case 0x03: // 4 byte signed integer
$value = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
break;
case 0x13: // 4 byte unsigned integer
// not needed yet, fix later if necessary
break;
case 0x1E: // null-terminated string prepended by dword string length
$byteLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset);
$value = substr($this->_documentSummaryInformation, $secOffset + 8 + $offset, $byteLength);
$value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage);
$value = rtrim($value);
break;
case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
// PHP-Time
$value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_documentSummaryInformation, $secOffset + 4 + $offset, 8));
break;
case 0x47: // Clipboard format
// not needed yet, fix later if necessary
break;
}
switch ($id) {
case 0x01: // Code Page
$codePage = PHPExcel_Shared_CodePage::NumberToName($value);
break;
case 0x02: // Category
$this->_phpExcel->getProperties()->setCategory($value);
break;
case 0x03: // Presentation Target
// Not supported by PHPExcel
break;
case 0x04: // Bytes
// Not supported by PHPExcel
break;
case 0x05: // Lines
// Not supported by PHPExcel
break;
case 0x06: // Paragraphs
// Not supported by PHPExcel
break;
case 0x07: // Slides
// Not supported by PHPExcel
break;
case 0x08: // Notes
// Not supported by PHPExcel
break;
case 0x09: // Hidden Slides
// Not supported by PHPExcel
break;
case 0x0A: // MM Clips
// Not supported by PHPExcel
break;
case 0x0B: // Scale Crop
// Not supported by PHPExcel
break;
case 0x0C: // Heading Pairs
// Not supported by PHPExcel
break;
case 0x0D: // Titles of Parts
// Not supported by PHPExcel
break;
case 0x0E: // Manager
$this->_phpExcel->getProperties()->setManager($value);
break;
case 0x0F: // Company
$this->_phpExcel->getProperties()->setCompany($value);
break;
case 0x10: // Links up-to-date
// Not supported by PHPExcel
break;
}
}
}
/**
* Reads a general type of BIFF record. Does nothing except for moving stream pointer forward to next record.
*/
private function _readDefault()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
// $recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
}
/**
* The NOTE record specifies a comment associated with a particular cell. In Excel 95 (BIFF7) and earlier versions,
* this record stores a note (cell note). This feature was significantly enhanced in Excel 97.
*/
private function _readNote()
{
// echo '<b>Read Cell Annotation</b><br />';
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_readDataOnly) {
return;
}
$cellAddress = $this->_readBIFF8CellAddress(substr($recordData, 0, 4));
if ($this->_version == self::XLS_BIFF8) {
$noteObjID = self::_GetInt2d($recordData, 6);
$noteAuthor = self::_readUnicodeStringLong(substr($recordData, 8));
$noteAuthor = $noteAuthor['value'];
// echo 'Note Address=',$cellAddress,'<br />';
// echo 'Note Object ID=',$noteObjID,'<br />';
// echo 'Note Author=',$noteAuthor,'<hr />';
//
$this->_cellNotes[$noteObjID] = array('cellRef' => $cellAddress,
'objectID' => $noteObjID,
'author' => $noteAuthor
);
} else {
$extension = false;
if ($cellAddress == '$B$65536') {
// If the address row is -1 and the column is 0, (which translates as $B$65536) then this is a continuation
// note from the previous cell annotation. We're not yet handling this, so annotations longer than the
// max 2048 bytes will probably throw a wobbly.
$row = self::_GetInt2d($recordData, 0);
$extension = true;
$cellAddress = array_pop(array_keys($this->_phpSheet->getComments()));
}
// echo 'Note Address=',$cellAddress,'<br />';
$cellAddress = str_replace('$','',$cellAddress);
$noteLength = self::_GetInt2d($recordData, 4);
$noteText = trim(substr($recordData, 6));
// echo 'Note Length=',$noteLength,'<br />';
// echo 'Note Text=',$noteText,'<br />';
if ($extension) {
// Concatenate this extension with the currently set comment for the cell
$comment = $this->_phpSheet->getComment( $cellAddress );
$commentText = $comment->getText()->getPlainText();
$comment->setText($this->_parseRichText($commentText.$noteText) );
} else {
// Set comment for the cell
$this->_phpSheet->getComment( $cellAddress )
// ->setAuthor( $author )
->setText($this->_parseRichText($noteText) );
}
}
}
/**
* The TEXT Object record contains the text associated with a cell annotation.
*/
private function _readTextObject()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_readDataOnly) {
return;
}
// recordData consists of an array of subrecords looking like this:
// grbit: 2 bytes; Option Flags
// rot: 2 bytes; rotation
// cchText: 2 bytes; length of the text (in the first continue record)
// cbRuns: 2 bytes; length of the formatting (in the second continue record)
// followed by the continuation records containing the actual text and formatting
$grbitOpts = self::_GetInt2d($recordData, 0);
$rot = self::_GetInt2d($recordData, 2);
$cchText = self::_GetInt2d($recordData, 10);
$cbRuns = self::_GetInt2d($recordData, 12);
$text = $this->_getSplicedRecordData();
$this->_textObjects[$this->textObjRef] = array(
'text' => substr($text["recordData"],$text["spliceOffsets"][0]+1,$cchText),
'format' => substr($text["recordData"],$text["spliceOffsets"][1],$cbRuns),
'alignment' => $grbitOpts,
'rotation' => $rot
);
// echo '<b>_readTextObject()</b><br />';
// var_dump($this->_textObjects[$this->textObjRef]);
// echo '<br />';
}
/**
* Read BOF
*/
private function _readBof()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 2; size: 2; type of the following data
$substreamType = self::_GetInt2d($recordData, 2);
switch ($substreamType) {
case self::XLS_WorkbookGlobals:
$version = self::_GetInt2d($recordData, 0);
if (($version != self::XLS_BIFF8) && ($version != self::XLS_BIFF7)) {
throw new Exception('Cannot read this Excel file. Version is too old.');
}
$this->_version = $version;
break;
case self::XLS_Worksheet:
// do not use this version information for anything
// it is unreliable (OpenOffice doc, 5.8), use only version information from the global stream
break;
default:
// substream, e.g. chart
// just skip the entire substream
do {
$code = self::_GetInt2d($this->_data, $this->_pos);
$this->_readDefault();
} while ($code != self::XLS_Type_EOF && $this->_pos < $this->_dataSize);
break;
}
}
/**
* FILEPASS
*
* This record is part of the File Protection Block. It
* contains information about the read/write password of the
* file. All record contents following this record will be
* encrypted.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readFilepass()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
// $recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
throw new Exception('Cannot read encrypted file');
}
/**
* CODEPAGE
*
* This record stores the text encoding used to write byte
* strings, stored as MS Windows code page identifier.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readCodepage()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; code page identifier
$codepage = self::_GetInt2d($recordData, 0);
$this->_codepage = PHPExcel_Shared_CodePage::NumberToName($codepage);
}
/**
* DATEMODE
*
* This record specifies the base date for displaying date
* values. All dates are stored as count of days past this
* base date. In BIFF2-BIFF4 this record is part of the
* Calculation Settings Block. In BIFF5-BIFF8 it is
* stored in the Workbook Globals Substream.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readDateMode()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; 0 = base 1900, 1 = base 1904
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900);
if (ord($recordData{0}) == 1) {
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904);
}
}
/**
* Read a FONT record
*/
private function _readFont()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
$objFont = new PHPExcel_Style_Font();
// offset: 0; size: 2; height of the font (in twips = 1/20 of a point)
$size = self::_GetInt2d($recordData, 0);
$objFont->setSize($size / 20);
// offset: 2; size: 2; option flags
// bit: 0; mask 0x0001; bold (redundant in BIFF5-BIFF8)
// bit: 1; mask 0x0002; italic
$isItalic = (0x0002 & self::_GetInt2d($recordData, 2)) >> 1;
if ($isItalic) $objFont->setItalic(true);
// bit: 2; mask 0x0004; underlined (redundant in BIFF5-BIFF8)
// bit: 3; mask 0x0008; strike
$isStrike = (0x0008 & self::_GetInt2d($recordData, 2)) >> 3;
if ($isStrike) $objFont->setStrikethrough(true);
// offset: 4; size: 2; colour index
$colorIndex = self::_GetInt2d($recordData, 4);
$objFont->colorIndex = $colorIndex;
// offset: 6; size: 2; font weight
$weight = self::_GetInt2d($recordData, 6);
switch ($weight) {
case 0x02BC:
$objFont->setBold(true);
break;
}
// offset: 8; size: 2; escapement type
$escapement = self::_GetInt2d($recordData, 8);
switch ($escapement) {
case 0x0001:
$objFont->setSuperScript(true);
break;
case 0x0002:
$objFont->setSubScript(true);
break;
}
// offset: 10; size: 1; underline type
$underlineType = ord($recordData{10});
switch ($underlineType) {
case 0x00:
break; // no underline
case 0x01:
$objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
break;
case 0x02:
$objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
break;
case 0x21:
$objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING);
break;
case 0x22:
$objFont->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING);
break;
}
// offset: 11; size: 1; font family
// offset: 12; size: 1; character set
// offset: 13; size: 1; not used
// offset: 14; size: var; font name
if ($this->_version == self::XLS_BIFF8) {
$string = self::_readUnicodeStringShort(substr($recordData, 14));
} else {
$string = $this->_readByteStringShort(substr($recordData, 14));
}
$objFont->setName($string['value']);
$this->_objFonts[] = $objFont;
}
}
/**
* FORMAT
*
* This record contains information about a number format.
* All FORMAT records occur together in a sequential list.
*
* In BIFF2-BIFF4 other records referencing a FORMAT record
* contain a zero-based index into this list. From BIFF5 on
* the FORMAT record contains the index itself that will be
* used by other records.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readFormat()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
$indexCode = self::_GetInt2d($recordData, 0);
if ($this->_version == self::XLS_BIFF8) {
$string = self::_readUnicodeStringLong(substr($recordData, 2));
} else {
// BIFF7
$string = $this->_readByteStringShort(substr($recordData, 2));
}
$formatString = $string['value'];
$this->_formats[$indexCode] = $formatString;
}
}
/**
* XF - Extended Format
*
* This record contains formatting information for cells, rows, columns or styles.
* According to http://support.microsoft.com/kb/147732 there are always at least 15 cell style XF
* and 1 cell XF.
* Inspection of Excel files generated by MS Office Excel shows that XF records 0-14 are cell style XF
* and XF record 15 is a cell XF
* We only read the first cell style XF and skip the remaining cell style XF records
* We read all cell XF records.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readXf()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
$objStyle = new PHPExcel_Style();
if (!$this->_readDataOnly) {
// offset: 0; size: 2; Index to FONT record
if (self::_GetInt2d($recordData, 0) < 4) {
$fontIndex = self::_GetInt2d($recordData, 0);
} else {
// this has to do with that index 4 is omitted in all BIFF versions for some strange reason
// check the OpenOffice documentation of the FONT record
$fontIndex = self::_GetInt2d($recordData, 0) - 1;
}
$objStyle->setFont($this->_objFonts[$fontIndex]);
// offset: 2; size: 2; Index to FORMAT record
$numberFormatIndex = self::_GetInt2d($recordData, 2);
if (isset($this->_formats[$numberFormatIndex])) {
// then we have user-defined format code
$numberformat = array('code' => $this->_formats[$numberFormatIndex]);
} elseif (($code = PHPExcel_Style_NumberFormat::builtInFormatCode($numberFormatIndex)) !== '') {
// then we have built-in format code
$numberformat = array('code' => $code);
} else {
// we set the general format code
$numberformat = array('code' => 'General');
}
$objStyle->getNumberFormat()->setFormatCode($numberformat['code']);
// offset: 4; size: 2; XF type, cell protection, and parent style XF
// bit 2-0; mask 0x0007; XF_TYPE_PROT
$xfTypeProt = self::_GetInt2d($recordData, 4);
// bit 0; mask 0x01; 1 = cell is locked
$isLocked = (0x01 & $xfTypeProt) >> 0;
$objStyle->getProtection()->setLocked($isLocked ?
PHPExcel_Style_Protection::PROTECTION_INHERIT : PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
// bit 1; mask 0x02; 1 = Formula is hidden
$isHidden = (0x02 & $xfTypeProt) >> 1;
$objStyle->getProtection()->setHidden($isHidden ?
PHPExcel_Style_Protection::PROTECTION_PROTECTED : PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
// bit 2; mask 0x04; 0 = Cell XF, 1 = Cell Style XF
$isCellStyleXf = (0x04 & $xfTypeProt) >> 2;
// offset: 6; size: 1; Alignment and text break
// bit 2-0, mask 0x07; horizontal alignment
$horAlign = (0x07 & ord($recordData{6})) >> 0;
switch ($horAlign) {
case 0:
$objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_GENERAL);
break;
case 1:
$objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
break;
case 2:
$objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
break;
case 3:
$objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
break;
case 5:
$objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY);
break;
case 6:
$objStyle->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS);
break;
}
// bit 3, mask 0x08; wrap text
$wrapText = (0x08 & ord($recordData{6})) >> 3;
switch ($wrapText) {
case 0:
$objStyle->getAlignment()->setWrapText(false);
break;
case 1:
$objStyle->getAlignment()->setWrapText(true);
break;
}
// bit 6-4, mask 0x70; vertical alignment
$vertAlign = (0x70 & ord($recordData{6})) >> 4;
switch ($vertAlign) {
case 0:
$objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP);
break;
case 1:
$objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
break;
case 2:
$objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_BOTTOM);
break;
case 3:
$objStyle->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_JUSTIFY);
break;
}
if ($this->_version == self::XLS_BIFF8) {
// offset: 7; size: 1; XF_ROTATION: Text rotation angle
$angle = ord($recordData{7});
$rotation = 0;
if ($angle <= 90) {
$rotation = $angle;
} else if ($angle <= 180) {
$rotation = 90 - $angle;
} else if ($angle == 255) {
$rotation = -165;
}
$objStyle->getAlignment()->setTextRotation($rotation);
// offset: 8; size: 1; Indentation, shrink to cell size, and text direction
// bit: 3-0; mask: 0x0F; indent level
$indent = (0x0F & ord($recordData{8})) >> 0;
$objStyle->getAlignment()->setIndent($indent);
// bit: 4; mask: 0x10; 1 = shrink content to fit into cell
$shrinkToFit = (0x10 & ord($recordData{8})) >> 4;
switch ($shrinkToFit) {
case 0:
$objStyle->getAlignment()->setShrinkToFit(false);
break;
case 1:
$objStyle->getAlignment()->setShrinkToFit(true);
break;
}
// offset: 9; size: 1; Flags used for attribute groups
// offset: 10; size: 4; Cell border lines and background area
// bit: 3-0; mask: 0x0000000F; left style
if ($bordersLeftStyle = self::_mapBorderStyle((0x0000000F & self::_GetInt4d($recordData, 10)) >> 0)) {
$objStyle->getBorders()->getLeft()->setBorderStyle($bordersLeftStyle);
}
// bit: 7-4; mask: 0x000000F0; right style
if ($bordersRightStyle = self::_mapBorderStyle((0x000000F0 & self::_GetInt4d($recordData, 10)) >> 4)) {
$objStyle->getBorders()->getRight()->setBorderStyle($bordersRightStyle);
}
// bit: 11-8; mask: 0x00000F00; top style
if ($bordersTopStyle = self::_mapBorderStyle((0x00000F00 & self::_GetInt4d($recordData, 10)) >> 8)) {
$objStyle->getBorders()->getTop()->setBorderStyle($bordersTopStyle);
}
// bit: 15-12; mask: 0x0000F000; bottom style
if ($bordersBottomStyle = self::_mapBorderStyle((0x0000F000 & self::_GetInt4d($recordData, 10)) >> 12)) {
$objStyle->getBorders()->getBottom()->setBorderStyle($bordersBottomStyle);
}
// bit: 22-16; mask: 0x007F0000; left color
$objStyle->getBorders()->getLeft()->colorIndex = (0x007F0000 & self::_GetInt4d($recordData, 10)) >> 16;
// bit: 29-23; mask: 0x3F800000; right color
$objStyle->getBorders()->getRight()->colorIndex = (0x3F800000 & self::_GetInt4d($recordData, 10)) >> 23;
// bit: 30; mask: 0x40000000; 1 = diagonal line from top left to right bottom
$diagonalDown = (0x40000000 & self::_GetInt4d($recordData, 10)) >> 30 ?
true : false;
// bit: 31; mask: 0x80000000; 1 = diagonal line from bottom left to top right
$diagonalUp = (0x80000000 & self::_GetInt4d($recordData, 10)) >> 31 ?
true : false;
if ($diagonalUp == false && $diagonalDown == false) {
$objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_NONE);
} elseif ($diagonalUp == true && $diagonalDown == false) {
$objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_UP);
} elseif ($diagonalUp == false && $diagonalDown == true) {
$objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_DOWN);
} elseif ($diagonalUp == true && $diagonalDown == true) {
$objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_BOTH);
}
// offset: 14; size: 4;
// bit: 6-0; mask: 0x0000007F; top color
$objStyle->getBorders()->getTop()->colorIndex = (0x0000007F & self::_GetInt4d($recordData, 14)) >> 0;
// bit: 13-7; mask: 0x00003F80; bottom color
$objStyle->getBorders()->getBottom()->colorIndex = (0x00003F80 & self::_GetInt4d($recordData, 14)) >> 7;
// bit: 20-14; mask: 0x001FC000; diagonal color
$objStyle->getBorders()->getDiagonal()->colorIndex = (0x001FC000 & self::_GetInt4d($recordData, 14)) >> 14;
// bit: 24-21; mask: 0x01E00000; diagonal style
if ($bordersDiagonalStyle = self::_mapBorderStyle((0x01E00000 & self::_GetInt4d($recordData, 14)) >> 21)) {
$objStyle->getBorders()->getDiagonal()->setBorderStyle($bordersDiagonalStyle);
}
// bit: 31-26; mask: 0xFC000000 fill pattern
if ($fillType = self::_mapFillPattern((0xFC000000 & self::_GetInt4d($recordData, 14)) >> 26)) {
$objStyle->getFill()->setFillType($fillType);
}
// offset: 18; size: 2; pattern and background colour
// bit: 6-0; mask: 0x007F; color index for pattern color
$objStyle->getFill()->startcolorIndex = (0x007F & self::_GetInt2d($recordData, 18)) >> 0;
// bit: 13-7; mask: 0x3F80; color index for pattern background
$objStyle->getFill()->endcolorIndex = (0x3F80 & self::_GetInt2d($recordData, 18)) >> 7;
} else {
// BIFF5
// offset: 7; size: 1; Text orientation and flags
$orientationAndFlags = ord($recordData{7});
// bit: 1-0; mask: 0x03; XF_ORIENTATION: Text orientation
$xfOrientation = (0x03 & $orientationAndFlags) >> 0;
switch ($xfOrientation) {
case 0:
$objStyle->getAlignment()->setTextRotation(0);
break;
case 1:
$objStyle->getAlignment()->setTextRotation(-165);
break;
case 2:
$objStyle->getAlignment()->setTextRotation(90);
break;
case 3:
$objStyle->getAlignment()->setTextRotation(-90);
break;
}
// offset: 8; size: 4; cell border lines and background area
$borderAndBackground = self::_GetInt4d($recordData, 8);
// bit: 6-0; mask: 0x0000007F; color index for pattern color
$objStyle->getFill()->startcolorIndex = (0x0000007F & $borderAndBackground) >> 0;
// bit: 13-7; mask: 0x00003F80; color index for pattern background
$objStyle->getFill()->endcolorIndex = (0x00003F80 & $borderAndBackground) >> 7;
// bit: 21-16; mask: 0x003F0000; fill pattern
$objStyle->getFill()->setFillType(self::_mapFillPattern((0x003F0000 & $borderAndBackground) >> 16));
// bit: 24-22; mask: 0x01C00000; bottom line style
$objStyle->getBorders()->getBottom()->setBorderStyle(self::_mapBorderStyle((0x01C00000 & $borderAndBackground) >> 22));
// bit: 31-25; mask: 0xFE000000; bottom line color
$objStyle->getBorders()->getBottom()->colorIndex = (0xFE000000 & $borderAndBackground) >> 25;
// offset: 12; size: 4; cell border lines
$borderLines = self::_GetInt4d($recordData, 12);
// bit: 2-0; mask: 0x00000007; top line style
$objStyle->getBorders()->getTop()->setBorderStyle(self::_mapBorderStyle((0x00000007 & $borderLines) >> 0));
// bit: 5-3; mask: 0x00000038; left line style
$objStyle->getBorders()->getLeft()->setBorderStyle(self::_mapBorderStyle((0x00000038 & $borderLines) >> 3));
// bit: 8-6; mask: 0x000001C0; right line style
$objStyle->getBorders()->getRight()->setBorderStyle(self::_mapBorderStyle((0x000001C0 & $borderLines) >> 6));
// bit: 15-9; mask: 0x0000FE00; top line color index
$objStyle->getBorders()->getTop()->colorIndex = (0x0000FE00 & $borderLines) >> 9;
// bit: 22-16; mask: 0x007F0000; left line color index
$objStyle->getBorders()->getLeft()->colorIndex = (0x007F0000 & $borderLines) >> 16;
// bit: 29-23; mask: 0x3F800000; right line color index
$objStyle->getBorders()->getRight()->colorIndex = (0x3F800000 & $borderLines) >> 23;
}
// add cellStyleXf or cellXf and update mapping
if ($isCellStyleXf) {
// we only read one style XF record which is always the first
if ($this->_xfIndex == 0) {
$this->_phpExcel->addCellStyleXf($objStyle);
$this->_mapCellStyleXfIndex[$this->_xfIndex] = 0;
}
} else {
// we read all cell XF records
$this->_phpExcel->addCellXf($objStyle);
$this->_mapCellXfIndex[$this->_xfIndex] = count($this->_phpExcel->getCellXfCollection()) - 1;
}
// update XF index for when we read next record
++$this->_xfIndex;
}
}
/**
*
*/
private function _readXfExt()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; 0x087D = repeated header
// offset: 2; size: 2
// offset: 4; size: 8; not used
// offset: 12; size: 2; record version
// offset: 14; size: 2; index to XF record which this record modifies
$ixfe = self::_GetInt2d($recordData, 14);
// offset: 16; size: 2; not used
// offset: 18; size: 2; number of extension properties that follow
$cexts = self::_GetInt2d($recordData, 18);
// start reading the actual extension data
$offset = 20;
while ($offset < $length) {
// extension type
$extType = self::_GetInt2d($recordData, $offset);
// extension length
$cb = self::_GetInt2d($recordData, $offset + 2);
// extension data
$extData = substr($recordData, $offset + 4, $cb);
switch ($extType) {
case 4: // fill start color
$xclfType = self::_GetInt2d($extData, 0); // color type
$xclrValue = substr($extData, 4, 4); // color value (value based on color type)
if ($xclfType == 2) {
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
$fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill();
$fill->getStartColor()->setRGB($rgb);
unset($fill->startcolorIndex); // normal color index does not apply, discard
}
}
break;
case 5: // fill end color
$xclfType = self::_GetInt2d($extData, 0); // color type
$xclrValue = substr($extData, 4, 4); // color value (value based on color type)
if ($xclfType == 2) {
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
$fill = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFill();
$fill->getEndColor()->setRGB($rgb);
unset($fill->endcolorIndex); // normal color index does not apply, discard
}
}
break;
case 7: // border color top
$xclfType = self::_GetInt2d($extData, 0); // color type
$xclrValue = substr($extData, 4, 4); // color value (value based on color type)
if ($xclfType == 2) {
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
$top = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getTop();
$top->getColor()->setRGB($rgb);
unset($top->colorIndex); // normal color index does not apply, discard
}
}
break;
case 8: // border color bottom
$xclfType = self::_GetInt2d($extData, 0); // color type
$xclrValue = substr($extData, 4, 4); // color value (value based on color type)
if ($xclfType == 2) {
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
$bottom = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getBottom();
$bottom->getColor()->setRGB($rgb);
unset($bottom->colorIndex); // normal color index does not apply, discard
}
}
break;
case 9: // border color left
$xclfType = self::_GetInt2d($extData, 0); // color type
$xclrValue = substr($extData, 4, 4); // color value (value based on color type)
if ($xclfType == 2) {
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
$left = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getLeft();
$left->getColor()->setRGB($rgb);
unset($left->colorIndex); // normal color index does not apply, discard
}
}
break;
case 10: // border color right
$xclfType = self::_GetInt2d($extData, 0); // color type
$xclrValue = substr($extData, 4, 4); // color value (value based on color type)
if ($xclfType == 2) {
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
$right = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getRight();
$right->getColor()->setRGB($rgb);
unset($right->colorIndex); // normal color index does not apply, discard
}
}
break;
case 11: // border color diagonal
$xclfType = self::_GetInt2d($extData, 0); // color type
$xclrValue = substr($extData, 4, 4); // color value (value based on color type)
if ($xclfType == 2) {
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
$diagonal = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getBorders()->getDiagonal();
$diagonal->getColor()->setRGB($rgb);
unset($diagonal->colorIndex); // normal color index does not apply, discard
}
}
break;
case 13: // font color
$xclfType = self::_GetInt2d($extData, 0); // color type
$xclrValue = substr($extData, 4, 4); // color value (value based on color type)
if ($xclfType == 2) {
$rgb = sprintf('%02X%02X%02X', ord($xclrValue{0}), ord($xclrValue{1}), ord($xclrValue{2}));
// modify the relevant style property
if ( isset($this->_mapCellXfIndex[$ixfe]) ) {
$font = $this->_phpExcel->getCellXfByIndex($this->_mapCellXfIndex[$ixfe])->getFont();
$font->getColor()->setRGB($rgb);
unset($font->colorIndex); // normal color index does not apply, discard
}
}
break;
}
$offset += $cb;
}
}
}
/**
* Read STYLE record
*/
private function _readStyle()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; index to XF record and flag for built-in style
$ixfe = self::_GetInt2d($recordData, 0);
// bit: 11-0; mask 0x0FFF; index to XF record
$xfIndex = (0x0FFF & $ixfe) >> 0;
// bit: 15; mask 0x8000; 0 = user-defined style, 1 = built-in style
$isBuiltIn = (bool) ((0x8000 & $ixfe) >> 15);
if ($isBuiltIn) {
// offset: 2; size: 1; identifier for built-in style
$builtInId = ord($recordData{2});
switch ($builtInId) {
case 0x00:
// currently, we are not using this for anything
break;
default:
break;
}
} else {
// user-defined; not supported by PHPExcel
}
}
}
/**
* Read PALETTE record
*/
private function _readPalette()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; number of following colors
$nm = self::_GetInt2d($recordData, 0);
// list of RGB colors
for ($i = 0; $i < $nm; ++$i) {
$rgb = substr($recordData, 2 + 4 * $i, 4);
$this->_palette[] = self::_readRGB($rgb);
}
}
}
/**
* SHEET
*
* This record is located in the Workbook Globals
* Substream and represents a sheet inside the workbook.
* One SHEET record is written for each sheet. It stores the
* sheet name and a stream offset to the BOF record of the
* respective Sheet Substream within the Workbook Stream.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readSheet()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 4; absolute stream position of the BOF record of the sheet
$rec_offset = self::_GetInt4d($recordData, 0);
// offset: 4; size: 1; sheet state
switch (ord($recordData{4})) {
case 0x00: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; break;
case 0x01: $sheetState = PHPExcel_Worksheet::SHEETSTATE_HIDDEN; break;
case 0x02: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN; break;
default: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; break;
}
// offset: 5; size: 1; sheet type
$sheetType = ord($recordData{5});
// offset: 6; size: var; sheet name
if ($this->_version == self::XLS_BIFF8) {
$string = self::_readUnicodeStringShort(substr($recordData, 6));
$rec_name = $string['value'];
} elseif ($this->_version == self::XLS_BIFF7) {
$string = $this->_readByteStringShort(substr($recordData, 6));
$rec_name = $string['value'];
}
$this->_sheets[] = array(
'name' => $rec_name,
'offset' => $rec_offset,
'sheetState' => $sheetState,
'sheetType' => $sheetType,
);
}
/**
* Read EXTERNALBOOK record
*/
private function _readExternalBook()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset within record data
$offset = 0;
// there are 4 types of records
if (strlen($recordData) > 4) {
// external reference
// offset: 0; size: 2; number of sheet names ($nm)
$nm = self::_GetInt2d($recordData, 0);
$offset += 2;
// offset: 2; size: var; encoded URL without sheet name (Unicode string, 16-bit length)
$encodedUrlString = self::_readUnicodeStringLong(substr($recordData, 2));
$offset += $encodedUrlString['size'];
// offset: var; size: var; list of $nm sheet names (Unicode strings, 16-bit length)
$externalSheetNames = array();
for ($i = 0; $i < $nm; ++$i) {
$externalSheetNameString = self::_readUnicodeStringLong(substr($recordData, $offset));
$externalSheetNames[] = $externalSheetNameString['value'];
$offset += $externalSheetNameString['size'];
}
// store the record data
$this->_externalBooks[] = array(
'type' => 'external',
'encodedUrl' => $encodedUrlString['value'],
'externalSheetNames' => $externalSheetNames,
);
} elseif (substr($recordData, 2, 2) == pack('CC', 0x01, 0x04)) {
// internal reference
// offset: 0; size: 2; number of sheet in this document
// offset: 2; size: 2; 0x01 0x04
$this->_externalBooks[] = array(
'type' => 'internal',
);
} elseif (substr($recordData, 0, 4) == pack('vCC', 0x0001, 0x01, 0x3A)) {
// add-in function
// offset: 0; size: 2; 0x0001
$this->_externalBooks[] = array(
'type' => 'addInFunction',
);
} elseif (substr($recordData, 0, 2) == pack('v', 0x0000)) {
// DDE links, OLE links
// offset: 0; size: 2; 0x0000
// offset: 2; size: var; encoded source document name
$this->_externalBooks[] = array(
'type' => 'DDEorOLE',
);
}
}
/**
* Read EXTERNNAME record.
*/
private function _readExternName()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// external sheet references provided for named cells
if ($this->_version == self::XLS_BIFF8) {
// offset: 0; size: 2; options
$options = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2;
// offset: 4; size: 2; not used
// offset: 6; size: var
$nameString = self::_readUnicodeStringShort(substr($recordData, 6));
// offset: var; size: var; formula data
$offset = 6 + $nameString['size'];
$formula = $this->_getFormulaFromStructure(substr($recordData, $offset));
$this->_externalNames[] = array(
'name' => $nameString['value'],
'formula' => $formula,
);
}
}
/**
* Read EXTERNSHEET record
*/
private function _readExternSheet()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// external sheet references provided for named cells
if ($this->_version == self::XLS_BIFF8) {
// offset: 0; size: 2; number of following ref structures
$nm = self::_GetInt2d($recordData, 0);
for ($i = 0; $i < $nm; ++$i) {
$this->_ref[] = array(
// offset: 2 + 6 * $i; index to EXTERNALBOOK record
'externalBookIndex' => self::_GetInt2d($recordData, 2 + 6 * $i),
// offset: 4 + 6 * $i; index to first sheet in EXTERNALBOOK record
'firstSheetIndex' => self::_GetInt2d($recordData, 4 + 6 * $i),
// offset: 6 + 6 * $i; index to last sheet in EXTERNALBOOK record
'lastSheetIndex' => self::_GetInt2d($recordData, 6 + 6 * $i),
);
}
}
}
/**
* DEFINEDNAME
*
* This record is part of a Link Table. It contains the name
* and the token array of an internal defined name. Token
* arrays of defined names contain tokens with aberrant
* token classes.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readDefinedName()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_version == self::XLS_BIFF8) {
// retrieves named cells
// offset: 0; size: 2; option flags
$opts = self::_GetInt2d($recordData, 0);
// bit: 5; mask: 0x0020; 0 = user-defined name, 1 = built-in-name
$isBuiltInName = (0x0020 & $opts) >> 5;
// offset: 2; size: 1; keyboard shortcut
// offset: 3; size: 1; length of the name (character count)
$nlen = ord($recordData{3});
// offset: 4; size: 2; size of the formula data (it can happen that this is zero)
// note: there can also be additional data, this is not included in $flen
$flen = self::_GetInt2d($recordData, 4);
// offset: 8; size: 2; 0=Global name, otherwise index to sheet (1-based)
$scope = self::_GetInt2d($recordData, 8);
// offset: 14; size: var; Name (Unicode string without length field)
$string = self::_readUnicodeString(substr($recordData, 14), $nlen);
// offset: var; size: $flen; formula data
$offset = 14 + $string['size'];
$formulaStructure = pack('v', $flen) . substr($recordData, $offset);
try {
$formula = $this->_getFormulaFromStructure($formulaStructure);
} catch (Exception $e) {
$formula = '';
}
$this->_definedname[] = array(
'isBuiltInName' => $isBuiltInName,
'name' => $string['value'],
'formula' => $formula,
'scope' => $scope,
);
}
}
/**
* Read MSODRAWINGGROUP record
*/
private function _readMsoDrawingGroup()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
// get spliced record data
$splicedRecordData = $this->_getSplicedRecordData();
$recordData = $splicedRecordData['recordData'];
$this->_drawingGroupData .= $recordData;
}
/**
* SST - Shared String Table
*
* This record contains a list of all strings used anywhere
* in the workbook. Each string occurs only once. The
* workbook uses indexes into the list to reference the
* strings.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
**/
private function _readSst()
{
// offset within (spliced) record data
$pos = 0;
// get spliced record data
$splicedRecordData = $this->_getSplicedRecordData();
$recordData = $splicedRecordData['recordData'];
$spliceOffsets = $splicedRecordData['spliceOffsets'];
// offset: 0; size: 4; total number of strings in the workbook
$pos += 4;
// offset: 4; size: 4; number of following strings ($nm)
$nm = self::_GetInt4d($recordData, 4);
$pos += 4;
// loop through the Unicode strings (16-bit length)
for ($i = 0; $i < $nm; ++$i) {
// number of characters in the Unicode string
$numChars = self::_GetInt2d($recordData, $pos);
$pos += 2;
// option flags
$optionFlags = ord($recordData{$pos});
++$pos;
// bit: 0; mask: 0x01; 0 = compressed; 1 = uncompressed
$isCompressed = (($optionFlags & 0x01) == 0) ;
// bit: 2; mask: 0x02; 0 = ordinary; 1 = Asian phonetic
$hasAsian = (($optionFlags & 0x04) != 0);
// bit: 3; mask: 0x03; 0 = ordinary; 1 = Rich-Text
$hasRichText = (($optionFlags & 0x08) != 0);
if ($hasRichText) {
// number of Rich-Text formatting runs
$formattingRuns = self::_GetInt2d($recordData, $pos);
$pos += 2;
}
if ($hasAsian) {
// size of Asian phonetic setting
$extendedRunLength = self::_GetInt4d($recordData, $pos);
$pos += 4;
}
// expected byte length of character array if not split
$len = ($isCompressed) ? $numChars : $numChars * 2;
// look up limit position
foreach ($spliceOffsets as $spliceOffset) {
// it can happen that the string is empty, therefore we need
// <= and not just <
if ($pos <= $spliceOffset) {
$limitpos = $spliceOffset;
break;
}
}
if ($pos + $len <= $limitpos) {
// character array is not split between records
$retstr = substr($recordData, $pos, $len);
$pos += $len;
} else {
// character array is split between records
// first part of character array
$retstr = substr($recordData, $pos, $limitpos - $pos);
$bytesRead = $limitpos - $pos;
// remaining characters in Unicode string
$charsLeft = $numChars - (($isCompressed) ? $bytesRead : ($bytesRead / 2));
$pos = $limitpos;
// keep reading the characters
while ($charsLeft > 0) {
// look up next limit position, in case the string span more than one continue record
foreach ($spliceOffsets as $spliceOffset) {
if ($pos < $spliceOffset) {
$limitpos = $spliceOffset;
break;
}
}
// repeated option flags
// OpenOffice.org documentation 5.21
$option = ord($recordData{$pos});
++$pos;
if ($isCompressed && ($option == 0)) {
// 1st fragment compressed
// this fragment compressed
$len = min($charsLeft, $limitpos - $pos);
$retstr .= substr($recordData, $pos, $len);
$charsLeft -= $len;
$isCompressed = true;
} elseif (!$isCompressed && ($option != 0)) {
// 1st fragment uncompressed
// this fragment uncompressed
$len = min($charsLeft * 2, $limitpos - $pos);
$retstr .= substr($recordData, $pos, $len);
$charsLeft -= $len / 2;
$isCompressed = false;
} elseif (!$isCompressed && ($option == 0)) {
// 1st fragment uncompressed
// this fragment compressed
$len = min($charsLeft, $limitpos - $pos);
for ($j = 0; $j < $len; ++$j) {
$retstr .= $recordData{$pos + $j} . chr(0);
}
$charsLeft -= $len;
$isCompressed = false;
} else {
// 1st fragment compressed
// this fragment uncompressed
$newstr = '';
for ($j = 0; $j < strlen($retstr); ++$j) {
$newstr .= $retstr[$j] . chr(0);
}
$retstr = $newstr;
$len = min($charsLeft * 2, $limitpos - $pos);
$retstr .= substr($recordData, $pos, $len);
$charsLeft -= $len / 2;
$isCompressed = false;
}
$pos += $len;
}
}
// convert to UTF-8
$retstr = self::_encodeUTF16($retstr, $isCompressed);
// read additional Rich-Text information, if any
$fmtRuns = array();
if ($hasRichText) {
// list of formatting runs
for ($j = 0; $j < $formattingRuns; ++$j) {
// first formatted character; zero-based
$charPos = self::_GetInt2d($recordData, $pos + $j * 4);
// index to font record
$fontIndex = self::_GetInt2d($recordData, $pos + 2 + $j * 4);
$fmtRuns[] = array(
'charPos' => $charPos,
'fontIndex' => $fontIndex,
);
}
$pos += 4 * $formattingRuns;
}
// read additional Asian phonetics information, if any
if ($hasAsian) {
// For Asian phonetic settings, we skip the extended string data
$pos += $extendedRunLength;
}
// store the shared sting
$this->_sst[] = array(
'value' => $retstr,
'fmtRuns' => $fmtRuns,
);
}
// _getSplicedRecordData() takes care of moving current position in data stream
}
/**
* Read PRINTGRIDLINES record
*/
private function _readPrintGridlines()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
// offset: 0; size: 2; 0 = do not print sheet grid lines; 1 = print sheet gridlines
$printGridlines = (bool) self::_GetInt2d($recordData, 0);
$this->_phpSheet->setPrintGridlines($printGridlines);
}
}
/**
* Read DEFAULTROWHEIGHT record
*/
private function _readDefaultRowHeight()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; option flags
// offset: 2; size: 2; default height for unused rows, (twips 1/20 point)
$height = self::_GetInt2d($recordData, 2);
$this->_phpSheet->getDefaultRowDimension()->setRowHeight($height / 20);
}
/**
* Read SHEETPR record
*/
private function _readSheetPr()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2
// bit: 6; mask: 0x0040; 0 = outline buttons above outline group
$isSummaryBelow = (0x0040 & self::_GetInt2d($recordData, 0)) >> 6;
$this->_phpSheet->setShowSummaryBelow($isSummaryBelow);
// bit: 7; mask: 0x0080; 0 = outline buttons left of outline group
$isSummaryRight = (0x0080 & self::_GetInt2d($recordData, 0)) >> 7;
$this->_phpSheet->setShowSummaryRight($isSummaryRight);
// bit: 8; mask: 0x100; 0 = scale printout in percent, 1 = fit printout to number of pages
// this corresponds to radio button setting in page setup dialog in Excel
$this->_isFitToPages = (bool) ((0x0100 & self::_GetInt2d($recordData, 0)) >> 8);
}
/**
* Read HORIZONTALPAGEBREAKS record
*/
private function _readHorizontalPageBreaks()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
// offset: 0; size: 2; number of the following row index structures
$nm = self::_GetInt2d($recordData, 0);
// offset: 2; size: 6 * $nm; list of $nm row index structures
for ($i = 0; $i < $nm; ++$i) {
$r = self::_GetInt2d($recordData, 2 + 6 * $i);
$cf = self::_GetInt2d($recordData, 2 + 6 * $i + 2);
$cl = self::_GetInt2d($recordData, 2 + 6 * $i + 4);
// not sure why two column indexes are necessary?
$this->_phpSheet->setBreakByColumnAndRow($cf, $r, PHPExcel_Worksheet::BREAK_ROW);
}
}
}
/**
* Read VERTICALPAGEBREAKS record
*/
private function _readVerticalPageBreaks()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
// offset: 0; size: 2; number of the following column index structures
$nm = self::_GetInt2d($recordData, 0);
// offset: 2; size: 6 * $nm; list of $nm row index structures
for ($i = 0; $i < $nm; ++$i) {
$c = self::_GetInt2d($recordData, 2 + 6 * $i);
$rf = self::_GetInt2d($recordData, 2 + 6 * $i + 2);
$rl = self::_GetInt2d($recordData, 2 + 6 * $i + 4);
// not sure why two row indexes are necessary?
$this->_phpSheet->setBreakByColumnAndRow($c, $rf, PHPExcel_Worksheet::BREAK_COLUMN);
}
}
}
/**
* Read HEADER record
*/
private function _readHeader()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: var
// realized that $recordData can be empty even when record exists
if ($recordData) {
if ($this->_version == self::XLS_BIFF8) {
$string = self::_readUnicodeStringLong($recordData);
} else {
$string = $this->_readByteStringShort($recordData);
}
$this->_phpSheet->getHeaderFooter()->setOddHeader($string['value']);
$this->_phpSheet->getHeaderFooter()->setEvenHeader($string['value']);
}
}
}
/**
* Read FOOTER record
*/
private function _readFooter()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: var
// realized that $recordData can be empty even when record exists
if ($recordData) {
if ($this->_version == self::XLS_BIFF8) {
$string = self::_readUnicodeStringLong($recordData);
} else {
$string = $this->_readByteStringShort($recordData);
}
$this->_phpSheet->getHeaderFooter()->setOddFooter($string['value']);
$this->_phpSheet->getHeaderFooter()->setEvenFooter($string['value']);
}
}
}
/**
* Read HCENTER record
*/
private function _readHcenter()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally
$isHorizontalCentered = (bool) self::_GetInt2d($recordData, 0);
$this->_phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered);
}
}
/**
* Read VCENTER record
*/
private function _readVcenter()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; 0 = print sheet aligned at top page border, 1 = print sheet vertically centered
$isVerticalCentered = (bool) self::_GetInt2d($recordData, 0);
$this->_phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered);
}
}
/**
* Read LEFTMARGIN record
*/
private function _readLeftMargin()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 8
$this->_phpSheet->getPageMargins()->setLeft(self::_extractNumber($recordData));
}
}
/**
* Read RIGHTMARGIN record
*/
private function _readRightMargin()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 8
$this->_phpSheet->getPageMargins()->setRight(self::_extractNumber($recordData));
}
}
/**
* Read TOPMARGIN record
*/
private function _readTopMargin()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 8
$this->_phpSheet->getPageMargins()->setTop(self::_extractNumber($recordData));
}
}
/**
* Read BOTTOMMARGIN record
*/
private function _readBottomMargin()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 8
$this->_phpSheet->getPageMargins()->setBottom(self::_extractNumber($recordData));
}
}
/**
* Read PAGESETUP record
*/
private function _readPageSetup()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; paper size
$paperSize = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; scaling factor
$scale = self::_GetInt2d($recordData, 2);
// offset: 6; size: 2; fit worksheet width to this number of pages, 0 = use as many as needed
$fitToWidth = self::_GetInt2d($recordData, 6);
// offset: 8; size: 2; fit worksheet height to this number of pages, 0 = use as many as needed
$fitToHeight = self::_GetInt2d($recordData, 8);
// offset: 10; size: 2; option flags
// bit: 1; mask: 0x0002; 0=landscape, 1=portrait
$isPortrait = (0x0002 & self::_GetInt2d($recordData, 10)) >> 1;
// bit: 2; mask: 0x0004; 1= paper size, scaling factor, paper orient. not init
// when this bit is set, do not use flags for those properties
$isNotInit = (0x0004 & self::_GetInt2d($recordData, 10)) >> 2;
if (!$isNotInit) {
$this->_phpSheet->getPageSetup()->setPaperSize($paperSize);
switch ($isPortrait) {
case 0: $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); break;
case 1: $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); break;
}
$this->_phpSheet->getPageSetup()->setScale($scale, false);
$this->_phpSheet->getPageSetup()->setFitToPage((bool) $this->_isFitToPages);
$this->_phpSheet->getPageSetup()->setFitToWidth($fitToWidth, false);
$this->_phpSheet->getPageSetup()->setFitToHeight($fitToHeight, false);
}
// offset: 16; size: 8; header margin (IEEE 754 floating-point value)
$marginHeader = self::_extractNumber(substr($recordData, 16, 8));
$this->_phpSheet->getPageMargins()->setHeader($marginHeader);
// offset: 24; size: 8; footer margin (IEEE 754 floating-point value)
$marginFooter = self::_extractNumber(substr($recordData, 24, 8));
$this->_phpSheet->getPageMargins()->setFooter($marginFooter);
}
}
/**
* PROTECT - Sheet protection (BIFF2 through BIFF8)
* if this record is omitted, then it also means no sheet protection
*/
private function _readProtect()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_readDataOnly) {
return;
}
// offset: 0; size: 2;
// bit 0, mask 0x01; 1 = sheet is protected
$bool = (0x01 & self::_GetInt2d($recordData, 0)) >> 0;
$this->_phpSheet->getProtection()->setSheet((bool)$bool);
}
/**
* SCENPROTECT
*/
private function _readScenProtect()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_readDataOnly) {
return;
}
// offset: 0; size: 2;
// bit: 0, mask 0x01; 1 = scenarios are protected
$bool = (0x01 & self::_GetInt2d($recordData, 0)) >> 0;
$this->_phpSheet->getProtection()->setScenarios((bool)$bool);
}
/**
* OBJECTPROTECT
*/
private function _readObjectProtect()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_readDataOnly) {
return;
}
// offset: 0; size: 2;
// bit: 0, mask 0x01; 1 = objects are protected
$bool = (0x01 & self::_GetInt2d($recordData, 0)) >> 0;
$this->_phpSheet->getProtection()->setObjects((bool)$bool);
}
/**
* PASSWORD - Sheet protection (hashed) password (BIFF2 through BIFF8)
*/
private function _readPassword()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; 16-bit hash value of password
$password = strtoupper(dechex(self::_GetInt2d($recordData, 0))); // the hashed password
$this->_phpSheet->getProtection()->setPassword($password, true);
}
}
/**
* Read DEFCOLWIDTH record
*/
private function _readDefColWidth()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; default column width
$width = self::_GetInt2d($recordData, 0);
if ($width != 8) {
$this->_phpSheet->getDefaultColumnDimension()->setWidth($width);
}
}
/**
* Read COLINFO record
*/
private function _readColInfo()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; index to first column in range
$fc = self::_GetInt2d($recordData, 0); // first column index
// offset: 2; size: 2; index to last column in range
$lc = self::_GetInt2d($recordData, 2); // first column index
// offset: 4; size: 2; width of the column in 1/256 of the width of the zero character
$width = self::_GetInt2d($recordData, 4);
// offset: 6; size: 2; index to XF record for default column formatting
$xfIndex = self::_GetInt2d($recordData, 6);
// offset: 8; size: 2; option flags
// bit: 0; mask: 0x0001; 1= columns are hidden
$isHidden = (0x0001 & self::_GetInt2d($recordData, 8)) >> 0;
// bit: 10-8; mask: 0x0700; outline level of the columns (0 = no outline)
$level = (0x0700 & self::_GetInt2d($recordData, 8)) >> 8;
// bit: 12; mask: 0x1000; 1 = collapsed
$isCollapsed = (0x1000 & self::_GetInt2d($recordData, 8)) >> 12;
// offset: 10; size: 2; not used
for ($i = $fc; $i <= $lc; ++$i) {
if ($lc == 255 || $lc == 256) {
$this->_phpSheet->getDefaultColumnDimension()->setWidth($width / 256);
break;
}
$this->_phpSheet->getColumnDimensionByColumn($i)->setWidth($width / 256);
$this->_phpSheet->getColumnDimensionByColumn($i)->setVisible(!$isHidden);
$this->_phpSheet->getColumnDimensionByColumn($i)->setOutlineLevel($level);
$this->_phpSheet->getColumnDimensionByColumn($i)->setCollapsed($isCollapsed);
$this->_phpSheet->getColumnDimensionByColumn($i)->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
/**
* ROW
*
* This record contains the properties of a single row in a
* sheet. Rows and cells in a sheet are divided into blocks
* of 32 rows.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readRow()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; index of this row
$r = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; index to column of the first cell which is described by a cell record
// offset: 4; size: 2; index to column of the last cell which is described by a cell record, increased by 1
// offset: 6; size: 2;
// bit: 14-0; mask: 0x7FFF; height of the row, in twips = 1/20 of a point
$height = (0x7FFF & self::_GetInt2d($recordData, 6)) >> 0;
// bit: 15: mask: 0x8000; 0 = row has custom height; 1= row has default height
$useDefaultHeight = (0x8000 & self::_GetInt2d($recordData, 6)) >> 15;
if (!$useDefaultHeight) {
$this->_phpSheet->getRowDimension($r + 1)->setRowHeight($height / 20);
}
// offset: 8; size: 2; not used
// offset: 10; size: 2; not used in BIFF5-BIFF8
// offset: 12; size: 4; option flags and default row formatting
// bit: 2-0: mask: 0x00000007; outline level of the row
$level = (0x00000007 & self::_GetInt4d($recordData, 12)) >> 0;
$this->_phpSheet->getRowDimension($r + 1)->setOutlineLevel($level);
// bit: 4; mask: 0x00000010; 1 = outline group start or ends here... and is collapsed
$isCollapsed = (0x00000010 & self::_GetInt4d($recordData, 12)) >> 4;
$this->_phpSheet->getRowDimension($r + 1)->setCollapsed($isCollapsed);
// bit: 5; mask: 0x00000020; 1 = row is hidden
$isHidden = (0x00000020 & self::_GetInt4d($recordData, 12)) >> 5;
$this->_phpSheet->getRowDimension($r + 1)->setVisible(!$isHidden);
// bit: 7; mask: 0x00000080; 1 = row has explicit format
$hasExplicitFormat = (0x00000080 & self::_GetInt4d($recordData, 12)) >> 7;
// bit: 27-16; mask: 0x0FFF0000; only applies when hasExplicitFormat = 1; index to XF record
$xfIndex = (0x0FFF0000 & self::_GetInt4d($recordData, 12)) >> 16;
if ($hasExplicitFormat) {
$this->_phpSheet->getRowDimension($r + 1)->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
/**
* Read RK record
* This record represents a cell that contains an RK value
* (encoded integer or floating-point value). If a
* floating-point value cannot be encoded to an RK value,
* a NUMBER record will be written. This record replaces the
* record INTEGER written in BIFF2.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readRk()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; index to row
$row = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; index to column
$column = self::_GetInt2d($recordData, 2);
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: 4; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, 4);
// offset: 6; size: 4; RK value
$rknum = self::_GetInt4d($recordData, 6);
$numValue = self::_GetIEEE754($rknum);
$cell = $this->_phpSheet->getCell($columnString . ($row + 1));
if (!$this->_readDataOnly) {
// add style information
$cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
// add cell
$cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC);
}
}
/**
* Read LABELSST record
* This record represents a cell that contains a string. It
* replaces the LABEL record and RSTRING record used in
* BIFF2-BIFF5.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readLabelSst()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; index to row
$row = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; index to column
$column = self::_GetInt2d($recordData, 2);
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: 4; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, 4);
// offset: 6; size: 4; index to SST record
$index = self::_GetInt4d($recordData, 6);
// add cell
if (($fmtRuns = $this->_sst[$index]['fmtRuns']) && !$this->_readDataOnly) {
// then we should treat as rich text
$richText = new PHPExcel_RichText();
$charPos = 0;
$sstCount = count($this->_sst[$index]['fmtRuns']);
for ($i = 0; $i <= $sstCount; ++$i) {
if (isset($fmtRuns[$i])) {
$text = PHPExcel_Shared_String::Substring($this->_sst[$index]['value'], $charPos, $fmtRuns[$i]['charPos'] - $charPos);
$charPos = $fmtRuns[$i]['charPos'];
} else {
$text = PHPExcel_Shared_String::Substring($this->_sst[$index]['value'], $charPos, PHPExcel_Shared_String::CountCharacters($this->_sst[$index]['value']));
}
if (PHPExcel_Shared_String::CountCharacters($text) > 0) {
if ($i == 0) { // first text run, no style
$richText->createText($text);
} else {
$textRun = $richText->createTextRun($text);
if (isset($fmtRuns[$i - 1])) {
if ($fmtRuns[$i - 1]['fontIndex'] < 4) {
$fontIndex = $fmtRuns[$i - 1]['fontIndex'];
} else {
// this has to do with that index 4 is omitted in all BIFF versions for some strange reason
// check the OpenOffice documentation of the FONT record
$fontIndex = $fmtRuns[$i - 1]['fontIndex'] - 1;
}
$textRun->setFont(clone $this->_objFonts[$fontIndex]);
}
}
}
}
$cell = $this->_phpSheet->getCell($columnString . ($row + 1));
$cell->setValueExplicit($richText, PHPExcel_Cell_DataType::TYPE_STRING);
} else {
$cell = $this->_phpSheet->getCell($columnString . ($row + 1));
$cell->setValueExplicit($this->_sst[$index]['value'], PHPExcel_Cell_DataType::TYPE_STRING);
}
if (!$this->_readDataOnly) {
// add style information
$cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
/**
* Read MULRK record
* This record represents a cell range containing RK value
* cells. All cells are located in the same row.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readMulRk()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; index to row
$row = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; index to first column
$colFirst = self::_GetInt2d($recordData, 2);
// offset: var; size: 2; index to last column
$colLast = self::_GetInt2d($recordData, $length - 2);
$columns = $colLast - $colFirst + 1;
// offset within record data
$offset = 4;
for ($i = 0; $i < $columns; ++$i) {
$columnString = PHPExcel_Cell::stringFromColumnIndex($colFirst + $i);
// Read cell?
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: var; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, $offset);
// offset: var; size: 4; RK value
$numValue = self::_GetIEEE754(self::_GetInt4d($recordData, $offset + 2));
$cell = $this->_phpSheet->getCell($columnString . ($row + 1));
if (!$this->_readDataOnly) {
// add style
$cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
// add cell value
$cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC);
}
$offset += 6;
}
}
/**
* Read NUMBER record
* This record represents a cell that contains a
* floating-point value.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readNumber()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; index to row
$row = self::_GetInt2d($recordData, 0);
// offset: 2; size 2; index to column
$column = self::_GetInt2d($recordData, 2);
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset 4; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, 4);
$numValue = self::_extractNumber(substr($recordData, 6, 8));
$cell = $this->_phpSheet->getCell($columnString . ($row + 1));
if (!$this->_readDataOnly) {
// add cell style
$cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
// add cell value
$cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC);
}
}
/**
* Read FORMULA record + perhaps a following STRING record if formula result is a string
* This record contains the token array and the result of a
* formula cell.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readFormula()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; row index
$row = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; col index
$column = self::_GetInt2d($recordData, 2);
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// offset: 20: size: variable; formula structure
$formulaStructure = substr($recordData, 20);
// offset: 14: size: 2; option flags, recalculate always, recalculate on open etc.
$options = self::_GetInt2d($recordData, 14);
// bit: 0; mask: 0x0001; 1 = recalculate always
// bit: 1; mask: 0x0002; 1 = calculate on open
// bit: 2; mask: 0x0008; 1 = part of a shared formula
$isPartOfSharedFormula = (bool) (0x0008 & $options);
// WARNING:
// We can apparently not rely on $isPartOfSharedFormula. Even when $isPartOfSharedFormula = true
// the formula data may be ordinary formula data, therefore we need to check
// explicitly for the tExp token (0x01)
$isPartOfSharedFormula = $isPartOfSharedFormula && ord($formulaStructure{2}) == 0x01;
if ($isPartOfSharedFormula) {
// part of shared formula which means there will be a formula with a tExp token and nothing else
// get the base cell, grab tExp token
$baseRow = self::_GetInt2d($formulaStructure, 3);
$baseCol = self::_GetInt2d($formulaStructure, 5);
$this->_baseCell = PHPExcel_Cell::stringFromColumnIndex($baseCol). ($baseRow + 1);
}
// Read cell?
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
if ($isPartOfSharedFormula) {
// formula is added to this cell after the sheet has been read
$this->_sharedFormulaParts[$columnString . ($row + 1)] = $this->_baseCell;
}
// offset: 16: size: 4; not used
// offset: 4; size: 2; XF index
$xfIndex = self::_GetInt2d($recordData, 4);
// offset: 6; size: 8; result of the formula
if ( (ord($recordData{6}) == 0)
&& (ord($recordData{12}) == 255)
&& (ord($recordData{13}) == 255) ) {
// String formula. Result follows in appended STRING record
$dataType = PHPExcel_Cell_DataType::TYPE_STRING;
// read possible SHAREDFMLA record
$code = self::_GetInt2d($this->_data, $this->_pos);
if ($code == self::XLS_Type_SHAREDFMLA) {
$this->_readSharedFmla();
}
// read STRING record
$value = $this->_readString();
} elseif ((ord($recordData{6}) == 1)
&& (ord($recordData{12}) == 255)
&& (ord($recordData{13}) == 255)) {
// Boolean formula. Result is in +2; 0=false, 1=true
$dataType = PHPExcel_Cell_DataType::TYPE_BOOL;
$value = (bool) ord($recordData{8});
} elseif ((ord($recordData{6}) == 2)
&& (ord($recordData{12}) == 255)
&& (ord($recordData{13}) == 255)) {
// Error formula. Error code is in +2
$dataType = PHPExcel_Cell_DataType::TYPE_ERROR;
$value = self::_mapErrorCode(ord($recordData{8}));
} elseif ((ord($recordData{6}) == 3)
&& (ord($recordData{12}) == 255)
&& (ord($recordData{13}) == 255)) {
// Formula result is a null string
$dataType = PHPExcel_Cell_DataType::TYPE_NULL;
$value = '';
} else {
// forumla result is a number, first 14 bytes like _NUMBER record
$dataType = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$value = self::_extractNumber(substr($recordData, 6, 8));
}
$cell = $this->_phpSheet->getCell($columnString . ($row + 1));
if (!$this->_readDataOnly) {
// add cell style
$cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
// store the formula
if (!$isPartOfSharedFormula) {
// not part of shared formula
// add cell value. If we can read formula, populate with formula, otherwise just used cached value
try {
if ($this->_version != self::XLS_BIFF8) {
throw new Exception('Not BIFF8. Can only read BIFF8 formulas');
}
$formula = $this->_getFormulaFromStructure($formulaStructure); // get formula in human language
$cell->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
} catch (Exception $e) {
$cell->setValueExplicit($value, $dataType);
}
} else {
if ($this->_version == self::XLS_BIFF8) {
// do nothing at this point, formula id added later in the code
} else {
$cell->setValueExplicit($value, $dataType);
}
}
// store the cached calculated value
$cell->setCalculatedValue($value);
}
}
/**
* Read a SHAREDFMLA record. This function just stores the binary shared formula in the reader,
* which usually contains relative references.
* These will be used to construct the formula in each shared formula part after the sheet is read.
*/
private function _readSharedFmla()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0, size: 6; cell range address of the area used by the shared formula, not used for anything
$cellRange = substr($recordData, 0, 6);
$cellRange = $this->_readBIFF5CellRangeAddressFixed($cellRange); // note: even BIFF8 uses BIFF5 syntax
// offset: 6, size: 1; not used
// offset: 7, size: 1; number of existing FORMULA records for this shared formula
$no = ord($recordData{7});
// offset: 8, size: var; Binary token array of the shared formula
$formula = substr($recordData, 8);
// at this point we only store the shared formula for later use
$this->_sharedFormulas[$this->_baseCell] = $formula;
}
/**
* Read a STRING record from current stream position and advance the stream pointer to next record
* This record is used for storing result from FORMULA record when it is a string, and
* it occurs directly after the FORMULA record
*
* @return string The string contents as UTF-8
*/
private function _readString()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_version == self::XLS_BIFF8) {
$string = self::_readUnicodeStringLong($recordData);
$value = $string['value'];
} else {
$string = $this->_readByteStringLong($recordData);
$value = $string['value'];
}
return $value;
}
/**
* Read BOOLERR record
* This record represents a Boolean value or error value
* cell.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readBoolErr()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; row index
$row = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; column index
$column = self::_GetInt2d($recordData, 2);
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: 4; size: 2; index to XF record
$xfIndex = self::_GetInt2d($recordData, 4);
// offset: 6; size: 1; the boolean value or error value
$boolErr = ord($recordData{6});
// offset: 7; size: 1; 0=boolean; 1=error
$isError = ord($recordData{7});
$cell = $this->_phpSheet->getCell($columnString . ($row + 1));
switch ($isError) {
case 0: // boolean
$value = (bool) $boolErr;
// add cell value
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_BOOL);
break;
case 1: // error type
$value = self::_mapErrorCode($boolErr);
// add cell value
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_ERROR);
break;
}
if (!$this->_readDataOnly) {
// add cell style
$cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
/**
* Read MULBLANK record
* This record represents a cell range of empty cells. All
* cells are located in the same row
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readMulBlank()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; index to row
$row = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; index to first column
$fc = self::_GetInt2d($recordData, 2);
// offset: 4; size: 2 x nc; list of indexes to XF records
// add style information
if (!$this->_readDataOnly) {
for ($i = 0; $i < $length / 2 - 3; ++$i) {
$columnString = PHPExcel_Cell::stringFromColumnIndex($fc + $i);
// Read cell?
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
$xfIndex = self::_GetInt2d($recordData, 4 + 2 * $i);
$this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
// offset: 6; size 2; index to last column (not needed)
}
/**
* Read LABEL record
* This record represents a cell that contains a string. In
* BIFF8 it is usually replaced by the LABELSST record.
* Excel still uses this record, if it copies unformatted
* text cells to the clipboard.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readLabel()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; index to row
$row = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; index to column
$column = self::_GetInt2d($recordData, 2);
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
// Read cell?
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: 4; size: 2; XF index
$xfIndex = self::_GetInt2d($recordData, 4);
// add cell value
// todo: what if string is very long? continue record
if ($this->_version == self::XLS_BIFF8) {
$string = self::_readUnicodeStringLong(substr($recordData, 6));
$value = $string['value'];
} else {
$string = $this->_readByteStringLong(substr($recordData, 6));
$value = $string['value'];
}
$cell = $this->_phpSheet->getCell($columnString . ($row + 1));
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
if (!$this->_readDataOnly) {
// add cell style
$cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
/**
* Read BLANK record
*/
private function _readBlank()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; row index
$row = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; col index
$col = self::_GetInt2d($recordData, 2);
$columnString = PHPExcel_Cell::stringFromColumnIndex($col);
// Read cell?
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
// offset: 4; size: 2; XF index
$xfIndex = self::_GetInt2d($recordData, 4);
// add style information
if (!$this->_readDataOnly) {
$this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
/**
* Read MSODRAWING record
*/
private function _readMsoDrawing()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
// get spliced record data
$splicedRecordData = $this->_getSplicedRecordData();
$recordData = $splicedRecordData['recordData'];
$this->_drawingData .= $recordData;
}
/**
* Read OBJ record
*/
private function _readObj()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_readDataOnly || $this->_version != self::XLS_BIFF8) {
return;
}
// recordData consists of an array of subrecords looking like this:
// ft: 2 bytes; ftCmo type (0x15)
// cb: 2 bytes; size in bytes of ftCmo data
// ot: 2 bytes; Object Type
// id: 2 bytes; Object id number
// grbit: 2 bytes; Option Flags
// data: var; subrecord data
// for now, we are just interested in the second subrecord containing the object type
$ftCmoType = self::_GetInt2d($recordData, 0);
$cbCmoSize = self::_GetInt2d($recordData, 2);
$otObjType = self::_GetInt2d($recordData, 4);
$idObjID = self::_GetInt2d($recordData, 6);
$grbitOpts = self::_GetInt2d($recordData, 6);
$this->_objs[] = array(
'ftCmoType' => $ftCmoType,
'cbCmoSize' => $cbCmoSize,
'otObjType' => $otObjType,
'idObjID' => $idObjID,
'grbitOpts' => $grbitOpts
);
$this->textObjRef = $idObjID;
// echo '<b>_readObj()</b><br />';
// var_dump(end($this->_objs));
// echo '<br />';
}
/**
* Read WINDOW2 record
*/
private function _readWindow2()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; option flags
$options = self::_GetInt2d($recordData, 0);
// bit: 1; mask: 0x0002; 0 = do not show gridlines, 1 = show gridlines
$showGridlines = (bool) ((0x0002 & $options) >> 1);
$this->_phpSheet->setShowGridlines($showGridlines);
// bit: 2; mask: 0x0004; 0 = do not show headers, 1 = show headers
$showRowColHeaders = (bool) ((0x0004 & $options) >> 2);
$this->_phpSheet->setShowRowColHeaders($showRowColHeaders);
// bit: 3; mask: 0x0008; 0 = panes are not frozen, 1 = panes are frozen
$this->_frozen = (bool) ((0x0008 & $options) >> 3);
// bit: 6; mask: 0x0040; 0 = columns from left to right, 1 = columns from right to left
$this->_phpSheet->setRightToLeft((bool)((0x0040 & $options) >> 6));
// bit: 10; mask: 0x0400; 0 = sheet not active, 1 = sheet active
$isActive = (bool) ((0x0400 & $options) >> 10);
if ($isActive) {
$this->_phpExcel->setActiveSheetIndex($this->_phpExcel->getIndex($this->_phpSheet));
}
}
/**
* Read SCL record
*/
private function _readScl()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// offset: 0; size: 2; numerator of the view magnification
$numerator = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; numerator of the view magnification
$denumerator = self::_GetInt2d($recordData, 2);
// set the zoom scale (in percent)
$this->_phpSheet->getSheetView()->setZoomScale($numerator * 100 / $denumerator);
}
/**
* Read PANE record
*/
private function _readPane()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; position of vertical split
$px = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; position of horizontal split
$py = self::_GetInt2d($recordData, 2);
if ($this->_frozen) {
// frozen panes
$this->_phpSheet->freezePane(PHPExcel_Cell::stringFromColumnIndex($px) . ($py + 1));
} else {
// unfrozen panes; split windows; not supported by PHPExcel core
}
}
}
/**
* Read SELECTION record. There is one such record for each pane in the sheet.
*/
private function _readSelection()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 1; pane identifier
$paneId = ord($recordData{0});
// offset: 1; size: 2; index to row of the active cell
$r = self::_GetInt2d($recordData, 1);
// offset: 3; size: 2; index to column of the active cell
$c = self::_GetInt2d($recordData, 3);
// offset: 5; size: 2; index into the following cell range list to the
// entry that contains the active cell
$index = self::_GetInt2d($recordData, 5);
// offset: 7; size: var; cell range address list containing all selected cell ranges
$data = substr($recordData, 7);
$cellRangeAddressList = $this->_readBIFF5CellRangeAddressList($data); // note: also BIFF8 uses BIFF5 syntax
$selectedCells = $cellRangeAddressList['cellRangeAddresses'][0];
// first row '1' + last row '16384' indicates that full column is selected (apparently also in BIFF8!)
if (preg_match('/^([A-Z]+1\:[A-Z]+)16384$/', $selectedCells)) {
$selectedCells = preg_replace('/^([A-Z]+1\:[A-Z]+)16384$/', '${1}1048576', $selectedCells);
}
// first row '1' + last row '65536' indicates that full column is selected
if (preg_match('/^([A-Z]+1\:[A-Z]+)65536$/', $selectedCells)) {
$selectedCells = preg_replace('/^([A-Z]+1\:[A-Z]+)65536$/', '${1}1048576', $selectedCells);
}
// first column 'A' + last column 'IV' indicates that full row is selected
if (preg_match('/^(A[0-9]+\:)IV([0-9]+)$/', $selectedCells)) {
$selectedCells = preg_replace('/^(A[0-9]+\:)IV([0-9]+)$/', '${1}XFD${2}', $selectedCells);
}
$this->_phpSheet->setSelectedCells($selectedCells);
}
}
private function _includeCellRangeFiltered($cellRangeAddress)
{
$includeCellRange = true;
if (!is_null($this->getReadFilter())) {
$includeCellRange = false;
$rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($cellRangeAddress);
$rangeBoundaries[1][0]++;
for ($row = $rangeBoundaries[0][1]; $row <= $rangeBoundaries[1][1]; $row++) {
for ($column = $rangeBoundaries[0][0]; $column != $rangeBoundaries[1][0]; $column++) {
if ($this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle())) {
$includeCellRange = true;
break 2;
}
}
}
}
return $includeCellRange;
}
/**
* MERGEDCELLS
*
* This record contains the addresses of merged cell ranges
* in the current sheet.
*
* -- "OpenOffice.org's Documentation of the Microsoft
* Excel File Format"
*/
private function _readMergedCells()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) {
$cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($recordData);
foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) {
if ($this->_includeCellRangeFiltered($cellRangeAddress)) {
$this->_phpSheet->mergeCells($cellRangeAddress);
}
}
}
}
/**
* Read HYPERLINK record
*/
private function _readHyperLink()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer forward to next record
$this->_pos += 4 + $length;
if (!$this->_readDataOnly) {
// offset: 0; size: 8; cell range address of all cells containing this hyperlink
try {
$cellRange = $this->_readBIFF8CellRangeAddressFixed($recordData, 0, 8);
} catch (Exception $e) {
return;
}
// offset: 8, size: 16; GUID of StdLink
// offset: 24, size: 4; unknown value
// offset: 28, size: 4; option flags
// bit: 0; mask: 0x00000001; 0 = no link or extant, 1 = file link or URL
$isFileLinkOrUrl = (0x00000001 & self::_GetInt2d($recordData, 28)) >> 0;
// bit: 1; mask: 0x00000002; 0 = relative path, 1 = absolute path or URL
$isAbsPathOrUrl = (0x00000001 & self::_GetInt2d($recordData, 28)) >> 1;
// bit: 2 (and 4); mask: 0x00000014; 0 = no description
$hasDesc = (0x00000014 & self::_GetInt2d($recordData, 28)) >> 2;
// bit: 3; mask: 0x00000008; 0 = no text, 1 = has text
$hasText = (0x00000008 & self::_GetInt2d($recordData, 28)) >> 3;
// bit: 7; mask: 0x00000080; 0 = no target frame, 1 = has target frame
$hasFrame = (0x00000080 & self::_GetInt2d($recordData, 28)) >> 7;
// bit: 8; mask: 0x00000100; 0 = file link or URL, 1 = UNC path (inc. server name)
$isUNC = (0x00000100 & self::_GetInt2d($recordData, 28)) >> 8;
// offset within record data
$offset = 32;
if ($hasDesc) {
// offset: 32; size: var; character count of description text
$dl = self::_GetInt4d($recordData, 32);
// offset: 36; size: var; character array of description text, no Unicode string header, always 16-bit characters, zero terminated
$desc = self::_encodeUTF16(substr($recordData, 36, 2 * ($dl - 1)), false);
$offset += 4 + 2 * $dl;
}
if ($hasFrame) {
$fl = self::_GetInt4d($recordData, $offset);
$offset += 4 + 2 * $fl;
}
// detect type of hyperlink (there are 4 types)
$hyperlinkType = null;
if ($isUNC) {
$hyperlinkType = 'UNC';
} else if (!$isFileLinkOrUrl) {
$hyperlinkType = 'workbook';
} else if (ord($recordData{$offset}) == 0x03) {
$hyperlinkType = 'local';
} else if (ord($recordData{$offset}) == 0xE0) {
$hyperlinkType = 'URL';
}
switch ($hyperlinkType) {
case 'URL':
// section 5.58.2: Hyperlink containing a URL
// e.g. http://example.org/index.php
// offset: var; size: 16; GUID of URL Moniker
$offset += 16;
// offset: var; size: 4; size (in bytes) of character array of the URL including trailing zero word
$us = self::_GetInt4d($recordData, $offset);
$offset += 4;
// offset: var; size: $us; character array of the URL, no Unicode string header, always 16-bit characters, zero-terminated
$url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false);
$url .= $hasText ? '#' : '';
$offset += $us;
break;
case 'local':
// section 5.58.3: Hyperlink to local file
// examples:
// mydoc.txt
// ../../somedoc.xls#Sheet!A1
// offset: var; size: 16; GUI of File Moniker
$offset += 16;
// offset: var; size: 2; directory up-level count.
$upLevelCount = self::_GetInt2d($recordData, $offset);
$offset += 2;
// offset: var; size: 4; character count of the shortened file path and name, including trailing zero word
$sl = self::_GetInt4d($recordData, $offset);
$offset += 4;
// offset: var; size: sl; character array of the shortened file path and name in 8.3-DOS-format (compressed Unicode string)
$shortenedFilePath = substr($recordData, $offset, $sl);
$shortenedFilePath = self::_encodeUTF16($shortenedFilePath, true);
$shortenedFilePath = substr($shortenedFilePath, 0, -1); // remove trailing zero
$offset += $sl;
// offset: var; size: 24; unknown sequence
$offset += 24;
// extended file path
// offset: var; size: 4; size of the following file link field including string lenth mark
$sz = self::_GetInt4d($recordData, $offset);
$offset += 4;
// only present if $sz > 0
if ($sz > 0) {
// offset: var; size: 4; size of the character array of the extended file path and name
$xl = self::_GetInt4d($recordData, $offset);
$offset += 4;
// offset: var; size 2; unknown
$offset += 2;
// offset: var; size $xl; character array of the extended file path and name.
$extendedFilePath = substr($recordData, $offset, $xl);
$extendedFilePath = self::_encodeUTF16($extendedFilePath, false);
$offset += $xl;
}
// construct the path
$url = str_repeat('..\\', $upLevelCount);
$url .= ($sz > 0) ?
$extendedFilePath : $shortenedFilePath; // use extended path if available
$url .= $hasText ? '#' : '';
break;
case 'UNC':
// section 5.58.4: Hyperlink to a File with UNC (Universal Naming Convention) Path
// todo: implement
return;
case 'workbook':
// section 5.58.5: Hyperlink to the Current Workbook
// e.g. Sheet2!B1:C2, stored in text mark field
$url = 'sheet://';
break;
default:
return;
}
if ($hasText) {
// offset: var; size: 4; character count of text mark including trailing zero word
$tl = self::_GetInt4d($recordData, $offset);
$offset += 4;
// offset: var; size: var; character array of the text mark without the # sign, no Unicode header, always 16-bit characters, zero-terminated
$text = self::_encodeUTF16(substr($recordData, $offset, 2 * ($tl - 1)), false);
$url .= $text;
}
// apply the hyperlink to all the relevant cells
foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cellRange) as $coordinate) {
$this->_phpSheet->getCell($coordinate)->getHyperLink()->setUrl($url);
}
}
}
/**
* Read DATAVALIDATIONS record
*/
private function _readDataValidations()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer forward to next record
$this->_pos += 4 + $length;
}
/**
* Read DATAVALIDATION record
*/
private function _readDataValidation()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer forward to next record
$this->_pos += 4 + $length;
if ($this->_readDataOnly) {
return;
}
// offset: 0; size: 4; Options
$options = self::_GetInt4d($recordData, 0);
// bit: 0-3; mask: 0x0000000F; type
$type = (0x0000000F & $options) >> 0;
switch ($type) {
case 0x00: $type = PHPExcel_Cell_DataValidation::TYPE_NONE; break;
case 0x01: $type = PHPExcel_Cell_DataValidation::TYPE_WHOLE; break;
case 0x02: $type = PHPExcel_Cell_DataValidation::TYPE_DECIMAL; break;
case 0x03: $type = PHPExcel_Cell_DataValidation::TYPE_LIST; break;
case 0x04: $type = PHPExcel_Cell_DataValidation::TYPE_DATE; break;
case 0x05: $type = PHPExcel_Cell_DataValidation::TYPE_TIME; break;
case 0x06: $type = PHPExcel_Cell_DataValidation::TYPE_TEXTLENGTH; break;
case 0x07: $type = PHPExcel_Cell_DataValidation::TYPE_CUSTOM; break;
}
// bit: 4-6; mask: 0x00000070; error type
$errorStyle = (0x00000070 & $options) >> 4;
switch ($errorStyle) {
case 0x00: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; break;
case 0x01: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_WARNING; break;
case 0x02: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_INFORMATION; break;
}
// bit: 7; mask: 0x00000080; 1= formula is explicit (only applies to list)
// I have only seen cases where this is 1
$explicitFormula = (0x00000080 & $options) >> 7;
// bit: 8; mask: 0x00000100; 1= empty cells allowed
$allowBlank = (0x00000100 & $options) >> 8;
// bit: 9; mask: 0x00000200; 1= suppress drop down arrow in list type validity
$suppressDropDown = (0x00000200 & $options) >> 9;
// bit: 18; mask: 0x00040000; 1= show prompt box if cell selected
$showInputMessage = (0x00040000 & $options) >> 18;
// bit: 19; mask: 0x00080000; 1= show error box if invalid values entered
$showErrorMessage = (0x00080000 & $options) >> 19;
// bit: 20-23; mask: 0x00F00000; condition operator
$operator = (0x00F00000 & $options) >> 20;
switch ($operator) {
case 0x00: $operator = PHPExcel_Cell_DataValidation::OPERATOR_BETWEEN ; break;
case 0x01: $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTBETWEEN ; break;
case 0x02: $operator = PHPExcel_Cell_DataValidation::OPERATOR_EQUAL ; break;
case 0x03: $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTEQUAL ; break;
case 0x04: $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHAN ; break;
case 0x05: $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHAN ; break;
case 0x06: $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL; break;
case 0x07: $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHANOREQUAL ; break;
}
// offset: 4; size: var; title of the prompt box
$offset = 4;
$string = self::_readUnicodeStringLong(substr($recordData, $offset));
$promptTitle = $string['value'] !== chr(0) ?
$string['value'] : '';
$offset += $string['size'];
// offset: var; size: var; title of the error box
$string = self::_readUnicodeStringLong(substr($recordData, $offset));
$errorTitle = $string['value'] !== chr(0) ?
$string['value'] : '';
$offset += $string['size'];
// offset: var; size: var; text of the prompt box
$string = self::_readUnicodeStringLong(substr($recordData, $offset));
$prompt = $string['value'] !== chr(0) ?
$string['value'] : '';
$offset += $string['size'];
// offset: var; size: var; text of the error box
$string = self::_readUnicodeStringLong(substr($recordData, $offset));
$error = $string['value'] !== chr(0) ?
$string['value'] : '';
$offset += $string['size'];
// offset: var; size: 2; size of the formula data for the first condition
$sz1 = self::_GetInt2d($recordData, $offset);
$offset += 2;
// offset: var; size: 2; not used
$offset += 2;
// offset: var; size: $sz1; formula data for first condition (without size field)
$formula1 = substr($recordData, $offset, $sz1);
$formula1 = pack('v', $sz1) . $formula1; // prepend the length
try {
$formula1 = $this->_getFormulaFromStructure($formula1);
// in list type validity, null characters are used as item separators
if ($type == PHPExcel_Cell_DataValidation::TYPE_LIST) {
$formula1 = str_replace(chr(0), ',', $formula1);
}
} catch (Exception $e) {
return;
}
$offset += $sz1;
// offset: var; size: 2; size of the formula data for the first condition
$sz2 = self::_GetInt2d($recordData, $offset);
$offset += 2;
// offset: var; size: 2; not used
$offset += 2;
// offset: var; size: $sz2; formula data for second condition (without size field)
$formula2 = substr($recordData, $offset, $sz2);
$formula2 = pack('v', $sz2) . $formula2; // prepend the length
try {
$formula2 = $this->_getFormulaFromStructure($formula2);
} catch (Exception $e) {
return;
}
$offset += $sz2;
// offset: var; size: var; cell range address list with
$cellRangeAddressList = $this->_readBIFF8CellRangeAddressList(substr($recordData, $offset));
$cellRangeAddresses = $cellRangeAddressList['cellRangeAddresses'];
foreach ($cellRangeAddresses as $cellRange) {
$stRange = $this->_phpSheet->shrinkRangeToFit($cellRange);
$stRange = PHPExcel_Cell::extractAllCellReferencesInRange($stRange);
foreach ($stRange as $coordinate) {
$objValidation = $this->_phpSheet->getCell($coordinate)->getDataValidation();
$objValidation->setType($type);
$objValidation->setErrorStyle($errorStyle);
$objValidation->setAllowBlank((bool)$allowBlank);
$objValidation->setShowInputMessage((bool)$showInputMessage);
$objValidation->setShowErrorMessage((bool)$showErrorMessage);
$objValidation->setShowDropDown(!$suppressDropDown);
$objValidation->setOperator($operator);
$objValidation->setErrorTitle($errorTitle);
$objValidation->setError($error);
$objValidation->setPromptTitle($promptTitle);
$objValidation->setPrompt($prompt);
$objValidation->setFormula1($formula1);
$objValidation->setFormula2($formula2);
}
}
}
/**
* Read SHEETLAYOUT record. Stores sheet tab color information.
*/
private function _readSheetLayout()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// local pointer in record data
$offset = 0;
if (!$this->_readDataOnly) {
// offset: 0; size: 2; repeated record identifier 0x0862
// offset: 2; size: 10; not used
// offset: 12; size: 4; size of record data
// Excel 2003 uses size of 0x14 (documented), Excel 2007 uses size of 0x28 (not documented?)
$sz = self::_GetInt4d($recordData, 12);
switch ($sz) {
case 0x14:
// offset: 16; size: 2; color index for sheet tab
$colorIndex = self::_GetInt2d($recordData, 16);
$color = self::_readColor($colorIndex,$this->_palette,$this->_version);
$this->_phpSheet->getTabColor()->setRGB($color['rgb']);
break;
case 0x28:
// TODO: Investigate structure for .xls SHEETLAYOUT record as saved by MS Office Excel 2007
return;
break;
}
}
}
/**
* Read SHEETPROTECTION record (FEATHEADR)
*/
private function _readSheetProtection()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
if ($this->_readDataOnly) {
return;
}
// offset: 0; size: 2; repeated record header
// offset: 2; size: 2; FRT cell reference flag (=0 currently)
// offset: 4; size: 8; Currently not used and set to 0
// offset: 12; size: 2; Shared feature type index (2=Enhanced Protetion, 4=SmartTag)
$isf = self::_GetInt2d($recordData, 12);
if ($isf != 2) {
return;
}
// offset: 14; size: 1; =1 since this is a feat header
// offset: 15; size: 4; size of rgbHdrSData
// rgbHdrSData, assume "Enhanced Protection"
// offset: 19; size: 2; option flags
$options = self::_GetInt2d($recordData, 19);
// bit: 0; mask 0x0001; 1 = user may edit objects, 0 = users must not edit objects
$bool = (0x0001 & $options) >> 0;
$this->_phpSheet->getProtection()->setObjects(!$bool);
// bit: 1; mask 0x0002; edit scenarios
$bool = (0x0002 & $options) >> 1;
$this->_phpSheet->getProtection()->setScenarios(!$bool);
// bit: 2; mask 0x0004; format cells
$bool = (0x0004 & $options) >> 2;
$this->_phpSheet->getProtection()->setFormatCells(!$bool);
// bit: 3; mask 0x0008; format columns
$bool = (0x0008 & $options) >> 3;
$this->_phpSheet->getProtection()->setFormatColumns(!$bool);
// bit: 4; mask 0x0010; format rows
$bool = (0x0010 & $options) >> 4;
$this->_phpSheet->getProtection()->setFormatRows(!$bool);
// bit: 5; mask 0x0020; insert columns
$bool = (0x0020 & $options) >> 5;
$this->_phpSheet->getProtection()->setInsertColumns(!$bool);
// bit: 6; mask 0x0040; insert rows
$bool = (0x0040 & $options) >> 6;
$this->_phpSheet->getProtection()->setInsertRows(!$bool);
// bit: 7; mask 0x0080; insert hyperlinks
$bool = (0x0080 & $options) >> 7;
$this->_phpSheet->getProtection()->setInsertHyperlinks(!$bool);
// bit: 8; mask 0x0100; delete columns
$bool = (0x0100 & $options) >> 8;
$this->_phpSheet->getProtection()->setDeleteColumns(!$bool);
// bit: 9; mask 0x0200; delete rows
$bool = (0x0200 & $options) >> 9;
$this->_phpSheet->getProtection()->setDeleteRows(!$bool);
// bit: 10; mask 0x0400; select locked cells
$bool = (0x0400 & $options) >> 10;
$this->_phpSheet->getProtection()->setSelectLockedCells(!$bool);
// bit: 11; mask 0x0800; sort cell range
$bool = (0x0800 & $options) >> 11;
$this->_phpSheet->getProtection()->setSort(!$bool);
// bit: 12; mask 0x1000; auto filter
$bool = (0x1000 & $options) >> 12;
$this->_phpSheet->getProtection()->setAutoFilter(!$bool);
// bit: 13; mask 0x2000; pivot tables
$bool = (0x2000 & $options) >> 13;
$this->_phpSheet->getProtection()->setPivotTables(!$bool);
// bit: 14; mask 0x4000; select unlocked cells
$bool = (0x4000 & $options) >> 14;
$this->_phpSheet->getProtection()->setSelectUnlockedCells(!$bool);
// offset: 21; size: 2; not used
}
/**
* Read RANGEPROTECTION record
* Reading of this record is based on Microsoft Office Excel 97-2000 Binary File Format Specification,
* where it is referred to as FEAT record
*/
private function _readRangeProtection()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// move stream pointer to next record
$this->_pos += 4 + $length;
// local pointer in record data
$offset = 0;
if (!$this->_readDataOnly) {
$offset += 12;
// offset: 12; size: 2; shared feature type, 2 = enhanced protection, 4 = smart tag
$isf = self::_GetInt2d($recordData, 12);
if ($isf != 2) {
// we only read FEAT records of type 2
return;
}
$offset += 2;
$offset += 5;
// offset: 19; size: 2; count of ref ranges this feature is on
$cref = self::_GetInt2d($recordData, 19);
$offset += 2;
$offset += 6;
// offset: 27; size: 8 * $cref; list of cell ranges (like in hyperlink record)
$cellRanges = array();
for ($i = 0; $i < $cref; ++$i) {
try {
$cellRange = $this->_readBIFF8CellRangeAddressFixed(substr($recordData, 27 + 8 * $i, 8));
} catch (Exception $e) {
return;
}
$cellRanges[] = $cellRange;
$offset += 8;
}
// offset: var; size: var; variable length of feature specific data
$rgbFeat = substr($recordData, $offset);
$offset += 4;
// offset: var; size: 4; the encrypted password (only 16-bit although field is 32-bit)
$wPassword = self::_GetInt4d($recordData, $offset);
$offset += 4;
// Apply range protection to sheet
if ($cellRanges) {
$this->_phpSheet->protectCells(implode(' ', $cellRanges), strtoupper(dechex($wPassword)), true);
}
}
}
/**
* Read IMDATA record
*/
private function _readImData()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
// get spliced record data
$splicedRecordData = $this->_getSplicedRecordData();
$recordData = $splicedRecordData['recordData'];
// UNDER CONSTRUCTION
// offset: 0; size: 2; image format
$cf = self::_GetInt2d($recordData, 0);
// offset: 2; size: 2; environment from which the file was written
$env = self::_GetInt2d($recordData, 2);
// offset: 4; size: 4; length of the image data
$lcb = self::_GetInt4d($recordData, 4);
// offset: 8; size: var; image data
$iData = substr($recordData, 8);
switch ($cf) {
case 0x09: // Windows bitmap format
// BITMAPCOREINFO
// 1. BITMAPCOREHEADER
// offset: 0; size: 4; bcSize, Specifies the number of bytes required by the structure
$bcSize = self::_GetInt4d($iData, 0);
// var_dump($bcSize);
// offset: 4; size: 2; bcWidth, specifies the width of the bitmap, in pixels
$bcWidth = self::_GetInt2d($iData, 4);
// var_dump($bcWidth);
// offset: 6; size: 2; bcHeight, specifies the height of the bitmap, in pixels.
$bcHeight = self::_GetInt2d($iData, 6);
// var_dump($bcHeight);
$ih = imagecreatetruecolor($bcWidth, $bcHeight);
// offset: 8; size: 2; bcPlanes, specifies the number of planes for the target device. This value must be 1
// offset: 10; size: 2; bcBitCount specifies the number of bits-per-pixel. This value must be 1, 4, 8, or 24
$bcBitCount = self::_GetInt2d($iData, 10);
// var_dump($bcBitCount);
$rgbString = substr($iData, 12);
$rgbTriples = array();
while (strlen($rgbString) > 0) {
$rgbTriples[] = unpack('Cb/Cg/Cr', $rgbString);
$rgbString = substr($rgbString, 3);
}
$x = 0;
$y = 0;
foreach ($rgbTriples as $i => $rgbTriple) {
$color = imagecolorallocate($ih, $rgbTriple['r'], $rgbTriple['g'], $rgbTriple['b']);
imagesetpixel($ih, $x, $bcHeight - 1 - $y, $color);
$x = ($x + 1) % $bcWidth;
$y = $y + floor(($x + 1) / $bcWidth);
}
//imagepng($ih, 'image.png');
$drawing = new PHPExcel_Worksheet_Drawing();
$drawing->setPath($filename);
$drawing->setWorksheet($this->_phpSheet);
break;
case 0x02: // Windows metafile or Macintosh PICT format
case 0x0e: // native format
default;
break;
}
// _getSplicedRecordData() takes care of moving current position in data stream
}
/**
* Read a free CONTINUE record. Free CONTINUE record may be a camouflaged MSODRAWING record
* When MSODRAWING data on a sheet exceeds 8224 bytes, CONTINUE records are used instead. Undocumented.
* In this case, we must treat the CONTINUE record as a MSODRAWING record
*/
private function _readContinue()
{
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
// check if we are reading drawing data
// this is in case a free CONTINUE record occurs in other circumstances we are unaware of
if ($this->_drawingData == '') {
// move stream pointer to next record
$this->_pos += 4 + $length;
return;
}
// check if record data is at least 4 bytes long, otherwise there is no chance this is MSODRAWING data
if ($length < 4) {
// move stream pointer to next record
$this->_pos += 4 + $length;
return;
}
// dirty check to see if CONTINUE record could be a camouflaged MSODRAWING record
// look inside CONTINUE record to see if it looks like a part of an Escher stream
// we know that Escher stream may be split at least at
// 0xF003 MsofbtSpgrContainer
// 0xF004 MsofbtSpContainer
// 0xF00D MsofbtClientTextbox
$validSplitPoints = array(0xF003, 0xF004, 0xF00D); // add identifiers if we find more
$splitPoint = self::_GetInt2d($recordData, 2);
if (in_array($splitPoint, $validSplitPoints)) {
// get spliced record data (and move pointer to next record)
$splicedRecordData = $this->_getSplicedRecordData();
$this->_drawingData .= $splicedRecordData['recordData'];
return;
}
// move stream pointer to next record
$this->_pos += 4 + $length;
}
/**
* Reads a record from current position in data stream and continues reading data as long as CONTINUE
* records are found. Splices the record data pieces and returns the combined string as if record data
* is in one piece.
* Moves to next current position in data stream to start of next record different from a CONtINUE record
*
* @return array
*/
private function _getSplicedRecordData()
{
$data = '';
$spliceOffsets = array();
$i = 0;
$spliceOffsets[0] = 0;
do {
++$i;
// offset: 0; size: 2; identifier
$identifier = self::_GetInt2d($this->_data, $this->_pos);
// offset: 2; size: 2; length
$length = self::_GetInt2d($this->_data, $this->_pos + 2);
$data .= substr($this->_data, $this->_pos + 4, $length);
$spliceOffsets[$i] = $spliceOffsets[$i - 1] + $length;
$this->_pos += 4 + $length;
$nextIdentifier = self::_GetInt2d($this->_data, $this->_pos);
}
while ($nextIdentifier == self::XLS_Type_CONTINUE);
$splicedData = array(
'recordData' => $data,
'spliceOffsets' => $spliceOffsets,
);
return $splicedData;
}
/**
* Convert formula structure into human readable Excel formula like 'A3+A5*5'
*
* @param string $formulaStructure The complete binary data for the formula
* @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas
* @return string Human readable formula
*/
private function _getFormulaFromStructure($formulaStructure, $baseCell = 'A1')
{
// offset: 0; size: 2; size of the following formula data
$sz = self::_GetInt2d($formulaStructure, 0);
// offset: 2; size: sz
$formulaData = substr($formulaStructure, 2, $sz);
// for debug: dump the formula data
//echo '<xmp>';
//echo 'size: ' . $sz . "\n";
//echo 'the entire formula data: ';
//Debug::dump($formulaData);
//echo "\n----\n";
// offset: 2 + sz; size: variable (optional)
if (strlen($formulaStructure) > 2 + $sz) {
$additionalData = substr($formulaStructure, 2 + $sz);
// for debug: dump the additional data
//echo 'the entire additional data: ';
//Debug::dump($additionalData);
//echo "\n----\n";
} else {
$additionalData = '';
}
return $this->_getFormulaFromData($formulaData, $additionalData, $baseCell);
}
/**
* Take formula data and additional data for formula and return human readable formula
*
* @param string $formulaData The binary data for the formula itself
* @param string $additionalData Additional binary data going with the formula
* @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas
* @return string Human readable formula
*/
private function _getFormulaFromData($formulaData, $additionalData = '', $baseCell = 'A1')
{
// start parsing the formula data
$tokens = array();
while (strlen($formulaData) > 0 and $token = $this->_getNextToken($formulaData, $baseCell)) {
$tokens[] = $token;
$formulaData = substr($formulaData, $token['size']);
// for debug: dump the token
//var_dump($token);
}
$formulaString = $this->_createFormulaFromTokens($tokens, $additionalData);
return $formulaString;
}
/**
* Take array of tokens together with additional data for formula and return human readable formula
*
* @param array $tokens
* @param array $additionalData Additional binary data going with the formula
* @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas
* @return string Human readable formula
*/
private function _createFormulaFromTokens($tokens, $additionalData)
{
// empty formula?
if (count($tokens) == 0) {
return '';
}
$formulaStrings = array();
foreach ($tokens as $token) {
// initialize spaces
$space0 = isset($space0) ? $space0 : ''; // spaces before next token, not tParen
$space1 = isset($space1) ? $space1 : ''; // carriage returns before next token, not tParen
$space2 = isset($space2) ? $space2 : ''; // spaces before opening parenthesis
$space3 = isset($space3) ? $space3 : ''; // carriage returns before opening parenthesis
$space4 = isset($space4) ? $space4 : ''; // spaces before closing parenthesis
$space5 = isset($space5) ? $space5 : ''; // carriage returns before closing parenthesis
switch ($token['name']) {
case 'tAdd': // addition
case 'tConcat': // addition
case 'tDiv': // division
case 'tEQ': // equality
case 'tGE': // greater than or equal
case 'tGT': // greater than
case 'tIsect': // intersection
case 'tLE': // less than or equal
case 'tList': // less than or equal
case 'tLT': // less than
case 'tMul': // multiplication
case 'tNE': // multiplication
case 'tPower': // power
case 'tRange': // range
case 'tSub': // subtraction
$op2 = array_pop($formulaStrings);
$op1 = array_pop($formulaStrings);
$formulaStrings[] = "$op1$space1$space0{$token['data']}$op2";
unset($space0, $space1);
break;
case 'tUplus': // unary plus
case 'tUminus': // unary minus
$op = array_pop($formulaStrings);
$formulaStrings[] = "$space1$space0{$token['data']}$op";
unset($space0, $space1);
break;
case 'tPercent': // percent sign
$op = array_pop($formulaStrings);
$formulaStrings[] = "$op$space1$space0{$token['data']}";
unset($space0, $space1);
break;
case 'tAttrVolatile': // indicates volatile function
case 'tAttrIf':
case 'tAttrSkip':
case 'tAttrChoose':
// token is only important for Excel formula evaluator
// do nothing
break;
case 'tAttrSpace': // space / carriage return
// space will be used when next token arrives, do not alter formulaString stack
switch ($token['data']['spacetype']) {
case 'type0':
$space0 = str_repeat(' ', $token['data']['spacecount']);
break;
case 'type1':
$space1 = str_repeat("\n", $token['data']['spacecount']);
break;
case 'type2':
$space2 = str_repeat(' ', $token['data']['spacecount']);
break;
case 'type3':
$space3 = str_repeat("\n", $token['data']['spacecount']);
break;
case 'type4':
$space4 = str_repeat(' ', $token['data']['spacecount']);
break;
case 'type5':
$space5 = str_repeat("\n", $token['data']['spacecount']);
break;
}
break;
case 'tAttrSum': // SUM function with one parameter
$op = array_pop($formulaStrings);
$formulaStrings[] = "{$space1}{$space0}SUM($op)";
unset($space0, $space1);
break;
case 'tFunc': // function with fixed number of arguments
case 'tFuncV': // function with variable number of arguments
if ($token['data']['function'] != '') {
// normal function
$ops = array(); // array of operators
for ($i = 0; $i < $token['data']['args']; ++$i) {
$ops[] = array_pop($formulaStrings);
}
$ops = array_reverse($ops);
$formulaStrings[] = "$space1$space0{$token['data']['function']}(" . implode(',', $ops) . ")";
unset($space0, $space1);
} else {
// add-in function
$ops = array(); // array of operators
for ($i = 0; $i < $token['data']['args'] - 1; ++$i) {
$ops[] = array_pop($formulaStrings);
}
$ops = array_reverse($ops);
$function = array_pop($formulaStrings);
$formulaStrings[] = "$space1$space0$function(" . implode(',', $ops) . ")";
unset($space0, $space1);
}
break;
case 'tParen': // parenthesis
$expression = array_pop($formulaStrings);
$formulaStrings[] = "$space3$space2($expression$space5$space4)";
unset($space2, $space3, $space4, $space5);
break;
case 'tArray': // array constant
$constantArray = self::_readBIFF8ConstantArray($additionalData);
$formulaStrings[] = $space1 . $space0 . $constantArray['value'];
$additionalData = substr($additionalData, $constantArray['size']); // bite of chunk of additional data
unset($space0, $space1);
break;
case 'tMemArea':
// bite off chunk of additional data
$cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($additionalData);
$additionalData = substr($additionalData, $cellRangeAddressList['size']);
$formulaStrings[] = "$space1$space0{$token['data']}";
unset($space0, $space1);
break;
case 'tArea': // cell range address
case 'tBool': // boolean
case 'tErr': // error code
case 'tInt': // integer
case 'tMemErr':
case 'tMemFunc':
case 'tMissArg':
case 'tName':
case 'tNameX':
case 'tNum': // number
case 'tRef': // single cell reference
case 'tRef3d': // 3d cell reference
case 'tArea3d': // 3d cell range reference
case 'tRefN':
case 'tAreaN':
case 'tStr': // string
$formulaStrings[] = "$space1$space0{$token['data']}";
unset($space0, $space1);
break;
}
}
$formulaString = $formulaStrings[0];
// for debug: dump the human readable formula
//echo '----' . "\n";
//echo 'Formula: ' . $formulaString;
return $formulaString;
}
/**
* Fetch next token from binary formula data
*
* @param string Formula data
* @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas
* @return array
* @throws Exception
*/
private function _getNextToken($formulaData, $baseCell = 'A1')
{
// offset: 0; size: 1; token id
$id = ord($formulaData[0]); // token id
$name = false; // initialize token name
switch ($id) {
case 0x03: $name = 'tAdd'; $size = 1; $data = '+'; break;
case 0x04: $name = 'tSub'; $size = 1; $data = '-'; break;
case 0x05: $name = 'tMul'; $size = 1; $data = '*'; break;
case 0x06: $name = 'tDiv'; $size = 1; $data = '/'; break;
case 0x07: $name = 'tPower'; $size = 1; $data = '^'; break;
case 0x08: $name = 'tConcat'; $size = 1; $data = '&'; break;
case 0x09: $name = 'tLT'; $size = 1; $data = '<'; break;
case 0x0A: $name = 'tLE'; $size = 1; $data = '<='; break;
case 0x0B: $name = 'tEQ'; $size = 1; $data = '='; break;
case 0x0C: $name = 'tGE'; $size = 1; $data = '>='; break;
case 0x0D: $name = 'tGT'; $size = 1; $data = '>'; break;
case 0x0E: $name = 'tNE'; $size = 1; $data = '<>'; break;
case 0x0F: $name = 'tIsect'; $size = 1; $data = ' '; break;
case 0x10: $name = 'tList'; $size = 1; $data = ','; break;
case 0x11: $name = 'tRange'; $size = 1; $data = ':'; break;
case 0x12: $name = 'tUplus'; $size = 1; $data = '+'; break;
case 0x13: $name = 'tUminus'; $size = 1; $data = '-'; break;
case 0x14: $name = 'tPercent'; $size = 1; $data = '%'; break;
case 0x15: // parenthesis
$name = 'tParen';
$size = 1;
$data = null;
break;
case 0x16: // missing argument
$name = 'tMissArg';
$size = 1;
$data = '';
break;
case 0x17: // string
$name = 'tStr';
// offset: 1; size: var; Unicode string, 8-bit string length
$string = self::_readUnicodeStringShort(substr($formulaData, 1));
$size = 1 + $string['size'];
$data = self::_UTF8toExcelDoubleQuoted($string['value']);
break;
case 0x19: // Special attribute
// offset: 1; size: 1; attribute type flags:
switch (ord($formulaData[1])) {
case 0x01:
$name = 'tAttrVolatile';
$size = 4;
$data = null;
break;
case 0x02:
$name = 'tAttrIf';
$size = 4;
$data = null;
break;
case 0x04:
$name = 'tAttrChoose';
// offset: 2; size: 2; number of choices in the CHOOSE function ($nc, number of parameters decreased by 1)
$nc = self::_GetInt2d($formulaData, 2);
// offset: 4; size: 2 * $nc
// offset: 4 + 2 * $nc; size: 2
$size = 2 * $nc + 6;
$data = null;
break;
case 0x08:
$name = 'tAttrSkip';
$size = 4;
$data = null;
break;
case 0x10:
$name = 'tAttrSum';
$size = 4;
$data = null;
break;
case 0x40:
case 0x41:
$name = 'tAttrSpace';
$size = 4;
// offset: 2; size: 2; space type and position
switch (ord($formulaData[2])) {
case 0x00:
$spacetype = 'type0';
break;
case 0x01:
$spacetype = 'type1';
break;
case 0x02:
$spacetype = 'type2';
break;
case 0x03:
$spacetype = 'type3';
break;
case 0x04:
$spacetype = 'type4';
break;
case 0x05:
$spacetype = 'type5';
break;
default:
throw new Exception('Unrecognized space type in tAttrSpace token');
break;
}
// offset: 3; size: 1; number of inserted spaces/carriage returns
$spacecount = ord($formulaData[3]);
$data = array('spacetype' => $spacetype, 'spacecount' => $spacecount);
break;
default:
throw new Exception('Unrecognized attribute flag in tAttr token');
break;
}
break;
case 0x1C: // error code
// offset: 1; size: 1; error code
$name = 'tErr';
$size = 2;
$data = self::_mapErrorCode(ord($formulaData[1]));
break;
case 0x1D: // boolean
// offset: 1; size: 1; 0 = false, 1 = true;
$name = 'tBool';
$size = 2;
$data = ord($formulaData[1]) ? 'TRUE' : 'FALSE';
break;
case 0x1E: // integer
// offset: 1; size: 2; unsigned 16-bit integer
$name = 'tInt';
$size = 3;
$data = self::_GetInt2d($formulaData, 1);
break;
case 0x1F: // number
// offset: 1; size: 8;
$name = 'tNum';
$size = 9;
$data = self::_extractNumber(substr($formulaData, 1));
$data = str_replace(',', '.', (string)$data); // in case non-English locale
break;
case 0x20: // array constant
case 0x40:
case 0x60:
// offset: 1; size: 7; not used
$name = 'tArray';
$size = 8;
$data = null;
break;
case 0x21: // function with fixed number of arguments
case 0x41:
case 0x61:
$name = 'tFunc';
$size = 3;
// offset: 1; size: 2; index to built-in sheet function
switch (self::_GetInt2d($formulaData, 1)) {
case 2: $function = 'ISNA'; $args = 1; break;
case 3: $function = 'ISERROR'; $args = 1; break;
case 10: $function = 'NA'; $args = 0; break;
case 15: $function = 'SIN'; $args = 1; break;
case 16: $function = 'COS'; $args = 1; break;
case 17: $function = 'TAN'; $args = 1; break;
case 18: $function = 'ATAN'; $args = 1; break;
case 19: $function = 'PI'; $args = 0; break;
case 20: $function = 'SQRT'; $args = 1; break;
case 21: $function = 'EXP'; $args = 1; break;
case 22: $function = 'LN'; $args = 1; break;
case 23: $function = 'LOG10'; $args = 1; break;
case 24: $function = 'ABS'; $args = 1; break;
case 25: $function = 'INT'; $args = 1; break;
case 26: $function = 'SIGN'; $args = 1; break;
case 27: $function = 'ROUND'; $args = 2; break;
case 30: $function = 'REPT'; $args = 2; break;
case 31: $function = 'MID'; $args = 3; break;
case 32: $function = 'LEN'; $args = 1; break;
case 33: $function = 'VALUE'; $args = 1; break;
case 34: $function = 'TRUE'; $args = 0; break;
case 35: $function = 'FALSE'; $args = 0; break;
case 38: $function = 'NOT'; $args = 1; break;
case 39: $function = 'MOD'; $args = 2; break;
case 40: $function = 'DCOUNT'; $args = 3; break;
case 41: $function = 'DSUM'; $args = 3; break;
case 42: $function = 'DAVERAGE'; $args = 3; break;
case 43: $function = 'DMIN'; $args = 3; break;
case 44: $function = 'DMAX'; $args = 3; break;
case 45: $function = 'DSTDEV'; $args = 3; break;
case 48: $function = 'TEXT'; $args = 2; break;
case 61: $function = 'MIRR'; $args = 3; break;
case 63: $function = 'RAND'; $args = 0; break;
case 65: $function = 'DATE'; $args = 3; break;
case 66: $function = 'TIME'; $args = 3; break;
case 67: $function = 'DAY'; $args = 1; break;
case 68: $function = 'MONTH'; $args = 1; break;
case 69: $function = 'YEAR'; $args = 1; break;
case 71: $function = 'HOUR'; $args = 1; break;
case 72: $function = 'MINUTE'; $args = 1; break;
case 73: $function = 'SECOND'; $args = 1; break;
case 74: $function = 'NOW'; $args = 0; break;
case 75: $function = 'AREAS'; $args = 1; break;
case 76: $function = 'ROWS'; $args = 1; break;
case 77: $function = 'COLUMNS'; $args = 1; break;
case 83: $function = 'TRANSPOSE'; $args = 1; break;
case 86: $function = 'TYPE'; $args = 1; break;
case 97: $function = 'ATAN2'; $args = 2; break;
case 98: $function = 'ASIN'; $args = 1; break;
case 99: $function = 'ACOS'; $args = 1; break;
case 105: $function = 'ISREF'; $args = 1; break;
case 111: $function = 'CHAR'; $args = 1; break;
case 112: $function = 'LOWER'; $args = 1; break;
case 113: $function = 'UPPER'; $args = 1; break;
case 114: $function = 'PROPER'; $args = 1; break;
case 117: $function = 'EXACT'; $args = 2; break;
case 118: $function = 'TRIM'; $args = 1; break;
case 119: $function = 'REPLACE'; $args = 4; break;
case 121: $function = 'CODE'; $args = 1; break;
case 126: $function = 'ISERR'; $args = 1; break;
case 127: $function = 'ISTEXT'; $args = 1; break;
case 128: $function = 'ISNUMBER'; $args = 1; break;
case 129: $function = 'ISBLANK'; $args = 1; break;
case 130: $function = 'T'; $args = 1; break;
case 131: $function = 'N'; $args = 1; break;
case 140: $function = 'DATEVALUE'; $args = 1; break;
case 141: $function = 'TIMEVALUE'; $args = 1; break;
case 142: $function = 'SLN'; $args = 3; break;
case 143: $function = 'SYD'; $args = 4; break;
case 162: $function = 'CLEAN'; $args = 1; break;
case 163: $function = 'MDETERM'; $args = 1; break;
case 164: $function = 'MINVERSE'; $args = 1; break;
case 165: $function = 'MMULT'; $args = 2; break;
case 184: $function = 'FACT'; $args = 1; break;
case 189: $function = 'DPRODUCT'; $args = 3; break;
case 190: $function = 'ISNONTEXT'; $args = 1; break;
case 195: $function = 'DSTDEVP'; $args = 3; break;
case 196: $function = 'DVARP'; $args = 3; break;
case 198: $function = 'ISLOGICAL'; $args = 1; break;
case 199: $function = 'DCOUNTA'; $args = 3; break;
case 207: $function = 'REPLACEB'; $args = 4; break;
case 210: $function = 'MIDB'; $args = 3; break;
case 211: $function = 'LENB'; $args = 1; break;
case 212: $function = 'ROUNDUP'; $args = 2; break;
case 213: $function = 'ROUNDDOWN'; $args = 2; break;
case 214: $function = 'ASC'; $args = 1; break;
case 215: $function = 'DBCS'; $args = 1; break;
case 221: $function = 'TODAY'; $args = 0; break;
case 229: $function = 'SINH'; $args = 1; break;
case 230: $function = 'COSH'; $args = 1; break;
case 231: $function = 'TANH'; $args = 1; break;
case 232: $function = 'ASINH'; $args = 1; break;
case 233: $function = 'ACOSH'; $args = 1; break;
case 234: $function = 'ATANH'; $args = 1; break;
case 235: $function = 'DGET'; $args = 3; break;
case 244: $function = 'INFO'; $args = 1; break;
case 252: $function = 'FREQUENCY'; $args = 2; break;
case 261: $function = 'ERROR.TYPE'; $args = 1; break;
case 271: $function = 'GAMMALN'; $args = 1; break;
case 273: $function = 'BINOMDIST'; $args = 4; break;
case 274: $function = 'CHIDIST'; $args = 2; break;
case 275: $function = 'CHIINV'; $args = 2; break;
case 276: $function = 'COMBIN'; $args = 2; break;
case 277: $function = 'CONFIDENCE'; $args = 3; break;
case 278: $function = 'CRITBINOM'; $args = 3; break;
case 279: $function = 'EVEN'; $args = 1; break;
case 280: $function = 'EXPONDIST'; $args = 3; break;
case 281: $function = 'FDIST'; $args = 3; break;
case 282: $function = 'FINV'; $args = 3; break;
case 283: $function = 'FISHER'; $args = 1; break;
case 284: $function = 'FISHERINV'; $args = 1; break;
case 285: $function = 'FLOOR'; $args = 2; break;
case 286: $function = 'GAMMADIST'; $args = 4; break;
case 287: $function = 'GAMMAINV'; $args = 3; break;
case 288: $function = 'CEILING'; $args = 2; break;
case 289: $function = 'HYPGEOMDIST'; $args = 4; break;
case 290: $function = 'LOGNORMDIST'; $args = 3; break;
case 291: $function = 'LOGINV'; $args = 3; break;
case 292: $function = 'NEGBINOMDIST'; $args = 3; break;
case 293: $function = 'NORMDIST'; $args = 4; break;
case 294: $function = 'NORMSDIST'; $args = 1; break;
case 295: $function = 'NORMINV'; $args = 3; break;
case 296: $function = 'NORMSINV'; $args = 1; break;
case 297: $function = 'STANDARDIZE'; $args = 3; break;
case 298: $function = 'ODD'; $args = 1; break;
case 299: $function = 'PERMUT'; $args = 2; break;
case 300: $function = 'POISSON'; $args = 3; break;
case 301: $function = 'TDIST'; $args = 3; break;
case 302: $function = 'WEIBULL'; $args = 4; break;
case 303: $function = 'SUMXMY2'; $args = 2; break;
case 304: $function = 'SUMX2MY2'; $args = 2; break;
case 305: $function = 'SUMX2PY2'; $args = 2; break;
case 306: $function = 'CHITEST'; $args = 2; break;
case 307: $function = 'CORREL'; $args = 2; break;
case 308: $function = 'COVAR'; $args = 2; break;
case 309: $function = 'FORECAST'; $args = 3; break;
case 310: $function = 'FTEST'; $args = 2; break;
case 311: $function = 'INTERCEPT'; $args = 2; break;
case 312: $function = 'PEARSON'; $args = 2; break;
case 313: $function = 'RSQ'; $args = 2; break;
case 314: $function = 'STEYX'; $args = 2; break;
case 315: $function = 'SLOPE'; $args = 2; break;
case 316: $function = 'TTEST'; $args = 4; break;
case 325: $function = 'LARGE'; $args = 2; break;
case 326: $function = 'SMALL'; $args = 2; break;
case 327: $function = 'QUARTILE'; $args = 2; break;
case 328: $function = 'PERCENTILE'; $args = 2; break;
case 331: $function = 'TRIMMEAN'; $args = 2; break;
case 332: $function = 'TINV'; $args = 2; break;
case 337: $function = 'POWER'; $args = 2; break;
case 342: $function = 'RADIANS'; $args = 1; break;
case 343: $function = 'DEGREES'; $args = 1; break;
case 346: $function = 'COUNTIF'; $args = 2; break;
case 347: $function = 'COUNTBLANK'; $args = 1; break;
case 350: $function = 'ISPMT'; $args = 4; break;
case 351: $function = 'DATEDIF'; $args = 3; break;
case 352: $function = 'DATESTRING'; $args = 1; break;
case 353: $function = 'NUMBERSTRING'; $args = 2; break;
case 360: $function = 'PHONETIC'; $args = 1; break;
case 368: $function = 'BAHTTEXT'; $args = 1; break;
default:
throw new Exception('Unrecognized function in formula');
break;
}
$data = array('function' => $function, 'args' => $args);
break;
case 0x22: // function with variable number of arguments
case 0x42:
case 0x62:
$name = 'tFuncV';
$size = 4;
// offset: 1; size: 1; number of arguments
$args = ord($formulaData[1]);
// offset: 2: size: 2; index to built-in sheet function
$index = self::_GetInt2d($formulaData, 2);
switch ($index) {
case 0: $function = 'COUNT'; break;
case 1: $function = 'IF'; break;
case 4: $function = 'SUM'; break;
case 5: $function = 'AVERAGE'; break;
case 6: $function = 'MIN'; break;
case 7: $function = 'MAX'; break;
case 8: $function = 'ROW'; break;
case 9: $function = 'COLUMN'; break;
case 11: $function = 'NPV'; break;
case 12: $function = 'STDEV'; break;
case 13: $function = 'DOLLAR'; break;
case 14: $function = 'FIXED'; break;
case 28: $function = 'LOOKUP'; break;
case 29: $function = 'INDEX'; break;
case 36: $function = 'AND'; break;
case 37: $function = 'OR'; break;
case 46: $function = 'VAR'; break;
case 49: $function = 'LINEST'; break;
case 50: $function = 'TREND'; break;
case 51: $function = 'LOGEST'; break;
case 52: $function = 'GROWTH'; break;
case 56: $function = 'PV'; break;
case 57: $function = 'FV'; break;
case 58: $function = 'NPER'; break;
case 59: $function = 'PMT'; break;
case 60: $function = 'RATE'; break;
case 62: $function = 'IRR'; break;
case 64: $function = 'MATCH'; break;
case 70: $function = 'WEEKDAY'; break;
case 78: $function = 'OFFSET'; break;
case 82: $function = 'SEARCH'; break;
case 100: $function = 'CHOOSE'; break;
case 101: $function = 'HLOOKUP'; break;
case 102: $function = 'VLOOKUP'; break;
case 109: $function = 'LOG'; break;
case 115: $function = 'LEFT'; break;
case 116: $function = 'RIGHT'; break;
case 120: $function = 'SUBSTITUTE'; break;
case 124: $function = 'FIND'; break;
case 125: $function = 'CELL'; break;
case 144: $function = 'DDB'; break;
case 148: $function = 'INDIRECT'; break;
case 167: $function = 'IPMT'; break;
case 168: $function = 'PPMT'; break;
case 169: $function = 'COUNTA'; break;
case 183: $function = 'PRODUCT'; break;
case 193: $function = 'STDEVP'; break;
case 194: $function = 'VARP'; break;
case 197: $function = 'TRUNC'; break;
case 204: $function = 'USDOLLAR'; break;
case 205: $function = 'FINDB'; break;
case 206: $function = 'SEARCHB'; break;
case 208: $function = 'LEFTB'; break;
case 209: $function = 'RIGHTB'; break;
case 216: $function = 'RANK'; break;
case 219: $function = 'ADDRESS'; break;
case 220: $function = 'DAYS360'; break;
case 222: $function = 'VDB'; break;
case 227: $function = 'MEDIAN'; break;
case 228: $function = 'SUMPRODUCT'; break;
case 247: $function = 'DB'; break;
case 255: $function = ''; break;
case 269: $function = 'AVEDEV'; break;
case 270: $function = 'BETADIST'; break;
case 272: $function = 'BETAINV'; break;
case 317: $function = 'PROB'; break;
case 318: $function = 'DEVSQ'; break;
case 319: $function = 'GEOMEAN'; break;
case 320: $function = 'HARMEAN'; break;
case 321: $function = 'SUMSQ'; break;
case 322: $function = 'KURT'; break;
case 323: $function = 'SKEW'; break;
case 324: $function = 'ZTEST'; break;
case 329: $function = 'PERCENTRANK'; break;
case 330: $function = 'MODE'; break;
case 336: $function = 'CONCATENATE'; break;
case 344: $function = 'SUBTOTAL'; break;
case 345: $function = 'SUMIF'; break;
case 354: $function = 'ROMAN'; break;
case 358: $function = 'GETPIVOTDATA'; break;
case 359: $function = 'HYPERLINK'; break;
case 361: $function = 'AVERAGEA'; break;
case 362: $function = 'MAXA'; break;
case 363: $function = 'MINA'; break;
case 364: $function = 'STDEVPA'; break;
case 365: $function = 'VARPA'; break;
case 366: $function = 'STDEVA'; break;
case 367: $function = 'VARA'; break;
default:
throw new Exception('Unrecognized function in formula');
break;
}
$data = array('function' => $function, 'args' => $args);
break;
case 0x23: // index to defined name
case 0x43:
case 0x63:
$name = 'tName';
$size = 5;
// offset: 1; size: 2; one-based index to definedname record
$definedNameIndex = self::_GetInt2d($formulaData, 1) - 1;
// offset: 2; size: 2; not used
$data = $this->_definedname[$definedNameIndex]['name'];
break;
case 0x24: // single cell reference e.g. A5
case 0x44:
case 0x64:
$name = 'tRef';
$size = 5;
$data = $this->_readBIFF8CellAddress(substr($formulaData, 1, 4));
break;
case 0x25: // cell range reference to cells in the same sheet (2d)
case 0x45:
case 0x65:
$name = 'tArea';
$size = 9;
$data = $this->_readBIFF8CellRangeAddress(substr($formulaData, 1, 8));
break;
case 0x26: // Constant reference sub-expression
case 0x46:
case 0x66:
$name = 'tMemArea';
// offset: 1; size: 4; not used
// offset: 5; size: 2; size of the following subexpression
$subSize = self::_GetInt2d($formulaData, 5);
$size = 7 + $subSize;
$data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize));
break;
case 0x27: // Deleted constant reference sub-expression
case 0x47:
case 0x67:
$name = 'tMemErr';
// offset: 1; size: 4; not used
// offset: 5; size: 2; size of the following subexpression
$subSize = self::_GetInt2d($formulaData, 5);
$size = 7 + $subSize;
$data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize));
break;
case 0x29: // Variable reference sub-expression
case 0x49:
case 0x69:
$name = 'tMemFunc';
// offset: 1; size: 2; size of the following sub-expression
$subSize = self::_GetInt2d($formulaData, 1);
$size = 3 + $subSize;
$data = $this->_getFormulaFromData(substr($formulaData, 3, $subSize));
break;
case 0x2C: // Relative 2d cell reference reference, used in shared formulas and some other places
case 0x4C:
case 0x6C:
$name = 'tRefN';
$size = 5;
$data = $this->_readBIFF8CellAddressB(substr($formulaData, 1, 4), $baseCell);
break;
case 0x2D: // Relative 2d range reference
case 0x4D:
case 0x6D:
$name = 'tAreaN';
$size = 9;
$data = $this->_readBIFF8CellRangeAddressB(substr($formulaData, 1, 8), $baseCell);
break;
case 0x39: // External name
case 0x59:
case 0x79:
$name = 'tNameX';
$size = 7;
// offset: 1; size: 2; index to REF entry in EXTERNSHEET record
// offset: 3; size: 2; one-based index to DEFINEDNAME or EXTERNNAME record
$index = self::_GetInt2d($formulaData, 3);
// assume index is to EXTERNNAME record
$data = $this->_externalNames[$index - 1]['name'];
// offset: 5; size: 2; not used
break;
case 0x3A: // 3d reference to cell
case 0x5A:
case 0x7A:
$name = 'tRef3d';
$size = 7;
try {
// offset: 1; size: 2; index to REF entry
$sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1));
// offset: 3; size: 4; cell address
$cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4));
$data = "$sheetRange!$cellAddress";
} catch (Exception $e) {
// deleted sheet reference
$data = '#REF!';
}
break;
case 0x3B: // 3d reference to cell range
case 0x5B:
case 0x7B:
$name = 'tArea3d';
$size = 11;
try {
// offset: 1; size: 2; index to REF entry
$sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1));
// offset: 3; size: 8; cell address
$cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8));
$data = "$sheetRange!$cellRangeAddress";
} catch (Exception $e) {
// deleted sheet reference
$data = '#REF!';
}
break;
// Unknown cases // don't know how to deal with
default:
throw new Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula');
break;
}
return array(
'id' => $id,
'name' => $name,
'size' => $size,
'data' => $data,
);
}
/**
* Reads a cell address in BIFF8 e.g. 'A2' or '$A$2'
* section 3.3.4
*
* @param string $cellAddressStructure
* @return string
*/
private function _readBIFF8CellAddress($cellAddressStructure)
{
// offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767))
$row = self::_GetInt2d($cellAddressStructure, 0) + 1;
// offset: 2; size: 2; index to column or column offset + relative flags
// bit: 7-0; mask 0x00FF; column index
$column = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($cellAddressStructure, 2));
// bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) {
$column = '$' . $column;
}
// bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) {
$row = '$' . $row;
}
return $column . $row;
}
/**
* Reads a cell address in BIFF8 for shared formulas. Uses positive and negative values for row and column
* to indicate offsets from a base cell
* section 3.3.4
*
* @param string $cellAddressStructure
* @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas
* @return string
*/
private function _readBIFF8CellAddressB($cellAddressStructure, $baseCell = 'A1')
{
list($baseCol, $baseRow) = PHPExcel_Cell::coordinateFromString($baseCell);
$baseCol = PHPExcel_Cell::columnIndexFromString($baseCol) - 1;
// offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767))
$rowIndex = self::_GetInt2d($cellAddressStructure, 0);
$row = self::_GetInt2d($cellAddressStructure, 0) + 1;
// offset: 2; size: 2; index to column or column offset + relative flags
// bit: 7-0; mask 0x00FF; column index
$colIndex = 0x00FF & self::_GetInt2d($cellAddressStructure, 2);
// bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) {
$column = PHPExcel_Cell::stringFromColumnIndex($colIndex);
$column = '$' . $column;
} else {
$colIndex = ($colIndex <= 127) ? $colIndex : $colIndex - 256;
$column = PHPExcel_Cell::stringFromColumnIndex($baseCol + $colIndex);
}
// bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) {
$row = '$' . $row;
} else {
$rowIndex = ($rowIndex <= 32767) ? $rowIndex : $rowIndex - 65536;
$row = $baseRow + $rowIndex;
}
return $column . $row;
}
/**
* Reads a cell range address in BIFF5 e.g. 'A2:B6' or 'A1'
* always fixed range
* section 2.5.14
*
* @param string $subData
* @return string
* @throws Exception
*/
private function _readBIFF5CellRangeAddressFixed($subData)
{
// offset: 0; size: 2; index to first row
$fr = self::_GetInt2d($subData, 0) + 1;
// offset: 2; size: 2; index to last row
$lr = self::_GetInt2d($subData, 2) + 1;
// offset: 4; size: 1; index to first column
$fc = ord($subData{4});
// offset: 5; size: 1; index to last column
$lc = ord($subData{5});
// check values
if ($fr > $lr || $fc > $lc) {
throw new Exception('Not a cell range address');
}
// column index to letter
$fc = PHPExcel_Cell::stringFromColumnIndex($fc);
$lc = PHPExcel_Cell::stringFromColumnIndex($lc);
if ($fr == $lr and $fc == $lc) {
return "$fc$fr";
}
return "$fc$fr:$lc$lr";
}
/**
* Reads a cell range address in BIFF8 e.g. 'A2:B6' or 'A1'
* always fixed range
* section 2.5.14
*
* @param string $subData
* @return string
* @throws Exception
*/
private function _readBIFF8CellRangeAddressFixed($subData)
{
// offset: 0; size: 2; index to first row
$fr = self::_GetInt2d($subData, 0) + 1;
// offset: 2; size: 2; index to last row
$lr = self::_GetInt2d($subData, 2) + 1;
// offset: 4; size: 2; index to first column
$fc = self::_GetInt2d($subData, 4);
// offset: 6; size: 2; index to last column
$lc = self::_GetInt2d($subData, 6);
// check values
if ($fr > $lr || $fc > $lc) {
throw new Exception('Not a cell range address');
}
// column index to letter
$fc = PHPExcel_Cell::stringFromColumnIndex($fc);
$lc = PHPExcel_Cell::stringFromColumnIndex($lc);
if ($fr == $lr and $fc == $lc) {
return "$fc$fr";
}
return "$fc$fr:$lc$lr";
}
/**
* Reads a cell range address in BIFF8 e.g. 'A2:B6' or '$A$2:$B$6'
* there are flags indicating whether column/row index is relative
* section 3.3.4
*
* @param string $subData
* @return string
*/
private function _readBIFF8CellRangeAddress($subData)
{
// todo: if cell range is just a single cell, should this funciton
// not just return e.g. 'A1' and not 'A1:A1' ?
// offset: 0; size: 2; index to first row (0... 65535) (or offset (-32768... 32767))
$fr = self::_GetInt2d($subData, 0) + 1;
// offset: 2; size: 2; index to last row (0... 65535) (or offset (-32768... 32767))
$lr = self::_GetInt2d($subData, 2) + 1;
// offset: 4; size: 2; index to first column or column offset + relative flags
// bit: 7-0; mask 0x00FF; column index
$fc = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($subData, 4));
// bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
if (!(0x4000 & self::_GetInt2d($subData, 4))) {
$fc = '$' . $fc;
}
// bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
if (!(0x8000 & self::_GetInt2d($subData, 4))) {
$fr = '$' . $fr;
}
// offset: 6; size: 2; index to last column or column offset + relative flags
// bit: 7-0; mask 0x00FF; column index
$lc = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($subData, 6));
// bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
if (!(0x4000 & self::_GetInt2d($subData, 6))) {
$lc = '$' . $lc;
}
// bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
if (!(0x8000 & self::_GetInt2d($subData, 6))) {
$lr = '$' . $lr;
}
return "$fc$fr:$lc$lr";
}
/**
* Reads a cell range address in BIFF8 for shared formulas. Uses positive and negative values for row and column
* to indicate offsets from a base cell
* section 3.3.4
*
* @param string $subData
* @param string $baseCell Base cell
* @return string Cell range address
*/
private function _readBIFF8CellRangeAddressB($subData, $baseCell = 'A1')
{
list($baseCol, $baseRow) = PHPExcel_Cell::coordinateFromString($baseCell);
$baseCol = PHPExcel_Cell::columnIndexFromString($baseCol) - 1;
// TODO: if cell range is just a single cell, should this funciton
// not just return e.g. 'A1' and not 'A1:A1' ?
// offset: 0; size: 2; first row
$frIndex = self::_GetInt2d($subData, 0); // adjust below
// offset: 2; size: 2; relative index to first row (0... 65535) should be treated as offset (-32768... 32767)
$lrIndex = self::_GetInt2d($subData, 2); // adjust below
// offset: 4; size: 2; first column with relative/absolute flags
// bit: 7-0; mask 0x00FF; column index
$fcIndex = 0x00FF & self::_GetInt2d($subData, 4);
// bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
if (!(0x4000 & self::_GetInt2d($subData, 4))) {
// absolute column index
$fc = PHPExcel_Cell::stringFromColumnIndex($fcIndex);
$fc = '$' . $fc;
} else {
// column offset
$fcIndex = ($fcIndex <= 127) ? $fcIndex : $fcIndex - 256;
$fc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $fcIndex);
}
// bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
if (!(0x8000 & self::_GetInt2d($subData, 4))) {
// absolute row index
$fr = $frIndex + 1;
$fr = '$' . $fr;
} else {
// row offset
$frIndex = ($frIndex <= 32767) ? $frIndex : $frIndex - 65536;
$fr = $baseRow + $frIndex;
}
// offset: 6; size: 2; last column with relative/absolute flags
// bit: 7-0; mask 0x00FF; column index
$lcIndex = 0x00FF & self::_GetInt2d($subData, 6);
$lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256;
$lc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $lcIndex);
// bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
if (!(0x4000 & self::_GetInt2d($subData, 6))) {
// absolute column index
$lc = PHPExcel_Cell::stringFromColumnIndex($lcIndex);
$lc = '$' . $lc;
} else {
// column offset
$lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256;
$lc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $lcIndex);
}
// bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
if (!(0x8000 & self::_GetInt2d($subData, 6))) {
// absolute row index
$lr = $lrIndex + 1;
$lr = '$' . $lr;
} else {
// row offset
$lrIndex = ($lrIndex <= 32767) ? $lrIndex : $lrIndex - 65536;
$lr = $baseRow + $lrIndex;
}
return "$fc$fr:$lc$lr";
}
/**
* Read BIFF8 cell range address list
* section 2.5.15
*
* @param string $subData
* @return array
*/
private function _readBIFF8CellRangeAddressList($subData)
{
$cellRangeAddresses = array();
// offset: 0; size: 2; number of the following cell range addresses
$nm = self::_GetInt2d($subData, 0);
$offset = 2;
// offset: 2; size: 8 * $nm; list of $nm (fixed) cell range addresses
for ($i = 0; $i < $nm; ++$i) {
$cellRangeAddresses[] = $this->_readBIFF8CellRangeAddressFixed(substr($subData, $offset, 8));
$offset += 8;
}
return array(
'size' => 2 + 8 * $nm,
'cellRangeAddresses' => $cellRangeAddresses,
);
}
/**
* Read BIFF5 cell range address list
* section 2.5.15
*
* @param string $subData
* @return array
*/
private function _readBIFF5CellRangeAddressList($subData)
{
$cellRangeAddresses = array();
// offset: 0; size: 2; number of the following cell range addresses
$nm = self::_GetInt2d($subData, 0);
$offset = 2;
// offset: 2; size: 6 * $nm; list of $nm (fixed) cell range addresses
for ($i = 0; $i < $nm; ++$i) {
$cellRangeAddresses[] = $this->_readBIFF5CellRangeAddressFixed(substr($subData, $offset, 6));
$offset += 6;
}
return array(
'size' => 2 + 6 * $nm,
'cellRangeAddresses' => $cellRangeAddresses,
);
}
/**
* Get a sheet range like Sheet1:Sheet3 from REF index
* Note: If there is only one sheet in the range, one gets e.g Sheet1
* It can also happen that the REF structure uses the -1 (FFFF) code to indicate deleted sheets,
* in which case an exception is thrown
*
* @param int $index
* @return string|false
* @throws Exception
*/
private function _readSheetRangeByRefIndex($index)
{
if (isset($this->_ref[$index])) {
$type = $this->_externalBooks[$this->_ref[$index]['externalBookIndex']]['type'];
switch ($type) {
case 'internal':
// check if we have a deleted 3d reference
if ($this->_ref[$index]['firstSheetIndex'] == 0xFFFF or $this->_ref[$index]['lastSheetIndex'] == 0xFFFF) {
throw new Exception('Deleted sheet reference');
}
// we have normal sheet range (collapsed or uncollapsed)
$firstSheetName = $this->_sheets[$this->_ref[$index]['firstSheetIndex']]['name'];
$lastSheetName = $this->_sheets[$this->_ref[$index]['lastSheetIndex']]['name'];
if ($firstSheetName == $lastSheetName) {
// collapsed sheet range
$sheetRange = $firstSheetName;
} else {
$sheetRange = "$firstSheetName:$lastSheetName";
}
// escape the single-quotes
$sheetRange = str_replace("'", "''", $sheetRange);
// if there are special characters, we need to enclose the range in single-quotes
// todo: check if we have identified the whole set of special characters
// it seems that the following characters are not accepted for sheet names
// and we may assume that they are not present: []*/:\?
if (preg_match("/[ !\"@#£$%&{()}<>=+'|^,;-]/", $sheetRange)) {
$sheetRange = "'$sheetRange'";
}
return $sheetRange;
break;
default:
// TODO: external sheet support
throw new Exception('Excel5 reader only supports internal sheets in fomulas');
break;
}
}
return false;
}
/**
* read BIFF8 constant value array from array data
* returns e.g. array('value' => '{1,2;3,4}', 'size' => 40}
* section 2.5.8
*
* @param string $arrayData
* @return array
*/
private static function _readBIFF8ConstantArray($arrayData)
{
// offset: 0; size: 1; number of columns decreased by 1
$nc = ord($arrayData[0]);
// offset: 1; size: 2; number of rows decreased by 1
$nr = self::_GetInt2d($arrayData, 1);
$size = 3; // initialize
$arrayData = substr($arrayData, 3);
// offset: 3; size: var; list of ($nc + 1) * ($nr + 1) constant values
$matrixChunks = array();
for ($r = 1; $r <= $nr + 1; ++$r) {
$items = array();
for ($c = 1; $c <= $nc + 1; ++$c) {
$constant = self::_readBIFF8Constant($arrayData);
$items[] = $constant['value'];
$arrayData = substr($arrayData, $constant['size']);
$size += $constant['size'];
}
$matrixChunks[] = implode(',', $items); // looks like e.g. '1,"hello"'
}
$matrix = '{' . implode(';', $matrixChunks) . '}';
return array(
'value' => $matrix,
'size' => $size,
);
}
/**
* read BIFF8 constant value which may be 'Empty Value', 'Number', 'String Value', 'Boolean Value', 'Error Value'
* section 2.5.7
* returns e.g. array('value' => '5', 'size' => 9)
*
* @param string $valueData
* @return array
*/
private static function _readBIFF8Constant($valueData)
{
// offset: 0; size: 1; identifier for type of constant
$identifier = ord($valueData[0]);
switch ($identifier) {
case 0x00: // empty constant (what is this?)
$value = '';
$size = 9;
break;
case 0x01: // number
// offset: 1; size: 8; IEEE 754 floating-point value
$value = self::_extractNumber(substr($valueData, 1, 8));
$size = 9;
break;
case 0x02: // string value
// offset: 1; size: var; Unicode string, 16-bit string length
$string = self::_readUnicodeStringLong(substr($valueData, 1));
$value = '"' . $string['value'] . '"';
$size = 1 + $string['size'];
break;
case 0x04: // boolean
// offset: 1; size: 1; 0 = FALSE, 1 = TRUE
if (ord($valueData[1])) {
$value = 'TRUE';
} else {
$value = 'FALSE';
}
$size = 9;
break;
case 0x10: // error code
// offset: 1; size: 1; error code
$value = self::_mapErrorCode(ord($valueData[1]));
$size = 9;
break;
}
return array(
'value' => $value,
'size' => $size,
);
}
/**
* Extract RGB color
* OpenOffice.org's Documentation of the Microsoft Excel File Format, section 2.5.4
*
* @param string $rgb Encoded RGB value (4 bytes)
* @return array
*/
private static function _readRGB($rgb)
{
// offset: 0; size 1; Red component
$r = ord($rgb{0});
// offset: 1; size: 1; Green component
$g = ord($rgb{1});
// offset: 2; size: 1; Blue component
$b = ord($rgb{2});
// HEX notation, e.g. 'FF00FC'
$rgb = sprintf('%02X%02X%02X', $r, $g, $b);
return array('rgb' => $rgb);
}
/**
* Read byte string (8-bit string length)
* OpenOffice documentation: 2.5.2
*
* @param string $subData
* @return array
*/
private function _readByteStringShort($subData)
{
// offset: 0; size: 1; length of the string (character count)
$ln = ord($subData[0]);
// offset: 1: size: var; character array (8-bit characters)
$value = $this->_decodeCodepage(substr($subData, 1, $ln));
return array(
'value' => $value,
'size' => 1 + $ln, // size in bytes of data structure
);
}
/**
* Read byte string (16-bit string length)
* OpenOffice documentation: 2.5.2
*
* @param string $subData
* @return array
*/
private function _readByteStringLong($subData)
{
// offset: 0; size: 2; length of the string (character count)
$ln = self::_GetInt2d($subData, 0);
// offset: 2: size: var; character array (8-bit characters)
$value = $this->_decodeCodepage(substr($subData, 2));
//return $string;
return array(
'value' => $value,
'size' => 2 + $ln, // size in bytes of data structure
);
}
/**
* Extracts an Excel Unicode short string (8-bit string length)
* OpenOffice documentation: 2.5.3
* function will automatically find out where the Unicode string ends.
*
* @param string $subData
* @return array
*/
private static function _readUnicodeStringShort($subData)
{
$value = '';
// offset: 0: size: 1; length of the string (character count)
$characterCount = ord($subData[0]);
$string = self::_readUnicodeString(substr($subData, 1), $characterCount);
// add 1 for the string length
$string['size'] += 1;
return $string;
}
/**
* Extracts an Excel Unicode long string (16-bit string length)
* OpenOffice documentation: 2.5.3
* this function is under construction, needs to support rich text, and Asian phonetic settings
*
* @param string $subData
* @return array
*/
private static function _readUnicodeStringLong($subData)
{
$value = '';
// offset: 0: size: 2; length of the string (character count)
$characterCount = self::_GetInt2d($subData, 0);
$string = self::_readUnicodeString(substr($subData, 2), $characterCount);
// add 2 for the string length
$string['size'] += 2;
return $string;
}
/**
* Read Unicode string with no string length field, but with known character count
* this function is under construction, needs to support rich text, and Asian phonetic settings
* OpenOffice.org's Documentation of the Microsoft Excel File Format, section 2.5.3
*
* @param string $subData
* @param int $characterCount
* @return array
*/
private static function _readUnicodeString($subData, $characterCount)
{
$value = '';
// offset: 0: size: 1; option flags
// bit: 0; mask: 0x01; character compression (0 = compressed 8-bit, 1 = uncompressed 16-bit)
$isCompressed = !((0x01 & ord($subData[0])) >> 0);
// bit: 2; mask: 0x04; Asian phonetic settings
$hasAsian = (0x04) & ord($subData[0]) >> 2;
// bit: 3; mask: 0x08; Rich-Text settings
$hasRichText = (0x08) & ord($subData[0]) >> 3;
// offset: 1: size: var; character array
// this offset assumes richtext and Asian phonetic settings are off which is generally wrong
// needs to be fixed
$value = self::_encodeUTF16(substr($subData, 1, $isCompressed ? $characterCount : 2 * $characterCount), $isCompressed);
return array(
'value' => $value,
'size' => $isCompressed ? 1 + $characterCount : 1 + 2 * $characterCount, // the size in bytes including the option flags
);
}
/**
* Convert UTF-8 string to string surounded by double quotes. Used for explicit string tokens in formulas.
* Example: hello"world --> "hello""world"
*
* @param string $value UTF-8 encoded string
* @return string
*/
private static function _UTF8toExcelDoubleQuoted($value)
{
return '"' . str_replace('"', '""', $value) . '"';
}
/**
* Reads first 8 bytes of a string and return IEEE 754 float
*
* @param string $data Binary string that is at least 8 bytes long
* @return float
*/
private static function _extractNumber($data)
{
$rknumhigh = self::_GetInt4d($data, 4);
$rknumlow = self::_GetInt4d($data, 0);
$sign = ($rknumhigh & 0x80000000) >> 31;
$exp = (($rknumhigh & 0x7ff00000) >> 20) - 1023;
$mantissa = (0x100000 | ($rknumhigh & 0x000fffff));
$mantissalow1 = ($rknumlow & 0x80000000) >> 31;
$mantissalow2 = ($rknumlow & 0x7fffffff);
$value = $mantissa / pow( 2 , (20 - $exp));
if ($mantissalow1 != 0) {
$value += 1 / pow (2 , (21 - $exp));
}
$value += $mantissalow2 / pow (2 , (52 - $exp));
if ($sign) {
$value = -1 * $value;
}
return $value;
}
private static function _GetIEEE754($rknum)
{
if (($rknum & 0x02) != 0) {
$value = $rknum >> 2;
}
else {
// changes by mmp, info on IEEE754 encoding from
// research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html
// The RK format calls for using only the most significant 30 bits
// of the 64 bit floating point value. The other 34 bits are assumed
// to be 0 so we use the upper 30 bits of $rknum as follows...
$sign = ($rknum & 0x80000000) >> 31;
$exp = ($rknum & 0x7ff00000) >> 20;
$mantissa = (0x100000 | ($rknum & 0x000ffffc));
$value = $mantissa / pow( 2 , (20- ($exp - 1023)));
if ($sign) {
$value = -1 * $value;
}
//end of changes by mmp
}
if (($rknum & 0x01) != 0) {
$value /= 100;
}
return $value;
}
/**
* Get UTF-8 string from (compressed or uncompressed) UTF-16 string
*
* @param string $string
* @param bool $compressed
* @return string
*/
private static function _encodeUTF16($string, $compressed = '')
{
if ($compressed) {
$string = self::_uncompressByteString($string);
}
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', 'UTF-16LE');
}
/**
* Convert UTF-16 string in compressed notation to uncompressed form. Only used for BIFF8.
*
* @param string $string
* @return string
*/
private static function _uncompressByteString($string)
{
$uncompressedString = '';
$strLen = strlen($string);
for ($i = 0; $i < $strLen; ++$i) {
$uncompressedString .= $string[$i] . "\0";
}
return $uncompressedString;
}
/**
* Convert string to UTF-8. Only used for BIFF5.
*
* @param string $string
* @return string
*/
private function _decodeCodepage($string)
{
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $this->_codepage);
}
/**
* Read 16-bit unsigned integer
*
* @param string $data
* @param int $pos
* @return int
*/
public static function _GetInt2d($data, $pos)
{
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8);
}
/**
* Read 32-bit signed integer
*
* @param string $data
* @param int $pos
* @return int
*/
public static function _GetInt4d($data, $pos)
{
// FIX: represent numbers correctly on 64-bit system
// http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334
// Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems
$_or_24 = ord($data[$pos + 3]);
if ($_or_24 >= 128) {
// negative number
$_ord_24 = -abs((256 - $_or_24) << 24);
} else {
$_ord_24 = ($_or_24 & 127) << 24;
}
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $_ord_24;
}
/**
* Read color
*
* @param int $color Indexed color
* @param array $palette Color palette
* @return array RGB color value, example: array('rgb' => 'FF0000')
*/
private static function _readColor($color,$palette,$version)
{
if ($color <= 0x07 || $color >= 0x40) {
// special built-in color
return self::_mapBuiltInColor($color);
} elseif (isset($palette) && isset($palette[$color - 8])) {
// palette color, color index 0x08 maps to pallete index 0
return $palette[$color - 8];
} else {
// default color table
if ($version == self::XLS_BIFF8) {
return self::_mapColor($color);
} else {
// BIFF5
return self::_mapColorBIFF5($color);
}
}
return $color;
}
/**
* Map border style
* OpenOffice documentation: 2.5.11
*
* @param int $index
* @return string
*/
private static function _mapBorderStyle($index)
{
switch ($index) {
case 0x00: return PHPExcel_Style_Border::BORDER_NONE;
case 0x01: return PHPExcel_Style_Border::BORDER_THIN;
case 0x02: return PHPExcel_Style_Border::BORDER_MEDIUM;
case 0x03: return PHPExcel_Style_Border::BORDER_DASHED;
case 0x04: return PHPExcel_Style_Border::BORDER_DOTTED;
case 0x05: return PHPExcel_Style_Border::BORDER_THICK;
case 0x06: return PHPExcel_Style_Border::BORDER_DOUBLE;
case 0x07: return PHPExcel_Style_Border::BORDER_HAIR;
case 0x08: return PHPExcel_Style_Border::BORDER_MEDIUMDASHED;
case 0x09: return PHPExcel_Style_Border::BORDER_DASHDOT;
case 0x0A: return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT;
case 0x0B: return PHPExcel_Style_Border::BORDER_DASHDOTDOT;
case 0x0C: return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
case 0x0D: return PHPExcel_Style_Border::BORDER_SLANTDASHDOT;
default: return PHPExcel_Style_Border::BORDER_NONE;
}
}
/**
* Get fill pattern from index
* OpenOffice documentation: 2.5.12
*
* @param int $index
* @return string
*/
private static function _mapFillPattern($index)
{
switch ($index) {
case 0x00: return PHPExcel_Style_Fill::FILL_NONE;
case 0x01: return PHPExcel_Style_Fill::FILL_SOLID;
case 0x02: return PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY;
case 0x03: return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY;
case 0x04: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY;
case 0x05: return PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL;
case 0x06: return PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL;
case 0x07: return PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN;
case 0x08: return PHPExcel_Style_Fill::FILL_PATTERN_DARKUP;
case 0x09: return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID;
case 0x0A: return PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS;
case 0x0B: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL;
case 0x0C: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL;
case 0x0D: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN;
case 0x0E: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP;
case 0x0F: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID;
case 0x10: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS;
case 0x11: return PHPExcel_Style_Fill::FILL_PATTERN_GRAY125;
case 0x12: return PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625;
default: return PHPExcel_Style_Fill::FILL_NONE;
}
}
/**
* Map error code, e.g. '#N/A'
*
* @param int $subData
* @return string
*/
private static function _mapErrorCode($subData)
{
switch ($subData) {
case 0x00: return '#NULL!'; break;
case 0x07: return '#DIV/0!'; break;
case 0x0F: return '#VALUE!'; break;
case 0x17: return '#REF!'; break;
case 0x1D: return '#NAME?'; break;
case 0x24: return '#NUM!'; break;
case 0x2A: return '#N/A'; break;
default: return false;
}
}
/**
* Map built-in color to RGB value
*
* @param int $color Indexed color
* @return array
*/
private static function _mapBuiltInColor($color)
{
switch ($color) {
case 0x00: return array('rgb' => '000000');
case 0x01: return array('rgb' => 'FFFFFF');
case 0x02: return array('rgb' => 'FF0000');
case 0x03: return array('rgb' => '00FF00');
case 0x04: return array('rgb' => '0000FF');
case 0x05: return array('rgb' => 'FFFF00');
case 0x06: return array('rgb' => 'FF00FF');
case 0x07: return array('rgb' => '00FFFF');
case 0x40: return array('rgb' => '000000'); // system window text color
case 0x41: return array('rgb' => 'FFFFFF'); // system window background color
default: return array('rgb' => '000000');
}
}
/**
* Map color array from BIFF5 built-in color index
*
* @param int $subData
* @return array
*/
private static function _mapColorBIFF5($subData)
{
switch ($subData) {
case 0x08: return array('rgb' => '000000');
case 0x09: return array('rgb' => 'FFFFFF');
case 0x0A: return array('rgb' => 'FF0000');
case 0x0B: return array('rgb' => '00FF00');
case 0x0C: return array('rgb' => '0000FF');
case 0x0D: return array('rgb' => 'FFFF00');
case 0x0E: return array('rgb' => 'FF00FF');
case 0x0F: return array('rgb' => '00FFFF');
case 0x10: return array('rgb' => '800000');
case 0x11: return array('rgb' => '008000');
case 0x12: return array('rgb' => '000080');
case 0x13: return array('rgb' => '808000');
case 0x14: return array('rgb' => '800080');
case 0x15: return array('rgb' => '008080');
case 0x16: return array('rgb' => 'C0C0C0');
case 0x17: return array('rgb' => '808080');
case 0x18: return array('rgb' => '8080FF');
case 0x19: return array('rgb' => '802060');
case 0x1A: return array('rgb' => 'FFFFC0');
case 0x1B: return array('rgb' => 'A0E0F0');
case 0x1C: return array('rgb' => '600080');
case 0x1D: return array('rgb' => 'FF8080');
case 0x1E: return array('rgb' => '0080C0');
case 0x1F: return array('rgb' => 'C0C0FF');
case 0x20: return array('rgb' => '000080');
case 0x21: return array('rgb' => 'FF00FF');
case 0x22: return array('rgb' => 'FFFF00');
case 0x23: return array('rgb' => '00FFFF');
case 0x24: return array('rgb' => '800080');
case 0x25: return array('rgb' => '800000');
case 0x26: return array('rgb' => '008080');
case 0x27: return array('rgb' => '0000FF');
case 0x28: return array('rgb' => '00CFFF');
case 0x29: return array('rgb' => '69FFFF');
case 0x2A: return array('rgb' => 'E0FFE0');
case 0x2B: return array('rgb' => 'FFFF80');
case 0x2C: return array('rgb' => 'A6CAF0');
case 0x2D: return array('rgb' => 'DD9CB3');
case 0x2E: return array('rgb' => 'B38FEE');
case 0x2F: return array('rgb' => 'E3E3E3');
case 0x30: return array('rgb' => '2A6FF9');
case 0x31: return array('rgb' => '3FB8CD');
case 0x32: return array('rgb' => '488436');
case 0x33: return array('rgb' => '958C41');
case 0x34: return array('rgb' => '8E5E42');
case 0x35: return array('rgb' => 'A0627A');
case 0x36: return array('rgb' => '624FAC');
case 0x37: return array('rgb' => '969696');
case 0x38: return array('rgb' => '1D2FBE');
case 0x39: return array('rgb' => '286676');
case 0x3A: return array('rgb' => '004500');
case 0x3B: return array('rgb' => '453E01');
case 0x3C: return array('rgb' => '6A2813');
case 0x3D: return array('rgb' => '85396A');
case 0x3E: return array('rgb' => '4A3285');
case 0x3F: return array('rgb' => '424242');
default: return array('rgb' => '000000');
}
}
/**
* Map color array from BIFF8 built-in color index
*
* @param int $subData
* @return array
*/
private static function _mapColor($subData)
{
switch ($subData) {
case 0x08: return array('rgb' => '000000');
case 0x09: return array('rgb' => 'FFFFFF');
case 0x0A: return array('rgb' => 'FF0000');
case 0x0B: return array('rgb' => '00FF00');
case 0x0C: return array('rgb' => '0000FF');
case 0x0D: return array('rgb' => 'FFFF00');
case 0x0E: return array('rgb' => 'FF00FF');
case 0x0F: return array('rgb' => '00FFFF');
case 0x10: return array('rgb' => '800000');
case 0x11: return array('rgb' => '008000');
case 0x12: return array('rgb' => '000080');
case 0x13: return array('rgb' => '808000');
case 0x14: return array('rgb' => '800080');
case 0x15: return array('rgb' => '008080');
case 0x16: return array('rgb' => 'C0C0C0');
case 0x17: return array('rgb' => '808080');
case 0x18: return array('rgb' => '9999FF');
case 0x19: return array('rgb' => '993366');
case 0x1A: return array('rgb' => 'FFFFCC');
case 0x1B: return array('rgb' => 'CCFFFF');
case 0x1C: return array('rgb' => '660066');
case 0x1D: return array('rgb' => 'FF8080');
case 0x1E: return array('rgb' => '0066CC');
case 0x1F: return array('rgb' => 'CCCCFF');
case 0x20: return array('rgb' => '000080');
case 0x21: return array('rgb' => 'FF00FF');
case 0x22: return array('rgb' => 'FFFF00');
case 0x23: return array('rgb' => '00FFFF');
case 0x24: return array('rgb' => '800080');
case 0x25: return array('rgb' => '800000');
case 0x26: return array('rgb' => '008080');
case 0x27: return array('rgb' => '0000FF');
case 0x28: return array('rgb' => '00CCFF');
case 0x29: return array('rgb' => 'CCFFFF');
case 0x2A: return array('rgb' => 'CCFFCC');
case 0x2B: return array('rgb' => 'FFFF99');
case 0x2C: return array('rgb' => '99CCFF');
case 0x2D: return array('rgb' => 'FF99CC');
case 0x2E: return array('rgb' => 'CC99FF');
case 0x2F: return array('rgb' => 'FFCC99');
case 0x30: return array('rgb' => '3366FF');
case 0x31: return array('rgb' => '33CCCC');
case 0x32: return array('rgb' => '99CC00');
case 0x33: return array('rgb' => 'FFCC00');
case 0x34: return array('rgb' => 'FF9900');
case 0x35: return array('rgb' => 'FF6600');
case 0x36: return array('rgb' => '666699');
case 0x37: return array('rgb' => '969696');
case 0x38: return array('rgb' => '003366');
case 0x39: return array('rgb' => '339966');
case 0x3A: return array('rgb' => '003300');
case 0x3B: return array('rgb' => '333300');
case 0x3C: return array('rgb' => '993300');
case 0x3D: return array('rgb' => '993366');
case 0x3E: return array('rgb' => '333399');
case 0x3F: return array('rgb' => '333333');
default: return array('rgb' => '000000');
}
}
private function _parseRichText($is = '') {
$value = new PHPExcel_RichText();
$value->createText($is);
return $value;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Reader/Excel5.php | PHP | asf20 | 225,085 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_DefaultReadFilter
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
{
/**
* Should this cell be read?
*
* @param $column String column index
* @param $row Row index
* @param $worksheetName Optional worksheet name
* @return boolean
*/
public function readCell($column, $row, $worksheetName = '') {
return true;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Reader/DefaultReadFilter.php | PHP | asf20 | 1,799 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Reader_Excel5_Escher
*
* @category PHPExcel
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel5_Escher
{
const DGGCONTAINER = 0xF000;
const BSTORECONTAINER = 0xF001;
const DGCONTAINER = 0xF002;
const SPGRCONTAINER = 0xF003;
const SPCONTAINER = 0xF004;
const DGG = 0xF006;
const BSE = 0xF007;
const DG = 0xF008;
const SPGR = 0xF009;
const SP = 0xF00A;
const OPT = 0xF00B;
const CLIENTTEXTBOX = 0xF00D;
const CLIENTANCHOR = 0xF010;
const CLIENTDATA = 0xF011;
const BLIPJPEG = 0xF01D;
const BLIPPNG = 0xF01E;
const SPLITMENUCOLORS = 0xF11E;
const TERTIARYOPT = 0xF122;
/**
* Escher stream data (binary)
*
* @var string
*/
private $_data;
/**
* Size in bytes of the Escher stream data
*
* @var int
*/
private $_dataSize;
/**
* Current position of stream pointer in Escher stream data
*
* @var int
*/
private $_pos;
/**
* The object to be returned by the reader. Modified during load.
*
* @var mixed
*/
private $_object;
/**
* Create a new PHPExcel_Reader_Excel5_Escher instance
*
* @param mixed $object
*/
public function __construct($object)
{
$this->_object = $object;
}
/**
* Load Escher stream data. May be a partial Escher stream.
*
* @param string $data
*/
public function load($data)
{
$this->_data = $data;
// total byte size of Excel data (workbook global substream + sheet substreams)
$this->_dataSize = strlen($this->_data);
$this->_pos = 0;
// Parse Escher stream
while ($this->_pos < $this->_dataSize) {
// offset: 2; size: 2: Record Type
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
switch ($fbt) {
case self::DGGCONTAINER: $this->_readDggContainer(); break;
case self::DGG: $this->_readDgg(); break;
case self::BSTORECONTAINER: $this->_readBstoreContainer(); break;
case self::BSE: $this->_readBSE(); break;
case self::BLIPJPEG: $this->_readBlipJPEG(); break;
case self::BLIPPNG: $this->_readBlipPNG(); break;
case self::OPT: $this->_readOPT(); break;
case self::TERTIARYOPT: $this->_readTertiaryOPT(); break;
case self::SPLITMENUCOLORS: $this->_readSplitMenuColors(); break;
case self::DGCONTAINER: $this->_readDgContainer(); break;
case self::DG: $this->_readDg(); break;
case self::SPGRCONTAINER: $this->_readSpgrContainer(); break;
case self::SPCONTAINER: $this->_readSpContainer(); break;
case self::SPGR: $this->_readSpgr(); break;
case self::SP: $this->_readSp(); break;
case self::CLIENTTEXTBOX: $this->_readClientTextbox(); break;
case self::CLIENTANCHOR: $this->_readClientAnchor(); break;
case self::CLIENTDATA: $this->_readClientData(); break;
default: $this->_readDefault(); break;
}
}
return $this->_object;
}
/**
* Read a generic record
*/
private function _readDefault()
{
// offset 0; size: 2; recVer and recInstance
$verInstance = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos);
// offset: 2; size: 2: Record Type
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
// bit: 0-3; mask: 0x000F; recVer
$recVer = (0x000F & $verInstance) >> 0;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
/**
* Read DggContainer record (Drawing Group Container)
*/
private function _readDggContainer()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
// record is a container, read contents
$dggContainer = new PHPExcel_Shared_Escher_DggContainer();
$this->_object->setDggContainer($dggContainer);
$reader = new PHPExcel_Reader_Excel5_Escher($dggContainer);
$reader->load($recordData);
}
/**
* Read Dgg record (Drawing Group)
*/
private function _readDgg()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
/**
* Read BstoreContainer record (Blip Store Container)
*/
private function _readBstoreContainer()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
// record is a container, read contents
$bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer();
$this->_object->setBstoreContainer($bstoreContainer);
$reader = new PHPExcel_Reader_Excel5_Escher($bstoreContainer);
$reader->load($recordData);
}
/**
* Read BSE record
*/
private function _readBSE()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
// add BSE to BstoreContainer
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
$this->_object->addBSE($BSE);
$BSE->setBLIPType($recInstance);
// offset: 0; size: 1; btWin32 (MSOBLIPTYPE)
$btWin32 = ord($recordData[0]);
// offset: 1; size: 1; btWin32 (MSOBLIPTYPE)
$btMacOS = ord($recordData[1]);
// offset: 2; size: 16; MD4 digest
$rgbUid = substr($recordData, 2, 16);
// offset: 18; size: 2; tag
$tag = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 18);
// offset: 20; size: 4; size of BLIP in bytes
$size = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 20);
// offset: 24; size: 4; number of references to this BLIP
$cRef = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 24);
// offset: 28; size: 4; MSOFO file offset
$foDelay = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 28);
// offset: 32; size: 1; unused1
$unused1 = ord($recordData{32});
// offset: 33; size: 1; size of nameData in bytes (including null terminator)
$cbName = ord($recordData{33});
// offset: 34; size: 1; unused2
$unused2 = ord($recordData{34});
// offset: 35; size: 1; unused3
$unused3 = ord($recordData{35});
// offset: 36; size: $cbName; nameData
$nameData = substr($recordData, 36, $cbName);
// offset: 36 + $cbName, size: var; the BLIP data
$blipData = substr($recordData, 36 + $cbName);
// record is a container, read contents
$reader = new PHPExcel_Reader_Excel5_Escher($BSE);
$reader->load($blipData);
}
/**
* Read BlipJPEG record. Holds raw JPEG image data
*/
private function _readBlipJPEG()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$pos = 0;
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
$rgbUid1 = substr($recordData, 0, 16);
$pos += 16;
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
if (in_array($recInstance, array(0x046B, 0x06E3))) {
$rgbUid2 = substr($recordData, 16, 16);
$pos += 16;
}
// offset: var; size: 1; tag
$tag = ord($recordData{$pos});
$pos += 1;
// offset: var; size: var; the raw image data
$data = substr($recordData, $pos);
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($data);
$this->_object->setBlip($blip);
}
/**
* Read BlipPNG record. Holds raw PNG image data
*/
private function _readBlipPNG()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$pos = 0;
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
$rgbUid1 = substr($recordData, 0, 16);
$pos += 16;
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
if ($recInstance == 0x06E1) {
$rgbUid2 = substr($recordData, 16, 16);
$pos += 16;
}
// offset: var; size: 1; tag
$tag = ord($recordData{$pos});
$pos += 1;
// offset: var; size: var; the raw image data
$data = substr($recordData, $pos);
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($data);
$this->_object->setBlip($blip);
}
/**
* Read OPT record. This record may occur within DggContainer record or SpContainer
*/
private function _readOPT()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$this->_readOfficeArtRGFOPTE($recordData, $recInstance);
}
/**
* Read TertiaryOPT record
*/
private function _readTertiaryOPT()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
/**
* Read SplitMenuColors record
*/
private function _readSplitMenuColors()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
/**
* Read DgContainer record (Drawing Container)
*/
private function _readDgContainer()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
// record is a container, read contents
$dgContainer = new PHPExcel_Shared_Escher_DgContainer();
$this->_object->setDgContainer($dgContainer);
$reader = new PHPExcel_Reader_Excel5_Escher($dgContainer);
$escher = $reader->load($recordData);
}
/**
* Read Dg record (Drawing)
*/
private function _readDg()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
/**
* Read SpgrContainer record (Shape Group Container)
*/
private function _readSpgrContainer()
{
// context is either context DgContainer or SpgrContainer
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
// record is a container, read contents
$spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
if ($this->_object instanceof PHPExcel_Shared_Escher_DgContainer) {
// DgContainer
$this->_object->setSpgrContainer($spgrContainer);
} else {
// SpgrContainer
$this->_object->addChild($spgrContainer);
}
$reader = new PHPExcel_Reader_Excel5_Escher($spgrContainer);
$escher = $reader->load($recordData);
}
/**
* Read SpContainer record (Shape Container)
*/
private function _readSpContainer()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// add spContainer to spgrContainer
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
$this->_object->addChild($spContainer);
// move stream pointer to next record
$this->_pos += 8 + $length;
// record is a container, read contents
$reader = new PHPExcel_Reader_Excel5_Escher($spContainer);
$escher = $reader->load($recordData);
}
/**
* Read Spgr record (Shape Group)
*/
private function _readSpgr()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
/**
* Read Sp record (Shape)
*/
private function _readSp()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
/**
* Read ClientTextbox record
*/
private function _readClientTextbox()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
/**
* Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet
*/
private function _readClientAnchor()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
// offset: 2; size: 2; upper-left corner column index (0-based)
$c1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 2);
// offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width
$startOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 4);
// offset: 6; size: 2; upper-left corner row index (0-based)
$r1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 6);
// offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height
$startOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 8);
// offset: 10; size: 2; bottom-right corner column index (0-based)
$c2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 10);
// offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width
$endOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 12);
// offset: 14; size: 2; bottom-right corner row index (0-based)
$r2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 14);
// offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height
$endOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 16);
// set the start coordinates
$this->_object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1));
// set the start offsetX
$this->_object->setStartOffsetX($startOffsetX);
// set the start offsetY
$this->_object->setStartOffsetY($startOffsetY);
// set the end coordinates
$this->_object->setEndCoordinates(PHPExcel_Cell::stringFromColumnIndex($c2) . ($r2 + 1));
// set the end offsetX
$this->_object->setEndOffsetX($endOffsetX);
// set the end offsetY
$this->_object->setEndOffsetY($endOffsetY);
}
/**
* Read ClientData record
*/
private function _readClientData()
{
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
/**
* Read OfficeArtRGFOPTE table of property-value pairs
*
* @param string $data Binary data
* @param int $n Number of properties
*/
private function _readOfficeArtRGFOPTE($data, $n) {
$splicedComplexData = substr($data, 6 * $n);
// loop through property-value pairs
for ($i = 0; $i < $n; ++$i) {
// read 6 bytes at a time
$fopte = substr($data, 6 * $i, 6);
// offset: 0; size: 2; opid
$opid = PHPExcel_Reader_Excel5::_GetInt2d($fopte, 0);
// bit: 0-13; mask: 0x3FFF; opid.opid
$opidOpid = (0x3FFF & $opid) >> 0;
// bit: 14; mask 0x4000; 1 = value in op field is BLIP identifier
$opidFBid = (0x4000 & $opid) >> 14;
// bit: 15; mask 0x8000; 1 = this is a complex property, op field specifies size of complex data
$opidFComplex = (0x8000 & $opid) >> 15;
// offset: 2; size: 4; the value for this property
$op = PHPExcel_Reader_Excel5::_GetInt4d($fopte, 2);
if ($opidFComplex) {
$complexData = substr($splicedComplexData, 0, $op);
$splicedComplexData = substr($splicedComplexData, $op);
// we store string value with complex data
$value = $complexData;
} else {
// we store integer value
$value = $op;
}
$this->_object->setOPT($opidOpid, $value);
}
}
}
| zysms | trunk/zysms/customer/PHPExcel/Reader/Excel5/Escher.php | PHP | asf20 | 18,841 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_Excel2003XML
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
{
/**
* Read data only?
*
* @var boolean
*/
private $_readDataOnly = false;
/**
* Restict which sheets should be loaded?
*
* @var array
*/
private $_loadSheetsOnly = null;
/**
* Formats
*
* @var array
*/
private $_styles = array();
/**
* PHPExcel_Reader_IReadFilter instance
*
* @var PHPExcel_Reader_IReadFilter
*/
private $_readFilter = null;
/**
* Read data only?
*
* @return boolean
*/
public function getReadDataOnly() {
return $this->_readDataOnly;
}
/**
* Set read data only
*
* @param boolean $pValue
* @return PHPExcel_Reader_Excel2003XML
*/
public function setReadDataOnly($pValue = false) {
$this->_readDataOnly = $pValue;
return $this;
}
/**
* Get which sheets to load
*
* @return mixed
*/
public function getLoadSheetsOnly()
{
return $this->_loadSheetsOnly;
}
/**
* Set which sheets to load
*
* @param mixed $value
* @return PHPExcel_Reader_Excel2003XML
*/
public function setLoadSheetsOnly($value = null)
{
$this->_loadSheetsOnly = is_array($value) ?
$value : array($value);
return $this;
}
/**
* Set all sheets to load
*
* @return PHPExcel_Reader_Excel2003XML
*/
public function setLoadAllSheets()
{
$this->_loadSheetsOnly = null;
return $this;
}
/**
* Read filter
*
* @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter() {
return $this->_readFilter;
}
/**
* Set read filter
*
* @param PHPExcel_Reader_IReadFilter $pValue
* @return PHPExcel_Reader_Excel2003XML
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
$this->_readFilter = $pValue;
return $this;
}
/**
* Create a new PHPExcel_Reader_Excel2003XML
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
*/
public function canRead($pFilename)
{
// Office xmlns:o="urn:schemas-microsoft-com:office:office"
// Excel xmlns:x="urn:schemas-microsoft-com:office:excel"
// XML Spreadsheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
// Spreadsheet component xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"
// XML schema xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
// XML data type xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
// MS-persist recordset xmlns:rs="urn:schemas-microsoft-com:rowset"
// Rowset xmlns:z="#RowsetSchema"
//
$signature = array(
'<?xml version="1.0"',
'<?mso-application progid="Excel.Sheet"?>'
);
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Read sample data (first 2 KB will do)
$fh = fopen($pFilename, 'r');
$data = fread($fh, 2048);
fclose($fh);
$valid = true;
foreach($signature as $match) {
// every part of the signature must be present
if (strpos($data, $match) === false) {
$valid = false;
break;
}
}
return $valid;
}
/**
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
* @param string $pFilename
* @throws Exception
*/
public function listWorksheetNames($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetNames = array();
$xml = simplexml_load_file($pFilename);
$namespaces = $xml->getNamespaces(true);
$xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
$worksheetNames[] = $worksheet_ss['Name'];
}
return $worksheetNames;
}
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
$styleAttributeValue = strtolower($styleAttributeValue);
foreach($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) {
$styleAttributeValue = $style;
return true;
}
}
return false;
}
/**
* pixel units to excel width units(units of 1/256th of a character width)
* @param pxs
* @return
*/
private static function _pixel2WidthUnits($pxs) {
$UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219);
$widthUnits = 256 * ($pxs / 7);
$widthUnits += $UNIT_OFFSET_MAP[($pxs % 7)];
return $widthUnits;
}
/**
* excel width units(units of 1/256th of a character width) to pixel units
* @param widthUnits
* @return
*/
private static function _widthUnits2Pixel($widthUnits) {
$pixels = ($widthUnits / 256) * 7;
$offsetWidthUnits = $widthUnits % 256;
$pixels += round($offsetWidthUnits / (256 / 7));
return $pixels;
}
private static function _hex2str($hex) {
return chr(hexdec($hex[1]));
}
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
$fromFormats = array('\-', '\ ');
$toFormats = array('-', ' ');
$underlineStyles = array (
PHPExcel_Style_Font::UNDERLINE_NONE,
PHPExcel_Style_Font::UNDERLINE_DOUBLE,
PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING,
PHPExcel_Style_Font::UNDERLINE_SINGLE,
PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING
);
$verticalAlignmentStyles = array (
PHPExcel_Style_Alignment::VERTICAL_BOTTOM,
PHPExcel_Style_Alignment::VERTICAL_TOP,
PHPExcel_Style_Alignment::VERTICAL_CENTER,
PHPExcel_Style_Alignment::VERTICAL_JUSTIFY
);
$horizontalAlignmentStyles = array (
PHPExcel_Style_Alignment::HORIZONTAL_GENERAL,
PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
PHPExcel_Style_Alignment::HORIZONTAL_RIGHT,
PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS,
PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY
);
$timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC');
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$xml = simplexml_load_file($pFilename);
$namespaces = $xml->getNamespaces(true);
$docProps = $objPHPExcel->getProperties();
if (isset($xml->DocumentProperties[0])) {
foreach($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
switch ($propertyName) {
case 'Title' :
$docProps->setTitle($propertyValue);
break;
case 'Subject' :
$docProps->setSubject($propertyValue);
break;
case 'Author' :
$docProps->setCreator($propertyValue);
break;
case 'Created' :
$creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate);
break;
case 'LastAuthor' :
$docProps->setLastModifiedBy($propertyValue);
break;
case 'LastSaved' :
$lastSaveDate = strtotime($propertyValue);
$docProps->setModified($lastSaveDate);
break;
case 'Company' :
$docProps->setCompany($propertyValue);
break;
case 'Category' :
$docProps->setCategory($propertyValue);
break;
case 'Manager' :
$docProps->setManager($propertyValue);
break;
case 'Keywords' :
$docProps->setKeywords($propertyValue);
break;
case 'Description' :
$docProps->setDescription($propertyValue);
break;
}
}
}
if (isset($xml->CustomDocumentProperties)) {
foreach($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
$propertyAttributes = $propertyValue->attributes($namespaces['dt']);
$propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/','PHPExcel_Reader_Excel2003XML::_hex2str',$propertyName);
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN;
switch((string) $propertyAttributes) {
case 'string' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
$propertyValue = trim($propertyValue);
break;
case 'boolean' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN;
$propertyValue = (bool) $propertyValue;
break;
case 'integer' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_INTEGER;
$propertyValue = intval($propertyValue);
break;
case 'float' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT;
$propertyValue = floatval($propertyValue);
break;
case 'dateTime.tz' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE;
$propertyValue = strtotime(trim($propertyValue));
break;
}
$docProps->setCustomProperty($propertyName,$propertyValue,$propertyType);
}
}
foreach($xml->Styles[0] as $style) {
$style_ss = $style->attributes($namespaces['ss']);
$styleID = (string) $style_ss['ID'];
// echo 'Style ID = '.$styleID.'<br />';
if ($styleID == 'Default') {
$this->_styles['Default'] = array();
} else {
$this->_styles[$styleID] = $this->_styles['Default'];
}
foreach ($style as $styleType => $styleData) {
$styleAttributes = $styleData->attributes($namespaces['ss']);
// echo $styleType.'<br />';
switch ($styleType) {
case 'Alignment' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) {
case 'Vertical' :
if (self::identifyFixedStyleValue($verticalAlignmentStyles,$styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
}
break;
case 'Horizontal' :
if (self::identifyFixedStyleValue($horizontalAlignmentStyles,$styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
}
break;
case 'WrapText' :
$this->_styles[$styleID]['alignment']['wrap'] = true;
break;
}
}
break;
case 'Borders' :
foreach($styleData->Border as $borderStyle) {
$borderAttributes = $borderStyle->attributes($namespaces['ss']);
$thisBorder = array();
foreach($borderAttributes as $borderStyleKey => $borderStyleValue) {
// echo $borderStyleKey.' = '.$borderStyleValue.'<br />';
switch ($borderStyleKey) {
case 'LineStyle' :
$thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
// $thisBorder['style'] = $borderStyleValue;
break;
case 'Weight' :
// $thisBorder['style'] = $borderStyleValue;
break;
case 'Position' :
$borderPosition = strtolower($borderStyleValue);
break;
case 'Color' :
$borderColour = substr($borderStyleValue,1);
$thisBorder['color']['rgb'] = $borderColour;
break;
}
}
if (count($thisBorder) > 0) {
if (($borderPosition == 'left') || ($borderPosition == 'right') || ($borderPosition == 'top') || ($borderPosition == 'bottom')) {
$this->_styles[$styleID]['borders'][$borderPosition] = $thisBorder;
}
}
}
break;
case 'Font' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) {
case 'FontName' :
$this->_styles[$styleID]['font']['name'] = $styleAttributeValue;
break;
case 'Size' :
$this->_styles[$styleID]['font']['size'] = $styleAttributeValue;
break;
case 'Color' :
$this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue,1);
break;
case 'Bold' :
$this->_styles[$styleID]['font']['bold'] = true;
break;
case 'Italic' :
$this->_styles[$styleID]['font']['italic'] = true;
break;
case 'Underline' :
if (self::identifyFixedStyleValue($underlineStyles,$styleAttributeValue)) {
$this->_styles[$styleID]['font']['underline'] = $styleAttributeValue;
}
break;
}
}
break;
case 'Interior' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
switch ($styleAttributeKey) {
case 'Color' :
$this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue,1);
break;
}
}
break;
case 'NumberFormat' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = str_replace($fromFormats,$toFormats,$styleAttributeValue);
switch ($styleAttributeValue) {
case 'Short Date' :
$styleAttributeValue = 'dd/mm/yyyy';
break;
}
if ($styleAttributeValue > '') {
$this->_styles[$styleID]['numberformat']['code'] = $styleAttributeValue;
}
}
break;
case 'Protection' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
}
break;
}
}
// print_r($this->_styles[$styleID]);
// echo '<hr />';
}
// echo '<hr />';
$worksheetID = 0;
$xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
if ((isset($this->_loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
(!in_array($worksheet_ss['Name'], $this->_loadSheetsOnly))) {
continue;
}
// echo '<h3>Worksheet: ',$worksheet_ss['Name'],'<h3>';
//
// Create new Worksheet
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($worksheetID);
if (isset($worksheet_ss['Name'])) {
$worksheetName = (string) $worksheet_ss['Name'];
$objPHPExcel->getActiveSheet()->setTitle($worksheetName);
}
$columnID = 'A';
if (isset($worksheet->Table->Column)) {
foreach($worksheet->Table->Column as $columnData) {
$columnData_ss = $columnData->attributes($namespaces['ss']);
if (isset($columnData_ss['Index'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($columnData_ss['Index']-1);
}
if (isset($columnData_ss['Width'])) {
$columnWidth = $columnData_ss['Width'];
// echo '<b>Setting column width for '.$columnID.' to '.$columnWidth.'</b><br />';
$objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setWidth($columnWidth / 5.4);
}
++$columnID;
}
}
$rowID = 1;
if (isset($worksheet->Table->Row)) {
foreach($worksheet->Table->Row as $rowData) {
$rowHasData = false;
$row_ss = $rowData->attributes($namespaces['ss']);
if (isset($row_ss['Index'])) {
$rowID = (integer) $row_ss['Index'];
}
// echo '<b>Row '.$rowID.'</b><br />';
$columnID = 'A';
foreach($rowData->Cell as $cell) {
$cell_ss = $cell->attributes($namespaces['ss']);
if (isset($cell_ss['Index'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($cell_ss['Index']-1);
}
$cellRange = $columnID.$rowID;
if (!is_null($this->getReadFilter())) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue;
}
}
if ((isset($cell_ss['MergeAcross'])) || (isset($cell_ss['MergeDown']))) {
$columnTo = $columnID;
if (isset($cell_ss['MergeAcross'])) {
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cell_ss['MergeAcross'] -1);
}
$rowTo = $rowID;
if (isset($cell_ss['MergeDown'])) {
$rowTo = $rowTo + $cell_ss['MergeDown'];
}
$cellRange .= ':'.$columnTo.$rowTo;
$objPHPExcel->getActiveSheet()->mergeCells($cellRange);
}
$cellIsSet = $hasCalculatedValue = false;
$cellDataFormula = '';
if (isset($cell_ss['Formula'])) {
$cellDataFormula = $cell_ss['Formula'];
// added this as a check for array formulas
if (isset($cell_ss['ArrayRange'])) {
$cellDataCSEFormula = $cell_ss['ArrayRange'];
// echo "found an array formula at ".$columnID.$rowID."<br />";
}
$hasCalculatedValue = true;
}
if (isset($cell->Data)) {
$cellValue = $cellData = $cell->Data;
$type = PHPExcel_Cell_DataType::TYPE_NULL;
$cellData_ss = $cellData->attributes($namespaces['ss']);
if (isset($cellData_ss['Type'])) {
$cellDataType = $cellData_ss['Type'];
switch ($cellDataType) {
/*
const TYPE_STRING = 's';
const TYPE_FORMULA = 'f';
const TYPE_NUMERIC = 'n';
const TYPE_BOOL = 'b';
const TYPE_NULL = 's';
const TYPE_INLINE = 'inlineStr';
const TYPE_ERROR = 'e';
*/
case 'String' :
$type = PHPExcel_Cell_DataType::TYPE_STRING;
break;
case 'Number' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$cellValue = (float) $cellValue;
if (floor($cellValue) == $cellValue) {
$cellValue = (integer) $cellValue;
}
break;
case 'Boolean' :
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$cellValue = ($cellValue != 0);
break;
case 'DateTime' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue));
break;
case 'Error' :
$type = PHPExcel_Cell_DataType::TYPE_ERROR;
break;
}
}
if ($hasCalculatedValue) {
// echo 'FORMULA<br />';
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
$columnNumber = PHPExcel_Cell::columnIndexFromString($columnID);
if (substr($cellDataFormula,0,3) == 'of:') {
$cellDataFormula = substr($cellDataFormula,3);
// echo 'Before: ',$cellDataFormula,'<br />';
$temp = explode('"',$cellDataFormula);
$key = false;
foreach($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks)
if ($key = !$key) {
$value = str_replace(array('[.','.',']'),'',$value);
}
}
} else {
// Convert R1C1 style references to A1 style references (but only when not quoted)
// echo 'Before: ',$cellDataFormula,'<br />';
$temp = explode('"',$cellDataFormula);
$key = false;
foreach($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks)
if ($key = !$key) {
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
// through the formula from left to right. Reversing means that we work right to left.through
// the formula
$cellReferences = array_reverse($cellReferences);
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
// then modify the formula to use that new reference
foreach($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0];
// Empty R reference is the current row
if ($rowReference == '') $rowReference = $rowID;
// Bracketed R references are relative to the current row
if ($rowReference{0} == '[') $rowReference = $rowID + trim($rowReference,'[]');
$columnReference = $cellReference[4][0];
// Empty C reference is the current column
if ($columnReference == '') $columnReference = $columnNumber;
// Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]');
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
}
}
}
}
unset($value);
// Then rebuild the formula string
$cellDataFormula = implode('"',$temp);
// echo 'After: ',$cellDataFormula,'<br />';
}
// echo 'Cell '.$columnID.$rowID.' is a '.$type.' with a value of '.(($hasCalculatedValue) ? $cellDataFormula : $cellValue).'<br />';
//
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $cellValue),$type);
if ($hasCalculatedValue) {
// echo 'Formula result is '.$cellValue.'<br />';
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($cellValue);
}
$cellIsSet = $rowHasData = true;
}
if (isset($cell->Comment)) {
// echo '<b>comment found</b><br />';
$commentAttributes = $cell->Comment->attributes($namespaces['ss']);
$author = 'unknown';
if (isset($commentAttributes->Author)) {
$author = (string)$commentAttributes->Author;
// echo 'Author: ',$author,'<br />';
}
$node = $cell->Comment->Data->asXML();
// $annotation = str_replace('html:','',substr($node,49,-10));
// echo $annotation,'<br />';
$annotation = strip_tags($node);
// echo 'Annotation: ',$annotation,'<br />';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
->setAuthor( $author )
->setText($this->_parseRichText($annotation) );
}
if (($cellIsSet) && (isset($cell_ss['StyleID']))) {
$style = (string) $cell_ss['StyleID'];
// echo 'Cell style for '.$columnID.$rowID.' is '.$style.'<br />';
if ((isset($this->_styles[$style])) && (count($this->_styles[$style]) > 0)) {
// echo 'Cell '.$columnID.$rowID.'<br />';
// print_r($this->_styles[$style]);
// echo '<br />';
if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) {
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(NULL);
}
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]);
}
}
++$columnID;
}
if ($rowHasData) {
if (isset($row_ss['StyleID'])) {
$rowStyle = $row_ss['StyleID'];
}
if (isset($row_ss['Height'])) {
$rowHeight = $row_ss['Height'];
// echo '<b>Setting row height to '.$rowHeight.'</b><br />';
$objPHPExcel->getActiveSheet()->getRowDimension($rowID)->setRowHeight($rowHeight);
}
}
++$rowID;
}
}
++$worksheetID;
}
// Return
return $objPHPExcel;
}
private function _parseRichText($is = '') {
$value = new PHPExcel_RichText();
$value->createText($is);
return $value;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Reader/Excel2003XML.php | PHP | asf20 | 25,585 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_CSV
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
{
/**
* Input encoding
*
* @access private
* @var string
*/
private $_inputEncoding = 'UTF-8';
/**
* Delimiter
*
* @access private
* @var string
*/
private $_delimiter = ',';
/**
* Enclosure
*
* @access private
* @var string
*/
private $_enclosure = '"';
/**
* Line ending
*
* @access private
* @var string
*/
private $_lineEnding = PHP_EOL;
/**
* Sheet index to read
*
* @access private
* @var int
*/
private $_sheetIndex = 0;
/**
* Load rows contiguously
*
* @access private
* @var int
*/
private $_contiguous = false;
/**
* Row counter for loading rows contiguously
*
* @access private
* @var int
*/
private $_contiguousRow = -1;
/**
* PHPExcel_Reader_IReadFilter instance
*
* @access private
* @var PHPExcel_Reader_IReadFilter
*/
private $_readFilter = null;
/**
* Create a new PHPExcel_Reader_CSV
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
} // function __construct()
/**
* Can the current PHPExcel_Reader_IReader read the file?
*
* @access public
* @param string $pFileName
* @return boolean
* @throws Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
return true;
} // function canRead()
/**
* Loads PHPExcel from file
*
* @access public
* @param string $pFilename
* @return PHPExcel
* @throws Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
} // function load()
/**
* Read filter
*
* @access public
* @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter() {
return $this->_readFilter;
} // function getReadFilter()
/**
* Set read filter
*
* @access public
* @param PHPExcel_Reader_IReadFilter $pValue
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
$this->_readFilter = $pValue;
return $this;
} // function setReadFilter()
/**
* Set input encoding
*
* @access public
* @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'UTF-8')
{
$this->_inputEncoding = $pValue;
return $this;
} // function setInputEncoding()
/**
* Get input encoding
*
* @access public
* @return string
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
} // function getInputEncoding()
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @access public
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
$objPHPExcel->createSheet();
}
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
// Open file
$fileHandle = fopen($pFilename, 'r');
if ($fileHandle === false) {
throw new Exception("Could not open file $pFilename for reading.");
}
// Skip BOM, if any
switch ($this->_inputEncoding) {
case 'UTF-8':
fgets($fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($fileHandle, 3) : fseek($fileHandle, 0);
break;
case 'UTF-16LE':
fgets($fileHandle, 3) == "\xFF\xFE" ?
fseek($fileHandle, 2) : fseek($fileHandle, 0);
break;
case 'UTF-16BE':
fgets($fileHandle, 3) == "\xFE\xFF" ?
fseek($fileHandle, 2) : fseek($fileHandle, 0);
break;
case 'UTF-32LE':
fgets($fileHandle, 5) == "\xFF\xFE\x00\x00" ?
fseek($fileHandle, 4) : fseek($fileHandle, 0);
break;
case 'UTF-32BE':
fgets($fileHandle, 5) == "\x00\x00\xFE\xFF" ?
fseek($fileHandle, 4) : fseek($fileHandle, 0);
break;
default:
break;
}
$escapeEnclosures = array( "\\" . $this->_enclosure,
$this->_enclosure . $this->_enclosure
);
// Set our starting row based on whether we're in contiguous mode or not
$currentRow = 1;
if ($this->_contiguous) {
$currentRow = ($this->_contiguousRow == -1) ? $objPHPExcel->getActiveSheet()->getHighestRow(): $this->_contiguousRow;
}
// Loop through each line of the file in turn
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
$columnLetter = 'A';
foreach($rowData as $rowDatum) {
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
// Unescape enclosures
$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);
// Convert encoding if necessary
if ($this->_inputEncoding !== 'UTF-8') {
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
}
// Set cell value
$objPHPExcel->getActiveSheet()->getCell($columnLetter . $currentRow)->setValue($rowDatum);
}
++$columnLetter;
}
++$currentRow;
}
// Close file
fclose($fileHandle);
if ($this->_contiguous) {
$this->_contiguousRow = $currentRow;
}
// Return
return $objPHPExcel;
} // function loadIntoExisting()
/**
* Get delimiter
*
* @access public
* @return string
*/
public function getDelimiter() {
return $this->_delimiter;
} // function getDelimiter()
/**
* Set delimiter
*
* @access public
* @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Reader_CSV
*/
public function setDelimiter($pValue = ',') {
$this->_delimiter = $pValue;
return $this;
} // function setDelimiter()
/**
* Get enclosure
*
* @access public
* @return string
*/
public function getEnclosure() {
return $this->_enclosure;
} // function getEnclosure()
/**
* Set enclosure
*
* @access public
* @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Reader_CSV
*/
public function setEnclosure($pValue = '"') {
if ($pValue == '') {
$pValue = '"';
}
$this->_enclosure = $pValue;
return $this;
} // function setEnclosure()
/**
* Get line ending
*
* @access public
* @return string
*/
public function getLineEnding() {
return $this->_lineEnding;
} // function getLineEnding()
/**
* Set line ending
*
* @access public
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
* @return PHPExcel_Reader_CSV
*/
public function setLineEnding($pValue = PHP_EOL) {
$this->_lineEnding = $pValue;
return $this;
} // function setLineEnding()
/**
* Get sheet index
*
* @access public
* @return int
*/
public function getSheetIndex() {
return $this->_sheetIndex;
} // function getSheetIndex()
/**
* Set sheet index
*
* @access public
* @param int $pValue Sheet index
* @return PHPExcel_Reader_CSV
*/
public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue;
return $this;
} // function setSheetIndex()
/**
* Set Contiguous
*
* @access public
* @param string $pValue Input encoding
*/
public function setContiguous($contiguous = false)
{
$this->_contiguous = (bool)$contiguous;
if (!$contiguous) {
$this->_contiguousRow = -1;
}
return $this;
} // function setInputEncoding()
/**
* Get Contiguous
*
* @access public
* @return boolean
*/
public function getContiguous() {
return $this->_contiguous;
} // function getSheetIndex()
}
| zysms | trunk/zysms/customer/PHPExcel/Reader/CSV.php | PHP | asf20 | 9,201 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet implements PHPExcel_IComparable
{
/* Break types */
const BREAK_NONE = 0;
const BREAK_ROW = 1;
const BREAK_COLUMN = 2;
/* Sheet state */
const SHEETSTATE_VISIBLE = 'visible';
const SHEETSTATE_HIDDEN = 'hidden';
const SHEETSTATE_VERYHIDDEN = 'veryHidden';
/**
* Invalid characters in sheet title
*
* @var array
*/
private static $_invalidCharacters = array('*', ':', '/', '\\', '?', '[', ']');
/**
* Parent spreadsheet
*
* @var PHPExcel
*/
private $_parent;
/**
* Cacheable collection of cells
*
* @var PHPExcel_CachedObjectStorage_xxx
*/
private $_cellCollection = null;
/**
* Collection of row dimensions
*
* @var PHPExcel_Worksheet_RowDimension[]
*/
private $_rowDimensions = array();
/**
* Default row dimension
*
* @var PHPExcel_Worksheet_RowDimension
*/
private $_defaultRowDimension = null;
/**
* Collection of column dimensions
*
* @var PHPExcel_Worksheet_ColumnDimension[]
*/
private $_columnDimensions = array();
/**
* Default column dimension
*
* @var PHPExcel_Worksheet_ColumnDimension
*/
private $_defaultColumnDimension = null;
/**
* Collection of drawings
*
* @var PHPExcel_Worksheet_BaseDrawing[]
*/
private $_drawingCollection = null;
/**
* Worksheet title
*
* @var string
*/
private $_title;
/**
* Sheet state
*
* @var string
*/
private $_sheetState;
/**
* Page setup
*
* @var PHPExcel_Worksheet_PageSetup
*/
private $_pageSetup;
/**
* Page margins
*
* @var PHPExcel_Worksheet_PageMargins
*/
private $_pageMargins;
/**
* Page header/footer
*
* @var PHPExcel_Worksheet_HeaderFooter
*/
private $_headerFooter;
/**
* Sheet view
*
* @var PHPExcel_Worksheet_SheetView
*/
private $_sheetView;
/**
* Protection
*
* @var PHPExcel_Worksheet_Protection
*/
private $_protection;
/**
* Collection of styles
*
* @var PHPExcel_Style[]
*/
private $_styles = array();
/**
* Conditional styles. Indexed by cell coordinate, e.g. 'A1'
*
* @var array
*/
private $_conditionalStylesCollection = array();
/**
* Is the current cell collection sorted already?
*
* @var boolean
*/
private $_cellCollectionIsSorted = false;
/**
* Collection of breaks
*
* @var array
*/
private $_breaks = array();
/**
* Collection of merged cell ranges
*
* @var array
*/
private $_mergeCells = array();
/**
* Collection of protected cell ranges
*
* @var array
*/
private $_protectedCells = array();
/**
* Autofilter Range
*
* @var string
*/
private $_autoFilter = '';
/**
* Freeze pane
*
* @var string
*/
private $_freezePane = '';
/**
* Show gridlines?
*
* @var boolean
*/
private $_showGridlines = true;
/**
* Print gridlines?
*
* @var boolean
*/
private $_printGridlines = false;
/**
* Show row and column headers?
*
* @var boolean
*/
private $_showRowColHeaders = true;
/**
* Show summary below? (Row/Column outline)
*
* @var boolean
*/
private $_showSummaryBelow = true;
/**
* Show summary right? (Row/Column outline)
*
* @var boolean
*/
private $_showSummaryRight = true;
/**
* Collection of comments
*
* @var PHPExcel_Comment[]
*/
private $_comments = array();
/**
* Active cell. (Only one!)
*
* @var string
*/
private $_activeCell = 'A1';
/**
* Selected cells
*
* @var string
*/
private $_selectedCells = 'A1';
/**
* Cached highest column
*
* @var string
*/
private $_cachedHighestColumn = 'A';
/**
* Cached highest row
*
* @var int
*/
private $_cachedHighestRow = 1;
/**
* Right-to-left?
*
* @var boolean
*/
private $_rightToLeft = false;
/**
* Hyperlinks. Indexed by cell coordinate, e.g. 'A1'
*
* @var array
*/
private $_hyperlinkCollection = array();
/**
* Data validation objects. Indexed by cell coordinate, e.g. 'A1'
*
* @var array
*/
private $_dataValidationCollection = array();
/**
* Tab color
*
* @var PHPExcel_Style_Color
*/
private $_tabColor;
/**
* Dirty flag
*
* @var boolean
*/
private $_dirty = true;
/**
* Hash
*
* @var string
*/
private $_hash = null;
/**
* Create a new worksheet
*
* @param PHPExcel $pParent
* @param string $pTitle
*/
public function __construct(PHPExcel $pParent = null, $pTitle = 'Worksheet')
{
// Set parent and title
$this->_parent = $pParent;
$this->setTitle($pTitle);
$this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE);
$this->_cellCollection = PHPExcel_CachedObjectStorageFactory::getInstance($this);
// Set page setup
$this->_pageSetup = new PHPExcel_Worksheet_PageSetup();
// Set page margins
$this->_pageMargins = new PHPExcel_Worksheet_PageMargins();
// Set page header/footer
$this->_headerFooter = new PHPExcel_Worksheet_HeaderFooter();
// Set sheet view
$this->_sheetView = new PHPExcel_Worksheet_SheetView();
// Drawing collection
$this->_drawingCollection = new ArrayObject();
// Protection
$this->_protection = new PHPExcel_Worksheet_Protection();
// Default row dimension
$this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(null);
// Default column dimension
$this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(null);
}
public function disconnectCells() {
$this->_cellCollection->unsetWorksheetCells();
$this->_cellCollection = null;
// detach ourself from the workbook, so that it can then delete this worksheet successfully
$this->_parent = null;
}
/**
* Return the cache controller for the cell collection
*
* @return PHPExcel_CachedObjectStorage_xxx
*/
public function getCellCacheController() {
return $this->_cellCollection;
} // function getCellCacheController()
/**
* Get array of invalid characters for sheet title
*
* @return array
*/
public static function getInvalidCharacters()
{
return self::$_invalidCharacters;
}
/**
* Check sheet title for valid Excel syntax
*
* @param string $pValue The string to check
* @return string The valid string
* @throws Exception
*/
private static function _checkSheetTitle($pValue)
{
// Some of the printable ASCII characters are invalid: * : / \ ? [ ]
if (str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) {
throw new Exception('Invalid character found in sheet title');
}
// Maximum 31 characters allowed for sheet title
if (PHPExcel_Shared_String::CountCharacters($pValue) > 31) {
throw new Exception('Maximum 31 characters allowed in sheet title.');
}
return $pValue;
}
/**
* Get collection of cells
*
* @param boolean $pSorted Also sort the cell collection?
* @return PHPExcel_Cell[]
*/
public function getCellCollection($pSorted = true)
{
if ($pSorted) {
// Re-order cell collection
return $this->sortCellCollection();
}
if (!is_null($this->_cellCollection)) {
return $this->_cellCollection->getCellList();
}
return array();
}
/**
* Sort collection of cells
*
* @return PHPExcel_Worksheet
*/
public function sortCellCollection()
{
if (!is_null($this->_cellCollection)) {
return $this->_cellCollection->getSortedCellList();
}
return array();
}
/**
* Get collection of row dimensions
*
* @return PHPExcel_Worksheet_RowDimension[]
*/
public function getRowDimensions()
{
return $this->_rowDimensions;
}
/**
* Get default row dimension
*
* @return PHPExcel_Worksheet_RowDimension
*/
public function getDefaultRowDimension()
{
return $this->_defaultRowDimension;
}
/**
* Get collection of column dimensions
*
* @return PHPExcel_Worksheet_ColumnDimension[]
*/
public function getColumnDimensions()
{
return $this->_columnDimensions;
}
/**
* Get default column dimension
*
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function getDefaultColumnDimension()
{
return $this->_defaultColumnDimension;
}
/**
* Get collection of drawings
*
* @return PHPExcel_Worksheet_BaseDrawing[]
*/
public function getDrawingCollection()
{
return $this->_drawingCollection;
}
/**
* Refresh column dimensions
*
* @return PHPExcel_Worksheet
*/
public function refreshColumnDimensions()
{
$currentColumnDimensions = $this->getColumnDimensions();
$newColumnDimensions = array();
foreach ($currentColumnDimensions as $objColumnDimension) {
$newColumnDimensions[$objColumnDimension->getColumnIndex()] = $objColumnDimension;
}
$this->_columnDimensions = $newColumnDimensions;
return $this;
}
/**
* Refresh row dimensions
*
* @return PHPExcel_Worksheet
*/
public function refreshRowDimensions()
{
$currentRowDimensions = $this->getRowDimensions();
$newRowDimensions = array();
foreach ($currentRowDimensions as $objRowDimension) {
$newRowDimensions[$objRowDimension->getRowIndex()] = $objRowDimension;
}
$this->_rowDimensions = $newRowDimensions;
return $this;
}
/**
* Calculate worksheet dimension
*
* @return string String containing the dimension of this worksheet
*/
public function calculateWorksheetDimension()
{
// Return
return 'A1' . ':' . $this->getHighestColumn() . $this->getHighestRow();
}
/**
* Calculate widths for auto-size columns
*
* @param boolean $calculateMergeCells Calculate merge cell width
* @return PHPExcel_Worksheet;
*/
public function calculateColumnWidths($calculateMergeCells = false)
{
// initialize $autoSizes array
$autoSizes = array();
foreach ($this->getColumnDimensions() as $colDimension) {
if ($colDimension->getAutoSize()) {
$autoSizes[$colDimension->getColumnIndex()] = -1;
}
}
// There is only something to do if there are some auto-size columns
if (!empty($autoSizes)) {
// build list of cells references that participate in a merge
$isMergeCell = array();
foreach ($this->getMergeCells() as $cells) {
foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cells) as $cellReference) {
$isMergeCell[$cellReference] = true;
}
}
// loop through all cells in the worksheet
foreach ($this->getCellCollection(false) as $cellID) {
$cell = $this->getCell($cellID);
if (isset($autoSizes[$cell->getColumn()])) {
// Determine width if cell does not participate in a merge
if (!isset($isMergeCell[$cell->getCoordinate()])) {
// Calculated value
$cellValue = $cell->getCalculatedValue();
// To formatted string
$cellValue = PHPExcel_Style_NumberFormat::toFormattedString($cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
$autoSizes[$cell->getColumn()] = max(
(float)$autoSizes[$cell->getColumn()],
(float)PHPExcel_Shared_Font::calculateColumnWidth(
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
$cellValue,
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
$this->getDefaultStyle()->getFont()
)
);
}
}
}
// adjust column widths
foreach ($autoSizes as $columnIndex => $width) {
if ($width == -1) $width = $this->getDefaultColumnDimension()->getWidth();
$this->getColumnDimension($columnIndex)->setWidth($width);
}
}
return $this;
}
/**
* Get parent
*
* @return PHPExcel
*/
public function getParent() {
return $this->_parent;
}
/**
* Re-bind parent
*
* @param PHPExcel $parent
* @return PHPExcel_Worksheet
*/
public function rebindParent(PHPExcel $parent) {
$namedRanges = $this->_parent->getNamedRanges();
foreach ($namedRanges as $namedRange) {
$parent->addNamedRange($namedRange);
}
$this->_parent->removeSheetByIndex(
$this->_parent->getIndex($this)
);
$this->_parent = $parent;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->_title;
}
/**
* Set title
*
* @param string $pValue String containing the dimension of this worksheet
* @return PHPExcel_Worksheet
*/
public function setTitle($pValue = 'Worksheet')
{
// Is this a 'rename' or not?
if ($this->getTitle() == $pValue) {
return $this;
}
// Syntax check
self::_checkSheetTitle($pValue);
// Old title
$oldTitle = $this->getTitle();
// Is there already such sheet name?
if ($this->getParent()->getSheetByName($pValue)) {
// Use name, but append with lowest possible integer
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
}
$i = 1;
while ($this->getParent()->getSheetByName($pValue . ' ' . $i)) {
++$i;
if ($i == 10) {
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,28);
}
} elseif ($i == 100) {
if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,27);
}
}
}
$altTitle = $pValue . ' ' . $i;
return $this->setTitle($altTitle);
}
// Set title
$this->_title = $pValue;
$this->_dirty = true;
// New title
$newTitle = $this->getTitle();
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->getParent(), $oldTitle, $newTitle);
return $this;
}
/**
* Get sheet state
*
* @return string Sheet state (visible, hidden, veryHidden)
*/
public function getSheetState() {
return $this->_sheetState;
}
/**
* Set sheet state
*
* @param string $value Sheet state (visible, hidden, veryHidden)
* @return PHPExcel_Worksheet
*/
public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) {
$this->_sheetState = $value;
return $this;
}
/**
* Get page setup
*
* @return PHPExcel_Worksheet_PageSetup
*/
public function getPageSetup()
{
return $this->_pageSetup;
}
/**
* Set page setup
*
* @param PHPExcel_Worksheet_PageSetup $pValue
* @return PHPExcel_Worksheet
*/
public function setPageSetup(PHPExcel_Worksheet_PageSetup $pValue)
{
$this->_pageSetup = $pValue;
return $this;
}
/**
* Get page margins
*
* @return PHPExcel_Worksheet_PageMargins
*/
public function getPageMargins()
{
return $this->_pageMargins;
}
/**
* Set page margins
*
* @param PHPExcel_Worksheet_PageMargins $pValue
* @return PHPExcel_Worksheet
*/
public function setPageMargins(PHPExcel_Worksheet_PageMargins $pValue)
{
$this->_pageMargins = $pValue;
return $this;
}
/**
* Get page header/footer
*
* @return PHPExcel_Worksheet_HeaderFooter
*/
public function getHeaderFooter()
{
return $this->_headerFooter;
}
/**
* Set page header/footer
*
* @param PHPExcel_Worksheet_HeaderFooter $pValue
* @return PHPExcel_Worksheet
*/
public function setHeaderFooter(PHPExcel_Worksheet_HeaderFooter $pValue)
{
$this->_headerFooter = $pValue;
return $this;
}
/**
* Get sheet view
*
* @return PHPExcel_Worksheet_HeaderFooter
*/
public function getSheetView()
{
return $this->_sheetView;
}
/**
* Set sheet view
*
* @param PHPExcel_Worksheet_SheetView $pValue
* @return PHPExcel_Worksheet
*/
public function setSheetView(PHPExcel_Worksheet_SheetView $pValue)
{
$this->_sheetView = $pValue;
return $this;
}
/**
* Get Protection
*
* @return PHPExcel_Worksheet_Protection
*/
public function getProtection()
{
return $this->_protection;
}
/**
* Set Protection
*
* @param PHPExcel_Worksheet_Protection $pValue
* @return PHPExcel_Worksheet
*/
public function setProtection(PHPExcel_Worksheet_Protection $pValue)
{
$this->_protection = $pValue;
$this->_dirty = true;
return $this;
}
/**
* Get highest worksheet column
*
* @return string Highest column name
*/
public function getHighestColumn()
{
return $this->_cachedHighestColumn;
}
/**
* Get highest worksheet row
*
* @return int Highest row number
*/
public function getHighestRow()
{
return $this->_cachedHighestRow;
}
/**
* Set a cell value
*
* @param string $pCoordinate Coordinate of the cell
* @param mixed $pValue Value of the cell
* @param bool $returnCell Return the worksheet (false, default) or the cell (true)
* @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified
*/
public function setCellValue($pCoordinate = 'A1', $pValue = null, $returnCell = false)
{
$cell = $this->getCell($pCoordinate);
$cell->setValue($pValue);
if ($returnCell) {
return $cell;
}
return $this;
}
/**
* Set a cell value by using numeric cell coordinates
*
* @param string $pColumn Numeric column coordinate of the cell
* @param string $pRow Numeric row coordinate of the cell
* @param mixed $pValue Value of the cell
* @param bool $returnCell Return the worksheet (false, default) or the cell (true)
* @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified
*/
public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false)
{
$cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
$cell->setValue($pValue);
if ($returnCell) {
return $cell;
}
return $this;
}
/**
* Set a cell value
*
* @param string $pCoordinate Coordinate of the cell
* @param mixed $pValue Value of the cell
* @param string $pDataType Explicit data type
* @return PHPExcel_Worksheet
*/
public function setCellValueExplicit($pCoordinate = 'A1', $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
// Set value
$this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType);
return $this;
}
/**
* Set a cell value by using numeric cell coordinates
*
* @param string $pColumn Numeric column coordinate of the cell
* @param string $pRow Numeric row coordinate of the cell
* @param mixed $pValue Value of the cell
* @param string $pDataType Explicit data type
* @return PHPExcel_Worksheet
*/
public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
return $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValueExplicit($pValue, $pDataType);
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoordinate Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found
*/
public function getCell($pCoordinate = 'A1')
{
// Check cell collection
if ($this->_cellCollection->isDataSet($pCoordinate)) {
return $this->_cellCollection->getCacheData($pCoordinate);
}
// Worksheet reference?
if (strpos($pCoordinate, '!') !== false) {
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
return $this->getParent()->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]);
}
// Named range?
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if (!is_null($namedRange)) {
$pCoordinate = $namedRange->getRange();
return $namedRange->getWorksheet()->getCell($pCoordinate);
}
}
// Uppercase coordinate
$pCoordinate = strtoupper($pCoordinate);
if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) {
throw new Exception('Cell coordinate can not be a range of cells.');
} elseif (strpos($pCoordinate,'$') !== false) {
throw new Exception('Cell coordinate must not be absolute.');
} else {
// Create new cell object
// Coordinates
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
$cell = $this->_cellCollection->addCacheData($pCoordinate,new PHPExcel_Cell($aCoordinates[0], $aCoordinates[1], null, PHPExcel_Cell_DataType::TYPE_NULL, $this));
$this->_cellCollectionIsSorted = false;
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
$this->_cachedHighestColumn = $aCoordinates[0];
$this->_cachedHighestRow = max($this->_cachedHighestRow,$aCoordinates[1]);
// Cell needs appropriate xfIndex
$rowDimensions = $this->getRowDimensions();
$columnDimensions = $this->getColumnDimensions();
if ( isset($rowDimensions[$aCoordinates[1]]) && $rowDimensions[$aCoordinates[1]]->getXfIndex() !== null ) {
// then there is a row dimension with explicit style, assign it to the cell
$cell->setXfIndex($rowDimensions[$aCoordinates[1]]->getXfIndex());
} else if ( isset($columnDimensions[$aCoordinates[0]]) ) {
// then there is a column dimension, assign it to the cell
$cell->setXfIndex($columnDimensions[$aCoordinates[0]]->getXfIndex());
} else {
// set to default index
$cell->setXfIndex(0);
}
return $cell;
}
}
/**
* Get cell at a specific coordinate by using numeric cell coordinates
*
* @param string $pColumn Numeric column coordinate of the cell
* @param string $pRow Numeric row coordinate of the cell
* @return PHPExcel_Cell Cell that was found
*/
public function getCellByColumnAndRow($pColumn = 0, $pRow = 1)
{
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
$coordinate = $columnLetter . $pRow;
if (!$this->_cellCollection->isDataSet($coordinate)) {
$cell = $this->_cellCollection->addCacheData($coordinate, new PHPExcel_Cell($columnLetter, $pRow, null, PHPExcel_Cell_DataType::TYPE_NULL, $this));
$this->_cellCollectionIsSorted = false;
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
$this->_cachedHighestColumn = $columnLetter;
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
return $cell;
}
return $this->_cellCollection->getCacheData($coordinate);
}
/**
* Cell at a specific coordinate exists?
*
* @param string $pCoordinate Coordinate of the cell
* @throws Exception
* @return boolean
*/
public function cellExists($pCoordinate = 'A1')
{
// Worksheet reference?
if (strpos($pCoordinate, '!') !== false) {
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
return $this->getParent()->getSheetByName($worksheetReference[0])->cellExists($worksheetReference[1]);
}
// Named range?
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if (!is_null($namedRange)) {
$pCoordinate = $namedRange->getRange();
if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) {
if (!$namedRange->getLocalOnly()) {
return $namedRange->getWorksheet()->cellExists($pCoordinate);
} else {
throw new Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
}
}
}
}
// Uppercase coordinate
$pCoordinate = strtoupper($pCoordinate);
if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) {
throw new Exception('Cell coordinate can not be a range of cells.');
} elseif (strpos($pCoordinate,'$') !== false) {
throw new Exception('Cell coordinate must not be absolute.');
} else {
// Coordinates
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
// Cell exists?
return $this->_cellCollection->isDataSet($pCoordinate);
}
}
/**
* Cell at a specific coordinate by using numeric cell coordinates exists?
*
* @param string $pColumn Numeric column coordinate of the cell
* @param string $pRow Numeric row coordinate of the cell
* @return boolean
*/
public function cellExistsByColumnAndRow($pColumn = 0, $pRow = 1)
{
return $this->cellExists(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
}
/**
* Get row dimension at a specific row
*
* @param int $pRow Numeric index of the row
* @return PHPExcel_Worksheet_RowDimension
*/
public function getRowDimension($pRow = 1)
{
// Found
$found = null;
// Get row dimension
if (!isset($this->_rowDimensions[$pRow])) {
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
}
return $this->_rowDimensions[$pRow];
}
/**
* Get column dimension at a specific column
*
* @param string $pColumn String index of the column
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function getColumnDimension($pColumn = 'A')
{
// Uppercase coordinate
$pColumn = strtoupper($pColumn);
// Fetch dimensions
if (!isset($this->_columnDimensions[$pColumn])) {
$this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn);
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn))
$this->_cachedHighestColumn = $pColumn;
}
return $this->_columnDimensions[$pColumn];
}
/**
* Get column dimension at a specific column by using numeric cell coordinates
*
* @param string $pColumn Numeric column coordinate of the cell
* @param string $pRow Numeric row coordinate of the cell
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function getColumnDimensionByColumn($pColumn = 0)
{
return $this->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($pColumn));
}
/**
* Get styles
*
* @return PHPExcel_Style[]
*/
public function getStyles()
{
return $this->_styles;
}
/**
* Get default style of workbork.
*
* @deprecated
* @return PHPExcel_Style
* @throws Exception
*/
public function getDefaultStyle()
{
return $this->_parent->getDefaultStyle();
}
/**
* Set default style - should only be used by PHPExcel_IReader implementations!
*
* @deprecated
* @param PHPExcel_Style $value
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function setDefaultStyle(PHPExcel_Style $pValue)
{
$this->_parent->getDefaultStyle()->applyFromArray(array(
'font' => array(
'name' => $pValue->getFont()->getName(),
'size' => $pValue->getFont()->getSize(),
),
));
return $this;
}
/**
* Get style for cell
*
* @param string $pCellCoordinate Cell coordinate to get style for
* @return PHPExcel_Style
* @throws Exception
*/
public function getStyle($pCellCoordinate = 'A1')
{
// set this sheet as active
$this->_parent->setActiveSheetIndex($this->_parent->getIndex($this));
// set cell coordinate as active
$this->setSelectedCells($pCellCoordinate);
return $this->_parent->getCellXfSupervisor();
}
/**
* Get conditional styles for a cell
*
* @param string $pCoordinate
* @return PHPExcel_Style_Conditional[]
*/
public function getConditionalStyles($pCoordinate = 'A1')
{
if (!isset($this->_conditionalStylesCollection[$pCoordinate])) {
$this->_conditionalStylesCollection[$pCoordinate] = array();
}
return $this->_conditionalStylesCollection[$pCoordinate];
}
/**
* Do conditional styles exist for this cell?
*
* @param string $pCoordinate
* @return boolean
*/
public function conditionalStylesExists($pCoordinate = 'A1')
{
if (isset($this->_conditionalStylesCollection[$pCoordinate])) {
return true;
}
return false;
}
/**
* Removes conditional styles for a cell
*
* @param string $pCoordinate
* @return PHPExcel_Worksheet
*/
public function removeConditionalStyles($pCoordinate = 'A1')
{
unset($this->_conditionalStylesCollection[$pCoordinate]);
return $this;
}
/**
* Get collection of conditional styles
*
* @return array
*/
public function getConditionalStylesCollection()
{
return $this->_conditionalStylesCollection;
}
/**
* Set conditional styles
*
* @param $pCoordinate string E.g. 'A1'
* @param $pValue PHPExcel_Style_Conditional[]
* @return PHPExcel_Worksheet
*/
public function setConditionalStyles($pCoordinate = 'A1', $pValue)
{
$this->_conditionalStylesCollection[$pCoordinate] = $pValue;
return $this;
}
/**
* Get style for cell by using numeric cell coordinates
*
* @param int $pColumn Numeric column coordinate of the cell
* @param int $pRow Numeric row coordinate of the cell
* @return PHPExcel_Style
*/
public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1)
{
return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
}
/**
* Set shared cell style to a range of cells
*
* Please note that this will overwrite existing cell styles for cells in range!
*
* @deprecated
* @param PHPExcel_Style $pSharedCellStyle Cell style to share
* @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function setSharedStyle(PHPExcel_Style $pSharedCellStyle = null, $pRange = '')
{
$this->duplicateStyle($pSharedCellStyle, $pRange);
return $this;
}
/**
* Duplicate cell style to a range of cells
*
* Please note that this will overwrite existing cell styles for cells in range!
*
* @param PHPExcel_Style $pCellStyle Cell style to duplicate
* @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function duplicateStyle(PHPExcel_Style $pCellStyle = null, $pRange = '')
{
// make sure we have a real style and not supervisor
$style = $pCellStyle->getIsSupervisor() ? $pCellStyle->getSharedComponent() : $pCellStyle;
// Add the style to the workbook if necessary
$workbook = $this->_parent;
if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) {
// there is already such cell Xf in our collection
$xfIndex = $existingStyle->getIndex();
} else {
// we don't have such a cell Xf, need to add
$workbook->addCellXf($pCellStyle);
$xfIndex = $pCellStyle->getIndex();
}
// Uppercase coordinate
$pRange = strtoupper($pRange);
// Is it a cell range or a single cell?
$rangeA = '';
$rangeB = '';
if (strpos($pRange, ':') === false) {
$rangeA = $pRange;
$rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
}
// Calculate range outer borders
$rangeStart = PHPExcel_Cell::coordinateFromString($rangeA);
$rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB);
// Translate column into index
$rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1;
$rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1;
// Make sure we can loop upwards on rows and columns
if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
$tmp = $rangeStart;
$rangeStart = $rangeEnd;
$rangeEnd = $tmp;
}
// Loop through cells and apply styles
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
$this->getCell(PHPExcel_Cell::stringFromColumnIndex($col) . $row)->setXfIndex($xfIndex);
}
}
return $this;
}
/**
* Duplicate cell style array to a range of cells
*
* Please note that this will overwrite existing cell styles for cells in range,
* if they are in the styles array. For example, if you decide to set a range of
* cells to font bold, only include font bold in the styles array.
*
* @deprecated
* @param array $pStyles Array containing style information
* @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
* @param boolean $pAdvanced Advanced mode for setting borders.
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function duplicateStyleArray($pStyles = null, $pRange = '', $pAdvanced = true)
{
$this->getStyle($pRange)->applyFromArray($pStyles, $pAdvanced);
return $this;
}
/**
* Set break on a cell
*
* @param string $pCell Cell coordinate (e.g. A1)
* @param int $pBreak Break type (type of PHPExcel_Worksheet::BREAK_*)
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function setBreak($pCell = 'A1', $pBreak = PHPExcel_Worksheet::BREAK_NONE)
{
// Uppercase coordinate
$pCell = strtoupper($pCell);
if ($pCell != '') {
$this->_breaks[$pCell] = $pBreak;
} else {
throw new Exception('No cell coordinate specified.');
}
return $this;
}
/**
* Set break on a cell by using numeric cell coordinates
*
* @param integer $pColumn Numeric column coordinate of the cell
* @param integer $pRow Numeric row coordinate of the cell
* @param integer $pBreak Break type (type of PHPExcel_Worksheet::BREAK_*)
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function setBreakByColumnAndRow($pColumn = 0, $pRow = 1, $pBreak = PHPExcel_Worksheet::BREAK_NONE)
{
return $this->setBreak(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow, $pBreak);
}
/**
* Get breaks
*
* @return array[]
*/
public function getBreaks()
{
return $this->_breaks;
}
/**
* Set merge on a cell range
*
* @param string $pRange Cell range (e.g. A1:E1)
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function mergeCells($pRange = 'A1:A1')
{
// Uppercase coordinate
$pRange = strtoupper($pRange);
if (strpos($pRange,':') !== false) {
$this->_mergeCells[$pRange] = $pRange;
// make sure cells are created
// get the cells in the range
$aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
// create upper left cell if it does not already exist
$upperLeft = $aReferences[0];
if (!$this->cellExists($upperLeft)) {
$this->getCell($upperLeft)->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
}
// create or blank out the rest of the cells in the range
$count = count($aReferences);
for ($i = 1; $i < $count; $i++) {
$this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
}
} else {
throw new Exception('Merge must be set on a range of cells.');
}
return $this;
}
/**
* Set merge on a cell range by using numeric cell coordinates
*
* @param int $pColumn1 Numeric column coordinate of the first cell
* @param int $pRow1 Numeric row coordinate of the first cell
* @param int $pColumn2 Numeric column coordinate of the last cell
* @param int $pRow2 Numeric row coordinate of the last cell
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function mergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1)
{
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->mergeCells($cellRange);
}
/**
* Remove merge on a cell range
*
* @param string $pRange Cell range (e.g. A1:E1)
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function unmergeCells($pRange = 'A1:A1')
{
// Uppercase coordinate
$pRange = strtoupper($pRange);
if (strpos($pRange,':') !== false) {
if (isset($this->_mergeCells[$pRange])) {
unset($this->_mergeCells[$pRange]);
} else {
throw new Exception('Cell range ' . $pRange . ' not known as merged.');
}
} else {
throw new Exception('Merge can only be removed from a range of cells.');
}
return $this;
}
/**
* Remove merge on a cell range by using numeric cell coordinates
*
* @param int $pColumn1 Numeric column coordinate of the first cell
* @param int $pRow1 Numeric row coordinate of the first cell
* @param int $pColumn2 Numeric column coordinate of the last cell
* @param int $pRow2 Numeric row coordinate of the last cell
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function unmergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1)
{
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->unmergeCells($cellRange);
}
/**
* Get merge cells array.
*
* @return array[]
*/
public function getMergeCells()
{
return $this->_mergeCells;
}
/**
* Set merge cells array for the entire sheet. Use instead mergeCells() to merge
* a single cell range.
*
* @param array
*/
public function setMergeCells($pValue = array())
{
$this->_mergeCells = $pValue;
return $this;
}
/**
* Set protection on a cell range
*
* @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1)
* @param string $pPassword Password to unlock the protection
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function protectCells($pRange = 'A1', $pPassword = '', $pAlreadyHashed = false)
{
// Uppercase coordinate
$pRange = strtoupper($pRange);
if (!$pAlreadyHashed) {
$pPassword = PHPExcel_Shared_PasswordHasher::hashPassword($pPassword);
}
$this->_protectedCells[$pRange] = $pPassword;
return $this;
}
/**
* Set protection on a cell range by using numeric cell coordinates
*
* @param int $pColumn1 Numeric column coordinate of the first cell
* @param int $pRow1 Numeric row coordinate of the first cell
* @param int $pColumn2 Numeric column coordinate of the last cell
* @param int $pRow2 Numeric row coordinate of the last cell
* @param string $pPassword Password to unlock the protection
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function protectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false)
{
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->protectCells($cellRange, $pPassword, $pAlreadyHashed);
}
/**
* Remove protection on a cell range
*
* @param string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1)
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function unprotectCells($pRange = 'A1')
{
// Uppercase coordinate
$pRange = strtoupper($pRange);
if (isset($this->_protectedCells[$pRange])) {
unset($this->_protectedCells[$pRange]);
} else {
throw new Exception('Cell range ' . $pRange . ' not known as protected.');
}
return $this;
}
/**
* Remove protection on a cell range by using numeric cell coordinates
*
* @param int $pColumn1 Numeric column coordinate of the first cell
* @param int $pRow1 Numeric row coordinate of the first cell
* @param int $pColumn2 Numeric column coordinate of the last cell
* @param int $pRow2 Numeric row coordinate of the last cell
* @param string $pPassword Password to unlock the protection
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function unprotectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false)
{
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->unprotectCells($cellRange, $pPassword, $pAlreadyHashed);
}
/**
* Get protected cells
*
* @return array[]
*/
public function getProtectedCells()
{
return $this->_protectedCells;
}
/**
* Get Autofilter Range
*
* @return string
*/
public function getAutoFilter()
{
return $this->_autoFilter;
}
/**
* Set Autofilter Range
*
* @param string $pRange Cell range (i.e. A1:E10)
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function setAutoFilter($pRange = '')
{
// Uppercase coordinate
$pRange = strtoupper($pRange);
if (strpos($pRange,':') !== false) {
$this->_autoFilter = $pRange;
$this->_dirty = true;
} else {
throw new Exception('Autofilter must be set on a range of cells.');
}
return $this;
}
/**
* Set Autofilter Range by using numeric cell coordinates
*
* @param int $pColumn1 Numeric column coordinate of the first cell
* @param int $pRow1 Numeric row coordinate of the first cell
* @param int $pColumn2 Numeric column coordinate of the second cell
* @param int $pRow2 Numeric row coordinate of the second cell
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function setAutoFilterByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1)
{
return $this->setAutoFilter(
PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1
. ':' .
PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2
);
}
/**
* Remove autofilter
*
* @return PHPExcel_Worksheet
*/
public function removeAutoFilter()
{
$this->_autoFilter = '';
return $this;
}
/**
* Get Freeze Pane
*
* @return string
*/
public function getFreezePane()
{
return $this->_freezePane;
}
/**
* Freeze Pane
*
* @param string $pCell Cell (i.e. A1)
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function freezePane($pCell = '')
{
// Uppercase coordinate
$pCell = strtoupper($pCell);
if (strpos($pCell,':') === false && strpos($pCell,',') === false) {
$this->_freezePane = $pCell;
} else {
throw new Exception('Freeze pane can not be set on a range of cells.');
}
return $this;
}
/**
* Freeze Pane by using numeric cell coordinates
*
* @param int $pColumn Numeric column coordinate of the cell
* @param int $pRow Numeric row coordinate of the cell
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function freezePaneByColumnAndRow($pColumn = 0, $pRow = 1)
{
return $this->freezePane(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
}
/**
* Unfreeze Pane
*
* @return PHPExcel_Worksheet
*/
public function unfreezePane()
{
return $this->freezePane('');
}
/**
* Insert a new row, updating all possible related data
*
* @param int $pBefore Insert before this one
* @param int $pNumRows Number of rows to insert
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) {
if ($pBefore >= 1) {
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore('A' . $pBefore, 0, $pNumRows, $this);
} else {
throw new Exception("Rows can only be inserted before at least row 1.");
}
return $this;
}
/**
* Insert a new column, updating all possible related data
*
* @param int $pBefore Insert before this one
* @param int $pNumCols Number of columns to insert
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1) {
if (!is_numeric($pBefore)) {
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore($pBefore . '1', $pNumCols, 0, $this);
} else {
throw new Exception("Column references should not be numeric.");
}
return $this;
}
/**
* Insert a new column, updating all possible related data
*
* @param int $pBefore Insert before this one (numeric column coordinate of the cell)
* @param int $pNumCols Number of columns to insert
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) {
if ($pBefore >= 0) {
return $this->insertNewColumnBefore(PHPExcel_Cell::stringFromColumnIndex($pBefore), $pNumCols);
} else {
throw new Exception("Columns can only be inserted before at least column A (0).");
}
}
/**
* Delete a row, updating all possible related data
*
* @param int $pRow Remove starting with this one
* @param int $pNumRows Number of rows to remove
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function removeRow($pRow = 1, $pNumRows = 1) {
if ($pRow >= 1) {
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this);
} else {
throw new Exception("Rows to be deleted should at least start from row 1.");
}
return $this;
}
/**
* Remove a column, updating all possible related data
*
* @param int $pColumn Remove starting with this one
* @param int $pNumCols Number of columns to remove
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function removeColumn($pColumn = 'A', $pNumCols = 1) {
if (!is_numeric($pColumn)) {
$pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols);
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this);
} else {
throw new Exception("Column references should not be numeric.");
}
return $this;
}
/**
* Remove a column, updating all possible related data
*
* @param int $pColumn Remove starting with this one (numeric column coordinate of the cell)
* @param int $pNumCols Number of columns to remove
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) {
if ($pColumn >= 0) {
return $this->removeColumn(PHPExcel_Cell::stringFromColumnIndex($pColumn), $pNumCols);
} else {
throw new Exception("Columns to be deleted should at least start from column 0");
}
}
/**
* Show gridlines?
*
* @return boolean
*/
public function getShowGridlines() {
return $this->_showGridlines;
}
/**
* Set show gridlines
*
* @param boolean $pValue Show gridlines (true/false)
* @return PHPExcel_Worksheet
*/
public function setShowGridlines($pValue = false) {
$this->_showGridlines = $pValue;
return $this;
}
/**
* Print gridlines?
*
* @return boolean
*/
public function getPrintGridlines() {
return $this->_printGridlines;
}
/**
* Set print gridlines
*
* @param boolean $pValue Print gridlines (true/false)
* @return PHPExcel_Worksheet
*/
public function setPrintGridlines($pValue = false) {
$this->_printGridlines = $pValue;
return $this;
}
/**
* Show row and column headers?
*
* @return boolean
*/
public function getShowRowColHeaders() {
return $this->_showRowColHeaders;
}
/**
* Set show row and column headers
*
* @param boolean $pValue Show row and column headers (true/false)
* @return PHPExcel_Worksheet
*/
public function setShowRowColHeaders($pValue = false) {
$this->_showRowColHeaders = $pValue;
return $this;
}
/**
* Show summary below? (Row/Column outlining)
*
* @return boolean
*/
public function getShowSummaryBelow() {
return $this->_showSummaryBelow;
}
/**
* Set show summary below
*
* @param boolean $pValue Show summary below (true/false)
* @return PHPExcel_Worksheet
*/
public function setShowSummaryBelow($pValue = true) {
$this->_showSummaryBelow = $pValue;
return $this;
}
/**
* Show summary right? (Row/Column outlining)
*
* @return boolean
*/
public function getShowSummaryRight() {
return $this->_showSummaryRight;
}
/**
* Set show summary right
*
* @param boolean $pValue Show summary right (true/false)
* @return PHPExcel_Worksheet
*/
public function setShowSummaryRight($pValue = true) {
$this->_showSummaryRight = $pValue;
return $this;
}
/**
* Get comments
*
* @return PHPExcel_Comment[]
*/
public function getComments()
{
return $this->_comments;
}
/**
* Set comments array for the entire sheet.
*
* @param array of PHPExcel_Comment
* @return PHPExcel_Worksheet
*/
public function setComments($pValue = array())
{
$this->_comments = $pValue;
return $this;
}
/**
* Get comment for cell
*
* @param string $pCellCoordinate Cell coordinate to get comment for
* @return PHPExcel_Comment
* @throws Exception
*/
public function getComment($pCellCoordinate = 'A1')
{
// Uppercase coordinate
$pCellCoordinate = strtoupper($pCellCoordinate);
if (strpos($pCellCoordinate,':') !== false || strpos($pCellCoordinate,',') !== false) {
throw new Exception('Cell coordinate string can not be a range of cells.');
} else if (strpos($pCellCoordinate,'$') !== false) {
throw new Exception('Cell coordinate string must not be absolute.');
} else if ($pCellCoordinate == '') {
throw new Exception('Cell coordinate can not be zero-length string.');
} else {
// Check if we already have a comment for this cell.
// If not, create a new comment.
if (isset($this->_comments[$pCellCoordinate])) {
return $this->_comments[$pCellCoordinate];
} else {
$newComment = new PHPExcel_Comment();
$this->_comments[$pCellCoordinate] = $newComment;
return $newComment;
}
}
}
/**
* Get comment for cell by using numeric cell coordinates
*
* @param int $pColumn Numeric column coordinate of the cell
* @param int $pRow Numeric row coordinate of the cell
* @return PHPExcel_Comment
*/
public function getCommentByColumnAndRow($pColumn = 0, $pRow = 1)
{
return $this->getComment(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
}
/**
* Get selected cell
*
* @deprecated
* @return string
*/
public function getSelectedCell()
{
return $this->getSelectedCells();
}
/**
* Get active cell
*
* @return string Example: 'A1'
*/
public function getActiveCell()
{
return $this->_activeCell;
}
/**
* Get selected cells
*
* @return string
*/
public function getSelectedCells()
{
return $this->_selectedCells;
}
/**
* Selected cell
*
* @param string $pCell Cell (i.e. A1)
* @return PHPExcel_Worksheet
*/
public function setSelectedCell($pCoordinate = 'A1')
{
return $this->setSelectedCells($pCoordinate);
}
/**
* Select a range of cells.
*
* @param string $pCoordinate Cell range, examples: 'A1', 'B2:G5', 'A:C', '3:6'
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function setSelectedCells($pCoordinate = 'A1')
{
// Uppercase coordinate
$pCoordinate = strtoupper($pCoordinate);
// Convert 'A' to 'A:A'
$pCoordinate = preg_replace('/^([A-Z]+)$/', '${1}:${1}', $pCoordinate);
// Convert '1' to '1:1'
$pCoordinate = preg_replace('/^([0-9]+)$/', '${1}:${1}', $pCoordinate);
// Convert 'A:C' to 'A1:C1048576'
$pCoordinate = preg_replace('/^([A-Z]+):([A-Z]+)$/', '${1}1:${2}1048576', $pCoordinate);
// Convert '1:3' to 'A1:XFD3'
$pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate);
if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) {
list($first, ) = PHPExcel_Cell::splitRange($pCoordinate);
$this->_activeCell = $first[0];
} else {
$this->_activeCell = $pCoordinate;
}
$this->_selectedCells = $pCoordinate;
return $this;
}
/**
* Selected cell by using numeric cell coordinates
*
* @param int $pColumn Numeric column coordinate of the cell
* @param int $pRow Numeric row coordinate of the cell
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function setSelectedCellByColumnAndRow($pColumn = 0, $pRow = 1)
{
return $this->setSelectedCells(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
}
/**
* Get right-to-left
*
* @return boolean
*/
public function getRightToLeft() {
return $this->_rightToLeft;
}
/**
* Set right-to-left
*
* @param boolean $value Right-to-left true/false
* @return PHPExcel_Worksheet
*/
public function setRightToLeft($value = false) {
$this->_rightToLeft = $value;
return $this;
}
/**
* Fill worksheet from values in array
*
* @param array $source Source array
* @param mixed $nullValue Value in source array that stands for blank cell
* @param string $startCell Insert array starting from this cell address as the top left coordinate
* @param boolean $strictNullComparison Apply strict comparison when testing for null values in the array
* @throws Exception
* @return PHPExcel_Worksheet
*/
public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) {
if (is_array($source)) {
// Convert a 1-D array to 2-D (for ease of looping)
if (!is_array(end($source))) {
$source = array($source);
}
// start coordinate
list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($startCell);
// Loop through $source
foreach ($source as $rowData) {
$currentColumn = $startColumn;
foreach($rowData as $cellValue) {
if ($strictNullComparison) {
if ($cellValue !== $nullValue) {
// Set cell value
$this->getCell($currentColumn . $startRow)->setValue($cellValue);
}
} else {
if ($cellValue != $nullValue) {
// Set cell value
$this->getCell($currentColumn . $startRow)->setValue($cellValue);
}
}
++$currentColumn;
}
++$startRow;
}
} else {
throw new Exception("Parameter \$source should be an array.");
}
return $this;
}
/**
* Create array from a range of cells
*
* @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
* @param mixed $nullValue Value returned in the array entry if a cell doesn't exist
* @param boolean $calculateFormulas Should formulas be calculated?
* @param boolean $formatData Should formatting be applied to cell values?
* @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero
* True - Return rows and columns indexed by their actual row and column IDs
* @return array
*/
public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
// Returnvalue
$returnValue = array();
// Identify the range that we need to extract from the worksheet
list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($pRange);
$minCol = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] -1);
$minRow = $rangeStart[1];
$maxCol = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] -1);
$maxRow = $rangeEnd[1];
$maxCol++;
// Loop through rows
for ($row = $minRow; $row <= $maxRow; ++$row) {
$c = -1;
// Loop through columns in the current row
for ($col = $minCol; $col != $maxCol; ++$col) {
$rRef = ($returnCellRef) ? $row : $row-1;
$cRef = ($returnCellRef) ? $col : ++$c;
// Using getCell() will create a new cell if it doesn't already exist. We don't want that to happen
// so we test and retrieve directly against _cellCollection
if ($this->_cellCollection->isDataSet($col.$row)) {
// Cell exists
$cell = $this->_cellCollection->getCacheData($col.$row);
if ($cell->getValue() !== null) {
if ($cell->getValue() instanceof PHPExcel_RichText) {
$returnValue[$rRef][$cRef] = $cell->getValue()->getPlainText();
} else {
if ($calculateFormulas) {
$returnValue[$rRef][$cRef] = $cell->getCalculatedValue();
} else {
$returnValue[$rRef][$cRef] = $cell->getValue();
}
}
if ($formatData) {
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString($returnValue[$rRef][$cRef], $style->getNumberFormat()->getFormatCode());
}
} else {
// Cell holds a NULL
$returnValue[$rRef][$cRef] = $nullValue;
}
} else {
// Cell doesn't exist
$returnValue[$rRef][$cRef] = $nullValue;
}
}
}
// Return
return $returnValue;
}
/**
* Create array from a range of cells
*
* @param string $pNamedRange Name of the Named Range
* @param mixed $nullValue Value returned in the array entry if a cell doesn't exist
* @param boolean $calculateFormulas Should formulas be calculated?
* @param boolean $formatData Should formatting be applied to cell values?
* @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero
* True - Return rows and columns indexed by their actual row and column IDs
* @return array
* @throws Exception
*/
public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
$namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
if (!is_null($namedRange)) {
$pWorkSheet = $namedRange->getWorksheet();
$pCellRange = $namedRange->getRange();
return $pWorkSheet->rangeToArray( $pCellRange,
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
}
throw new Exception('Named Range '.$pNamedRange.' does not exist.');
}
/**
* Create array from worksheet
*
* @param mixed $nullValue Value returned in the array entry if a cell doesn't exist
* @param boolean $calculateFormulas Should formulas be calculated?
* @param boolean $formatData Should formatting be applied to cell values?
* @param boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero
* True - Return rows and columns indexed by their actual row and column IDs
* @return array
*/
public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
// Garbage collect...
$this->garbageCollect();
// Identify the range that we need to extract from the worksheet
$maxCol = $this->getHighestColumn();
$maxRow = $this->getHighestRow();
// Return
return $this->rangeToArray( 'A1:'.$maxCol.$maxRow,
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
}
/**
* Get row iterator
*
* @return PHPExcel_Worksheet_RowIterator
*/
public function getRowIterator() {
return new PHPExcel_Worksheet_RowIterator($this);
}
/**
* Run PHPExcel garabage collector.
*
* @return PHPExcel_Worksheet
*/
public function garbageCollect() {
// Build a reference table from images
// $imageCoordinates = array();
// $iterator = $this->getDrawingCollection()->getIterator();
// while ($iterator->valid()) {
// $imageCoordinates[$iterator->current()->getCoordinates()] = true;
//
// $iterator->next();
// }
//
// Lookup highest column and highest row if cells are cleaned
$highestColumn = -1;
$highestRow = 1;
// Find cells that can be cleaned
$col = $row = array();
foreach ($this->_cellCollection->getCellList() as $coord) {
list($c,$r) = sscanf($coord,'%[A-Z]%d');
$row[$r] = $r;
$col[$c] = strlen($c).$c;
}
if (count($row) > 0) {
// Determine highest column and row
$highestRow = max($row);
$highestColumn = PHPExcel_Cell::columnIndexFromString(substr(max($col),1));
}
// Loop through column dimensions
foreach ($this->_columnDimensions as $dimension) {
$highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex()));
}
// Loop through row dimensions
foreach ($this->_rowDimensions as $dimension) {
$highestRow = max($highestRow,$dimension->getRowIndex());
}
// Cache values
if ($highestColumn < 0) {
$this->_cachedHighestColumn = 'A';
} else {
$this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn);
}
$this->_cachedHighestRow = $highestRow;
// Return
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
if ($this->_dirty) {
$this->_hash = md5( $this->_title .
$this->_autoFilter .
($this->_protection->isProtectionEnabled() ? 't' : 'f') .
__CLASS__
);
$this->_dirty = false;
}
return $this->_hash;
}
/**
* Extract worksheet title from range.
*
* Example: extractSheetTitle("testSheet!A1") ==> 'A1'
* Example: extractSheetTitle("'testSheet 1'!A1", true) ==> array('testSheet 1', 'A1');
*
* @param string $pRange Range to extract title from
* @param bool $returnRange Return range? (see example)
* @return mixed
*/
public static function extractSheetTitle($pRange, $returnRange = false) {
// Sheet title included?
if (($sep = strpos($pRange, '!')) === false) {
return '';
}
if ($returnRange) {
return array( trim(substr($pRange, 0, $sep),"'"),
substr($pRange, $sep + 1)
);
}
return substr($pRange, $sep + 1);
}
/**
* Get hyperlink
*
* @param string $pCellCoordinate Cell coordinate to get hyperlink for
*/
public function getHyperlink($pCellCoordinate = 'A1')
{
// return hyperlink if we already have one
if (isset($this->_hyperlinkCollection[$pCellCoordinate])) {
return $this->_hyperlinkCollection[$pCellCoordinate];
}
// else create hyperlink
$this->_hyperlinkCollection[$pCellCoordinate] = new PHPExcel_Cell_Hyperlink();
return $this->_hyperlinkCollection[$pCellCoordinate];
}
/**
* Set hyperlnk
*
* @param string $pCellCoordinate Cell coordinate to insert hyperlink
* @param PHPExcel_Cell_Hyperlink $pHyperlink
* @return PHPExcel_Worksheet
*/
public function setHyperlink($pCellCoordinate = 'A1', PHPExcel_Cell_Hyperlink $pHyperlink = null)
{
if ($pHyperlink === null) {
unset($this->_hyperlinkCollection[$pCellCoordinate]);
} else {
$this->_hyperlinkCollection[$pCellCoordinate] = $pHyperlink;
}
return $this;
}
/**
* Hyperlink at a specific coordinate exists?
*
* @param string $pCellCoordinate
* @return boolean
*/
public function hyperlinkExists($pCoordinate = 'A1')
{
return isset($this->_hyperlinkCollection[$pCoordinate]);
}
/**
* Get collection of hyperlinks
*
* @return PHPExcel_Cell_Hyperlink[]
*/
public function getHyperlinkCollection()
{
return $this->_hyperlinkCollection;
}
/**
* Get data validation
*
* @param string $pCellCoordinate Cell coordinate to get data validation for
*/
public function getDataValidation($pCellCoordinate = 'A1')
{
// return data validation if we already have one
if (isset($this->_dataValidationCollection[$pCellCoordinate])) {
return $this->_dataValidationCollection[$pCellCoordinate];
}
// else create data validation
$this->_dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation();
return $this->_dataValidationCollection[$pCellCoordinate];
}
/**
* Set data validation
*
* @param string $pCellCoordinate Cell coordinate to insert data validation
* @param PHPExcel_Cell_DataValidation $pDataValidation
* @return PHPExcel_Worksheet
*/
public function setDataValidation($pCellCoordinate = 'A1', PHPExcel_Cell_DataValidation $pDataValidation = null)
{
if ($pDataValidation === null) {
unset($this->_dataValidationCollection[$pCellCoordinate]);
} else {
$this->_dataValidationCollection[$pCellCoordinate] = $pDataValidation;
}
return $this;
}
/**
* Data validation at a specific coordinate exists?
*
* @param string $pCellCoordinate
* @return boolean
*/
public function dataValidationExists($pCoordinate = 'A1')
{
return isset($this->_dataValidationCollection[$pCoordinate]);
}
/**
* Get collection of data validations
*
* @return PHPExcel_Cell_DataValidation[]
*/
public function getDataValidationCollection()
{
return $this->_dataValidationCollection;
}
/**
* Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet
*
* @param string $range
* @return string Adjusted range value
*/
public function shrinkRangeToFit($range) {
$maxCol = $this->getHighestColumn();
$maxRow = $this->getHighestRow();
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
$rangeBlocks = explode(' ',$range);
foreach ($rangeBlocks as &$rangeSet) {
$rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet);
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); }
if ($rangeBoundaries[0][1] > $maxRow) { $rangeBoundaries[0][1] = $maxRow; }
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); }
if ($rangeBoundaries[1][1] > $maxRow) { $rangeBoundaries[1][1] = $maxRow; }
$rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1];
}
unset($rangeSet);
$stRange = implode(' ',$rangeBlocks);
return $stRange;
}
/**
* Get tab color
*
* @return PHPExcel_Style_Color
*/
public function getTabColor()
{
if (is_null($this->_tabColor))
$this->_tabColor = new PHPExcel_Style_Color();
return $this->_tabColor;
}
/**
* Reset tab color
*
* @return PHPExcel_Worksheet
*/
public function resetTabColor()
{
$this->_tabColor = null;
unset($this->_tabColor);
return $this;
}
/**
* Tab color set?
*
* @return boolean
*/
public function isTabColorSet()
{
return !is_null($this->_tabColor);
}
/**
* Copy worksheet (!= clone!)
*
* @return PHPExcel_Worksheet
*/
public function copy() {
$copied = clone $this;
return $copied;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
foreach ($this as $key => $val) {
if ($key == '_parent') {
continue;
}
if (is_object($val) || (is_array($val))) {
if ($key == '_cellCollection') {
$newCollection = clone $this->_cellCollection;
$newCollection->copyCellCollection($this);
$this->_cellCollection = $newCollection;
} elseif ($key == '_drawingCollection') {
$newCollection = clone $this->_drawingCollection;
$this->_drawingCollection = $newCollection;
} else {
$this->{$key} = unserialize(serialize($val));
}
}
}
}
}
| zysms | trunk/zysms/customer/PHPExcel/Worksheet.php | PHP | asf20 | 67,544 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Calculation_ExceptionHandler
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_ExceptionHandler {
/**
* Register errorhandler
*/
public function __construct() {
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
}
/**
* Unregister errorhandler
*/
public function __destruct() {
restore_error_handler();
}
}
| zysms | trunk/zysms/customer/PHPExcel/Calculation/ExceptionHandler.php | PHP | asf20 | 1,572 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/trendClass.php';
/** LOG_GAMMA_X_MAX_VALUE */
define('LOG_GAMMA_X_MAX_VALUE', 2.55e305);
/** XMININ */
define('XMININ', 2.23e-308);
/** EPS */
define('EPS', 2.22e-16);
/** SQRT2PI */
define('SQRT2PI', 2.5066282746310005024157652848110452530069867406099);
/**
* PHPExcel_Calculation_Statistical
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Statistical {
private static function _checkTrendArrays(&$array1,&$array2) {
if (!is_array($array1)) { $array1 = array($array1); }
if (!is_array($array2)) { $array2 = array($array2); }
$array1 = PHPExcel_Calculation_Functions::flattenArray($array1);
$array2 = PHPExcel_Calculation_Functions::flattenArray($array2);
foreach($array1 as $key => $value) {
if ((is_bool($value)) || (is_string($value)) || (is_null($value))) {
unset($array1[$key]);
unset($array2[$key]);
}
}
foreach($array2 as $key => $value) {
if ((is_bool($value)) || (is_string($value)) || (is_null($value))) {
unset($array1[$key]);
unset($array2[$key]);
}
}
$array1 = array_merge($array1);
$array2 = array_merge($array2);
return True;
} // function _checkTrendArrays()
/**
* Beta function.
*
* @author Jaco van Kooten
*
* @param p require p>0
* @param q require q>0
* @return 0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow
*/
private static function _beta($p, $q) {
if ($p <= 0.0 || $q <= 0.0 || ($p + $q) > LOG_GAMMA_X_MAX_VALUE) {
return 0.0;
} else {
return exp(self::_logBeta($p, $q));
}
} // function _beta()
/**
* Incomplete beta function
*
* @author Jaco van Kooten
* @author Paul Meagher
*
* The computation is based on formulas from Numerical Recipes, Chapter 6.4 (W.H. Press et al, 1992).
* @param x require 0<=x<=1
* @param p require p>0
* @param q require q>0
* @return 0 if x<0, p<=0, q<=0 or p+q>2.55E305 and 1 if x>1 to avoid errors and over/underflow
*/
private static function _incompleteBeta($x, $p, $q) {
if ($x <= 0.0) {
return 0.0;
} elseif ($x >= 1.0) {
return 1.0;
} elseif (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > LOG_GAMMA_X_MAX_VALUE)) {
return 0.0;
}
$beta_gam = exp((0 - self::_logBeta($p, $q)) + $p * log($x) + $q * log(1.0 - $x));
if ($x < ($p + 1.0) / ($p + $q + 2.0)) {
return $beta_gam * self::_betaFraction($x, $p, $q) / $p;
} else {
return 1.0 - ($beta_gam * self::_betaFraction(1 - $x, $q, $p) / $q);
}
} // function _incompleteBeta()
// Function cache for _logBeta function
private static $_logBetaCache_p = 0.0;
private static $_logBetaCache_q = 0.0;
private static $_logBetaCache_result = 0.0;
/**
* The natural logarithm of the beta function.
* @param p require p>0
* @param q require q>0
* @return 0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow
* @author Jaco van Kooten
*/
private static function _logBeta($p, $q) {
if ($p != self::$_logBetaCache_p || $q != self::$_logBetaCache_q) {
self::$_logBetaCache_p = $p;
self::$_logBetaCache_q = $q;
if (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > LOG_GAMMA_X_MAX_VALUE)) {
self::$_logBetaCache_result = 0.0;
} else {
self::$_logBetaCache_result = self::_logGamma($p) + self::_logGamma($q) - self::_logGamma($p + $q);
}
}
return self::$_logBetaCache_result;
} // function _logBeta()
/**
* Evaluates of continued fraction part of incomplete beta function.
* Based on an idea from Numerical Recipes (W.H. Press et al, 1992).
* @author Jaco van Kooten
*/
private static function _betaFraction($x, $p, $q) {
$c = 1.0;
$sum_pq = $p + $q;
$p_plus = $p + 1.0;
$p_minus = $p - 1.0;
$h = 1.0 - $sum_pq * $x / $p_plus;
if (abs($h) < XMININ) {
$h = XMININ;
}
$h = 1.0 / $h;
$frac = $h;
$m = 1;
$delta = 0.0;
while ($m <= MAX_ITERATIONS && abs($delta-1.0) > PRECISION ) {
$m2 = 2 * $m;
// even index for d
$d = $m * ($q - $m) * $x / ( ($p_minus + $m2) * ($p + $m2));
$h = 1.0 + $d * $h;
if (abs($h) < XMININ) {
$h = XMININ;
}
$h = 1.0 / $h;
$c = 1.0 + $d / $c;
if (abs($c) < XMININ) {
$c = XMININ;
}
$frac *= $h * $c;
// odd index for d
$d = -($p + $m) * ($sum_pq + $m) * $x / (($p + $m2) * ($p_plus + $m2));
$h = 1.0 + $d * $h;
if (abs($h) < XMININ) {
$h = XMININ;
}
$h = 1.0 / $h;
$c = 1.0 + $d / $c;
if (abs($c) < XMININ) {
$c = XMININ;
}
$delta = $h * $c;
$frac *= $delta;
++$m;
}
return $frac;
} // function _betaFraction()
/**
* logGamma function
*
* @version 1.1
* @author Jaco van Kooten
*
* Original author was Jaco van Kooten. Ported to PHP by Paul Meagher.
*
* The natural logarithm of the gamma function. <br />
* Based on public domain NETLIB (Fortran) code by W. J. Cody and L. Stoltz <br />
* Applied Mathematics Division <br />
* Argonne National Laboratory <br />
* Argonne, IL 60439 <br />
* <p>
* References:
* <ol>
* <li>W. J. Cody and K. E. Hillstrom, 'Chebyshev Approximations for the Natural
* Logarithm of the Gamma Function,' Math. Comp. 21, 1967, pp. 198-203.</li>
* <li>K. E. Hillstrom, ANL/AMD Program ANLC366S, DGAMMA/DLGAMA, May, 1969.</li>
* <li>Hart, Et. Al., Computer Approximations, Wiley and sons, New York, 1968.</li>
* </ol>
* </p>
* <p>
* From the original documentation:
* </p>
* <p>
* This routine calculates the LOG(GAMMA) function for a positive real argument X.
* Computation is based on an algorithm outlined in references 1 and 2.
* The program uses rational functions that theoretically approximate LOG(GAMMA)
* to at least 18 significant decimal digits. The approximation for X > 12 is from
* reference 3, while approximations for X < 12.0 are similar to those in reference
* 1, but are unpublished. The accuracy achieved depends on the arithmetic system,
* the compiler, the intrinsic functions, and proper selection of the
* machine-dependent constants.
* </p>
* <p>
* Error returns: <br />
* The program returns the value XINF for X .LE. 0.0 or when overflow would occur.
* The computation is believed to be free of underflow and overflow.
* </p>
* @return MAX_VALUE for x < 0.0 or when overflow would occur, i.e. x > 2.55E305
*/
// Function cache for logGamma
private static $_logGammaCache_result = 0.0;
private static $_logGammaCache_x = 0.0;
private static function _logGamma($x) {
// Log Gamma related constants
static $lg_d1 = -0.5772156649015328605195174;
static $lg_d2 = 0.4227843350984671393993777;
static $lg_d4 = 1.791759469228055000094023;
static $lg_p1 = array( 4.945235359296727046734888,
201.8112620856775083915565,
2290.838373831346393026739,
11319.67205903380828685045,
28557.24635671635335736389,
38484.96228443793359990269,
26377.48787624195437963534,
7225.813979700288197698961 );
static $lg_p2 = array( 4.974607845568932035012064,
542.4138599891070494101986,
15506.93864978364947665077,
184793.2904445632425417223,
1088204.76946882876749847,
3338152.967987029735917223,
5106661.678927352456275255,
3074109.054850539556250927 );
static $lg_p4 = array( 14745.02166059939948905062,
2426813.369486704502836312,
121475557.4045093227939592,
2663432449.630976949898078,
29403789566.34553899906876,
170266573776.5398868392998,
492612579337.743088758812,
560625185622.3951465078242 );
static $lg_q1 = array( 67.48212550303777196073036,
1113.332393857199323513008,
7738.757056935398733233834,
27639.87074403340708898585,
54993.10206226157329794414,
61611.22180066002127833352,
36351.27591501940507276287,
8785.536302431013170870835 );
static $lg_q2 = array( 183.0328399370592604055942,
7765.049321445005871323047,
133190.3827966074194402448,
1136705.821321969608938755,
5267964.117437946917577538,
13467014.54311101692290052,
17827365.30353274213975932,
9533095.591844353613395747 );
static $lg_q4 = array( 2690.530175870899333379843,
639388.5654300092398984238,
41355999.30241388052042842,
1120872109.61614794137657,
14886137286.78813811542398,
101680358627.2438228077304,
341747634550.7377132798597,
446315818741.9713286462081 );
static $lg_c = array( -0.001910444077728,
8.4171387781295e-4,
-5.952379913043012e-4,
7.93650793500350248e-4,
-0.002777777777777681622553,
0.08333333333333333331554247,
0.0057083835261 );
// Rough estimate of the fourth root of logGamma_xBig
static $lg_frtbig = 2.25e76;
static $pnt68 = 0.6796875;
if ($x == self::$_logGammaCache_x) {
return self::$_logGammaCache_result;
}
$y = $x;
if ($y > 0.0 && $y <= LOG_GAMMA_X_MAX_VALUE) {
if ($y <= EPS) {
$res = -log(y);
} elseif ($y <= 1.5) {
// ---------------------
// EPS .LT. X .LE. 1.5
// ---------------------
if ($y < $pnt68) {
$corr = -log($y);
$xm1 = $y;
} else {
$corr = 0.0;
$xm1 = $y - 1.0;
}
if ($y <= 0.5 || $y >= $pnt68) {
$xden = 1.0;
$xnum = 0.0;
for ($i = 0; $i < 8; ++$i) {
$xnum = $xnum * $xm1 + $lg_p1[$i];
$xden = $xden * $xm1 + $lg_q1[$i];
}
$res = $corr + $xm1 * ($lg_d1 + $xm1 * ($xnum / $xden));
} else {
$xm2 = $y - 1.0;
$xden = 1.0;
$xnum = 0.0;
for ($i = 0; $i < 8; ++$i) {
$xnum = $xnum * $xm2 + $lg_p2[$i];
$xden = $xden * $xm2 + $lg_q2[$i];
}
$res = $corr + $xm2 * ($lg_d2 + $xm2 * ($xnum / $xden));
}
} elseif ($y <= 4.0) {
// ---------------------
// 1.5 .LT. X .LE. 4.0
// ---------------------
$xm2 = $y - 2.0;
$xden = 1.0;
$xnum = 0.0;
for ($i = 0; $i < 8; ++$i) {
$xnum = $xnum * $xm2 + $lg_p2[$i];
$xden = $xden * $xm2 + $lg_q2[$i];
}
$res = $xm2 * ($lg_d2 + $xm2 * ($xnum / $xden));
} elseif ($y <= 12.0) {
// ----------------------
// 4.0 .LT. X .LE. 12.0
// ----------------------
$xm4 = $y - 4.0;
$xden = -1.0;
$xnum = 0.0;
for ($i = 0; $i < 8; ++$i) {
$xnum = $xnum * $xm4 + $lg_p4[$i];
$xden = $xden * $xm4 + $lg_q4[$i];
}
$res = $lg_d4 + $xm4 * ($xnum / $xden);
} else {
// ---------------------------------
// Evaluate for argument .GE. 12.0
// ---------------------------------
$res = 0.0;
if ($y <= $lg_frtbig) {
$res = $lg_c[6];
$ysq = $y * $y;
for ($i = 0; $i < 6; ++$i)
$res = $res / $ysq + $lg_c[$i];
}
$res /= $y;
$corr = log($y);
$res = $res + log(SQRT2PI) - 0.5 * $corr;
$res += $y * ($corr - 1.0);
}
} else {
// --------------------------
// Return for bad arguments
// --------------------------
$res = MAX_VALUE;
}
// ------------------------------
// Final adjustments and return
// ------------------------------
self::$_logGammaCache_x = $x;
self::$_logGammaCache_result = $res;
return $res;
} // function _logGamma()
//
// Private implementation of the incomplete Gamma function
//
private static function _incompleteGamma($a,$x) {
static $max = 32;
$summer = 0;
for ($n=0; $n<=$max; ++$n) {
$divisor = $a;
for ($i=1; $i<=$n; ++$i) {
$divisor *= ($a + $i);
}
$summer += (pow($x,$n) / $divisor);
}
return pow($x,$a) * exp(0-$x) * $summer;
} // function _incompleteGamma()
//
// Private implementation of the Gamma function
//
private static function _gamma($data) {
if ($data == 0.0) return 0;
static $p0 = 1.000000000190015;
static $p = array ( 1 => 76.18009172947146,
2 => -86.50532032941677,
3 => 24.01409824083091,
4 => -1.231739572450155,
5 => 1.208650973866179e-3,
6 => -5.395239384953e-6
);
$y = $x = $data;
$tmp = $x + 5.5;
$tmp -= ($x + 0.5) * log($tmp);
$summer = $p0;
for ($j=1;$j<=6;++$j) {
$summer += ($p[$j] / ++$y);
}
return exp(0 - $tmp + log(SQRT2PI * $summer / $x));
} // function _gamma()
/***************************************************************************
* inverse_ncdf.php
* -------------------
* begin : Friday, January 16, 2004
* copyright : (C) 2004 Michael Nickerson
* email : nickersonm@yahoo.com
*
***************************************************************************/
private static function _inverse_ncdf($p) {
// Inverse ncdf approximation by Peter J. Acklam, implementation adapted to
// PHP by Michael Nickerson, using Dr. Thomas Ziegler's C implementation as
// a guide. http://home.online.no/~pjacklam/notes/invnorm/index.html
// I have not checked the accuracy of this implementation. Be aware that PHP
// will truncate the coeficcients to 14 digits.
// You have permission to use and distribute this function freely for
// whatever purpose you want, but please show common courtesy and give credit
// where credit is due.
// Input paramater is $p - probability - where 0 < p < 1.
// Coefficients in rational approximations
static $a = array( 1 => -3.969683028665376e+01,
2 => 2.209460984245205e+02,
3 => -2.759285104469687e+02,
4 => 1.383577518672690e+02,
5 => -3.066479806614716e+01,
6 => 2.506628277459239e+00
);
static $b = array( 1 => -5.447609879822406e+01,
2 => 1.615858368580409e+02,
3 => -1.556989798598866e+02,
4 => 6.680131188771972e+01,
5 => -1.328068155288572e+01
);
static $c = array( 1 => -7.784894002430293e-03,
2 => -3.223964580411365e-01,
3 => -2.400758277161838e+00,
4 => -2.549732539343734e+00,
5 => 4.374664141464968e+00,
6 => 2.938163982698783e+00
);
static $d = array( 1 => 7.784695709041462e-03,
2 => 3.224671290700398e-01,
3 => 2.445134137142996e+00,
4 => 3.754408661907416e+00
);
// Define lower and upper region break-points.
$p_low = 0.02425; //Use lower region approx. below this
$p_high = 1 - $p_low; //Use upper region approx. above this
if (0 < $p && $p < $p_low) {
// Rational approximation for lower region.
$q = sqrt(-2 * log($p));
return ((((($c[1] * $q + $c[2]) * $q + $c[3]) * $q + $c[4]) * $q + $c[5]) * $q + $c[6]) /
(((($d[1] * $q + $d[2]) * $q + $d[3]) * $q + $d[4]) * $q + 1);
} elseif ($p_low <= $p && $p <= $p_high) {
// Rational approximation for central region.
$q = $p - 0.5;
$r = $q * $q;
return ((((($a[1] * $r + $a[2]) * $r + $a[3]) * $r + $a[4]) * $r + $a[5]) * $r + $a[6]) * $q /
((((($b[1] * $r + $b[2]) * $r + $b[3]) * $r + $b[4]) * $r + $b[5]) * $r + 1);
} elseif ($p_high < $p && $p < 1) {
// Rational approximation for upper region.
$q = sqrt(-2 * log(1 - $p));
return -((((($c[1] * $q + $c[2]) * $q + $c[3]) * $q + $c[4]) * $q + $c[5]) * $q + $c[6]) /
(((($d[1] * $q + $d[2]) * $q + $d[3]) * $q + $d[4]) * $q + 1);
}
// If 0 < p < 1, return a null value
return PHPExcel_Calculation_Functions::NULL();
} // function _inverse_ncdf()
private static function _inverse_ncdf2($prob) {
// Approximation of inverse standard normal CDF developed by
// B. Moro, "The Full Monte," Risk 8(2), Feb 1995, 57-58.
$a1 = 2.50662823884;
$a2 = -18.61500062529;
$a3 = 41.39119773534;
$a4 = -25.44106049637;
$b1 = -8.4735109309;
$b2 = 23.08336743743;
$b3 = -21.06224101826;
$b4 = 3.13082909833;
$c1 = 0.337475482272615;
$c2 = 0.976169019091719;
$c3 = 0.160797971491821;
$c4 = 2.76438810333863E-02;
$c5 = 3.8405729373609E-03;
$c6 = 3.951896511919E-04;
$c7 = 3.21767881768E-05;
$c8 = 2.888167364E-07;
$c9 = 3.960315187E-07;
$y = $prob - 0.5;
if (abs($y) < 0.42) {
$z = ($y * $y);
$z = $y * ((($a4 * $z + $a3) * $z + $a2) * $z + $a1) / (((($b4 * $z + $b3) * $z + $b2) * $z + $b1) * $z + 1);
} else {
if ($y > 0) {
$z = log(-log(1 - $prob));
} else {
$z = log(-log($prob));
}
$z = $c1 + $z * ($c2 + $z * ($c3 + $z * ($c4 + $z * ($c5 + $z * ($c6 + $z * ($c7 + $z * ($c8 + $z * $c9)))))));
if ($y < 0) {
$z = -$z;
}
}
return $z;
} // function _inverse_ncdf2()
private static function _inverse_ncdf3($p) {
// ALGORITHM AS241 APPL. STATIST. (1988) VOL. 37, NO. 3.
// Produces the normal deviate Z corresponding to a given lower
// tail area of P; Z is accurate to about 1 part in 10**16.
//
// This is a PHP version of the original FORTRAN code that can
// be found at http://lib.stat.cmu.edu/apstat/
$split1 = 0.425;
$split2 = 5;
$const1 = 0.180625;
$const2 = 1.6;
// coefficients for p close to 0.5
$a0 = 3.3871328727963666080;
$a1 = 1.3314166789178437745E+2;
$a2 = 1.9715909503065514427E+3;
$a3 = 1.3731693765509461125E+4;
$a4 = 4.5921953931549871457E+4;
$a5 = 6.7265770927008700853E+4;
$a6 = 3.3430575583588128105E+4;
$a7 = 2.5090809287301226727E+3;
$b1 = 4.2313330701600911252E+1;
$b2 = 6.8718700749205790830E+2;
$b3 = 5.3941960214247511077E+3;
$b4 = 2.1213794301586595867E+4;
$b5 = 3.9307895800092710610E+4;
$b6 = 2.8729085735721942674E+4;
$b7 = 5.2264952788528545610E+3;
// coefficients for p not close to 0, 0.5 or 1.
$c0 = 1.42343711074968357734;
$c1 = 4.63033784615654529590;
$c2 = 5.76949722146069140550;
$c3 = 3.64784832476320460504;
$c4 = 1.27045825245236838258;
$c5 = 2.41780725177450611770E-1;
$c6 = 2.27238449892691845833E-2;
$c7 = 7.74545014278341407640E-4;
$d1 = 2.05319162663775882187;
$d2 = 1.67638483018380384940;
$d3 = 6.89767334985100004550E-1;
$d4 = 1.48103976427480074590E-1;
$d5 = 1.51986665636164571966E-2;
$d6 = 5.47593808499534494600E-4;
$d7 = 1.05075007164441684324E-9;
// coefficients for p near 0 or 1.
$e0 = 6.65790464350110377720;
$e1 = 5.46378491116411436990;
$e2 = 1.78482653991729133580;
$e3 = 2.96560571828504891230E-1;
$e4 = 2.65321895265761230930E-2;
$e5 = 1.24266094738807843860E-3;
$e6 = 2.71155556874348757815E-5;
$e7 = 2.01033439929228813265E-7;
$f1 = 5.99832206555887937690E-1;
$f2 = 1.36929880922735805310E-1;
$f3 = 1.48753612908506148525E-2;
$f4 = 7.86869131145613259100E-4;
$f5 = 1.84631831751005468180E-5;
$f6 = 1.42151175831644588870E-7;
$f7 = 2.04426310338993978564E-15;
$q = $p - 0.5;
// computation for p close to 0.5
if (abs($q) <= split1) {
$R = $const1 - $q * $q;
$z = $q * ((((((($a7 * $R + $a6) * $R + $a5) * $R + $a4) * $R + $a3) * $R + $a2) * $R + $a1) * $R + $a0) /
((((((($b7 * $R + $b6) * $R + $b5) * $R + $b4) * $R + $b3) * $R + $b2) * $R + $b1) * $R + 1);
} else {
if ($q < 0) {
$R = $p;
} else {
$R = 1 - $p;
}
$R = pow(-log($R),2);
// computation for p not close to 0, 0.5 or 1.
If ($R <= $split2) {
$R = $R - $const2;
$z = ((((((($c7 * $R + $c6) * $R + $c5) * $R + $c4) * $R + $c3) * $R + $c2) * $R + $c1) * $R + $c0) /
((((((($d7 * $R + $d6) * $R + $d5) * $R + $d4) * $R + $d3) * $R + $d2) * $R + $d1) * $R + 1);
} else {
// computation for p near 0 or 1.
$R = $R - $split2;
$z = ((((((($e7 * $R + $e6) * $R + $e5) * $R + $e4) * $R + $e3) * $R + $e2) * $R + $e1) * $R + $e0) /
((((((($f7 * $R + $f6) * $R + $f5) * $R + $f4) * $R + $f3) * $R + $f2) * $R + $f1) * $R + 1);
}
if ($q < 0) {
$z = -$z;
}
}
return $z;
} // function _inverse_ncdf3()
/**
* AVEDEV
*
* Returns the average of the absolute deviations of data points from their mean.
* AVEDEV is a measure of the variability in a data set.
*
* Excel Function:
* AVEDEV(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function AVEDEV() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
// Return value
$returnValue = null;
$aMean = self::AVERAGE($aArgs);
if ($aMean != PHPExcel_Calculation_Functions::DIV0()) {
$aCount = 0;
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) {
$arg = (integer) $arg;
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = abs($arg - $aMean);
} else {
$returnValue += abs($arg - $aMean);
}
++$aCount;
}
}
// Return
if ($aCount == 0) {
return PHPExcel_Calculation_Functions::DIV0();
}
return $returnValue / $aCount;
}
return PHPExcel_Calculation_Functions::NaN();
} // function AVEDEV()
/**
* AVERAGE
*
* Returns the average (arithmetic mean) of the arguments
*
* Excel Function:
* AVERAGE(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function AVERAGE() {
$returnValue = $aCount = 0;
// Loop through arguments
foreach (PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()) as $k => $arg) {
if ((is_bool($arg)) &&
((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) {
$arg = (integer) $arg;
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = $arg;
} else {
$returnValue += $arg;
}
++$aCount;
}
}
// Return
if ($aCount > 0) {
return $returnValue / $aCount;
} else {
return PHPExcel_Calculation_Functions::DIV0();
}
} // function AVERAGE()
/**
* AVERAGEA
*
* Returns the average of its arguments, including numbers, text, and logical values
*
* Excel Function:
* AVERAGEA(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function AVERAGEA() {
// Return value
$returnValue = null;
$aCount = 0;
// Loop through arguments
foreach (PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()) as $k => $arg) {
if ((is_bool($arg)) &&
(!PHPExcel_Calculation_Functions::isMatrixValue($k))) {
} else {
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
if (is_null($returnValue)) {
$returnValue = $arg;
} else {
$returnValue += $arg;
}
++$aCount;
}
}
}
// Return
if ($aCount > 0) {
return $returnValue / $aCount;
} else {
return PHPExcel_Calculation_Functions::DIV0();
}
} // function AVERAGEA()
/**
* AVERAGEIF
*
* Returns the average value from a range of cells that contain numbers within the list of arguments
*
* Excel Function:
* AVERAGEIF(value1[,value2[, ...]],condition)
*
* @access public
* @category Mathematical and Trigonometric Functions
* @param mixed $arg,... Data values
* @param string $condition The criteria that defines which cells will be checked.
* @return float
*/
public static function AVERAGEIF($aArgs,$condition,$averageArgs = array()) {
// Return value
$returnValue = 0;
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
$averageArgs = PHPExcel_Calculation_Functions::flattenArray($averageArgs);
if (count($averageArgs) == 0) {
$averageArgs = $aArgs;
}
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
// Loop through arguments
$aCount = 0;
foreach ($aArgs as $key => $arg) {
if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
$testCondition = '='.$arg.$condition;
if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
if ((is_null($returnValue)) || ($arg > $returnValue)) {
$returnValue += $arg;
++$aCount;
}
}
}
// Return
if ($aCount > 0) {
return $returnValue / $aCount;
} else {
return PHPExcel_Calculation_Functions::DIV0();
}
} // function AVERAGEIF()
/**
* BETADIST
*
* Returns the beta distribution.
*
* @param float $value Value at which you want to evaluate the distribution
* @param float $alpha Parameter to the distribution
* @param float $beta Parameter to the distribution
* @param boolean $cumulative
* @return float
*
*/
public static function BETADIST($value,$alpha,$beta,$rMin=0,$rMax=1) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha);
$beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta);
$rMin = PHPExcel_Calculation_Functions::flattenSingleValue($rMin);
$rMax = PHPExcel_Calculation_Functions::flattenSingleValue($rMax);
if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
if (($value < $rMin) || ($value > $rMax) || ($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($rMin > $rMax) {
$tmp = $rMin;
$rMin = $rMax;
$rMax = $tmp;
}
$value -= $rMin;
$value /= ($rMax - $rMin);
return self::_incompleteBeta($value,$alpha,$beta);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BETADIST()
/**
* BETAINV
*
* Returns the inverse of the beta distribution.
*
* @param float $probability Probability at which you want to evaluate the distribution
* @param float $alpha Parameter to the distribution
* @param float $beta Parameter to the distribution
* @param boolean $cumulative
* @return float
*
*/
public static function BETAINV($probability,$alpha,$beta,$rMin=0,$rMax=1) {
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
$alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha);
$beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta);
$rMin = PHPExcel_Calculation_Functions::flattenSingleValue($rMin);
$rMax = PHPExcel_Calculation_Functions::flattenSingleValue($rMax);
if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
if (($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax) || ($probability <= 0) || ($probability > 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($rMin > $rMax) {
$tmp = $rMin;
$rMin = $rMax;
$rMax = $tmp;
}
$a = 0;
$b = 2;
$i = 0;
while ((($b - $a) > PRECISION) && ($i++ < MAX_ITERATIONS)) {
$guess = ($a + $b) / 2;
$result = self::BETADIST($guess, $alpha, $beta);
if (($result == $probability) || ($result == 0)) {
$b = $a;
} elseif ($result > $probability) {
$b = $guess;
} else {
$a = $guess;
}
}
if ($i == MAX_ITERATIONS) {
return PHPExcel_Calculation_Functions::NA();
}
return round($rMin + $guess * ($rMax - $rMin),12);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BETAINV()
/**
* BINOMDIST
*
* Returns the individual term binomial distribution probability. Use BINOMDIST in problems with
* a fixed number of tests or trials, when the outcomes of any trial are only success or failure,
* when trials are independent, and when the probability of success is constant throughout the
* experiment. For example, BINOMDIST can calculate the probability that two of the next three
* babies born are male.
*
* @param float $value Number of successes in trials
* @param float $trials Number of trials
* @param float $probability Probability of success on each trial
* @param boolean $cumulative
* @return float
*
* @todo Cumulative distribution function
*
*/
public static function BINOMDIST($value, $trials, $probability, $cumulative) {
$value = floor(PHPExcel_Calculation_Functions::flattenSingleValue($value));
$trials = floor(PHPExcel_Calculation_Functions::flattenSingleValue($trials));
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
if ((is_numeric($value)) && (is_numeric($trials)) && (is_numeric($probability))) {
if (($value < 0) || ($value > $trials)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (($probability < 0) || ($probability > 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
$summer = 0;
for ($i = 0; $i <= $value; ++$i) {
$summer += PHPExcel_Calculation_MathTrig::COMBIN($trials,$i) * pow($probability,$i) * pow(1 - $probability,$trials - $i);
}
return $summer;
} else {
return PHPExcel_Calculation_MathTrig::COMBIN($trials,$value) * pow($probability,$value) * pow(1 - $probability,$trials - $value) ;
}
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BINOMDIST()
/**
* CHIDIST
*
* Returns the one-tailed probability of the chi-squared distribution.
*
* @param float $value Value for the function
* @param float $degrees degrees of freedom
* @return float
*/
public static function CHIDIST($value, $degrees) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees));
if ((is_numeric($value)) && (is_numeric($degrees))) {
if ($degrees < 1) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($value < 0) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
return 1;
}
return PHPExcel_Calculation_Functions::NaN();
}
return 1 - (self::_incompleteGamma($degrees/2,$value/2) / self::_gamma($degrees/2));
}
return PHPExcel_Calculation_Functions::VALUE();
} // function CHIDIST()
/**
* CHIINV
*
* Returns the one-tailed probability of the chi-squared distribution.
*
* @param float $probability Probability for the function
* @param float $degrees degrees of freedom
* @return float
*/
public static function CHIINV($probability, $degrees) {
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
$degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees));
if ((is_numeric($probability)) && (is_numeric($degrees))) {
$xLo = 100;
$xHi = 0;
$x = $xNew = 1;
$dx = 1;
$i = 0;
while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) {
// Apply Newton-Raphson step
$result = self::CHIDIST($x, $degrees);
$error = $result - $probability;
if ($error == 0.0) {
$dx = 0;
} elseif ($error < 0.0) {
$xLo = $x;
} else {
$xHi = $x;
}
// Avoid division by zero
if ($result != 0.0) {
$dx = $error / $result;
$xNew = $x - $dx;
}
// If the NR fails to converge (which for example may be the
// case if the initial guess is too rough) we apply a bisection
// step to determine a more narrow interval around the root.
if (($xNew < $xLo) || ($xNew > $xHi) || ($result == 0.0)) {
$xNew = ($xLo + $xHi) / 2;
$dx = $xNew - $x;
}
$x = $xNew;
}
if ($i == MAX_ITERATIONS) {
return PHPExcel_Calculation_Functions::NA();
}
return round($x,12);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function CHIINV()
/**
* CONFIDENCE
*
* Returns the confidence interval for a population mean
*
* @param float $alpha
* @param float $stdDev Standard Deviation
* @param float $size
* @return float
*
*/
public static function CONFIDENCE($alpha,$stdDev,$size) {
$alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha);
$stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev);
$size = floor(PHPExcel_Calculation_Functions::flattenSingleValue($size));
if ((is_numeric($alpha)) && (is_numeric($stdDev)) && (is_numeric($size))) {
if (($alpha <= 0) || ($alpha >= 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (($stdDev <= 0) || ($size < 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
return self::NORMSINV(1 - $alpha / 2) * $stdDev / sqrt($size);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function CONFIDENCE()
/**
* CORREL
*
* Returns covariance, the average of the products of deviations for each data point pair.
*
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @return float
*/
public static function CORREL($yValues,$xValues=null) {
if ((is_null($xValues)) || (!is_array($yValues)) || (!is_array($xValues))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (!self::_checkTrendArrays($yValues,$xValues)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$yValueCount = count($yValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return PHPExcel_Calculation_Functions::NA();
} elseif ($yValueCount == 1) {
return PHPExcel_Calculation_Functions::DIV0();
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getCorrelation();
} // function CORREL()
/**
* COUNT
*
* Counts the number of cells that contain numbers within the list of arguments
*
* Excel Function:
* COUNT(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return int
*/
public static function COUNT() {
// Return value
$returnValue = 0;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) {
$arg = (integer) $arg;
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
++$returnValue;
}
}
// Return
return $returnValue;
} // function COUNT()
/**
* COUNTA
*
* Counts the number of cells that are not empty within the list of arguments
*
* Excel Function:
* COUNTA(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return int
*/
public static function COUNTA() {
// Return value
$returnValue = 0;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric, boolean or string value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
++$returnValue;
}
}
// Return
return $returnValue;
} // function COUNTA()
/**
* COUNTBLANK
*
* Counts the number of empty cells within the list of arguments
*
* Excel Function:
* COUNTBLANK(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return int
*/
public static function COUNTBLANK() {
// Return value
$returnValue = 0;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a blank cell?
if ((is_null($arg)) || ((is_string($arg)) && ($arg == ''))) {
++$returnValue;
}
}
// Return
return $returnValue;
} // function COUNTBLANK()
/**
* COUNTIF
*
* Counts the number of cells that contain numbers within the list of arguments
*
* Excel Function:
* COUNTIF(value1[,value2[, ...]],condition)
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @param string $condition The criteria that defines which cells will be counted.
* @return int
*/
public static function COUNTIF($aArgs,$condition) {
// Return value
$returnValue = 0;
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
// Loop through arguments
foreach ($aArgs as $arg) {
if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
$testCondition = '='.$arg.$condition;
if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
// Is it a value within our criteria
++$returnValue;
}
}
// Return
return $returnValue;
} // function COUNTIF()
/**
* COVAR
*
* Returns covariance, the average of the products of deviations for each data point pair.
*
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @return float
*/
public static function COVAR($yValues,$xValues) {
if (!self::_checkTrendArrays($yValues,$xValues)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$yValueCount = count($yValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return PHPExcel_Calculation_Functions::NA();
} elseif ($yValueCount == 1) {
return PHPExcel_Calculation_Functions::DIV0();
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getCovariance();
} // function COVAR()
/**
* CRITBINOM
*
* Returns the smallest value for which the cumulative binomial distribution is greater
* than or equal to a criterion value
*
* See http://support.microsoft.com/kb/828117/ for details of the algorithm used
*
* @param float $trials number of Bernoulli trials
* @param float $probability probability of a success on each trial
* @param float $alpha criterion value
* @return int
*
* @todo Warning. This implementation differs from the algorithm detailed on the MS
* web site in that $CumPGuessMinus1 = $CumPGuess - 1 rather than $CumPGuess - $PGuess
* This eliminates a potential endless loop error, but may have an adverse affect on the
* accuracy of the function (although all my tests have so far returned correct results).
*
*/
public static function CRITBINOM($trials, $probability, $alpha) {
$trials = floor(PHPExcel_Calculation_Functions::flattenSingleValue($trials));
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
$alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha);
if ((is_numeric($trials)) && (is_numeric($probability)) && (is_numeric($alpha))) {
if ($trials < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if (($probability < 0) || ($probability > 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (($alpha < 0) || ($alpha > 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($alpha <= 0.5) {
$t = sqrt(log(1 / ($alpha * $alpha)));
$trialsApprox = 0 - ($t + (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t));
} else {
$t = sqrt(log(1 / pow(1 - $alpha,2)));
$trialsApprox = $t - (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t);
}
$Guess = floor($trials * $probability + $trialsApprox * sqrt($trials * $probability * (1 - $probability)));
if ($Guess < 0) {
$Guess = 0;
} elseif ($Guess > $trials) {
$Guess = $trials;
}
$TotalUnscaledProbability = $UnscaledPGuess = $UnscaledCumPGuess = 0.0;
$EssentiallyZero = 10e-12;
$m = floor($trials * $probability);
++$TotalUnscaledProbability;
if ($m == $Guess) { ++$UnscaledPGuess; }
if ($m <= $Guess) { ++$UnscaledCumPGuess; }
$PreviousValue = 1;
$Done = False;
$k = $m + 1;
while ((!$Done) && ($k <= $trials)) {
$CurrentValue = $PreviousValue * ($trials - $k + 1) * $probability / ($k * (1 - $probability));
$TotalUnscaledProbability += $CurrentValue;
if ($k == $Guess) { $UnscaledPGuess += $CurrentValue; }
if ($k <= $Guess) { $UnscaledCumPGuess += $CurrentValue; }
if ($CurrentValue <= $EssentiallyZero) { $Done = True; }
$PreviousValue = $CurrentValue;
++$k;
}
$PreviousValue = 1;
$Done = False;
$k = $m - 1;
while ((!$Done) && ($k >= 0)) {
$CurrentValue = $PreviousValue * $k + 1 * (1 - $probability) / (($trials - $k) * $probability);
$TotalUnscaledProbability += $CurrentValue;
if ($k == $Guess) { $UnscaledPGuess += $CurrentValue; }
if ($k <= $Guess) { $UnscaledCumPGuess += $CurrentValue; }
if ($CurrentValue <= $EssentiallyZero) { $Done = True; }
$PreviousValue = $CurrentValue;
--$k;
}
$PGuess = $UnscaledPGuess / $TotalUnscaledProbability;
$CumPGuess = $UnscaledCumPGuess / $TotalUnscaledProbability;
// $CumPGuessMinus1 = $CumPGuess - $PGuess;
$CumPGuessMinus1 = $CumPGuess - 1;
while (True) {
if (($CumPGuessMinus1 < $alpha) && ($CumPGuess >= $alpha)) {
return $Guess;
} elseif (($CumPGuessMinus1 < $alpha) && ($CumPGuess < $alpha)) {
$PGuessPlus1 = $PGuess * ($trials - $Guess) * $probability / $Guess / (1 - $probability);
$CumPGuessMinus1 = $CumPGuess;
$CumPGuess = $CumPGuess + $PGuessPlus1;
$PGuess = $PGuessPlus1;
++$Guess;
} elseif (($CumPGuessMinus1 >= $alpha) && ($CumPGuess >= $alpha)) {
$PGuessMinus1 = $PGuess * $Guess * (1 - $probability) / ($trials - $Guess + 1) / $probability;
$CumPGuess = $CumPGuessMinus1;
$CumPGuessMinus1 = $CumPGuessMinus1 - $PGuess;
$PGuess = $PGuessMinus1;
--$Guess;
}
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function CRITBINOM()
/**
* DEVSQ
*
* Returns the sum of squares of deviations of data points from their sample mean.
*
* Excel Function:
* DEVSQ(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function DEVSQ() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
// Return value
$returnValue = null;
$aMean = self::AVERAGE($aArgs);
if ($aMean != PHPExcel_Calculation_Functions::DIV0()) {
$aCount = -1;
foreach ($aArgs as $k => $arg) {
// Is it a numeric value?
if ((is_bool($arg)) &&
((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) {
$arg = (integer) $arg;
}
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = pow(($arg - $aMean),2);
} else {
$returnValue += pow(($arg - $aMean),2);
}
++$aCount;
}
}
// Return
if (is_null($returnValue)) {
return PHPExcel_Calculation_Functions::NaN();
} else {
return $returnValue;
}
}
return self::NA();
} // function DEVSQ()
/**
* EXPONDIST
*
* Returns the exponential distribution. Use EXPONDIST to model the time between events,
* such as how long an automated bank teller takes to deliver cash. For example, you can
* use EXPONDIST to determine the probability that the process takes at most 1 minute.
*
* @param float $value Value of the function
* @param float $lambda The parameter value
* @param boolean $cumulative
* @return float
*/
public static function EXPONDIST($value, $lambda, $cumulative) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$lambda = PHPExcel_Calculation_Functions::flattenSingleValue($lambda);
$cumulative = PHPExcel_Calculation_Functions::flattenSingleValue($cumulative);
if ((is_numeric($value)) && (is_numeric($lambda))) {
if (($value < 0) || ($lambda < 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
return 1 - exp(0-$value*$lambda);
} else {
return $lambda * exp(0-$value*$lambda);
}
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function EXPONDIST()
/**
* FISHER
*
* Returns the Fisher transformation at x. This transformation produces a function that
* is normally distributed rather than skewed. Use this function to perform hypothesis
* testing on the correlation coefficient.
*
* @param float $value
* @return float
*/
public static function FISHER($value) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
if (is_numeric($value)) {
if (($value <= -1) || ($value >= 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
return 0.5 * log((1+$value)/(1-$value));
}
return PHPExcel_Calculation_Functions::VALUE();
} // function FISHER()
/**
* FISHERINV
*
* Returns the inverse of the Fisher transformation. Use this transformation when
* analyzing correlations between ranges or arrays of data. If y = FISHER(x), then
* FISHERINV(y) = x.
*
* @param float $value
* @return float
*/
public static function FISHERINV($value) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
if (is_numeric($value)) {
return (exp(2 * $value) - 1) / (exp(2 * $value) + 1);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function FISHERINV()
/**
* FORECAST
*
* Calculates, or predicts, a future value by using existing values. The predicted value is a y-value for a given x-value.
*
* @param float Value of X for which we want to find Y
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @return float
*/
public static function FORECAST($xValue,$yValues,$xValues) {
$xValue = PHPExcel_Calculation_Functions::flattenSingleValue($xValue);
if (!is_numeric($xValue)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (!self::_checkTrendArrays($yValues,$xValues)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$yValueCount = count($yValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return PHPExcel_Calculation_Functions::NA();
} elseif ($yValueCount == 1) {
return PHPExcel_Calculation_Functions::DIV0();
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getValueOfYForX($xValue);
} // function FORECAST()
/**
* GAMMADIST
*
* Returns the gamma distribution.
*
* @param float $value Value at which you want to evaluate the distribution
* @param float $a Parameter to the distribution
* @param float $b Parameter to the distribution
* @param boolean $cumulative
* @return float
*
*/
public static function GAMMADIST($value,$a,$b,$cumulative) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$a = PHPExcel_Calculation_Functions::flattenSingleValue($a);
$b = PHPExcel_Calculation_Functions::flattenSingleValue($b);
if ((is_numeric($value)) && (is_numeric($a)) && (is_numeric($b))) {
if (($value < 0) || ($a <= 0) || ($b <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
return self::_incompleteGamma($a,$value / $b) / self::_gamma($a);
} else {
return (1 / (pow($b,$a) * self::_gamma($a))) * pow($value,$a-1) * exp(0-($value / $b));
}
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function GAMMADIST()
/**
* GAMMAINV
*
* Returns the inverse of the beta distribution.
*
* @param float $probability Probability at which you want to evaluate the distribution
* @param float $alpha Parameter to the distribution
* @param float $beta Parameter to the distribution
* @return float
*
*/
public static function GAMMAINV($probability,$alpha,$beta) {
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
$alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha);
$beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta);
if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta))) {
if (($alpha <= 0) || ($beta <= 0) || ($probability < 0) || ($probability > 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
$xLo = 0;
$xHi = $alpha * $beta * 5;
$x = $xNew = 1;
$error = $pdf = 0;
$dx = 1024;
$i = 0;
while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) {
// Apply Newton-Raphson step
$error = self::GAMMADIST($x, $alpha, $beta, True) - $probability;
if ($error < 0.0) {
$xLo = $x;
} else {
$xHi = $x;
}
$pdf = self::GAMMADIST($x, $alpha, $beta, False);
// Avoid division by zero
if ($pdf != 0.0) {
$dx = $error / $pdf;
$xNew = $x - $dx;
}
// If the NR fails to converge (which for example may be the
// case if the initial guess is too rough) we apply a bisection
// step to determine a more narrow interval around the root.
if (($xNew < $xLo) || ($xNew > $xHi) || ($pdf == 0.0)) {
$xNew = ($xLo + $xHi) / 2;
$dx = $xNew - $x;
}
$x = $xNew;
}
if ($i == MAX_ITERATIONS) {
return PHPExcel_Calculation_Functions::NA();
}
return $x;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function GAMMAINV()
/**
* GAMMALN
*
* Returns the natural logarithm of the gamma function.
*
* @param float $value
* @return float
*/
public static function GAMMALN($value) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
if (is_numeric($value)) {
if ($value <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
return log(self::_gamma($value));
}
return PHPExcel_Calculation_Functions::VALUE();
} // function GAMMALN()
/**
* GEOMEAN
*
* Returns the geometric mean of an array or range of positive data. For example, you
* can use GEOMEAN to calculate average growth rate given compound interest with
* variable rates.
*
* Excel Function:
* GEOMEAN(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function GEOMEAN() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$aMean = PHPExcel_Calculation_MathTrig::PRODUCT($aArgs);
if (is_numeric($aMean) && ($aMean > 0)) {
$aCount = self::COUNT($aArgs) ;
if (self::MIN($aArgs) > 0) {
return pow($aMean, (1 / $aCount));
}
}
return PHPExcel_Calculation_Functions::NaN();
} // GEOMEAN()
/**
* GROWTH
*
* Returns values along a predicted emponential trend
*
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @param array of mixed Values of X for which we want to find Y
* @param boolean A logical value specifying whether to force the intersect to equal 0.
* @return array of float
*/
public static function GROWTH($yValues,$xValues=array(),$newValues=array(),$const=True) {
$yValues = PHPExcel_Calculation_Functions::flattenArray($yValues);
$xValues = PHPExcel_Calculation_Functions::flattenArray($xValues);
$newValues = PHPExcel_Calculation_Functions::flattenArray($newValues);
$const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const);
$bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL,$yValues,$xValues,$const);
if (count($newValues) == 0) {
$newValues = $bestFitExponential->getXValues();
}
$returnArray = array();
foreach($newValues as $xValue) {
$returnArray[0][] = $bestFitExponential->getValueOfYForX($xValue);
}
return $returnArray;
} // function GROWTH()
/**
* HARMEAN
*
* Returns the harmonic mean of a data set. The harmonic mean is the reciprocal of the
* arithmetic mean of reciprocals.
*
* Excel Function:
* HARMEAN(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function HARMEAN() {
// Return value
$returnValue = PHPExcel_Calculation_Functions::NA();
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
if (self::MIN($aArgs) < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
$aCount = 0;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if ($arg <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if (is_null($returnValue)) {
$returnValue = (1 / $arg);
} else {
$returnValue += (1 / $arg);
}
++$aCount;
}
}
// Return
if ($aCount > 0) {
return 1 / ($returnValue / $aCount);
} else {
return $returnValue;
}
} // function HARMEAN()
/**
* HYPGEOMDIST
*
* Returns the hypergeometric distribution. HYPGEOMDIST returns the probability of a given number of
* sample successes, given the sample size, population successes, and population size.
*
* @param float $sampleSuccesses Number of successes in the sample
* @param float $sampleNumber Size of the sample
* @param float $populationSuccesses Number of successes in the population
* @param float $populationNumber Population size
* @return float
*
*/
public static function HYPGEOMDIST($sampleSuccesses, $sampleNumber, $populationSuccesses, $populationNumber) {
$sampleSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleSuccesses));
$sampleNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($sampleNumber));
$populationSuccesses = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationSuccesses));
$populationNumber = floor(PHPExcel_Calculation_Functions::flattenSingleValue($populationNumber));
if ((is_numeric($sampleSuccesses)) && (is_numeric($sampleNumber)) && (is_numeric($populationSuccesses)) && (is_numeric($populationNumber))) {
if (($sampleSuccesses < 0) || ($sampleSuccesses > $sampleNumber) || ($sampleSuccesses > $populationSuccesses)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (($sampleNumber <= 0) || ($sampleNumber > $populationNumber)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (($populationSuccesses <= 0) || ($populationSuccesses > $populationNumber)) {
return PHPExcel_Calculation_Functions::NaN();
}
return PHPExcel_Calculation_MathTrig::COMBIN($populationSuccesses,$sampleSuccesses) *
PHPExcel_Calculation_MathTrig::COMBIN($populationNumber - $populationSuccesses,$sampleNumber - $sampleSuccesses) /
PHPExcel_Calculation_MathTrig::COMBIN($populationNumber,$sampleNumber);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function HYPGEOMDIST()
/**
* INTERCEPT
*
* Calculates the point at which a line will intersect the y-axis by using existing x-values and y-values.
*
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @return float
*/
public static function INTERCEPT($yValues,$xValues) {
if (!self::_checkTrendArrays($yValues,$xValues)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$yValueCount = count($yValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return PHPExcel_Calculation_Functions::NA();
} elseif ($yValueCount == 1) {
return PHPExcel_Calculation_Functions::DIV0();
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getIntersect();
} // function INTERCEPT()
/**
* KURT
*
* Returns the kurtosis of a data set. Kurtosis characterizes the relative peakedness
* or flatness of a distribution compared with the normal distribution. Positive
* kurtosis indicates a relatively peaked distribution. Negative kurtosis indicates a
* relatively flat distribution.
*
* @param array Data Series
* @return float
*/
public static function KURT() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
$mean = self::AVERAGE($aArgs);
$stdDev = self::STDEV($aArgs);
if ($stdDev > 0) {
$count = $summer = 0;
// Loop through arguments
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
(!PHPExcel_Calculation_Functions::isMatrixValue($k))) {
} else {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$summer += pow((($arg - $mean) / $stdDev),4) ;
++$count;
}
}
}
// Return
if ($count > 3) {
return $summer * ($count * ($count+1) / (($count-1) * ($count-2) * ($count-3))) - (3 * pow($count-1,2) / (($count-2) * ($count-3)));
}
}
return PHPExcel_Calculation_Functions::DIV0();
} // function KURT()
/**
* LARGE
*
* Returns the nth largest value in a data set. You can use this function to
* select a value based on its relative standing.
*
* Excel Function:
* LARGE(value1[,value2[, ...]],entry)
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @param int $entry Position (ordered from the largest) in the array or range of data to return
* @return float
*
*/
public static function LARGE() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
// Calculate
$entry = floor(array_pop($aArgs));
if ((is_numeric($entry)) && (!is_string($entry))) {
$mArgs = array();
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
$count = self::COUNT($mArgs);
$entry = floor(--$entry);
if (($entry < 0) || ($entry >= $count) || ($count == 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
rsort($mArgs);
return $mArgs[$entry];
}
return PHPExcel_Calculation_Functions::VALUE();
} // function LARGE()
/**
* LINEST
*
* Calculates the statistics for a line by using the "least squares" method to calculate a straight line that best fits your data,
* and then returns an array that describes the line.
*
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @param boolean A logical value specifying whether to force the intersect to equal 0.
* @param boolean A logical value specifying whether to return additional regression statistics.
* @return array
*/
public static function LINEST($yValues,$xValues=null,$const=True,$stats=False) {
$const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const);
$stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats);
if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues)));
if (!self::_checkTrendArrays($yValues,$xValues)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$yValueCount = count($yValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return PHPExcel_Calculation_Functions::NA();
} elseif ($yValueCount == 1) {
return 0;
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues,$const);
if ($stats) {
return array( array( $bestFitLinear->getSlope(),
$bestFitLinear->getSlopeSE(),
$bestFitLinear->getGoodnessOfFit(),
$bestFitLinear->getF(),
$bestFitLinear->getSSRegression(),
),
array( $bestFitLinear->getIntersect(),
$bestFitLinear->getIntersectSE(),
$bestFitLinear->getStdevOfResiduals(),
$bestFitLinear->getDFResiduals(),
$bestFitLinear->getSSResiduals()
)
);
} else {
return array( $bestFitLinear->getSlope(),
$bestFitLinear->getIntersect()
);
}
} // function LINEST()
/**
* LOGEST
*
* Calculates an exponential curve that best fits the X and Y data series,
* and then returns an array that describes the line.
*
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @param boolean A logical value specifying whether to force the intersect to equal 0.
* @param boolean A logical value specifying whether to return additional regression statistics.
* @return array
*/
public static function LOGEST($yValues,$xValues=null,$const=True,$stats=False) {
$const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const);
$stats = (is_null($stats)) ? False : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($stats);
if (is_null($xValues)) $xValues = range(1,count(PHPExcel_Calculation_Functions::flattenArray($yValues)));
if (!self::_checkTrendArrays($yValues,$xValues)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$yValueCount = count($yValues);
$xValueCount = count($xValues);
foreach($yValues as $value) {
if ($value <= 0.0) {
return PHPExcel_Calculation_Functions::NaN();
}
}
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return PHPExcel_Calculation_Functions::NA();
} elseif ($yValueCount == 1) {
return 1;
}
$bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL,$yValues,$xValues,$const);
if ($stats) {
return array( array( $bestFitExponential->getSlope(),
$bestFitExponential->getSlopeSE(),
$bestFitExponential->getGoodnessOfFit(),
$bestFitExponential->getF(),
$bestFitExponential->getSSRegression(),
),
array( $bestFitExponential->getIntersect(),
$bestFitExponential->getIntersectSE(),
$bestFitExponential->getStdevOfResiduals(),
$bestFitExponential->getDFResiduals(),
$bestFitExponential->getSSResiduals()
)
);
} else {
return array( $bestFitExponential->getSlope(),
$bestFitExponential->getIntersect()
);
}
} // function LOGEST()
/**
* LOGINV
*
* Returns the inverse of the normal cumulative distribution
*
* @param float $value
* @return float
*
* @todo Try implementing P J Acklam's refinement algorithm for greater
* accuracy if I can get my head round the mathematics
* (as described at) http://home.online.no/~pjacklam/notes/invnorm/
*/
public static function LOGINV($probability, $mean, $stdDev) {
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
$mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean);
$stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev);
if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
if (($probability < 0) || ($probability > 1) || ($stdDev <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
return exp($mean + $stdDev * self::NORMSINV($probability));
}
return PHPExcel_Calculation_Functions::VALUE();
} // function LOGINV()
/**
* LOGNORMDIST
*
* Returns the cumulative lognormal distribution of x, where ln(x) is normally distributed
* with parameters mean and standard_dev.
*
* @param float $value
* @return float
*/
public static function LOGNORMDIST($value, $mean, $stdDev) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean);
$stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev);
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
if (($value <= 0) || ($stdDev <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
return self::NORMSDIST((log($value) - $mean) / $stdDev);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function LOGNORMDIST()
/**
* MAX
*
* MAX returns the value of the element of the values passed that has the highest value,
* with negative numbers considered smaller than positive numbers.
*
* Excel Function:
* MAX(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function MAX() {
// Return value
$returnValue = null;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if ((is_null($returnValue)) || ($arg > $returnValue)) {
$returnValue = $arg;
}
}
}
// Return
if(is_null($returnValue)) {
return 0;
}
return $returnValue;
} // function MAX()
/**
* MAXA
*
* Returns the greatest value in a list of arguments, including numbers, text, and logical values
*
* Excel Function:
* MAXA(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function MAXA() {
// Return value
$returnValue = null;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
if ((is_null($returnValue)) || ($arg > $returnValue)) {
$returnValue = $arg;
}
}
}
// Return
if(is_null($returnValue)) {
return 0;
}
return $returnValue;
} // function MAXA()
/**
* MAXIF
*
* Counts the maximum value within a range of cells that contain numbers within the list of arguments
*
* Excel Function:
* MAXIF(value1[,value2[, ...]],condition)
*
* @access public
* @category Mathematical and Trigonometric Functions
* @param mixed $arg,... Data values
* @param string $condition The criteria that defines which cells will be checked.
* @return float
*/
public static function MAXIF($aArgs,$condition,$sumArgs = array()) {
// Return value
$returnValue = null;
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
$sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs);
if (count($sumArgs) == 0) {
$sumArgs = $aArgs;
}
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
// Loop through arguments
foreach ($aArgs as $key => $arg) {
if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
$testCondition = '='.$arg.$condition;
if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
if ((is_null($returnValue)) || ($arg > $returnValue)) {
$returnValue = $arg;
}
}
}
// Return
return $returnValue;
} // function MAXIF()
/**
* MEDIAN
*
* Returns the median of the given numbers. The median is the number in the middle of a set of numbers.
*
* Excel Function:
* MEDIAN(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function MEDIAN() {
// Return value
$returnValue = PHPExcel_Calculation_Functions::NaN();
$mArgs = array();
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
$mValueCount = count($mArgs);
if ($mValueCount > 0) {
sort($mArgs,SORT_NUMERIC);
$mValueCount = $mValueCount / 2;
if ($mValueCount == floor($mValueCount)) {
$returnValue = ($mArgs[$mValueCount--] + $mArgs[$mValueCount]) / 2;
} else {
$mValueCount == floor($mValueCount);
$returnValue = $mArgs[$mValueCount];
}
}
// Return
return $returnValue;
} // function MEDIAN()
/**
* MIN
*
* MIN returns the value of the element of the values passed that has the smallest value,
* with negative numbers considered smaller than positive numbers.
*
* Excel Function:
* MIN(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function MIN() {
// Return value
$returnValue = null;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if ((is_null($returnValue)) || ($arg < $returnValue)) {
$returnValue = $arg;
}
}
}
// Return
if(is_null($returnValue)) {
return 0;
}
return $returnValue;
} // function MIN()
/**
* MINA
*
* Returns the smallest value in a list of arguments, including numbers, text, and logical values
*
* Excel Function:
* MINA(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function MINA() {
// Return value
$returnValue = null;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
if ((is_null($returnValue)) || ($arg < $returnValue)) {
$returnValue = $arg;
}
}
}
// Return
if(is_null($returnValue)) {
return 0;
}
return $returnValue;
} // function MINA()
/**
* MINIF
*
* Returns the minimum value within a range of cells that contain numbers within the list of arguments
*
* Excel Function:
* MINIF(value1[,value2[, ...]],condition)
*
* @access public
* @category Mathematical and Trigonometric Functions
* @param mixed $arg,... Data values
* @param string $condition The criteria that defines which cells will be checked.
* @return float
*/
public static function MINIF($aArgs,$condition,$sumArgs = array()) {
// Return value
$returnValue = null;
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
$sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs);
if (count($sumArgs) == 0) {
$sumArgs = $aArgs;
}
$condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
// Loop through arguments
foreach ($aArgs as $key => $arg) {
if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
$testCondition = '='.$arg.$condition;
if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
if ((is_null($returnValue)) || ($arg < $returnValue)) {
$returnValue = $arg;
}
}
}
// Return
return $returnValue;
} // function MINIF()
//
// Special variant of array_count_values that isn't limited to strings and integers,
// but can work with floating point numbers as values
//
private static function _modeCalc($data) {
$frequencyArray = array();
foreach($data as $datum) {
$found = False;
foreach($frequencyArray as $key => $value) {
if ((string) $value['value'] == (string) $datum) {
++$frequencyArray[$key]['frequency'];
$found = True;
break;
}
}
if (!$found) {
$frequencyArray[] = array('value' => $datum,
'frequency' => 1 );
}
}
foreach($frequencyArray as $key => $value) {
$frequencyList[$key] = $value['frequency'];
$valueList[$key] = $value['value'];
}
array_multisort($frequencyList, SORT_DESC, $valueList, SORT_ASC, SORT_NUMERIC, $frequencyArray);
if ($frequencyArray[0]['frequency'] == 1) {
return PHPExcel_Calculation_Functions::NA();
}
return $frequencyArray[0]['value'];
} // function _modeCalc()
/**
* MODE
*
* Returns the most frequently occurring, or repetitive, value in an array or range of data
*
* Excel Function:
* MODE(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function MODE() {
// Return value
$returnValue = PHPExcel_Calculation_Functions::NA();
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$mArgs = array();
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
if (count($mArgs) > 0) {
return self::_modeCalc($mArgs);
}
// Return
return $returnValue;
} // function MODE()
/**
* NEGBINOMDIST
*
* Returns the negative binomial distribution. NEGBINOMDIST returns the probability that
* there will be number_f failures before the number_s-th success, when the constant
* probability of a success is probability_s. This function is similar to the binomial
* distribution, except that the number of successes is fixed, and the number of trials is
* variable. Like the binomial, trials are assumed to be independent.
*
* @param float $failures Number of Failures
* @param float $successes Threshold number of Successes
* @param float $probability Probability of success on each trial
* @return float
*
*/
public static function NEGBINOMDIST($failures, $successes, $probability) {
$failures = floor(PHPExcel_Calculation_Functions::flattenSingleValue($failures));
$successes = floor(PHPExcel_Calculation_Functions::flattenSingleValue($successes));
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
if ((is_numeric($failures)) && (is_numeric($successes)) && (is_numeric($probability))) {
if (($failures < 0) || ($successes < 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (($probability < 0) || ($probability > 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
if (($failures + $successes - 1) <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
}
return (PHPExcel_Calculation_MathTrig::COMBIN($failures + $successes - 1,$successes - 1)) * (pow($probability,$successes)) * (pow(1 - $probability,$failures)) ;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function NEGBINOMDIST()
/**
* NORMDIST
*
* Returns the normal distribution for the specified mean and standard deviation. This
* function has a very wide range of applications in statistics, including hypothesis
* testing.
*
* @param float $value
* @param float $mean Mean Value
* @param float $stdDev Standard Deviation
* @param boolean $cumulative
* @return float
*
*/
public static function NORMDIST($value, $mean, $stdDev, $cumulative) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean);
$stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev);
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
if ($stdDev < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
return 0.5 * (1 + PHPExcel_Calculation_Engineering::_erfVal(($value - $mean) / ($stdDev * sqrt(2))));
} else {
return (1 / (SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean,2) / (2 * ($stdDev * $stdDev))));
}
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function NORMDIST()
/**
* NORMINV
*
* Returns the inverse of the normal cumulative distribution for the specified mean and standard deviation.
*
* @param float $value
* @param float $mean Mean Value
* @param float $stdDev Standard Deviation
* @return float
*
*/
public static function NORMINV($probability,$mean,$stdDev) {
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
$mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean);
$stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev);
if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
if (($probability < 0) || ($probability > 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($stdDev < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
return (self::_inverse_ncdf($probability) * $stdDev) + $mean;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function NORMINV()
/**
* NORMSDIST
*
* Returns the standard normal cumulative distribution function. The distribution has
* a mean of 0 (zero) and a standard deviation of one. Use this function in place of a
* table of standard normal curve areas.
*
* @param float $value
* @return float
*/
public static function NORMSDIST($value) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
return self::NORMDIST($value, 0, 1, True);
} // function NORMSDIST()
/**
* NORMSINV
*
* Returns the inverse of the standard normal cumulative distribution
*
* @param float $value
* @return float
*/
public static function NORMSINV($value) {
return self::NORMINV($value, 0, 1);
} // function NORMSINV()
/**
* PERCENTILE
*
* Returns the nth percentile of values in a range..
*
* Excel Function:
* PERCENTILE(value1[,value2[, ...]],entry)
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @param float $entry Percentile value in the range 0..1, inclusive.
* @return float
*/
public static function PERCENTILE() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
// Calculate
$entry = array_pop($aArgs);
if ((is_numeric($entry)) && (!is_string($entry))) {
if (($entry < 0) || ($entry > 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
$mArgs = array();
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
$mValueCount = count($mArgs);
if ($mValueCount > 0) {
sort($mArgs);
$count = self::COUNT($mArgs);
$index = $entry * ($count-1);
$iBase = floor($index);
if ($index == $iBase) {
return $mArgs[$index];
} else {
$iNext = $iBase + 1;
$iProportion = $index - $iBase;
return $mArgs[$iBase] + (($mArgs[$iNext] - $mArgs[$iBase]) * $iProportion) ;
}
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function PERCENTILE()
/**
* PERCENTRANK
*
* Returns the rank of a value in a data set as a percentage of the data set.
*
* @param array of number An array of, or a reference to, a list of numbers.
* @param number The number whose rank you want to find.
* @param number The number of significant digits for the returned percentage value.
* @return float
*/
public static function PERCENTRANK($valueSet,$value,$significance=3) {
$valueSet = PHPExcel_Calculation_Functions::flattenArray($valueSet);
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$significance = (is_null($significance)) ? 3 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($significance);
foreach($valueSet as $key => $valueEntry) {
if (!is_numeric($valueEntry)) {
unset($valueSet[$key]);
}
}
sort($valueSet,SORT_NUMERIC);
$valueCount = count($valueSet);
if ($valueCount == 0) {
return PHPExcel_Calculation_Functions::NaN();
}
$valueAdjustor = $valueCount - 1;
if (($value < $valueSet[0]) || ($value > $valueSet[$valueAdjustor])) {
return PHPExcel_Calculation_Functions::NA();
}
$pos = array_search($value,$valueSet);
if ($pos === False) {
$pos = 0;
$testValue = $valueSet[0];
while ($testValue < $value) {
$testValue = $valueSet[++$pos];
}
--$pos;
$pos += (($value - $valueSet[$pos]) / ($testValue - $valueSet[$pos]));
}
return round($pos / $valueAdjustor,$significance);
} // function PERCENTRANK()
/**
* PERMUT
*
* Returns the number of permutations for a given number of objects that can be
* selected from number objects. A permutation is any set or subset of objects or
* events where internal order is significant. Permutations are different from
* combinations, for which the internal order is not significant. Use this function
* for lottery-style probability calculations.
*
* @param int $numObjs Number of different objects
* @param int $numInSet Number of objects in each permutation
* @return int Number of permutations
*/
public static function PERMUT($numObjs,$numInSet) {
$numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs);
$numInSet = PHPExcel_Calculation_Functions::flattenSingleValue($numInSet);
if ((is_numeric($numObjs)) && (is_numeric($numInSet))) {
$numInSet = floor($numInSet);
if ($numObjs < $numInSet) {
return PHPExcel_Calculation_Functions::NaN();
}
return round(PHPExcel_Calculation_MathTrig::FACT($numObjs) / PHPExcel_Calculation_MathTrig::FACT($numObjs - $numInSet));
}
return PHPExcel_Calculation_Functions::VALUE();
} // function PERMUT()
/**
* POISSON
*
* Returns the Poisson distribution. A common application of the Poisson distribution
* is predicting the number of events over a specific time, such as the number of
* cars arriving at a toll plaza in 1 minute.
*
* @param float $value
* @param float $mean Mean Value
* @param boolean $cumulative
* @return float
*
*/
public static function POISSON($value, $mean, $cumulative) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean);
if ((is_numeric($value)) && (is_numeric($mean))) {
if (($value <= 0) || ($mean <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
$summer = 0;
for ($i = 0; $i <= floor($value); ++$i) {
$summer += pow($mean,$i) / PHPExcel_Calculation_MathTrig::FACT($i);
}
return exp(0-$mean) * $summer;
} else {
return (exp(0-$mean) * pow($mean,$value)) / PHPExcel_Calculation_MathTrig::FACT($value);
}
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function POISSON()
/**
* QUARTILE
*
* Returns the quartile of a data set.
*
* Excel Function:
* QUARTILE(value1[,value2[, ...]],entry)
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @param int $entry Quartile value in the range 1..3, inclusive.
* @return float
*/
public static function QUARTILE() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
// Calculate
$entry = floor(array_pop($aArgs));
if ((is_numeric($entry)) && (!is_string($entry))) {
$entry /= 4;
if (($entry < 0) || ($entry > 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
return self::PERCENTILE($aArgs,$entry);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function QUARTILE()
/**
* RANK
*
* Returns the rank of a number in a list of numbers.
*
* @param number The number whose rank you want to find.
* @param array of number An array of, or a reference to, a list of numbers.
* @param mixed Order to sort the values in the value set
* @return float
*/
public static function RANK($value,$valueSet,$order=0) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$valueSet = PHPExcel_Calculation_Functions::flattenArray($valueSet);
$order = (is_null($order)) ? 0 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($order);
foreach($valueSet as $key => $valueEntry) {
if (!is_numeric($valueEntry)) {
unset($valueSet[$key]);
}
}
if ($order == 0) {
rsort($valueSet,SORT_NUMERIC);
} else {
sort($valueSet,SORT_NUMERIC);
}
$pos = array_search($value,$valueSet);
if ($pos === False) {
return PHPExcel_Calculation_Functions::NA();
}
return ++$pos;
} // function RANK()
/**
* RSQ
*
* Returns the square of the Pearson product moment correlation coefficient through data points in known_y's and known_x's.
*
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @return float
*/
public static function RSQ($yValues,$xValues) {
if (!self::_checkTrendArrays($yValues,$xValues)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$yValueCount = count($yValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return PHPExcel_Calculation_Functions::NA();
} elseif ($yValueCount == 1) {
return PHPExcel_Calculation_Functions::DIV0();
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getGoodnessOfFit();
} // function RSQ()
/**
* SKEW
*
* Returns the skewness of a distribution. Skewness characterizes the degree of asymmetry
* of a distribution around its mean. Positive skewness indicates a distribution with an
* asymmetric tail extending toward more positive values. Negative skewness indicates a
* distribution with an asymmetric tail extending toward more negative values.
*
* @param array Data Series
* @return float
*/
public static function SKEW() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
$mean = self::AVERAGE($aArgs);
$stdDev = self::STDEV($aArgs);
$count = $summer = 0;
// Loop through arguments
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
(!PHPExcel_Calculation_Functions::isMatrixValue($k))) {
} else {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$summer += pow((($arg - $mean) / $stdDev),3) ;
++$count;
}
}
}
// Return
if ($count > 2) {
return $summer * ($count / (($count-1) * ($count-2)));
}
return PHPExcel_Calculation_Functions::DIV0();
} // function SKEW()
/**
* SLOPE
*
* Returns the slope of the linear regression line through data points in known_y's and known_x's.
*
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @return float
*/
public static function SLOPE($yValues,$xValues) {
if (!self::_checkTrendArrays($yValues,$xValues)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$yValueCount = count($yValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return PHPExcel_Calculation_Functions::NA();
} elseif ($yValueCount == 1) {
return PHPExcel_Calculation_Functions::DIV0();
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getSlope();
} // function SLOPE()
/**
* SMALL
*
* Returns the nth smallest value in a data set. You can use this function to
* select a value based on its relative standing.
*
* Excel Function:
* SMALL(value1[,value2[, ...]],entry)
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @param int $entry Position (ordered from the smallest) in the array or range of data to return
* @return float
*/
public static function SMALL() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
// Calculate
$entry = array_pop($aArgs);
if ((is_numeric($entry)) && (!is_string($entry))) {
$mArgs = array();
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
$count = self::COUNT($mArgs);
$entry = floor(--$entry);
if (($entry < 0) || ($entry >= $count) || ($count == 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
sort($mArgs);
return $mArgs[$entry];
}
return PHPExcel_Calculation_Functions::VALUE();
} // function SMALL()
/**
* STANDARDIZE
*
* Returns a normalized value from a distribution characterized by mean and standard_dev.
*
* @param float $value Value to normalize
* @param float $mean Mean Value
* @param float $stdDev Standard Deviation
* @return float Standardized value
*/
public static function STANDARDIZE($value,$mean,$stdDev) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean);
$stdDev = PHPExcel_Calculation_Functions::flattenSingleValue($stdDev);
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
if ($stdDev <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
return ($value - $mean) / $stdDev ;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function STANDARDIZE()
/**
* STDEV
*
* Estimates standard deviation based on a sample. The standard deviation is a measure of how
* widely values are dispersed from the average value (the mean).
*
* Excel Function:
* STDEV(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function STDEV() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
// Return value
$returnValue = null;
$aMean = self::AVERAGE($aArgs);
if (!is_null($aMean)) {
$aCount = -1;
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) {
$arg = (integer) $arg;
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = pow(($arg - $aMean),2);
} else {
$returnValue += pow(($arg - $aMean),2);
}
++$aCount;
}
}
// Return
if (($aCount > 0) && ($returnValue >= 0)) {
return sqrt($returnValue / $aCount);
}
}
return PHPExcel_Calculation_Functions::DIV0();
} // function STDEV()
/**
* STDEVA
*
* Estimates standard deviation based on a sample, including numbers, text, and logical values
*
* Excel Function:
* STDEVA(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function STDEVA() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
// Return value
$returnValue = null;
$aMean = self::AVERAGEA($aArgs);
if (!is_null($aMean)) {
$aCount = -1;
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
(!PHPExcel_Calculation_Functions::isMatrixValue($k))) {
} else {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
if (is_null($returnValue)) {
$returnValue = pow(($arg - $aMean),2);
} else {
$returnValue += pow(($arg - $aMean),2);
}
++$aCount;
}
}
}
// Return
if (($aCount > 0) && ($returnValue >= 0)) {
return sqrt($returnValue / $aCount);
}
}
return PHPExcel_Calculation_Functions::DIV0();
} // function STDEVA()
/**
* STDEVP
*
* Calculates standard deviation based on the entire population
*
* Excel Function:
* STDEVP(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function STDEVP() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
// Return value
$returnValue = null;
$aMean = self::AVERAGE($aArgs);
if (!is_null($aMean)) {
$aCount = 0;
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
((!PHPExcel_Calculation_Functions::isCellValue($k)) || (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE))) {
$arg = (integer) $arg;
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = pow(($arg - $aMean),2);
} else {
$returnValue += pow(($arg - $aMean),2);
}
++$aCount;
}
}
// Return
if (($aCount > 0) && ($returnValue >= 0)) {
return sqrt($returnValue / $aCount);
}
}
return PHPExcel_Calculation_Functions::DIV0();
} // function STDEVP()
/**
* STDEVPA
*
* Calculates standard deviation based on the entire population, including numbers, text, and logical values
*
* Excel Function:
* STDEVPA(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function STDEVPA() {
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
// Return value
$returnValue = null;
$aMean = self::AVERAGEA($aArgs);
if (!is_null($aMean)) {
$aCount = 0;
foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) &&
(!PHPExcel_Calculation_Functions::isMatrixValue($k))) {
} else {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
if (is_null($returnValue)) {
$returnValue = pow(($arg - $aMean),2);
} else {
$returnValue += pow(($arg - $aMean),2);
}
++$aCount;
}
}
}
// Return
if (($aCount > 0) && ($returnValue >= 0)) {
return sqrt($returnValue / $aCount);
}
}
return PHPExcel_Calculation_Functions::DIV0();
} // function STDEVPA()
/**
* STEYX
*
* Returns the standard error of the predicted y-value for each x in the regression.
*
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @return float
*/
public static function STEYX($yValues,$xValues) {
if (!self::_checkTrendArrays($yValues,$xValues)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$yValueCount = count($yValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return PHPExcel_Calculation_Functions::NA();
} elseif ($yValueCount == 1) {
return PHPExcel_Calculation_Functions::DIV0();
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getStdevOfResiduals();
} // function STEYX()
/**
* TDIST
*
* Returns the probability of Student's T distribution.
*
* @param float $value Value for the function
* @param float $degrees degrees of freedom
* @param float $tails number of tails (1 or 2)
* @return float
*/
public static function TDIST($value, $degrees, $tails) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees));
$tails = floor(PHPExcel_Calculation_Functions::flattenSingleValue($tails));
if ((is_numeric($value)) && (is_numeric($degrees)) && (is_numeric($tails))) {
if (($value < 0) || ($degrees < 1) || ($tails < 1) || ($tails > 2)) {
return PHPExcel_Calculation_Functions::NaN();
}
// tdist, which finds the probability that corresponds to a given value
// of t with k degrees of freedom. This algorithm is translated from a
// pascal function on p81 of "Statistical Computing in Pascal" by D
// Cooke, A H Craven & G M Clark (1985: Edward Arnold (Pubs.) Ltd:
// London). The above Pascal algorithm is itself a translation of the
// fortran algoritm "AS 3" by B E Cooper of the Atlas Computer
// Laboratory as reported in (among other places) "Applied Statistics
// Algorithms", editied by P Griffiths and I D Hill (1985; Ellis
// Horwood Ltd.; W. Sussex, England).
$tterm = $degrees;
$ttheta = atan2($value,sqrt($tterm));
$tc = cos($ttheta);
$ts = sin($ttheta);
$tsum = 0;
if (($degrees % 2) == 1) {
$ti = 3;
$tterm = $tc;
} else {
$ti = 2;
$tterm = 1;
}
$tsum = $tterm;
while ($ti < $degrees) {
$tterm *= $tc * $tc * ($ti - 1) / $ti;
$tsum += $tterm;
$ti += 2;
}
$tsum *= $ts;
if (($degrees % 2) == 1) { $tsum = M_2DIVPI * ($tsum + $ttheta); }
$tValue = 0.5 * (1 + $tsum);
if ($tails == 1) {
return 1 - abs($tValue);
} else {
return 1 - abs((1 - $tValue) - $tValue);
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function TDIST()
/**
* TINV
*
* Returns the one-tailed probability of the chi-squared distribution.
*
* @param float $probability Probability for the function
* @param float $degrees degrees of freedom
* @return float
*/
public static function TINV($probability, $degrees) {
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
$degrees = floor(PHPExcel_Calculation_Functions::flattenSingleValue($degrees));
if ((is_numeric($probability)) && (is_numeric($degrees))) {
$xLo = 100;
$xHi = 0;
$x = $xNew = 1;
$dx = 1;
$i = 0;
while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) {
// Apply Newton-Raphson step
$result = self::TDIST($x, $degrees, 2);
$error = $result - $probability;
if ($error == 0.0) {
$dx = 0;
} elseif ($error < 0.0) {
$xLo = $x;
} else {
$xHi = $x;
}
// Avoid division by zero
if ($result != 0.0) {
$dx = $error / $result;
$xNew = $x - $dx;
}
// If the NR fails to converge (which for example may be the
// case if the initial guess is too rough) we apply a bisection
// step to determine a more narrow interval around the root.
if (($xNew < $xLo) || ($xNew > $xHi) || ($result == 0.0)) {
$xNew = ($xLo + $xHi) / 2;
$dx = $xNew - $x;
}
$x = $xNew;
}
if ($i == MAX_ITERATIONS) {
return PHPExcel_Calculation_Functions::NA();
}
return round($x,12);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function TINV()
/**
* TREND
*
* Returns values along a linear trend
*
* @param array of mixed Data Series Y
* @param array of mixed Data Series X
* @param array of mixed Values of X for which we want to find Y
* @param boolean A logical value specifying whether to force the intersect to equal 0.
* @return array of float
*/
public static function TREND($yValues,$xValues=array(),$newValues=array(),$const=True) {
$yValues = PHPExcel_Calculation_Functions::flattenArray($yValues);
$xValues = PHPExcel_Calculation_Functions::flattenArray($xValues);
$newValues = PHPExcel_Calculation_Functions::flattenArray($newValues);
$const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const);
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues,$const);
if (count($newValues) == 0) {
$newValues = $bestFitLinear->getXValues();
}
$returnArray = array();
foreach($newValues as $xValue) {
$returnArray[0][] = $bestFitLinear->getValueOfYForX($xValue);
}
return $returnArray;
} // function TREND()
/**
* TRIMMEAN
*
* Returns the mean of the interior of a data set. TRIMMEAN calculates the mean
* taken by excluding a percentage of data points from the top and bottom tails
* of a data set.
*
* Excel Function:
* TRIMEAN(value1[,value2[, ...]],$discard)
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @param float $discard Percentage to discard
* @return float
*/
public static function TRIMMEAN() {
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
// Calculate
$percent = array_pop($aArgs);
if ((is_numeric($percent)) && (!is_string($percent))) {
if (($percent < 0) || ($percent > 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
$mArgs = array();
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
$discard = floor(self::COUNT($mArgs) * $percent / 2);
sort($mArgs);
for ($i=0; $i < $discard; ++$i) {
array_pop($mArgs);
array_shift($mArgs);
}
return self::AVERAGE($mArgs);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function TRIMMEAN()
/**
* VARFunc
*
* Estimates variance based on a sample.
*
* Excel Function:
* VAR(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function VARFunc() {
// Return value
$returnValue = PHPExcel_Calculation_Functions::DIV0();
$summerA = $summerB = 0;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$aCount = 0;
foreach ($aArgs as $arg) {
if (is_bool($arg)) { $arg = (integer) $arg; }
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$summerA += ($arg * $arg);
$summerB += $arg;
++$aCount;
}
}
// Return
if ($aCount > 1) {
$summerA *= $aCount;
$summerB *= $summerB;
$returnValue = ($summerA - $summerB) / ($aCount * ($aCount - 1));
}
return $returnValue;
} // function VARFunc()
/**
* VARA
*
* Estimates variance based on a sample, including numbers, text, and logical values
*
* Excel Function:
* VARA(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function VARA() {
// Return value
$returnValue = PHPExcel_Calculation_Functions::DIV0();
$summerA = $summerB = 0;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
$aCount = 0;
foreach ($aArgs as $k => $arg) {
if ((is_string($arg)) &&
(PHPExcel_Calculation_Functions::isValue($k))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ((is_string($arg)) &&
(!PHPExcel_Calculation_Functions::isMatrixValue($k))) {
} else {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
$summerA += ($arg * $arg);
$summerB += $arg;
++$aCount;
}
}
}
// Return
if ($aCount > 1) {
$summerA *= $aCount;
$summerB *= $summerB;
$returnValue = ($summerA - $summerB) / ($aCount * ($aCount - 1));
}
return $returnValue;
} // function VARA()
/**
* VARP
*
* Calculates variance based on the entire population
*
* Excel Function:
* VARP(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function VARP() {
// Return value
$returnValue = PHPExcel_Calculation_Functions::DIV0();
$summerA = $summerB = 0;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$aCount = 0;
foreach ($aArgs as $arg) {
if (is_bool($arg)) { $arg = (integer) $arg; }
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$summerA += ($arg * $arg);
$summerB += $arg;
++$aCount;
}
}
// Return
if ($aCount > 0) {
$summerA *= $aCount;
$summerB *= $summerB;
$returnValue = ($summerA - $summerB) / ($aCount * $aCount);
}
return $returnValue;
} // function VARP()
/**
* VARPA
*
* Calculates variance based on the entire population, including numbers, text, and logical values
*
* Excel Function:
* VARPA(value1[,value2[, ...]])
*
* @access public
* @category Statistical Functions
* @param mixed $arg,... Data values
* @return float
*/
public static function VARPA() {
// Return value
$returnValue = PHPExcel_Calculation_Functions::DIV0();
$summerA = $summerB = 0;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args());
$aCount = 0;
foreach ($aArgs as $k => $arg) {
if ((is_string($arg)) &&
(PHPExcel_Calculation_Functions::isValue($k))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ((is_string($arg)) &&
(!PHPExcel_Calculation_Functions::isMatrixValue($k))) {
} else {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
$summerA += ($arg * $arg);
$summerB += $arg;
++$aCount;
}
}
}
// Return
if ($aCount > 0) {
$summerA *= $aCount;
$summerB *= $summerB;
$returnValue = ($summerA - $summerB) / ($aCount * $aCount);
}
return $returnValue;
} // function VARPA()
/**
* WEIBULL
*
* Returns the Weibull distribution. Use this distribution in reliability
* analysis, such as calculating a device's mean time to failure.
*
* @param float $value
* @param float $alpha Alpha Parameter
* @param float $beta Beta Parameter
* @param boolean $cumulative
* @return float
*
*/
public static function WEIBULL($value, $alpha, $beta, $cumulative) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$alpha = PHPExcel_Calculation_Functions::flattenSingleValue($alpha);
$beta = PHPExcel_Calculation_Functions::flattenSingleValue($beta);
if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta))) {
if (($value < 0) || ($alpha <= 0) || ($beta <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
return 1 - exp(0 - pow($value / $beta,$alpha));
} else {
return ($alpha / pow($beta,$alpha)) * pow($value,$alpha - 1) * exp(0 - pow($value / $beta,$alpha));
}
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function WEIBULL()
/**
* ZTEST
*
* Returns the Weibull distribution. Use this distribution in reliability
* analysis, such as calculating a device's mean time to failure.
*
* @param float $value
* @param float $alpha Alpha Parameter
* @param float $beta Beta Parameter
* @param boolean $cumulative
* @return float
*
*/
public static function ZTEST($dataSet, $m0, $sigma=null) {
$dataSet = PHPExcel_Calculation_Functions::flattenArrayIndexed($dataSet);
$m0 = PHPExcel_Calculation_Functions::flattenSingleValue($m0);
$sigma = PHPExcel_Calculation_Functions::flattenSingleValue($sigma);
if (is_null($sigma)) {
$sigma = self::STDEV($dataSet);
}
$n = count($dataSet);
return 1 - self::NORMSDIST((self::AVERAGE($dataSet) - $m0)/($sigma/SQRT($n)));
} // function ZTEST()
} // class PHPExcel_Calculation_Statistical
| zysms | trunk/zysms/customer/PHPExcel/Calculation/Statistical.php | PHP | asf20 | 109,004 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/*
PARTLY BASED ON:
Copyright (c) 2007 E. W. Bachtal, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
The software is provided "as is", without warranty of any kind, express or implied, including but not
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
software or the use or other dealings in the software.
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
*/
/**
* PHPExcel_Calculation_FormulaToken
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_FormulaToken {
/* Token types */
const TOKEN_TYPE_NOOP = 'Noop';
const TOKEN_TYPE_OPERAND = 'Operand';
const TOKEN_TYPE_FUNCTION = 'Function';
const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
const TOKEN_TYPE_ARGUMENT = 'Argument';
const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
const TOKEN_TYPE_WHITESPACE = 'Whitespace';
const TOKEN_TYPE_UNKNOWN = 'Unknown';
/* Token subtypes */
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
const TOKEN_SUBTYPE_START = 'Start';
const TOKEN_SUBTYPE_STOP = 'Stop';
const TOKEN_SUBTYPE_TEXT = 'Text';
const TOKEN_SUBTYPE_NUMBER = 'Number';
const TOKEN_SUBTYPE_LOGICAL = 'Logical';
const TOKEN_SUBTYPE_ERROR = 'Error';
const TOKEN_SUBTYPE_RANGE = 'Range';
const TOKEN_SUBTYPE_MATH = 'Math';
const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
const TOKEN_SUBTYPE_UNION = 'Union';
/**
* Value
*
* @var string
*/
private $_value;
/**
* Token Type (represented by TOKEN_TYPE_*)
*
* @var string
*/
private $_tokenType;
/**
* Token SubType (represented by TOKEN_SUBTYPE_*)
*
* @var string
*/
private $_tokenSubType;
/**
* Create a new PHPExcel_Calculation_FormulaToken
*
* @param string $pValue
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
* @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
*/
public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
{
// Initialise values
$this->_value = $pValue;
$this->_tokenType = $pTokenType;
$this->_tokenSubType = $pTokenSubType;
}
/**
* Get Value
*
* @return string
*/
public function getValue() {
return $this->_value;
}
/**
* Set Value
*
* @param string $value
*/
public function setValue($value) {
$this->_value = $value;
}
/**
* Get Token Type (represented by TOKEN_TYPE_*)
*
* @return string
*/
public function getTokenType() {
return $this->_tokenType;
}
/**
* Set Token Type
*
* @param string $value
*/
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) {
$this->_tokenType = $value;
}
/**
* Get Token SubType (represented by TOKEN_SUBTYPE_*)
*
* @return string
*/
public function getTokenSubType() {
return $this->_tokenSubType;
}
/**
* Set Token SubType
*
* @param string $value
*/
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
$this->_tokenSubType = $value;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Calculation/FormulaToken.php | PHP | asf20 | 5,507 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Calculation_DateTime
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_DateTime {
public static function _isLeapYear($year) {
return ((($year % 4) == 0) && (($year % 100) != 0) || (($year % 400) == 0));
} // function _isLeapYear()
private static function _dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) {
if ($startDay == 31) {
--$startDay;
} elseif ($methodUS && ($startMonth == 2 && ($startDay == 29 || ($startDay == 28 && !self::_isLeapYear($startYear))))) {
$startDay = 30;
}
if ($endDay == 31) {
if ($methodUS && $startDay != 30) {
$endDay = 1;
if ($endMonth == 12) {
++$endYear;
$endMonth = 1;
} else {
++$endMonth;
}
} else {
$endDay = 30;
}
}
return $endDay + $endMonth * 30 + $endYear * 360 - $startDay - $startMonth * 30 - $startYear * 360;
} // function _dateDiff360()
/**
* _getDateValue
*
* @param string $dateValue
* @return mixed Excel date/time serial value, or string if error
*/
public static function _getDateValue($dateValue) {
if (!is_numeric($dateValue)) {
if ((is_string($dateValue)) && (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if ((is_object($dateValue)) && ($dateValue instanceof PHPExcel_Shared_Date::$dateTimeObjectType)) {
$dateValue = PHPExcel_Shared_Date::PHPToExcel($dateValue);
} else {
$saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$dateValue = self::DATEVALUE($dateValue);
PHPExcel_Calculation_Functions::setReturnDateType($saveReturnDateType);
}
}
return $dateValue;
} // function _getDateValue()
/**
* _getTimeValue
*
* @param string $timeValue
* @return mixed Excel date/time serial value, or string if error
*/
private static function _getTimeValue($timeValue) {
$saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
$timeValue = self::TIMEVALUE($timeValue);
PHPExcel_Calculation_Functions::setReturnDateType($saveReturnDateType);
return $timeValue;
} // function _getTimeValue()
private static function _adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0) {
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
$oMonth = (int) $PHPDateObject->format('m');
$oYear = (int) $PHPDateObject->format('Y');
$adjustmentMonthsString = (string) $adjustmentMonths;
if ($adjustmentMonths > 0) {
$adjustmentMonthsString = '+'.$adjustmentMonths;
}
if ($adjustmentMonths != 0) {
$PHPDateObject->modify($adjustmentMonthsString.' months');
}
$nMonth = (int) $PHPDateObject->format('m');
$nYear = (int) $PHPDateObject->format('Y');
$monthDiff = ($nMonth - $oMonth) + (($nYear - $oYear) * 12);
if ($monthDiff != $adjustmentMonths) {
$adjustDays = (int) $PHPDateObject->format('d');
$adjustDaysString = '-'.$adjustDays.' days';
$PHPDateObject->modify($adjustDaysString);
}
return $PHPDateObject;
} // function _adjustDateByMonths()
/**
* DATETIMENOW
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATETIMENOW() {
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$retValue = False;
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
$retValue = (float) PHPExcel_Shared_Date::PHPToExcel(time());
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
$retValue = (integer) time();
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
$retValue = new DateTime();
break;
}
date_default_timezone_set($saveTimeZone);
return $retValue;
} // function DATETIMENOW()
/**
* DATENOW
*
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATENOW() {
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$retValue = False;
$excelDateTime = floor(PHPExcel_Shared_Date::PHPToExcel(time()));
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
$retValue = (float) $excelDateTime;
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
$retValue = (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateTime) - 3600;
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
$retValue = PHPExcel_Shared_Date::ExcelToPHPObject($excelDateTime);
break;
}
date_default_timezone_set($saveTimeZone);
return $retValue;
} // function DATENOW()
/**
* DATE
*
* @param long $year
* @param long $month
* @param long $day
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATE($year = 0, $month = 1, $day = 1) {
$year = (integer) PHPExcel_Calculation_Functions::flattenSingleValue($year);
$month = (integer) PHPExcel_Calculation_Functions::flattenSingleValue($month);
$day = (integer) PHPExcel_Calculation_Functions::flattenSingleValue($day);
$baseYear = PHPExcel_Shared_Date::getExcelCalendar();
// Validate parameters
if ($year < ($baseYear-1900)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ((($baseYear-1900) != 0) && ($year < $baseYear) && ($year >= 1900)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (($year < $baseYear) && ($year >= ($baseYear-1900))) {
$year += 1900;
}
if ($month < 1) {
// Handle year/month adjustment if month < 1
--$month;
$year += ceil($month / 12) - 1;
$month = 13 - abs($month % 12);
} elseif ($month > 12) {
// Handle year/month adjustment if month > 12
$year += floor($month / 12);
$month = ($month % 12);
}
// Re-validate the year parameter after adjustments
if (($year < $baseYear) || ($year >= 10000)) {
return PHPExcel_Calculation_Functions::NaN();
}
// Execute function
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day);
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) $excelDateValue;
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue);
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return PHPExcel_Shared_Date::ExcelToPHPObject($excelDateValue);
break;
}
} // function DATE()
/**
* TIME
*
* @param long $hour
* @param long $minute
* @param long $second
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function TIME($hour = 0, $minute = 0, $second = 0) {
$hour = PHPExcel_Calculation_Functions::flattenSingleValue($hour);
$minute = PHPExcel_Calculation_Functions::flattenSingleValue($minute);
$second = PHPExcel_Calculation_Functions::flattenSingleValue($second);
if ($hour == '') { $hour = 0; }
if ($minute == '') { $minute = 0; }
if ($second == '') { $second = 0; }
if ((!is_numeric($hour)) || (!is_numeric($minute)) || (!is_numeric($second))) {
return PHPExcel_Calculation_Functions::VALUE();
}
$hour = (integer) $hour;
$minute = (integer) $minute;
$second = (integer) $second;
if ($second < 0) {
$minute += floor($second / 60);
$second = 60 - abs($second % 60);
if ($second == 60) { $second = 0; }
} elseif ($second >= 60) {
$minute += floor($second / 60);
$second = $second % 60;
}
if ($minute < 0) {
$hour += floor($minute / 60);
$minute = 60 - abs($minute % 60);
if ($minute == 60) { $minute = 0; }
} elseif ($minute >= 60) {
$hour += floor($minute / 60);
$minute = $minute % 60;
}
if ($hour > 23) {
$hour = $hour % 24;
} elseif ($hour < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
// Execute function
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
$date = 0;
$calendar = PHPExcel_Shared_Date::getExcelCalendar();
if ($calendar != PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900) {
$date = 1;
}
return (float) PHPExcel_Shared_Date::FormattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::FormattedPHPToExcel(1970, 1, 1, $hour-1, $minute, $second)); // -2147468400; // -2147472000 + 3600
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
$dayAdjust = 0;
if ($hour < 0) {
$dayAdjust = floor($hour / 24);
$hour = 24 - abs($hour % 24);
if ($hour == 24) { $hour = 0; }
} elseif ($hour >= 24) {
$dayAdjust = floor($hour / 24);
$hour = $hour % 24;
}
$phpDateObject = new DateTime('1900-01-01 '.$hour.':'.$minute.':'.$second);
if ($dayAdjust != 0) {
$phpDateObject->modify($dayAdjust.' days');
}
return $phpDateObject;
break;
}
} // function TIME()
/**
* DATEVALUE
*
* @param string $dateValue
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATEVALUE($dateValue = 1) {
$dateValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($dateValue),'"');
// Strip any ordinals because they're allowed in Excel (English only)
$dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui','$1$3',$dateValue);
// Convert separators (/ . or space) to hyphens (should also handle dot used for ordinals in some countries, e.g. Denmark, Germany)
$dateValue = str_replace(array('/','.','-',' '),array(' ',' ',' ',' '),$dateValue);
$yearFound = false;
$t1 = explode(' ',$dateValue);
foreach($t1 as &$t) {
if ((is_numeric($t)) && ($t > 31)) {
if ($yearFound) {
return PHPExcel_Calculation_Functions::VALUE();
} else {
if ($t < 100) { $t += 1900; }
$yearFound = true;
}
}
}
if ((count($t1) == 1) && (strpos($t,':') != false)) {
// We've been fed a time value without any date
return 0.0;
} elseif (count($t1) == 2) {
// We only have two parts of the date: either day/month or month/year
if ($yearFound) {
array_unshift($t1,1);
} else {
array_push($t1,date('Y'));
}
}
unset($t);
$dateValue = implode(' ',$t1);
$PHPDateArray = date_parse($dateValue);
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
$testVal1 = strtok($dateValue,'- ');
if ($testVal1 !== False) {
$testVal2 = strtok('- ');
if ($testVal2 !== False) {
$testVal3 = strtok('- ');
if ($testVal3 === False) {
$testVal3 = strftime('%Y');
}
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
$PHPDateArray = date_parse($testVal1.'-'.$testVal2.'-'.$testVal3);
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
$PHPDateArray = date_parse($testVal2.'-'.$testVal1.'-'.$testVal3);
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
return PHPExcel_Calculation_Functions::VALUE();
}
}
}
if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) {
// Execute function
if ($PHPDateArray['year'] == '') { $PHPDateArray['year'] = strftime('%Y'); }
if ($PHPDateArray['month'] == '') { $PHPDateArray['month'] = strftime('%m'); }
if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); }
$excelDateValue = floor(PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']));
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) $excelDateValue;
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue);
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return new DateTime($PHPDateArray['year'].'-'.$PHPDateArray['month'].'-'.$PHPDateArray['day'].' 00:00:00');
break;
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function DATEVALUE()
/**
* TIMEVALUE
*
* @param string $timeValue
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function TIMEVALUE($timeValue) {
$timeValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($timeValue),'"');
$timeValue = str_replace(array('/','.'),array('-','-'),$timeValue);
$PHPDateArray = date_parse($timeValue);
if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']);
} else {
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(1900,1,1,$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']) - 1;
}
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) $excelDateValue;
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) $phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue+25569) - 3600;;
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return new DateTime('1900-01-01 '.$PHPDateArray['hour'].':'.$PHPDateArray['minute'].':'.$PHPDateArray['second']);
break;
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function TIMEVALUE()
/**
* DATEDIF
*
* @param long $startDate Excel date serial value or a standard date string
* @param long $endDate Excel date serial value or a standard date string
* @param string $unit
* @return long Interval between the dates
*/
public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') {
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
$unit = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($unit));
if (is_string($startDate = self::_getDateValue($startDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($endDate = self::_getDateValue($endDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
// Validate parameters
if ($startDate >= $endDate) {
return PHPExcel_Calculation_Functions::NaN();
}
// Execute function
$difference = $endDate - $startDate;
$PHPStartDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($startDate);
$startDays = $PHPStartDateObject->format('j');
$startMonths = $PHPStartDateObject->format('n');
$startYears = $PHPStartDateObject->format('Y');
$PHPEndDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($endDate);
$endDays = $PHPEndDateObject->format('j');
$endMonths = $PHPEndDateObject->format('n');
$endYears = $PHPEndDateObject->format('Y');
$retVal = PHPExcel_Calculation_Functions::NaN();
switch ($unit) {
case 'D':
$retVal = intval($difference);
break;
case 'M':
$retVal = intval($endMonths - $startMonths) + (intval($endYears - $startYears) * 12);
// We're only interested in full months
if ($endDays < $startDays) {
--$retVal;
}
break;
case 'Y':
$retVal = intval($endYears - $startYears);
// We're only interested in full months
if ($endMonths < $startMonths) {
--$retVal;
} elseif (($endMonths == $startMonths) && ($endDays < $startDays)) {
--$retVal;
}
break;
case 'MD':
if ($endDays < $startDays) {
$retVal = $endDays;
$PHPEndDateObject->modify('-'.$endDays.' days');
$adjustDays = $PHPEndDateObject->format('j');
if ($adjustDays > $startDays) {
$retVal += ($adjustDays - $startDays);
}
} else {
$retVal = $endDays - $startDays;
}
break;
case 'YM':
$retVal = intval($endMonths - $startMonths);
if ($retVal < 0) $retVal = 12 + $retVal;
// We're only interested in full months
if ($endDays < $startDays) {
--$retVal;
}
break;
case 'YD':
$retVal = intval($difference);
if ($endYears > $startYears) {
while ($endYears > $startYears) {
$PHPEndDateObject->modify('-1 year');
$endYears = $PHPEndDateObject->format('Y');
}
$retVal = $PHPEndDateObject->format('z') - $PHPStartDateObject->format('z');
if ($retVal < 0) { $retVal += 365; }
}
break;
}
return $retVal;
} // function DATEDIF()
/**
* DAYS360
*
* @param long $startDate Excel date serial value or a standard date string
* @param long $endDate Excel date serial value or a standard date string
* @param boolean $method US or European Method
* @return long PHP date/time serial
*/
public static function DAYS360($startDate = 0, $endDate = 0, $method = false) {
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
if (is_string($startDate = self::_getDateValue($startDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($endDate = self::_getDateValue($endDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
// Execute function
$PHPStartDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($startDate);
$startDay = $PHPStartDateObject->format('j');
$startMonth = $PHPStartDateObject->format('n');
$startYear = $PHPStartDateObject->format('Y');
$PHPEndDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($endDate);
$endDay = $PHPEndDateObject->format('j');
$endMonth = $PHPEndDateObject->format('n');
$endYear = $PHPEndDateObject->format('Y');
return self::_dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, !$method);
} // function DAYS360()
/**
* YEARFRAC
*
* Calculates the fraction of the year represented by the number of whole days between two dates (the start_date and the
* end_date). Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or obligations
* to assign to a specific term.
*
* @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer) or date object, or a standard date string
* @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer) or date object, or a standard date string
* @param integer $method Method used for the calculation
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
* @return float fraction of the year
*/
public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) {
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
$method = PHPExcel_Calculation_Functions::flattenSingleValue($method);
if (is_string($startDate = self::_getDateValue($startDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($endDate = self::_getDateValue($endDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) {
switch($method) {
case 0 :
return self::DAYS360($startDate,$endDate) / 360;
break;
case 1 :
$days = self::DATEDIF($startDate,$endDate);
$startYear = self::YEAR($startDate);
$endYear = self::YEAR($endDate);
$years = $endYear - $startYear + 1;
$leapDays = 0;
if ($years == 1) {
if (self::_isLeapYear($endYear)) {
$startMonth = self::MONTHOFYEAR($startDate);
$endMonth = self::MONTHOFYEAR($endDate);
$endDay = self::DAYOFMONTH($endDate);
if (($startMonth < 3) ||
(($endMonth * 100 + $endDay) >= (2 * 100 + 29))) {
$leapDays += 1;
}
}
} else {
for($year = $startYear; $year <= $endYear; ++$year) {
if ($year == $startYear) {
$startMonth = self::MONTHOFYEAR($startDate);
$startDay = self::DAYOFMONTH($startDate);
if ($startMonth < 3) {
$leapDays += (self::_isLeapYear($year)) ? 1 : 0;
}
} elseif($year == $endYear) {
$endMonth = self::MONTHOFYEAR($endDate);
$endDay = self::DAYOFMONTH($endDate);
if (($endMonth * 100 + $endDay) >= (2 * 100 + 29)) {
$leapDays += (self::_isLeapYear($year)) ? 1 : 0;
}
} else {
$leapDays += (self::_isLeapYear($year)) ? 1 : 0;
}
}
if ($years == 2) {
if (($leapDays == 0) && (self::_isLeapYear($startYear)) && ($days > 365)) {
$leapDays = 1;
} elseif ($days < 366) {
$years = 1;
}
}
$leapDays /= $years;
}
return $days / (365 + $leapDays);
break;
case 2 :
return self::DATEDIF($startDate,$endDate) / 360;
break;
case 3 :
return self::DATEDIF($startDate,$endDate) / 365;
break;
case 4 :
return self::DAYS360($startDate,$endDate,True) / 360;
break;
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function YEARFRAC()
/**
* NETWORKDAYS
*
* @param mixed Start date
* @param mixed End date
* @param array of mixed Optional Date Series
* @return long Interval between the dates
*/
public static function NETWORKDAYS($startDate,$endDate) {
// Retrieve the mandatory start and end date that are referenced in the function definition
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
// Flush the mandatory start and end date that are referenced in the function definition, and get the optional days
$dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
array_shift($dateArgs);
array_shift($dateArgs);
// Validate the start and end dates
if (is_string($startDate = $sDate = self::_getDateValue($startDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
$startDate = (float) floor($startDate);
if (is_string($endDate = $eDate = self::_getDateValue($endDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
$endDate = (float) floor($endDate);
if ($sDate > $eDate) {
$startDate = $eDate;
$endDate = $sDate;
}
// Execute function
$startDoW = 6 - self::DAYOFWEEK($startDate,2);
if ($startDoW < 0) { $startDoW = 0; }
$endDoW = self::DAYOFWEEK($endDate,2);
if ($endDoW >= 6) { $endDoW = 0; }
$wholeWeekDays = floor(($endDate - $startDate) / 7) * 5;
$partWeekDays = $endDoW + $startDoW;
if ($partWeekDays > 5) {
$partWeekDays -= 5;
}
// Test any extra holiday parameters
$holidayCountedArray = array();
foreach ($dateArgs as $holidayDate) {
if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
if ((self::DAYOFWEEK($holidayDate,2) < 6) && (!in_array($holidayDate,$holidayCountedArray))) {
--$partWeekDays;
$holidayCountedArray[] = $holidayDate;
}
}
}
if ($sDate > $eDate) {
return 0 - ($wholeWeekDays + $partWeekDays);
}
return $wholeWeekDays + $partWeekDays;
} // function NETWORKDAYS()
/**
* WORKDAY
*
* @param mixed Start date
* @param mixed number of days for adjustment
* @param array of mixed Optional Date Series
* @return long Interval between the dates
*/
public static function WORKDAY($startDate,$endDays) {
// Retrieve the mandatory start date and days that are referenced in the function definition
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
$endDays = (int) PHPExcel_Calculation_Functions::flattenSingleValue($endDays);
// Flush the mandatory start date and days that are referenced in the function definition, and get the optional days
$dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
array_shift($dateArgs);
array_shift($dateArgs);
if ((is_string($startDate = self::_getDateValue($startDate))) || (!is_numeric($endDays))) {
return PHPExcel_Calculation_Functions::VALUE();
}
$startDate = (float) floor($startDate);
// If endDays is 0, we always return startDate
if ($endDays == 0) { return $startDate; }
$decrementing = ($endDays < 0) ? True : False;
// Adjust the start date if it falls over a weekend
$startDoW = self::DAYOFWEEK($startDate,3);
if (self::DAYOFWEEK($startDate,3) >= 5) {
$startDate += ($decrementing) ? -$startDoW + 4: 7 - $startDoW;
($decrementing) ? $endDays++ : $endDays--;
}
// Add endDays
$endDate = (float) $startDate + (intval($endDays / 5) * 7) + ($endDays % 5);
// Adjust the calculated end date if it falls over a weekend
$endDoW = self::DAYOFWEEK($endDate,3);
if ($endDoW >= 5) {
$endDate += ($decrementing) ? -$endDoW + 4: 7 - $endDoW;
}
// Test any extra holiday parameters
if (count($dateArgs) > 0) {
$holidayCountedArray = $holidayDates = array();
foreach ($dateArgs as $holidayDate) {
if ((!is_null($holidayDate)) && (trim($holidayDate) > '')) {
if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (self::DAYOFWEEK($holidayDate,3) < 5) {
$holidayDates[] = $holidayDate;
}
}
}
if ($decrementing) {
rsort($holidayDates, SORT_NUMERIC);
} else {
sort($holidayDates, SORT_NUMERIC);
}
foreach ($holidayDates as $holidayDate) {
if ($decrementing) {
if (($holidayDate <= $startDate) && ($holidayDate >= $endDate)) {
if (!in_array($holidayDate,$holidayCountedArray)) {
--$endDate;
$holidayCountedArray[] = $holidayDate;
}
}
} else {
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
if (!in_array($holidayDate,$holidayCountedArray)) {
++$endDate;
$holidayCountedArray[] = $holidayDate;
}
}
}
// Adjust the calculated end date if it falls over a weekend
$endDoW = self::DAYOFWEEK($endDate,3);
if ($endDoW >= 5) {
$endDate += ($decrementing) ? -$endDoW + 4: 7 - $endDoW;
}
}
}
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) $endDate;
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP($endDate);
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return PHPExcel_Shared_Date::ExcelToPHPObject($endDate);
break;
}
} // function WORKDAY()
/**
* DAYOFMONTH
*
* @param long $dateValue Excel date serial value or a standard date string
* @return int Day
*/
public static function DAYOFMONTH($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($dateValue == 0.0) {
return 0;
} elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
}
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
return (int) $PHPDateObject->format('j');
} // function DAYOFMONTH()
/**
* DAYOFWEEK
*
* @param long $dateValue Excel date serial value or a standard date string
* @return int Day
*/
public static function DAYOFWEEK($dateValue = 1, $style = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
$style = floor(PHPExcel_Calculation_Functions::flattenSingleValue($style));
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
}
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
$DoW = $PHPDateObject->format('w');
$firstDay = 1;
switch ($style) {
case 1: ++$DoW;
break;
case 2: if ($DoW == 0) { $DoW = 7; }
break;
case 3: if ($DoW == 0) { $DoW = 7; }
$firstDay = 0;
--$DoW;
break;
default:
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL) {
// Test for Excel's 1900 leap year, and introduce the error as required
if (($PHPDateObject->format('Y') == 1900) && ($PHPDateObject->format('n') <= 2)) {
--$DoW;
if ($DoW < $firstDay) {
$DoW += 7;
}
}
}
return (int) $DoW;
} // function DAYOFWEEK()
/**
* WEEKOFYEAR
*
* @param long $dateValue Excel date serial value or a standard date string
* @param boolean $method Week begins on Sunday or Monday
* @return int Week Number
*/
public static function WEEKOFYEAR($dateValue = 1, $method = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
$method = floor(PHPExcel_Calculation_Functions::flattenSingleValue($method));
if (!is_numeric($method)) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif (($method < 1) || ($method > 2)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
}
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
$dayOfYear = $PHPDateObject->format('z');
$dow = $PHPDateObject->format('w');
$PHPDateObject->modify('-'.$dayOfYear.' days');
$dow = $PHPDateObject->format('w');
$daysInFirstWeek = 7 - (($dow + (2 - $method)) % 7);
$dayOfYear -= $daysInFirstWeek;
$weekOfYear = ceil($dayOfYear / 7) + 1;
return (int) $weekOfYear;
} // function WEEKOFYEAR()
/**
* MONTHOFYEAR
*
* @param long $dateValue Excel date serial value or a standard date string
* @return int Month
*/
public static function MONTHOFYEAR($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
}
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
return (int) $PHPDateObject->format('n');
} // function MONTHOFYEAR()
/**
* YEAR
*
* @param long $dateValue Excel date serial value or a standard date string
* @return int Year
*/
public static function YEAR($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
}
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
return (int) $PHPDateObject->format('Y');
} // function YEAR()
/**
* HOUROFDAY
*
* @param mixed $timeValue Excel time serial value or a standard time string
* @return int Hour
*/
public static function HOUROFDAY($timeValue = 0) {
$timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue);
if (!is_numeric($timeValue)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$testVal = strtok($timeValue,'/-: ');
if (strlen($testVal) < strlen($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE();
}
}
$timeValue = self::_getTimeValue($timeValue);
if (is_string($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE();
}
}
// Execute function
if ($timeValue >= 1) {
$timeValue = fmod($timeValue,1);
} elseif ($timeValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
}
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
return (int) gmdate('G',$timeValue);
} // function HOUROFDAY()
/**
* MINUTEOFHOUR
*
* @param long $timeValue Excel time serial value or a standard time string
* @return int Minute
*/
public static function MINUTEOFHOUR($timeValue = 0) {
$timeValue = $timeTester = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue);
if (!is_numeric($timeValue)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$testVal = strtok($timeValue,'/-: ');
if (strlen($testVal) < strlen($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE();
}
}
$timeValue = self::_getTimeValue($timeValue);
if (is_string($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE();
}
}
// Execute function
if ($timeValue >= 1) {
$timeValue = fmod($timeValue,1);
} elseif ($timeValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
}
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
return (int) gmdate('i',$timeValue);
} // function MINUTEOFHOUR()
/**
* SECONDOFMINUTE
*
* @param long $timeValue Excel time serial value or a standard time string
* @return int Second
*/
public static function SECONDOFMINUTE($timeValue = 0) {
$timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue);
if (!is_numeric($timeValue)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$testVal = strtok($timeValue,'/-: ');
if (strlen($testVal) < strlen($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE();
}
}
$timeValue = self::_getTimeValue($timeValue);
if (is_string($timeValue)) {
return PHPExcel_Calculation_Functions::VALUE();
}
}
// Execute function
if ($timeValue >= 1) {
$timeValue = fmod($timeValue,1);
} elseif ($timeValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
}
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
return (int) gmdate('s',$timeValue);
} // function SECONDOFMINUTE()
/**
* EDATE
*
* Returns the serial number that represents the date that is the indicated number of months before or after a specified date
* (the start_date). Use EDATE to calculate maturity dates or due dates that fall on the same day of the month as the date of issue.
*
* @param long $dateValue Excel date serial value or a standard date string
* @param int $adjustmentMonths Number of months to adjust by
* @return long Excel date serial value
*/
public static function EDATE($dateValue = 1, $adjustmentMonths = 0) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
$adjustmentMonths = floor(PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths));
if (!is_numeric($adjustmentMonths)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
}
// Execute function
$PHPDateObject = self::_adjustDateByMonths($dateValue,$adjustmentMonths);
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) PHPExcel_Shared_Date::PHPToExcel($PHPDateObject);
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::PHPToExcel($PHPDateObject));
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return $PHPDateObject;
break;
}
} // function EDATE()
/**
* EOMONTH
*
* Returns the serial number for the last day of the month that is the indicated number of months before or after start_date.
* Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month.
*
* @param long $dateValue Excel date serial value or a standard date string
* @param int $adjustmentMonths Number of months to adjust by
* @return long Excel date serial value
*/
public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
$adjustmentMonths = floor(PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths));
if (!is_numeric($adjustmentMonths)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
}
// Execute function
$PHPDateObject = self::_adjustDateByMonths($dateValue,$adjustmentMonths+1);
$adjustDays = (int) $PHPDateObject->format('d');
$adjustDaysString = '-'.$adjustDays.' days';
$PHPDateObject->modify($adjustDaysString);
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL :
return (float) PHPExcel_Shared_Date::PHPToExcel($PHPDateObject);
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC :
return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::PHPToExcel($PHPDateObject));
break;
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT :
return $PHPDateObject;
break;
}
} // function EOMONTH()
} // class PHPExcel_Calculation_DateTime
| zysms | trunk/zysms/customer/PHPExcel/Calculation/DateTime.php | PHP | asf20 | 40,428 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Calculation_LookupRef
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_LookupRef {
/**
* CELL_ADDRESS
*
* Creates a cell address as text, given specified row and column numbers.
*
* @param row Row number to use in the cell reference
* @param column Column number to use in the cell reference
* @param relativity Flag indicating the type of reference to return
* 1 or omitted Absolute
* 2 Absolute row; relative column
* 3 Relative row; absolute column
* 4 Relative
* @param referenceStyle A logical value that specifies the A1 or R1C1 reference style.
* TRUE or omitted CELL_ADDRESS returns an A1-style reference
* FALSE CELL_ADDRESS returns an R1C1-style reference
* @param sheetText Optional Name of worksheet to use
* @return string
*/
public static function CELL_ADDRESS($row, $column, $relativity=1, $referenceStyle=True, $sheetText='') {
$row = PHPExcel_Calculation_Functions::flattenSingleValue($row);
$column = PHPExcel_Calculation_Functions::flattenSingleValue($column);
$relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity);
$sheetText = PHPExcel_Calculation_Functions::flattenSingleValue($sheetText);
if (($row < 1) || ($column < 1)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if ($sheetText > '') {
if (strpos($sheetText,' ') !== False) { $sheetText = "'".$sheetText."'"; }
$sheetText .='!';
}
if ((!is_bool($referenceStyle)) || $referenceStyle) {
$rowRelative = $columnRelative = '$';
$column = PHPExcel_Cell::stringFromColumnIndex($column-1);
if (($relativity == 2) || ($relativity == 4)) { $columnRelative = ''; }
if (($relativity == 3) || ($relativity == 4)) { $rowRelative = ''; }
return $sheetText.$columnRelative.$column.$rowRelative.$row;
} else {
if (($relativity == 2) || ($relativity == 4)) { $column = '['.$column.']'; }
if (($relativity == 3) || ($relativity == 4)) { $row = '['.$row.']'; }
return $sheetText.'R'.$row.'C'.$column;
}
} // function CELL_ADDRESS()
/**
* COLUMN
*
* Returns the column number of the given cell reference
* If the cell reference is a range of cells, COLUMN returns the column numbers of each column in the reference as a horizontal array.
* If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the
* reference of the cell in which the COLUMN function appears; otherwise this function returns 0.
*
* @param cellAddress A reference to a range of cells for which you want the column numbers
* @return integer or array of integer
*/
public static function COLUMN($cellAddress=Null) {
if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; }
if (is_array($cellAddress)) {
foreach($cellAddress as $columnKey => $value) {
$columnKey = preg_replace('/[^a-z]/i','',$columnKey);
return (integer) PHPExcel_Cell::columnIndexFromString($columnKey);
}
} else {
if (strpos($cellAddress,'!') !== false) {
list($sheet,$cellAddress) = explode('!',$cellAddress);
}
if (strpos($cellAddress,':') !== false) {
list($startAddress,$endAddress) = explode(':',$cellAddress);
$startAddress = preg_replace('/[^a-z]/i','',$startAddress);
$endAddress = preg_replace('/[^a-z]/i','',$endAddress);
$returnValue = array();
do {
$returnValue[] = (integer) PHPExcel_Cell::columnIndexFromString($startAddress);
} while ($startAddress++ != $endAddress);
return $returnValue;
} else {
$cellAddress = preg_replace('/[^a-z]/i','',$cellAddress);
return (integer) PHPExcel_Cell::columnIndexFromString($cellAddress);
}
}
} // function COLUMN()
/**
* COLUMNS
*
* Returns the number of columns in an array or reference.
*
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns
* @return integer
*/
public static function COLUMNS($cellAddress=Null) {
if (is_null($cellAddress) || $cellAddress === '') {
return 1;
} elseif (!is_array($cellAddress)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = array_keys($cellAddress);
$x = array_shift($x);
$isMatrix = (is_numeric($x));
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) {
return $rows;
} else {
return $columns;
}
} // function COLUMNS()
/**
* ROW
*
* Returns the row number of the given cell reference
* If the cell reference is a range of cells, ROW returns the row numbers of each row in the reference as a vertical array.
* If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the
* reference of the cell in which the ROW function appears; otherwise this function returns 0.
*
* @param cellAddress A reference to a range of cells for which you want the row numbers
* @return integer or array of integer
*/
public static function ROW($cellAddress=Null) {
if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; }
if (is_array($cellAddress)) {
foreach($cellAddress as $columnKey => $rowValue) {
foreach($rowValue as $rowKey => $cellValue) {
return (integer) preg_replace('/[^0-9]/i','',$rowKey);
}
}
} else {
if (strpos($cellAddress,'!') !== false) {
list($sheet,$cellAddress) = explode('!',$cellAddress);
}
if (strpos($cellAddress,':') !== false) {
list($startAddress,$endAddress) = explode(':',$cellAddress);
$startAddress = preg_replace('/[^0-9]/','',$startAddress);
$endAddress = preg_replace('/[^0-9]/','',$endAddress);
$returnValue = array();
do {
$returnValue[][] = (integer) $startAddress;
} while ($startAddress++ != $endAddress);
return $returnValue;
} else {
list($cellAddress) = explode(':',$cellAddress);
return (integer) preg_replace('/[^0-9]/','',$cellAddress);
}
}
} // function ROW()
/**
* ROWS
*
* Returns the number of rows in an array or reference.
*
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
* @return integer
*/
public static function ROWS($cellAddress=Null) {
if (is_null($cellAddress) || $cellAddress === '') {
return 1;
} elseif (!is_array($cellAddress)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$i = array_keys($cellAddress);
$isMatrix = (is_numeric(array_shift($i)));
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) {
return $columns;
} else {
return $rows;
}
} // function ROWS()
/**
* HYPERLINK
*
* Excel Function:
* =HYPERLINK(linkURL,displayName)
*
* @access public
* @category Logical Functions
* @param string $linkURL Value to check, is also the value returned when no error
* @param string $displayName Value to return when testValue is an error condition
* @return mixed The value of errorpart or testValue determined by error condition
*/
public static function HYPERLINK($linkURL = '', $displayName = null, PHPExcel_Cell $pCell = null) {
$args = func_get_args();
$pCell = array_pop($args);
$linkURL = (is_null($linkURL)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($linkURL);
$displayName = (is_null($displayName)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($displayName);
if ((!is_object($pCell)) || (trim($linkURL) == '')) {
return PHPExcel_Calculation_Functions::REF();
}
if ((is_object($displayName)) || trim($displayName) == '') {
$displayName = $linkURL;
}
$pCell->getHyperlink()->setUrl($linkURL);
return $displayName;
} // function HYPERLINK()
/**
* INDIRECT
*
* Returns the number of rows in an array or reference.
*
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of rows
* @return integer
*/
public static function INDIRECT($cellAddress=Null, PHPExcel_Cell $pCell = null) {
$cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress);
if (is_null($cellAddress) || $cellAddress === '') {
return PHPExcel_Calculation_Functions::REF();
}
$cellAddress1 = $cellAddress;
$cellAddress2 = NULL;
if (strpos($cellAddress,':') !== false) {
list($cellAddress1,$cellAddress2) = explode(':',$cellAddress);
}
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) ||
((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) {
return PHPExcel_Calculation_Functions::REF();
}
if (strpos($cellAddress,'!') !== false) {
list($sheetName,$cellAddress) = explode('!',$cellAddress);
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
} else {
$pSheet = $pCell->getParent();
}
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False);
} // function INDIRECT()
/**
* OFFSET
*
* Returns a reference to a range that is a specified number of rows and columns from a cell or range of cells.
* The reference that is returned can be a single cell or a range of cells. You can specify the number of rows and
* the number of columns to be returned.
*
* @param cellAddress The reference from which you want to base the offset. Reference must refer to a cell or
* range of adjacent cells; otherwise, OFFSET returns the #VALUE! error value.
* @param rows The number of rows, up or down, that you want the upper-left cell to refer to.
* Using 5 as the rows argument specifies that the upper-left cell in the reference is
* five rows below reference. Rows can be positive (which means below the starting reference)
* or negative (which means above the starting reference).
* @param cols The number of columns, to the left or right, that you want the upper-left cell of the result
* to refer to. Using 5 as the cols argument specifies that the upper-left cell in the
* reference is five columns to the right of reference. Cols can be positive (which means
* to the right of the starting reference) or negative (which means to the left of the
* starting reference).
* @param height The height, in number of rows, that you want the returned reference to be. Height must be a positive number.
* @param width The width, in number of columns, that you want the returned reference to be. Width must be a positive number.
* @return string A reference to a cell or range of cells
*/
public static function OFFSET($cellAddress=Null,$rows=0,$columns=0,$height=null,$width=null) {
$rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows);
$columns = PHPExcel_Calculation_Functions::flattenSingleValue($columns);
$height = PHPExcel_Calculation_Functions::flattenSingleValue($height);
$width = PHPExcel_Calculation_Functions::flattenSingleValue($width);
if ($cellAddress == Null) {
return 0;
}
$args = func_get_args();
$pCell = array_pop($args);
if (!is_object($pCell)) {
return PHPExcel_Calculation_Functions::REF();
}
$sheetName = null;
if (strpos($cellAddress,"!")) {
list($sheetName,$cellAddress) = explode("!",$cellAddress);
}
if (strpos($cellAddress,":")) {
list($startCell,$endCell) = explode(":",$cellAddress);
} else {
$startCell = $endCell = $cellAddress;
}
list($startCellColumn,$startCellRow) = PHPExcel_Cell::coordinateFromString($startCell);
list($endCellColumn,$endCellRow) = PHPExcel_Cell::coordinateFromString($endCell);
$startCellRow += $rows;
$startCellColumn = PHPExcel_Cell::columnIndexFromString($startCellColumn) - 1;
$startCellColumn += $columns;
if (($startCellRow <= 0) || ($startCellColumn < 0)) {
return PHPExcel_Calculation_Functions::REF();
}
$endCellColumn = PHPExcel_Cell::columnIndexFromString($endCellColumn) - 1;
if (($width != null) && (!is_object($width))) {
$endCellColumn = $startCellColumn + $width - 1;
} else {
$endCellColumn += $columns;
}
$startCellColumn = PHPExcel_Cell::stringFromColumnIndex($startCellColumn);
if (($height != null) && (!is_object($height))) {
$endCellRow = $startCellRow + $height - 1;
} else {
$endCellRow += $rows;
}
if (($endCellRow <= 0) || ($endCellColumn < 0)) {
return PHPExcel_Calculation_Functions::REF();
}
$endCellColumn = PHPExcel_Cell::stringFromColumnIndex($endCellColumn);
$cellAddress = $startCellColumn.$startCellRow;
if (($startCellColumn != $endCellColumn) || ($startCellRow != $endCellRow)) {
$cellAddress .= ':'.$endCellColumn.$endCellRow;
}
if ($sheetName !== null) {
$pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName);
} else {
$pSheet = $pCell->getParent();
}
return PHPExcel_Calculation::getInstance()->extractCellRange($cellAddress, $pSheet, False);
} // function OFFSET()
public static function CHOOSE() {
$chooseArgs = func_get_args();
$chosenEntry = PHPExcel_Calculation_Functions::flattenArray(array_shift($chooseArgs));
$entryCount = count($chooseArgs) - 1;
if(is_array($chosenEntry)) {
$chosenEntry = array_shift($chosenEntry);
}
if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) {
--$chosenEntry;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
$chosenEntry = floor($chosenEntry);
if (($chosenEntry <= 0) || ($chosenEntry > $entryCount)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_array($chooseArgs[$chosenEntry])) {
return PHPExcel_Calculation_Functions::flattenArray($chooseArgs[$chosenEntry]);
} else {
return $chooseArgs[$chosenEntry];
}
} // function CHOOSE()
/**
* MATCH
*
* The MATCH function searches for a specified item in a range of cells
*
* @param lookup_value The value that you want to match in lookup_array
* @param lookup_array The range of cells being searched
* @param match_type The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.
* @return integer The relative position of the found item
*/
public static function MATCH($lookup_value, $lookup_array, $match_type=1) {
$lookup_array = PHPExcel_Calculation_Functions::flattenArray($lookup_array);
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
$match_type = (is_null($match_type)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($match_type);
// MATCH is not case sensitive
$lookup_value = strtolower($lookup_value);
// lookup_value type has to be number, text, or logical values
if ((!is_numeric($lookup_value)) && (!is_string($lookup_value)) && (!is_bool($lookup_value))) {
return PHPExcel_Calculation_Functions::NA();
}
// match_type is 0, 1 or -1
if (($match_type !== 0) && ($match_type !== -1) && ($match_type !== 1)) {
return PHPExcel_Calculation_Functions::NA();
}
// lookup_array should not be empty
$lookupArraySize = count($lookup_array);
if ($lookupArraySize <= 0) {
return PHPExcel_Calculation_Functions::NA();
}
// lookup_array should contain only number, text, or logical values, or empty (null) cells
foreach($lookup_array as $i => $lookupArrayValue) {
// check the type of the value
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
(!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))) {
return PHPExcel_Calculation_Functions::NA();
}
// convert strings to lowercase for case-insensitive testing
if (is_string($lookupArrayValue)) {
$lookup_array[$i] = strtolower($lookupArrayValue);
}
if ((is_null($lookupArrayValue)) && (($match_type == 1) || ($match_type == -1))) {
$lookup_array = array_slice($lookup_array,0,$i-1);
}
}
// if match_type is 1 or -1, the list has to be ordered
if ($match_type == 1) {
asort($lookup_array);
$keySet = array_keys($lookup_array);
} elseif($match_type == -1) {
arsort($lookup_array);
$keySet = array_keys($lookup_array);
}
// **
// find the match
// **
// loop on the cells
// var_dump($lookup_array);
// echo '<br />';
foreach($lookup_array as $i => $lookupArrayValue) {
if (($match_type == 0) && ($lookupArrayValue == $lookup_value)) {
// exact match
return ++$i;
} elseif (($match_type == -1) && ($lookupArrayValue <= $lookup_value)) {
// echo '$i = '.$i.' => ';
// var_dump($lookupArrayValue);
// echo '<br />';
// echo 'Keyset = ';
// var_dump($keySet);
// echo '<br />';
$i = array_search($i,$keySet);
// echo '$i='.$i.'<br />';
// if match_type is -1 <=> find the smallest value that is greater than or equal to lookup_value
if ($i < 1){
// 1st cell was allready smaller than the lookup_value
break;
} else {
// the previous cell was the match
return $keySet[$i-1]+1;
}
} elseif (($match_type == 1) && ($lookupArrayValue >= $lookup_value)) {
// echo '$i = '.$i.' => ';
// var_dump($lookupArrayValue);
// echo '<br />';
// echo 'Keyset = ';
// var_dump($keySet);
// echo '<br />';
$i = array_search($i,$keySet);
// echo '$i='.$i.'<br />';
// if match_type is 1 <=> find the largest value that is less than or equal to lookup_value
if ($i < 1){
// 1st cell was allready bigger than the lookup_value
break;
} else {
// the previous cell was the match
return $keySet[$i-1]+1;
}
}
}
// unsuccessful in finding a match, return #N/A error value
return PHPExcel_Calculation_Functions::NA();
} // function MATCH()
/**
* INDEX
*
* Uses an index to choose a value from a reference or array
* implemented: Return the value of a specified cell or array of cells Array form
* not implemented: Return a reference to specified cells Reference form
*
* @param range_array a range of cells or an array constant
* @param row_num selects the row in array from which to return a value. If row_num is omitted, column_num is required.
* @param column_num selects the column in array from which to return a value. If column_num is omitted, row_num is required.
*/
public static function INDEX($arrayValues,$rowNum = 0,$columnNum = 0) {
if (($rowNum < 0) || ($columnNum < 0)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (!is_array($arrayValues)) {
return PHPExcel_Calculation_Functions::REF();
}
$rowKeys = array_keys($arrayValues);
$columnKeys = @array_keys($arrayValues[$rowKeys[0]]);
if ($columnNum > count($columnKeys)) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($columnNum == 0) {
if ($rowNum == 0) {
return $arrayValues;
}
$rowNum = $rowKeys[--$rowNum];
$returnArray = array();
foreach($arrayValues as $arrayColumn) {
if (is_array($arrayColumn)) {
if (isset($arrayColumn[$rowNum])) {
$returnArray[] = $arrayColumn[$rowNum];
} else {
return $arrayValues[$rowNum];
}
} else {
return $arrayValues[$rowNum];
}
}
return $returnArray;
}
$columnNum = $columnKeys[--$columnNum];
if ($rowNum > count($rowKeys)) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($rowNum == 0) {
return $arrayValues[$columnNum];
}
$rowNum = $rowKeys[--$rowNum];
return $arrayValues[$rowNum][$columnNum];
} // function INDEX()
/**
* TRANSPOSE
*
* @param array $matrixData A matrix of values
* @return array
*
* Unlike the Excel TRANSPOSE function, which will only work on a single row or column, this function will transpose a full matrix.
*/
public static function TRANSPOSE($matrixData) {
$returnMatrix = array();
if (!is_array($matrixData)) { $matrixData = array(array($matrixData)); }
$column = 0;
foreach($matrixData as $matrixRow) {
$row = 0;
foreach($matrixRow as $matrixCell) {
$returnMatrix[$row][$column] = $matrixCell;
++$row;
}
++$column;
}
return $returnMatrix;
} // function TRANSPOSE()
private static function _vlookupSort($a,$b) {
$f = array_keys($a);
$firstColumn = array_shift($f);
if (strtolower($a[$firstColumn]) == strtolower($b[$firstColumn])) {
return 0;
}
return (strtolower($a[$firstColumn]) < strtolower($b[$firstColumn])) ? -1 : 1;
} // function _vlookupSort()
/**
* VLOOKUP
* The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number.
* @param lookup_value The value that you want to match in lookup_array
* @param lookup_array The range of cells being searched
* @param index_number The column number in table_array from which the matching value must be returned. The first column is 1.
* @param not_exact_match Determines if you are looking for an exact match based on lookup_value.
* @return mixed The value of the found cell
*/
public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) {
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
$index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number);
$not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match);
// index_number must be greater than or equal to 1
if ($index_number < 1) {
return PHPExcel_Calculation_Functions::VALUE();
}
// index_number must be less than or equal to the number of columns in lookup_array
if ((!is_array($lookup_array)) || (count($lookup_array) < 1)) {
return PHPExcel_Calculation_Functions::REF();
} else {
$f = array_keys($lookup_array);
$firstRow = array_pop($f);
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) {
return PHPExcel_Calculation_Functions::REF();
} else {
$columnKeys = array_keys($lookup_array[$firstRow]);
$returnColumn = $columnKeys[--$index_number];
$firstColumn = array_shift($columnKeys);
}
}
if (!$not_exact_match) {
uasort($lookup_array,array('self','_vlookupSort'));
}
$rowNumber = $rowValue = False;
foreach($lookup_array as $rowKey => $rowData) {
if (strtolower($rowData[$firstColumn]) > strtolower($lookup_value)) {
break;
}
$rowNumber = $rowKey;
$rowValue = $rowData[$firstColumn];
}
if ($rowNumber !== false) {
if ((!$not_exact_match) && ($rowValue != $lookup_value)) {
// if an exact match is required, we have what we need to return an appropriate response
return PHPExcel_Calculation_Functions::NA();
} else {
// otherwise return the appropriate value
return $lookup_array[$rowNumber][$returnColumn];
}
}
return PHPExcel_Calculation_Functions::NA();
} // function VLOOKUP()
/**
* LOOKUP
* The LOOKUP function searches for value either from a one-row or one-column range or from an array.
* @param lookup_value The value that you want to match in lookup_array
* @param lookup_vector The range of cells being searched
* @param result_vector The column from which the matching value must be returned
* @return mixed The value of the found cell
*/
public static function LOOKUP($lookup_value, $lookup_vector, $result_vector=null) {
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
if (!is_array($lookup_vector)) {
return PHPExcel_Calculation_Functions::NA();
}
$lookupRows = count($lookup_vector);
$l = array_keys($lookup_vector);
$l = array_shift($l);
$lookupColumns = count($lookup_vector[$l]);
if ((($lookupRows == 1) && ($lookupColumns > 1)) || (($lookupRows == 2) && ($lookupColumns != 2))) {
$lookup_vector = self::TRANSPOSE($lookup_vector);
$lookupRows = count($lookup_vector);
$l = array_keys($lookup_vector);
$lookupColumns = count($lookup_vector[array_shift($l)]);
}
if (is_null($result_vector)) {
$result_vector = $lookup_vector;
}
$resultRows = count($result_vector);
$l = array_keys($result_vector);
$l = array_shift($l);
$resultColumns = count($result_vector[$l]);
if ((($resultRows == 1) && ($resultColumns > 1)) || (($resultRows == 2) && ($resultColumns != 2))) {
$result_vector = self::TRANSPOSE($result_vector);
$resultRows = count($result_vector);
$r = array_keys($result_vector);
$resultColumns = count($result_vector[array_shift($r)]);
}
if ($lookupRows == 2) {
$result_vector = array_pop($lookup_vector);
$lookup_vector = array_shift($lookup_vector);
}
if ($lookupColumns != 2) {
foreach($lookup_vector as &$value) {
if (is_array($value)) {
$k = array_keys($value);
$key1 = $key2 = array_shift($k);
$key2++;
$dataValue1 = $value[$key1];
} else {
$key1 = 0;
$key2 = 1;
$dataValue1 = $value;
}
$dataValue2 = array_shift($result_vector);
if (is_array($dataValue2)) {
$dataValue2 = array_shift($dataValue2);
}
$value = array($key1 => $dataValue1, $key2 => $dataValue2);
}
unset($value);
}
return self::VLOOKUP($lookup_value,$lookup_vector,2);
} // function LOOKUP()
} // class PHPExcel_Calculation_LookupRef
| zysms | trunk/zysms/customer/PHPExcel/Calculation/LookupRef.php | PHP | asf20 | 26,664 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** FINANCIAL_MAX_ITERATIONS */
define('FINANCIAL_MAX_ITERATIONS', 128);
/** FINANCIAL_PRECISION */
define('FINANCIAL_PRECISION', 1.0e-08);
/**
* PHPExcel_Calculation_Financial
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Financial {
private static function _lastDayOfMonth($testDate) {
$date = clone $testDate;
$date->modify('+1 day');
return ($date->format('d') == 1);
} // function _lastDayOfMonth()
private static function _firstDayOfMonth($testDate) {
$date = clone $testDate;
return ($date->format('d') == 1);
} // function _lastDayOfMonth()
private static function _coupFirstPeriodDate($settlement, $maturity, $frequency, $next) {
$months = 12 / $frequency;
$result = PHPExcel_Shared_Date::ExcelToPHPObject($maturity);
$eom = self::_lastDayOfMonth($result);
while ($settlement < PHPExcel_Shared_Date::PHPToExcel($result)) {
$result->modify('-'.$months.' months');
}
if ($next) {
$result->modify('+'.$months.' months');
}
if ($eom) {
$result->modify('-1 day');
}
return PHPExcel_Shared_Date::PHPToExcel($result);
} // function _coupFirstPeriodDate()
private static function _validFrequency($frequency) {
if (($frequency == 1) || ($frequency == 2) || ($frequency == 4)) {
return true;
}
if ((PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) &&
(($frequency == 6) || ($frequency == 12))) {
return true;
}
return false;
} // function _validFrequency()
private static function _daysPerYear($year,$basis) {
switch ($basis) {
case 0 :
case 2 :
case 4 :
$daysPerYear = 360;
break;
case 3 :
$daysPerYear = 365;
break;
case 1 :
if (PHPExcel_Calculation_DateTime::_isLeapYear($year)) {
$daysPerYear = 366;
} else {
$daysPerYear = 365;
}
break;
default :
return PHPExcel_Calculation_Functions::NaN();
}
return $daysPerYear;
} // function _daysPerYear()
private static function _interestAndPrincipal($rate=0, $per=0, $nper=0, $pv=0, $fv=0, $type=0) {
$pmt = self::PMT($rate, $nper, $pv, $fv, $type);
$capital = $pv;
for ($i = 1; $i<= $per; ++$i) {
$interest = ($type && $i == 1) ? 0 : -$capital * $rate;
$principal = $pmt - $interest;
$capital += $principal;
}
return array($interest, $principal);
} // function _interestAndPrincipal()
/**
* ACCRINT
*
* Returns the discount rate for a security.
*
* @param mixed issue The security's issue date.
* @param mixed firstinter The security's first interest date.
* @param mixed settlement The security's settlement date.
* @param float rate The security's annual coupon rate.
* @param float par The security's par value.
* @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
* @return float
*/
public static function ACCRINT($issue, $firstinter, $settlement, $rate, $par=1000, $frequency=1, $basis=0) {
$issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue);
$firstinter = PHPExcel_Calculation_Functions::flattenSingleValue($firstinter);
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$rate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$par = (is_null($par)) ? 1000 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($par);
$frequency = (is_null($frequency)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($rate)) && (is_numeric($par))) {
if (($rate <= 0) || ($par <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error
return $daysBetweenIssueAndSettlement;
}
return $par * $rate * $daysBetweenIssueAndSettlement;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function ACCRINT()
/**
* ACCRINTM
*
* Returns the discount rate for a security.
*
* @param mixed issue The security's issue date.
* @param mixed settlement The security's settlement date.
* @param float rate The security's annual coupon rate.
* @param float par The security's par value.
* @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
* @return float
*/
public static function ACCRINTM($issue, $settlement, $rate, $par=1000, $basis=0) {
$issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue);
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$rate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$par = (is_null($par)) ? 1000 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($par);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($rate)) && (is_numeric($par))) {
if (($rate <= 0) || ($par <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error
return $daysBetweenIssueAndSettlement;
}
return $par * $rate * $daysBetweenIssueAndSettlement;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function ACCRINTM()
public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis=0) {
$cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
$purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased);
$firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod);
$salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
$period = floor(PHPExcel_Calculation_Functions::flattenSingleValue($period));
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
$fUsePer = 1.0 / $rate;
if ($fUsePer < 3.0) {
$amortiseCoeff = 1.0;
} elseif ($fUsePer < 5.0) {
$amortiseCoeff = 1.5;
} elseif ($fUsePer <= 6.0) {
$amortiseCoeff = 2.0;
} else {
$amortiseCoeff = 2.5;
}
$rate *= $amortiseCoeff;
$fNRate = round(PHPExcel_Calculation_DateTime::YEARFRAC($purchased, $firstPeriod, $basis) * $rate * $cost,0);
$cost -= $fNRate;
$fRest = $cost - $salvage;
for ($n = 0; $n < $period; ++$n) {
$fNRate = round($rate * $cost,0);
$fRest -= $fNRate;
if ($fRest < 0.0) {
switch ($period - $n) {
case 0 :
case 1 : return round($cost * 0.5,0);
break;
default : return 0.0;
break;
}
}
$cost -= $fNRate;
}
return $fNRate;
} // function AMORDEGRC()
public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis=0) {
$cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
$purchased = PHPExcel_Calculation_Functions::flattenSingleValue($purchased);
$firstPeriod = PHPExcel_Calculation_Functions::flattenSingleValue($firstPeriod);
$salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
$period = PHPExcel_Calculation_Functions::flattenSingleValue($period);
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
$fOneRate = $cost * $rate;
$fCostDelta = $cost - $salvage;
// Note, quirky variation for leap years on the YEARFRAC for this function
$purchasedYear = PHPExcel_Calculation_DateTime::YEAR($purchased);
$yearFrac = PHPExcel_Calculation_DateTime::YEARFRAC($purchased, $firstPeriod, $basis);
if (($basis == 1) && ($yearFrac < 1) && (PHPExcel_Calculation_DateTime::_isLeapYear($purchasedYear))) {
$yearFrac *= 365 / 366;
}
$f0Rate = $yearFrac * $rate * $cost;
$nNumOfFullPeriods = intval(($cost - $salvage - $f0Rate) / $fOneRate);
if ($period == 0) {
return $f0Rate;
} elseif ($period <= $nNumOfFullPeriods) {
return $fOneRate;
} elseif ($period == ($nNumOfFullPeriods + 1)) {
return ($fCostDelta - $fOneRate * $nNumOfFullPeriods - $f0Rate);
} else {
return 0.0;
}
} // function AMORLINC()
public static function COUPDAYBS($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($maturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (($settlement > $maturity) ||
(!self::_validFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis);
$prev = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False);
return PHPExcel_Calculation_DateTime::YEARFRAC($prev, $settlement, $basis) * $daysPerYear;
} // function COUPDAYBS()
public static function COUPDAYS($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($maturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (($settlement > $maturity) ||
(!self::_validFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) {
return PHPExcel_Calculation_Functions::NaN();
}
switch ($basis) {
case 3: // Actual/365
return 365 / $frequency;
case 1: // Actual/actual
if ($frequency == 1) {
$daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($maturity),$basis);
return ($daysPerYear / $frequency);
} else {
$prev = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False);
$next = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True);
return ($next - $prev);
}
default: // US (NASD) 30/360, Actual/360 or European 30/360
return 360 / $frequency;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function COUPDAYS()
public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($maturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (($settlement > $maturity) ||
(!self::_validFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis);
$next = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True);
return PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $next, $basis) * $daysPerYear;
} // function COUPDAYSNC()
public static function COUPNCD($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($maturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (($settlement > $maturity) ||
(!self::_validFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) {
return PHPExcel_Calculation_Functions::NaN();
}
return self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True);
} // function COUPNCD()
public static function COUPNUM($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($maturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (($settlement > $maturity) ||
(!self::_validFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) {
return PHPExcel_Calculation_Functions::NaN();
}
$settlement = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True);
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis) * 365;
switch ($frequency) {
case 1: // annual payments
return ceil($daysBetweenSettlementAndMaturity / 360);
case 2: // half-yearly
return ceil($daysBetweenSettlementAndMaturity / 180);
case 4: // quarterly
return ceil($daysBetweenSettlementAndMaturity / 90);
case 6: // bimonthly
return ceil($daysBetweenSettlementAndMaturity / 60);
case 12: // monthly
return ceil($daysBetweenSettlementAndMaturity / 30);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function COUPNUM()
public static function COUPPCD($settlement, $maturity, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($maturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (($settlement > $maturity) ||
(!self::_validFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) {
return PHPExcel_Calculation_Functions::NaN();
}
return self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False);
} // function COUPPCD()
/**
* CUMIPMT
*
* Returns the cumulative interest paid on a loan between start_period and end_period.
*
* @param float $rate Interest rate per period
* @param int $nper Number of periods
* @param float $pv Present Value
* @param int start The first period in the calculation.
* Payment periods are numbered beginning with 1.
* @param int end The last period in the calculation.
* @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
* @return float
*/
public static function CUMIPMT($rate, $nper, $pv, $start, $end, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper);
$pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
$start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start);
$end = (int) PHPExcel_Calculation_Functions::flattenSingleValue($end);
$type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($start < 1 || $start > $end) {
return PHPExcel_Calculation_Functions::VALUE();
}
// Calculate
$interest = 0;
for ($per = $start; $per <= $end; ++$per) {
$interest += self::IPMT($rate, $per, $nper, $pv, 0, $type);
}
return $interest;
} // function CUMIPMT()
/**
* CUMPRINC
*
* Returns the cumulative principal paid on a loan between start_period and end_period.
*
* @param float $rate Interest rate per period
* @param int $nper Number of periods
* @param float $pv Present Value
* @param int start The first period in the calculation.
* Payment periods are numbered beginning with 1.
* @param int end The last period in the calculation.
* @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
* @return float
*/
public static function CUMPRINC($rate, $nper, $pv, $start, $end, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper);
$pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
$start = (int) PHPExcel_Calculation_Functions::flattenSingleValue($start);
$end = (int) PHPExcel_Calculation_Functions::flattenSingleValue($end);
$type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($start < 1 || $start > $end) {
return PHPExcel_Calculation_Functions::VALUE();
}
// Calculate
$principal = 0;
for ($per = $start; $per <= $end; ++$per) {
$principal += self::PPMT($rate, $per, $nper, $pv, 0, $type);
}
return $principal;
} // function CUMPRINC()
/**
* DB
*
* Returns the depreciation of an asset for a specified period using the fixed-declining balance method.
* This form of depreciation is used if you want to get a higher depreciation value at the beginning of the depreciation
* (as opposed to linear depreciation). The depreciation value is reduced with every depreciation period by the
* depreciation already deducted from the initial cost.
*
* @param float cost Initial cost of the asset.
* @param float salvage Value at the end of the depreciation. (Sometimes called the salvage value of the asset)
* @param int life Number of periods over which the asset is depreciated. (Sometimes called the useful life of the asset)
* @param int period The period for which you want to calculate the depreciation. Period must use the same units as life.
* @param float month Number of months in the first year. If month is omitted, it defaults to 12.
* @return float
*/
public static function DB($cost, $salvage, $life, $period, $month=12) {
$cost = (float) PHPExcel_Calculation_Functions::flattenSingleValue($cost);
$salvage = (float) PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
$life = (int) PHPExcel_Calculation_Functions::flattenSingleValue($life);
$period = (int) PHPExcel_Calculation_Functions::flattenSingleValue($period);
$month = (int) PHPExcel_Calculation_Functions::flattenSingleValue($month);
// Validate
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period)) && (is_numeric($month))) {
if ($cost == 0) {
return 0.0;
} elseif (($cost < 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($month < 1)) {
return PHPExcel_Calculation_Functions::NaN();
}
// Set Fixed Depreciation Rate
$fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life));
$fixedDepreciationRate = round($fixedDepreciationRate, 3);
// Loop through each period calculating the depreciation
$previousDepreciation = 0;
for ($per = 1; $per <= $period; ++$per) {
if ($per == 1) {
$depreciation = $cost * $fixedDepreciationRate * $month / 12;
} elseif ($per == ($life + 1)) {
$depreciation = ($cost - $previousDepreciation) * $fixedDepreciationRate * (12 - $month) / 12;
} else {
$depreciation = ($cost - $previousDepreciation) * $fixedDepreciationRate;
}
$previousDepreciation += $depreciation;
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$depreciation = round($depreciation,2);
}
return $depreciation;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function DB()
/**
* DDB
*
* Returns the depreciation of an asset for a specified period using the double-declining balance method or some other method you specify.
*
* @param float cost Initial cost of the asset.
* @param float salvage Value at the end of the depreciation. (Sometimes called the salvage value of the asset)
* @param int life Number of periods over which the asset is depreciated. (Sometimes called the useful life of the asset)
* @param int period The period for which you want to calculate the depreciation. Period must use the same units as life.
* @param float factor The rate at which the balance declines.
* If factor is omitted, it is assumed to be 2 (the double-declining balance method).
* @return float
*/
public static function DDB($cost, $salvage, $life, $period, $factor=2.0) {
$cost = (float) PHPExcel_Calculation_Functions::flattenSingleValue($cost);
$salvage = (float) PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
$life = (int) PHPExcel_Calculation_Functions::flattenSingleValue($life);
$period = (int) PHPExcel_Calculation_Functions::flattenSingleValue($period);
$factor = (float) PHPExcel_Calculation_Functions::flattenSingleValue($factor);
// Validate
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period)) && (is_numeric($factor))) {
if (($cost <= 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($factor <= 0.0) || ($period > $life)) {
return PHPExcel_Calculation_Functions::NaN();
}
// Set Fixed Depreciation Rate
$fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life));
$fixedDepreciationRate = round($fixedDepreciationRate, 3);
// Loop through each period calculating the depreciation
$previousDepreciation = 0;
for ($per = 1; $per <= $period; ++$per) {
$depreciation = min( ($cost - $previousDepreciation) * ($factor / $life), ($cost - $salvage - $previousDepreciation) );
$previousDepreciation += $depreciation;
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$depreciation = round($depreciation,2);
}
return $depreciation;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function DDB()
/**
* DISC
*
* Returns the discount rate for a security.
*
* @param mixed settlement The security's settlement date.
* The security settlement date is the date after the issue date when the security is traded to the buyer.
* @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param int price The security's price per $100 face value.
* @param int redemption the security's redemption value per $100 face value.
* @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
* @return float
*/
public static function DISC($settlement, $maturity, $price, $redemption, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$price = (float) PHPExcel_Calculation_Functions::flattenSingleValue($price);
$redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption);
$basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($price)) && (is_numeric($redemption)) && (is_numeric($basis))) {
if (($price <= 0) || ($redemption <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
return ((1 - $price / $redemption) / $daysBetweenSettlementAndMaturity);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function DISC()
/**
* DOLLARDE
*
* Converts a dollar price expressed as an integer part and a fraction part into a dollar price expressed as a decimal number.
* Fractional dollar numbers are sometimes used for security prices.
*
* @param float $fractional_dollar Fractional Dollar
* @param int $fraction Fraction
* @return float
*/
public static function DOLLARDE($fractional_dollar = Null, $fraction = 0) {
$fractional_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($fractional_dollar);
$fraction = (int)PHPExcel_Calculation_Functions::flattenSingleValue($fraction);
// Validate parameters
if (is_null($fractional_dollar) || $fraction < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($fraction == 0) {
return PHPExcel_Calculation_Functions::DIV0();
}
$dollars = floor($fractional_dollar);
$cents = fmod($fractional_dollar,1);
$cents /= $fraction;
$cents *= pow(10,ceil(log10($fraction)));
return $dollars + $cents;
} // function DOLLARDE()
/**
* DOLLARFR
*
* Converts a dollar price expressed as a decimal number into a dollar price expressed as a fraction.
* Fractional dollar numbers are sometimes used for security prices.
*
* @param float $decimal_dollar Decimal Dollar
* @param int $fraction Fraction
* @return float
*/
public static function DOLLARFR($decimal_dollar = Null, $fraction = 0) {
$decimal_dollar = PHPExcel_Calculation_Functions::flattenSingleValue($decimal_dollar);
$fraction = (int)PHPExcel_Calculation_Functions::flattenSingleValue($fraction);
// Validate parameters
if (is_null($decimal_dollar) || $fraction < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($fraction == 0) {
return PHPExcel_Calculation_Functions::DIV0();
}
$dollars = floor($decimal_dollar);
$cents = fmod($decimal_dollar,1);
$cents *= $fraction;
$cents *= pow(10,-ceil(log10($fraction)));
return $dollars + $cents;
} // function DOLLARFR()
/**
* EFFECT
*
* Returns the effective interest rate given the nominal rate and the number of compounding payments per year.
*
* @param float $nominal_rate Nominal interest rate
* @param int $npery Number of compounding payments per year
* @return float
*/
public static function EFFECT($nominal_rate = 0, $npery = 0) {
$nominal_rate = PHPExcel_Calculation_Functions::flattenSingleValue($nominal_rate);
$npery = (int)PHPExcel_Calculation_Functions::flattenSingleValue($npery);
// Validate parameters
if ($nominal_rate <= 0 || $npery < 1) {
return PHPExcel_Calculation_Functions::NaN();
}
return pow((1 + $nominal_rate / $npery), $npery) - 1;
} // function EFFECT()
/**
* FV
*
* Returns the Future Value of a cash flow with constant payments and interest rate (annuities).
*
* @param float $rate Interest rate per period
* @param int $nper Number of periods
* @param float $pmt Periodic payment (annuity)
* @param float $pv Present Value
* @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
* @return float
*/
public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$nper = PHPExcel_Calculation_Functions::flattenSingleValue($nper);
$pmt = PHPExcel_Calculation_Functions::flattenSingleValue($pmt);
$pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
$type = PHPExcel_Calculation_Functions::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return PHPExcel_Calculation_Functions::NaN();
}
// Calculate
if (!is_null($rate) && $rate != 0) {
return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate;
} else {
return -$pv - $pmt * $nper;
}
} // function FV()
/**
* FVSCHEDULE
*
*/
public static function FVSCHEDULE($principal, $schedule) {
$principal = PHPExcel_Calculation_Functions::flattenSingleValue($principal);
$schedule = PHPExcel_Calculation_Functions::flattenArray($schedule);
foreach($schedule as $n) {
$principal *= 1 + $n;
}
return $principal;
} // function FVSCHEDULE()
/**
* INTRATE
*
* Returns the interest rate for a fully invested security.
*
* @param mixed settlement The security's settlement date.
* The security settlement date is the date after the issue date when the security is traded to the buyer.
* @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param int investment The amount invested in the security.
* @param int redemption The amount to be received at maturity.
* @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
* @return float
*/
public static function INTRATE($settlement, $maturity, $investment, $redemption, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$investment = (float) PHPExcel_Calculation_Functions::flattenSingleValue($investment);
$redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption);
$basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($investment)) && (is_numeric($redemption)) && (is_numeric($basis))) {
if (($investment <= 0) || ($redemption <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
return (($redemption / $investment) - 1) / ($daysBetweenSettlementAndMaturity);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function INTRATE()
/**
* IPMT
*
* Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.
*
* @param float $rate Interest rate per period
* @param int $per Period for which we want to find the interest
* @param int $nper Number of periods
* @param float $pv Present Value
* @param float $fv Future Value
* @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
* @return float
*/
public static function IPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$per = (int) PHPExcel_Calculation_Functions::flattenSingleValue($per);
$nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper);
$pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
$fv = PHPExcel_Calculation_Functions::flattenSingleValue($fv);
$type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($per <= 0 || $per > $nper) {
return PHPExcel_Calculation_Functions::VALUE();
}
// Calculate
$interestAndPrincipal = self::_interestAndPrincipal($rate, $per, $nper, $pv, $fv, $type);
return $interestAndPrincipal[0];
} // function IPMT()
public static function IRR($values, $guess = 0.1) {
if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE();
$values = PHPExcel_Calculation_Functions::flattenArray($values);
$guess = PHPExcel_Calculation_Functions::flattenSingleValue($guess);
// create an initial range, with a root somewhere between 0 and guess
$x1 = 0.0;
$x2 = $guess;
$f1 = self::NPV($x1, $values);
$f2 = self::NPV($x2, $values);
for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) {
if (($f1 * $f2) < 0.0) break;
if (abs($f1) < abs($f2)) {
$f1 = self::NPV($x1 += 1.6 * ($x1 - $x2), $values);
} else {
$f2 = self::NPV($x2 += 1.6 * ($x2 - $x1), $values);
}
}
if (($f1 * $f2) > 0.0) return PHPExcel_Calculation_Functions::VALUE();
$f = self::NPV($x1, $values);
if ($f < 0.0) {
$rtb = $x1;
$dx = $x2 - $x1;
} else {
$rtb = $x2;
$dx = $x1 - $x2;
}
for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) {
$dx *= 0.5;
$x_mid = $rtb + $dx;
$f_mid = self::NPV($x_mid, $values);
if ($f_mid <= 0.0) $rtb = $x_mid;
if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) return $x_mid;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function IRR()
/**
* ISPMT
*
* Returns the interest payment for an investment based on an interest rate and a constant payment schedule.
*
* Excel Function:
* =ISPMT(interest_rate, period, number_payments, PV)
*
* interest_rate is the interest rate for the investment
*
* period is the period to calculate the interest rate. It must be betweeen 1 and number_payments.
*
* number_payments is the number of payments for the annuity
*
* PV is the loan amount or present value of the payments
*/
public static function ISPMT() {
// Return value
$returnValue = 0;
// Get the parameters
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$interestRate = array_shift($aArgs);
$period = array_shift($aArgs);
$numberPeriods = array_shift($aArgs);
$principleRemaining = array_shift($aArgs);
// Calculate
$principlePayment = ($principleRemaining * 1.0) / ($numberPeriods * 1.0);
for($i=0; $i <= $period; ++$i) {
$returnValue = $interestRate * $principleRemaining * -1;
$principleRemaining -= $principlePayment;
// principle needs to be 0 after the last payment, don't let floating point screw it up
if($i == $numberPeriods) {
$returnValue = 0;
}
}
return($returnValue);
} // function ISPMT()
public static function MIRR($values, $finance_rate, $reinvestment_rate) {
if (!is_array($values)) return PHPExcel_Calculation_Functions::VALUE();
$values = PHPExcel_Calculation_Functions::flattenArray($values);
$finance_rate = PHPExcel_Calculation_Functions::flattenSingleValue($finance_rate);
$reinvestment_rate = PHPExcel_Calculation_Functions::flattenSingleValue($reinvestment_rate);
$n = count($values);
$rr = 1.0 + $reinvestment_rate;
$fr = 1.0 + $finance_rate;
$npv_pos = $npv_neg = 0.0;
foreach($values as $i => $v) {
if ($v >= 0) {
$npv_pos += $v / pow($rr, $i);
} else {
$npv_neg += $v / pow($fr, $i);
}
}
if (($npv_neg == 0) || ($npv_pos == 0) || ($reinvestment_rate <= -1)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$mirr = pow((-$npv_pos * pow($rr, $n))
/ ($npv_neg * ($rr)), (1.0 / ($n - 1))) - 1.0;
return (is_finite($mirr) ? $mirr : PHPExcel_Calculation_Functions::VALUE());
} // function MIRR()
/**
* NOMINAL
*
* Returns the nominal interest rate given the effective rate and the number of compounding payments per year.
*
* @param float $effect_rate Effective interest rate
* @param int $npery Number of compounding payments per year
* @return float
*/
public static function NOMINAL($effect_rate = 0, $npery = 0) {
$effect_rate = PHPExcel_Calculation_Functions::flattenSingleValue($effect_rate);
$npery = (int)PHPExcel_Calculation_Functions::flattenSingleValue($npery);
// Validate parameters
if ($effect_rate <= 0 || $npery < 1) {
return PHPExcel_Calculation_Functions::NaN();
}
// Calculate
return $npery * (pow($effect_rate + 1, 1 / $npery) - 1);
} // function NOMINAL()
/**
* NPER
*
* Returns the number of periods for a cash flow with constant periodic payments (annuities), and interest rate.
*
* @param float $rate Interest rate per period
* @param int $pmt Periodic payment (annuity)
* @param float $pv Present Value
* @param float $fv Future Value
* @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
* @return float
*/
public static function NPER($rate = 0, $pmt = 0, $pv = 0, $fv = 0, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$pmt = PHPExcel_Calculation_Functions::flattenSingleValue($pmt);
$pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
$fv = PHPExcel_Calculation_Functions::flattenSingleValue($fv);
$type = PHPExcel_Calculation_Functions::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return PHPExcel_Calculation_Functions::NaN();
}
// Calculate
if (!is_null($rate) && $rate != 0) {
if ($pmt == 0 && $pv == 0) {
return PHPExcel_Calculation_Functions::NaN();
}
return log(($pmt * (1 + $rate * $type) / $rate - $fv) / ($pv + $pmt * (1 + $rate * $type) / $rate)) / log(1 + $rate);
} else {
if ($pmt == 0) {
return PHPExcel_Calculation_Functions::NaN();
}
return (-$pv -$fv) / $pmt;
}
} // function NPER()
/**
* NPV
*
* Returns the Net Present Value of a cash flow series given a discount rate.
*
* @param float Discount interest rate
* @param array Cash flow series
* @return float
*/
public static function NPV() {
// Return value
$returnValue = 0;
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
// Calculate
$rate = array_shift($aArgs);
for ($i = 1; $i <= count($aArgs); ++$i) {
// Is it a numeric value?
if (is_numeric($aArgs[$i - 1])) {
$returnValue += $aArgs[$i - 1] / pow(1 + $rate, $i);
}
}
// Return
return $returnValue;
} // function NPV()
/**
* PMT
*
* Returns the constant payment (annuity) for a cash flow with a constant interest rate.
*
* @param float $rate Interest rate per period
* @param int $nper Number of periods
* @param float $pv Present Value
* @param float $fv Future Value
* @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
* @return float
*/
public static function PMT($rate = 0, $nper = 0, $pv = 0, $fv = 0, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$nper = PHPExcel_Calculation_Functions::flattenSingleValue($nper);
$pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
$fv = PHPExcel_Calculation_Functions::flattenSingleValue($fv);
$type = PHPExcel_Calculation_Functions::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return PHPExcel_Calculation_Functions::NaN();
}
// Calculate
if (!is_null($rate) && $rate != 0) {
return (-$fv - $pv * pow(1 + $rate, $nper)) / (1 + $rate * $type) / ((pow(1 + $rate, $nper) - 1) / $rate);
} else {
return (-$pv - $fv) / $nper;
}
} // function PMT()
/**
* PPMT
*
* Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.
*
* @param float $rate Interest rate per period
* @param int $per Period for which we want to find the interest
* @param int $nper Number of periods
* @param float $pv Present Value
* @param float $fv Future Value
* @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
* @return float
*/
public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$per = (int) PHPExcel_Calculation_Functions::flattenSingleValue($per);
$nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper);
$pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
$fv = PHPExcel_Calculation_Functions::flattenSingleValue($fv);
$type = (int) PHPExcel_Calculation_Functions::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($per <= 0 || $per > $nper) {
return PHPExcel_Calculation_Functions::VALUE();
}
// Calculate
$interestAndPrincipal = self::_interestAndPrincipal($rate, $per, $nper, $pv, $fv, $type);
return $interestAndPrincipal[1];
} // function PPMT()
public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$rate = (float) PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$yield = (float) PHPExcel_Calculation_Functions::flattenSingleValue($yield);
$redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption);
$frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($maturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (($settlement > $maturity) ||
(!self::_validFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) {
return PHPExcel_Calculation_Functions::NaN();
}
$dsc = self::COUPDAYSNC($settlement, $maturity, $frequency, $basis);
$e = self::COUPDAYS($settlement, $maturity, $frequency, $basis);
$n = self::COUPNUM($settlement, $maturity, $frequency, $basis);
$a = self::COUPDAYBS($settlement, $maturity, $frequency, $basis);
$baseYF = 1.0 + ($yield / $frequency);
$rfp = 100 * ($rate / $frequency);
$de = $dsc / $e;
$result = $redemption / pow($baseYF, (--$n + $de));
for($k = 0; $k <= $n; ++$k) {
$result += $rfp / (pow($baseYF, ($k + $de)));
}
$result -= $rfp * ($a / $e);
return $result;
} // function PRICE()
/**
* PRICEDISC
*
* Returns the price per $100 face value of a discounted security.
*
* @param mixed settlement The security's settlement date.
* The security settlement date is the date after the issue date when the security is traded to the buyer.
* @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param int discount The security's discount rate.
* @param int redemption The security's redemption value per $100 face value.
* @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
* @return float
*/
public static function PRICEDISC($settlement, $maturity, $discount, $redemption, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$discount = (float) PHPExcel_Calculation_Functions::flattenSingleValue($discount);
$redemption = (float) PHPExcel_Calculation_Functions::flattenSingleValue($redemption);
$basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($discount)) && (is_numeric($redemption)) && (is_numeric($basis))) {
if (($discount <= 0) || ($redemption <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
return $redemption * (1 - $discount * $daysBetweenSettlementAndMaturity);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function PRICEDISC()
/**
* PRICEMAT
*
* Returns the price per $100 face value of a security that pays interest at maturity.
*
* @param mixed settlement The security's settlement date.
* The security's settlement date is the date after the issue date when the security is traded to the buyer.
* @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param mixed issue The security's issue date.
* @param int rate The security's interest rate at date of issue.
* @param int yield The security's annual yield.
* @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
* @return float
*/
public static function PRICEMAT($settlement, $maturity, $issue, $rate, $yield, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue);
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$yield = PHPExcel_Calculation_Functions::flattenSingleValue($yield);
$basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if (is_numeric($rate) && is_numeric($yield)) {
if (($rate <= 0) || ($yield <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error
return $daysBetweenIssueAndSettlement;
}
$daysBetweenIssueAndSettlement *= $daysPerYear;
$daysBetweenIssueAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $maturity, $basis);
if (!is_numeric($daysBetweenIssueAndMaturity)) {
// return date error
return $daysBetweenIssueAndMaturity;
}
$daysBetweenIssueAndMaturity *= $daysPerYear;
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
$daysBetweenSettlementAndMaturity *= $daysPerYear;
return ((100 + (($daysBetweenIssueAndMaturity / $daysPerYear) * $rate * 100)) /
(1 + (($daysBetweenSettlementAndMaturity / $daysPerYear) * $yield)) -
(($daysBetweenIssueAndSettlement / $daysPerYear) * $rate * 100));
}
return PHPExcel_Calculation_Functions::VALUE();
} // function PRICEMAT()
/**
* PV
*
* Returns the Present Value of a cash flow with constant payments and interest rate (annuities).
*
* @param float $rate Interest rate per period
* @param int $nper Number of periods
* @param float $pmt Periodic payment (annuity)
* @param float $fv Future Value
* @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
* @return float
*/
public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$nper = PHPExcel_Calculation_Functions::flattenSingleValue($nper);
$pmt = PHPExcel_Calculation_Functions::flattenSingleValue($pmt);
$fv = PHPExcel_Calculation_Functions::flattenSingleValue($fv);
$type = PHPExcel_Calculation_Functions::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return PHPExcel_Calculation_Functions::NaN();
}
// Calculate
if (!is_null($rate) && $rate != 0) {
return (-$pmt * (1 + $rate * $type) * ((pow(1 + $rate, $nper) - 1) / $rate) - $fv) / pow(1 + $rate, $nper);
} else {
return -$fv - $pmt * $nper;
}
} // function PV()
/**
* RATE
*
**/
public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1) {
$nper = (int) PHPExcel_Calculation_Functions::flattenSingleValue($nper);
$pmt = PHPExcel_Calculation_Functions::flattenSingleValue($pmt);
$pv = PHPExcel_Calculation_Functions::flattenSingleValue($pv);
$fv = (is_null($fv)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($fv);
$type = (is_null($type)) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($type);
$guess = (is_null($guess)) ? 0.1 : PHPExcel_Calculation_Functions::flattenSingleValue($guess);
$rate = $guess;
if (abs($rate) < FINANCIAL_PRECISION) {
$y = $pv * (1 + $nper * $rate) + $pmt * (1 + $rate * $type) * $nper + $fv;
} else {
$f = exp($nper * log(1 + $rate));
$y = $pv * $f + $pmt * (1 / $rate + $type) * ($f - 1) + $fv;
}
$y0 = $pv + $pmt * $nper + $fv;
$y1 = $pv * $f + $pmt * (1 / $rate + $type) * ($f - 1) + $fv;
// find root by secant method
$i = $x0 = 0.0;
$x1 = $rate;
while ((abs($y0 - $y1) > FINANCIAL_PRECISION) && ($i < FINANCIAL_MAX_ITERATIONS)) {
$rate = ($y1 * $x0 - $y0 * $x1) / ($y1 - $y0);
$x0 = $x1;
$x1 = $rate;
if (abs($rate) < FINANCIAL_PRECISION) {
$y = $pv * (1 + $nper * $rate) + $pmt * (1 + $rate * $type) * $nper + $fv;
} else {
$f = exp($nper * log(1 + $rate));
$y = $pv * $f + $pmt * (1 / $rate + $type) * ($f - 1) + $fv;
}
$y0 = $y1;
$y1 = $y;
++$i;
}
return $rate;
} // function RATE()
/**
* RECEIVED
*
* Returns the price per $100 face value of a discounted security.
*
* @param mixed settlement The security's settlement date.
* The security settlement date is the date after the issue date when the security is traded to the buyer.
* @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param int investment The amount invested in the security.
* @param int discount The security's discount rate.
* @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
* @return float
*/
public static function RECEIVED($settlement, $maturity, $investment, $discount, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$investment = (float) PHPExcel_Calculation_Functions::flattenSingleValue($investment);
$discount = (float) PHPExcel_Calculation_Functions::flattenSingleValue($discount);
$basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if ((is_numeric($investment)) && (is_numeric($discount)) && (is_numeric($basis))) {
if (($investment <= 0) || ($discount <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
return $investment / ( 1 - ($discount * $daysBetweenSettlementAndMaturity));
}
return PHPExcel_Calculation_Functions::VALUE();
} // function RECEIVED()
/**
* SLN
*
* Returns the straight-line depreciation of an asset for one period
*
* @param cost Initial cost of the asset
* @param salvage Value at the end of the depreciation
* @param life Number of periods over which the asset is depreciated
* @return float
*/
public static function SLN($cost, $salvage, $life) {
$cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
$salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
$life = PHPExcel_Calculation_Functions::flattenSingleValue($life);
// Calculate
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life))) {
if ($life < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
return ($cost - $salvage) / $life;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function SLN()
/**
* SYD
*
* Returns the sum-of-years' digits depreciation of an asset for a specified period.
*
* @param cost Initial cost of the asset
* @param salvage Value at the end of the depreciation
* @param life Number of periods over which the asset is depreciated
* @param period Period
* @return float
*/
public static function SYD($cost, $salvage, $life, $period) {
$cost = PHPExcel_Calculation_Functions::flattenSingleValue($cost);
$salvage = PHPExcel_Calculation_Functions::flattenSingleValue($salvage);
$life = PHPExcel_Calculation_Functions::flattenSingleValue($life);
$period = PHPExcel_Calculation_Functions::flattenSingleValue($period);
// Calculate
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period))) {
if (($life < 1) || ($period > $life)) {
return PHPExcel_Calculation_Functions::NaN();
}
return (($cost - $salvage) * ($life - $period + 1) * 2) / ($life * ($life + 1));
}
return PHPExcel_Calculation_Functions::VALUE();
} // function SYD()
/**
* TBILLEQ
*
* Returns the bond-equivalent yield for a Treasury bill.
*
* @param mixed settlement The Treasury bill's settlement date.
* The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
* @param mixed maturity The Treasury bill's maturity date.
* The maturity date is the date when the Treasury bill expires.
* @param int discount The Treasury bill's discount rate.
* @return float
*/
public static function TBILLEQ($settlement, $maturity, $discount) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$discount = PHPExcel_Calculation_Functions::flattenSingleValue($discount);
// Use TBILLPRICE for validation
$testValue = self::TBILLPRICE($settlement, $maturity, $discount);
if (is_string($testValue)) {
return $testValue;
}
if (is_string($maturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
++$maturity;
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity) * 360;
} else {
$daysBetweenSettlementAndMaturity = (PHPExcel_Calculation_DateTime::_getDateValue($maturity) - PHPExcel_Calculation_DateTime::_getDateValue($settlement));
}
return (365 * $discount) / (360 - $discount * $daysBetweenSettlementAndMaturity);
} // function TBILLEQ()
/**
* TBILLPRICE
*
* Returns the yield for a Treasury bill.
*
* @param mixed settlement The Treasury bill's settlement date.
* The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
* @param mixed maturity The Treasury bill's maturity date.
* The maturity date is the date when the Treasury bill expires.
* @param int discount The Treasury bill's discount rate.
* @return float
*/
public static function TBILLPRICE($settlement, $maturity, $discount) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$discount = PHPExcel_Calculation_Functions::flattenSingleValue($discount);
if (is_string($maturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity))) {
return PHPExcel_Calculation_Functions::VALUE();
}
// Validate
if (is_numeric($discount)) {
if ($discount <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
++$maturity;
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity) * 360;
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
} else {
$daysBetweenSettlementAndMaturity = (PHPExcel_Calculation_DateTime::_getDateValue($maturity) - PHPExcel_Calculation_DateTime::_getDateValue($settlement));
}
if ($daysBetweenSettlementAndMaturity > 360) {
return PHPExcel_Calculation_Functions::NaN();
}
$price = 100 * (1 - (($discount * $daysBetweenSettlementAndMaturity) / 360));
if ($price <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
return $price;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function TBILLPRICE()
/**
* TBILLYIELD
*
* Returns the yield for a Treasury bill.
*
* @param mixed settlement The Treasury bill's settlement date.
* The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
* @param mixed maturity The Treasury bill's maturity date.
* The maturity date is the date when the Treasury bill expires.
* @param int price The Treasury bill's price per $100 face value.
* @return float
*/
public static function TBILLYIELD($settlement, $maturity, $price) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$price = PHPExcel_Calculation_Functions::flattenSingleValue($price);
// Validate
if (is_numeric($price)) {
if ($price <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
++$maturity;
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity) * 360;
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
} else {
$daysBetweenSettlementAndMaturity = (PHPExcel_Calculation_DateTime::_getDateValue($maturity) - PHPExcel_Calculation_DateTime::_getDateValue($settlement));
}
if ($daysBetweenSettlementAndMaturity > 360) {
return PHPExcel_Calculation_Functions::NaN();
}
return ((100 - $price) / $price) * (360 / $daysBetweenSettlementAndMaturity);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function TBILLYIELD()
public static function XIRR($values, $dates, $guess = 0.1) {
if ((!is_array($values)) && (!is_array($dates))) return PHPExcel_Calculation_Functions::VALUE();
$values = PHPExcel_Calculation_Functions::flattenArray($values);
$dates = PHPExcel_Calculation_Functions::flattenArray($dates);
$guess = PHPExcel_Calculation_Functions::flattenSingleValue($guess);
if (count($values) != count($dates)) return PHPExcel_Calculation_Functions::NaN();
// create an initial range, with a root somewhere between 0 and guess
$x1 = 0.0;
$x2 = $guess;
$f1 = self::XNPV($x1, $values, $dates);
$f2 = self::XNPV($x2, $values, $dates);
for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) {
if (($f1 * $f2) < 0.0) break;
if (abs($f1) < abs($f2)) {
$f1 = self::XNPV($x1 += 1.6 * ($x1 - $x2), $values, $dates);
} else {
$f2 = self::XNPV($x2 += 1.6 * ($x2 - $x1), $values, $dates);
}
}
if (($f1 * $f2) > 0.0) return PHPExcel_Calculation_Functions::VALUE();
$f = self::XNPV($x1, $values, $dates);
if ($f < 0.0) {
$rtb = $x1;
$dx = $x2 - $x1;
} else {
$rtb = $x2;
$dx = $x1 - $x2;
}
for ($i = 0; $i < FINANCIAL_MAX_ITERATIONS; ++$i) {
$dx *= 0.5;
$x_mid = $rtb + $dx;
$f_mid = self::XNPV($x_mid, $values, $dates);
if ($f_mid <= 0.0) $rtb = $x_mid;
if ((abs($f_mid) < FINANCIAL_PRECISION) || (abs($dx) < FINANCIAL_PRECISION)) return $x_mid;
}
return PHPExcel_Calculation_Functions::VALUE();
}
/**
* XNPV
*
* Returns the net present value for a schedule of cash flows that is not necessarily periodic.
* To calculate the net present value for a series of cash flows that is periodic, use the NPV function.
*
* Excel Function:
* =XNPV(rate,values,dates)
*
* @param float $rate The discount rate to apply to the cash flows.
* @param array of float $values A series of cash flows that corresponds to a schedule of payments in dates. The first payment is optional and corresponds to a cost or payment that occurs at the beginning of the investment. If the first value is a cost or payment, it must be a negative value. All succeeding payments are discounted based on a 365-day year. The series of values must contain at least one positive value and one negative value.
* @param array of mixed $dates A schedule of payment dates that corresponds to the cash flow payments. The first payment date indicates the beginning of the schedule of payments. All other dates must be later than this date, but they may occur in any order.
* @return float
*/
public static function XNPV($rate, $values, $dates) {
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
if (!is_numeric($rate)) return PHPExcel_Calculation_Functions::VALUE();
if ((!is_array($values)) || (!is_array($dates))) return PHPExcel_Calculation_Functions::VALUE();
$values = PHPExcel_Calculation_Functions::flattenArray($values);
$dates = PHPExcel_Calculation_Functions::flattenArray($dates);
$valCount = count($values);
if ($valCount != count($dates)) return PHPExcel_Calculation_Functions::NaN();
if ((min($values) > 0) || (max($values) < 0)) return PHPExcel_Calculation_Functions::VALUE();
$xnpv = 0.0;
for ($i = 0; $i < $valCount; ++$i) {
if (!is_numeric($values[$i])) return PHPExcel_Calculation_Functions::VALUE();
$xnpv += $values[$i] / pow(1 + $rate, PHPExcel_Calculation_DateTime::DATEDIF($dates[0],$dates[$i],'d') / 365);
}
return (is_finite($xnpv)) ? $xnpv : PHPExcel_Calculation_Functions::VALUE();
} // function XNPV()
/**
* YIELDDISC
*
* Returns the annual yield of a security that pays interest at maturity.
*
* @param mixed settlement The security's settlement date.
* The security's settlement date is the date after the issue date when the security is traded to the buyer.
* @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param int price The security's price per $100 face value.
* @param int redemption The security's redemption value per $100 face value.
* @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
* @return float
*/
public static function YIELDDISC($settlement, $maturity, $price, $redemption, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$price = PHPExcel_Calculation_Functions::flattenSingleValue($price);
$redemption = PHPExcel_Calculation_Functions::flattenSingleValue($redemption);
$basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if (is_numeric($price) && is_numeric($redemption)) {
if (($price <= 0) || ($redemption <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity,$basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
$daysBetweenSettlementAndMaturity *= $daysPerYear;
return (($redemption - $price) / $price) * ($daysPerYear / $daysBetweenSettlementAndMaturity);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function YIELDDISC()
/**
* YIELDMAT
*
* Returns the annual yield of a security that pays interest at maturity.
*
* @param mixed settlement The security's settlement date.
* The security's settlement date is the date after the issue date when the security is traded to the buyer.
* @param mixed maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param mixed issue The security's issue date.
* @param int rate The security's interest rate at date of issue.
* @param int price The security's price per $100 face value.
* @param int basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
* 2 Actual/360
* 3 Actual/365
* 4 European 30/360
* @return float
*/
public static function YIELDMAT($settlement, $maturity, $issue, $rate, $price, $basis=0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$issue = PHPExcel_Calculation_Functions::flattenSingleValue($issue);
$rate = PHPExcel_Calculation_Functions::flattenSingleValue($rate);
$price = PHPExcel_Calculation_Functions::flattenSingleValue($price);
$basis = (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if (is_numeric($rate) && is_numeric($price)) {
if (($rate <= 0) || ($price <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($settlement),$basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenIssueAndSettlement = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error
return $daysBetweenIssueAndSettlement;
}
$daysBetweenIssueAndSettlement *= $daysPerYear;
$daysBetweenIssueAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($issue, $maturity, $basis);
if (!is_numeric($daysBetweenIssueAndMaturity)) {
// return date error
return $daysBetweenIssueAndMaturity;
}
$daysBetweenIssueAndMaturity *= $daysPerYear;
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
$daysBetweenSettlementAndMaturity *= $daysPerYear;
return ((1 + (($daysBetweenIssueAndMaturity / $daysPerYear) * $rate) - (($price / 100) + (($daysBetweenIssueAndSettlement / $daysPerYear) * $rate))) /
(($price / 100) + (($daysBetweenIssueAndSettlement / $daysPerYear) * $rate))) *
($daysPerYear / $daysBetweenSettlementAndMaturity);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function YIELDMAT()
} // class PHPExcel_Calculation_Financial
| zysms | trunk/zysms/customer/PHPExcel/Calculation/Financial.php | PHP | asf20 | 70,665 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** MAX_VALUE */
define('MAX_VALUE', 1.2e308);
/** 2 / PI */
define('M_2DIVPI', 0.63661977236758134307553505349006);
/** MAX_ITERATIONS */
define('MAX_ITERATIONS', 256);
/** PRECISION */
define('PRECISION', 8.88E-016);
/**
* PHPExcel_Calculation_Functions
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Functions {
/** constants */
const COMPATIBILITY_EXCEL = 'Excel';
const COMPATIBILITY_GNUMERIC = 'Gnumeric';
const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc';
const RETURNDATE_PHP_NUMERIC = 'P';
const RETURNDATE_PHP_OBJECT = 'O';
const RETURNDATE_EXCEL = 'E';
/**
* Compatibility mode to use for error checking and responses
*
* @access private
* @var string
*/
protected static $compatibilityMode = self::COMPATIBILITY_EXCEL;
/**
* Data Type to use when returning date values
*
* @access private
* @var string
*/
protected static $ReturnDateType = self::RETURNDATE_EXCEL;
/**
* List of error codes
*
* @access private
* @var array
*/
protected static $_errorCodes = array( 'null' => '#NULL!',
'divisionbyzero' => '#DIV/0!',
'value' => '#VALUE!',
'reference' => '#REF!',
'name' => '#NAME?',
'num' => '#NUM!',
'na' => '#N/A',
'gettingdata' => '#GETTING_DATA'
);
/**
* Set the Compatibility Mode
*
* @access public
* @category Function Configuration
* @param string $compatibilityMode Compatibility Mode
* Permitted values are:
* PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
* @return boolean (Success or Failure)
*/
public static function setCompatibilityMode($compatibilityMode) {
if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
self::$compatibilityMode = $compatibilityMode;
return True;
}
return False;
} // function setCompatibilityMode()
/**
* Return the current Compatibility Mode
*
* @access public
* @category Function Configuration
* @return string Compatibility Mode
* Possible Return values are:
* PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
*/
public static function getCompatibilityMode() {
return self::$compatibilityMode;
} // function getCompatibilityMode()
/**
* Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
*
* @access public
* @category Function Configuration
* @param string $returnDateType Return Date Format
* Permitted values are:
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
* @return boolean Success or failure
*/
public static function setReturnDateType($returnDateType) {
if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
($returnDateType == self::RETURNDATE_EXCEL)) {
self::$ReturnDateType = $returnDateType;
return True;
}
return False;
} // function setReturnDateType()
/**
* Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
*
* @access public
* @category Function Configuration
* @return string Return Date Format
* Possible Return values are:
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
*/
public static function getReturnDateType() {
return self::$ReturnDateType;
} // function getReturnDateType()
/**
* DUMMY
*
* @access public
* @category Error Returns
* @return string #Not Yet Implemented
*/
public static function DUMMY() {
return '#Not Yet Implemented';
} // function DUMMY()
/**
* DIV0
*
* @access public
* @category Error Returns
* @return string #Not Yet Implemented
*/
public static function DIV0() {
return self::$_errorCodes['divisionbyzero'];
} // function DIV0()
/**
* NA
*
* Excel Function:
* =NA()
*
* Returns the error value #N/A
* #N/A is the error value that means "no value is available."
*
* @access public
* @category Logical Functions
* @return string #N/A!
*/
public static function NA() {
return self::$_errorCodes['na'];
} // function NA()
/**
* NaN
*
* Returns the error value #NUM!
*
* @access public
* @category Error Returns
* @return string #NUM!
*/
public static function NaN() {
return self::$_errorCodes['num'];
} // function NaN()
/**
* NAME
*
* Returns the error value #NAME?
*
* @access public
* @category Error Returns
* @return string #NAME?
*/
public static function NAME() {
return self::$_errorCodes['name'];
} // function NAME()
/**
* REF
*
* Returns the error value #REF!
*
* @access public
* @category Error Returns
* @return string #REF!
*/
public static function REF() {
return self::$_errorCodes['reference'];
} // function REF()
/**
* NULL
*
* Returns the error value #NULL!
*
* @access public
* @category Error Returns
* @return string #REF!
*/
public static function NULL() {
return self::$_errorCodes['null'];
} // function NULL()
/**
* VALUE
*
* Returns the error value #VALUE!
*
* @access public
* @category Error Returns
* @return string #VALUE!
*/
public static function VALUE() {
return self::$_errorCodes['value'];
} // function VALUE()
public static function isMatrixValue($idx) {
return ((substr_count($idx,'.') <= 1) || (preg_match('/\.[A-Z]/',$idx) > 0));
}
public static function isValue($idx) {
return (substr_count($idx,'.') == 0);
}
public static function isCellValue($idx) {
return (substr_count($idx,'.') > 1);
}
public static function _ifCondition($condition) {
$condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition);
if (!in_array($condition{0},array('>', '<', '='))) {
if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); }
return '='.$condition;
} else {
preg_match('/([<>=]+)(.*)/',$condition,$matches);
list(,$operator,$operand) = $matches;
if (!is_numeric($operand)) { $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); }
return $operator.$operand;
}
} // function _ifCondition()
/**
* ERROR_TYPE
*
* @param mixed $value Value to check
* @return boolean
*/
public static function ERROR_TYPE($value = '') {
$value = self::flattenSingleValue($value);
$i = 1;
foreach(self::$_errorCodes as $errorCode) {
if ($value == $errorCode) {
return $i;
}
++$i;
}
return self::$_errorCodes['na'];
} // function ERROR_TYPE()
/**
* IS_BLANK
*
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_BLANK($value=null) {
if (!is_null($value)) {
$value = self::flattenSingleValue($value);
}
return is_null($value);
} // function IS_BLANK()
/**
* IS_ERR
*
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_ERR($value = '') {
$value = self::flattenSingleValue($value);
return self::IS_ERROR($value) && (!self::IS_NA($value));
} // function IS_ERR()
/**
* IS_ERROR
*
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_ERROR($value = '') {
$value = self::flattenSingleValue($value);
return in_array($value, array_values(self::$_errorCodes));
} // function IS_ERROR()
/**
* IS_NA
*
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_NA($value = '') {
$value = self::flattenSingleValue($value);
return ($value === self::$_errorCodes['na']);
} // function IS_NA()
/**
* IS_EVEN
*
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_EVEN($value = 0) {
$value = self::flattenSingleValue($value);
if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
return self::$_errorCodes['value'];
}
return ($value % 2 == 0);
} // function IS_EVEN()
/**
* IS_ODD
*
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_ODD($value = null) {
$value = self::flattenSingleValue($value);
if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
return self::$_errorCodes['value'];
}
return (abs($value) % 2 == 1);
} // function IS_ODD()
/**
* IS_NUMBER
*
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_NUMBER($value = 0) {
$value = self::flattenSingleValue($value);
if (is_string($value)) {
return False;
}
return is_numeric($value);
} // function IS_NUMBER()
/**
* IS_LOGICAL
*
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_LOGICAL($value = true) {
$value = self::flattenSingleValue($value);
return is_bool($value);
} // function IS_LOGICAL()
/**
* IS_TEXT
*
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_TEXT($value = '') {
$value = self::flattenSingleValue($value);
return is_string($value);
} // function IS_TEXT()
/**
* IS_NONTEXT
*
* @param mixed $value Value to check
* @return boolean
*/
public static function IS_NONTEXT($value = '') {
return !self::IS_TEXT($value);
} // function IS_NONTEXT()
/**
* VERSION
*
* @return string Version information
*/
public static function VERSION() {
return 'PHPExcel 1.7.6, 2011-02-27';
} // function VERSION()
/**
* N
*
* Returns a value converted to a number
*
* @param value The value you want converted
* @return number N converts values listed in the following table
* If value is or refers to N returns
* A number That number
* A date The serial number of that date
* TRUE 1
* FALSE 0
* An error value The error value
* Anything else 0
*/
public static function N($value) {
while (is_array($value)) {
$value = array_shift($value);
}
switch (gettype($value)) {
case 'double' :
case 'float' :
case 'integer' :
return $value;
break;
case 'boolean' :
return (integer) $value;
break;
case 'string' :
// Errors
if ((strlen($value) > 0) && ($value{0} == '#')) {
return $value;
}
break;
}
return 0;
} // function N()
/**
* TYPE
*
* Returns a number that identifies the type of a value
*
* @param value The value you want tested
* @return number N converts values listed in the following table
* If value is or refers to N returns
* A number 1
* Text 2
* Logical Value 4
* An error value 16
* Array or Matrix 64
*/
public static function TYPE($value) {
$value = self::flattenArrayIndexed($value);
if (is_array($value) && (count($value) > 1)) {
$a = array_keys($value);
$a = array_pop($a);
// Range of cells is an error
if (self::isCellValue($a)) {
return 16;
// Test for Matrix
} elseif (self::isMatrixValue($a)) {
return 64;
}
} elseif(count($value) == 0) {
// Empty Cell
return 1;
}
$value = self::flattenSingleValue($value);
if ((is_float($value)) || (is_int($value))) {
return 1;
} elseif(is_bool($value)) {
return 4;
} elseif(is_array($value)) {
return 64;
break;
} elseif(is_string($value)) {
// Errors
if ((strlen($value) > 0) && ($value{0} == '#')) {
return 16;
}
return 2;
}
return 0;
} // function TYPE()
/**
* Convert a multi-dimensional array to a simple 1-dimensional array
*
* @param array $array Array to be flattened
* @return array Flattened array
*/
public static function flattenArray($array) {
if (!is_array($array)) {
return (array) $array;
}
$arrayValues = array();
foreach ($array as $value) {
if (is_array($value)) {
foreach ($value as $val) {
if (is_array($val)) {
foreach ($val as $v) {
$arrayValues[] = $v;
}
} else {
$arrayValues[] = $val;
}
}
} else {
$arrayValues[] = $value;
}
}
return $arrayValues;
} // function flattenArray()
/**
* Convert a multi-dimensional array to a simple 1-dimensional array, but retain an element of indexing
*
* @param array $array Array to be flattened
* @return array Flattened array
*/
public static function flattenArrayIndexed($array) {
if (!is_array($array)) {
return (array) $array;
}
$arrayValues = array();
foreach ($array as $k1 => $value) {
if (is_array($value)) {
foreach ($value as $k2 => $val) {
if (is_array($val)) {
foreach ($val as $k3 => $v) {
$arrayValues[$k1.'.'.$k2.'.'.$k3] = $v;
}
} else {
$arrayValues[$k1.'.'.$k2] = $val;
}
}
} else {
$arrayValues[$k1] = $value;
}
}
return $arrayValues;
} // function flattenArrayIndexed()
/**
* Convert an array to a single scalar value by extracting the first element
*
* @param mixed $value Array or scalar value
* @return mixed
*/
public static function flattenSingleValue($value = '') {
while (is_array($value)) {
$value = array_pop($value);
}
return $value;
} // function flattenSingleValue()
} // class PHPExcel_Calculation_Functions
//
// There are a few mathematical functions that aren't available on all versions of PHP for all platforms
// These functions aren't available in Windows implementations of PHP prior to version 5.3.0
// So we test if they do exist for this version of PHP/operating platform; and if not we create them
//
if (!function_exists('acosh')) {
function acosh($x) {
return 2 * log(sqrt(($x + 1) / 2) + sqrt(($x - 1) / 2));
} // function acosh()
}
if (!function_exists('asinh')) {
function asinh($x) {
return log($x + sqrt(1 + $x * $x));
} // function asinh()
}
if (!function_exists('atanh')) {
function atanh($x) {
return (log(1 + $x) - log(1 - $x)) / 2;
} // function atanh()
}
if (!function_exists('money_format')) {
function money_format($format, $number) {
$regex = array( '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?(?:#([0-9]+))?',
'(?:\.([0-9]+))?([in%])/'
);
$regex = implode('', $regex);
if (setlocale(LC_MONETARY, null) == '') {
setlocale(LC_MONETARY, '');
}
$locale = localeconv();
$number = floatval($number);
if (!preg_match($regex, $format, $fmatch)) {
trigger_error("No format specified or invalid format", E_USER_WARNING);
return $number;
}
$flags = array( 'fillchar' => preg_match('/\=(.)/', $fmatch[1], $match) ? $match[1] : ' ',
'nogroup' => preg_match('/\^/', $fmatch[1]) > 0,
'usesignal' => preg_match('/\+|\(/', $fmatch[1], $match) ? $match[0] : '+',
'nosimbol' => preg_match('/\!/', $fmatch[1]) > 0,
'isleft' => preg_match('/\-/', $fmatch[1]) > 0
);
$width = trim($fmatch[2]) ? (int)$fmatch[2] : 0;
$left = trim($fmatch[3]) ? (int)$fmatch[3] : 0;
$right = trim($fmatch[4]) ? (int)$fmatch[4] : $locale['int_frac_digits'];
$conversion = $fmatch[5];
$positive = true;
if ($number < 0) {
$positive = false;
$number *= -1;
}
$letter = $positive ? 'p' : 'n';
$prefix = $suffix = $cprefix = $csuffix = $signal = '';
if (!$positive) {
$signal = $locale['negative_sign'];
switch (true) {
case $locale['n_sign_posn'] == 0 || $flags['usesignal'] == '(':
$prefix = '(';
$suffix = ')';
break;
case $locale['n_sign_posn'] == 1:
$prefix = $signal;
break;
case $locale['n_sign_posn'] == 2:
$suffix = $signal;
break;
case $locale['n_sign_posn'] == 3:
$cprefix = $signal;
break;
case $locale['n_sign_posn'] == 4:
$csuffix = $signal;
break;
}
}
if (!$flags['nosimbol']) {
$currency = $cprefix;
$currency .= ($conversion == 'i' ? $locale['int_curr_symbol'] : $locale['currency_symbol']);
$currency .= $csuffix;
$currency = iconv('ISO-8859-1','UTF-8',$currency);
} else {
$currency = '';
}
$space = $locale["{$letter}_sep_by_space"] ? ' ' : '';
$number = number_format($number, $right, $locale['mon_decimal_point'], $flags['nogroup'] ? '' : $locale['mon_thousands_sep'] );
$number = explode($locale['mon_decimal_point'], $number);
$n = strlen($prefix) + strlen($currency);
if ($left > 0 && $left > $n) {
if ($flags['isleft']) {
$number[0] .= str_repeat($flags['fillchar'], $left - $n);
} else {
$number[0] = str_repeat($flags['fillchar'], $left - $n) . $number[0];
}
}
$number = implode($locale['mon_decimal_point'], $number);
if ($locale["{$letter}_cs_precedes"]) {
$number = $prefix . $currency . $space . $number . $suffix;
} else {
$number = $prefix . $number . $space . $currency . $suffix;
}
if ($width > 0) {
$number = str_pad($number, $width, $flags['fillchar'], $flags['isleft'] ? STR_PAD_RIGHT : STR_PAD_LEFT);
}
$format = str_replace($fmatch[0], $number, $format);
return $format;
} // function money_format()
}
//
// Strangely, PHP doesn't have a mb_str_replace multibyte function
// As we'll only ever use this function with UTF-8 characters, we can simply "hard-code" the character set
//
if ((!function_exists('mb_str_replace')) &&
(function_exists('mb_substr')) && (function_exists('mb_strlen')) && (function_exists('mb_strpos'))) {
function mb_str_replace($search, $replace, $subject) {
if(is_array($subject)) {
$ret = array();
foreach($subject as $key => $val) {
$ret[$key] = mb_str_replace($search, $replace, $val);
}
return $ret;
}
foreach((array) $search as $key => $s) {
if($s == '') {
continue;
}
$r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : '');
$pos = mb_strpos($subject, $s, 0, 'UTF-8');
while($pos !== false) {
$subject = mb_substr($subject, 0, $pos, 'UTF-8') . $r . mb_substr($subject, $pos + mb_strlen($s, 'UTF-8'), 65535, 'UTF-8');
$pos = mb_strpos($subject, $s, $pos + mb_strlen($r, 'UTF-8'), 'UTF-8');
}
}
return $subject;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Calculation/Functions.php | PHP | asf20 | 20,111 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Calculation_Exception
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Exception extends Exception {
/**
* Error handler callback
*
* @param mixed $code
* @param mixed $string
* @param mixed $file
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Calculation/Exception.php | PHP | asf20 | 1,648 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/*
PARTLY BASED ON:
Copyright (c) 2007 E. W. Bachtal, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
The software is provided "as is", without warranty of any kind, express or implied, including but not
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
software or the use or other dealings in the software.
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
*/
/**
* PHPExcel_Calculation_FormulaParser
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_FormulaParser {
/* Character constants */
const QUOTE_DOUBLE = '"';
const QUOTE_SINGLE = '\'';
const BRACKET_CLOSE = ']';
const BRACKET_OPEN = '[';
const BRACE_OPEN = '{';
const BRACE_CLOSE = '}';
const PAREN_OPEN = '(';
const PAREN_CLOSE = ')';
const SEMICOLON = ';';
const WHITESPACE = ' ';
const COMMA = ',';
const ERROR_START = '#';
const OPERATORS_SN = "+-";
const OPERATORS_INFIX = "+-*/^&=><";
const OPERATORS_POSTFIX = "%";
/**
* Formula
*
* @var string
*/
private $_formula;
/**
* Tokens
*
* @var PHPExcel_Calculation_FormulaToken[]
*/
private $_tokens = array();
/**
* Create a new PHPExcel_Calculation_FormulaParser
*
* @param string $pFormula Formula to parse
* @throws Exception
*/
public function __construct($pFormula = '')
{
// Check parameters
if (is_null($pFormula)) {
throw new Exception("Invalid parameter passed: formula");
}
// Initialise values
$this->_formula = trim($pFormula);
// Parse!
$this->_parseToTokens();
}
/**
* Get Formula
*
* @return string
*/
public function getFormula() {
return $this->_formula;
}
/**
* Get Token
*
* @param int $pId Token id
* @return string
* @throws Exception
*/
public function getToken($pId = 0) {
if (isset($this->_tokens[$pId])) {
return $this->_tokens[$pId];
} else {
throw new Exception("Token with id $pId does not exist.");
}
}
/**
* Get Token count
*
* @return string
*/
public function getTokenCount() {
return count($this->_tokens);
}
/**
* Get Tokens
*
* @return PHPExcel_Calculation_FormulaToken[]
*/
public function getTokens() {
return $this->_tokens;
}
/**
* Parse to tokens
*/
private function _parseToTokens() {
// No attempt is made to verify formulas; assumes formulas are derived from Excel, where
// they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions.
// Check if the formula has a valid starting =
$formulaLength = strlen($this->_formula);
if ($formulaLength < 2 || $this->_formula{0} != '=') return;
// Helper variables
$tokens1 = $tokens2 = $stack = array();
$inString = $inPath = $inRange = $inError = false;
$token = $previousToken = $nextToken = null;
$index = 1;
$value = '';
$ERRORS = array("#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A");
$COMPARATORS_MULTI = array(">=", "<=", "<>");
while ($index < $formulaLength) {
// state-dependent character evaluation (order is important)
// double-quoted strings
// embeds are doubled
// end marks token
if ($inString) {
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE;
++$index;
} else {
$inString = false;
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_TEXT);
$value = "";
}
} else {
$value .= $this->_formula{$index};
}
++$index;
continue;
}
// single-quoted strings (links)
// embeds are double
// end does not mark a token
if ($inPath) {
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE;
++$index;
} else {
$inPath = false;
}
} else {
$value .= $this->_formula{$index};
}
++$index;
continue;
}
// bracked strings (R1C1 range index or linked workbook name)
// no embeds (changed to "()" by Excel)
// end does not mark a token
if ($inRange) {
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
$inRange = false;
}
$value .= $this->_formula{$index};
++$index;
continue;
}
// error values
// end marks a token, determined from absolute list of values
if ($inError) {
$value .= $this->_formula{$index};
++$index;
if (in_array($value, $ERRORS)) {
$inError = false;
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_ERROR);
$value = "";
}
continue;
}
// scientific notation check
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->_formula{$index}) !== false) {
if (strlen($value) > 1) {
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->_formula{$index}) != 0) {
$value .= $this->_formula{$index};
++$index;
continue;
}
}
}
// independent character evaluation (order not important)
// establish state-dependent character evaluations
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
if (strlen($value > 0)) { // unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
$inString = true;
++$index;
continue;
}
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
if (strlen($value) > 0) { // unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
$inPath = true;
++$index;
continue;
}
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
$inRange = true;
$value .= PHPExcel_Calculation_FormulaParser::BRACKET_OPEN;
++$index;
continue;
}
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
if (strlen($value) > 0) { // unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
$inError = true;
$value .= PHPExcel_Calculation_FormulaParser::ERROR_START;
++$index;
continue;
}
// mark start and end of arrays and array rows
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
if (strlen($value) > 0) { // unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAY", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
$stack[] = clone $tmp;
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAYROW", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
$stack[] = clone $tmp;
++$index;
continue;
}
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tmp = array_pop($stack);
$tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp;
$tmp = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT);
$tokens1[] = $tmp;
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAYROW", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
$stack[] = clone $tmp;
++$index;
continue;
}
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tmp = array_pop($stack);
$tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp;
$tmp = array_pop($stack);
$tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp;
++$index;
continue;
}
// trim white-space
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE);
++$index;
while (($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
++$index;
}
continue;
}
// multi-character comparators
if (($index + 2) <= $formulaLength) {
if (in_array(substr($this->_formula, $index, 2), $COMPARATORS_MULTI)) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken(substr($this->_formula, $index, 2), PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
$index += 2;
continue;
}
}
// standard infix operators
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->_formula{$index}) !== false) {
if (strlen($value) > 0) {
$tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
++$index;
continue;
}
// standard postfix operators (only one)
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->_formula{$index}) !== false) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
++$index;
continue;
}
// start subexpression or function
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) {
if (strlen($value) > 0) {
$tmp = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
$stack[] = clone $tmp;
$value = "";
} else {
$tmp = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
$stack[] = clone $tmp;
}
++$index;
continue;
}
// function, subexpression, or array parameters, or operand unions
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::COMMA) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tmp = array_pop($stack);
$tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$stack[] = $tmp;
if ($tmp->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_UNION);
} else {
$tokens1[] = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT);
}
++$index;
continue;
}
// stop subexpression
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tmp = array_pop($stack);
$tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp;
++$index;
continue;
}
// token accumulation
$value .= $this->_formula{$index};
++$index;
}
// dump remaining accumulation
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
}
// move tokenList to new set, excluding unnecessary white-space tokens and converting necessary ones to intersections
$tokenCount = count($tokens1);
for ($i = 0; $i < $tokenCount; ++$i) {
$token = $tokens1[$i];
if (isset($tokens1[$i - 1])) {
$previousToken = $tokens1[$i - 1];
} else {
$previousToken = null;
}
if (isset($tokens1[$i + 1])) {
$nextToken = $tokens1[$i + 1];
} else {
$nextToken = null;
}
if (is_null($token)) {
continue;
}
if ($token->getTokenType() != PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE) {
$tokens2[] = $token;
continue;
}
if (is_null($previousToken)) {
continue;
}
if (! (
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) ) {
continue;
}
if (is_null($nextToken)) {
continue;
}
if (! (
(($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) ||
(($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) ||
($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) ) {
continue;
}
$tokens2[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_INTERSECTION);
}
// move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators
// to noop when appropriate, identifying operand and infix-operator subtypes, and pulling "@" from function names
$this->_tokens = array();
$tokenCount = count($tokens2);
for ($i = 0; $i < $tokenCount; ++$i) {
$token = $tokens2[$i];
if (isset($tokens2[$i - 1])) {
$previousToken = $tokens2[$i - 1];
} else {
$previousToken = null;
}
if (isset($tokens2[$i + 1])) {
$nextToken = $tokens2[$i + 1];
} else {
$nextToken = null;
}
if (is_null($token)) {
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") {
if ($i == 0) {
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
} else if (
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
} else {
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
}
$this->_tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") {
if ($i == 0) {
continue;
} else if (
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
} else {
continue;
}
$this->_tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
if (strpos("<>=", substr($token->getValue(), 0, 1)) !== false) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
} else if ($token->getValue() == "&") {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_CONCATENATION);
} else {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
}
$this->_tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
if (!is_numeric($token->getValue())) {
if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
} else {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_RANGE);
}
} else {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NUMBER);
}
$this->_tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) {
if (strlen($token->getValue() > 0)) {
if (substr($token->getValue(), 0, 1) == "@") {
$token->setValue(substr($token->getValue(), 1));
}
}
}
$this->_tokens[] = $token;
}
}
}
| zysms | trunk/zysms/customer/PHPExcel/Calculation/FormulaParser.php | PHP | asf20 | 22,063 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Calculation_TextData
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_TextData {
private static $_invalidChars = Null;
private static function _uniord($c) {
if (ord($c{0}) >=0 && ord($c{0}) <= 127)
return ord($c{0});
if (ord($c{0}) >= 192 && ord($c{0}) <= 223)
return (ord($c{0})-192)*64 + (ord($c{1})-128);
if (ord($c{0}) >= 224 && ord($c{0}) <= 239)
return (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128);
if (ord($c{0}) >= 240 && ord($c{0}) <= 247)
return (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128);
if (ord($c{0}) >= 248 && ord($c{0}) <= 251)
return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
if (ord($c{0}) >= 252 && ord($c{0}) <= 253)
return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
if (ord($c{0}) >= 254 && ord($c{0}) <= 255) //error
return PHPExcel_Calculation_Functions::VALUE();
return 0;
} // function _uniord()
/**
* CHARACTER
*
* @param string $character Value
* @return int
*/
public static function CHARACTER($character) {
$character = PHPExcel_Calculation_Functions::flattenSingleValue($character);
if ((!is_numeric($character)) || ($character < 0)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding('&#'.intval($character).';', 'UTF-8', 'HTML-ENTITIES');
} else {
return chr(intval($character));
}
}
/**
* TRIMNONPRINTABLE
*
* @param mixed $value Value to check
* @return string
*/
public static function TRIMNONPRINTABLE($stringValue = '') {
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
if (is_bool($stringValue)) {
$stringValue = ($stringValue) ? 'TRUE' : 'FALSE';
}
if (self::$_invalidChars == Null) {
self::$_invalidChars = range(chr(0),chr(31));
}
if (is_string($stringValue) || is_numeric($stringValue)) {
return str_replace(self::$_invalidChars,'',trim($stringValue,"\x00..\x1F"));
}
return Null;
} // function TRIMNONPRINTABLE()
/**
* TRIMSPACES
*
* @param mixed $value Value to check
* @return string
*/
public static function TRIMSPACES($stringValue = '') {
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
if (is_string($stringValue) || is_numeric($stringValue)) {
return trim(preg_replace('/ +/',' ',$stringValue));
}
return Null;
} // function TRIMSPACES()
/**
* ASCIICODE
*
* @param string $character Value
* @return int
*/
public static function ASCIICODE($characters) {
$characters = PHPExcel_Calculation_Functions::flattenSingleValue($characters);
if (is_bool($characters)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$characters = (int) $characters;
} else {
if ($characters) {
$characters = 'True';
} else {
$characters = 'False';
}
}
}
$character = $characters;
if ((function_exists('mb_strlen')) && (function_exists('mb_substr'))) {
if (mb_strlen($characters, 'UTF-8') > 1) { $character = mb_substr($characters, 0, 1, 'UTF-8'); }
return self::_uniord($character);
} else {
if (strlen($characters) > 0) { $character = substr($characters, 0, 1); }
return ord($character);
}
} // function ASCIICODE()
/**
* CONCATENATE
*
* @return string
*/
public static function CONCATENATE() {
// Return value
$returnValue = '';
// Loop through arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
if (is_bool($arg)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$arg = (int) $arg;
} else {
if ($arg) {
$arg = 'TRUE';
} else {
$arg = 'FALSE';
}
}
}
$returnValue .= $arg;
}
// Return
return $returnValue;
} // function CONCATENATE()
/**
* DOLLAR
*
* This function converts a number to text using currency format, with the decimals rounded to the specified place.
* The format used is $#,##0.00_);($#,##0.00)..
*
* @param float $value The value to format
* @param int $decimals The number of digits to display to the right of the decimal point.
* If decimals is negative, number is rounded to the left of the decimal point.
* If you omit decimals, it is assumed to be 2
* @return string
*/
public static function DOLLAR($value = 0, $decimals = 2) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$decimals = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
// Validate parameters
if (!is_numeric($value) || !is_numeric($decimals)) {
return PHPExcel_Calculation_Functions::NaN();
}
$decimals = floor($decimals);
if ($decimals > 0) {
return money_format('%.'.$decimals.'n',$value);
} else {
$round = pow(10,abs($decimals));
if ($value < 0) { $round = 0-$round; }
$value = PHPExcel_Calculation_MathTrig::MROUND($value,$round);
// The implementation of money_format used if the standard PHP function is not available can't handle decimal places of 0,
// so we display to 1 dp and chop off that character and the decimal separator using substr
return substr(money_format('%.1n',$value),0,-2);
}
} // function DOLLAR()
/**
* SEARCHSENSITIVE
*
* @param string $needle The string to look for
* @param string $haystack The string in which to look
* @param int $offset Offset within $haystack
* @return string
*/
public static function SEARCHSENSITIVE($needle,$haystack,$offset=1) {
$needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
$haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
$offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
if (!is_bool($needle)) {
if (is_bool($haystack)) {
$haystack = ($haystack) ? 'TRUE' : 'FALSE';
}
if (($offset > 0) && (strlen($haystack) > $offset)) {
if (function_exists('mb_strpos')) {
$pos = mb_strpos($haystack, $needle, --$offset,'UTF-8');
} else {
$pos = strpos($haystack, $needle, --$offset);
}
if ($pos !== false) {
return ++$pos;
}
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function SEARCHSENSITIVE()
/**
* SEARCHINSENSITIVE
*
* @param string $needle The string to look for
* @param string $haystack The string in which to look
* @param int $offset Offset within $haystack
* @return string
*/
public static function SEARCHINSENSITIVE($needle,$haystack,$offset=1) {
$needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
$haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
$offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
if (!is_bool($needle)) {
if (is_bool($haystack)) {
$haystack = ($haystack) ? 'TRUE' : 'FALSE';
}
if (($offset > 0) && (strlen($haystack) > $offset)) {
if (function_exists('mb_stripos')) {
$pos = mb_stripos($haystack, $needle, --$offset,'UTF-8');
} else {
$pos = stripos($haystack, $needle, --$offset);
}
if ($pos !== false) {
return ++$pos;
}
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function SEARCHINSENSITIVE()
/**
* FIXEDFORMAT
*
* @param mixed $value Value to check
* @return boolean
*/
public static function FIXEDFORMAT($value,$decimals=2,$no_commas=false) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$decimals = PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
$no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas);
$valueResult = round($value,$decimals);
if ($decimals < 0) { $decimals = 0; }
if (!$no_commas) {
$valueResult = number_format($valueResult,$decimals);
}
return (string) $valueResult;
} // function FIXEDFORMAT()
/**
* LEFT
*
* @param string $value Value
* @param int $chars Number of characters
* @return string
*/
public static function LEFT($value = '', $chars = 1) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
if ($chars < 0) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_bool($value)) {
$value = ($value) ? 'TRUE' : 'FALSE';
}
if (function_exists('mb_substr')) {
return mb_substr($value, 0, $chars, 'UTF-8');
} else {
return substr($value, 0, $chars);
}
} // function LEFT()
/**
* MID
*
* @param string $value Value
* @param int $start Start character
* @param int $chars Number of characters
* @return string
*/
public static function MID($value = '', $start = 1, $chars = null) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$start = PHPExcel_Calculation_Functions::flattenSingleValue($start);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
if (($start < 1) || ($chars < 0)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_bool($value)) {
$value = ($value) ? 'TRUE' : 'FALSE';
}
if (function_exists('mb_substr')) {
return mb_substr($value, --$start, $chars, 'UTF-8');
} else {
return substr($value, --$start, $chars);
}
} // function MID()
/**
* RIGHT
*
* @param string $value Value
* @param int $chars Number of characters
* @return string
*/
public static function RIGHT($value = '', $chars = 1) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
if ($chars < 0) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_bool($value)) {
$value = ($value) ? 'TRUE' : 'FALSE';
}
if ((function_exists('mb_substr')) && (function_exists('mb_strlen'))) {
return mb_substr($value, mb_strlen($value, 'UTF-8') - $chars, $chars, 'UTF-8');
} else {
return substr($value, strlen($value) - $chars);
}
} // function RIGHT()
/**
* STRINGLENGTH
*
* @param string $value Value
* @param int $chars Number of characters
* @return string
*/
public static function STRINGLENGTH($value = '') {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
if (is_bool($value)) {
$value = ($value) ? 'TRUE' : 'FALSE';
}
if (function_exists('mb_strlen')) {
return mb_strlen($value, 'UTF-8');
} else {
return strlen($value);
}
} // function STRINGLENGTH()
/**
* LOWERCASE
*
* Converts a string value to upper case.
*
* @param string $mixedCaseString
* @return string
*/
public static function LOWERCASE($mixedCaseString) {
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) {
$mixedCaseString = ($mixedCaseString) ? 'TRUE' : 'FALSE';
}
if (function_exists('mb_convert_case')) {
return mb_convert_case($mixedCaseString, MB_CASE_LOWER, 'UTF-8');
} else {
return strtoupper($mixedCaseString);
}
} // function LOWERCASE()
/**
* UPPERCASE
*
* Converts a string value to upper case.
*
* @param string $mixedCaseString
* @return string
*/
public static function UPPERCASE($mixedCaseString) {
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) {
$mixedCaseString = ($mixedCaseString) ? 'TRUE' : 'FALSE';
}
if (function_exists('mb_convert_case')) {
return mb_convert_case($mixedCaseString, MB_CASE_UPPER, 'UTF-8');
} else {
return strtoupper($mixedCaseString);
}
} // function UPPERCASE()
/**
* PROPERCASE
*
* Converts a string value to upper case.
*
* @param string $mixedCaseString
* @return string
*/
public static function PROPERCASE($mixedCaseString) {
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
if (is_bool($mixedCaseString)) {
$mixedCaseString = ($mixedCaseString) ? 'TRUE' : 'FALSE';
}
if (function_exists('mb_convert_case')) {
return mb_convert_case($mixedCaseString, MB_CASE_TITLE, 'UTF-8');
} else {
return ucwords($mixedCaseString);
}
} // function PROPERCASE()
/**
* REPLACE
*
* @param string $value Value
* @param int $start Start character
* @param int $chars Number of characters
* @return string
*/
public static function REPLACE($oldText = '', $start = 1, $chars = null, $newText) {
$oldText = PHPExcel_Calculation_Functions::flattenSingleValue($oldText);
$start = PHPExcel_Calculation_Functions::flattenSingleValue($start);
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
$newText = PHPExcel_Calculation_Functions::flattenSingleValue($newText);
$left = self::LEFT($oldText,$start-1);
$right = self::RIGHT($oldText,self::STRINGLENGTH($oldText)-($start+$chars)+1);
return $left.$newText.$right;
} // function REPLACE()
/**
* SUBSTITUTE
*
* @param string $text Value
* @param string $fromText From Value
* @param string $toText To Value
* @param integer $instance Instance Number
* @return string
*/
public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) {
$text = PHPExcel_Calculation_Functions::flattenSingleValue($text);
$fromText = PHPExcel_Calculation_Functions::flattenSingleValue($fromText);
$toText = PHPExcel_Calculation_Functions::flattenSingleValue($toText);
$instance = floor(PHPExcel_Calculation_Functions::flattenSingleValue($instance));
if ($instance == 0) {
if(function_exists('mb_str_replace')) {
return mb_str_replace($fromText,$toText,$text);
} else {
return str_replace($fromText,$toText,$text);
}
} else {
$pos = -1;
while($instance > 0) {
if (function_exists('mb_strpos')) {
$pos = mb_strpos($text, $fromText, $pos+1, 'UTF-8');
} else {
$pos = strpos($text, $fromText, $pos+1);
}
if ($pos === false) {
break;
}
--$instance;
}
if ($pos !== false) {
if (function_exists('mb_strlen')) {
return self::REPLACE($text,++$pos,mb_strlen($fromText, 'UTF-8'),$toText);
} else {
return self::REPLACE($text,++$pos,strlen($fromText),$toText);
}
}
}
return $left.$newText.$right;
} // function SUBSTITUTE()
/**
* RETURNSTRING
*
* @param mixed $value Value to check
* @return boolean
*/
public static function RETURNSTRING($testValue = '') {
$testValue = PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
if (is_string($testValue)) {
return $testValue;
}
return Null;
} // function RETURNSTRING()
/**
* TEXTFORMAT
*
* @param mixed $value Value to check
* @return boolean
*/
public static function TEXTFORMAT($value,$format) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$format = PHPExcel_Calculation_Functions::flattenSingleValue($format);
if ((is_string($value)) && (!is_numeric($value)) && PHPExcel_Shared_Date::isDateTimeFormatCode($format)) {
$value = PHPExcel_Calculation_DateTime::DATEVALUE($value);
}
return (string) PHPExcel_Style_NumberFormat::toFormattedString($value,$format);
} // function TEXTFORMAT()
} // class PHPExcel_Calculation_TextData
| zysms | trunk/zysms/customer/PHPExcel/Calculation/TextData.php | PHP | asf20 | 16,957 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Calculation_Function
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Function {
/* Function categories */
const CATEGORY_CUBE = 'Cube';
const CATEGORY_DATABASE = 'Database';
const CATEGORY_DATE_AND_TIME = 'Date and Time';
const CATEGORY_ENGINEERING = 'Engineering';
const CATEGORY_FINANCIAL = 'Financial';
const CATEGORY_INFORMATION = 'Information';
const CATEGORY_LOGICAL = 'Logical';
const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
const CATEGORY_STATISTICAL = 'Statistical';
const CATEGORY_TEXT_AND_DATA = 'Text and Data';
/**
* Category (represented by CATEGORY_*)
*
* @var string
*/
private $_category;
/**
* Excel name
*
* @var string
*/
private $_excelName;
/**
* PHPExcel name
*
* @var string
*/
private $_phpExcelName;
/**
* Create a new PHPExcel_Calculation_Function
*
* @param string $pCategory Category (represented by CATEGORY_*)
* @param string $pExcelName Excel function name
* @param string $pPHPExcelName PHPExcel function mapping
* @throws Exception
*/
public function __construct($pCategory = null, $pExcelName = null, $pPHPExcelName = null)
{
if (!is_null($pCategory) && !is_null($pExcelName) && !is_null($pPHPExcelName)) {
// Initialise values
$this->_category = $pCategory;
$this->_excelName = $pExcelName;
$this->_phpExcelName = $pPHPExcelName;
} else {
throw new Exception("Invalid parameters passed.");
}
}
/**
* Get Category (represented by CATEGORY_*)
*
* @return string
*/
public function getCategory() {
return $this->_category;
}
/**
* Set Category (represented by CATEGORY_*)
*
* @param string $value
* @throws Exception
*/
public function setCategory($value = null) {
if (!is_null($value)) {
$this->_category = $value;
} else {
throw new Exception("Invalid parameter passed.");
}
}
/**
* Get Excel name
*
* @return string
*/
public function getExcelName() {
return $this->_excelName;
}
/**
* Set Excel name
*
* @param string $value
*/
public function setExcelName($value) {
$this->_excelName = $value;
}
/**
* Get PHPExcel name
*
* @return string
*/
public function getPHPExcelName() {
return $this->_phpExcelName;
}
/**
* Set PHPExcel name
*
* @param string $value
*/
public function setPHPExcelName($value) {
$this->_phpExcelName = $value;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Calculation/Function.php | PHP | asf20 | 3,902 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Calculation_Database
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Database {
private static function __fieldExtract($database,$field) {
$field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field));
$fieldNames = array_map('strtoupper',array_shift($database));
if (is_numeric($field)) {
$keys = array_keys($fieldNames);
return $keys[$field-1];
}
$key = array_search($field,$fieldNames);
return ($key) ? $key : null;
}
private static function __filter($database,$criteria) {
$fieldNames = array_shift($database);
$criteriaNames = array_shift($criteria);
// Convert the criteria into a set of AND/OR conditions with [:placeholders]
$testConditions = $testValues = array();
$testConditionsCount = 0;
foreach($criteriaNames as $key => $criteriaName) {
$testCondition = array();
$testConditionCount = 0;
foreach($criteria as $row => $criterion) {
if ($criterion[$key] > '') {
$testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::_ifCondition($criterion[$key]);
$testConditionCount++;
}
}
if ($testConditionCount > 1) {
$testConditions[] = 'OR('.implode(',',$testCondition).')';
$testConditionsCount++;
} elseif($testConditionCount == 1) {
$testConditions[] = $testCondition[0];
$testConditionsCount++;
}
}
if ($testConditionsCount > 1) {
$testConditionSet = 'AND('.implode(',',$testConditions).')';
} elseif($testConditionsCount == 1) {
$testConditionSet = $testConditions[0];
}
// Loop through each row of the database
foreach($database as $dataRow => $dataValues) {
// Substitute actual values from the database row for our [:placeholders]
$testConditionList = $testConditionSet;
foreach($criteriaNames as $key => $criteriaName) {
$k = array_search($criteriaName,$fieldNames);
if (isset($dataValues[$k])) {
$dataValue = $dataValues[$k];
$dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::_wrapResult(strtoupper($dataValue)) : $dataValue;
$testConditionList = str_replace('[:'.$criteriaName.']',$dataValue,$testConditionList);
}
}
// evaluate the criteria against the row data
$result = PHPExcel_Calculation::getInstance()->_calculateFormulaValue('='.$testConditionList);
// If the row failed to meet the criteria, remove it from the database
if (!$result) {
unset($database[$dataRow]);
}
}
return $database;
}
/**
* DAVERAGE
*
*/
public static function DAVERAGE($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::AVERAGE($colData);
} // function DAVERAGE()
/**
* DCOUNT
*
*/
public static function DCOUNT($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::COUNT($colData);
} // function DCOUNT()
/**
* DCOUNTA
*
*/
public static function DCOUNTA($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::COUNTA($colData);
} // function DCOUNTA()
/**
* DGET
*
*/
public static function DGET($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
if (count($colData) > 1) {
return PHPExcel_Calculation_Functions::NaN();
}
return $colData[0];
} // function DGET()
/**
* DMAX
*
*/
public static function DMAX($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::MAX($colData);
} // function DMAX()
/**
* DMIN
*
*/
public static function DMIN($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::MIN($colData);
} // function DMIN()
/**
* DPRODUCT
*
*/
public static function DPRODUCT($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_MathTrig::PRODUCT($colData);
} // function DPRODUCT()
/**
* DSTDEV
*
*/
public static function DSTDEV($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::STDEV($colData);
} // function DSTDEV()
/**
* DSTDEVP
*
*/
public static function DSTDEVP($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::STDEVP($colData);
} // function DSTDEVP()
/**
* DSUM
*
*/
public static function DSUM($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_MathTrig::SUM($colData);
} // function DSUM()
/**
* DVAR
*
*/
public static function DVAR($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::VARFunc($colData);
} // function DVAR()
/**
* DVARP
*
*/
public static function DVARP($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::VARP($colData);
} // function DVARP()
} // class PHPExcel_Calculation_Database
| zysms | trunk/zysms/customer/PHPExcel/Calculation/Database.php | PHP | asf20 | 10,454 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Calculation_Logical
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Logical {
/**
* TRUE
*
* Returns the boolean TRUE.
*
* Excel Function:
* =TRUE()
*
* @access public
* @category Logical Functions
* @return boolean True
*/
public static function TRUE() {
return true;
} // function TRUE()
/**
* FALSE
*
* Returns the boolean FALSE.
*
* Excel Function:
* =FALSE()
*
* @access public
* @category Logical Functions
* @return boolean False
*/
public static function FALSE() {
return false;
} // function FALSE()
/**
* LOGICAL_AND
*
* Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
*
* Excel Function:
* =AND(logical1[,logical2[, ...]])
*
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
* or references that contain logical values.
*
* Boolean arguments are treated as True or False as appropriate
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
* @access public
* @category Logical Functions
* @param mixed $arg,... Data values
* @return boolean The logical AND of the arguments.
*/
public static function LOGICAL_AND() {
// Return value
$returnValue = True;
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$argCount = 0;
foreach ($aArgs as $arg) {
// Is it a boolean value?
if (is_bool($arg)) {
$returnValue = $returnValue && $arg;
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue = $returnValue && ($arg != 0);
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
$arg = true;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
$arg = false;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
$returnValue = $returnValue && ($arg != 0);
}
++$argCount;
}
// Return
if ($argCount == 0) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $returnValue;
} // function LOGICAL_AND()
/**
* LOGICAL_OR
*
* Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
*
* Excel Function:
* =OR(logical1[,logical2[, ...]])
*
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
* or references that contain logical values.
*
* Boolean arguments are treated as True or False as appropriate
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
* @access public
* @category Logical Functions
* @param mixed $arg,... Data values
* @return boolean The logical OR of the arguments.
*/
public static function LOGICAL_OR() {
// Return value
$returnValue = False;
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
$argCount = 0;
foreach ($aArgs as $arg) {
// Is it a boolean value?
if (is_bool($arg)) {
$returnValue = $returnValue || $arg;
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue = $returnValue || ($arg != 0);
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
$arg = true;
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
$arg = false;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
$returnValue = $returnValue || ($arg != 0);
}
++$argCount;
}
// Return
if ($argCount == 0) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $returnValue;
} // function LOGICAL_OR()
/**
* NOT
*
* Returns the boolean inverse of the argument.
*
* Excel Function:
* =NOT(logical)
*
* The argument must evaluate to a logical value such as TRUE or FALSE
*
* Boolean arguments are treated as True or False as appropriate
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string holds
* the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
*
* @access public
* @category Logical Functions
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
* @return boolean The boolean inverse of the argument.
*/
public static function NOT($logical) {
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
if (is_string($logical)) {
$logical = strtoupper($logical);
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
return false;
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
return true;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
return !$logical;
} // function NOT()
/**
* STATEMENT_IF
*
* Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
*
* Excel Function:
* =IF(condition[,returnIfTrue[,returnIfFalse]])
*
* Condition is any value or expression that can be evaluated to TRUE or FALSE.
* For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100,
* the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE.
* This argument can use any comparison calculation operator.
* ReturnIfTrue is the value that is returned if condition evaluates to TRUE.
* For example, if this argument is the text string "Within budget" and the condition argument evaluates to TRUE,
* then the IF function returns the text "Within budget"
* If condition is TRUE and ReturnIfTrue is blank, this argument returns 0 (zero). To display the word TRUE, use
* the logical value TRUE for this argument.
* ReturnIfTrue can be another formula.
* ReturnIfFalse is the value that is returned if condition evaluates to FALSE.
* For example, if this argument is the text string "Over budget" and the condition argument evaluates to FALSE,
* then the IF function returns the text "Over budget".
* If condition is FALSE and ReturnIfFalse is omitted, then the logical value FALSE is returned.
* If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned.
* ReturnIfFalse can be another formula.
*
* @access public
* @category Logical Functions
* @param mixed $condition Condition to evaluate
* @param mixed $returnIfTrue Value to return when condition is true
* @param mixed $returnIfFalse Optional value to return when condition is false
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
*/
public static function STATEMENT_IF($condition = true, $returnIfTrue = 0, $returnIfFalse = False) {
$condition = (is_null($condition)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
$returnIfFalse = (is_null($returnIfFalse)) ? False : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
return ($condition ? $returnIfTrue : $returnIfFalse);
} // function STATEMENT_IF()
/**
* IFERROR
*
* Excel Function:
* =IFERROR(testValue,errorpart)
*
* @access public
* @category Logical Functions
* @param mixed $testValue Value to check, is also the value returned when no error
* @param mixed $errorpart Value to return when testValue is an error condition
* @return mixed The value of errorpart or testValue determined by error condition
*/
public static function IFERROR($testValue = '', $errorpart = '') {
$testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
$errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart);
return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue);
} // function IFERROR()
} // class PHPExcel_Calculation_Logical
| zysms | trunk/zysms/customer/PHPExcel/Calculation/Logical.php | PHP | asf20 | 10,185 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** EULER */
define('EULER', 2.71828182845904523536);
/**
* PHPExcel_Calculation_Engineering
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Engineering {
private static $_conversionUnits = array( 'g' => array( 'Group' => 'Mass', 'Unit Name' => 'Gram', 'AllowPrefix' => True ),
'sg' => array( 'Group' => 'Mass', 'Unit Name' => 'Slug', 'AllowPrefix' => False ),
'lbm' => array( 'Group' => 'Mass', 'Unit Name' => 'Pound mass (avoirdupois)', 'AllowPrefix' => False ),
'u' => array( 'Group' => 'Mass', 'Unit Name' => 'U (atomic mass unit)', 'AllowPrefix' => True ),
'ozm' => array( 'Group' => 'Mass', 'Unit Name' => 'Ounce mass (avoirdupois)', 'AllowPrefix' => False ),
'm' => array( 'Group' => 'Distance', 'Unit Name' => 'Meter', 'AllowPrefix' => True ),
'mi' => array( 'Group' => 'Distance', 'Unit Name' => 'Statute mile', 'AllowPrefix' => False ),
'Nmi' => array( 'Group' => 'Distance', 'Unit Name' => 'Nautical mile', 'AllowPrefix' => False ),
'in' => array( 'Group' => 'Distance', 'Unit Name' => 'Inch', 'AllowPrefix' => False ),
'ft' => array( 'Group' => 'Distance', 'Unit Name' => 'Foot', 'AllowPrefix' => False ),
'yd' => array( 'Group' => 'Distance', 'Unit Name' => 'Yard', 'AllowPrefix' => False ),
'ang' => array( 'Group' => 'Distance', 'Unit Name' => 'Angstrom', 'AllowPrefix' => True ),
'Pica' => array( 'Group' => 'Distance', 'Unit Name' => 'Pica (1/72 in)', 'AllowPrefix' => False ),
'yr' => array( 'Group' => 'Time', 'Unit Name' => 'Year', 'AllowPrefix' => False ),
'day' => array( 'Group' => 'Time', 'Unit Name' => 'Day', 'AllowPrefix' => False ),
'hr' => array( 'Group' => 'Time', 'Unit Name' => 'Hour', 'AllowPrefix' => False ),
'mn' => array( 'Group' => 'Time', 'Unit Name' => 'Minute', 'AllowPrefix' => False ),
'sec' => array( 'Group' => 'Time', 'Unit Name' => 'Second', 'AllowPrefix' => True ),
'Pa' => array( 'Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True ),
'p' => array( 'Group' => 'Pressure', 'Unit Name' => 'Pascal', 'AllowPrefix' => True ),
'atm' => array( 'Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True ),
'at' => array( 'Group' => 'Pressure', 'Unit Name' => 'Atmosphere', 'AllowPrefix' => True ),
'mmHg' => array( 'Group' => 'Pressure', 'Unit Name' => 'mm of Mercury', 'AllowPrefix' => True ),
'N' => array( 'Group' => 'Force', 'Unit Name' => 'Newton', 'AllowPrefix' => True ),
'dyn' => array( 'Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True ),
'dy' => array( 'Group' => 'Force', 'Unit Name' => 'Dyne', 'AllowPrefix' => True ),
'lbf' => array( 'Group' => 'Force', 'Unit Name' => 'Pound force', 'AllowPrefix' => False ),
'J' => array( 'Group' => 'Energy', 'Unit Name' => 'Joule', 'AllowPrefix' => True ),
'e' => array( 'Group' => 'Energy', 'Unit Name' => 'Erg', 'AllowPrefix' => True ),
'c' => array( 'Group' => 'Energy', 'Unit Name' => 'Thermodynamic calorie', 'AllowPrefix' => True ),
'cal' => array( 'Group' => 'Energy', 'Unit Name' => 'IT calorie', 'AllowPrefix' => True ),
'eV' => array( 'Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True ),
'ev' => array( 'Group' => 'Energy', 'Unit Name' => 'Electron volt', 'AllowPrefix' => True ),
'HPh' => array( 'Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False ),
'hh' => array( 'Group' => 'Energy', 'Unit Name' => 'Horsepower-hour', 'AllowPrefix' => False ),
'Wh' => array( 'Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True ),
'wh' => array( 'Group' => 'Energy', 'Unit Name' => 'Watt-hour', 'AllowPrefix' => True ),
'flb' => array( 'Group' => 'Energy', 'Unit Name' => 'Foot-pound', 'AllowPrefix' => False ),
'BTU' => array( 'Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False ),
'btu' => array( 'Group' => 'Energy', 'Unit Name' => 'BTU', 'AllowPrefix' => False ),
'HP' => array( 'Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False ),
'h' => array( 'Group' => 'Power', 'Unit Name' => 'Horsepower', 'AllowPrefix' => False ),
'W' => array( 'Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True ),
'w' => array( 'Group' => 'Power', 'Unit Name' => 'Watt', 'AllowPrefix' => True ),
'T' => array( 'Group' => 'Magnetism', 'Unit Name' => 'Tesla', 'AllowPrefix' => True ),
'ga' => array( 'Group' => 'Magnetism', 'Unit Name' => 'Gauss', 'AllowPrefix' => True ),
'C' => array( 'Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False ),
'cel' => array( 'Group' => 'Temperature', 'Unit Name' => 'Celsius', 'AllowPrefix' => False ),
'F' => array( 'Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False ),
'fah' => array( 'Group' => 'Temperature', 'Unit Name' => 'Fahrenheit', 'AllowPrefix' => False ),
'K' => array( 'Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False ),
'kel' => array( 'Group' => 'Temperature', 'Unit Name' => 'Kelvin', 'AllowPrefix' => False ),
'tsp' => array( 'Group' => 'Liquid', 'Unit Name' => 'Teaspoon', 'AllowPrefix' => False ),
'tbs' => array( 'Group' => 'Liquid', 'Unit Name' => 'Tablespoon', 'AllowPrefix' => False ),
'oz' => array( 'Group' => 'Liquid', 'Unit Name' => 'Fluid Ounce', 'AllowPrefix' => False ),
'cup' => array( 'Group' => 'Liquid', 'Unit Name' => 'Cup', 'AllowPrefix' => False ),
'pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False ),
'us_pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.S. Pint', 'AllowPrefix' => False ),
'uk_pt' => array( 'Group' => 'Liquid', 'Unit Name' => 'U.K. Pint', 'AllowPrefix' => False ),
'qt' => array( 'Group' => 'Liquid', 'Unit Name' => 'Quart', 'AllowPrefix' => False ),
'gal' => array( 'Group' => 'Liquid', 'Unit Name' => 'Gallon', 'AllowPrefix' => False ),
'l' => array( 'Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True ),
'lt' => array( 'Group' => 'Liquid', 'Unit Name' => 'Litre', 'AllowPrefix' => True )
);
private static $_conversionMultipliers = array( 'Y' => array( 'multiplier' => 1E24, 'name' => 'yotta' ),
'Z' => array( 'multiplier' => 1E21, 'name' => 'zetta' ),
'E' => array( 'multiplier' => 1E18, 'name' => 'exa' ),
'P' => array( 'multiplier' => 1E15, 'name' => 'peta' ),
'T' => array( 'multiplier' => 1E12, 'name' => 'tera' ),
'G' => array( 'multiplier' => 1E9, 'name' => 'giga' ),
'M' => array( 'multiplier' => 1E6, 'name' => 'mega' ),
'k' => array( 'multiplier' => 1E3, 'name' => 'kilo' ),
'h' => array( 'multiplier' => 1E2, 'name' => 'hecto' ),
'e' => array( 'multiplier' => 1E1, 'name' => 'deka' ),
'd' => array( 'multiplier' => 1E-1, 'name' => 'deci' ),
'c' => array( 'multiplier' => 1E-2, 'name' => 'centi' ),
'm' => array( 'multiplier' => 1E-3, 'name' => 'milli' ),
'u' => array( 'multiplier' => 1E-6, 'name' => 'micro' ),
'n' => array( 'multiplier' => 1E-9, 'name' => 'nano' ),
'p' => array( 'multiplier' => 1E-12, 'name' => 'pico' ),
'f' => array( 'multiplier' => 1E-15, 'name' => 'femto' ),
'a' => array( 'multiplier' => 1E-18, 'name' => 'atto' ),
'z' => array( 'multiplier' => 1E-21, 'name' => 'zepto' ),
'y' => array( 'multiplier' => 1E-24, 'name' => 'yocto' )
);
private static $_unitConversions = array( 'Mass' => array( 'g' => array( 'g' => 1.0,
'sg' => 6.85220500053478E-05,
'lbm' => 2.20462291469134E-03,
'u' => 6.02217000000000E+23,
'ozm' => 3.52739718003627E-02
),
'sg' => array( 'g' => 1.45938424189287E+04,
'sg' => 1.0,
'lbm' => 3.21739194101647E+01,
'u' => 8.78866000000000E+27,
'ozm' => 5.14782785944229E+02
),
'lbm' => array( 'g' => 4.5359230974881148E+02,
'sg' => 3.10810749306493E-02,
'lbm' => 1.0,
'u' => 2.73161000000000E+26,
'ozm' => 1.60000023429410E+01
),
'u' => array( 'g' => 1.66053100460465E-24,
'sg' => 1.13782988532950E-28,
'lbm' => 3.66084470330684E-27,
'u' => 1.0,
'ozm' => 5.85735238300524E-26
),
'ozm' => array( 'g' => 2.83495152079732E+01,
'sg' => 1.94256689870811E-03,
'lbm' => 6.24999908478882E-02,
'u' => 1.70725600000000E+25,
'ozm' => 1.0
)
),
'Distance' => array( 'm' => array( 'm' => 1.0,
'mi' => 6.21371192237334E-04,
'Nmi' => 5.39956803455724E-04,
'in' => 3.93700787401575E+01,
'ft' => 3.28083989501312E+00,
'yd' => 1.09361329797891E+00,
'ang' => 1.00000000000000E+10,
'Pica' => 2.83464566929116E+03
),
'mi' => array( 'm' => 1.60934400000000E+03,
'mi' => 1.0,
'Nmi' => 8.68976241900648E-01,
'in' => 6.33600000000000E+04,
'ft' => 5.28000000000000E+03,
'yd' => 1.76000000000000E+03,
'ang' => 1.60934400000000E+13,
'Pica' => 4.56191999999971E+06
),
'Nmi' => array( 'm' => 1.85200000000000E+03,
'mi' => 1.15077944802354E+00,
'Nmi' => 1.0,
'in' => 7.29133858267717E+04,
'ft' => 6.07611548556430E+03,
'yd' => 2.02537182785694E+03,
'ang' => 1.85200000000000E+13,
'Pica' => 5.24976377952723E+06
),
'in' => array( 'm' => 2.54000000000000E-02,
'mi' => 1.57828282828283E-05,
'Nmi' => 1.37149028077754E-05,
'in' => 1.0,
'ft' => 8.33333333333333E-02,
'yd' => 2.77777777686643E-02,
'ang' => 2.54000000000000E+08,
'Pica' => 7.19999999999955E+01
),
'ft' => array( 'm' => 3.04800000000000E-01,
'mi' => 1.89393939393939E-04,
'Nmi' => 1.64578833693305E-04,
'in' => 1.20000000000000E+01,
'ft' => 1.0,
'yd' => 3.33333333223972E-01,
'ang' => 3.04800000000000E+09,
'Pica' => 8.63999999999946E+02
),
'yd' => array( 'm' => 9.14400000300000E-01,
'mi' => 5.68181818368230E-04,
'Nmi' => 4.93736501241901E-04,
'in' => 3.60000000118110E+01,
'ft' => 3.00000000000000E+00,
'yd' => 1.0,
'ang' => 9.14400000300000E+09,
'Pica' => 2.59200000085023E+03
),
'ang' => array( 'm' => 1.00000000000000E-10,
'mi' => 6.21371192237334E-14,
'Nmi' => 5.39956803455724E-14,
'in' => 3.93700787401575E-09,
'ft' => 3.28083989501312E-10,
'yd' => 1.09361329797891E-10,
'ang' => 1.0,
'Pica' => 2.83464566929116E-07
),
'Pica' => array( 'm' => 3.52777777777800E-04,
'mi' => 2.19205948372629E-07,
'Nmi' => 1.90484761219114E-07,
'in' => 1.38888888888898E-02,
'ft' => 1.15740740740748E-03,
'yd' => 3.85802469009251E-04,
'ang' => 3.52777777777800E+06,
'Pica' => 1.0
)
),
'Time' => array( 'yr' => array( 'yr' => 1.0,
'day' => 365.25,
'hr' => 8766.0,
'mn' => 525960.0,
'sec' => 31557600.0
),
'day' => array( 'yr' => 2.73785078713210E-03,
'day' => 1.0,
'hr' => 24.0,
'mn' => 1440.0,
'sec' => 86400.0
),
'hr' => array( 'yr' => 1.14077116130504E-04,
'day' => 4.16666666666667E-02,
'hr' => 1.0,
'mn' => 60.0,
'sec' => 3600.0
),
'mn' => array( 'yr' => 1.90128526884174E-06,
'day' => 6.94444444444444E-04,
'hr' => 1.66666666666667E-02,
'mn' => 1.0,
'sec' => 60.0
),
'sec' => array( 'yr' => 3.16880878140289E-08,
'day' => 1.15740740740741E-05,
'hr' => 2.77777777777778E-04,
'mn' => 1.66666666666667E-02,
'sec' => 1.0
)
),
'Pressure' => array( 'Pa' => array( 'Pa' => 1.0,
'p' => 1.0,
'atm' => 9.86923299998193E-06,
'at' => 9.86923299998193E-06,
'mmHg' => 7.50061707998627E-03
),
'p' => array( 'Pa' => 1.0,
'p' => 1.0,
'atm' => 9.86923299998193E-06,
'at' => 9.86923299998193E-06,
'mmHg' => 7.50061707998627E-03
),
'atm' => array( 'Pa' => 1.01324996583000E+05,
'p' => 1.01324996583000E+05,
'atm' => 1.0,
'at' => 1.0,
'mmHg' => 760.0
),
'at' => array( 'Pa' => 1.01324996583000E+05,
'p' => 1.01324996583000E+05,
'atm' => 1.0,
'at' => 1.0,
'mmHg' => 760.0
),
'mmHg' => array( 'Pa' => 1.33322363925000E+02,
'p' => 1.33322363925000E+02,
'atm' => 1.31578947368421E-03,
'at' => 1.31578947368421E-03,
'mmHg' => 1.0
)
),
'Force' => array( 'N' => array( 'N' => 1.0,
'dyn' => 1.0E+5,
'dy' => 1.0E+5,
'lbf' => 2.24808923655339E-01
),
'dyn' => array( 'N' => 1.0E-5,
'dyn' => 1.0,
'dy' => 1.0,
'lbf' => 2.24808923655339E-06
),
'dy' => array( 'N' => 1.0E-5,
'dyn' => 1.0,
'dy' => 1.0,
'lbf' => 2.24808923655339E-06
),
'lbf' => array( 'N' => 4.448222,
'dyn' => 4.448222E+5,
'dy' => 4.448222E+5,
'lbf' => 1.0
)
),
'Energy' => array( 'J' => array( 'J' => 1.0,
'e' => 9.99999519343231E+06,
'c' => 2.39006249473467E-01,
'cal' => 2.38846190642017E-01,
'eV' => 6.24145700000000E+18,
'ev' => 6.24145700000000E+18,
'HPh' => 3.72506430801000E-07,
'hh' => 3.72506430801000E-07,
'Wh' => 2.77777916238711E-04,
'wh' => 2.77777916238711E-04,
'flb' => 2.37304222192651E+01,
'BTU' => 9.47815067349015E-04,
'btu' => 9.47815067349015E-04
),
'e' => array( 'J' => 1.00000048065700E-07,
'e' => 1.0,
'c' => 2.39006364353494E-08,
'cal' => 2.38846305445111E-08,
'eV' => 6.24146000000000E+11,
'ev' => 6.24146000000000E+11,
'HPh' => 3.72506609848824E-14,
'hh' => 3.72506609848824E-14,
'Wh' => 2.77778049754611E-11,
'wh' => 2.77778049754611E-11,
'flb' => 2.37304336254586E-06,
'BTU' => 9.47815522922962E-11,
'btu' => 9.47815522922962E-11
),
'c' => array( 'J' => 4.18399101363672E+00,
'e' => 4.18398900257312E+07,
'c' => 1.0,
'cal' => 9.99330315287563E-01,
'eV' => 2.61142000000000E+19,
'ev' => 2.61142000000000E+19,
'HPh' => 1.55856355899327E-06,
'hh' => 1.55856355899327E-06,
'Wh' => 1.16222030532950E-03,
'wh' => 1.16222030532950E-03,
'flb' => 9.92878733152102E+01,
'BTU' => 3.96564972437776E-03,
'btu' => 3.96564972437776E-03
),
'cal' => array( 'J' => 4.18679484613929E+00,
'e' => 4.18679283372801E+07,
'c' => 1.00067013349059E+00,
'cal' => 1.0,
'eV' => 2.61317000000000E+19,
'ev' => 2.61317000000000E+19,
'HPh' => 1.55960800463137E-06,
'hh' => 1.55960800463137E-06,
'Wh' => 1.16299914807955E-03,
'wh' => 1.16299914807955E-03,
'flb' => 9.93544094443283E+01,
'BTU' => 3.96830723907002E-03,
'btu' => 3.96830723907002E-03
),
'eV' => array( 'J' => 1.60219000146921E-19,
'e' => 1.60218923136574E-12,
'c' => 3.82933423195043E-20,
'cal' => 3.82676978535648E-20,
'eV' => 1.0,
'ev' => 1.0,
'HPh' => 5.96826078912344E-26,
'hh' => 5.96826078912344E-26,
'Wh' => 4.45053000026614E-23,
'wh' => 4.45053000026614E-23,
'flb' => 3.80206452103492E-18,
'BTU' => 1.51857982414846E-22,
'btu' => 1.51857982414846E-22
),
'ev' => array( 'J' => 1.60219000146921E-19,
'e' => 1.60218923136574E-12,
'c' => 3.82933423195043E-20,
'cal' => 3.82676978535648E-20,
'eV' => 1.0,
'ev' => 1.0,
'HPh' => 5.96826078912344E-26,
'hh' => 5.96826078912344E-26,
'Wh' => 4.45053000026614E-23,
'wh' => 4.45053000026614E-23,
'flb' => 3.80206452103492E-18,
'BTU' => 1.51857982414846E-22,
'btu' => 1.51857982414846E-22
),
'HPh' => array( 'J' => 2.68451741316170E+06,
'e' => 2.68451612283024E+13,
'c' => 6.41616438565991E+05,
'cal' => 6.41186757845835E+05,
'eV' => 1.67553000000000E+25,
'ev' => 1.67553000000000E+25,
'HPh' => 1.0,
'hh' => 1.0,
'Wh' => 7.45699653134593E+02,
'wh' => 7.45699653134593E+02,
'flb' => 6.37047316692964E+07,
'BTU' => 2.54442605275546E+03,
'btu' => 2.54442605275546E+03
),
'hh' => array( 'J' => 2.68451741316170E+06,
'e' => 2.68451612283024E+13,
'c' => 6.41616438565991E+05,
'cal' => 6.41186757845835E+05,
'eV' => 1.67553000000000E+25,
'ev' => 1.67553000000000E+25,
'HPh' => 1.0,
'hh' => 1.0,
'Wh' => 7.45699653134593E+02,
'wh' => 7.45699653134593E+02,
'flb' => 6.37047316692964E+07,
'BTU' => 2.54442605275546E+03,
'btu' => 2.54442605275546E+03
),
'Wh' => array( 'J' => 3.59999820554720E+03,
'e' => 3.59999647518369E+10,
'c' => 8.60422069219046E+02,
'cal' => 8.59845857713046E+02,
'eV' => 2.24692340000000E+22,
'ev' => 2.24692340000000E+22,
'HPh' => 1.34102248243839E-03,
'hh' => 1.34102248243839E-03,
'Wh' => 1.0,
'wh' => 1.0,
'flb' => 8.54294774062316E+04,
'BTU' => 3.41213254164705E+00,
'btu' => 3.41213254164705E+00
),
'wh' => array( 'J' => 3.59999820554720E+03,
'e' => 3.59999647518369E+10,
'c' => 8.60422069219046E+02,
'cal' => 8.59845857713046E+02,
'eV' => 2.24692340000000E+22,
'ev' => 2.24692340000000E+22,
'HPh' => 1.34102248243839E-03,
'hh' => 1.34102248243839E-03,
'Wh' => 1.0,
'wh' => 1.0,
'flb' => 8.54294774062316E+04,
'BTU' => 3.41213254164705E+00,
'btu' => 3.41213254164705E+00
),
'flb' => array( 'J' => 4.21400003236424E-02,
'e' => 4.21399800687660E+05,
'c' => 1.00717234301644E-02,
'cal' => 1.00649785509554E-02,
'eV' => 2.63015000000000E+17,
'ev' => 2.63015000000000E+17,
'HPh' => 1.56974211145130E-08,
'hh' => 1.56974211145130E-08,
'Wh' => 1.17055614802000E-05,
'wh' => 1.17055614802000E-05,
'flb' => 1.0,
'BTU' => 3.99409272448406E-05,
'btu' => 3.99409272448406E-05
),
'BTU' => array( 'J' => 1.05505813786749E+03,
'e' => 1.05505763074665E+10,
'c' => 2.52165488508168E+02,
'cal' => 2.51996617135510E+02,
'eV' => 6.58510000000000E+21,
'ev' => 6.58510000000000E+21,
'HPh' => 3.93015941224568E-04,
'hh' => 3.93015941224568E-04,
'Wh' => 2.93071851047526E-01,
'wh' => 2.93071851047526E-01,
'flb' => 2.50369750774671E+04,
'BTU' => 1.0,
'btu' => 1.0,
),
'btu' => array( 'J' => 1.05505813786749E+03,
'e' => 1.05505763074665E+10,
'c' => 2.52165488508168E+02,
'cal' => 2.51996617135510E+02,
'eV' => 6.58510000000000E+21,
'ev' => 6.58510000000000E+21,
'HPh' => 3.93015941224568E-04,
'hh' => 3.93015941224568E-04,
'Wh' => 2.93071851047526E-01,
'wh' => 2.93071851047526E-01,
'flb' => 2.50369750774671E+04,
'BTU' => 1.0,
'btu' => 1.0,
)
),
'Power' => array( 'HP' => array( 'HP' => 1.0,
'h' => 1.0,
'W' => 7.45701000000000E+02,
'w' => 7.45701000000000E+02
),
'h' => array( 'HP' => 1.0,
'h' => 1.0,
'W' => 7.45701000000000E+02,
'w' => 7.45701000000000E+02
),
'W' => array( 'HP' => 1.34102006031908E-03,
'h' => 1.34102006031908E-03,
'W' => 1.0,
'w' => 1.0
),
'w' => array( 'HP' => 1.34102006031908E-03,
'h' => 1.34102006031908E-03,
'W' => 1.0,
'w' => 1.0
)
),
'Magnetism' => array( 'T' => array( 'T' => 1.0,
'ga' => 10000.0
),
'ga' => array( 'T' => 0.0001,
'ga' => 1.0
)
),
'Liquid' => array( 'tsp' => array( 'tsp' => 1.0,
'tbs' => 3.33333333333333E-01,
'oz' => 1.66666666666667E-01,
'cup' => 2.08333333333333E-02,
'pt' => 1.04166666666667E-02,
'us_pt' => 1.04166666666667E-02,
'uk_pt' => 8.67558516821960E-03,
'qt' => 5.20833333333333E-03,
'gal' => 1.30208333333333E-03,
'l' => 4.92999408400710E-03,
'lt' => 4.92999408400710E-03
),
'tbs' => array( 'tsp' => 3.00000000000000E+00,
'tbs' => 1.0,
'oz' => 5.00000000000000E-01,
'cup' => 6.25000000000000E-02,
'pt' => 3.12500000000000E-02,
'us_pt' => 3.12500000000000E-02,
'uk_pt' => 2.60267555046588E-02,
'qt' => 1.56250000000000E-02,
'gal' => 3.90625000000000E-03,
'l' => 1.47899822520213E-02,
'lt' => 1.47899822520213E-02
),
'oz' => array( 'tsp' => 6.00000000000000E+00,
'tbs' => 2.00000000000000E+00,
'oz' => 1.0,
'cup' => 1.25000000000000E-01,
'pt' => 6.25000000000000E-02,
'us_pt' => 6.25000000000000E-02,
'uk_pt' => 5.20535110093176E-02,
'qt' => 3.12500000000000E-02,
'gal' => 7.81250000000000E-03,
'l' => 2.95799645040426E-02,
'lt' => 2.95799645040426E-02
),
'cup' => array( 'tsp' => 4.80000000000000E+01,
'tbs' => 1.60000000000000E+01,
'oz' => 8.00000000000000E+00,
'cup' => 1.0,
'pt' => 5.00000000000000E-01,
'us_pt' => 5.00000000000000E-01,
'uk_pt' => 4.16428088074541E-01,
'qt' => 2.50000000000000E-01,
'gal' => 6.25000000000000E-02,
'l' => 2.36639716032341E-01,
'lt' => 2.36639716032341E-01
),
'pt' => array( 'tsp' => 9.60000000000000E+01,
'tbs' => 3.20000000000000E+01,
'oz' => 1.60000000000000E+01,
'cup' => 2.00000000000000E+00,
'pt' => 1.0,
'us_pt' => 1.0,
'uk_pt' => 8.32856176149081E-01,
'qt' => 5.00000000000000E-01,
'gal' => 1.25000000000000E-01,
'l' => 4.73279432064682E-01,
'lt' => 4.73279432064682E-01
),
'us_pt' => array( 'tsp' => 9.60000000000000E+01,
'tbs' => 3.20000000000000E+01,
'oz' => 1.60000000000000E+01,
'cup' => 2.00000000000000E+00,
'pt' => 1.0,
'us_pt' => 1.0,
'uk_pt' => 8.32856176149081E-01,
'qt' => 5.00000000000000E-01,
'gal' => 1.25000000000000E-01,
'l' => 4.73279432064682E-01,
'lt' => 4.73279432064682E-01
),
'uk_pt' => array( 'tsp' => 1.15266000000000E+02,
'tbs' => 3.84220000000000E+01,
'oz' => 1.92110000000000E+01,
'cup' => 2.40137500000000E+00,
'pt' => 1.20068750000000E+00,
'us_pt' => 1.20068750000000E+00,
'uk_pt' => 1.0,
'qt' => 6.00343750000000E-01,
'gal' => 1.50085937500000E-01,
'l' => 5.68260698087162E-01,
'lt' => 5.68260698087162E-01
),
'qt' => array( 'tsp' => 1.92000000000000E+02,
'tbs' => 6.40000000000000E+01,
'oz' => 3.20000000000000E+01,
'cup' => 4.00000000000000E+00,
'pt' => 2.00000000000000E+00,
'us_pt' => 2.00000000000000E+00,
'uk_pt' => 1.66571235229816E+00,
'qt' => 1.0,
'gal' => 2.50000000000000E-01,
'l' => 9.46558864129363E-01,
'lt' => 9.46558864129363E-01
),
'gal' => array( 'tsp' => 7.68000000000000E+02,
'tbs' => 2.56000000000000E+02,
'oz' => 1.28000000000000E+02,
'cup' => 1.60000000000000E+01,
'pt' => 8.00000000000000E+00,
'us_pt' => 8.00000000000000E+00,
'uk_pt' => 6.66284940919265E+00,
'qt' => 4.00000000000000E+00,
'gal' => 1.0,
'l' => 3.78623545651745E+00,
'lt' => 3.78623545651745E+00
),
'l' => array( 'tsp' => 2.02840000000000E+02,
'tbs' => 6.76133333333333E+01,
'oz' => 3.38066666666667E+01,
'cup' => 4.22583333333333E+00,
'pt' => 2.11291666666667E+00,
'us_pt' => 2.11291666666667E+00,
'uk_pt' => 1.75975569552166E+00,
'qt' => 1.05645833333333E+00,
'gal' => 2.64114583333333E-01,
'l' => 1.0,
'lt' => 1.0
),
'lt' => array( 'tsp' => 2.02840000000000E+02,
'tbs' => 6.76133333333333E+01,
'oz' => 3.38066666666667E+01,
'cup' => 4.22583333333333E+00,
'pt' => 2.11291666666667E+00,
'us_pt' => 2.11291666666667E+00,
'uk_pt' => 1.75975569552166E+00,
'qt' => 1.05645833333333E+00,
'gal' => 2.64114583333333E-01,
'l' => 1.0,
'lt' => 1.0
)
)
);
public static function _parseComplex($complexNumber) {
$workString = (string) $complexNumber;
$realNumber = $imaginary = 0;
// Extract the suffix, if there is one
$suffix = substr($workString,-1);
if (!is_numeric($suffix)) {
$workString = substr($workString,0,-1);
} else {
$suffix = '';
}
// Split the input into its Real and Imaginary components
$leadingSign = 0;
if (strlen($workString) > 0) {
$leadingSign = (($workString{0} == '+') || ($workString{0} == '-')) ? 1 : 0;
}
$power = '';
$realNumber = strtok($workString, '+-');
if (strtoupper(substr($realNumber,-1)) == 'E') {
$power = strtok('+-');
++$leadingSign;
}
$realNumber = substr($workString,0,strlen($realNumber)+strlen($power)+$leadingSign);
if ($suffix != '') {
$imaginary = substr($workString,strlen($realNumber));
if (($imaginary == '') && (($realNumber == '') || ($realNumber == '+') || ($realNumber == '-'))) {
$imaginary = $realNumber.'1';
$realNumber = '0';
} else if ($imaginary == '') {
$imaginary = $realNumber;
$realNumber = '0';
} elseif (($imaginary == '+') || ($imaginary == '-')) {
$imaginary .= '1';
}
}
return array( 'real' => $realNumber,
'imaginary' => $imaginary,
'suffix' => $suffix
);
} // function _parseComplex()
private static function _cleanComplex($complexNumber) {
if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1);
if ($complexNumber{0} == '0') $complexNumber = substr($complexNumber,1);
if ($complexNumber{0} == '.') $complexNumber = '0'.$complexNumber;
if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1);
return $complexNumber;
}
private static function _nbrConversionFormat($xVal,$places) {
if (!is_null($places)) {
if (strlen($xVal) <= $places) {
return substr(str_pad($xVal,$places,'0',STR_PAD_LEFT),-10);
} else {
return PHPExcel_Calculation_Functions::NaN();
}
}
return substr($xVal,-10);
} // function _nbrConversionFormat()
/**
* BESSELI
*
* Returns the modified Bessel function, which is equivalent to the Bessel function evaluated for purely imaginary arguments
*
* @param float $x
* @param float $n
* @return int
*/
public static function BESSELI($x, $n) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
$n = (is_null($n)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($n);
if ((is_numeric($x)) && (is_numeric($n))) {
$n = floor($n);
if ($n < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
$f_2_PI = 2 * M_PI;
if (abs($x) <= 30) {
$fTerm = pow($x / 2, $n) / PHPExcel_Calculation_MathTrig::FACT($n);
$nK = 1;
$fResult = $fTerm;
$fSqrX = ($x * $x) / 4;
do {
$fTerm *= $fSqrX;
$fTerm /= ($nK * ($nK + $n));
$fResult += $fTerm;
} while ((abs($fTerm) > 1e-10) && (++$nK < 100));
} else {
$fXAbs = abs($x);
$fResult = exp($fXAbs) / sqrt($f_2_PI * $fXAbs);
if (($n && 1) && ($x < 0)) {
$fResult = -$fResult;
}
}
return $fResult;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BESSELI()
/**
* BESSELJ
*
* Returns the Bessel function
*
* @param float $x
* @param float $n
* @return int
*/
public static function BESSELJ($x, $n) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
$n = (is_null($n)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($n);
if ((is_numeric($x)) && (is_numeric($n))) {
$n = floor($n);
if ($n < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
$f_PI_DIV_2 = M_PI / 2;
$f_PI_DIV_4 = M_PI / 4;
$fResult = 0;
if (abs($x) <= 30) {
$fTerm = pow($x / 2, $n) / PHPExcel_Calculation_MathTrig::FACT($n);
$nK = 1;
$fResult = $fTerm;
$fSqrX = ($x * $x) / -4;
do {
$fTerm *= $fSqrX;
$fTerm /= ($nK * ($nK + $n));
$fResult += $fTerm;
} while ((abs($fTerm) > 1e-10) && (++$nK < 100));
} else {
$fXAbs = abs($x);
$fResult = sqrt(M_2DIVPI / $fXAbs) * cos($fXAbs - $n * $f_PI_DIV_2 - $f_PI_DIV_4);
if (($n && 1) && ($x < 0)) {
$fResult = -$fResult;
}
}
return $fResult;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BESSELJ()
private static function _Besselk0($fNum) {
if ($fNum <= 2) {
$fNum2 = $fNum * 0.5;
$y = ($fNum2 * $fNum2);
$fRet = -log($fNum2) * self::BESSELI($fNum, 0) +
(-0.57721566 + $y * (0.42278420 + $y * (0.23069756 + $y * (0.3488590e-1 + $y * (0.262698e-2 + $y *
(0.10750e-3 + $y * 0.74e-5))))));
} else {
$y = 2 / $fNum;
$fRet = exp(-$fNum) / sqrt($fNum) *
(1.25331414 + $y * (-0.7832358e-1 + $y * (0.2189568e-1 + $y * (-0.1062446e-1 + $y *
(0.587872e-2 + $y * (-0.251540e-2 + $y * 0.53208e-3))))));
}
return $fRet;
} // function _Besselk0()
private static function _Besselk1($fNum) {
if ($fNum <= 2) {
$fNum2 = $fNum * 0.5;
$y = ($fNum2 * $fNum2);
$fRet = log($fNum2) * self::BESSELI($fNum, 1) +
(1 + $y * (0.15443144 + $y * (-0.67278579 + $y * (-0.18156897 + $y * (-0.1919402e-1 + $y *
(-0.110404e-2 + $y * (-0.4686e-4))))))) / $fNum;
} else {
$y = 2 / $fNum;
$fRet = exp(-$fNum) / sqrt($fNum) *
(1.25331414 + $y * (0.23498619 + $y * (-0.3655620e-1 + $y * (0.1504268e-1 + $y * (-0.780353e-2 + $y *
(0.325614e-2 + $y * (-0.68245e-3)))))));
}
return $fRet;
} // function _Besselk1()
/**
* BESSELK
*
* Returns the modified Bessel function, which is equivalent to the Bessel functions evaluated for purely imaginary arguments.
*
* @param float $x
* @param float $ord
* @return float
*/
public static function BESSELK($x, $ord) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
$ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) {
if (($ord < 0) || ($x == 0.0)) {
return PHPExcel_Calculation_Functions::NaN();
}
switch(floor($ord)) {
case 0 : return self::_Besselk0($x);
break;
case 1 : return self::_Besselk1($x);
break;
default : $fTox = 2 / $x;
$fBkm = self::_Besselk0($x);
$fBk = self::_Besselk1($x);
for ($n = 1; $n < $ord; ++$n) {
$fBkp = $fBkm + $n * $fTox * $fBk;
$fBkm = $fBk;
$fBk = $fBkp;
}
}
return $fBk;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BESSELK()
private static function _Bessely0($fNum) {
if ($fNum < 8.0) {
$y = ($fNum * $fNum);
$f1 = -2957821389.0 + $y * (7062834065.0 + $y * (-512359803.6 + $y * (10879881.29 + $y * (-86327.92757 + $y * 228.4622733))));
$f2 = 40076544269.0 + $y * (745249964.8 + $y * (7189466.438 + $y * (47447.26470 + $y * (226.1030244 + $y))));
$fRet = $f1 / $f2 + M_2DIVPI * self::BESSELJ($fNum, 0) * log($fNum);
} else {
$z = 8.0 / $fNum;
$y = ($z * $z);
$xx = $fNum - 0.785398164;
$f1 = 1 + $y * (-0.1098628627e-2 + $y * (0.2734510407e-4 + $y * (-0.2073370639e-5 + $y * 0.2093887211e-6)));
$f2 = -0.1562499995e-1 + $y * (0.1430488765e-3 + $y * (-0.6911147651e-5 + $y * (0.7621095161e-6 + $y * (-0.934945152e-7))));
$fRet = sqrt(M_2DIVPI / $fNum) * (sin($xx) * $f1 + $z * cos($xx) * $f2);
}
return $fRet;
} // function _Bessely0()
private static function _Bessely1($fNum) {
if ($fNum < 8.0) {
$y = ($fNum * $fNum);
$f1 = $fNum * (-0.4900604943e13 + $y * (0.1275274390e13 + $y * (-0.5153438139e11 + $y * (0.7349264551e9 + $y *
(-0.4237922726e7 + $y * 0.8511937935e4)))));
$f2 = 0.2499580570e14 + $y * (0.4244419664e12 + $y * (0.3733650367e10 + $y * (0.2245904002e8 + $y *
(0.1020426050e6 + $y * (0.3549632885e3 + $y)))));
$fRet = $f1 / $f2 + M_2DIVPI * ( self::BESSELJ($fNum, 1) * log($fNum) - 1 / $fNum);
} else {
$z = 8.0 / $fNum;
$y = ($z * $z);
$xx = $fNum - 2.356194491;
$f1 = 1 + $y * (0.183105e-2 + $y * (-0.3516396496e-4 + $y * (0.2457520174e-5 + $y * (-0.240337019e6))));
$f2 = 0.04687499995 + $y * (-0.2002690873e-3 + $y * (0.8449199096e-5 + $y * (-0.88228987e-6 + $y * 0.105787412e-6)));
$fRet = sqrt(M_2DIVPI / $fNum) * (sin($xx) * $f1 + $z * cos($xx) * $f2);
#i12430# ...but this seems to work much better.
// $fRet = sqrt(M_2DIVPI / $fNum) * sin($fNum - 2.356194491);
}
return $fRet;
} // function _Bessely1()
/**
* BESSELY
*
* Returns the Bessel function, which is also called the Weber function or the Neumann function.
*
* @param float $x
* @param float $n
* @return int
*/
public static function BESSELY($x, $ord) {
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
$ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) {
if (($ord < 0) || ($x == 0.0)) {
return PHPExcel_Calculation_Functions::NaN();
}
switch(floor($ord)) {
case 0 : return self::_Bessely0($x);
break;
case 1 : return self::_Bessely1($x);
break;
default: $fTox = 2 / $x;
$fBym = self::_Bessely0($x);
$fBy = self::_Bessely1($x);
for ($n = 1; $n < $ord; ++$n) {
$fByp = $n * $fTox * $fBy - $fBym;
$fBym = $fBy;
$fBy = $fByp;
}
}
return $fBy;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function BESSELY()
/**
* BINTODEC
*
* Return a binary value as Decimal.
*
* @param string $x
* @return string
*/
public static function BINTODEC($x) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$x = floor($x);
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (strlen($x) > 10) {
return PHPExcel_Calculation_Functions::NaN();
} elseif (strlen($x) == 10) {
// Two's Complement
$x = substr($x,-9);
return '-'.(512-bindec($x));
}
return bindec($x);
} // function BINTODEC()
/**
* BINTOHEX
*
* Return a binary value as Hex.
*
* @param string $x
* @return string
*/
public static function BINTOHEX($x, $places=null) {
$x = floor(PHPExcel_Calculation_Functions::flattenSingleValue($x));
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$x = floor($x);
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (strlen($x) > 10) {
return PHPExcel_Calculation_Functions::NaN();
} elseif (strlen($x) == 10) {
// Two's Complement
return str_repeat('F',8).substr(strtoupper(dechex(bindec(substr($x,-9)))),-2);
}
$hexVal = (string) strtoupper(dechex(bindec($x)));
return self::_nbrConversionFormat($hexVal,$places);
} // function BINTOHEX()
/**
* BINTOOCT
*
* Return a binary value as Octal.
*
* @param string $x
* @return string
*/
public static function BINTOOCT($x, $places=null) {
$x = floor(PHPExcel_Calculation_Functions::flattenSingleValue($x));
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$x = floor($x);
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (strlen($x) > 10) {
return PHPExcel_Calculation_Functions::NaN();
} elseif (strlen($x) == 10) {
// Two's Complement
return str_repeat('7',7).substr(strtoupper(decoct(bindec(substr($x,-9)))),-3);
}
$octVal = (string) decoct(bindec($x));
return self::_nbrConversionFormat($octVal,$places);
} // function BINTOOCT()
/**
* DECTOBIN
*
* Return an octal value as binary.
*
* @param string $x
* @return string
*/
public static function DECTOBIN($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = (string) floor($x);
$r = decbin($x);
if (strlen($r) == 32) {
// Two's Complement
$r = substr($r,-10);
} elseif (strlen($r) > 11) {
return PHPExcel_Calculation_Functions::NaN();
}
return self::_nbrConversionFormat($r,$places);
} // function DECTOBIN()
/**
* DECTOHEX
*
* Return an octal value as binary.
*
* @param string $x
* @return string
*/
public static function DECTOHEX($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = (string) floor($x);
$r = strtoupper(dechex($x));
if (strlen($r) == 8) {
// Two's Complement
$r = 'FF'.$r;
}
return self::_nbrConversionFormat($r,$places);
} // function DECTOHEX()
/**
* DECTOOCT
*
* Return an octal value as binary.
*
* @param string $x
* @return string
*/
public static function DECTOOCT($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = (string) floor($x);
$r = decoct($x);
if (strlen($r) == 11) {
// Two's Complement
$r = substr($r,-10);
}
return self::_nbrConversionFormat($r,$places);
} // function DECTOOCT()
/**
* HEXTOBIN
*
* Return a hex value as binary.
*
* @param string $x
* @return string
*/
public static function HEXTOBIN($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
return PHPExcel_Calculation_Functions::NaN();
}
$binVal = decbin(hexdec($x));
return substr(self::_nbrConversionFormat($binVal,$places),-10);
} // function HEXTOBIN()
/**
* HEXTODEC
*
* Return a hex value as octal.
*
* @param string $x
* @return string
*/
public static function HEXTODEC($x) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
return PHPExcel_Calculation_Functions::NaN();
}
return hexdec($x);
} // function HEXTODEC()
/**
* HEXTOOCT
*
* Return a hex value as octal.
*
* @param string $x
* @return string
*/
public static function HEXTOOCT($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
return PHPExcel_Calculation_Functions::NaN();
}
$octVal = decoct(hexdec($x));
return self::_nbrConversionFormat($octVal,$places);
} // function HEXTOOCT()
/**
* OCTTOBIN
*
* Return an octal value as binary.
*
* @param string $x
* @return string
*/
public static function OCTTOBIN($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = (string) $x;
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
return PHPExcel_Calculation_Functions::NaN();
}
$r = decbin(octdec($x));
return self::_nbrConversionFormat($r,$places);
} // function OCTTOBIN()
/**
* OCTTODEC
*
* Return an octal value as binary.
*
* @param string $x
* @return string
*/
public static function OCTTODEC($x) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = (string) $x;
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
return PHPExcel_Calculation_Functions::NaN();
}
return octdec($x);
} // function OCTTODEC()
/**
* OCTTOHEX
*
* Return an octal value as hex.
*
* @param string $x
* @return string
*/
public static function OCTTOHEX($x, $places=null) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
if (is_bool($x)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$x = (string) $x;
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
return PHPExcel_Calculation_Functions::NaN();
}
$hexVal = strtoupper(dechex(octdec($x)));
return self::_nbrConversionFormat($hexVal,$places);
} // function OCTTOHEX()
/**
* COMPLEX
*
* returns a complex number of the form x + yi or x + yj.
*
* @param float $realNumber
* @param float $imaginary
* @param string $suffix
* @return string
*/
public static function COMPLEX($realNumber=0.0, $imaginary=0.0, $suffix='i') {
$realNumber = (is_null($realNumber)) ? 0.0 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($realNumber);
$imaginary = (is_null($imaginary)) ? 0.0 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($imaginary);
$suffix = (is_null($suffix)) ? 'i' : PHPExcel_Calculation_Functions::flattenSingleValue($suffix);
if (((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
(($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))) {
if ($suffix == '') $suffix = 'i';
if ($realNumber == 0.0) {
if ($imaginary == 0.0) {
return (string) '0';
} elseif ($imaginary == 1.0) {
return (string) $suffix;
} elseif ($imaginary == -1.0) {
return (string) '-'.$suffix;
}
return (string) $imaginary.$suffix;
} elseif ($imaginary == 0.0) {
return (string) $realNumber;
} elseif ($imaginary == 1.0) {
return (string) $realNumber.'+'.$suffix;
} elseif ($imaginary == -1.0) {
return (string) $realNumber.'-'.$suffix;
}
if ($imaginary > 0) { $imaginary = (string) '+'.$imaginary; }
return (string) $realNumber.$imaginary.$suffix;
}
return PHPExcel_Calculation_Functions::VALUE();
} // function COMPLEX()
/**
* IMAGINARY
*
* Returns the imaginary coefficient of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return real
*/
public static function IMAGINARY($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
return $parsedComplex['imaginary'];
} // function IMAGINARY()
/**
* IMREAL
*
* Returns the real coefficient of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return real
*/
public static function IMREAL($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
return $parsedComplex['real'];
} // function IMREAL()
/**
* IMABS
*
* Returns the absolute value (modulus) of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return real
*/
public static function IMABS($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
return sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']));
} // function IMABS()
/**
* IMARGUMENT
*
* Returns the argument theta of a complex number, i.e. the angle in radians from the real axis to the representation of the number in polar coordinates.
*
* @param string $complexNumber
* @return string
*/
public static function IMARGUMENT($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if ($parsedComplex['real'] == 0.0) {
if ($parsedComplex['imaginary'] == 0.0) {
return 0.0;
} elseif($parsedComplex['imaginary'] < 0.0) {
return M_PI / -2;
} else {
return M_PI / 2;
}
} elseif ($parsedComplex['real'] > 0.0) {
return atan($parsedComplex['imaginary'] / $parsedComplex['real']);
} elseif ($parsedComplex['imaginary'] < 0.0) {
return 0 - (M_PI - atan(abs($parsedComplex['imaginary']) / abs($parsedComplex['real'])));
} else {
return M_PI - atan($parsedComplex['imaginary'] / abs($parsedComplex['real']));
}
} // function IMARGUMENT()
/**
* IMCONJUGATE
*
* Returns the complex conjugate of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return string
*/
public static function IMCONJUGATE($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if ($parsedComplex['imaginary'] == 0.0) {
return $parsedComplex['real'];
} else {
return self::_cleanComplex(self::COMPLEX($parsedComplex['real'], 0 - $parsedComplex['imaginary'], $parsedComplex['suffix']));
}
} // function IMCONJUGATE()
/**
* IMCOS
*
* Returns the cosine of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return string
*/
public static function IMCOS($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if ($parsedComplex['imaginary'] == 0.0) {
return cos($parsedComplex['real']);
} else {
return self::IMCONJUGATE(self::COMPLEX(cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']),sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix']));
}
} // function IMCOS()
/**
* IMSIN
*
* Returns the sine of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return string
*/
public static function IMSIN($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if ($parsedComplex['imaginary'] == 0.0) {
return sin($parsedComplex['real']);
} else {
return self::COMPLEX(sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']),cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix']);
}
} // function IMSIN()
/**
* IMSQRT
*
* Returns the square root of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return string
*/
public static function IMSQRT($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
$theta = self::IMARGUMENT($complexNumber);
$d1 = cos($theta / 2);
$d2 = sin($theta / 2);
$r = sqrt(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])));
if ($parsedComplex['suffix'] == '') {
return self::COMPLEX($d1 * $r,$d2 * $r);
} else {
return self::COMPLEX($d1 * $r,$d2 * $r,$parsedComplex['suffix']);
}
} // function IMSQRT()
/**
* IMLN
*
* Returns the natural logarithm of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return string
*/
public static function IMLN($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return PHPExcel_Calculation_Functions::NaN();
}
$logR = log(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])));
$t = self::IMARGUMENT($complexNumber);
if ($parsedComplex['suffix'] == '') {
return self::COMPLEX($logR,$t);
} else {
return self::COMPLEX($logR,$t,$parsedComplex['suffix']);
}
} // function IMLN()
/**
* IMLOG10
*
* Returns the common logarithm (base 10) of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return string
*/
public static function IMLOG10($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return PHPExcel_Calculation_Functions::NaN();
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return log10($parsedComplex['real']);
}
return self::IMPRODUCT(log10(EULER),self::IMLN($complexNumber));
} // function IMLOG10()
/**
* IMLOG2
*
* Returns the common logarithm (base 10) of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return string
*/
public static function IMLOG2($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return PHPExcel_Calculation_Functions::NaN();
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return log($parsedComplex['real'],2);
}
return self::IMPRODUCT(log(EULER,2),self::IMLN($complexNumber));
} // function IMLOG2()
/**
* IMEXP
*
* Returns the exponential of a complex number in x + yi or x + yj text format.
*
* @param string $complexNumber
* @return string
*/
public static function IMEXP($complexNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return '1';
}
$e = exp($parsedComplex['real']);
$eX = $e * cos($parsedComplex['imaginary']);
$eY = $e * sin($parsedComplex['imaginary']);
if ($parsedComplex['suffix'] == '') {
return self::COMPLEX($eX,$eY);
} else {
return self::COMPLEX($eX,$eY,$parsedComplex['suffix']);
}
} // function IMEXP()
/**
* IMPOWER
*
* Returns a complex number in x + yi or x + yj text format raised to a power.
*
* @param string $complexNumber
* @return string
*/
public static function IMPOWER($complexNumber,$realNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$realNumber = PHPExcel_Calculation_Functions::flattenSingleValue($realNumber);
if (!is_numeric($realNumber)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
$r = sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']));
$rPower = pow($r,$realNumber);
$theta = self::IMARGUMENT($complexNumber) * $realNumber;
if ($theta == 0) {
return 1;
} elseif ($parsedComplex['imaginary'] == 0.0) {
return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex['suffix']);
} else {
return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex['suffix']);
}
} // function IMPOWER()
/**
* IMDIV
*
* Returns the quotient of two complex numbers in x + yi or x + yj text format.
*
* @param string $complexDividend
* @param string $complexDivisor
* @return real
*/
public static function IMDIV($complexDividend,$complexDivisor) {
$complexDividend = PHPExcel_Calculation_Functions::flattenSingleValue($complexDividend);
$complexDivisor = PHPExcel_Calculation_Functions::flattenSingleValue($complexDivisor);
$parsedComplexDividend = self::_parseComplex($complexDividend);
if (!is_array($parsedComplexDividend)) {
return $parsedComplexDividend;
}
$parsedComplexDivisor = self::_parseComplex($complexDivisor);
if (!is_array($parsedComplexDivisor)) {
return $parsedComplexDividend;
}
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') &&
($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) {
return PHPExcel_Calculation_Functions::NaN();
}
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] == '')) {
$parsedComplexDivisor['suffix'] = $parsedComplexDividend['suffix'];
}
$d1 = ($parsedComplexDividend['real'] * $parsedComplexDivisor['real']) + ($parsedComplexDividend['imaginary'] * $parsedComplexDivisor['imaginary']);
$d2 = ($parsedComplexDividend['imaginary'] * $parsedComplexDivisor['real']) - ($parsedComplexDividend['real'] * $parsedComplexDivisor['imaginary']);
$d3 = ($parsedComplexDivisor['real'] * $parsedComplexDivisor['real']) + ($parsedComplexDivisor['imaginary'] * $parsedComplexDivisor['imaginary']);
$r = $d1/$d3;
$i = $d2/$d3;
if ($i > 0.0) {
return self::_cleanComplex($r.'+'.$i.$parsedComplexDivisor['suffix']);
} elseif ($i < 0.0) {
return self::_cleanComplex($r.$i.$parsedComplexDivisor['suffix']);
} else {
return $r;
}
} // function IMDIV()
/**
* IMSUB
*
* Returns the difference of two complex numbers in x + yi or x + yj text format.
*
* @param string $complexNumber1
* @param string $complexNumber2
* @return real
*/
public static function IMSUB($complexNumber1,$complexNumber2) {
$complexNumber1 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber1);
$complexNumber2 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber2);
$parsedComplex1 = self::_parseComplex($complexNumber1);
if (!is_array($parsedComplex1)) {
return $parsedComplex1;
}
$parsedComplex2 = self::_parseComplex($complexNumber2);
if (!is_array($parsedComplex2)) {
return $parsedComplex2;
}
if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) &&
($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) {
return PHPExcel_Calculation_Functions::NaN();
} elseif (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) {
$parsedComplex1['suffix'] = $parsedComplex2['suffix'];
}
$d1 = $parsedComplex1['real'] - $parsedComplex2['real'];
$d2 = $parsedComplex1['imaginary'] - $parsedComplex2['imaginary'];
return self::COMPLEX($d1,$d2,$parsedComplex1['suffix']);
} // function IMSUB()
/**
* IMSUM
*
* Returns the sum of two or more complex numbers in x + yi or x + yj text format.
*
* @param array of mixed Data Series
* @return real
*/
public static function IMSUM() {
// Return value
$returnValue = self::_parseComplex('0');
$activeSuffix = '';
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
$parsedComplex = self::_parseComplex($arg);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if ($activeSuffix == '') {
$activeSuffix = $parsedComplex['suffix'];
} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
return PHPExcel_Calculation_Functions::VALUE();
}
$returnValue['real'] += $parsedComplex['real'];
$returnValue['imaginary'] += $parsedComplex['imaginary'];
}
if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; }
return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix);
} // function IMSUM()
/**
* IMPRODUCT
*
* Returns the product of two or more complex numbers in x + yi or x + yj text format.
*
* @param array of mixed Data Series
* @return real
*/
public static function IMPRODUCT() {
// Return value
$returnValue = self::_parseComplex('1');
$activeSuffix = '';
// Loop through the arguments
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
$parsedComplex = self::_parseComplex($arg);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
$workValue = $returnValue;
if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) {
$activeSuffix = $parsedComplex['suffix'];
} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
return PHPExcel_Calculation_Functions::NaN();
}
$returnValue['real'] = ($workValue['real'] * $parsedComplex['real']) - ($workValue['imaginary'] * $parsedComplex['imaginary']);
$returnValue['imaginary'] = ($workValue['real'] * $parsedComplex['imaginary']) + ($workValue['imaginary'] * $parsedComplex['real']);
}
if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; }
return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix);
} // function IMPRODUCT()
/**
* DELTA
*
* Tests whether two values are equal. Returns 1 if number1 = number2; returns 0 otherwise.
*
* @param float $a
* @param float $b
* @return int
*/
public static function DELTA($a, $b=0) {
$a = PHPExcel_Calculation_Functions::flattenSingleValue($a);
$b = PHPExcel_Calculation_Functions::flattenSingleValue($b);
return (int) ($a == $b);
} // function DELTA()
/**
* GESTEP
*
* Returns 1 if number = step; returns 0 (zero) otherwise
*
* @param float $number
* @param float $step
* @return int
*/
public static function GESTEP($number, $step=0) {
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
$step = PHPExcel_Calculation_Functions::flattenSingleValue($step);
return (int) ($number >= $step);
} // function GESTEP()
//
// Private method to calculate the erf value
//
private static $_two_sqrtpi = 1.128379167095512574;
public static function _erfVal($x) {
if (abs($x) > 2.2) {
return 1 - self::_erfcVal($x);
}
$sum = $term = $x;
$xsqr = ($x * $x);
$j = 1;
do {
$term *= $xsqr / $j;
$sum -= $term / (2 * $j + 1);
++$j;
$term *= $xsqr / $j;
$sum += $term / (2 * $j + 1);
++$j;
if ($sum == 0.0) {
break;
}
} while (abs($term / $sum) > PRECISION);
return self::$_two_sqrtpi * $sum;
} // function _erfVal()
/**
* ERF
*
* Returns the error function integrated between lower_limit and upper_limit
*
* @param float $lower lower bound for integrating ERF
* @param float $upper upper bound for integrating ERF.
* If omitted, ERF integrates between zero and lower_limit
* @return int
*/
public static function ERF($lower, $upper = null) {
$lower = PHPExcel_Calculation_Functions::flattenSingleValue($lower);
$upper = PHPExcel_Calculation_Functions::flattenSingleValue($upper);
if (is_numeric($lower)) {
if ($lower < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
if (is_null($upper)) {
return self::_erfVal($lower);
}
if (is_numeric($upper)) {
if ($upper < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
return self::_erfVal($upper) - self::_erfVal($lower);
}
}
return PHPExcel_Calculation_Functions::VALUE();
} // function ERF()
//
// Private method to calculate the erfc value
//
private static $_one_sqrtpi = 0.564189583547756287;
private static function _erfcVal($x) {
if (abs($x) < 2.2) {
return 1 - self::_erfVal($x);
}
if ($x < 0) {
return 2 - self::ERFC(-$x);
}
$a = $n = 1;
$b = $c = $x;
$d = ($x * $x) + 0.5;
$q1 = $q2 = $b / $d;
$t = 0;
do {
$t = $a * $n + $b * $x;
$a = $b;
$b = $t;
$t = $c * $n + $d * $x;
$c = $d;
$d = $t;
$n += 0.5;
$q1 = $q2;
$q2 = $b / $d;
} while ((abs($q1 - $q2) / $q2) > PRECISION);
return self::$_one_sqrtpi * exp(-$x * $x) * $q2;
} // function _erfcVal()
/**
* ERFC
*
* Returns the complementary ERF function integrated between x and infinity
*
* @param float $x The lower bound for integrating ERF
* @return int
*/
public static function ERFC($x) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
if (is_numeric($x)) {
if ($x < 0) {
return PHPExcel_Calculation_Functions::NaN();
}
return self::_erfcVal($x);
}
return PHPExcel_Calculation_Functions::VALUE();
} // function ERFC()
/**
* getConversionGroups
*
* @return array
*/
public static function getConversionGroups() {
$conversionGroups = array();
foreach(self::$_conversionUnits as $conversionUnit) {
$conversionGroups[] = $conversionUnit['Group'];
}
return array_merge(array_unique($conversionGroups));
} // function getConversionGroups()
/**
* getConversionGroupUnits
*
* @return array
*/
public static function getConversionGroupUnits($group = NULL) {
$conversionGroups = array();
foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) {
if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
$conversionGroups[$conversionGroup['Group']][] = $conversionUnit;
}
}
return $conversionGroups;
} // function getConversionGroupUnits()
/**
* getConversionGroupUnitDetails
*
* @return array
*/
public static function getConversionGroupUnitDetails($group = NULL) {
$conversionGroups = array();
foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) {
if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
$conversionGroups[$conversionGroup['Group']][] = array( 'unit' => $conversionUnit,
'description' => $conversionGroup['Unit Name']
);
}
}
return $conversionGroups;
} // function getConversionGroupUnitDetails()
/**
* getConversionGroups
*
* @return array
*/
public static function getConversionMultipliers() {
return self::$_conversionMultipliers;
} // function getConversionGroups()
/**
* CONVERTUOM
*
* @param float $value
* @param string $fromUOM
* @param string $toUOM
* @return float
*/
public static function CONVERTUOM($value, $fromUOM, $toUOM) {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
$fromUOM = PHPExcel_Calculation_Functions::flattenSingleValue($fromUOM);
$toUOM = PHPExcel_Calculation_Functions::flattenSingleValue($toUOM);
if (!is_numeric($value)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$fromMultiplier = 1;
if (isset(self::$_conversionUnits[$fromUOM])) {
$unitGroup1 = self::$_conversionUnits[$fromUOM]['Group'];
} else {
$fromMultiplier = substr($fromUOM,0,1);
$fromUOM = substr($fromUOM,1);
if (isset(self::$_conversionMultipliers[$fromMultiplier])) {
$fromMultiplier = self::$_conversionMultipliers[$fromMultiplier]['multiplier'];
} else {
return PHPExcel_Calculation_Functions::NA();
}
if ((isset(self::$_conversionUnits[$fromUOM])) && (self::$_conversionUnits[$fromUOM]['AllowPrefix'])) {
$unitGroup1 = self::$_conversionUnits[$fromUOM]['Group'];
} else {
return PHPExcel_Calculation_Functions::NA();
}
}
$value *= $fromMultiplier;
$toMultiplier = 1;
if (isset(self::$_conversionUnits[$toUOM])) {
$unitGroup2 = self::$_conversionUnits[$toUOM]['Group'];
} else {
$toMultiplier = substr($toUOM,0,1);
$toUOM = substr($toUOM,1);
if (isset(self::$_conversionMultipliers[$toMultiplier])) {
$toMultiplier = self::$_conversionMultipliers[$toMultiplier]['multiplier'];
} else {
return PHPExcel_Calculation_Functions::NA();
}
if ((isset(self::$_conversionUnits[$toUOM])) && (self::$_conversionUnits[$toUOM]['AllowPrefix'])) {
$unitGroup2 = self::$_conversionUnits[$toUOM]['Group'];
} else {
return PHPExcel_Calculation_Functions::NA();
}
}
if ($unitGroup1 != $unitGroup2) {
return PHPExcel_Calculation_Functions::NA();
}
if ($fromUOM == $toUOM) {
return 1.0;
} elseif ($unitGroup1 == 'Temperature') {
if (($fromUOM == 'F') || ($fromUOM == 'fah')) {
if (($toUOM == 'F') || ($toUOM == 'fah')) {
return 1.0;
} else {
$value = (($value - 32) / 1.8);
if (($toUOM == 'K') || ($toUOM == 'kel')) {
$value += 273.15;
}
return $value;
}
} elseif ((($fromUOM == 'K') || ($fromUOM == 'kel')) &&
(($toUOM == 'K') || ($toUOM == 'kel'))) {
return 1.0;
} elseif ((($fromUOM == 'C') || ($fromUOM == 'cel')) &&
(($toUOM == 'C') || ($toUOM == 'cel'))) {
return 1.0;
}
if (($toUOM == 'F') || ($toUOM == 'fah')) {
if (($fromUOM == 'K') || ($fromUOM == 'kel')) {
$value -= 273.15;
}
return ($value * 1.8) + 32;
}
if (($toUOM == 'C') || ($toUOM == 'cel')) {
return $value - 273.15;
}
return $value + 273.15;
}
return ($value * self::$_unitConversions[$unitGroup1][$fromUOM][$toUOM]) / $toMultiplier;
} // function CONVERTUOM()
} // class PHPExcel_Calculation_Engineering
| zysms | trunk/zysms/customer/PHPExcel/Calculation/Engineering.php | PHP | asf20 | 79,791 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_ReferenceHelper (Singleton)
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_ReferenceHelper
{
/** Constants */
/** Regular Expressions */
const REFHELPER_REGEXP_CELLREF = '((\w*|\'[^!]*\')!)?(?<![:a-z\$])(\$?[a-z]{1,3}\$?\d+)(?=[^:!\d\'])';
const REFHELPER_REGEXP_CELLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}\$?\d+):(\$?[a-z]{1,3}\$?\d+)';
const REFHELPER_REGEXP_ROWRANGE = '((\w*|\'[^!]*\')!)?(\$?\d+):(\$?\d+)';
const REFHELPER_REGEXP_COLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}):(\$?[a-z]{1,3})';
/**
* Instance of this class
*
* @var PHPExcel_ReferenceHelper
*/
private static $_instance;
/**
* Get an instance of this class
*
* @return PHPExcel_ReferenceHelper
*/
public static function getInstance() {
if (!isset(self::$_instance) || is_null(self::$_instance)) {
self::$_instance = new PHPExcel_ReferenceHelper();
}
return self::$_instance;
}
/**
* Create a new PHPExcel_ReferenceHelper
*/
protected function __construct() {
}
/**
* Insert a new column, updating all possible related data
*
* @param int $pBefore Insert before this one
* @param int $pNumCols Number of columns to insert
* @param int $pNumRows Number of rows to insert
* @throws Exception
*/
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null) {
$aCellCollection = $pSheet->getCellCollection();
// Get coordinates of $pBefore
$beforeColumn = 'A';
$beforeRow = 1;
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
// Clear cells if we are removing columns or rows
$highestColumn = $pSheet->getHighestColumn();
$highestRow = $pSheet->getHighestRow();
// 1. Clear column strips if we are removing columns
if ($pNumCols < 0 && PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 + $pNumCols > 0) {
for ($i = 1; $i <= $highestRow - 1; ++$i) {
for ($j = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1 + $pNumCols; $j <= PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2; ++$j) {
$coordinate = PHPExcel_Cell::stringFromColumnIndex($j) . $i;
$pSheet->removeConditionalStyles($coordinate);
if ($pSheet->cellExists($coordinate)) {
$pSheet->getCell($coordinate)->setValueExplicit('', PHPExcel_Cell_DataType::TYPE_NULL);
$pSheet->getCell($coordinate)->setXfIndex(0);
}
}
}
}
// 2. Clear row strips if we are removing rows
if ($pNumRows < 0 && $beforeRow - 1 + $pNumRows > 0) {
for ($i = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
for ($j = $beforeRow + $pNumRows; $j <= $beforeRow - 1; ++$j) {
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . $j;
$pSheet->removeConditionalStyles($coordinate);
if ($pSheet->cellExists($coordinate)) {
$pSheet->getCell($coordinate)->setValueExplicit('', PHPExcel_Cell_DataType::TYPE_NULL);
$pSheet->getCell($coordinate)->setXfIndex(0);
}
}
}
}
// Loop through cells, bottom-up, and change cell coordinates
while (($cellID = ($pNumCols < 0 || $pNumRows < 0) ? array_shift($aCellCollection) : array_pop($aCellCollection))) {
$cell = $pSheet->getCell($cellID);
// New coordinates
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1 + $pNumCols ) . ($cell->getRow() + $pNumRows);
// Should the cell be updated? Move value and cellXf index from one cell to another.
if ((PHPExcel_Cell::columnIndexFromString( $cell->getColumn() ) >= PHPExcel_Cell::columnIndexFromString($beforeColumn)) &&
($cell->getRow() >= $beforeRow)) {
// Update cell styles
$pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex());
$cell->setXfIndex(0);
// Insert this cell at its new location
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted
$pSheet->getCell($newCoordinates)
->setValue($this->updateFormulaReferences($cell->getValue(),
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
} else {
// Formula should not be adjusted
$pSheet->getCell($newCoordinates)->setValue($cell->getValue());
}
// Clear the original cell
$pSheet->getCell($cell->getCoordinate())->setValue('');
} else {
/* We don't need to update styles for rows/columns before our insertion position,
but we do still need to adjust any formulae in those cells */
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted
$cell->setValue($this->updateFormulaReferences($cell->getValue(),
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
}
}
}
// Duplicate styles for the newly inserted cells
$highestColumn = $pSheet->getHighestColumn();
$highestRow = $pSheet->getHighestRow();
if ($pNumCols > 0 && PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 > 0) {
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
// Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 ) . $i;
if ($pSheet->cellExists($coordinate)) {
$xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
$conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ?
$pSheet->getConditionalStyles($coordinate) : false;
for ($j = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1; $j <= PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 + $pNumCols; ++$j) {
$pSheet->getCellByColumnAndRow($j, $i)->setXfIndex($xfIndex);
if ($conditionalStyles) {
$cloned = array();
foreach ($conditionalStyles as $conditionalStyle) {
$cloned[] = clone $conditionalStyle;
}
$pSheet->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($j) . $i, $cloned);
}
}
}
}
}
if ($pNumRows > 0 && $beforeRow - 1 > 0) {
for ($i = PHPExcel_Cell::columnIndexFromString($beforeColumn) - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
// Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1);
if ($pSheet->cellExists($coordinate)) {
$xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
$conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ?
$pSheet->getConditionalStyles($coordinate) : false;
for ($j = $beforeRow; $j <= $beforeRow - 1 + $pNumRows; ++$j) {
$pSheet->getCell(PHPExcel_Cell::stringFromColumnIndex($i) . $j)->setXfIndex($xfIndex);
if ($conditionalStyles) {
$cloned = array();
foreach ($conditionalStyles as $conditionalStyle) {
$cloned[] = clone $conditionalStyle;
}
$pSheet->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($i) . $j, $cloned);
}
}
}
}
}
// Update worksheet: column dimensions
$aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true);
if (count($aColumnDimensions) > 0) {
foreach ($aColumnDimensions as $objColumnDimension) {
$newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows);
list($newReference) = PHPExcel_Cell::coordinateFromString($newReference);
if ($objColumnDimension->getColumnIndex() != $newReference) {
$objColumnDimension->setColumnIndex($newReference);
}
}
$pSheet->refreshColumnDimensions();
}
// Update worksheet: row dimensions
$aRowDimensions = array_reverse($pSheet->getRowDimensions(), true);
if (count($aRowDimensions) > 0) {
foreach ($aRowDimensions as $objRowDimension) {
$newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows);
list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference);
if ($objRowDimension->getRowIndex() != $newReference) {
$objRowDimension->setRowIndex($newReference);
}
}
$pSheet->refreshRowDimensions();
$copyDimension = $pSheet->getRowDimension($beforeRow - 1);
for ($i = $beforeRow; $i <= $beforeRow - 1 + $pNumRows; ++$i) {
$newDimension = $pSheet->getRowDimension($i);
$newDimension->setRowHeight($copyDimension->getRowHeight());
$newDimension->setVisible($copyDimension->getVisible());
$newDimension->setOutlineLevel($copyDimension->getOutlineLevel());
$newDimension->setCollapsed($copyDimension->getCollapsed());
}
}
// Update worksheet: breaks
$aBreaks = array_reverse($pSheet->getBreaks(), true);
foreach ($aBreaks as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) {
$pSheet->setBreak( $newReference, $value );
$pSheet->setBreak( $key, PHPExcel_Worksheet::BREAK_NONE );
}
}
// Update worksheet: comments
$aComments = $pSheet->getComments();
$aNewComments = array(); // the new array of all comments
foreach ($aComments as $key => &$value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
$aNewComments[$newReference] = $value;
}
$pSheet->setComments($aNewComments); // replace the comments array
// Update worksheet: hyperlinks
$aHyperlinkCollection = array_reverse($pSheet->getHyperlinkCollection(), true);
foreach ($aHyperlinkCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) {
$pSheet->setHyperlink( $newReference, $value );
$pSheet->setHyperlink( $key, null );
}
}
// Update worksheet: data validations
$aDataValidationCollection = array_reverse($pSheet->getDataValidationCollection(), true);
foreach ($aDataValidationCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) {
$pSheet->setDataValidation( $newReference, $value );
$pSheet->setDataValidation( $key, null );
}
}
// Update worksheet: merge cells
$aMergeCells = $pSheet->getMergeCells();
$aNewMergeCells = array(); // the new array of all merge cells
foreach ($aMergeCells as $key => &$value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
$aNewMergeCells[$newReference] = $newReference;
}
$pSheet->setMergeCells($aNewMergeCells); // replace the merge cells array
// Update worksheet: protected cells
$aProtectedCells = array_reverse($pSheet->getProtectedCells(), true);
foreach ($aProtectedCells as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) {
$pSheet->protectCells( $newReference, $value, true );
$pSheet->unprotectCells( $key );
}
}
// Update worksheet: autofilter
if ($pSheet->getAutoFilter() != '') {
$pSheet->setAutoFilter( $this->updateCellReference($pSheet->getAutoFilter(), $pBefore, $pNumCols, $pNumRows) );
}
// Update worksheet: freeze pane
if ($pSheet->getFreezePane() != '') {
$pSheet->freezePane( $this->updateCellReference($pSheet->getFreezePane(), $pBefore, $pNumCols, $pNumRows) );
}
// Page setup
if ($pSheet->getPageSetup()->isPrintAreaSet()) {
$pSheet->getPageSetup()->setPrintArea( $this->updateCellReference($pSheet->getPageSetup()->getPrintArea(), $pBefore, $pNumCols, $pNumRows) );
}
// Update worksheet: drawings
$aDrawings = $pSheet->getDrawingCollection();
foreach ($aDrawings as $objDrawing) {
$newReference = $this->updateCellReference($objDrawing->getCoordinates(), $pBefore, $pNumCols, $pNumRows);
if ($objDrawing->getCoordinates() != $newReference) {
$objDrawing->setCoordinates($newReference);
}
}
// Update workbook: named ranges
if (count($pSheet->getParent()->getNamedRanges()) > 0) {
foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) {
if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) {
$namedRange->setRange(
$this->updateCellReference($namedRange->getRange(), $pBefore, $pNumCols, $pNumRows)
);
}
}
}
// Garbage collect
$pSheet->garbageCollect();
}
/**
* Update references within formulas
*
* @param string $pFormula Formula to update
* @param int $pBefore Insert before this one
* @param int $pNumCols Number of columns to insert
* @param int $pNumRows Number of rows to insert
* @return string Updated formula
* @throws Exception
*/
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') {
// Update cell references in the formula
$formulaBlocks = explode('"',$pFormula);
$i = false;
foreach($formulaBlocks as &$formulaBlock) {
// Ignore blocks that were enclosed in quotes (alternating entries in the $formulaBlocks array after the explode)
if ($i = !$i) {
$adjustCount = 0;
$newCellTokens = $cellTokens = array();
// Search for row ranges (e.g. 'Sheet1'!3:5 or 3:5) with or without $ absolutes (e.g. $3:5)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_ROWRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) {
foreach($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4];
$modified3 = substr($this->updateCellReference('$A'.$match[3],$pBefore,$pNumCols,$pNumRows),2);
$modified4 = substr($this->updateCellReference('$A'.$match[4],$pBefore,$pNumCols,$pNumRows),2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4;
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = 100000;
$row = 10000000+trim($match[3],'$');
$cellIndex = $column.$row;
$newCellTokens[$cellIndex] = preg_quote($toString);
$cellTokens[$cellIndex] = '/(?<!\d)'.preg_quote($fromString).'(?!\d)/i';
++$adjustCount;
}
}
}
}
// Search for column ranges (e.g. 'Sheet1'!C:E or C:E) with or without $ absolutes (e.g. $C:E)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_COLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) {
foreach($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4];
$modified3 = substr($this->updateCellReference($match[3].'$1',$pBefore,$pNumCols,$pNumRows),0,-2);
$modified4 = substr($this->updateCellReference($match[4].'$1',$pBefore,$pNumCols,$pNumRows),0,-2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4;
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($match[3],'$')) + 100000;
$row = 10000000;
$cellIndex = $column.$row;
$newCellTokens[$cellIndex] = preg_quote($toString);
$cellTokens[$cellIndex] = '/(?<![A-Z])'.preg_quote($fromString).'(?![A-Z])/i';
++$adjustCount;
}
}
}
}
// Search for cell ranges (e.g. 'Sheet1'!A3:C5 or A3:C5) with or without $ absolutes (e.g. $A1:C$5)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) {
foreach($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4];
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows);
$modified4 = $this->updateCellReference($match[4],$pBefore,$pNumCols,$pNumRows);
if ($match[3].$match[4] !== $modified3.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4;
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000;
$cellIndex = $column.$row;
$newCellTokens[$cellIndex] = preg_quote($toString);
$cellTokens[$cellIndex] = '/(?<![A-Z])'.preg_quote($fromString).'(?!\d)/i';
++$adjustCount;
}
}
}
}
// Search for cell references (e.g. 'Sheet1'!A3 or C5) with or without $ absolutes (e.g. $A1 or C$5)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLREF.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) {
foreach($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3];
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows);
if ($match[3] !== $modified3) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3;
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000;
$cellIndex = $column.$row;
$newCellTokens[$cellIndex] = preg_quote($toString);
$cellTokens[$cellIndex] = '/(?<![A-Z])'.preg_quote($fromString).'(?!\d)/i';
++$adjustCount;
}
}
}
}
if ($adjustCount > 0) {
krsort($cellTokens);
krsort($newCellTokens);
// Update cell references in the formula
$formulaBlock = str_replace('\\','',preg_replace($cellTokens,$newCellTokens,$formulaBlock));
}
}
}
unset($formulaBlock);
// Then rebuild the formula string
return implode('"',$formulaBlocks);
}
/**
* Update cell reference
*
* @param string $pCellRange Cell range
* @param int $pBefore Insert before this one
* @param int $pNumCols Number of columns to increment
* @param int $pNumRows Number of rows to increment
* @return string Updated cell range
* @throws Exception
*/
public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
// Is it in another worksheet? Will not have to update anything.
if (strpos($pCellRange, "!") !== false) {
return $pCellRange;
// Is it a range or a single cell?
} elseif (strpos($pCellRange, ':') === false && strpos($pCellRange, ',') === false) {
// Single cell
return $this->_updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows);
} elseif (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) {
// Range
return $this->_updateCellRange($pCellRange, $pBefore, $pNumCols, $pNumRows);
} else {
// Return original
return $pCellRange;
}
}
/**
* Update named formulas (i.e. containing worksheet references / named ranges)
*
* @param PHPExcel $pPhpExcel Object to update
* @param string $oldName Old name (name to replace)
* @param string $newName New name
*/
public function updateNamedFormulas(PHPExcel $pPhpExcel, $oldName = '', $newName = '') {
if ($oldName == '') {
return;
}
foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
foreach ($sheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID);
if (!is_null($cell) && $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
$formula = $cell->getValue();
if (strpos($formula, $oldName) !== false) {
$formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula);
$formula = str_replace($oldName . "!", $newName . "!", $formula);
$cell->setValueExplicit($formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
}
}
}
}
}
/**
* Update cell range
*
* @param string $pCellRange Cell range (e.g. 'B2:D4', 'B:C' or '2:3')
* @param int $pBefore Insert before this one
* @param int $pNumCols Number of columns to increment
* @param int $pNumRows Number of rows to increment
* @return string Updated cell range
* @throws Exception
*/
private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) {
// Update range
$range = PHPExcel_Cell::splitRange($pCellRange);
$ic = count($range);
for ($i = 0; $i < $ic; ++$i) {
$jc = count($range[$i]);
for ($j = 0; $j < $jc; ++$j) {
if (ctype_alpha($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows));
$range[$i][$j] = $r[0];
} elseif(ctype_digit($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows));
$range[$i][$j] = $r[1];
} else {
$range[$i][$j] = $this->_updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows);
}
}
}
// Recreate range string
return PHPExcel_Cell::buildRange($range);
} else {
throw new Exception("Only cell ranges may be passed to this method.");
}
}
/**
* Update single cell reference
*
* @param string $pCellReference Single cell reference
* @param int $pBefore Insert before this one
* @param int $pNumCols Number of columns to increment
* @param int $pNumRows Number of rows to increment
* @return string Updated cell reference
* @throws Exception
*/
private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {
// Get coordinates of $pBefore
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
// Get coordinates of $pCellReference
list($newColumn, $newRow) = PHPExcel_Cell::coordinateFromString( $pCellReference );
// Verify which parts should be updated
$updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') &&
PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn));
$updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') &&
$newRow >= $beforeRow);
// Create new column reference
if ($updateColumn) {
$newColumn = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols );
}
// Create new row reference
if ($updateRow) {
$newRow = $newRow + $pNumRows;
}
// Return new reference
return $newColumn . $newRow;
} else {
throw new Exception("Only single cell references may be passed to this method.");
}
}
/**
* __clone implementation. Cloning should not be allowed in a Singleton!
*
* @throws Exception
*/
public final function __clone() {
throw new Exception("Cloning a Singleton is not allowed!");
}
}
| zysms | trunk/zysms/customer/PHPExcel/ReferenceHelper.php | PHP | asf20 | 25,022 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_DocumentProperties
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_DocumentProperties
{
/** constants */
const PROPERTY_TYPE_BOOLEAN = 'b';
const PROPERTY_TYPE_INTEGER = 'i';
const PROPERTY_TYPE_FLOAT = 'f';
const PROPERTY_TYPE_DATE = 'd';
const PROPERTY_TYPE_STRING = 's';
const PROPERTY_TYPE_UNKNOWN = 'u';
/**
* Creator
*
* @var string
*/
private $_creator = 'Unknown Creator';
/**
* LastModifiedBy
*
* @var string
*/
private $_lastModifiedBy;
/**
* Created
*
* @var datetime
*/
private $_created;
/**
* Modified
*
* @var datetime
*/
private $_modified;
/**
* Title
*
* @var string
*/
private $_title = 'Untitled Spreadsheet';
/**
* Description
*
* @var string
*/
private $_description = '';
/**
* Subject
*
* @var string
*/
private $_subject = '';
/**
* Keywords
*
* @var string
*/
private $_keywords = '';
/**
* Category
*
* @var string
*/
private $_category = '';
/**
* Manager
*
* @var string
*/
private $_manager = '';
/**
* Company
*
* @var string
*/
private $_company = 'Microsoft Corporation';
/**
* Custom Properties
*
* @var string
*/
private $_customProperties = array();
/**
* Create a new PHPExcel_DocumentProperties
*/
public function __construct()
{
// Initialise values
$this->_lastModifiedBy = $this->_creator;
$this->_created = time();
$this->_modified = time();
}
/**
* Get Creator
*
* @return string
*/
public function getCreator() {
return $this->_creator;
}
/**
* Set Creator
*
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setCreator($pValue = '') {
$this->_creator = $pValue;
return $this;
}
/**
* Get Last Modified By
*
* @return string
*/
public function getLastModifiedBy() {
return $this->_lastModifiedBy;
}
/**
* Set Last Modified By
*
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setLastModifiedBy($pValue = '') {
$this->_lastModifiedBy = $pValue;
return $this;
}
/**
* Get Created
*
* @return datetime
*/
public function getCreated() {
return $this->_created;
}
/**
* Set Created
*
* @param datetime $pValue
* @return PHPExcel_DocumentProperties
*/
public function setCreated($pValue = null) {
if (is_null($pValue)) {
$pValue = time();
} elseif (is_string($pValue)) {
if (is_numeric($pValue)) {
$pValue = intval($pValue);
} else {
$pValue = strtotime($pValue);
}
}
$this->_created = $pValue;
return $this;
}
/**
* Get Modified
*
* @return datetime
*/
public function getModified() {
return $this->_modified;
}
/**
* Set Modified
*
* @param datetime $pValue
* @return PHPExcel_DocumentProperties
*/
public function setModified($pValue = null) {
if (is_null($pValue)) {
$pValue = time();
} elseif (is_string($pValue)) {
if (is_numeric($pValue)) {
$pValue = intval($pValue);
} else {
$pValue = strtotime($pValue);
}
}
$this->_modified = $pValue;
return $this;
}
/**
* Get Title
*
* @return string
*/
public function getTitle() {
return $this->_title;
}
/**
* Set Title
*
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setTitle($pValue = '') {
$this->_title = $pValue;
return $this;
}
/**
* Get Description
*
* @return string
*/
public function getDescription() {
return $this->_description;
}
/**
* Set Description
*
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setDescription($pValue = '') {
$this->_description = $pValue;
return $this;
}
/**
* Get Subject
*
* @return string
*/
public function getSubject() {
return $this->_subject;
}
/**
* Set Subject
*
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setSubject($pValue = '') {
$this->_subject = $pValue;
return $this;
}
/**
* Get Keywords
*
* @return string
*/
public function getKeywords() {
return $this->_keywords;
}
/**
* Set Keywords
*
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setKeywords($pValue = '') {
$this->_keywords = $pValue;
return $this;
}
/**
* Get Category
*
* @return string
*/
public function getCategory() {
return $this->_category;
}
/**
* Set Category
*
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setCategory($pValue = '') {
$this->_category = $pValue;
return $this;
}
/**
* Get Company
*
* @return string
*/
public function getCompany() {
return $this->_company;
}
/**
* Set Company
*
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setCompany($pValue = '') {
$this->_company = $pValue;
return $this;
}
/**
* Get Manager
*
* @return string
*/
public function getManager() {
return $this->_manager;
}
/**
* Set Manager
*
* @param string $pValue
* @return PHPExcel_DocumentProperties
*/
public function setManager($pValue = '') {
$this->_manager = $pValue;
return $this;
}
/**
* Get a List of Custom Property Names
*
* @return array of string
*/
public function getCustomProperties() {
return array_keys($this->_customProperties);
}
/**
* Check if a Custom Property is defined
*
* @param string $propertyName
* @return boolean
*/
public function isCustomPropertySet($propertyName) {
return isset($this->_customProperties[$propertyName]);
}
/**
* Get a Custom Property Value
*
* @param string $propertyName
* @return string
*/
public function getCustomPropertyValue($propertyName) {
if (isset($this->_customProperties[$propertyName])) {
return $this->_customProperties[$propertyName]['value'];
}
}
/**
* Get a Custom Property Type
*
* @param string $propertyName
* @return string
*/
public function getCustomPropertyType($propertyName) {
if (isset($this->_customProperties[$propertyName])) {
return $this->_customProperties[$propertyName]['type'];
}
}
/**
* Set a Custom Property
*
* @param string $propertyName
* @param mixed $propertyValue
* @param string $propertyType
* 'i' : Integer
* 'f' : Floating Point
* 's' : String
* 'd' : Date/Time
* 'b' : Boolean
* @return PHPExcel_DocumentProperties
*/
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
if ((is_null($propertyType)) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
self::PROPERTY_TYPE_FLOAT,
self::PROPERTY_TYPE_STRING,
self::PROPERTY_TYPE_DATE,
self::PROPERTY_TYPE_BOOLEAN)))) {
if (is_null($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_STRING;
} elseif (is_float($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_FLOAT;
} elseif(is_int($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_INTEGER;
} elseif (is_bool($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
} else {
$propertyType = self::PROPERTY_TYPE_STRING;
}
}
$this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType);
return $this;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
public static function convertProperty($propertyValue,$propertyType) {
switch ($propertyType) {
case 'empty' : // Empty
return '';
break;
case 'null' : // Null
return NULL;
break;
case 'i1' : // 1-Byte Signed Integer
case 'i2' : // 2-Byte Signed Integer
case 'i4' : // 4-Byte Signed Integer
case 'i8' : // 8-Byte Signed Integer
case 'int' : // Integer
return (int) $propertyValue;
break;
case 'ui1' : // 1-Byte Unsigned Integer
case 'ui2' : // 2-Byte Unsigned Integer
case 'ui4' : // 4-Byte Unsigned Integer
case 'ui8' : // 8-Byte Unsigned Integer
case 'uint' : // Unsigned Integer
return abs((int) $propertyValue);
break;
case 'r4' : // 4-Byte Real Number
case 'r8' : // 8-Byte Real Number
case 'decimal' : // Decimal
return (float) $propertyValue;
break;
case 'lpstr' : // LPSTR
case 'lpwstr' : // LPWSTR
case 'bstr' : // Basic String
return $propertyValue;
break;
case 'date' : // Date and Time
case 'filetime' : // File Time
return strtotime($propertyValue);
break;
case 'bool' : // Boolean
return ($propertyValue == 'true') ? True : False;
break;
case 'cy' : // Currency
case 'error' : // Error Status Code
case 'vector' : // Vector
case 'array' : // Array
case 'blob' : // Binary Blob
case 'oblob' : // Binary Blob Object
case 'stream' : // Binary Stream
case 'ostream' : // Binary Stream Object
case 'storage' : // Binary Storage
case 'ostorage' : // Binary Storage Object
case 'vstream' : // Binary Versioned Stream
case 'clsid' : // Class ID
case 'cf' : // Clipboard Data
return $propertyValue;
break;
}
return $propertyValue;
}
public static function convertPropertyType($propertyType) {
switch ($propertyType) {
case 'i1' : // 1-Byte Signed Integer
case 'i2' : // 2-Byte Signed Integer
case 'i4' : // 4-Byte Signed Integer
case 'i8' : // 8-Byte Signed Integer
case 'int' : // Integer
case 'ui1' : // 1-Byte Unsigned Integer
case 'ui2' : // 2-Byte Unsigned Integer
case 'ui4' : // 4-Byte Unsigned Integer
case 'ui8' : // 8-Byte Unsigned Integer
case 'uint' : // Unsigned Integer
return self::PROPERTY_TYPE_INTEGER;
break;
case 'r4' : // 4-Byte Real Number
case 'r8' : // 8-Byte Real Number
case 'decimal' : // Decimal
return self::PROPERTY_TYPE_FLOAT;
break;
case 'empty' : // Empty
case 'null' : // Null
case 'lpstr' : // LPSTR
case 'lpwstr' : // LPWSTR
case 'bstr' : // Basic String
return self::PROPERTY_TYPE_STRING;
break;
case 'date' : // Date and Time
case 'filetime' : // File Time
return self::PROPERTY_TYPE_DATE;
break;
case 'bool' : // Boolean
return self::PROPERTY_TYPE_BOOLEAN;
break;
case 'cy' : // Currency
case 'error' : // Error Status Code
case 'vector' : // Vector
case 'array' : // Array
case 'blob' : // Binary Blob
case 'oblob' : // Binary Blob Object
case 'stream' : // Binary Stream
case 'ostream' : // Binary Stream Object
case 'storage' : // Binary Storage
case 'ostorage' : // Binary Storage Object
case 'vstream' : // Binary Versioned Stream
case 'clsid' : // Class ID
case 'cf' : // Clipboard Data
return self::PROPERTY_TYPE_UNKNOWN;
break;
}
return self::PROPERTY_TYPE_UNKNOWN;
}
}
| zysms | trunk/zysms/customer/PHPExcel/DocumentProperties.php | PHP | asf20 | 12,271 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Date
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Date
{
/** constants */
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0
private static $ExcelBaseDate = self::CALENDAR_WINDOWS_1900;
public static $dateTimeObjectType = 'DateTime';
/**
* Set the Excel calendar (Windows 1900 or Mac 1904)
*
* @param integer $baseDate Excel base date
* @return boolean Success or failure
*/
public static function setExcelCalendar($baseDate) {
if (($baseDate == self::CALENDAR_WINDOWS_1900) ||
($baseDate == self::CALENDAR_MAC_1904)) {
self::$ExcelBaseDate = $baseDate;
return True;
}
return False;
} // function setExcelCalendar()
/**
* Return the Excel calendar (Windows 1900 or Mac 1904)
*
* @return integer $baseDate Excel base date
*/
public static function getExcelCalendar() {
return self::$ExcelBaseDate;
} // function getExcelCalendar()
/**
* Convert a date from Excel to PHP
*
* @param long $dateValue Excel date/time value
* @return long PHP serialized date/time
*/
public static function ExcelToPHP($dateValue = 0) {
if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) {
$myExcelBaseDate = 25569;
// Adjust for the spurious 29-Feb-1900 (Day 60)
if ($dateValue < 60) {
--$myExcelBaseDate;
}
} else {
$myExcelBaseDate = 24107;
}
// Perform conversion
if ($dateValue >= 1) {
$utcDays = $dateValue - $myExcelBaseDate;
$returnValue = round($utcDays * 24 * 60 * 60);
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
$returnValue = (integer) $returnValue;
}
} else {
$hours = round($dateValue * 24);
$mins = round($dateValue * 24 * 60) - round($hours * 60);
$secs = round($dateValue * 24 * 60 * 60) - round($hours * 60 * 60) - round($mins * 60);
$returnValue = (integer) gmmktime($hours, $mins, $secs);
}
// Return
return $returnValue;
} // function ExcelToPHP()
/**
* Convert a date from Excel to a PHP Date/Time object
*
* @param long $dateValue Excel date/time value
* @return long PHP date/time object
*/
public static function ExcelToPHPObject($dateValue = 0) {
$dateTime = self::ExcelToPHP($dateValue);
$days = floor($dateTime / 86400);
$time = round((($dateTime / 86400) - $days) * 86400);
$hours = round($time / 3600);
$minutes = round($time / 60) - ($hours * 60);
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
$dateObj = date_create('1-Jan-1970+'.$days.' days');
$dateObj->setTime($hours,$minutes,$seconds);
return $dateObj;
} // function ExcelToPHPObject()
/**
* Convert a date from PHP to Excel
*
* @param mixed $dateValue PHP serialized date/time or date object
* @return mixed Excel date/time value
* or boolean False on failure
*/
public static function PHPToExcel($dateValue = 0) {
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$retValue = False;
if ((is_object($dateValue)) && ($dateValue instanceof self::$dateTimeObjectType)) {
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'),
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
);
} elseif (is_numeric($dateValue)) {
$retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue),
date('H',$dateValue), date('i',$dateValue), date('s',$dateValue)
);
}
date_default_timezone_set($saveTimeZone);
return $retValue;
} // function PHPToExcel()
/**
* FormattedPHPToExcel
*
* @param long $year
* @param long $month
* @param long $day
* @param long $hours
* @param long $minutes
* @param long $seconds
* @return long Excel date/time value
*/
public static function FormattedPHPToExcel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) {
if (self::$ExcelBaseDate == self::CALENDAR_WINDOWS_1900) {
//
// Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel
// This affects every date following 28th February 1900
//
$excel1900isLeapYear = True;
if (($year == 1900) && ($month <= 2)) { $excel1900isLeapYear = False; }
$myExcelBaseDate = 2415020;
} else {
$myExcelBaseDate = 2416481;
$excel1900isLeapYear = False;
}
// Julian base date Adjustment
if ($month > 2) {
$month = $month - 3;
} else {
$month = $month + 9;
--$year;
}
// Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0)
$century = substr($year,0,2);
$decade = substr($year,2,2);
$excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $myExcelBaseDate + $excel1900isLeapYear;
$excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
return (float) $excelDate + $excelTime;
} // function FormattedPHPToExcel()
/**
* Is a given cell a date/time?
*
* @param PHPExcel_Cell $pCell
* @return boolean
*/
public static function isDateTime(PHPExcel_Cell $pCell) {
return self::isDateTimeFormat($pCell->getParent()->getStyle($pCell->getCoordinate())->getNumberFormat());
} // function isDateTime()
/**
* Is a given number format a date/time?
*
* @param PHPExcel_Style_NumberFormat $pFormat
* @return boolean
*/
public static function isDateTimeFormat(PHPExcel_Style_NumberFormat $pFormat) {
return self::isDateTimeFormatCode($pFormat->getFormatCode());
} // function isDateTimeFormat()
private static $possibleDateFormatCharacters = 'ymdHs';
/**
* Is a given number format code a date/time?
*
* @param string $pFormatCode
* @return boolean
*/
public static function isDateTimeFormatCode($pFormatCode = '') {
// Switch on formatcode
switch ($pFormatCode) {
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYSLASH:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMYMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DMMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_MYMINUS:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME1:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME2:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME5:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME7:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX14:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX16:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX17:
case PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22:
return true;
}
// Typically number, currency or accounting (or occasionally fraction) formats
if ((substr($pFormatCode,0,1) == '_') || (substr($pFormatCode,0,2) == '0 ')) {
return false;
}
// Try checking for any of the date formatting characters that don't appear within square braces
if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) {
// We might also have a format mask containing quoted strings...
// we don't want to test for any of our characters within the quoted blocks
if (strpos($pFormatCode,'"') !== false) {
$i = false;
foreach(explode('"',$pFormatCode) as $subVal) {
// Only test in alternate array entries (the non-quoted blocks)
if (($i = !$i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) {
return true;
}
}
return false;
}
return true;
}
// No date...
return false;
} // function isDateTimeFormatCode()
/**
* Convert a date/time string to Excel time
*
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
* @return float|false Excel date/time serial value
*/
public static function stringToExcel($dateValue = '') {
if (strlen($dateValue) < 2)
return false;
if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue))
return false;
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);
if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
return false;
} else {
if (strpos($dateValue, ':') !== false) {
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
return false;
}
$dateValueNew += $timeValue;
}
return $dateValueNew;
}
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Date.php | PHP | asf20 | 10,431 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared_ZipArchive
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PCLZip/pclzip.lib.php';
/**
* PHPExcel_Shared_ZipArchive
*
* @category PHPExcel
* @package PHPExcel_Shared_ZipArchive
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_ZipArchive
{
/**
* Temporary storage directory
*
* @var string
*/
private $_tempDir;
/**
* Zip Archive Stream Handle
*
* @var string
*/
private $_zip;
public function open($fileName)
{
$this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
$this->_zip = new PclZip($fileName);
return true;
}
public function close()
{
}
public function addFromString($localname, $contents)
{
$filenameParts = pathinfo($localname);
$handle = fopen($this->_tempDir.'/'.$filenameParts["basename"], "wb");
fwrite($handle, $contents);
fclose($handle);
$res = $this->_zip->add($this->_tempDir.'/'.$filenameParts["basename"],
PCLZIP_OPT_REMOVE_PATH, $this->_tempDir,
PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]
);
if ($res == 0) {
throw new Exception("Error zipping files : " . $this->_zip->errorInfo(true));
}
unlink($this->_tempDir.'/'.$filenameParts["basename"]);
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/ZipArchive.php | PHP | asf20 | 2,308 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Drawing
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Drawing
{
/**
* Convert pixels to EMU
*
* @param int $pValue Value in pixels
* @return int Value in EMU
*/
public static function pixelsToEMU($pValue = 0) {
return round($pValue * 9525);
}
/**
* Convert EMU to pixels
*
* @param int $pValue Value in EMU
* @return int Value in pixels
*/
public static function EMUToPixels($pValue = 0) {
if ($pValue != 0) {
return round($pValue / 9525);
} else {
return 0;
}
}
/**
* Convert pixels to column width. Exact algorithm not known.
* By inspection of a real Excel file using Calibri 11, one finds 1000px ~ 142.85546875
* This gives a conversion factor of 7. Also, we assume that pixels and font size are proportional.
*
* @param int $pValue Value in pixels
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
* @return int Value in cell dimension
*/
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
// Font name and size
$name = $pDefaultFont->getName();
$size = $pDefaultFont->getSize();
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
// Exact width can be determined
$colWidth = $pValue
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width']
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
} else {
// We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11
$colWidth = $pValue * 11
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width']
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
}
return $colWidth;
}
/**
* Convert column width from (intrinsic) Excel units to pixels
*
* @param float $pValue Value in cell dimension
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
* @return int Value in pixels
*/
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
// Font name and size
$name = $pDefaultFont->getName();
$size = $pDefaultFont->getSize();
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
// Exact width can be determined
$colWidth = $pValue
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px']
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
} else {
// We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11
$colWidth = $pValue * $size
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px']
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
}
// Round pixels to closest integer
$colWidth = (int) round($colWidth);
return $colWidth;
}
/**
* Convert pixels to points
*
* @param int $pValue Value in pixels
* @return int Value in points
*/
public static function pixelsToPoints($pValue = 0) {
return $pValue * 0.67777777;
}
/**
* Convert points to pixels
*
* @param int $pValue Value in points
* @return int Value in pixels
*/
public static function pointsToPixels($pValue = 0) {
if ($pValue != 0) {
return (int) ceil($pValue * 1.333333333);
} else {
return 0;
}
}
/**
* Convert degrees to angle
*
* @param int $pValue Degrees
* @return int Angle
*/
public static function degreesToAngle($pValue = 0) {
return (int)round($pValue * 60000);
}
/**
* Convert angle to degrees
*
* @param int $pValue Angle
* @return int Degrees
*/
public static function angleToDegrees($pValue = 0) {
if ($pValue != 0) {
return round($pValue / 60000);
} else {
return 0;
}
}
/**
* Create a new image from file. By alexander at alexauto dot nl
*
* @link http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
* @param string $filename Path to Windows DIB (BMP) image
* @return resource
*/
public static function imagecreatefrombmp($p_sFile)
{
// Load the image into a string
$file = fopen($p_sFile,"rb");
$read = fread($file,10);
while(!feof($file)&&($read<>""))
$read .= fread($file,1024);
$temp = unpack("H*",$read);
$hex = $temp[1];
$header = substr($hex,0,108);
// Process the header
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
if (substr($header,0,4)=="424d")
{
// Cut it in parts of 2 bytes
$header_parts = str_split($header,2);
// Get the width 4 bytes
$width = hexdec($header_parts[19].$header_parts[18]);
// Get the height 4 bytes
$height = hexdec($header_parts[23].$header_parts[22]);
// Unset the header params
unset($header_parts);
}
// Define starting X and Y
$x = 0;
$y = 1;
// Create newimage
$image = imagecreatetruecolor($width,$height);
// Grab the body from the image
$body = substr($hex,108);
// Calculate if padding at the end-line is needed
// Divided by two to keep overview.
// 1 byte = 2 HEX-chars
$body_size = (strlen($body)/2);
$header_size = ($width*$height);
// Use end-line padding? Only when needed
$usePadding = ($body_size>($header_size*3)+4);
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
// Calculate the next DWORD-position in the body
for ($i=0;$i<$body_size;$i+=3)
{
// Calculate line-ending and padding
if ($x>=$width)
{
// If padding needed, ignore image-padding
// Shift i to the ending of the current 32-bit-block
if ($usePadding)
$i += $width%4;
// Reset horizontal position
$x = 0;
// Raise the height-position (bottom-up)
$y++;
// Reached the image-height? Break the for-loop
if ($y>$height)
break;
}
// Calculation of the RGB-pixel (defined as BGR in image-data)
// Define $i_pos as absolute position in the body
$i_pos = $i*2;
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
$b = hexdec($body[$i_pos].$body[$i_pos+1]);
// Calculate and draw the pixel
$color = imagecolorallocate($image,$r,$g,$b);
imagesetpixel($image,$x,$height-$y,$color);
// Raise the horizontal position
$x++;
}
// Unset the body / free the memory
unset($body);
// Return image-object
return $image;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Drawing.php | PHP | asf20 | 8,630 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Font
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Font
{
/* Methods for resolving autosize value */
const AUTOSIZE_METHOD_APPROX = 'approx';
const AUTOSIZE_METHOD_EXACT = 'exact';
/** Character set codes used by BIFF5-8 in Font records */
const CHARSET_ANSI_LATIN = 0x00;
const CHARSET_SYSTEM_DEFAULT = 0x01;
const CHARSET_SYMBOL = 0x02;
const CHARSET_APPLE_ROMAN = 0x4D;
const CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80;
const CHARSET_ANSI_KOREAN_HANGUL = 0x81;
const CHARSET_ANSI_KOREAN_JOHAB = 0x82;
const CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86;
const CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88;
const CHARSET_ANSI_GREEK = 0xA1;
const CHARSET_ANSI_TURKISH = 0xA2;
const CHARSET_ANSI_VIETNAMESE = 0xA3;
const CHARSET_ANSI_HEBREW = 0xB1;
const CHARSET_ANSI_ARABIC = 0xB2;
const CHARSET_ANSI_BALTIC = 0xBA;
const CHARSET_ANSI_CYRILLIC = 0xCC;
const CHARSET_ANSI_THAI = 0xDE;
const CHARSET_ANSI_LATIN_II = 0xEE;
const CHARSET_OEM_LATIN_I = 0xFF;
// XXX: Constants created!
/** Font filenames */
const ARIAL = 'arial.ttf';
const ARIAL_BOLD = 'arialbd.ttf';
const ARIAL_ITALIC = 'ariali.ttf';
const ARIAL_BOLD_ITALIC = 'arialbi.ttf';
const CALIBRI = 'CALIBRI.TTF';
const CALIBRI_BOLD = 'CALIBRIB.TTF';
const CALIBRI_ITALIC = 'CALIBRII.TTF';
const CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF';
const COMIC_SANS_MS = 'comic.ttf';
const COMIC_SANS_MS_BOLD = 'comicbd.ttf';
const COURIER_NEW = 'cour.ttf';
const COURIER_NEW_BOLD = 'courbd.ttf';
const COURIER_NEW_ITALIC = 'couri.ttf';
const COURIER_NEW_BOLD_ITALIC = 'courbi.ttf';
const GEORGIA = 'georgia.ttf';
const GEORGIA_BOLD = 'georgiab.ttf';
const GEORGIA_ITALIC = 'georgiai.ttf';
const GEORGIA_BOLD_ITALIC = 'georgiaz.ttf';
const IMPACT = 'impact.ttf';
const LIBERATION_SANS = 'LiberationSans-Regular.ttf';
const LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf';
const LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf';
const LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf';
const LUCIDA_CONSOLE = 'lucon.ttf';
const LUCIDA_SANS_UNICODE = 'l_10646.ttf';
const MICROSOFT_SANS_SERIF = 'micross.ttf';
const PALATINO_LINOTYPE = 'pala.ttf';
const PALATINO_LINOTYPE_BOLD = 'palab.ttf';
const PALATINO_LINOTYPE_ITALIC = 'palai.ttf';
const PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf';
const SYMBOL = 'symbol.ttf';
const TAHOMA = 'tahoma.ttf';
const TAHOMA_BOLD = 'tahomabd.ttf';
const TIMES_NEW_ROMAN = 'times.ttf';
const TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf';
const TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf';
const TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf';
const TREBUCHET_MS = 'trebuc.ttf';
const TREBUCHET_MS_BOLD = 'trebucbd.ttf';
const TREBUCHET_MS_ITALIC = 'trebucit.ttf';
const TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf';
const VERDANA = 'verdana.ttf';
const VERDANA_BOLD = 'verdanab.ttf';
const VERDANA_ITALIC = 'verdanai.ttf';
const VERDANA_BOLD_ITALIC = 'verdanaz.ttf';
/**
* AutoSize method
*
* @var string
*/
private static $autoSizeMethod = self::AUTOSIZE_METHOD_APPROX;
/**
* Path to folder containing TrueType font .ttf files
*
* @var string
*/
private static $trueTypeFontPath = null;
/**
* How wide is a default column for a given default font and size?
* Empirical data found by inspecting real Excel files and reading off the pixel width
* in Microsoft Office Excel 2007.
*
* @var array
*/
public static $defaultColumnWidths = array(
'Arial' => array(
1 => array('px' => 24, 'width' => 12.00000000),
2 => array('px' => 24, 'width' => 12.00000000),
3 => array('px' => 32, 'width' => 10.66406250),
4 => array('px' => 32, 'width' => 10.66406250),
5 => array('px' => 40, 'width' => 10.00000000),
6 => array('px' => 48, 'width' => 9.59765625),
7 => array('px' => 48, 'width' => 9.59765625),
8 => array('px' => 56, 'width' => 9.33203125),
9 => array('px' => 64, 'width' => 9.14062500),
10 => array('px' => 64, 'width' => 9.14062500),
),
'Calibri' => array(
1 => array('px' => 24, 'width' => 12.00000000),
2 => array('px' => 24, 'width' => 12.00000000),
3 => array('px' => 32, 'width' => 10.66406250),
4 => array('px' => 32, 'width' => 10.66406250),
5 => array('px' => 40, 'width' => 10.00000000),
6 => array('px' => 48, 'width' => 9.59765625),
7 => array('px' => 48, 'width' => 9.59765625),
8 => array('px' => 56, 'width' => 9.33203125),
9 => array('px' => 56, 'width' => 9.33203125),
10 => array('px' => 64, 'width' => 9.14062500),
11 => array('px' => 64, 'width' => 9.14062500),
),
'Verdana' => array(
1 => array('px' => 24, 'width' => 12.00000000),
2 => array('px' => 24, 'width' => 12.00000000),
3 => array('px' => 32, 'width' => 10.66406250),
4 => array('px' => 32, 'width' => 10.66406250),
5 => array('px' => 40, 'width' => 10.00000000),
6 => array('px' => 48, 'width' => 9.59765625),
7 => array('px' => 48, 'width' => 9.59765625),
8 => array('px' => 64, 'width' => 9.14062500),
9 => array('px' => 72, 'width' => 9.00000000),
10 => array('px' => 72, 'width' => 9.00000000),
),
);
/**
* Set autoSize method
*
* @param string $pValue
*/
public static function setAutoSizeMethod($pValue = 'approx')
{
self::$autoSizeMethod = $pValue;
}
/**
* Get autoSize method
*
* @return string
*/
public static function getAutoSizeMethod()
{
return self::$autoSizeMethod;
}
/**
* Set the path to the folder containing .ttf files. There should be a trailing slash.
* Typical locations on variout some platforms:
* <ul>
* <li>C:/Windows/Fonts/</li>
* <li>/usr/share/fonts/truetype/</li>
* <li>~/.fonts/</li>
* </ul>
*
* @param string $pValue
*/
public static function setTrueTypeFontPath($pValue = '')
{
self::$trueTypeFontPath = $pValue;
}
/**
* Get the path to the folder containing .ttf files.
*
* @return string
*/
public static function getTrueTypeFontPath()
{
return self::$trueTypeFontPath;
}
/**
* Calculate an (approximate) OpenXML column width, based on font size and text contained
*
* @param int $fontSize Font size (in pixels or points)
* @param bool $fontSizeInPixels Is the font size specified in pixels (true) or in points (false) ?
* @param string $cellText Text to calculate width
* @param int $rotation Rotation angle
* @return int Column width
*/
public static function calculateColumnWidth(PHPExcel_Style_Font $font, $cellText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) {
// If it is rich text, use plain text
if ($cellText instanceof PHPExcel_RichText) {
$cellText = $cellText->getPlainText();
}
// Special case if there are one or more newline characters ("\n")
if (strpos($cellText, "\n") !== false) {
$lineTexts = explode("\n", $cellText);
$lineWitdhs = array();
foreach ($lineTexts as $lineText) {
$lineWidths[] = self::calculateColumnWidth($font, $lineText, $rotation = 0, $defaultFont);
}
return max($lineWidths); // width of longest line in cell
}
// Try to get the exact text width in pixels
try {
// If autosize method is set to 'approx', use approximation
if (self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX) {
throw new Exception('AutoSize method is set to approx');
}
// Width of text in pixels excl. padding
$columnWidth = self::getTextWidthPixelsExact($cellText, $font, $rotation);
// Excel adds some padding, use 1.07 of the width of an 'n' glyph
$columnWidth += ceil(self::getTextWidthPixelsExact('0', $font, 0) * 1.07); // pixels incl. padding
} catch (Exception $e) {
// Width of text in pixels excl. padding, approximation
$columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation);
// Excel adds some padding, just use approx width of 'n' glyph
$columnWidth += self::getTextWidthPixelsApprox('n', $font, 0);
}
// Convert from pixel width to column width
$columnWidth = PHPExcel_Shared_Drawing::pixelsToCellDimension($columnWidth, $defaultFont);
// Return
return round($columnWidth, 6);
}
/**
* Get GD text width in pixels for a string of text in a certain font at a certain rotation angle
*
* @param string $text
* @param PHPExcel_Style_Font
* @param int $rotation
* @return int
* @throws Exception
*/
public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0) {
if (!function_exists('imagettfbbox')) {
throw new Exception('GD library needs to be enabled');
}
// font size should really be supplied in pixels in GD2,
// but since GD2 seems to assume 72dpi, pixels and points are the same
$fontFile = self::getTrueTypeFontFileFromFont($font);
$textBox = imagettfbbox($font->getSize(), $rotation, $fontFile, $text);
// Get corners positions
$lowerLeftCornerX = $textBox[0];
$lowerLeftCornerY = $textBox[1];
$lowerRightCornerX = $textBox[2];
$lowerRightCornerY = $textBox[3];
$upperRightCornerX = $textBox[4];
$upperRightCornerY = $textBox[5];
$upperLeftCornerX = $textBox[6];
$upperLeftCornerY = $textBox[7];
// Consider the rotation when calculating the width
$textWidth = max($lowerRightCornerX - $upperLeftCornerX, $upperRightCornerX - $lowerLeftCornerX);
return $textWidth;
}
/**
* Get approximate width in pixels for a string of text in a certain font at a certain rotation angle
*
* @param string $columnText
* @param PHPExcel_Style_Font $font
* @param int $rotation
* @return int Text width in pixels (no padding added)
*/
public static function getTextWidthPixelsApprox($columnText, PHPExcel_Style_Font $font = null, $rotation = 0)
{
$fontName = $font->getName();
$fontSize = $font->getSize();
// Calculate column width in pixels. We assume fixed glyph width. Result varies with font name and size.
switch ($fontName) {
case 'Calibri':
// value 8.26 was found via interpolation by inspecting real Excel files with Calibri 11 font.
$columnWidth = (int) (8.26 * PHPExcel_Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
break;
case 'Arial':
// value 7 was found via interpolation by inspecting real Excel files with Arial 10 font.
$columnWidth = (int) (7 * PHPExcel_Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
break;
case 'Verdana':
// value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font.
$columnWidth = (int) (8 * PHPExcel_Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
break;
default:
// just assume Calibri
$columnWidth = (int) (8.26 * PHPExcel_Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
break;
}
// Calculate approximate rotated column width
if ($rotation !== 0) {
if ($rotation == -165) {
// stacked text
$columnWidth = 4; // approximation
} else {
// rotated text
$columnWidth = $columnWidth * cos(deg2rad($rotation))
+ $fontSize * abs(sin(deg2rad($rotation))) / 5; // approximation
}
}
// pixel width is an integer
$columnWidth = (int) $columnWidth;
return $columnWidth;
}
/**
* Calculate an (approximate) pixel size, based on a font points size
*
* @param int $fontSizeInPoints Font size (in points)
* @return int Font size (in pixels)
*/
public static function fontSizeToPixels($fontSizeInPoints = 11) {
return (int) ((4 / 3) * $fontSizeInPoints);
}
/**
* Calculate an (approximate) pixel size, based on inch size
*
* @param int $sizeInInch Font size (in inch)
* @return int Size (in pixels)
*/
public static function inchSizeToPixels($sizeInInch = 1) {
return ($sizeInInch * 96);
}
/**
* Calculate an (approximate) pixel size, based on centimeter size
*
* @param int $sizeInCm Font size (in centimeters)
* @return int Size (in pixels)
*/
public static function centimeterSizeToPixels($sizeInCm = 1) {
return ($sizeInCm * 37.795275591);
}
/**
* Returns the font path given the font
*
* @param PHPExcel_Style_Font
* @return string Path to TrueType font file
*/
public static function getTrueTypeFontFileFromFont($font) {
if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) {
throw new Exception('Valid directory to TrueType Font files not specified');
}
$name = $font->getName();
$bold = $font->getBold();
$italic = $font->getItalic();
// Check if we can map font to true type font file
switch ($name) {
case 'Arial':
$fontFile = (
$bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
: ($italic ? self::ARIAL_ITALIC : self::ARIAL)
);
break;
case 'Calibri':
$fontFile = (
$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
: ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
);
break;
case 'Courier New':
$fontFile = (
$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
: ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
);
break;
case 'Comic Sans MS':
$fontFile = (
$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
);
break;
case 'Georgia':
$fontFile = (
$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
: ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
);
break;
case 'Impact':
$fontFile = self::IMPACT;
break;
case 'Liberation Sans':
$fontFile = (
$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
: ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
);
break;
case 'Lucida Console':
$fontFile = self::LUCIDA_CONSOLE;
break;
case 'Lucida Sans Unicode':
$fontFile = self::LUCIDA_SANS_UNICODE;
break;
case 'Microsoft Sans Serif':
$fontFile = self::MICROSOFT_SANS_SERIF;
break;
case 'Palatino Linotype':
$fontFile = (
$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
: ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
);
break;
case 'Symbol':
$fontFile = self::SYMBOL;
break;
case 'Tahoma':
$fontFile = (
$bold ? self::TAHOMA_BOLD : self::TAHOMA
);
break;
case 'Times New Roman':
$fontFile = (
$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
: ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
);
break;
case 'Trebuchet MS':
$fontFile = (
$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
: ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
);
break;
case 'Verdana':
$fontFile = (
$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
: ($italic ? self::VERDANA_ITALIC : self::VERDANA)
);
break;
default:
throw new Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file');
break;
}
$fontFile = self::$trueTypeFontPath . $fontFile;
// Check if file actually exists
if (!file_exists($fontFile)) {
throw New Exception('TrueType Font file not found');
}
return $fontFile;
}
/**
* Returns the associated charset for the font name.
*
* @param string $name Font name
* @return int Character set code
*/
public static function getCharsetFromFontName($name)
{
switch ($name) {
// Add more cases. Check FONT records in real Excel files.
case 'EucrosiaUPC': return self::CHARSET_ANSI_THAI;
case 'Wingdings': return self::CHARSET_SYMBOL;
case 'Wingdings 2': return self::CHARSET_SYMBOL;
case 'Wingdings 3': return self::CHARSET_SYMBOL;
default: return self::CHARSET_ANSI_LATIN;
}
}
/**
* Get the effective column width for columns without a column dimension or column with width -1
* For example, for Calibri 11 this is 9.140625 (64 px)
*
* @param PHPExcel_Style_Font $font The workbooks default font
* @param boolean $pPixels true = return column width in pixels, false = return in OOXML units
* @return mixed Column width
*/
public static function getDefaultColumnWidthByFont(PHPExcel_Style_Font $font, $pPixels = false)
{
if (isset(self::$defaultColumnWidths[$font->getName()][$font->getSize()])) {
// Exact width can be determined
$columnWidth = $pPixels ?
self::$defaultColumnWidths[$font->getName()][$font->getSize()]['px']
: self::$defaultColumnWidths[$font->getName()][$font->getSize()]['width'];
} else {
// We don't have data for this particular font and size, use approximation by
// extrapolating from Calibri 11
$columnWidth = $pPixels ?
self::$defaultColumnWidths['Calibri'][11]['px']
: self::$defaultColumnWidths['Calibri'][11]['width'];
$columnWidth = $columnWidth * $font->getSize() / 11;
// Round pixels to closest integer
if ($pPixels) {
$columnWidth = (int) round($columnWidth);
}
}
return $columnWidth;
}
/**
* Get the effective row height for rows without a row dimension or rows with height -1
* For example, for Calibri 11 this is 15 points
*
* @param PHPExcel_Style_Font $font The workbooks default font
* @return float Row height in points
*/
public static function getDefaultRowHeightByFont(PHPExcel_Style_Font $font)
{
switch ($font->getName()) {
case 'Arial':
switch ($font->getSize()) {
case 10:
// inspection of Arial 10 workbook says 12.75pt ~17px
$rowHeight = 12.75;
break;
case 9:
// inspection of Arial 9 workbook says 12.00pt ~16px
$rowHeight = 12;
break;
case 8:
// inspection of Arial 8 workbook says 11.25pt ~15px
$rowHeight = 11.25;
break;
case 7:
// inspection of Arial 7 workbook says 9.00pt ~12px
$rowHeight = 9;
break;
case 6:
case 5:
// inspection of Arial 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25;
break;
case 4:
// inspection of Arial 4 workbook says 6.75pt ~9px
$rowHeight = 6.75;
break;
case 3:
// inspection of Arial 3 workbook says 6.00pt ~8px
$rowHeight = 6;
break;
case 2:
case 1:
// inspection of Arial 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25;
break;
default:
// use Arial 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10;
break;
}
break;
case 'Calibri':
switch ($font->getSize()) {
case 11:
// inspection of Calibri 11 workbook says 15.00pt ~20px
$rowHeight = 15;
break;
case 10:
// inspection of Calibri 10 workbook says 12.75pt ~17px
$rowHeight = 12.75;
break;
case 9:
// inspection of Calibri 9 workbook says 12.00pt ~16px
$rowHeight = 12;
break;
case 8:
// inspection of Calibri 8 workbook says 11.25pt ~15px
$rowHeight = 11.25;
break;
case 7:
// inspection of Calibri 7 workbook says 9.00pt ~12px
$rowHeight = 9;
break;
case 6:
case 5:
// inspection of Calibri 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25;
break;
case 4:
// inspection of Calibri 4 workbook says 6.75pt ~9px
$rowHeight = 6.75;
break;
case 3:
// inspection of Calibri 3 workbook says 6.00pt ~8px
$rowHeight = 6.00;
break;
case 2:
case 1:
// inspection of Calibri 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25;
break;
default:
// use Calibri 11 workbook as an approximation, extrapolation
$rowHeight = 15 * $font->getSize() / 11;
break;
}
break;
case 'Verdana':
switch ($font->getSize()) {
case 10:
// inspection of Verdana 10 workbook says 12.75pt ~17px
$rowHeight = 12.75;
break;
case 9:
// inspection of Verdana 9 workbook says 11.25pt ~15px
$rowHeight = 11.25;
break;
case 8:
// inspection of Verdana 8 workbook says 10.50pt ~14px
$rowHeight = 10.50;
break;
case 7:
// inspection of Verdana 7 workbook says 9.00pt ~12px
$rowHeight = 9.00;
break;
case 6:
case 5:
// inspection of Verdana 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25;
break;
case 4:
// inspection of Verdana 4 workbook says 6.75pt ~9px
$rowHeight = 6.75;
break;
case 3:
// inspection of Verdana 3 workbook says 6.00pt ~8px
$rowHeight = 6;
break;
case 2:
case 1:
// inspection of Verdana 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25;
break;
default:
// use Verdana 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10;
break;
}
break;
default:
// just use Calibri as an approximation
$rowHeight = 15 * $font->getSize() / 11;
break;
}
return $rowHeight;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Font.php | PHP | asf20 | 22,725 |
<?php
// --------------------------------------------------------------------------------
// PhpConcept Library - Zip Module 2.8.2
// --------------------------------------------------------------------------------
// License GNU/LGPL - Vincent Blavet - August 2009
// http://www.phpconcept.net
// --------------------------------------------------------------------------------
//
// Presentation :
// PclZip is a PHP library that manage ZIP archives.
// So far tests show that archives generated by PclZip are readable by
// WinZip application and other tools.
//
// Description :
// See readme.txt and http://www.phpconcept.net
//
// Warning :
// This library and the associated files are non commercial, non professional
// work.
// It should not have unexpected results. However if any damage is caused by
// this software the author can not be responsible.
// The use of this software is at the risk of the user.
//
// --------------------------------------------------------------------------------
// $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $
// --------------------------------------------------------------------------------
// ----- Constants
if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
}
// ----- File list separator
// In version 1.x of PclZip, the separator for file list is a space
// (which is not a very smart choice, specifically for windows paths !).
// A better separator should be a comma (,). This constant gives you the
// abilty to change that.
// However notice that changing this value, may have impact on existing
// scripts, using space separated filenames.
// Recommanded values for compatibility with older versions :
//define( 'PCLZIP_SEPARATOR', ' ' );
// Recommanded values for smart separation of filenames.
if (!defined('PCLZIP_SEPARATOR')) {
define( 'PCLZIP_SEPARATOR', ',' );
}
// ----- Error configuration
// 0 : PclZip Class integrated error handling
// 1 : PclError external library error handling. By enabling this
// you must ensure that you have included PclError library.
// [2,...] : reserved for futur use
if (!defined('PCLZIP_ERROR_EXTERNAL')) {
define( 'PCLZIP_ERROR_EXTERNAL', 0 );
}
// ----- Optional static temporary directory
// By default temporary files are generated in the script current
// path.
// If defined :
// - MUST BE terminated by a '/'.
// - MUST be a valid, already created directory
// Samples :
// define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
// define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
if (!defined('PCLZIP_TEMPORARY_DIR')) {
define( 'PCLZIP_TEMPORARY_DIR', '' );
}
// ----- Optional threshold ratio for use of temporary files
// Pclzip sense the size of the file to add/extract and decide to
// use or not temporary file. The algorythm is looking for
// memory_limit of PHP and apply a ratio.
// threshold = memory_limit * ratio.
// Recommended values are under 0.5. Default 0.47.
// Samples :
// define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
}
// --------------------------------------------------------------------------------
// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
// --------------------------------------------------------------------------------
// ----- Global variables
$g_pclzip_version = "2.8.2";
// ----- Error codes
// -1 : Unable to open file in binary write mode
// -2 : Unable to open file in binary read mode
// -3 : Invalid parameters
// -4 : File does not exist
// -5 : Filename is too long (max. 255)
// -6 : Not a valid zip file
// -7 : Invalid extracted file size
// -8 : Unable to create directory
// -9 : Invalid archive extension
// -10 : Invalid archive format
// -11 : Unable to delete file (unlink)
// -12 : Unable to rename file (rename)
// -13 : Invalid header checksum
// -14 : Invalid archive size
define( 'PCLZIP_ERR_USER_ABORTED', 2 );
define( 'PCLZIP_ERR_NO_ERROR', 0 );
define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
define( 'PCLZIP_ERR_MISSING_FILE', -4 );
define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
// ----- Options values
define( 'PCLZIP_OPT_PATH', 77001 );
define( 'PCLZIP_OPT_ADD_PATH', 77002 );
define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
define( 'PCLZIP_OPT_BY_NAME', 77008 );
define( 'PCLZIP_OPT_BY_INDEX', 77009 );
define( 'PCLZIP_OPT_BY_EREG', 77010 );
define( 'PCLZIP_OPT_BY_PREG', 77011 );
define( 'PCLZIP_OPT_COMMENT', 77012 );
define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
// Having big trouble with crypt. Need to multiply 2 long int
// which is not correctly supported by PHP ...
//define( 'PCLZIP_OPT_CRYPT', 77018 );
define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
// ----- File description attributes
define( 'PCLZIP_ATT_FILE_NAME', 79001 );
define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
// ----- Call backs values
define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
define( 'PCLZIP_CB_PRE_ADD', 78003 );
define( 'PCLZIP_CB_POST_ADD', 78004 );
/* For futur use
define( 'PCLZIP_CB_PRE_LIST', 78005 );
define( 'PCLZIP_CB_POST_LIST', 78006 );
define( 'PCLZIP_CB_PRE_DELETE', 78007 );
define( 'PCLZIP_CB_POST_DELETE', 78008 );
*/
// --------------------------------------------------------------------------------
// Class : PclZip
// Description :
// PclZip is the class that represent a Zip archive.
// The public methods allow the manipulation of the archive.
// Attributes :
// Attributes must not be accessed directly.
// Methods :
// PclZip() : Object creator
// create() : Creates the Zip archive
// listContent() : List the content of the Zip archive
// extract() : Extract the content of the archive
// properties() : List the properties of the archive
// --------------------------------------------------------------------------------
class PclZip
{
// ----- Filename of the zip file
var $zipname = '';
// ----- File descriptor of the zip file
var $zip_fd = 0;
// ----- Internal error handling
var $error_code = 1;
var $error_string = '';
// ----- Current status of the magic_quotes_runtime
// This value store the php configuration for magic_quotes
// The class can then disable the magic_quotes and reset it after
var $magic_quotes_status;
// --------------------------------------------------------------------------------
// Function : PclZip()
// Description :
// Creates a PclZip object and set the name of the associated Zip archive
// filename.
// Note that no real action is taken, if the archive does not exist it is not
// created. Use create() for that.
// --------------------------------------------------------------------------------
function PclZip($p_zipname)
{
// ----- Tests the zlib
if (!function_exists('gzopen'))
{
die('Abort '.basename(__FILE__).' : Missing zlib extensions');
}
// ----- Set the attributes
$this->zipname = $p_zipname;
$this->zip_fd = 0;
$this->magic_quotes_status = -1;
// ----- Return
return;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function :
// create($p_filelist, $p_add_dir="", $p_remove_dir="")
// create($p_filelist, $p_option, $p_option_value, ...)
// Description :
// This method supports two different synopsis. The first one is historical.
// This method creates a Zip Archive. The Zip file is created in the
// filesystem. The files and directories indicated in $p_filelist
// are added in the archive. See the parameters description for the
// supported format of $p_filelist.
// When a directory is in the list, the directory and its content is added
// in the archive.
// In this synopsis, the function takes an optional variable list of
// options. See bellow the supported options.
// Parameters :
// $p_filelist : An array containing file or directory names, or
// a string containing one filename or one directory name, or
// a string containing a list of filenames and/or directory
// names separated by spaces.
// $p_add_dir : A path to add before the real path of the archived file,
// in order to have it memorized in the archive.
// $p_remove_dir : A path to remove from the real path of the file to archive,
// in order to have a shorter path memorized in the archive.
// When $p_add_dir and $p_remove_dir are set, $p_remove_dir
// is removed first, before $p_add_dir is added.
// Options :
// PCLZIP_OPT_ADD_PATH :
// PCLZIP_OPT_REMOVE_PATH :
// PCLZIP_OPT_REMOVE_ALL_PATH :
// PCLZIP_OPT_COMMENT :
// PCLZIP_CB_PRE_ADD :
// PCLZIP_CB_POST_ADD :
// Return Values :
// 0 on failure,
// The list of the added files, with a status of the add action.
// (see PclZip::listContent() for list entry format)
// --------------------------------------------------------------------------------
function create($p_filelist)
{
$v_result=1;
// ----- Reset the error handler
$this->privErrorReset();
// ----- Set default values
$v_options = array();
$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
// ----- Look for variable options arguments
$v_size = func_num_args();
// ----- Look for arguments
if ($v_size > 1) {
// ----- Get the arguments
$v_arg_list = func_get_args();
// ----- Remove from the options list the first argument
array_shift($v_arg_list);
$v_size--;
// ----- Look for first arg
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
// ----- Parse the options
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
array (PCLZIP_OPT_REMOVE_PATH => 'optional',
PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
PCLZIP_OPT_ADD_PATH => 'optional',
PCLZIP_CB_PRE_ADD => 'optional',
PCLZIP_CB_POST_ADD => 'optional',
PCLZIP_OPT_NO_COMPRESSION => 'optional',
PCLZIP_OPT_COMMENT => 'optional',
PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
PCLZIP_OPT_TEMP_FILE_ON => 'optional',
PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
//, PCLZIP_OPT_CRYPT => 'optional'
));
if ($v_result != 1) {
return 0;
}
}
// ----- Look for 2 args
// Here we need to support the first historic synopsis of the
// method.
else {
// ----- Get the first argument
$v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
// ----- Look for the optional second argument
if ($v_size == 2) {
$v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
}
else if ($v_size > 2) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
"Invalid number / type of arguments");
return 0;
}
}
}
// ----- Look for default option values
$this->privOptionDefaultThreshold($v_options);
// ----- Init
$v_string_list = array();
$v_att_list = array();
$v_filedescr_list = array();
$p_result_list = array();
// ----- Look if the $p_filelist is really an array
if (is_array($p_filelist)) {
// ----- Look if the first element is also an array
// This will mean that this is a file description entry
if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
$v_att_list = $p_filelist;
}
// ----- The list is a list of string names
else {
$v_string_list = $p_filelist;
}
}
// ----- Look if the $p_filelist is a string
else if (is_string($p_filelist)) {
// ----- Create a list from the string
$v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
}
// ----- Invalid variable type for $p_filelist
else {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
return 0;
}
// ----- Reformat the string list
if (sizeof($v_string_list) != 0) {
foreach ($v_string_list as $v_string) {
if ($v_string != '') {
$v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
}
else {
}
}
}
// ----- For each file in the list check the attributes
$v_supported_attributes
= array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
,PCLZIP_ATT_FILE_MTIME => 'optional'
,PCLZIP_ATT_FILE_CONTENT => 'optional'
,PCLZIP_ATT_FILE_COMMENT => 'optional'
);
foreach ($v_att_list as $v_entry) {
$v_result = $this->privFileDescrParseAtt($v_entry,
$v_filedescr_list[],
$v_options,
$v_supported_attributes);
if ($v_result != 1) {
return 0;
}
}
// ----- Expand the filelist (expand directories)
$v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
if ($v_result != 1) {
return 0;
}
// ----- Call the create fct
$v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
if ($v_result != 1) {
return 0;
}
// ----- Return
return $p_result_list;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function :
// add($p_filelist, $p_add_dir="", $p_remove_dir="")
// add($p_filelist, $p_option, $p_option_value, ...)
// Description :
// This method supports two synopsis. The first one is historical.
// This methods add the list of files in an existing archive.
// If a file with the same name already exists, it is added at the end of the
// archive, the first one is still present.
// If the archive does not exist, it is created.
// Parameters :
// $p_filelist : An array containing file or directory names, or
// a string containing one filename or one directory name, or
// a string containing a list of filenames and/or directory
// names separated by spaces.
// $p_add_dir : A path to add before the real path of the archived file,
// in order to have it memorized in the archive.
// $p_remove_dir : A path to remove from the real path of the file to archive,
// in order to have a shorter path memorized in the archive.
// When $p_add_dir and $p_remove_dir are set, $p_remove_dir
// is removed first, before $p_add_dir is added.
// Options :
// PCLZIP_OPT_ADD_PATH :
// PCLZIP_OPT_REMOVE_PATH :
// PCLZIP_OPT_REMOVE_ALL_PATH :
// PCLZIP_OPT_COMMENT :
// PCLZIP_OPT_ADD_COMMENT :
// PCLZIP_OPT_PREPEND_COMMENT :
// PCLZIP_CB_PRE_ADD :
// PCLZIP_CB_POST_ADD :
// Return Values :
// 0 on failure,
// The list of the added files, with a status of the add action.
// (see PclZip::listContent() for list entry format)
// --------------------------------------------------------------------------------
function add($p_filelist)
{
$v_result=1;
// ----- Reset the error handler
$this->privErrorReset();
// ----- Set default values
$v_options = array();
$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
// ----- Look for variable options arguments
$v_size = func_num_args();
// ----- Look for arguments
if ($v_size > 1) {
// ----- Get the arguments
$v_arg_list = func_get_args();
// ----- Remove form the options list the first argument
array_shift($v_arg_list);
$v_size--;
// ----- Look for first arg
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
// ----- Parse the options
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
array (PCLZIP_OPT_REMOVE_PATH => 'optional',
PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
PCLZIP_OPT_ADD_PATH => 'optional',
PCLZIP_CB_PRE_ADD => 'optional',
PCLZIP_CB_POST_ADD => 'optional',
PCLZIP_OPT_NO_COMPRESSION => 'optional',
PCLZIP_OPT_COMMENT => 'optional',
PCLZIP_OPT_ADD_COMMENT => 'optional',
PCLZIP_OPT_PREPEND_COMMENT => 'optional',
PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
PCLZIP_OPT_TEMP_FILE_ON => 'optional',
PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
//, PCLZIP_OPT_CRYPT => 'optional'
));
if ($v_result != 1) {
return 0;
}
}
// ----- Look for 2 args
// Here we need to support the first historic synopsis of the
// method.
else {
// ----- Get the first argument
$v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
// ----- Look for the optional second argument
if ($v_size == 2) {
$v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
}
else if ($v_size > 2) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
// ----- Return
return 0;
}
}
}
// ----- Look for default option values
$this->privOptionDefaultThreshold($v_options);
// ----- Init
$v_string_list = array();
$v_att_list = array();
$v_filedescr_list = array();
$p_result_list = array();
// ----- Look if the $p_filelist is really an array
if (is_array($p_filelist)) {
// ----- Look if the first element is also an array
// This will mean that this is a file description entry
if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
$v_att_list = $p_filelist;
}
// ----- The list is a list of string names
else {
$v_string_list = $p_filelist;
}
}
// ----- Look if the $p_filelist is a string
else if (is_string($p_filelist)) {
// ----- Create a list from the string
$v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
}
// ----- Invalid variable type for $p_filelist
else {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
return 0;
}
// ----- Reformat the string list
if (sizeof($v_string_list) != 0) {
foreach ($v_string_list as $v_string) {
$v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
}
}
// ----- For each file in the list check the attributes
$v_supported_attributes
= array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
,PCLZIP_ATT_FILE_MTIME => 'optional'
,PCLZIP_ATT_FILE_CONTENT => 'optional'
,PCLZIP_ATT_FILE_COMMENT => 'optional'
);
foreach ($v_att_list as $v_entry) {
$v_result = $this->privFileDescrParseAtt($v_entry,
$v_filedescr_list[],
$v_options,
$v_supported_attributes);
if ($v_result != 1) {
return 0;
}
}
// ----- Expand the filelist (expand directories)
$v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
if ($v_result != 1) {
return 0;
}
// ----- Call the create fct
$v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
if ($v_result != 1) {
return 0;
}
// ----- Return
return $p_result_list;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : listContent()
// Description :
// This public method, gives the list of the files and directories, with their
// properties.
// The properties of each entries in the list are (used also in other functions) :
// filename : Name of the file. For a create or add action it is the filename
// given by the user. For an extract function it is the filename
// of the extracted file.
// stored_filename : Name of the file / directory stored in the archive.
// size : Size of the stored file.
// compressed_size : Size of the file's data compressed in the archive
// (without the headers overhead)
// mtime : Last known modification date of the file (UNIX timestamp)
// comment : Comment associated with the file
// folder : true | false
// index : index of the file in the archive
// status : status of the action (depending of the action) :
// Values are :
// ok : OK !
// filtered : the file / dir is not extracted (filtered by user)
// already_a_directory : the file can not be extracted because a
// directory with the same name already exists
// write_protected : the file can not be extracted because a file
// with the same name already exists and is
// write protected
// newer_exist : the file was not extracted because a newer file exists
// path_creation_fail : the file is not extracted because the folder
// does not exist and can not be created
// write_error : the file was not extracted because there was a
// error while writing the file
// read_error : the file was not extracted because there was a error
// while reading the file
// invalid_header : the file was not extracted because of an archive
// format error (bad file header)
// Note that each time a method can continue operating when there
// is an action error on a file, the error is only logged in the file status.
// Return Values :
// 0 on an unrecoverable failure,
// The list of the files in the archive.
// --------------------------------------------------------------------------------
function listContent()
{
$v_result=1;
// ----- Reset the error handler
$this->privErrorReset();
// ----- Check archive
if (!$this->privCheckFormat()) {
return(0);
}
// ----- Call the extracting fct
$p_list = array();
if (($v_result = $this->privList($p_list)) != 1)
{
unset($p_list);
return(0);
}
// ----- Return
return $p_list;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function :
// extract($p_path="./", $p_remove_path="")
// extract([$p_option, $p_option_value, ...])
// Description :
// This method supports two synopsis. The first one is historical.
// This method extract all the files / directories from the archive to the
// folder indicated in $p_path.
// If you want to ignore the 'root' part of path of the memorized files
// you can indicate this in the optional $p_remove_path parameter.
// By default, if a newer file with the same name already exists, the
// file is not extracted.
//
// If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
// are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
// at the end of the path value of PCLZIP_OPT_PATH.
// Parameters :
// $p_path : Path where the files and directories are to be extracted
// $p_remove_path : First part ('root' part) of the memorized path
// (if any similar) to remove while extracting.
// Options :
// PCLZIP_OPT_PATH :
// PCLZIP_OPT_ADD_PATH :
// PCLZIP_OPT_REMOVE_PATH :
// PCLZIP_OPT_REMOVE_ALL_PATH :
// PCLZIP_CB_PRE_EXTRACT :
// PCLZIP_CB_POST_EXTRACT :
// Return Values :
// 0 or a negative value on failure,
// The list of the extracted files, with a status of the action.
// (see PclZip::listContent() for list entry format)
// --------------------------------------------------------------------------------
function extract()
{
$v_result=1;
// ----- Reset the error handler
$this->privErrorReset();
// ----- Check archive
if (!$this->privCheckFormat()) {
return(0);
}
// ----- Set default values
$v_options = array();
// $v_path = "./";
$v_path = '';
$v_remove_path = "";
$v_remove_all_path = false;
// ----- Look for variable options arguments
$v_size = func_num_args();
// ----- Default values for option
$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
// ----- Look for arguments
if ($v_size > 0) {
// ----- Get the arguments
$v_arg_list = func_get_args();
// ----- Look for first arg
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
// ----- Parse the options
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
array (PCLZIP_OPT_PATH => 'optional',
PCLZIP_OPT_REMOVE_PATH => 'optional',
PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
PCLZIP_OPT_ADD_PATH => 'optional',
PCLZIP_CB_PRE_EXTRACT => 'optional',
PCLZIP_CB_POST_EXTRACT => 'optional',
PCLZIP_OPT_SET_CHMOD => 'optional',
PCLZIP_OPT_BY_NAME => 'optional',
PCLZIP_OPT_BY_EREG => 'optional',
PCLZIP_OPT_BY_PREG => 'optional',
PCLZIP_OPT_BY_INDEX => 'optional',
PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
PCLZIP_OPT_REPLACE_NEWER => 'optional'
,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
PCLZIP_OPT_TEMP_FILE_ON => 'optional',
PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
));
if ($v_result != 1) {
return 0;
}
// ----- Set the arguments
if (isset($v_options[PCLZIP_OPT_PATH])) {
$v_path = $v_options[PCLZIP_OPT_PATH];
}
if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
$v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
}
if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
$v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
}
if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
// ----- Check for '/' in last path char
if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
$v_path .= '/';
}
$v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
}
}
// ----- Look for 2 args
// Here we need to support the first historic synopsis of the
// method.
else {
// ----- Get the first argument
$v_path = $v_arg_list[0];
// ----- Look for the optional second argument
if ($v_size == 2) {
$v_remove_path = $v_arg_list[1];
}
else if ($v_size > 2) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
// ----- Return
return 0;
}
}
}
// ----- Look for default option values
$this->privOptionDefaultThreshold($v_options);
// ----- Trace
// ----- Call the extracting fct
$p_list = array();
$v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
$v_remove_all_path, $v_options);
if ($v_result < 1) {
unset($p_list);
return(0);
}
// ----- Return
return $p_list;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function :
// extractByIndex($p_index, $p_path="./", $p_remove_path="")
// extractByIndex($p_index, [$p_option, $p_option_value, ...])
// Description :
// This method supports two synopsis. The first one is historical.
// This method is doing a partial extract of the archive.
// The extracted files or folders are identified by their index in the
// archive (from 0 to n).
// Note that if the index identify a folder, only the folder entry is
// extracted, not all the files included in the archive.
// Parameters :
// $p_index : A single index (integer) or a string of indexes of files to
// extract. The form of the string is "0,4-6,8-12" with only numbers
// and '-' for range or ',' to separate ranges. No spaces or ';'
// are allowed.
// $p_path : Path where the files and directories are to be extracted
// $p_remove_path : First part ('root' part) of the memorized path
// (if any similar) to remove while extracting.
// Options :
// PCLZIP_OPT_PATH :
// PCLZIP_OPT_ADD_PATH :
// PCLZIP_OPT_REMOVE_PATH :
// PCLZIP_OPT_REMOVE_ALL_PATH :
// PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
// not as files.
// The resulting content is in a new field 'content' in the file
// structure.
// This option must be used alone (any other options are ignored).
// PCLZIP_CB_PRE_EXTRACT :
// PCLZIP_CB_POST_EXTRACT :
// Return Values :
// 0 on failure,
// The list of the extracted files, with a status of the action.
// (see PclZip::listContent() for list entry format)
// --------------------------------------------------------------------------------
//function extractByIndex($p_index, options...)
function extractByIndex($p_index)
{
$v_result=1;
// ----- Reset the error handler
$this->privErrorReset();
// ----- Check archive
if (!$this->privCheckFormat()) {
return(0);
}
// ----- Set default values
$v_options = array();
// $v_path = "./";
$v_path = '';
$v_remove_path = "";
$v_remove_all_path = false;
// ----- Look for variable options arguments
$v_size = func_num_args();
// ----- Default values for option
$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
// ----- Look for arguments
if ($v_size > 1) {
// ----- Get the arguments
$v_arg_list = func_get_args();
// ----- Remove form the options list the first argument
array_shift($v_arg_list);
$v_size--;
// ----- Look for first arg
if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
// ----- Parse the options
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
array (PCLZIP_OPT_PATH => 'optional',
PCLZIP_OPT_REMOVE_PATH => 'optional',
PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
PCLZIP_OPT_ADD_PATH => 'optional',
PCLZIP_CB_PRE_EXTRACT => 'optional',
PCLZIP_CB_POST_EXTRACT => 'optional',
PCLZIP_OPT_SET_CHMOD => 'optional',
PCLZIP_OPT_REPLACE_NEWER => 'optional'
,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
PCLZIP_OPT_TEMP_FILE_ON => 'optional',
PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
));
if ($v_result != 1) {
return 0;
}
// ----- Set the arguments
if (isset($v_options[PCLZIP_OPT_PATH])) {
$v_path = $v_options[PCLZIP_OPT_PATH];
}
if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
$v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
}
if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
$v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
}
if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
// ----- Check for '/' in last path char
if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
$v_path .= '/';
}
$v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
}
if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
}
else {
}
}
// ----- Look for 2 args
// Here we need to support the first historic synopsis of the
// method.
else {
// ----- Get the first argument
$v_path = $v_arg_list[0];
// ----- Look for the optional second argument
if ($v_size == 2) {
$v_remove_path = $v_arg_list[1];
}
else if ($v_size > 2) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
// ----- Return
return 0;
}
}
}
// ----- Trace
// ----- Trick
// Here I want to reuse extractByRule(), so I need to parse the $p_index
// with privParseOptions()
$v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
$v_options_trick = array();
$v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
array (PCLZIP_OPT_BY_INDEX => 'optional' ));
if ($v_result != 1) {
return 0;
}
$v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
// ----- Look for default option values
$this->privOptionDefaultThreshold($v_options);
// ----- Call the extracting fct
if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
return(0);
}
// ----- Return
return $p_list;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function :
// delete([$p_option, $p_option_value, ...])
// Description :
// This method removes files from the archive.
// If no parameters are given, then all the archive is emptied.
// Parameters :
// None or optional arguments.
// Options :
// PCLZIP_OPT_BY_INDEX :
// PCLZIP_OPT_BY_NAME :
// PCLZIP_OPT_BY_EREG :
// PCLZIP_OPT_BY_PREG :
// Return Values :
// 0 on failure,
// The list of the files which are still present in the archive.
// (see PclZip::listContent() for list entry format)
// --------------------------------------------------------------------------------
function delete()
{
$v_result=1;
// ----- Reset the error handler
$this->privErrorReset();
// ----- Check archive
if (!$this->privCheckFormat()) {
return(0);
}
// ----- Set default values
$v_options = array();
// ----- Look for variable options arguments
$v_size = func_num_args();
// ----- Look for arguments
if ($v_size > 0) {
// ----- Get the arguments
$v_arg_list = func_get_args();
// ----- Parse the options
$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
array (PCLZIP_OPT_BY_NAME => 'optional',
PCLZIP_OPT_BY_EREG => 'optional',
PCLZIP_OPT_BY_PREG => 'optional',
PCLZIP_OPT_BY_INDEX => 'optional' ));
if ($v_result != 1) {
return 0;
}
}
// ----- Magic quotes trick
$this->privDisableMagicQuotes();
// ----- Call the delete fct
$v_list = array();
if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
$this->privSwapBackMagicQuotes();
unset($v_list);
return(0);
}
// ----- Magic quotes trick
$this->privSwapBackMagicQuotes();
// ----- Return
return $v_list;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : deleteByIndex()
// Description :
// ***** Deprecated *****
// delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
// --------------------------------------------------------------------------------
function deleteByIndex($p_index)
{
$p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
// ----- Return
return $p_list;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : properties()
// Description :
// This method gives the properties of the archive.
// The properties are :
// nb : Number of files in the archive
// comment : Comment associated with the archive file
// status : not_exist, ok
// Parameters :
// None
// Return Values :
// 0 on failure,
// An array with the archive properties.
// --------------------------------------------------------------------------------
function properties()
{
// ----- Reset the error handler
$this->privErrorReset();
// ----- Magic quotes trick
$this->privDisableMagicQuotes();
// ----- Check archive
if (!$this->privCheckFormat()) {
$this->privSwapBackMagicQuotes();
return(0);
}
// ----- Default properties
$v_prop = array();
$v_prop['comment'] = '';
$v_prop['nb'] = 0;
$v_prop['status'] = 'not_exist';
// ----- Look if file exists
if (@is_file($this->zipname))
{
// ----- Open the zip file
if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
{
$this->privSwapBackMagicQuotes();
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
// ----- Return
return 0;
}
// ----- Read the central directory informations
$v_central_dir = array();
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
{
$this->privSwapBackMagicQuotes();
return 0;
}
// ----- Close the zip file
$this->privCloseFd();
// ----- Set the user attributes
$v_prop['comment'] = $v_central_dir['comment'];
$v_prop['nb'] = $v_central_dir['entries'];
$v_prop['status'] = 'ok';
}
// ----- Magic quotes trick
$this->privSwapBackMagicQuotes();
// ----- Return
return $v_prop;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : duplicate()
// Description :
// This method creates an archive by copying the content of an other one. If
// the archive already exist, it is replaced by the new one without any warning.
// Parameters :
// $p_archive : The filename of a valid archive, or
// a valid PclZip object.
// Return Values :
// 1 on success.
// 0 or a negative value on error (error code).
// --------------------------------------------------------------------------------
function duplicate($p_archive)
{
$v_result = 1;
// ----- Reset the error handler
$this->privErrorReset();
// ----- Look if the $p_archive is a PclZip object
if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
{
// ----- Duplicate the archive
$v_result = $this->privDuplicate($p_archive->zipname);
}
// ----- Look if the $p_archive is a string (so a filename)
else if (is_string($p_archive))
{
// ----- Check that $p_archive is a valid zip file
// TBC : Should also check the archive format
if (!is_file($p_archive)) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
$v_result = PCLZIP_ERR_MISSING_FILE;
}
else {
// ----- Duplicate the archive
$v_result = $this->privDuplicate($p_archive);
}
}
// ----- Invalid variable
else
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
$v_result = PCLZIP_ERR_INVALID_PARAMETER;
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : merge()
// Description :
// This method merge the $p_archive_to_add archive at the end of the current
// one ($this).
// If the archive ($this) does not exist, the merge becomes a duplicate.
// If the $p_archive_to_add archive does not exist, the merge is a success.
// Parameters :
// $p_archive_to_add : It can be directly the filename of a valid zip archive,
// or a PclZip object archive.
// Return Values :
// 1 on success,
// 0 or negative values on error (see below).
// --------------------------------------------------------------------------------
function merge($p_archive_to_add)
{
$v_result = 1;
// ----- Reset the error handler
$this->privErrorReset();
// ----- Check archive
if (!$this->privCheckFormat()) {
return(0);
}
// ----- Look if the $p_archive_to_add is a PclZip object
if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
{
// ----- Merge the archive
$v_result = $this->privMerge($p_archive_to_add);
}
// ----- Look if the $p_archive_to_add is a string (so a filename)
else if (is_string($p_archive_to_add))
{
// ----- Create a temporary archive
$v_object_archive = new PclZip($p_archive_to_add);
// ----- Merge the archive
$v_result = $this->privMerge($v_object_archive);
}
// ----- Invalid variable
else
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
$v_result = PCLZIP_ERR_INVALID_PARAMETER;
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : errorCode()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function errorCode()
{
if (PCLZIP_ERROR_EXTERNAL == 1) {
return(PclErrorCode());
}
else {
return($this->error_code);
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : errorName()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function errorName($p_with_code=false)
{
$v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
);
if (isset($v_name[$this->error_code])) {
$v_value = $v_name[$this->error_code];
}
else {
$v_value = 'NoName';
}
if ($p_with_code) {
return($v_value.' ('.$this->error_code.')');
}
else {
return($v_value);
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : errorInfo()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function errorInfo($p_full=false)
{
if (PCLZIP_ERROR_EXTERNAL == 1) {
return(PclErrorString());
}
else {
if ($p_full) {
return($this->errorName(true)." : ".$this->error_string);
}
else {
return($this->error_string." [code ".$this->error_code."]");
}
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
// ***** *****
// ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privCheckFormat()
// Description :
// This method check that the archive exists and is a valid zip archive.
// Several level of check exists. (futur)
// Parameters :
// $p_level : Level of check. Default 0.
// 0 : Check the first bytes (magic codes) (default value))
// 1 : 0 + Check the central directory (futur)
// 2 : 1 + Check each file header (futur)
// Return Values :
// true on success,
// false on error, the error code is set.
// --------------------------------------------------------------------------------
function privCheckFormat($p_level=0)
{
$v_result = true;
// ----- Reset the file system cache
clearstatcache();
// ----- Reset the error handler
$this->privErrorReset();
// ----- Look if the file exits
if (!is_file($this->zipname)) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
return(false);
}
// ----- Check that the file is readeable
if (!is_readable($this->zipname)) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
return(false);
}
// ----- Check the magic code
// TBC
// ----- Check the central header
// TBC
// ----- Check each file header
// TBC
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privParseOptions()
// Description :
// This internal methods reads the variable list of arguments ($p_options_list,
// $p_size) and generate an array with the options and values ($v_result_list).
// $v_requested_options contains the options that can be present and those that
// must be present.
// $v_requested_options is an array, with the option value as key, and 'optional',
// or 'mandatory' as value.
// Parameters :
// See above.
// Return Values :
// 1 on success.
// 0 on failure.
// --------------------------------------------------------------------------------
function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
{
$v_result=1;
// ----- Read the options
$i=0;
while ($i<$p_size) {
// ----- Check if the option is supported
if (!isset($v_requested_options[$p_options_list[$i]])) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
// ----- Return
return PclZip::errorCode();
}
// ----- Look for next option
switch ($p_options_list[$i]) {
// ----- Look for options that request a path value
case PCLZIP_OPT_PATH :
case PCLZIP_OPT_REMOVE_PATH :
case PCLZIP_OPT_ADD_PATH :
// ----- Check the number of parameters
if (($i+1) >= $p_size) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Get the value
$v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
$i++;
break;
case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
// ----- Check the number of parameters
if (($i+1) >= $p_size) {
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
return PclZip::errorCode();
}
// ----- Check for incompatible options
if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
return PclZip::errorCode();
}
// ----- Check the value
$v_value = $p_options_list[$i+1];
if ((!is_integer($v_value)) || ($v_value<0)) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
return PclZip::errorCode();
}
// ----- Get the value (and convert it in bytes)
$v_result_list[$p_options_list[$i]] = $v_value*1048576;
$i++;
break;
case PCLZIP_OPT_TEMP_FILE_ON :
// ----- Check for incompatible options
if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
return PclZip::errorCode();
}
$v_result_list[$p_options_list[$i]] = true;
break;
case PCLZIP_OPT_TEMP_FILE_OFF :
// ----- Check for incompatible options
if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
return PclZip::errorCode();
}
// ----- Check for incompatible options
if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
return PclZip::errorCode();
}
$v_result_list[$p_options_list[$i]] = true;
break;
case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
// ----- Check the number of parameters
if (($i+1) >= $p_size) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Get the value
if ( is_string($p_options_list[$i+1])
&& ($p_options_list[$i+1] != '')) {
$v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
$i++;
}
else {
}
break;
// ----- Look for options that request an array of string for value
case PCLZIP_OPT_BY_NAME :
// ----- Check the number of parameters
if (($i+1) >= $p_size) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Get the value
if (is_string($p_options_list[$i+1])) {
$v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
}
else if (is_array($p_options_list[$i+1])) {
$v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
}
else {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
$i++;
break;
// ----- Look for options that request an EREG or PREG expression
case PCLZIP_OPT_BY_EREG :
// ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
// to PCLZIP_OPT_BY_PREG
$p_options_list[$i] = PCLZIP_OPT_BY_PREG;
case PCLZIP_OPT_BY_PREG :
//case PCLZIP_OPT_CRYPT :
// ----- Check the number of parameters
if (($i+1) >= $p_size) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Get the value
if (is_string($p_options_list[$i+1])) {
$v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
}
else {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
$i++;
break;
// ----- Look for options that takes a string
case PCLZIP_OPT_COMMENT :
case PCLZIP_OPT_ADD_COMMENT :
case PCLZIP_OPT_PREPEND_COMMENT :
// ----- Check the number of parameters
if (($i+1) >= $p_size) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
"Missing parameter value for option '"
.PclZipUtilOptionText($p_options_list[$i])
."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Get the value
if (is_string($p_options_list[$i+1])) {
$v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
}
else {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
"Wrong parameter value for option '"
.PclZipUtilOptionText($p_options_list[$i])
."'");
// ----- Return
return PclZip::errorCode();
}
$i++;
break;
// ----- Look for options that request an array of index
case PCLZIP_OPT_BY_INDEX :
// ----- Check the number of parameters
if (($i+1) >= $p_size) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Get the value
$v_work_list = array();
if (is_string($p_options_list[$i+1])) {
// ----- Remove spaces
$p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
// ----- Parse items
$v_work_list = explode(",", $p_options_list[$i+1]);
}
else if (is_integer($p_options_list[$i+1])) {
$v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
}
else if (is_array($p_options_list[$i+1])) {
$v_work_list = $p_options_list[$i+1];
}
else {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Reduce the index list
// each index item in the list must be a couple with a start and
// an end value : [0,3], [5-5], [8-10], ...
// ----- Check the format of each item
$v_sort_flag=false;
$v_sort_value=0;
for ($j=0; $j<sizeof($v_work_list); $j++) {
// ----- Explode the item
$v_item_list = explode("-", $v_work_list[$j]);
$v_size_item_list = sizeof($v_item_list);
// ----- TBC : Here we might check that each item is a
// real integer ...
// ----- Look for single value
if ($v_size_item_list == 1) {
// ----- Set the option value
$v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
$v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
}
elseif ($v_size_item_list == 2) {
// ----- Set the option value
$v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
$v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
}
else {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Look for list sort
if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
$v_sort_flag=true;
// ----- TBC : An automatic sort should be writen ...
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
$v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
}
// ----- Sort the items
if ($v_sort_flag) {
// TBC : To Be Completed
}
// ----- Next option
$i++;
break;
// ----- Look for options that request no value
case PCLZIP_OPT_REMOVE_ALL_PATH :
case PCLZIP_OPT_EXTRACT_AS_STRING :
case PCLZIP_OPT_NO_COMPRESSION :
case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
case PCLZIP_OPT_REPLACE_NEWER :
case PCLZIP_OPT_STOP_ON_ERROR :
$v_result_list[$p_options_list[$i]] = true;
break;
// ----- Look for options that request an octal value
case PCLZIP_OPT_SET_CHMOD :
// ----- Check the number of parameters
if (($i+1) >= $p_size) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Get the value
$v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
$i++;
break;
// ----- Look for options that request a call-back
case PCLZIP_CB_PRE_EXTRACT :
case PCLZIP_CB_POST_EXTRACT :
case PCLZIP_CB_PRE_ADD :
case PCLZIP_CB_POST_ADD :
/* for futur use
case PCLZIP_CB_PRE_DELETE :
case PCLZIP_CB_POST_DELETE :
case PCLZIP_CB_PRE_LIST :
case PCLZIP_CB_POST_LIST :
*/
// ----- Check the number of parameters
if (($i+1) >= $p_size) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Get the value
$v_function_name = $p_options_list[$i+1];
// ----- Check that the value is a valid existing function
if (!function_exists($v_function_name)) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Set the attribute
$v_result_list[$p_options_list[$i]] = $v_function_name;
$i++;
break;
default :
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
"Unknown parameter '"
.$p_options_list[$i]."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Next options
$i++;
}
// ----- Look for mandatory options
if ($v_requested_options !== false) {
for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
// ----- Look for mandatory option
if ($v_requested_options[$key] == 'mandatory') {
// ----- Look if present
if (!isset($v_result_list[$key])) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
// ----- Return
return PclZip::errorCode();
}
}
}
}
// ----- Look for default values
if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privOptionDefaultThreshold()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privOptionDefaultThreshold(&$p_options)
{
$v_result=1;
if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
|| isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
return $v_result;
}
// ----- Get 'memory_limit' configuration value
$v_memory_limit = ini_get('memory_limit');
$v_memory_limit = trim($v_memory_limit);
$last = strtolower(substr($v_memory_limit, -1));
if($last == 'g')
//$v_memory_limit = $v_memory_limit*1024*1024*1024;
$v_memory_limit = $v_memory_limit*1073741824;
if($last == 'm')
//$v_memory_limit = $v_memory_limit*1024*1024;
$v_memory_limit = $v_memory_limit*1048576;
if($last == 'k')
$v_memory_limit = $v_memory_limit*1024;
$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
// ----- Sanity check : No threshold if value lower than 1M
if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privFileDescrParseAtt()
// Description :
// Parameters :
// Return Values :
// 1 on success.
// 0 on failure.
// --------------------------------------------------------------------------------
function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
{
$v_result=1;
// ----- For each file in the list check the attributes
foreach ($p_file_list as $v_key => $v_value) {
// ----- Check if the option is supported
if (!isset($v_requested_options[$v_key])) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
// ----- Return
return PclZip::errorCode();
}
// ----- Look for attribute
switch ($v_key) {
case PCLZIP_ATT_FILE_NAME :
if (!is_string($v_value)) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
return PclZip::errorCode();
}
$p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
if ($p_filedescr['filename'] == '') {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
return PclZip::errorCode();
}
break;
case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
if (!is_string($v_value)) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
return PclZip::errorCode();
}
$p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
if ($p_filedescr['new_short_name'] == '') {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
return PclZip::errorCode();
}
break;
case PCLZIP_ATT_FILE_NEW_FULL_NAME :
if (!is_string($v_value)) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
return PclZip::errorCode();
}
$p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
if ($p_filedescr['new_full_name'] == '') {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
return PclZip::errorCode();
}
break;
// ----- Look for options that takes a string
case PCLZIP_ATT_FILE_COMMENT :
if (!is_string($v_value)) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
return PclZip::errorCode();
}
$p_filedescr['comment'] = $v_value;
break;
case PCLZIP_ATT_FILE_MTIME :
if (!is_integer($v_value)) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
return PclZip::errorCode();
}
$p_filedescr['mtime'] = $v_value;
break;
case PCLZIP_ATT_FILE_CONTENT :
$p_filedescr['content'] = $v_value;
break;
default :
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
"Unknown parameter '".$v_key."'");
// ----- Return
return PclZip::errorCode();
}
// ----- Look for mandatory options
if ($v_requested_options !== false) {
for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
// ----- Look for mandatory option
if ($v_requested_options[$key] == 'mandatory') {
// ----- Look if present
if (!isset($p_file_list[$key])) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
return PclZip::errorCode();
}
}
}
}
// end foreach
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privFileDescrExpand()
// Description :
// This method look for each item of the list to see if its a file, a folder
// or a string to be added as file. For any other type of files (link, other)
// just ignore the item.
// Then prepare the information that will be stored for that file.
// When its a folder, expand the folder with all the files that are in that
// folder (recursively).
// Parameters :
// Return Values :
// 1 on success.
// 0 on failure.
// --------------------------------------------------------------------------------
function privFileDescrExpand(&$p_filedescr_list, &$p_options)
{
$v_result=1;
// ----- Create a result list
$v_result_list = array();
// ----- Look each entry
for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
// ----- Get filedescr
$v_descr = $p_filedescr_list[$i];
// ----- Reduce the filename
$v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
$v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
// ----- Look for real file or folder
if (file_exists($v_descr['filename'])) {
if (@is_file($v_descr['filename'])) {
$v_descr['type'] = 'file';
}
else if (@is_dir($v_descr['filename'])) {
$v_descr['type'] = 'folder';
}
else if (@is_link($v_descr['filename'])) {
// skip
continue;
}
else {
// skip
continue;
}
}
// ----- Look for string added as file
else if (isset($v_descr['content'])) {
$v_descr['type'] = 'virtual_file';
}
// ----- Missing file
else {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
// ----- Return
return PclZip::errorCode();
}
// ----- Calculate the stored filename
$this->privCalculateStoredFilename($v_descr, $p_options);
// ----- Add the descriptor in result list
$v_result_list[sizeof($v_result_list)] = $v_descr;
// ----- Look for folder
if ($v_descr['type'] == 'folder') {
// ----- List of items in folder
$v_dirlist_descr = array();
$v_dirlist_nb = 0;
if ($v_folder_handler = @opendir($v_descr['filename'])) {
while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
// ----- Skip '.' and '..'
if (($v_item_handler == '.') || ($v_item_handler == '..')) {
continue;
}
// ----- Compose the full filename
$v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
// ----- Look for different stored filename
// Because the name of the folder was changed, the name of the
// files/sub-folders also change
if (($v_descr['stored_filename'] != $v_descr['filename'])
&& (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
if ($v_descr['stored_filename'] != '') {
$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
}
else {
$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
}
}
$v_dirlist_nb++;
}
@closedir($v_folder_handler);
}
else {
// TBC : unable to open folder in read mode
}
// ----- Expand each element of the list
if ($v_dirlist_nb != 0) {
// ----- Expand
if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
return $v_result;
}
// ----- Concat the resulting list
$v_result_list = array_merge($v_result_list, $v_dirlist_descr);
}
else {
}
// ----- Free local array
unset($v_dirlist_descr);
}
}
// ----- Get the result list
$p_filedescr_list = $v_result_list;
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privCreate()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
{
$v_result=1;
$v_list_detail = array();
// ----- Magic quotes trick
$this->privDisableMagicQuotes();
// ----- Open the file in write mode
if (($v_result = $this->privOpenFd('wb')) != 1)
{
// ----- Return
return $v_result;
}
// ----- Add the list of files
$v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
// ----- Close
$this->privCloseFd();
// ----- Magic quotes trick
$this->privSwapBackMagicQuotes();
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privAdd()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
{
$v_result=1;
$v_list_detail = array();
// ----- Look if the archive exists or is empty
if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
{
// ----- Do a create
$v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
// ----- Return
return $v_result;
}
// ----- Magic quotes trick
$this->privDisableMagicQuotes();
// ----- Open the zip file
if (($v_result=$this->privOpenFd('rb')) != 1)
{
// ----- Magic quotes trick
$this->privSwapBackMagicQuotes();
// ----- Return
return $v_result;
}
// ----- Read the central directory informations
$v_central_dir = array();
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
{
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
return $v_result;
}
// ----- Go to beginning of File
@rewind($this->zip_fd);
// ----- Creates a temporay file
$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
// ----- Open the temporary file in write mode
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
{
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
// ----- Return
return PclZip::errorCode();
}
// ----- Copy the files from the archive to the temporary file
// TBC : Here I should better append the file and go back to erase the central dir
$v_size = $v_central_dir['offset'];
while ($v_size != 0)
{
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = fread($this->zip_fd, $v_read_size);
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Swap the file descriptor
// Here is a trick : I swap the temporary fd with the zip fd, in order to use
// the following methods on the temporary fil and not the real archive
$v_swap = $this->zip_fd;
$this->zip_fd = $v_zip_temp_fd;
$v_zip_temp_fd = $v_swap;
// ----- Add the files
$v_header_list = array();
if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
{
fclose($v_zip_temp_fd);
$this->privCloseFd();
@unlink($v_zip_temp_name);
$this->privSwapBackMagicQuotes();
// ----- Return
return $v_result;
}
// ----- Store the offset of the central dir
$v_offset = @ftell($this->zip_fd);
// ----- Copy the block of file headers from the old archive
$v_size = $v_central_dir['size'];
while ($v_size != 0)
{
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($v_zip_temp_fd, $v_read_size);
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Create the Central Dir files header
for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
{
// ----- Create the file header
if ($v_header_list[$i]['status'] == 'ok') {
if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
fclose($v_zip_temp_fd);
$this->privCloseFd();
@unlink($v_zip_temp_name);
$this->privSwapBackMagicQuotes();
// ----- Return
return $v_result;
}
$v_count++;
}
// ----- Transform the header to a 'usable' info
$this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
}
// ----- Zip file comment
$v_comment = $v_central_dir['comment'];
if (isset($p_options[PCLZIP_OPT_COMMENT])) {
$v_comment = $p_options[PCLZIP_OPT_COMMENT];
}
if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
$v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
}
if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
$v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
}
// ----- Calculate the size of the central header
$v_size = @ftell($this->zip_fd)-$v_offset;
// ----- Create the central dir footer
if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
{
// ----- Reset the file list
unset($v_header_list);
$this->privSwapBackMagicQuotes();
// ----- Return
return $v_result;
}
// ----- Swap back the file descriptor
$v_swap = $this->zip_fd;
$this->zip_fd = $v_zip_temp_fd;
$v_zip_temp_fd = $v_swap;
// ----- Close
$this->privCloseFd();
// ----- Close the temporary file
@fclose($v_zip_temp_fd);
// ----- Magic quotes trick
$this->privSwapBackMagicQuotes();
// ----- Delete the zip file
// TBC : I should test the result ...
@unlink($this->zipname);
// ----- Rename the temporary file
// TBC : I should test the result ...
//@rename($v_zip_temp_name, $this->zipname);
PclZipUtilRename($v_zip_temp_name, $this->zipname);
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privOpenFd()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function privOpenFd($p_mode)
{
$v_result=1;
// ----- Look if already open
if ($this->zip_fd != 0)
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
// ----- Return
return PclZip::errorCode();
}
// ----- Open the zip file
if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
// ----- Return
return PclZip::errorCode();
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privCloseFd()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function privCloseFd()
{
$v_result=1;
if ($this->zip_fd != 0)
@fclose($this->zip_fd);
$this->zip_fd = 0;
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privAddList()
// Description :
// $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
// different from the real path of the file. This is usefull if you want to have PclTar
// running in any directory, and memorize relative path from an other directory.
// Parameters :
// $p_list : An array containing the file or directory names to add in the tar
// $p_result_list : list of added files with their properties (specially the status field)
// $p_add_dir : Path to add in the filename path archived
// $p_remove_dir : Path to remove in the filename path archived
// Return Values :
// --------------------------------------------------------------------------------
// function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
{
$v_result=1;
// ----- Add the files
$v_header_list = array();
if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
{
// ----- Return
return $v_result;
}
// ----- Store the offset of the central dir
$v_offset = @ftell($this->zip_fd);
// ----- Create the Central Dir files header
for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
{
// ----- Create the file header
if ($v_header_list[$i]['status'] == 'ok') {
if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
// ----- Return
return $v_result;
}
$v_count++;
}
// ----- Transform the header to a 'usable' info
$this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
}
// ----- Zip file comment
$v_comment = '';
if (isset($p_options[PCLZIP_OPT_COMMENT])) {
$v_comment = $p_options[PCLZIP_OPT_COMMENT];
}
// ----- Calculate the size of the central header
$v_size = @ftell($this->zip_fd)-$v_offset;
// ----- Create the central dir footer
if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
{
// ----- Reset the file list
unset($v_header_list);
// ----- Return
return $v_result;
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privAddFileList()
// Description :
// Parameters :
// $p_filedescr_list : An array containing the file description
// or directory names to add in the zip
// $p_result_list : list of added files with their properties (specially the status field)
// Return Values :
// --------------------------------------------------------------------------------
function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
{
$v_result=1;
$v_header = array();
// ----- Recuperate the current number of elt in list
$v_nb = sizeof($p_result_list);
// ----- Loop on the files
for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
// ----- Format the filename
$p_filedescr_list[$j]['filename']
= PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
// ----- Skip empty file names
// TBC : Can this be possible ? not checked in DescrParseAtt ?
if ($p_filedescr_list[$j]['filename'] == "") {
continue;
}
// ----- Check the filename
if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
&& (!file_exists($p_filedescr_list[$j]['filename']))) {
PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
return PclZip::errorCode();
}
// ----- Look if it is a file or a dir with no all path remove option
// or a dir with all its path removed
// if ( (is_file($p_filedescr_list[$j]['filename']))
// || ( is_dir($p_filedescr_list[$j]['filename'])
if ( ($p_filedescr_list[$j]['type'] == 'file')
|| ($p_filedescr_list[$j]['type'] == 'virtual_file')
|| ( ($p_filedescr_list[$j]['type'] == 'folder')
&& ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
|| !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
) {
// ----- Add the file
$v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
$p_options);
if ($v_result != 1) {
return $v_result;
}
// ----- Store the file infos
$p_result_list[$v_nb++] = $v_header;
}
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privAddFile()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privAddFile($p_filedescr, &$p_header, &$p_options)
{
$v_result=1;
// ----- Working variable
$p_filename = $p_filedescr['filename'];
// TBC : Already done in the fileAtt check ... ?
if ($p_filename == "") {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
// ----- Return
return PclZip::errorCode();
}
// ----- Look for a stored different filename
/* TBC : Removed
if (isset($p_filedescr['stored_filename'])) {
$v_stored_filename = $p_filedescr['stored_filename'];
}
else {
$v_stored_filename = $p_filedescr['stored_filename'];
}
*/
// ----- Set the file properties
clearstatcache();
$p_header['version'] = 20;
$p_header['version_extracted'] = 10;
$p_header['flag'] = 0;
$p_header['compression'] = 0;
$p_header['crc'] = 0;
$p_header['compressed_size'] = 0;
$p_header['filename_len'] = strlen($p_filename);
$p_header['extra_len'] = 0;
$p_header['disk'] = 0;
$p_header['internal'] = 0;
$p_header['offset'] = 0;
$p_header['filename'] = $p_filename;
// TBC : Removed $p_header['stored_filename'] = $v_stored_filename;
$p_header['stored_filename'] = $p_filedescr['stored_filename'];
$p_header['extra'] = '';
$p_header['status'] = 'ok';
$p_header['index'] = -1;
// ----- Look for regular file
if ($p_filedescr['type']=='file') {
$p_header['external'] = 0x00000000;
$p_header['size'] = filesize($p_filename);
}
// ----- Look for regular folder
else if ($p_filedescr['type']=='folder') {
$p_header['external'] = 0x00000010;
$p_header['mtime'] = filemtime($p_filename);
$p_header['size'] = filesize($p_filename);
}
// ----- Look for virtual file
else if ($p_filedescr['type'] == 'virtual_file') {
$p_header['external'] = 0x00000000;
$p_header['size'] = strlen($p_filedescr['content']);
}
// ----- Look for filetime
if (isset($p_filedescr['mtime'])) {
$p_header['mtime'] = $p_filedescr['mtime'];
}
else if ($p_filedescr['type'] == 'virtual_file') {
$p_header['mtime'] = time();
}
else {
$p_header['mtime'] = filemtime($p_filename);
}
// ------ Look for file comment
if (isset($p_filedescr['comment'])) {
$p_header['comment_len'] = strlen($p_filedescr['comment']);
$p_header['comment'] = $p_filedescr['comment'];
}
else {
$p_header['comment_len'] = 0;
$p_header['comment'] = '';
}
// ----- Look for pre-add callback
if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
// ----- Generate a local information
$v_local_header = array();
$this->privConvertHeader2FileInfo($p_header, $v_local_header);
// ----- Call the callback
// Here I do not use call_user_func() because I need to send a reference to the
// header.
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
$v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
if ($v_result == 0) {
// ----- Change the file status
$p_header['status'] = "skipped";
$v_result = 1;
}
// ----- Update the informations
// Only some fields can be modified
if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
$p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
}
}
// ----- Look for empty stored filename
if ($p_header['stored_filename'] == "") {
$p_header['status'] = "filtered";
}
// ----- Check the path length
if (strlen($p_header['stored_filename']) > 0xFF) {
$p_header['status'] = 'filename_too_long';
}
// ----- Look if no error, or file not skipped
if ($p_header['status'] == 'ok') {
// ----- Look for a file
if ($p_filedescr['type'] == 'file') {
// ----- Look for using temporary file to zip
if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
&& (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
|| (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
&& ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
$v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
if ($v_result < PCLZIP_ERR_NO_ERROR) {
return $v_result;
}
}
// ----- Use "in memory" zip algo
else {
// ----- Open the source file
if (($v_file = @fopen($p_filename, "rb")) == 0) {
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
return PclZip::errorCode();
}
// ----- Read the file content
$v_content = @fread($v_file, $p_header['size']);
// ----- Close the file
@fclose($v_file);
// ----- Calculate the CRC
$p_header['crc'] = @crc32($v_content);
// ----- Look for no compression
if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
// ----- Set header parameters
$p_header['compressed_size'] = $p_header['size'];
$p_header['compression'] = 0;
}
// ----- Look for normal compression
else {
// ----- Compress the content
$v_content = @gzdeflate($v_content);
// ----- Set header parameters
$p_header['compressed_size'] = strlen($v_content);
$p_header['compression'] = 8;
}
// ----- Call the header generation
if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
@fclose($v_file);
return $v_result;
}
// ----- Write the compressed (or not) content
@fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
}
}
// ----- Look for a virtual file (a file from string)
else if ($p_filedescr['type'] == 'virtual_file') {
$v_content = $p_filedescr['content'];
// ----- Calculate the CRC
$p_header['crc'] = @crc32($v_content);
// ----- Look for no compression
if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
// ----- Set header parameters
$p_header['compressed_size'] = $p_header['size'];
$p_header['compression'] = 0;
}
// ----- Look for normal compression
else {
// ----- Compress the content
$v_content = @gzdeflate($v_content);
// ----- Set header parameters
$p_header['compressed_size'] = strlen($v_content);
$p_header['compression'] = 8;
}
// ----- Call the header generation
if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
@fclose($v_file);
return $v_result;
}
// ----- Write the compressed (or not) content
@fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
}
// ----- Look for a directory
else if ($p_filedescr['type'] == 'folder') {
// ----- Look for directory last '/'
if (@substr($p_header['stored_filename'], -1) != '/') {
$p_header['stored_filename'] .= '/';
}
// ----- Set the file properties
$p_header['size'] = 0;
//$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
$p_header['external'] = 0x00000010; // Value for a folder : to be checked
// ----- Call the header generation
if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
{
return $v_result;
}
}
}
// ----- Look for post-add callback
if (isset($p_options[PCLZIP_CB_POST_ADD])) {
// ----- Generate a local information
$v_local_header = array();
$this->privConvertHeader2FileInfo($p_header, $v_local_header);
// ----- Call the callback
// Here I do not use call_user_func() because I need to send a reference to the
// header.
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
$v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
if ($v_result == 0) {
// ----- Ignored
$v_result = 1;
}
// ----- Update the informations
// Nothing can be modified
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privAddFileUsingTempFile()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
{
$v_result=PCLZIP_ERR_NO_ERROR;
// ----- Working variable
$p_filename = $p_filedescr['filename'];
// ----- Open the source file
if (($v_file = @fopen($p_filename, "rb")) == 0) {
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
return PclZip::errorCode();
}
// ----- Creates a compressed temporary file
$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
fclose($v_file);
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
return PclZip::errorCode();
}
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
$v_size = filesize($p_filename);
while ($v_size != 0) {
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($v_file, $v_read_size);
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
@gzputs($v_file_compressed, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Close the file
@fclose($v_file);
@gzclose($v_file_compressed);
// ----- Check the minimum file size
if (filesize($v_gzip_temp_name) < 18) {
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
return PclZip::errorCode();
}
// ----- Extract the compressed attributes
if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
return PclZip::errorCode();
}
// ----- Read the gzip file header
$v_binary_data = @fread($v_file_compressed, 10);
$v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
// ----- Check some parameters
$v_data_header['os'] = bin2hex($v_data_header['os']);
// ----- Read the gzip file footer
@fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
$v_binary_data = @fread($v_file_compressed, 8);
$v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
// ----- Set the attributes
$p_header['compression'] = ord($v_data_header['cm']);
//$p_header['mtime'] = $v_data_header['mtime'];
$p_header['crc'] = $v_data_footer['crc'];
$p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
// ----- Close the file
@fclose($v_file_compressed);
// ----- Call the header generation
if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
return $v_result;
}
// ----- Add the compressed data
if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
{
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
return PclZip::errorCode();
}
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
fseek($v_file_compressed, 10);
$v_size = $p_header['compressed_size'];
while ($v_size != 0)
{
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($v_file_compressed, $v_read_size);
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Close the file
@fclose($v_file_compressed);
// ----- Unlink the temporary file
@unlink($v_gzip_temp_name);
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privCalculateStoredFilename()
// Description :
// Based on file descriptor properties and global options, this method
// calculate the filename that will be stored in the archive.
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privCalculateStoredFilename(&$p_filedescr, &$p_options)
{
$v_result=1;
// ----- Working variables
$p_filename = $p_filedescr['filename'];
if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
$p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
}
else {
$p_add_dir = '';
}
if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
$p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
}
else {
$p_remove_dir = '';
}
if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
$p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
}
else {
$p_remove_all_dir = 0;
}
// ----- Look for full name change
if (isset($p_filedescr['new_full_name'])) {
// ----- Remove drive letter if any
$v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
}
// ----- Look for path and/or short name change
else {
// ----- Look for short name change
// Its when we cahnge just the filename but not the path
if (isset($p_filedescr['new_short_name'])) {
$v_path_info = pathinfo($p_filename);
$v_dir = '';
if ($v_path_info['dirname'] != '') {
$v_dir = $v_path_info['dirname'].'/';
}
$v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
}
else {
// ----- Calculate the stored filename
$v_stored_filename = $p_filename;
}
// ----- Look for all path to remove
if ($p_remove_all_dir) {
$v_stored_filename = basename($p_filename);
}
// ----- Look for partial path remove
else if ($p_remove_dir != "") {
if (substr($p_remove_dir, -1) != '/')
$p_remove_dir .= "/";
if ( (substr($p_filename, 0, 2) == "./")
|| (substr($p_remove_dir, 0, 2) == "./")) {
if ( (substr($p_filename, 0, 2) == "./")
&& (substr($p_remove_dir, 0, 2) != "./")) {
$p_remove_dir = "./".$p_remove_dir;
}
if ( (substr($p_filename, 0, 2) != "./")
&& (substr($p_remove_dir, 0, 2) == "./")) {
$p_remove_dir = substr($p_remove_dir, 2);
}
}
$v_compare = PclZipUtilPathInclusion($p_remove_dir,
$v_stored_filename);
if ($v_compare > 0) {
if ($v_compare == 2) {
$v_stored_filename = "";
}
else {
$v_stored_filename = substr($v_stored_filename,
strlen($p_remove_dir));
}
}
}
// ----- Remove drive letter if any
$v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
// ----- Look for path to add
if ($p_add_dir != "") {
if (substr($p_add_dir, -1) == "/")
$v_stored_filename = $p_add_dir.$v_stored_filename;
else
$v_stored_filename = $p_add_dir."/".$v_stored_filename;
}
}
// ----- Filename (reduce the path of stored name)
$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
$p_filedescr['stored_filename'] = $v_stored_filename;
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privWriteFileHeader()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privWriteFileHeader(&$p_header)
{
$v_result=1;
// ----- Store the offset position of the file
$p_header['offset'] = ftell($this->zip_fd);
// ----- Transform UNIX mtime to DOS format mdate/mtime
$v_date = getdate($p_header['mtime']);
$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
// ----- Packed data
$v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
$p_header['version_extracted'], $p_header['flag'],
$p_header['compression'], $v_mtime, $v_mdate,
$p_header['crc'], $p_header['compressed_size'],
$p_header['size'],
strlen($p_header['stored_filename']),
$p_header['extra_len']);
// ----- Write the first 148 bytes of the header in the archive
fputs($this->zip_fd, $v_binary_data, 30);
// ----- Write the variable fields
if (strlen($p_header['stored_filename']) != 0)
{
fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
}
if ($p_header['extra_len'] != 0)
{
fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privWriteCentralFileHeader()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privWriteCentralFileHeader(&$p_header)
{
$v_result=1;
// TBC
//for(reset($p_header); $key = key($p_header); next($p_header)) {
//}
// ----- Transform UNIX mtime to DOS format mdate/mtime
$v_date = getdate($p_header['mtime']);
$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
// ----- Packed data
$v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
$p_header['version'], $p_header['version_extracted'],
$p_header['flag'], $p_header['compression'],
$v_mtime, $v_mdate, $p_header['crc'],
$p_header['compressed_size'], $p_header['size'],
strlen($p_header['stored_filename']),
$p_header['extra_len'], $p_header['comment_len'],
$p_header['disk'], $p_header['internal'],
$p_header['external'], $p_header['offset']);
// ----- Write the 42 bytes of the header in the zip file
fputs($this->zip_fd, $v_binary_data, 46);
// ----- Write the variable fields
if (strlen($p_header['stored_filename']) != 0)
{
fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
}
if ($p_header['extra_len'] != 0)
{
fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
}
if ($p_header['comment_len'] != 0)
{
fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privWriteCentralHeader()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
{
$v_result=1;
// ----- Packed data
$v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
$p_nb_entries, $p_size,
$p_offset, strlen($p_comment));
// ----- Write the 22 bytes of the header in the zip file
fputs($this->zip_fd, $v_binary_data, 22);
// ----- Write the variable fields
if (strlen($p_comment) != 0)
{
fputs($this->zip_fd, $p_comment, strlen($p_comment));
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privList()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privList(&$p_list)
{
$v_result=1;
// ----- Magic quotes trick
$this->privDisableMagicQuotes();
// ----- Open the zip file
if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
{
// ----- Magic quotes trick
$this->privSwapBackMagicQuotes();
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
// ----- Return
return PclZip::errorCode();
}
// ----- Read the central directory informations
$v_central_dir = array();
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
{
$this->privSwapBackMagicQuotes();
return $v_result;
}
// ----- Go to beginning of Central Dir
@rewind($this->zip_fd);
if (@fseek($this->zip_fd, $v_central_dir['offset']))
{
$this->privSwapBackMagicQuotes();
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
// ----- Return
return PclZip::errorCode();
}
// ----- Read each entry
for ($i=0; $i<$v_central_dir['entries']; $i++)
{
// ----- Read the file header
if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
{
$this->privSwapBackMagicQuotes();
return $v_result;
}
$v_header['index'] = $i;
// ----- Get the only interesting attributes
$this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
unset($v_header);
}
// ----- Close the zip file
$this->privCloseFd();
// ----- Magic quotes trick
$this->privSwapBackMagicQuotes();
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privConvertHeader2FileInfo()
// Description :
// This function takes the file informations from the central directory
// entries and extract the interesting parameters that will be given back.
// The resulting file infos are set in the array $p_info
// $p_info['filename'] : Filename with full path. Given by user (add),
// extracted in the filesystem (extract).
// $p_info['stored_filename'] : Stored filename in the archive.
// $p_info['size'] = Size of the file.
// $p_info['compressed_size'] = Compressed size of the file.
// $p_info['mtime'] = Last modification date of the file.
// $p_info['comment'] = Comment associated with the file.
// $p_info['folder'] = true/false : indicates if the entry is a folder or not.
// $p_info['status'] = status of the action on the file.
// $p_info['crc'] = CRC of the file content.
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privConvertHeader2FileInfo($p_header, &$p_info)
{
$v_result=1;
// ----- Get the interesting attributes
$v_temp_path = PclZipUtilPathReduction($p_header['filename']);
$p_info['filename'] = $v_temp_path;
$v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
$p_info['stored_filename'] = $v_temp_path;
$p_info['size'] = $p_header['size'];
$p_info['compressed_size'] = $p_header['compressed_size'];
$p_info['mtime'] = $p_header['mtime'];
$p_info['comment'] = $p_header['comment'];
$p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
$p_info['index'] = $p_header['index'];
$p_info['status'] = $p_header['status'];
$p_info['crc'] = $p_header['crc'];
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privExtractByRule()
// Description :
// Extract a file or directory depending of rules (by index, by name, ...)
// Parameters :
// $p_file_list : An array where will be placed the properties of each
// extracted file
// $p_path : Path to add while writing the extracted files
// $p_remove_path : Path to remove (from the file memorized path) while writing the
// extracted files. If the path does not match the file path,
// the file is extracted with its memorized path.
// $p_remove_path does not apply to 'list' mode.
// $p_path and $p_remove_path are commulative.
// Return Values :
// 1 on success,0 or less on error (see error code list)
// --------------------------------------------------------------------------------
function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
{
$v_result=1;
// ----- Magic quotes trick
$this->privDisableMagicQuotes();
// ----- Check the path
if ( ($p_path == "")
|| ( (substr($p_path, 0, 1) != "/")
&& (substr($p_path, 0, 3) != "../")
&& (substr($p_path,1,2)!=":/")))
$p_path = "./".$p_path;
// ----- Reduce the path last (and duplicated) '/'
if (($p_path != "./") && ($p_path != "/"))
{
// ----- Look for the path end '/'
while (substr($p_path, -1) == "/")
{
$p_path = substr($p_path, 0, strlen($p_path)-1);
}
}
// ----- Look for path to remove format (should end by /)
if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
{
$p_remove_path .= '/';
}
$p_remove_path_size = strlen($p_remove_path);
// ----- Open the zip file
if (($v_result = $this->privOpenFd('rb')) != 1)
{
$this->privSwapBackMagicQuotes();
return $v_result;
}
// ----- Read the central directory informations
$v_central_dir = array();
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
{
// ----- Close the zip file
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
return $v_result;
}
// ----- Start at beginning of Central Dir
$v_pos_entry = $v_central_dir['offset'];
// ----- Read each entry
$j_start = 0;
for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
{
// ----- Read next Central dir entry
@rewind($this->zip_fd);
if (@fseek($this->zip_fd, $v_pos_entry))
{
// ----- Close the zip file
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
// ----- Return
return PclZip::errorCode();
}
// ----- Read the file header
$v_header = array();
if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
{
// ----- Close the zip file
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
return $v_result;
}
// ----- Store the index
$v_header['index'] = $i;
// ----- Store the file position
$v_pos_entry = ftell($this->zip_fd);
// ----- Look for the specific extract rules
$v_extract = false;
// ----- Look for extract by name rule
if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
&& ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
// ----- Look if the filename is in the list
for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
// ----- Look for a directory
if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
// ----- Look if the directory is in the filename path
if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
&& (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
$v_extract = true;
}
}
// ----- Look for a filename
elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
$v_extract = true;
}
}
}
// ----- Look for extract by ereg rule
// ereg() is deprecated with PHP 5.3
/*
else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
$v_extract = true;
}
}
*/
// ----- Look for extract by preg rule
else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
&& ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
$v_extract = true;
}
}
// ----- Look for extract by index rule
else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
&& ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
// ----- Look if the index is in the list
for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
$v_extract = true;
}
if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
$j_start = $j+1;
}
if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
break;
}
}
}
// ----- Look for no rule, which means extract all the archive
else {
$v_extract = true;
}
// ----- Check compression method
if ( ($v_extract)
&& ( ($v_header['compression'] != 8)
&& ($v_header['compression'] != 0))) {
$v_header['status'] = 'unsupported_compression';
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
$this->privSwapBackMagicQuotes();
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
"Filename '".$v_header['stored_filename']."' is "
."compressed by an unsupported compression "
."method (".$v_header['compression'].") ");
return PclZip::errorCode();
}
}
// ----- Check encrypted files
if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
$v_header['status'] = 'unsupported_encryption';
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
$this->privSwapBackMagicQuotes();
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
"Unsupported encryption for "
." filename '".$v_header['stored_filename']
."'");
return PclZip::errorCode();
}
}
// ----- Look for real extraction
if (($v_extract) && ($v_header['status'] != 'ok')) {
$v_result = $this->privConvertHeader2FileInfo($v_header,
$p_file_list[$v_nb_extracted++]);
if ($v_result != 1) {
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
return $v_result;
}
$v_extract = false;
}
// ----- Look for real extraction
if ($v_extract)
{
// ----- Go to the file position
@rewind($this->zip_fd);
if (@fseek($this->zip_fd, $v_header['offset']))
{
// ----- Close the zip file
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
// ----- Return
return PclZip::errorCode();
}
// ----- Look for extraction as string
if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
$v_string = '';
// ----- Extracting the file
$v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
if ($v_result1 < 1) {
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
return $v_result1;
}
// ----- Get the only interesting attributes
if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
{
// ----- Close the zip file
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
return $v_result;
}
// ----- Set the file content
$p_file_list[$v_nb_extracted]['content'] = $v_string;
// ----- Next extracted file
$v_nb_extracted++;
// ----- Look for user callback abort
if ($v_result1 == 2) {
break;
}
}
// ----- Look for extraction in standard output
elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
&& ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
// ----- Extracting the file in standard output
$v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
if ($v_result1 < 1) {
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
return $v_result1;
}
// ----- Get the only interesting attributes
if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
return $v_result;
}
// ----- Look for user callback abort
if ($v_result1 == 2) {
break;
}
}
// ----- Look for normal extraction
else {
// ----- Extracting the file
$v_result1 = $this->privExtractFile($v_header,
$p_path, $p_remove_path,
$p_remove_all_path,
$p_options);
if ($v_result1 < 1) {
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
return $v_result1;
}
// ----- Get the only interesting attributes
if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
{
// ----- Close the zip file
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
return $v_result;
}
// ----- Look for user callback abort
if ($v_result1 == 2) {
break;
}
}
}
}
// ----- Close the zip file
$this->privCloseFd();
$this->privSwapBackMagicQuotes();
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privExtractFile()
// Description :
// Parameters :
// Return Values :
//
// 1 : ... ?
// PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
// --------------------------------------------------------------------------------
function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
{
$v_result=1;
// ----- Read the file header
if (($v_result = $this->privReadFileHeader($v_header)) != 1)
{
// ----- Return
return $v_result;
}
// ----- Check that the file header is coherent with $p_entry info
if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
// TBC
}
// ----- Look for all path to remove
if ($p_remove_all_path == true) {
// ----- Look for folder entry that not need to be extracted
if (($p_entry['external']&0x00000010)==0x00000010) {
$p_entry['status'] = "filtered";
return $v_result;
}
// ----- Get the basename of the path
$p_entry['filename'] = basename($p_entry['filename']);
}
// ----- Look for path to remove
else if ($p_remove_path != "")
{
if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
{
// ----- Change the file status
$p_entry['status'] = "filtered";
// ----- Return
return $v_result;
}
$p_remove_path_size = strlen($p_remove_path);
if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
{
// ----- Remove the path
$p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
}
}
// ----- Add the path
if ($p_path != '') {
$p_entry['filename'] = $p_path."/".$p_entry['filename'];
}
// ----- Check a base_dir_restriction
if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
$v_inclusion
= PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
$p_entry['filename']);
if ($v_inclusion == 0) {
PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
"Filename '".$p_entry['filename']."' is "
."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
return PclZip::errorCode();
}
}
// ----- Look for pre-extract callback
if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
// ----- Generate a local information
$v_local_header = array();
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
// ----- Call the callback
// Here I do not use call_user_func() because I need to send a reference to the
// header.
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
$v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
if ($v_result == 0) {
// ----- Change the file status
$p_entry['status'] = "skipped";
$v_result = 1;
}
// ----- Look for abort result
if ($v_result == 2) {
// ----- This status is internal and will be changed in 'skipped'
$p_entry['status'] = "aborted";
$v_result = PCLZIP_ERR_USER_ABORTED;
}
// ----- Update the informations
// Only some fields can be modified
$p_entry['filename'] = $v_local_header['filename'];
}
// ----- Look if extraction should be done
if ($p_entry['status'] == 'ok') {
// ----- Look for specific actions while the file exist
if (file_exists($p_entry['filename']))
{
// ----- Look if file is a directory
if (is_dir($p_entry['filename']))
{
// ----- Change the file status
$p_entry['status'] = "already_a_directory";
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
// For historical reason first PclZip implementation does not stop
// when this kind of error occurs.
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
"Filename '".$p_entry['filename']."' is "
."already used by an existing directory");
return PclZip::errorCode();
}
}
// ----- Look if file is write protected
else if (!is_writeable($p_entry['filename']))
{
// ----- Change the file status
$p_entry['status'] = "write_protected";
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
// For historical reason first PclZip implementation does not stop
// when this kind of error occurs.
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
"Filename '".$p_entry['filename']."' exists "
."and is write protected");
return PclZip::errorCode();
}
}
// ----- Look if the extracted file is older
else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
{
// ----- Change the file status
if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
&& ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
}
else {
$p_entry['status'] = "newer_exist";
// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
// For historical reason first PclZip implementation does not stop
// when this kind of error occurs.
if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
"Newer version of '".$p_entry['filename']."' exists "
."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
return PclZip::errorCode();
}
}
}
else {
}
}
// ----- Check the directory availability and create it if necessary
else {
if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
$v_dir_to_check = $p_entry['filename'];
else if (!strstr($p_entry['filename'], "/"))
$v_dir_to_check = "";
else
$v_dir_to_check = dirname($p_entry['filename']);
if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
// ----- Change the file status
$p_entry['status'] = "path_creation_fail";
// ----- Return
//return $v_result;
$v_result = 1;
}
}
}
// ----- Look if extraction should be done
if ($p_entry['status'] == 'ok') {
// ----- Do the extraction (if not a folder)
if (!(($p_entry['external']&0x00000010)==0x00000010))
{
// ----- Look for not compressed file
if ($p_entry['compression'] == 0) {
// ----- Opening destination file
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
{
// ----- Change the file status
$p_entry['status'] = "write_error";
// ----- Return
return $v_result;
}
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
$v_size = $p_entry['compressed_size'];
while ($v_size != 0)
{
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($this->zip_fd, $v_read_size);
/* Try to speed up the code
$v_binary_data = pack('a'.$v_read_size, $v_buffer);
@fwrite($v_dest_file, $v_binary_data, $v_read_size);
*/
@fwrite($v_dest_file, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Closing the destination file
fclose($v_dest_file);
// ----- Change the file mtime
touch($p_entry['filename'], $p_entry['mtime']);
}
else {
// ----- TBC
// Need to be finished
if (($p_entry['flag'] & 1) == 1) {
PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
return PclZip::errorCode();
}
// ----- Look for using temporary file to unzip
if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
&& (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
|| (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
&& ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
$v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
if ($v_result < PCLZIP_ERR_NO_ERROR) {
return $v_result;
}
}
// ----- Look for extract in memory
else {
// ----- Read the compressed file in a buffer (one shot)
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
// ----- Decompress the file
$v_file_content = @gzinflate($v_buffer);
unset($v_buffer);
if ($v_file_content === FALSE) {
// ----- Change the file status
// TBC
$p_entry['status'] = "error";
return $v_result;
}
// ----- Opening destination file
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
// ----- Change the file status
$p_entry['status'] = "write_error";
return $v_result;
}
// ----- Write the uncompressed data
@fwrite($v_dest_file, $v_file_content, $p_entry['size']);
unset($v_file_content);
// ----- Closing the destination file
@fclose($v_dest_file);
}
// ----- Change the file mtime
@touch($p_entry['filename'], $p_entry['mtime']);
}
// ----- Look for chmod option
if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
// ----- Change the mode of the file
@chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
}
}
}
// ----- Change abort status
if ($p_entry['status'] == "aborted") {
$p_entry['status'] = "skipped";
}
// ----- Look for post-extract callback
elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
// ----- Generate a local information
$v_local_header = array();
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
// ----- Call the callback
// Here I do not use call_user_func() because I need to send a reference to the
// header.
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
$v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
// ----- Look for abort result
if ($v_result == 2) {
$v_result = PCLZIP_ERR_USER_ABORTED;
}
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privExtractFileUsingTempFile()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privExtractFileUsingTempFile(&$p_entry, &$p_options)
{
$v_result=1;
// ----- Creates a temporary file
$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
fclose($v_file);
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
return PclZip::errorCode();
}
// ----- Write gz file format header
$v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
@fwrite($v_dest_file, $v_binary_data, 10);
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
$v_size = $p_entry['compressed_size'];
while ($v_size != 0)
{
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($this->zip_fd, $v_read_size);
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
@fwrite($v_dest_file, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Write gz file format footer
$v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
@fwrite($v_dest_file, $v_binary_data, 8);
// ----- Close the temporary file
@fclose($v_dest_file);
// ----- Opening destination file
if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
$p_entry['status'] = "write_error";
return $v_result;
}
// ----- Open the temporary gz file
if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
@fclose($v_dest_file);
$p_entry['status'] = "read_error";
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
return PclZip::errorCode();
}
// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
$v_size = $p_entry['size'];
while ($v_size != 0) {
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @gzread($v_src_file, $v_read_size);
//$v_binary_data = pack('a'.$v_read_size, $v_buffer);
@fwrite($v_dest_file, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
@fclose($v_dest_file);
@gzclose($v_src_file);
// ----- Delete the temporary file
@unlink($v_gzip_temp_name);
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privExtractFileInOutput()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privExtractFileInOutput(&$p_entry, &$p_options)
{
$v_result=1;
// ----- Read the file header
if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
return $v_result;
}
// ----- Check that the file header is coherent with $p_entry info
if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
// TBC
}
// ----- Look for pre-extract callback
if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
// ----- Generate a local information
$v_local_header = array();
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
// ----- Call the callback
// Here I do not use call_user_func() because I need to send a reference to the
// header.
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
$v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
if ($v_result == 0) {
// ----- Change the file status
$p_entry['status'] = "skipped";
$v_result = 1;
}
// ----- Look for abort result
if ($v_result == 2) {
// ----- This status is internal and will be changed in 'skipped'
$p_entry['status'] = "aborted";
$v_result = PCLZIP_ERR_USER_ABORTED;
}
// ----- Update the informations
// Only some fields can be modified
$p_entry['filename'] = $v_local_header['filename'];
}
// ----- Trace
// ----- Look if extraction should be done
if ($p_entry['status'] == 'ok') {
// ----- Do the extraction (if not a folder)
if (!(($p_entry['external']&0x00000010)==0x00000010)) {
// ----- Look for not compressed file
if ($p_entry['compressed_size'] == $p_entry['size']) {
// ----- Read the file in a buffer (one shot)
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
// ----- Send the file to the output
echo $v_buffer;
unset($v_buffer);
}
else {
// ----- Read the compressed file in a buffer (one shot)
$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
// ----- Decompress the file
$v_file_content = gzinflate($v_buffer);
unset($v_buffer);
// ----- Send the file to the output
echo $v_file_content;
unset($v_file_content);
}
}
}
// ----- Change abort status
if ($p_entry['status'] == "aborted") {
$p_entry['status'] = "skipped";
}
// ----- Look for post-extract callback
elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
// ----- Generate a local information
$v_local_header = array();
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
// ----- Call the callback
// Here I do not use call_user_func() because I need to send a reference to the
// header.
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
$v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
// ----- Look for abort result
if ($v_result == 2) {
$v_result = PCLZIP_ERR_USER_ABORTED;
}
}
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privExtractFileAsString()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
{
$v_result=1;
// ----- Read the file header
$v_header = array();
if (($v_result = $this->privReadFileHeader($v_header)) != 1)
{
// ----- Return
return $v_result;
}
// ----- Check that the file header is coherent with $p_entry info
if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
// TBC
}
// ----- Look for pre-extract callback
if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
// ----- Generate a local information
$v_local_header = array();
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
// ----- Call the callback
// Here I do not use call_user_func() because I need to send a reference to the
// header.
// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
$v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
if ($v_result == 0) {
// ----- Change the file status
$p_entry['status'] = "skipped";
$v_result = 1;
}
// ----- Look for abort result
if ($v_result == 2) {
// ----- This status is internal and will be changed in 'skipped'
$p_entry['status'] = "aborted";
$v_result = PCLZIP_ERR_USER_ABORTED;
}
// ----- Update the informations
// Only some fields can be modified
$p_entry['filename'] = $v_local_header['filename'];
}
// ----- Look if extraction should be done
if ($p_entry['status'] == 'ok') {
// ----- Do the extraction (if not a folder)
if (!(($p_entry['external']&0x00000010)==0x00000010)) {
// ----- Look for not compressed file
// if ($p_entry['compressed_size'] == $p_entry['size'])
if ($p_entry['compression'] == 0) {
// ----- Reading the file
$p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
}
else {
// ----- Reading the file
$v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
// ----- Decompress the file
if (($p_string = @gzinflate($v_data)) === FALSE) {
// TBC
}
}
// ----- Trace
}
else {
// TBC : error : can not extract a folder in a string
}
}
// ----- Change abort status
if ($p_entry['status'] == "aborted") {
$p_entry['status'] = "skipped";
}
// ----- Look for post-extract callback
elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
// ----- Generate a local information
$v_local_header = array();
$this->privConvertHeader2FileInfo($p_entry, $v_local_header);
// ----- Swap the content to header
$v_local_header['content'] = $p_string;
$p_string = '';
// ----- Call the callback
// Here I do not use call_user_func() because I need to send a reference to the
// header.
// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
$v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
// ----- Swap back the content to header
$p_string = $v_local_header['content'];
unset($v_local_header['content']);
// ----- Look for abort result
if ($v_result == 2) {
$v_result = PCLZIP_ERR_USER_ABORTED;
}
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privReadFileHeader()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privReadFileHeader(&$p_header)
{
$v_result=1;
// ----- Read the 4 bytes signature
$v_binary_data = @fread($this->zip_fd, 4);
$v_data = unpack('Vid', $v_binary_data);
// ----- Check signature
if ($v_data['id'] != 0x04034b50)
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
// ----- Return
return PclZip::errorCode();
}
// ----- Read the first 42 bytes of the header
$v_binary_data = fread($this->zip_fd, 26);
// ----- Look for invalid block size
if (strlen($v_binary_data) != 26)
{
$p_header['filename'] = "";
$p_header['status'] = "invalid_header";
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
// ----- Return
return PclZip::errorCode();
}
// ----- Extract the values
$v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
// ----- Get filename
$p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
// ----- Get extra_fields
if ($v_data['extra_len'] != 0) {
$p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
}
else {
$p_header['extra'] = '';
}
// ----- Extract properties
$p_header['version_extracted'] = $v_data['version'];
$p_header['compression'] = $v_data['compression'];
$p_header['size'] = $v_data['size'];
$p_header['compressed_size'] = $v_data['compressed_size'];
$p_header['crc'] = $v_data['crc'];
$p_header['flag'] = $v_data['flag'];
$p_header['filename_len'] = $v_data['filename_len'];
// ----- Recuperate date in UNIX format
$p_header['mdate'] = $v_data['mdate'];
$p_header['mtime'] = $v_data['mtime'];
if ($p_header['mdate'] && $p_header['mtime'])
{
// ----- Extract time
$v_hour = ($p_header['mtime'] & 0xF800) >> 11;
$v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
$v_seconde = ($p_header['mtime'] & 0x001F)*2;
// ----- Extract date
$v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
$v_month = ($p_header['mdate'] & 0x01E0) >> 5;
$v_day = $p_header['mdate'] & 0x001F;
// ----- Get UNIX date format
$p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
}
else
{
$p_header['mtime'] = time();
}
// TBC
//for(reset($v_data); $key = key($v_data); next($v_data)) {
//}
// ----- Set the stored filename
$p_header['stored_filename'] = $p_header['filename'];
// ----- Set the status field
$p_header['status'] = "ok";
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privReadCentralFileHeader()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privReadCentralFileHeader(&$p_header)
{
$v_result=1;
// ----- Read the 4 bytes signature
$v_binary_data = @fread($this->zip_fd, 4);
$v_data = unpack('Vid', $v_binary_data);
// ----- Check signature
if ($v_data['id'] != 0x02014b50)
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
// ----- Return
return PclZip::errorCode();
}
// ----- Read the first 42 bytes of the header
$v_binary_data = fread($this->zip_fd, 42);
// ----- Look for invalid block size
if (strlen($v_binary_data) != 42)
{
$p_header['filename'] = "";
$p_header['status'] = "invalid_header";
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
// ----- Return
return PclZip::errorCode();
}
// ----- Extract the values
$p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
// ----- Get filename
if ($p_header['filename_len'] != 0)
$p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
else
$p_header['filename'] = '';
// ----- Get extra
if ($p_header['extra_len'] != 0)
$p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
else
$p_header['extra'] = '';
// ----- Get comment
if ($p_header['comment_len'] != 0)
$p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
else
$p_header['comment'] = '';
// ----- Extract properties
// ----- Recuperate date in UNIX format
//if ($p_header['mdate'] && $p_header['mtime'])
// TBC : bug : this was ignoring time with 0/0/0
if (1)
{
// ----- Extract time
$v_hour = ($p_header['mtime'] & 0xF800) >> 11;
$v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
$v_seconde = ($p_header['mtime'] & 0x001F)*2;
// ----- Extract date
$v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
$v_month = ($p_header['mdate'] & 0x01E0) >> 5;
$v_day = $p_header['mdate'] & 0x001F;
// ----- Get UNIX date format
$p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
}
else
{
$p_header['mtime'] = time();
}
// ----- Set the stored filename
$p_header['stored_filename'] = $p_header['filename'];
// ----- Set default status to ok
$p_header['status'] = 'ok';
// ----- Look if it is a directory
if (substr($p_header['filename'], -1) == '/') {
//$p_header['external'] = 0x41FF0010;
$p_header['external'] = 0x00000010;
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privCheckFileHeaders()
// Description :
// Parameters :
// Return Values :
// 1 on success,
// 0 on error;
// --------------------------------------------------------------------------------
function privCheckFileHeaders(&$p_local_header, &$p_central_header)
{
$v_result=1;
// ----- Check the static values
// TBC
if ($p_local_header['filename'] != $p_central_header['filename']) {
}
if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
}
if ($p_local_header['flag'] != $p_central_header['flag']) {
}
if ($p_local_header['compression'] != $p_central_header['compression']) {
}
if ($p_local_header['mtime'] != $p_central_header['mtime']) {
}
if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
}
// ----- Look for flag bit 3
if (($p_local_header['flag'] & 8) == 8) {
$p_local_header['size'] = $p_central_header['size'];
$p_local_header['compressed_size'] = $p_central_header['compressed_size'];
$p_local_header['crc'] = $p_central_header['crc'];
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privReadEndCentralDir()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privReadEndCentralDir(&$p_central_dir)
{
$v_result=1;
// ----- Go to the end of the zip file
$v_size = filesize($this->zipname);
@fseek($this->zip_fd, $v_size);
if (@ftell($this->zip_fd) != $v_size)
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
// ----- Return
return PclZip::errorCode();
}
// ----- First try : look if this is an archive with no commentaries (most of the time)
// in this case the end of central dir is at 22 bytes of the file end
$v_found = 0;
if ($v_size > 26) {
@fseek($this->zip_fd, $v_size-22);
if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
// ----- Return
return PclZip::errorCode();
}
// ----- Read for bytes
$v_binary_data = @fread($this->zip_fd, 4);
$v_data = @unpack('Vid', $v_binary_data);
// ----- Check signature
if ($v_data['id'] == 0x06054b50) {
$v_found = 1;
}
$v_pos = ftell($this->zip_fd);
}
// ----- Go back to the maximum possible size of the Central Dir End Record
if (!$v_found) {
$v_maximum_size = 65557; // 0xFFFF + 22;
if ($v_maximum_size > $v_size)
$v_maximum_size = $v_size;
@fseek($this->zip_fd, $v_size-$v_maximum_size);
if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
// ----- Return
return PclZip::errorCode();
}
// ----- Read byte per byte in order to find the signature
$v_pos = ftell($this->zip_fd);
$v_bytes = 0x00000000;
while ($v_pos < $v_size)
{
// ----- Read a byte
$v_byte = @fread($this->zip_fd, 1);
// ----- Add the byte
//$v_bytes = ($v_bytes << 8) | Ord($v_byte);
// Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
// Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
$v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
// ----- Compare the bytes
if ($v_bytes == 0x504b0506)
{
$v_pos++;
break;
}
$v_pos++;
}
// ----- Look if not found end of central dir
if ($v_pos == $v_size)
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
// ----- Return
return PclZip::errorCode();
}
}
// ----- Read the first 18 bytes of the header
$v_binary_data = fread($this->zip_fd, 18);
// ----- Look for invalid block size
if (strlen($v_binary_data) != 18)
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
// ----- Return
return PclZip::errorCode();
}
// ----- Extract the values
$v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
// ----- Check the global size
if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
// ----- Removed in release 2.2 see readme file
// The check of the file size is a little too strict.
// Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
// While decrypted, zip has training 0 bytes
if (0) {
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
'The central dir is not at the end of the archive.'
.' Some trailing bytes exists after the archive.');
// ----- Return
return PclZip::errorCode();
}
}
// ----- Get comment
if ($v_data['comment_size'] != 0) {
$p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
}
else
$p_central_dir['comment'] = '';
$p_central_dir['entries'] = $v_data['entries'];
$p_central_dir['disk_entries'] = $v_data['disk_entries'];
$p_central_dir['offset'] = $v_data['offset'];
$p_central_dir['size'] = $v_data['size'];
$p_central_dir['disk'] = $v_data['disk'];
$p_central_dir['disk_start'] = $v_data['disk_start'];
// TBC
//for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
//}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privDeleteByRule()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privDeleteByRule(&$p_result_list, &$p_options)
{
$v_result=1;
$v_list_detail = array();
// ----- Open the zip file
if (($v_result=$this->privOpenFd('rb')) != 1)
{
// ----- Return
return $v_result;
}
// ----- Read the central directory informations
$v_central_dir = array();
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
{
$this->privCloseFd();
return $v_result;
}
// ----- Go to beginning of File
@rewind($this->zip_fd);
// ----- Scan all the files
// ----- Start at beginning of Central Dir
$v_pos_entry = $v_central_dir['offset'];
@rewind($this->zip_fd);
if (@fseek($this->zip_fd, $v_pos_entry))
{
// ----- Close the zip file
$this->privCloseFd();
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
// ----- Return
return PclZip::errorCode();
}
// ----- Read each entry
$v_header_list = array();
$j_start = 0;
for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
{
// ----- Read the file header
$v_header_list[$v_nb_extracted] = array();
if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
{
// ----- Close the zip file
$this->privCloseFd();
return $v_result;
}
// ----- Store the index
$v_header_list[$v_nb_extracted]['index'] = $i;
// ----- Look for the specific extract rules
$v_found = false;
// ----- Look for extract by name rule
if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
&& ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
// ----- Look if the filename is in the list
for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
// ----- Look for a directory
if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
// ----- Look if the directory is in the filename path
if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
&& (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
$v_found = true;
}
elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
&& ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
$v_found = true;
}
}
// ----- Look for a filename
elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
$v_found = true;
}
}
}
// ----- Look for extract by ereg rule
// ereg() is deprecated with PHP 5.3
/*
else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
&& ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
$v_found = true;
}
}
*/
// ----- Look for extract by preg rule
else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
&& ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
$v_found = true;
}
}
// ----- Look for extract by index rule
else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
&& ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
// ----- Look if the index is in the list
for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
$v_found = true;
}
if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
$j_start = $j+1;
}
if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
break;
}
}
}
else {
$v_found = true;
}
// ----- Look for deletion
if ($v_found)
{
unset($v_header_list[$v_nb_extracted]);
}
else
{
$v_nb_extracted++;
}
}
// ----- Look if something need to be deleted
if ($v_nb_extracted > 0) {
// ----- Creates a temporay file
$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
// ----- Creates a temporary zip archive
$v_temp_zip = new PclZip($v_zip_temp_name);
// ----- Open the temporary zip file in write mode
if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
$this->privCloseFd();
// ----- Return
return $v_result;
}
// ----- Look which file need to be kept
for ($i=0; $i<sizeof($v_header_list); $i++) {
// ----- Calculate the position of the header
@rewind($this->zip_fd);
if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
// ----- Close the zip file
$this->privCloseFd();
$v_temp_zip->privCloseFd();
@unlink($v_zip_temp_name);
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
// ----- Return
return PclZip::errorCode();
}
// ----- Read the file header
$v_local_header = array();
if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
// ----- Close the zip file
$this->privCloseFd();
$v_temp_zip->privCloseFd();
@unlink($v_zip_temp_name);
// ----- Return
return $v_result;
}
// ----- Check that local file header is same as central file header
if ($this->privCheckFileHeaders($v_local_header,
$v_header_list[$i]) != 1) {
// TBC
}
unset($v_local_header);
// ----- Write the file header
if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
// ----- Close the zip file
$this->privCloseFd();
$v_temp_zip->privCloseFd();
@unlink($v_zip_temp_name);
// ----- Return
return $v_result;
}
// ----- Read/write the data block
if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
// ----- Close the zip file
$this->privCloseFd();
$v_temp_zip->privCloseFd();
@unlink($v_zip_temp_name);
// ----- Return
return $v_result;
}
}
// ----- Store the offset of the central dir
$v_offset = @ftell($v_temp_zip->zip_fd);
// ----- Re-Create the Central Dir files header
for ($i=0; $i<sizeof($v_header_list); $i++) {
// ----- Create the file header
if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
$v_temp_zip->privCloseFd();
$this->privCloseFd();
@unlink($v_zip_temp_name);
// ----- Return
return $v_result;
}
// ----- Transform the header to a 'usable' info
$v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
}
// ----- Zip file comment
$v_comment = '';
if (isset($p_options[PCLZIP_OPT_COMMENT])) {
$v_comment = $p_options[PCLZIP_OPT_COMMENT];
}
// ----- Calculate the size of the central header
$v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
// ----- Create the central dir footer
if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
// ----- Reset the file list
unset($v_header_list);
$v_temp_zip->privCloseFd();
$this->privCloseFd();
@unlink($v_zip_temp_name);
// ----- Return
return $v_result;
}
// ----- Close
$v_temp_zip->privCloseFd();
$this->privCloseFd();
// ----- Delete the zip file
// TBC : I should test the result ...
@unlink($this->zipname);
// ----- Rename the temporary file
// TBC : I should test the result ...
//@rename($v_zip_temp_name, $this->zipname);
PclZipUtilRename($v_zip_temp_name, $this->zipname);
// ----- Destroy the temporary archive
unset($v_temp_zip);
}
// ----- Remove every files : reset the file
else if ($v_central_dir['entries'] != 0) {
$this->privCloseFd();
if (($v_result = $this->privOpenFd('wb')) != 1) {
return $v_result;
}
if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
return $v_result;
}
$this->privCloseFd();
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privDirCheck()
// Description :
// Check if a directory exists, if not it creates it and all the parents directory
// which may be useful.
// Parameters :
// $p_dir : Directory path to check.
// Return Values :
// 1 : OK
// -1 : Unable to create directory
// --------------------------------------------------------------------------------
function privDirCheck($p_dir, $p_is_dir=false)
{
$v_result = 1;
// ----- Remove the final '/'
if (($p_is_dir) && (substr($p_dir, -1)=='/'))
{
$p_dir = substr($p_dir, 0, strlen($p_dir)-1);
}
// ----- Check the directory availability
if ((is_dir($p_dir)) || ($p_dir == ""))
{
return 1;
}
// ----- Extract parent directory
$p_parent_dir = dirname($p_dir);
// ----- Just a check
if ($p_parent_dir != $p_dir)
{
// ----- Look for parent directory
if ($p_parent_dir != "")
{
if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
{
return $v_result;
}
}
}
// ----- Create the directory
if (!@mkdir($p_dir, 0777))
{
// ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
// ----- Return
return PclZip::errorCode();
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privMerge()
// Description :
// If $p_archive_to_add does not exist, the function exit with a success result.
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privMerge(&$p_archive_to_add)
{
$v_result=1;
// ----- Look if the archive_to_add exists
if (!is_file($p_archive_to_add->zipname))
{
// ----- Nothing to merge, so merge is a success
$v_result = 1;
// ----- Return
return $v_result;
}
// ----- Look if the archive exists
if (!is_file($this->zipname))
{
// ----- Do a duplicate
$v_result = $this->privDuplicate($p_archive_to_add->zipname);
// ----- Return
return $v_result;
}
// ----- Open the zip file
if (($v_result=$this->privOpenFd('rb')) != 1)
{
// ----- Return
return $v_result;
}
// ----- Read the central directory informations
$v_central_dir = array();
if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
{
$this->privCloseFd();
return $v_result;
}
// ----- Go to beginning of File
@rewind($this->zip_fd);
// ----- Open the archive_to_add file
if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
{
$this->privCloseFd();
// ----- Return
return $v_result;
}
// ----- Read the central directory informations
$v_central_dir_to_add = array();
if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
{
$this->privCloseFd();
$p_archive_to_add->privCloseFd();
return $v_result;
}
// ----- Go to beginning of File
@rewind($p_archive_to_add->zip_fd);
// ----- Creates a temporay file
$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
// ----- Open the temporary file in write mode
if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
{
$this->privCloseFd();
$p_archive_to_add->privCloseFd();
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
// ----- Return
return PclZip::errorCode();
}
// ----- Copy the files from the archive to the temporary file
// TBC : Here I should better append the file and go back to erase the central dir
$v_size = $v_central_dir['offset'];
while ($v_size != 0)
{
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = fread($this->zip_fd, $v_read_size);
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Copy the files from the archive_to_add into the temporary file
$v_size = $v_central_dir_to_add['offset'];
while ($v_size != 0)
{
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Store the offset of the central dir
$v_offset = @ftell($v_zip_temp_fd);
// ----- Copy the block of file headers from the old archive
$v_size = $v_central_dir['size'];
while ($v_size != 0)
{
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($this->zip_fd, $v_read_size);
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Copy the block of file headers from the archive_to_add
$v_size = $v_central_dir_to_add['size'];
while ($v_size != 0)
{
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
@fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Merge the file comments
$v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
// ----- Calculate the size of the (new) central header
$v_size = @ftell($v_zip_temp_fd)-$v_offset;
// ----- Swap the file descriptor
// Here is a trick : I swap the temporary fd with the zip fd, in order to use
// the following methods on the temporary fil and not the real archive fd
$v_swap = $this->zip_fd;
$this->zip_fd = $v_zip_temp_fd;
$v_zip_temp_fd = $v_swap;
// ----- Create the central dir footer
if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
{
$this->privCloseFd();
$p_archive_to_add->privCloseFd();
@fclose($v_zip_temp_fd);
$this->zip_fd = null;
// ----- Reset the file list
unset($v_header_list);
// ----- Return
return $v_result;
}
// ----- Swap back the file descriptor
$v_swap = $this->zip_fd;
$this->zip_fd = $v_zip_temp_fd;
$v_zip_temp_fd = $v_swap;
// ----- Close
$this->privCloseFd();
$p_archive_to_add->privCloseFd();
// ----- Close the temporary file
@fclose($v_zip_temp_fd);
// ----- Delete the zip file
// TBC : I should test the result ...
@unlink($this->zipname);
// ----- Rename the temporary file
// TBC : I should test the result ...
//@rename($v_zip_temp_name, $this->zipname);
PclZipUtilRename($v_zip_temp_name, $this->zipname);
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privDuplicate()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privDuplicate($p_archive_filename)
{
$v_result=1;
// ----- Look if the $p_archive_filename exists
if (!is_file($p_archive_filename))
{
// ----- Nothing to duplicate, so duplicate is a success.
$v_result = 1;
// ----- Return
return $v_result;
}
// ----- Open the zip file
if (($v_result=$this->privOpenFd('wb')) != 1)
{
// ----- Return
return $v_result;
}
// ----- Open the temporary file in write mode
if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
{
$this->privCloseFd();
PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
// ----- Return
return PclZip::errorCode();
}
// ----- Copy the files from the archive to the temporary file
// TBC : Here I should better append the file and go back to erase the central dir
$v_size = filesize($p_archive_filename);
while ($v_size != 0)
{
$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = fread($v_zip_temp_fd, $v_read_size);
@fwrite($this->zip_fd, $v_buffer, $v_read_size);
$v_size -= $v_read_size;
}
// ----- Close
$this->privCloseFd();
// ----- Close the temporary file
@fclose($v_zip_temp_fd);
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privErrorLog()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function privErrorLog($p_error_code=0, $p_error_string='')
{
if (PCLZIP_ERROR_EXTERNAL == 1) {
PclError($p_error_code, $p_error_string);
}
else {
$this->error_code = $p_error_code;
$this->error_string = $p_error_string;
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privErrorReset()
// Description :
// Parameters :
// --------------------------------------------------------------------------------
function privErrorReset()
{
if (PCLZIP_ERROR_EXTERNAL == 1) {
PclErrorReset();
}
else {
$this->error_code = 0;
$this->error_string = '';
}
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privDisableMagicQuotes()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privDisableMagicQuotes()
{
$v_result=1;
// ----- Look if function exists
if ( (!function_exists("get_magic_quotes_runtime"))
|| (!function_exists("set_magic_quotes_runtime"))) {
return $v_result;
}
// ----- Look if already done
if ($this->magic_quotes_status != -1) {
return $v_result;
}
// ----- Get and memorize the magic_quote value
$this->magic_quotes_status = @get_magic_quotes_runtime();
// ----- Disable magic_quotes
if ($this->magic_quotes_status == 1) {
@set_magic_quotes_runtime(0);
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : privSwapBackMagicQuotes()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function privSwapBackMagicQuotes()
{
$v_result=1;
// ----- Look if function exists
if ( (!function_exists("get_magic_quotes_runtime"))
|| (!function_exists("set_magic_quotes_runtime"))) {
return $v_result;
}
// ----- Look if something to do
if ($this->magic_quotes_status != -1) {
return $v_result;
}
// ----- Swap back magic_quotes
if ($this->magic_quotes_status == 1) {
@set_magic_quotes_runtime($this->magic_quotes_status);
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
}
// End of class
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclZipUtilPathReduction()
// Description :
// Parameters :
// Return Values :
// --------------------------------------------------------------------------------
function PclZipUtilPathReduction($p_dir)
{
$v_result = "";
// ----- Look for not empty path
if ($p_dir != "") {
// ----- Explode path by directory names
$v_list = explode("/", $p_dir);
// ----- Study directories from last to first
$v_skip = 0;
for ($i=sizeof($v_list)-1; $i>=0; $i--) {
// ----- Look for current path
if ($v_list[$i] == ".") {
// ----- Ignore this directory
// Should be the first $i=0, but no check is done
}
else if ($v_list[$i] == "..") {
$v_skip++;
}
else if ($v_list[$i] == "") {
// ----- First '/' i.e. root slash
if ($i == 0) {
$v_result = "/".$v_result;
if ($v_skip > 0) {
// ----- It is an invalid path, so the path is not modified
// TBC
$v_result = $p_dir;
$v_skip = 0;
}
}
// ----- Last '/' i.e. indicates a directory
else if ($i == (sizeof($v_list)-1)) {
$v_result = $v_list[$i];
}
// ----- Double '/' inside the path
else {
// ----- Ignore only the double '//' in path,
// but not the first and last '/'
}
}
else {
// ----- Look for item to skip
if ($v_skip > 0) {
$v_skip--;
}
else {
$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
}
}
}
// ----- Look for skip
if ($v_skip > 0) {
while ($v_skip > 0) {
$v_result = '../'.$v_result;
$v_skip--;
}
}
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclZipUtilPathInclusion()
// Description :
// This function indicates if the path $p_path is under the $p_dir tree. Or,
// said in an other way, if the file or sub-dir $p_path is inside the dir
// $p_dir.
// The function indicates also if the path is exactly the same as the dir.
// This function supports path with duplicated '/' like '//', but does not
// support '.' or '..' statements.
// Parameters :
// Return Values :
// 0 if $p_path is not inside directory $p_dir
// 1 if $p_path is inside directory $p_dir
// 2 if $p_path is exactly the same as $p_dir
// --------------------------------------------------------------------------------
function PclZipUtilPathInclusion($p_dir, $p_path)
{
$v_result = 1;
// ----- Look for path beginning by ./
if ( ($p_dir == '.')
|| ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
$p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
}
if ( ($p_path == '.')
|| ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
$p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
}
// ----- Explode dir and path by directory separator
$v_list_dir = explode("/", $p_dir);
$v_list_dir_size = sizeof($v_list_dir);
$v_list_path = explode("/", $p_path);
$v_list_path_size = sizeof($v_list_path);
// ----- Study directories paths
$i = 0;
$j = 0;
while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
// ----- Look for empty dir (path reduction)
if ($v_list_dir[$i] == '') {
$i++;
continue;
}
if ($v_list_path[$j] == '') {
$j++;
continue;
}
// ----- Compare the items
if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
$v_result = 0;
}
// ----- Next items
$i++;
$j++;
}
// ----- Look if everything seems to be the same
if ($v_result) {
// ----- Skip all the empty items
while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
// ----- There are exactly the same
$v_result = 2;
}
else if ($i < $v_list_dir_size) {
// ----- The path is shorter than the dir
$v_result = 0;
}
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclZipUtilCopyBlock()
// Description :
// Parameters :
// $p_mode : read/write compression mode
// 0 : src & dest normal
// 1 : src gzip, dest normal
// 2 : src normal, dest gzip
// 3 : src & dest gzip
// Return Values :
// --------------------------------------------------------------------------------
function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
{
$v_result = 1;
if ($p_mode==0)
{
while ($p_size != 0)
{
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($p_src, $v_read_size);
@fwrite($p_dest, $v_buffer, $v_read_size);
$p_size -= $v_read_size;
}
}
else if ($p_mode==1)
{
while ($p_size != 0)
{
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @gzread($p_src, $v_read_size);
@fwrite($p_dest, $v_buffer, $v_read_size);
$p_size -= $v_read_size;
}
}
else if ($p_mode==2)
{
while ($p_size != 0)
{
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @fread($p_src, $v_read_size);
@gzwrite($p_dest, $v_buffer, $v_read_size);
$p_size -= $v_read_size;
}
}
else if ($p_mode==3)
{
while ($p_size != 0)
{
$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
$v_buffer = @gzread($p_src, $v_read_size);
@gzwrite($p_dest, $v_buffer, $v_read_size);
$p_size -= $v_read_size;
}
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclZipUtilRename()
// Description :
// This function tries to do a simple rename() function. If it fails, it
// tries to copy the $p_src file in a new $p_dest file and then unlink the
// first one.
// Parameters :
// $p_src : Old filename
// $p_dest : New filename
// Return Values :
// 1 on success, 0 on failure.
// --------------------------------------------------------------------------------
function PclZipUtilRename($p_src, $p_dest)
{
$v_result = 1;
// ----- Try to rename the files
if (!@rename($p_src, $p_dest)) {
// ----- Try to copy & unlink the src
if (!@copy($p_src, $p_dest)) {
$v_result = 0;
}
else if (!@unlink($p_src)) {
$v_result = 0;
}
}
// ----- Return
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclZipUtilOptionText()
// Description :
// Translate option value in text. Mainly for debug purpose.
// Parameters :
// $p_option : the option value.
// Return Values :
// The option text value.
// --------------------------------------------------------------------------------
function PclZipUtilOptionText($p_option)
{
$v_list = get_defined_constants();
for (reset($v_list); $v_key = key($v_list); next($v_list)) {
$v_prefix = substr($v_key, 0, 10);
if (( ($v_prefix == 'PCLZIP_OPT')
|| ($v_prefix == 'PCLZIP_CB_')
|| ($v_prefix == 'PCLZIP_ATT'))
&& ($v_list[$v_key] == $p_option)) {
return $v_key;
}
}
$v_result = 'Unknown';
return $v_result;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
// Function : PclZipUtilTranslateWinPath()
// Description :
// Translate windows path by replacing '\' by '/' and optionally removing
// drive letter.
// Parameters :
// $p_path : path to translate.
// $p_remove_disk_letter : true | false
// Return Values :
// The path translated.
// --------------------------------------------------------------------------------
function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
{
if (stristr(php_uname(), 'windows')) {
// ----- Look for potential disk letter
if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
$p_path = substr($p_path, $v_position+1);
}
// ----- Change potential windows directory separator
if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
$p_path = strtr($p_path, '\\', '/');
}
}
return $p_path;
}
// --------------------------------------------------------------------------------
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/PCLZip/pclzip.lib.php | PHP | asf20 | 202,844 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
if (!defined('DATE_W3C')) {
define('DATE_W3C', 'Y-m-d\TH:i:sP');
}
if (!defined('DEBUGMODE_ENABLED')) {
define('DEBUGMODE_ENABLED', false);
}
/**
* PHPExcel_Shared_XMLWriter
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_XMLWriter extends XMLWriter {
/** Temporary storage method */
const STORAGE_MEMORY = 1;
const STORAGE_DISK = 2;
/**
* Temporary filename
*
* @var string
*/
private $_tempFileName = '';
/**
* Create a new PHPExcel_Shared_XMLWriter instance
*
* @param int $pTemporaryStorage Temporary storage location
* @param string $pTemporaryStorageFolder Temporary storage folder
*/
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = './') {
// Open temporary storage
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
$this->openMemory();
} else {
// Create temporary filename
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
// Open storage
if ($this->openUri($this->_tempFileName) === false) {
// Fallback to memory...
$this->openMemory();
}
}
// Set default values
if (DEBUGMODE_ENABLED) {
$this->setIndent(true);
}
}
/**
* Destructor
*/
public function __destruct() {
// Unlink temporary files
if ($this->_tempFileName != '') {
@unlink($this->_tempFileName);
}
}
/**
* Get written data
*
* @return $data
*/
public function getData() {
if ($this->_tempFileName == '') {
return $this->outputMemory(true);
} else {
$this->flush();
return file_get_contents($this->_tempFileName);
}
}
/**
* Fallback method for writeRaw, introduced in PHP 5.2
*
* @param string $text
* @return string
*/
public function writeRawData($text)
{
if (method_exists($this, 'writeRaw')) {
return $this->writeRaw(htmlspecialchars($text));
}
return $this->text($text);
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/XMLWriter.php | PHP | asf20 | 3,043 |
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Xavier Noguer <xnoguer@php.net> |
// | Based on OLE::Storage_Lite by Kawai, Takanori |
// +----------------------------------------------------------------------+
//
// $Id: Root.php,v 1.9 2005/04/23 21:53:49 dufuz Exp $
/**
* Class for creating Root PPS's for OLE containers
*
* @author Xavier Noguer <xnoguer@php.net>
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
{
/**
* Directory for temporary files
* @var string
*/
protected $_tmp_dir = '';
/**
* @param integer $time_1st A timestamp
* @param integer $time_2nd A timestamp
*/
public function __construct($time_1st, $time_2nd, $raChild)
{
$this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
parent::__construct(
null,
PHPExcel_Shared_OLE::Asc2Ucs('Root Entry'),
PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT,
null,
null,
null,
$time_1st,
$time_2nd,
null,
$raChild);
}
/**
* 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.
* If a resource pointer to a stream created by fopen() is passed
* it will be used, but you have to close such stream by yourself.
*
* @param string|resource $filename The name of the file or stream where to save the OLE container.
* @access public
* @return mixed true on success
*/
public function save($filename)
{
// Initial Setting for saving
$this->_BIG_BLOCK_SIZE = pow(2,
((isset($this->_BIG_BLOCK_SIZE))? self::_adjust2($this->_BIG_BLOCK_SIZE) : 9));
$this->_SMALL_BLOCK_SIZE= pow(2,
((isset($this->_SMALL_BLOCK_SIZE))? self::_adjust2($this->_SMALL_BLOCK_SIZE): 6));
if (is_resource($filename)) {
$this->_FILEH_ = $filename;
} else if ($filename == '-' || $filename == '') {
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
$this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
if ($this->_FILEH_ == false) {
throw new Exception("Can't create temporary file.");
}
} else {
$this->_FILEH_ = fopen($filename, "wb");
}
if ($this->_FILEH_ == false) {
throw new Exception("Can't open $filename. It may be in use or protected.");
}
// Make an array of PPS's (for Save)
$aList = array();
$this->_savePpsSetPnt($aList);
// calculate values for header
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
$this->_savePps($aList);
// Write Big Block Depot and BDList and Adding Header informations
$this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt);
if (!is_resource($filename)) {
fclose($this->_FILEH_);
}
return true;
}
/**
* Calculate some numbers
*
* @access public
* @param array $raList Reference to an array of PPS's
* @return array The array of numbers
*/
public function _calcSize(&$raList)
{
// Calculate Basic Setting
list($iSBDcnt, $iBBcnt, $iPPScnt) = array(0,0,0);
$iSmallLen = 0;
$iSBcnt = 0;
$iCount = count($raList);
for ($i = 0; $i < $iCount; ++$i) {
if ($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE) {
$raList[$i]->Size = $raList[$i]->_DataLen();
if ($raList[$i]->Size < PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) {
$iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
+ (($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));
}
}
}
$iSmallLen = $iSBcnt * $this->_SMALL_BLOCK_SIZE;
$iSlCnt = floor($this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::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));
$iCnt = count($raList);
$iBdCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::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 public
* @param integer $i2 The argument
* @see save()
* @return integer
*/
private static function _adjust2($i2)
{
$iWk = log($i2)/log(2);
return ($iWk > floor($iWk))? floor($iWk)+1:$iWk;
}
/**
* Save OLE header
*
* @access public
* @param integer $iSBDcnt
* @param integer $iBBcnt
* @param integer $iPPScnt
*/
public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt)
{
$FILE = $this->_FILEH_;
// Calculate Basic Setting
$iBlCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE;
$i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / PHPExcel_Shared_OLE::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) {
while (1) {
++$iBdExL;
++$iAllW;
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0);
$iBdCnt = floor(($iAllW + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0);
if ($iBdCnt <= ($iBdExL*$iBlCnt+ $i1stBdL)) {
break;
}
}
}
// Save Header
fwrite($FILE,
"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1"
. "\x00\x00\x00\x00"
. "\x00\x00\x00\x00"
. "\x00\x00\x00\x00"
. "\x00\x00\x00\x00"
. pack("v", 0x3b)
. pack("v", 0x03)
. pack("v", -2)
. pack("v", 9)
. pack("v", 6)
. pack("v", 0)
. "\x00\x00\x00\x00"
. "\x00\x00\x00\x00"
. pack("V", $iBdCnt)
. pack("V", $iBBcnt+$iSBDcnt) //ROOT START
. pack("V", 0)
. pack("V", 0x1000)
. pack("V", $iSBDcnt ? 0 : -2) //Small Block Depot
. pack("V", $iSBDcnt)
);
// 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));
}
// BDList
for ($i = 0; $i < $i1stBdL && $i < $iBdCnt; ++$i) {
fwrite($FILE, pack("V", $iAll+$i));
}
if ($i < $i1stBdL) {
$jB = $i1stBdL - $i;
for ($j = 0; $j < $jB; ++$j) {
fwrite($FILE, (pack("V", -1)));
}
}
}
/**
* Saving big data (PPS's with data bigger than PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL)
*
* @access public
* @param integer $iStBlk
* @param array &$raList Reference to array of PPS's
*/
public function _saveBigData($iStBlk, &$raList)
{
$FILE = $this->_FILEH_;
// cycle through PPS's
$iCount = count($raList);
for ($i = 0; $i < $iCount; ++$i) {
if ($raList[$i]->Type != PHPExcel_Shared_OLE::OLE_PPS_TYPE_DIR) {
$raList[$i]->Size = $raList[$i]->_DataLen();
if (($raList[$i]->Size >= PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) ||
(($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data)))
{
// Write Data
//if (isset($raList[$i]->_PPS_FILE)) {
// $iLen = 0;
// fseek($raList[$i]->_PPS_FILE, 0); // To The Top
// while($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
// $iLen += strlen($sBuff);
// fwrite($FILE, $sBuff);
// }
//} else {
fwrite($FILE, $raList[$i]->_data);
//}
if ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE) {
fwrite($FILE, str_repeat("\x00", $this->_BIG_BLOCK_SIZE - ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)));
}
// 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));
}
// Close file for each PPS, and unlink it
//if (isset($raList[$i]->_PPS_FILE)) {
// fclose($raList[$i]->_PPS_FILE);
// $raList[$i]->_PPS_FILE = null;
// unlink($raList[$i]->_tmp_filename);
//}
}
}
}
/**
* get small data (PPS's with data smaller than PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL)
*
* @access public
* @param array &$raList Reference to array of PPS's
*/
public function _makeSmallData(&$raList)
{
$sRes = '';
$FILE = $this->_FILEH_;
$iSmBlk = 0;
$iCount = count($raList);
for ($i = 0; $i < $iCount; ++$i) {
// Make SBD, small data string
if ($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE) {
if ($raList[$i]->Size <= 0) {
continue;
}
if ($raList[$i]->Size < PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) {
$iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
// Add to SBD
$jB = $iSmbCnt - 1;
for ($j = 0; $j < $jB; ++$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) {
// fseek($raList[$i]->_PPS_FILE, 0); // To The Top
// while ($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
// $sRes .= $sBuff;
// }
//} else {
$sRes .= $raList[$i]->_data;
//}
if ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) {
$sRes .= str_repeat("\x00",$this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE));
}
// Set for PPS
$raList[$i]->_StartBlock = $iSmBlk;
$iSmBlk += $iSmbCnt;
}
}
}
$iSbCnt = floor($this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE);
if ($iSmBlk % $iSbCnt) {
$iB = $iSbCnt - ($iSmBlk % $iSbCnt);
for ($i = 0; $i < $iB; ++$i) {
fwrite($FILE, pack("V", -1));
}
}
return $sRes;
}
/**
* Saves all the PPS's WKs
*
* @access public
* @param array $raList Reference to an array with all PPS's
*/
public function _savePps(&$raList)
{
// Save each PPS WK
$iC = count($raList);
for ($i = 0; $i < $iC; ++$i) {
fwrite($this->_FILEH_, $raList[$i]->_getPpsWk());
}
// Adjust for Block
$iCnt = count($raList);
$iBCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_PPS_SIZE;
if ($iCnt % $iBCnt) {
fwrite($this->_FILEH_, str_repeat("\x00",($iBCnt - ($iCnt % $iBCnt)) * PHPExcel_Shared_OLE::OLE_PPS_SIZE));
}
}
/**
* Saving Big Block Depot
*
* @access public
* @param integer $iSbdSize
* @param integer $iBsize
* @param integer $iPpsCnt
*/
public function _saveBbd($iSbdSize, $iBsize, $iPpsCnt)
{
$FILE = $this->_FILEH_;
// Calculate Basic Setting
$iBbCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE;
$i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE;
$iBdExL = 0;
$iAll = $iBsize + $iPpsCnt + $iSbdSize;
$iAllW = $iAll;
$iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0);
$iBdCnt = floor(($iAll + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0);
// Calculate BD count
if ($iBdCnt >$i1stBdL) {
while (1) {
++$iBdExL;
++$iAllW;
$iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0);
$iBdCnt = floor(($iAllW + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0);
if ($iBdCnt <= ($iBdExL*$iBbCnt+ $i1stBdL)) {
break;
}
}
}
// Making BD
// Set for SBD
if ($iSbdSize > 0) {
for ($i = 0; $i < ($iSbdSize - 1); ++$i) {
fwrite($FILE, pack("V", $i+1));
}
fwrite($FILE, pack("V", -2));
}
// Set for B
for ($i = 0; $i < ($iBsize - 1); ++$i) {
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));
}
fwrite($FILE, pack("V", -2));
// Set for BBD itself ( 0xFFFFFFFD : BBD)
for ($i = 0; $i < $iBdCnt; ++$i) {
fwrite($FILE, pack("V", 0xFFFFFFFD));
}
// Set for ExtraBDList
for ($i = 0; $i < $iBdExL; ++$i) {
fwrite($FILE, pack("V", 0xFFFFFFFC));
}
// Adjust for Block
if (($iAllW + $iBdCnt) % $iBbCnt) {
$iBlock = ($iBbCnt - (($iAllW + $iBdCnt) % $iBbCnt));
for ($i = 0; $i < $iBlock; ++$i) {
fwrite($FILE, pack("V", -1));
}
}
// Extra BDList
if ($iBdCnt > $i1stBdL) {
$iN=0;
$iNb=0;
for ($i = $i1stBdL;$i < $iBdCnt; $i++, ++$iN) {
if ($iN >= ($iBbCnt - 1)) {
$iN = 0;
++$iNb;
fwrite($FILE, pack("V", $iAll+$iBdCnt+$iNb));
}
fwrite($FILE, pack("V", $iBsize+$iSbdSize+$iPpsCnt+$i));
}
if (($iBdCnt-$i1stBdL) % ($iBbCnt-1)) {
$iB = ($iBbCnt - 1) - (($iBdCnt - $i1stBdL) % ($iBbCnt - 1));
for ($i = 0; $i < $iB; ++$i) {
fwrite($FILE, pack("V", -1));
}
}
fwrite($FILE, pack("V", -2));
}
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/OLE/PPS/Root.php | PHP | asf20 | 14,132 |
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Xavier Noguer <xnoguer@php.net> |
// | Based on OLE::Storage_Lite by Kawai, Takanori |
// +----------------------------------------------------------------------+
//
// $Id: File.php,v 1.11 2007/02/13 21:00:42 schmidt Exp $
/**
* Class for creating File PPS's for OLE containers
*
* @author Xavier Noguer <xnoguer@php.net>
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
{
/**
* The constructor
*
* @access public
* @param string $name The name of the file (in Unicode)
* @see OLE::Asc2Ucs()
*/
public function __construct($name)
{
parent::__construct(
null,
$name,
PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE,
null,
null,
null,
null,
null,
'',
array());
}
/**
* Initialization method. Has to be called right after OLE_PPS_File().
*
* @access public
* @return mixed true on success
*/
public function init()
{
return true;
}
/**
* Append data to PPS
*
* @access public
* @param string $data The data to append
*/
public function append($data)
{
$this->_data .= $data;
}
/**
* Returns a stream for reading this file using fread() etc.
* @return resource a read-only stream
*/
public function getStream()
{
$this->ole->getStream($this);
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/OLE/PPS/File.php | PHP | asf20 | 2,403 |
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Xavier Noguer <xnoguer@php.net> |
// | Based on OLE::Storage_Lite by Kawai, Takanori |
// +----------------------------------------------------------------------+
//
// $Id: PPS.php,v 1.7 2007/02/13 21:00:42 schmidt Exp $
/**
* Class for creating PPS's for OLE containers
*
* @author Xavier Noguer <xnoguer@php.net>
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
class PHPExcel_Shared_OLE_PPS
{
/**
* The PPS index
* @var integer
*/
public $No;
/**
* The PPS name (in Unicode)
* @var string
*/
public $Name;
/**
* The PPS type. Dir, Root or File
* @var integer
*/
public $Type;
/**
* The index of the previous PPS
* @var integer
*/
public $PrevPps;
/**
* The index of the next PPS
* @var integer
*/
public $NextPps;
/**
* The index of it's first child if this is a Dir or Root PPS
* @var integer
*/
public $DirPps;
/**
* A timestamp
* @var integer
*/
public $Time1st;
/**
* A timestamp
* @var integer
*/
public $Time2nd;
/**
* Starting block (small or big) for this PPS's data inside the container
* @var integer
*/
public $_StartBlock;
/**
* The size of the PPS's data (in bytes)
* @var integer
*/
public $Size;
/**
* The PPS's data (only used if it's not using a temporary file)
* @var string
*/
public $_data;
/**
* Array of child PPS's (only used by Root and Dir PPS's)
* @var array
*/
public $children = array();
/**
* Pointer to OLE container
* @var OLE
*/
public $ole;
/**
* The constructor
*
* @access public
* @param integer $No The PPS index
* @param string $name The PPS name
* @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 string $data The (usually binary) source data of the PPS
* @param array $children Array containing children PPS for this PPS
*/
public function __construct($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
{
$this->No = $No;
$this->Name = $name;
$this->Type = $type;
$this->PrevPps = $prev;
$this->NextPps = $next;
$this->DirPps = $dir;
$this->Time1st = $time_1st;
$this->Time2nd = $time_2nd;
$this->_data = $data;
$this->children = $children;
if ($data != '') {
$this->Size = strlen($data);
} else {
$this->Size = 0;
}
}
/**
* Returns the amount of data saved for this PPS
*
* @access public
* @return integer The amount of data (in bytes)
*/
public function _DataLen()
{
if (!isset($this->_data)) {
return 0;
}
//if (isset($this->_PPS_FILE)) {
// fseek($this->_PPS_FILE, 0);
// $stats = fstat($this->_PPS_FILE);
// return $stats[7];
//} else {
return strlen($this->_data);
//}
}
/**
* Returns a string with the PPS's WK (What is a WK?)
*
* @access public
* @return string The binary string
*/
public function _getPpsWk()
{
$ret = str_pad($this->Name,64,"\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
. PHPExcel_Shared_OLE::LocalDate2OLE($this->Time1st) // 108
. PHPExcel_Shared_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 public
* @param array &$pps_array Reference to the array of PPS's for the whole OLE
* container
* @return integer The index for this PPS
*/
public function _savePpsSetPnt(&$pps_array)
{
$pps_array[count($pps_array)] = &$this;
$this->No = count($pps_array) - 1;
$this->PrevPps = 0xFFFFFFFF;
$this->NextPps = 0xFFFFFFFF;
if (count($this->children) > 0) {
$this->DirPps = $this->children[0]->_savePpsSetPnt($pps_array);
} else {
$this->DirPps = 0xFFFFFFFF;
}
return $this->No;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/OLE/PPS.php | PHP | asf20 | 5,835 |
<?php
/**
* PHPExcel
*
* Copyright (C) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared_OLE
* @copyright Copyright (c) 2006 - 2007 Christian Schmidt
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_OLE_ChainedBlockStream
*
* Stream wrapper for reading data stored in an OLE file. Implements methods
* for PHP's stream_wrapper_register(). For creating streams using this
* wrapper, use PHPExcel_Shared_OLE_PPS_File::getStream().
*
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
class PHPExcel_Shared_OLE_ChainedBlockStream
{
/**
* The OLE container of the file that is being read.
* @var OLE
*/
public $ole;
/**
* Parameters specified by fopen().
* @var array
*/
public $params;
/**
* The binary data of the file.
* @var string
*/
public $data;
/**
* The file pointer.
* @var int byte offset
*/
public $pos;
/**
* Implements support for fopen().
* For creating streams using this wrapper, use OLE_PPS_File::getStream().
* @param string resource name including scheme, e.g.
* ole-chainedblockstream://oleInstanceId=1
* @param string only "r" is supported
* @param int mask of STREAM_REPORT_ERRORS and STREAM_USE_PATH
* @param string absolute path of the opened stream (out parameter)
* @return bool true on success
*/
public function stream_open($path, $mode, $options, &$openedPath)
{
if ($mode != 'r') {
if ($options & STREAM_REPORT_ERRORS) {
trigger_error('Only reading is supported', E_USER_WARNING);
}
return false;
}
// 25 is length of "ole-chainedblockstream://"
parse_str(substr($path, 25), $this->params);
if (!isset($this->params['oleInstanceId'],
$this->params['blockId'],
$GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']])) {
if ($options & STREAM_REPORT_ERRORS) {
trigger_error('OLE stream not found', E_USER_WARNING);
}
return false;
}
$this->ole = $GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']];
$blockId = $this->params['blockId'];
$this->data = '';
if (isset($this->params['size']) &&
$this->params['size'] < $this->ole->bigBlockThreshold &&
$blockId != $this->ole->root->_StartBlock) {
// Block id refers to small blocks
$rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock);
while ($blockId != -2) {
$pos = $rootPos + $blockId * $this->ole->bigBlockSize;
$blockId = $this->ole->sbat[$blockId];
fseek($this->ole->_file_handle, $pos);
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
}
} else {
// Block id refers to big blocks
while ($blockId != -2) {
$pos = $this->ole->_getBlockOffset($blockId);
fseek($this->ole->_file_handle, $pos);
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
$blockId = $this->ole->bbat[$blockId];
}
}
if (isset($this->params['size'])) {
$this->data = substr($this->data, 0, $this->params['size']);
}
if ($options & STREAM_USE_PATH) {
$openedPath = $path;
}
return true;
}
/**
* Implements support for fclose().
* @return string
*/
public function stream_close()
{
$this->ole = null;
unset($GLOBALS['_OLE_INSTANCES']);
}
/**
* Implements support for fread(), fgets() etc.
* @param int maximum number of bytes to read
* @return string
*/
public function stream_read($count)
{
if ($this->stream_eof()) {
return false;
}
$s = substr($this->data, $this->pos, $count);
$this->pos += $count;
return $s;
}
/**
* Implements support for feof().
* @return bool TRUE if the file pointer is at EOF; otherwise FALSE
*/
public function stream_eof()
{
$eof = $this->pos >= strlen($this->data);
// Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508
if (version_compare(PHP_VERSION, '5.0', '>=') &&
version_compare(PHP_VERSION, '5.1', '<')) {
$eof = !$eof;
}
return $eof;
}
/**
* Returns the position of the file pointer, i.e. its offset into the file
* stream. Implements support for ftell().
* @return int
*/
public function stream_tell()
{
return $this->pos;
}
/**
* Implements support for fseek().
* @param int byte offset
* @param int SEEK_SET, SEEK_CUR or SEEK_END
* @return bool
*/
public function stream_seek($offset, $whence)
{
if ($whence == SEEK_SET && $offset >= 0) {
$this->pos = $offset;
} elseif ($whence == SEEK_CUR && -$offset <= $this->pos) {
$this->pos += $offset;
} elseif ($whence == SEEK_END && -$offset <= sizeof($this->data)) {
$this->pos = strlen($this->data) + $offset;
} else {
return false;
}
return true;
}
/**
* Implements support for fstat(). Currently the only supported field is
* "size".
* @return array
*/
public function stream_stat()
{
return array(
'size' => strlen($this->data),
);
}
// Methods used by stream_wrapper_register() that are not implemented:
// bool stream_flush ( void )
// int stream_write ( string data )
// bool rename ( string path_from, string path_to )
// bool mkdir ( string path, int mode, int options )
// bool rmdir ( string path, int options )
// bool dir_opendir ( string path, int options )
// array url_stat ( string path, int flags )
// string dir_readdir ( void )
// bool dir_rewinddir ( void )
// bool dir_closedir ( void )
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/OLE/ChainedBlockStream.php | PHP | asf20 | 6,210 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_String
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_String
{
/** Constants */
/** Regular Expressions */
// Fraction
const STRING_REGEXP_FRACTION = '(-?)(\d+)\s+(\d+\/\d+)';
/**
* Control characters array
*
* @var string[]
*/
private static $_controlCharacters = array();
/**
* SYLK Characters array
*
* $var array
*/
private static $_SYLKCharacters = array();
/**
* Decimal separator
*
* @var string
*/
private static $_decimalSeparator;
/**
* Thousands separator
*
* @var string
*/
private static $_thousandsSeparator;
/**
* Currency code
*
* @var string
*/
private static $_currencyCode;
/**
* Is mbstring extension avalable?
*
* @var boolean
*/
private static $_isMbstringEnabled;
/**
* Is iconv extension avalable?
*
* @var boolean
*/
private static $_isIconvEnabled;
/**
* Build control characters array
*/
private static function _buildControlCharacters() {
for ($i = 0; $i <= 31; ++$i) {
if ($i != 9 && $i != 10 && $i != 13) {
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
$replace = chr($i);
self::$_controlCharacters[$find] = $replace;
}
}
}
/**
* Build SYLK characters array
*/
private static function _buildSYLKCharacters()
{
self::$_SYLKCharacters = array(
"\x1B 0" => chr(0),
"\x1B 1" => chr(1),
"\x1B 2" => chr(2),
"\x1B 3" => chr(3),
"\x1B 4" => chr(4),
"\x1B 5" => chr(5),
"\x1B 6" => chr(6),
"\x1B 7" => chr(7),
"\x1B 8" => chr(8),
"\x1B 9" => chr(9),
"\x1B :" => chr(10),
"\x1B ;" => chr(11),
"\x1B <" => chr(12),
"\x1B :" => chr(13),
"\x1B >" => chr(14),
"\x1B ?" => chr(15),
"\x1B!0" => chr(16),
"\x1B!1" => chr(17),
"\x1B!2" => chr(18),
"\x1B!3" => chr(19),
"\x1B!4" => chr(20),
"\x1B!5" => chr(21),
"\x1B!6" => chr(22),
"\x1B!7" => chr(23),
"\x1B!8" => chr(24),
"\x1B!9" => chr(25),
"\x1B!:" => chr(26),
"\x1B!;" => chr(27),
"\x1B!<" => chr(28),
"\x1B!=" => chr(29),
"\x1B!>" => chr(30),
"\x1B!?" => chr(31),
"\x1B'?" => chr(127),
"\x1B(0" => '€', // 128 in CP1252
"\x1B(2" => '‚', // 130 in CP1252
"\x1B(3" => 'ƒ', // 131 in CP1252
"\x1B(4" => '„', // 132 in CP1252
"\x1B(5" => '…', // 133 in CP1252
"\x1B(6" => '†', // 134 in CP1252
"\x1B(7" => '‡', // 135 in CP1252
"\x1B(8" => 'ˆ', // 136 in CP1252
"\x1B(9" => '‰', // 137 in CP1252
"\x1B(:" => 'Š', // 138 in CP1252
"\x1B(;" => '‹', // 139 in CP1252
"\x1BNj" => 'Œ', // 140 in CP1252
"\x1B(>" => 'Ž', // 142 in CP1252
"\x1B)1" => '‘', // 145 in CP1252
"\x1B)2" => '’', // 146 in CP1252
"\x1B)3" => '“', // 147 in CP1252
"\x1B)4" => '”', // 148 in CP1252
"\x1B)5" => '•', // 149 in CP1252
"\x1B)6" => '–', // 150 in CP1252
"\x1B)7" => '—', // 151 in CP1252
"\x1B)8" => '˜', // 152 in CP1252
"\x1B)9" => '™', // 153 in CP1252
"\x1B):" => 'š', // 154 in CP1252
"\x1B);" => '›', // 155 in CP1252
"\x1BNz" => 'œ', // 156 in CP1252
"\x1B)>" => 'ž', // 158 in CP1252
"\x1B)?" => 'Ÿ', // 159 in CP1252
"\x1B*0" => ' ', // 160 in CP1252
"\x1BN!" => '¡', // 161 in CP1252
"\x1BN\"" => '¢', // 162 in CP1252
"\x1BN#" => '£', // 163 in CP1252
"\x1BN(" => '¤', // 164 in CP1252
"\x1BN%" => '¥', // 165 in CP1252
"\x1B*6" => '¦', // 166 in CP1252
"\x1BN'" => '§', // 167 in CP1252
"\x1BNH " => '¨', // 168 in CP1252
"\x1BNS" => '©', // 169 in CP1252
"\x1BNc" => 'ª', // 170 in CP1252
"\x1BN+" => '«', // 171 in CP1252
"\x1B*<" => '¬', // 172 in CP1252
"\x1B*=" => '', // 173 in CP1252
"\x1BNR" => '®', // 174 in CP1252
"\x1B*?" => '¯', // 175 in CP1252
"\x1BN0" => '°', // 176 in CP1252
"\x1BN1" => '±', // 177 in CP1252
"\x1BN2" => '²', // 178 in CP1252
"\x1BN3" => '³', // 179 in CP1252
"\x1BNB " => '´', // 180 in CP1252
"\x1BN5" => 'µ', // 181 in CP1252
"\x1BN6" => '¶', // 182 in CP1252
"\x1BN7" => '·', // 183 in CP1252
"\x1B+8" => '¸', // 184 in CP1252
"\x1BNQ" => '¹', // 185 in CP1252
"\x1BNk" => 'º', // 186 in CP1252
"\x1BN;" => '»', // 187 in CP1252
"\x1BN<" => '¼', // 188 in CP1252
"\x1BN=" => '½', // 189 in CP1252
"\x1BN>" => '¾', // 190 in CP1252
"\x1BN?" => '¿', // 191 in CP1252
"\x1BNAA" => 'À', // 192 in CP1252
"\x1BNBA" => 'Á', // 193 in CP1252
"\x1BNCA" => 'Â', // 194 in CP1252
"\x1BNDA" => 'Ã', // 195 in CP1252
"\x1BNHA" => 'Ä', // 196 in CP1252
"\x1BNJA" => 'Å', // 197 in CP1252
"\x1BNa" => 'Æ', // 198 in CP1252
"\x1BNKC" => 'Ç', // 199 in CP1252
"\x1BNAE" => 'È', // 200 in CP1252
"\x1BNBE" => 'É', // 201 in CP1252
"\x1BNCE" => 'Ê', // 202 in CP1252
"\x1BNHE" => 'Ë', // 203 in CP1252
"\x1BNAI" => 'Ì', // 204 in CP1252
"\x1BNBI" => 'Í', // 205 in CP1252
"\x1BNCI" => 'Î', // 206 in CP1252
"\x1BNHI" => 'Ï', // 207 in CP1252
"\x1BNb" => 'Ð', // 208 in CP1252
"\x1BNDN" => 'Ñ', // 209 in CP1252
"\x1BNAO" => 'Ò', // 210 in CP1252
"\x1BNBO" => 'Ó', // 211 in CP1252
"\x1BNCO" => 'Ô', // 212 in CP1252
"\x1BNDO" => 'Õ', // 213 in CP1252
"\x1BNHO" => 'Ö', // 214 in CP1252
"\x1B-7" => '×', // 215 in CP1252
"\x1BNi" => 'Ø', // 216 in CP1252
"\x1BNAU" => 'Ù', // 217 in CP1252
"\x1BNBU" => 'Ú', // 218 in CP1252
"\x1BNCU" => 'Û', // 219 in CP1252
"\x1BNHU" => 'Ü', // 220 in CP1252
"\x1B-=" => 'Ý', // 221 in CP1252
"\x1BNl" => 'Þ', // 222 in CP1252
"\x1BN{" => 'ß', // 223 in CP1252
"\x1BNAa" => 'à', // 224 in CP1252
"\x1BNBa" => 'á', // 225 in CP1252
"\x1BNCa" => 'â', // 226 in CP1252
"\x1BNDa" => 'ã', // 227 in CP1252
"\x1BNHa" => 'ä', // 228 in CP1252
"\x1BNJa" => 'å', // 229 in CP1252
"\x1BNq" => 'æ', // 230 in CP1252
"\x1BNKc" => 'ç', // 231 in CP1252
"\x1BNAe" => 'è', // 232 in CP1252
"\x1BNBe" => 'é', // 233 in CP1252
"\x1BNCe" => 'ê', // 234 in CP1252
"\x1BNHe" => 'ë', // 235 in CP1252
"\x1BNAi" => 'ì', // 236 in CP1252
"\x1BNBi" => 'í', // 237 in CP1252
"\x1BNCi" => 'î', // 238 in CP1252
"\x1BNHi" => 'ï', // 239 in CP1252
"\x1BNs" => 'ð', // 240 in CP1252
"\x1BNDn" => 'ñ', // 241 in CP1252
"\x1BNAo" => 'ò', // 242 in CP1252
"\x1BNBo" => 'ó', // 243 in CP1252
"\x1BNCo" => 'ô', // 244 in CP1252
"\x1BNDo" => 'õ', // 245 in CP1252
"\x1BNHo" => 'ö', // 246 in CP1252
"\x1B/7" => '÷', // 247 in CP1252
"\x1BNy" => 'ø', // 248 in CP1252
"\x1BNAu" => 'ù', // 249 in CP1252
"\x1BNBu" => 'ú', // 250 in CP1252
"\x1BNCu" => 'û', // 251 in CP1252
"\x1BNHu" => 'ü', // 252 in CP1252
"\x1B/=" => 'ý', // 253 in CP1252
"\x1BN|" => 'þ', // 254 in CP1252
"\x1BNHy" => 'ÿ', // 255 in CP1252
);
}
/**
* Get whether mbstring extension is available
*
* @return boolean
*/
public static function getIsMbstringEnabled()
{
if (isset(self::$_isMbstringEnabled)) {
return self::$_isMbstringEnabled;
}
self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ?
true : false;
return self::$_isMbstringEnabled;
}
/**
* Get whether iconv extension is available
*
* @return boolean
*/
public static function getIsIconvEnabled()
{
if (isset(self::$_isIconvEnabled)) {
return self::$_isIconvEnabled;
}
// Fail if iconv doesn't exist
if (!function_exists('iconv')) {
self::$_isIconvEnabled = false;
return false;
}
// Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
self::$_isIconvEnabled = false;
return false;
}
// Sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
// we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
if (!@iconv_substr('A', 0, 1, 'UTF-8')) {
self::$_isIconvEnabled = false;
return false;
}
// CUSTOM: IBM AIX iconv() does not work
if ( defined('PHP_OS') && @stristr(PHP_OS, 'AIX')
&& defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0)
&& defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0) )
{
self::$_isIconvEnabled = false;
return false;
}
// If we reach here no problems were detected with iconv
self::$_isIconvEnabled = true;
return true;
}
public static function buildCharacterSets() {
if(empty(self::$_controlCharacters)) {
self::_buildControlCharacters();
}
if(empty(self::$_SYLKCharacters)) {
self::_buildSYLKCharacters();
}
}
/**
* Convert from OpenXML escaped control character to PHP control character
*
* Excel 2007 team:
* ----------------
* That's correct, control characters are stored directly in the shared-strings table.
* We do encode characters that cannot be represented in XML using the following escape sequence:
* _xHHHH_ where H represents a hexadecimal character in the character's value...
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
* element or in the shared string <t> element.
*
* @param string $value Value to unescape
* @return string
*/
public static function ControlCharacterOOXML2PHP($value = '') {
return str_replace( array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value );
}
/**
* Convert from PHP control character to OpenXML escaped control character
*
* Excel 2007 team:
* ----------------
* That's correct, control characters are stored directly in the shared-strings table.
* We do encode characters that cannot be represented in XML using the following escape sequence:
* _xHHHH_ where H represents a hexadecimal character in the character's value...
* So you could end up with something like _x0008_ in a string (either in a cell value (<v>)
* element or in the shared string <t> element.
*
* @param string $value Value to escape
* @return string
*/
public static function ControlCharacterPHP2OOXML($value = '') {
return str_replace( array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value );
}
/**
* Try to sanitize UTF8, stripping invalid byte sequences. Not perfect. Does not surrogate characters.
*
* @param string $value
* @return string
*/
public static function SanitizeUTF8($value)
{
if (self::getIsIconvEnabled()) {
$value = @iconv('UTF-8', 'UTF-8', $value);
return $value;
}
if (self::getIsMbstringEnabled()) {
$value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
return $value;
}
// else, no conversion
return $value;
}
/**
* Check if a string contains UTF8 data
*
* @param string $value
* @return boolean
*/
public static function IsUTF8($value = '') {
return utf8_encode(utf8_decode($value)) === $value;
}
/**
* Formats a numeric value as a string for output in various output writers forcing
* point as decimal separator in case locale is other than English.
*
* @param mixed $value
* @return string
*/
public static function FormatNumber($value) {
if (is_float($value)) {
return str_replace(',', '.', $value);
}
return (string) $value;
}
/**
* Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length)
* Writes the string using uncompressed notation, no rich text, no Asian phonetics
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
* although this will give wrong results for non-ASCII strings
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
*
* @param string $value UTF-8 encoded string
* @return string
*/
public static function UTF8toBIFF8UnicodeShort($value)
{
// character count
$ln = self::CountCharacters($value, 'UTF-8');
// option flags
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
0x0001 : 0x0000;
// characters
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
$data = pack('CC', $ln, $opt) . $chars;
return $data;
}
/**
* Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length)
* Writes the string using uncompressed notation, no rich text, no Asian phonetics
* If mbstring extension is not available, ASCII is assumed, and compressed notation is used
* although this will give wrong results for non-ASCII strings
* see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3
*
* @param string $value UTF-8 encoded string
* @return string
*/
public static function UTF8toBIFF8UnicodeLong($value)
{
// character count
$ln = self::CountCharacters($value, 'UTF-8');
// option flags
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
0x0001 : 0x0000;
// characters
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
$data = pack('vC', $ln, $opt) . $chars;
return $data;
}
/**
* Convert string from one encoding to another. First try iconv, then mbstring, or no convertion
*
* @param string $value
* @param string $to Encoding to convert to, e.g. 'UTF-8'
* @param string $from Encoding to convert from, e.g. 'UTF-16LE'
* @return string
*/
public static function ConvertEncoding($value, $to, $from)
{
if (self::getIsIconvEnabled()) {
$value = iconv($from, $to, $value);
return $value;
}
if (self::getIsMbstringEnabled()) {
$value = mb_convert_encoding($value, $to, $from);
return $value;
}
if($from == 'UTF-16LE'){
return self::utf16_decode($value, false);
}else if($from == 'UTF-16BE'){
return self::utf16_decode($value);
}
// else, no conversion
return $value;
}
/**
* Decode UTF-16 encoded strings.
*
* Can handle both BOM'ed data and un-BOM'ed data.
* Assumes Big-Endian byte order if no BOM is available.
* This function was taken from http://php.net/manual/en/function.utf8-decode.php
* and $bom_be parameter added.
*
* @param string $str UTF-16 encoded data to decode.
* @return string UTF-8 / ISO encoded data.
* @access public
* @version 0.2 / 2010-05-13
* @author Rasmus Andersson {@link http://rasmusandersson.se/}
* @author vadik56
*/
public static function utf16_decode( $str, $bom_be=true ) {
if( strlen($str) < 2 ) return $str;
$c0 = ord($str{0});
$c1 = ord($str{1});
if( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); }
elseif( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; }
$len = strlen($str);
$newstr = '';
for($i=0;$i<$len;$i+=2) {
if( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); }
else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); }
$newstr .= ($val == 0x228) ? "\n" : chr($val);
}
return $newstr;
}
/**
* Get character count. First try mbstring, then iconv, finally strlen
*
* @param string $value
* @param string $enc Encoding
* @return int Character count
*/
public static function CountCharacters($value, $enc = 'UTF-8')
{
if (self::getIsIconvEnabled()) {
return iconv_strlen($value, $enc);
}
if (self::getIsMbstringEnabled()) {
return mb_strlen($value, $enc);
}
// else strlen
return strlen($value);
}
/**
* Get a substring of a UTF-8 encoded string
*
* @param string $pValue UTF-8 encoded string
* @param int $start Start offset
* @param int $length Maximum number of characters in substring
* @return string
*/
public static function Substring($pValue = '', $pStart = 0, $pLength = 0)
{
if (self::getIsIconvEnabled()) {
return iconv_substr($pValue, $pStart, $pLength, 'UTF-8');
}
if (self::getIsMbstringEnabled()) {
return mb_substr($pValue, $pStart, $pLength, 'UTF-8');
}
// else substr
return substr($pValue, $pStart, $pLength);
}
/**
* Identify whether a string contains a fractional numeric value,
* and convert it to a numeric if it is
*
* @param string &$operand string value to test
* @return boolean
*/
public static function convertToNumberIfFraction(&$operand) {
if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) {
$sign = ($match[1] == '-') ? '-' : '+';
$fractionFormula = '='.$sign.$match[2].$sign.$match[3];
$operand = PHPExcel_Calculation::getInstance()->_calculateFormulaValue($fractionFormula);
return true;
}
return false;
} // function convertToNumberIfFraction()
/**
* Get the decimal separator. If it has not yet been set explicitly, try to obtain number
* formatting information from locale.
*
* @return string
*/
public static function getDecimalSeparator()
{
if (!isset(self::$_decimalSeparator)) {
$localeconv = localeconv();
self::$_decimalSeparator = $localeconv['decimal_point'] != ''
? $localeconv['decimal_point'] : $localeconv['mon_decimal_point'];
if (self::$_decimalSeparator == '') {
// Default to .
self::$_decimalSeparator = '.';
}
}
return self::$_decimalSeparator;
}
/**
* Set the decimal separator. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
* to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
*
* @param string $pValue Character for decimal separator
*/
public static function setDecimalSeparator($pValue = '.')
{
self::$_decimalSeparator = $pValue;
}
/**
* Get the thousands separator. If it has not yet been set explicitly, try to obtain number
* formatting information from locale.
*
* @return string
*/
public static function getThousandsSeparator()
{
if (!isset(self::$_thousandsSeparator)) {
$localeconv = localeconv();
self::$_thousandsSeparator = $localeconv['thousands_sep'] != ''
? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep'];
}
return self::$_thousandsSeparator;
}
/**
* Set the thousands separator. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
* to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
*
* @param string $pValue Character for thousands separator
*/
public static function setThousandsSeparator($pValue = ',')
{
self::$_thousandsSeparator = $pValue;
}
/**
* Get the currency code. If it has not yet been set explicitly, try to obtain the
* symbol information from locale.
*
* @return string
*/
public static function getCurrencyCode()
{
if (!isset(self::$_currencyCode)) {
$localeconv = localeconv();
self::$_currencyCode = $localeconv['currency_symbol'] != ''
? $localeconv['currency_symbol'] : $localeconv['int_curr_symbol'];
if (self::$_currencyCode == '') {
// Default to $
self::$_currencyCode = '$';
}
}
return self::$_currencyCode;
}
/**
* Set the currency code. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
* to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
*
* @param string $pValue Character for currency code
*/
public static function setCurrencyCode($pValue = '$')
{
self::$_currencyCode = $pValue;
}
/**
* Convert SYLK encoded string to UTF-8
*
* @param string $pValue
* @return string UTF-8 encoded string
*/
public static function SYLKtoUTF8($pValue = '')
{
// If there is no escape character in the string there is nothing to do
if (strpos($pValue, '') === false) {
return $pValue;
}
foreach (self::$_SYLKCharacters as $k => $v) {
$pValue = str_replace($k, $v, $pValue);
}
return $pValue;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/String.php | PHP | asf20 | 20,787 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Excel5
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Excel5
{
/**
* Get the width of a column in pixels. We use the relationship y = ceil(7x) where
* x is the width in intrinsic Excel units (measuring width in number of normal characters)
* This holds for Arial 10
*
* @param PHPExcel_Worksheet $sheet The sheet
* @param integer $col The column
* @return integer The width in pixels
*/
public static function sizeCol($sheet, $col = 'A')
{
// default font of the workbook
$font = $sheet->getParent()->getDefaultStyle()->getFont();
$columnDimensions = $sheet->getColumnDimensions();
// first find the true column width in pixels (uncollapsed and unhidden)
if ( isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1 ) {
// then we have column dimension with explicit width
$columnDimension = $columnDimensions[$col];
$width = $columnDimension->getWidth();
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
} else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
// then we have default column dimension with explicit width
$defaultColumnDimension = $sheet->getDefaultColumnDimension();
$width = $defaultColumnDimension->getWidth();
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
} else {
// we don't even have any default column dimension. Width depends on default font
$pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true);
}
// now find the effective column width in pixels
if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) {
$effectivePixelWidth = 0;
} else {
$effectivePixelWidth = $pixelWidth;
}
return $effectivePixelWidth;
}
/**
* Convert the height of a cell from user's units to pixels. By interpolation
* the relationship is: y = 4/3x. If the height hasn't been set by the user we
* use the default value. If the row is hidden we use a value of zero.
*
* @param PHPExcel_Worksheet $sheet The sheet
* @param integer $row The row index (1-based)
* @return integer The width in pixels
*/
public static function sizeRow($sheet, $row = 1)
{
// default font of the workbook
$font = $sheet->getParent()->getDefaultStyle()->getFont();
$rowDimensions = $sheet->getRowDimensions();
// first find the true row height in pixels (uncollapsed and unhidden)
if ( isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) {
// then we have a row dimension
$rowDimension = $rowDimensions[$row];
$rowHeight = $rowDimension->getRowHeight();
$pixelRowHeight = (int) ceil(4 * $rowHeight / 3); // here we assume Arial 10
} else if ($sheet->getDefaultRowDimension()->getRowHeight() != -1) {
// then we have a default row dimension with explicit height
$defaultRowDimension = $sheet->getDefaultRowDimension();
$rowHeight = $defaultRowDimension->getRowHeight();
$pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight);
} else {
// we don't even have any default row dimension. Height depends on default font
$pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font);
$pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight);
}
// now find the effective row height in pixels
if ( isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible() ) {
$effectivePixelRowHeight = 0;
} else {
$effectivePixelRowHeight = $pixelRowHeight;
}
return $effectivePixelRowHeight;
}
/**
* Get the horizontal distance in pixels between two anchors
* The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets
*
* @param PHPExcel_Worksheet $sheet
* @param string $startColumn
* @param integer $startOffset Offset within start cell measured in 1/1024 of the cell width
* @param string $endColumn
* @param integer $endOffset Offset within end cell measured in 1/1024 of the cell width
* @return integer Horizontal measured in pixels
*/
public static function getDistanceX(PHPExcel_Worksheet $sheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0)
{
$distanceX = 0;
// add the widths of the spanning columns
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; // 1-based
$endColumnIndex = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; // 1-based
for ($i = $startColumnIndex; $i <= $endColumnIndex; ++$i) {
$distanceX += self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($i));
}
// correct for offsetX in startcell
$distanceX -= (int) floor(self::sizeCol($sheet, $startColumn) * $startOffsetX / 1024);
// correct for offsetX in endcell
$distanceX -= (int) floor(self::sizeCol($sheet, $endColumn) * (1 - $endOffsetX / 1024));
return $distanceX;
}
/**
* Get the vertical distance in pixels between two anchors
* The distanceY is found as sum of all the spanning rows minus two offsets
*
* @param PHPExcel_Worksheet $sheet
* @param string $startRow (1-based)
* @param integer $startOffset Offset within start cell measured in 1/256 of the cell height
* @param string $endRow (1-based)
* @param integer $endOffset Offset within end cell measured in 1/256 of the cell height
* @return integer Vertical distance measured in pixels
*/
public static function getDistanceY(PHPExcel_Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0)
{
$distanceY = 0;
// add the widths of the spanning rows
for ($row = $startRow; $row <= $endRow; ++$row) {
$distanceY += self::sizeRow($sheet, $row);
}
// correct for offsetX in startcell
$distanceY -= (int) floor(self::sizeRow($sheet, $startRow) * $startOffsetY / 256);
// correct for offsetX in endcell
$distanceY -= (int) floor(self::sizeRow($sheet, $endRow) * (1 - $endOffsetY / 256));
return $distanceY;
}
/**
* Convert 1-cell anchor coordinates to 2-cell anchor coordinates
* This function is ported from PEAR Spreadsheet_Writer_Excel with small modifications
*
* Calculate the vertices that define the position of the image as required by
* the OBJ record.
*
* +------------+------------+
* | A | B |
* +-----+------------+------------+
* | |(x1,y1) | |
* | 1 |(A1)._______|______ |
* | | | | |
* | | | | |
* +-----+----| BITMAP |-----+
* | | | | |
* | 2 | |______________. |
* | | | (B2)|
* | | | (x2,y2)|
* +---- +------------+------------+
*
* Example of a bitmap that covers some of the area from cell A1 to cell B2.
*
* Based on the width and height of the bitmap we need to calculate 8 vars:
* $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2.
* The width and height of the cells are also variable and have to be taken into
* account.
* The values of $col_start and $row_start are passed in from the calling
* function. The values of $col_end and $row_end are calculated by subtracting
* the width and height of the bitmap from the width and height of the
* underlying cells.
* The vertices are expressed as a percentage of the underlying cell width as
* follows (rhs values are in pixels):
*
* x1 = X / W *1024
* y1 = Y / H *256
* x2 = (X-1) / W *1024
* y2 = (Y-1) / H *256
*
* Where: X is distance from the left side of the underlying cell
* Y is distance from the top of the underlying cell
* W is the width of the cell
* H is the height of the cell
*
* @param PHPExcel_Worksheet $sheet
* @param string $coordinates E.g. 'A1'
* @param integer $offsetX Horizontal offset in pixels
* @param integer $offsetY Vertical offset in pixels
* @param integer $width Width in pixels
* @param integer $height Height in pixels
* @return array
*/
public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height)
{
list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinates);
$col_start = PHPExcel_Cell::columnIndexFromString($column) - 1;
$row_start = $row - 1;
$x1 = $offsetX;
$y1 = $offsetY;
// Initialise end cell to the same as the start cell
$col_end = $col_start; // Col containing lower right corner of object
$row_end = $row_start; // Row containing bottom right corner of object
// Zero the specified offset if greater than the cell dimensions
if ($x1 >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start))) {
$x1 = 0;
}
if ($y1 >= self::sizeRow($sheet, $row_start + 1)) {
$y1 = 0;
}
$width = $width + $x1 -1;
$height = $height + $y1 -1;
// Subtract the underlying cell widths to find the end cell of the image
while ($width >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end))) {
$width -= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end));
++$col_end;
}
// Subtract the underlying cell heights to find the end cell of the image
while ($height >= self::sizeRow($sheet, $row_end + 1)) {
$height -= self::sizeRow($sheet, $row_end + 1);
++$row_end;
}
// Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell
// with zero height or width.
if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) == 0) {
return;
}
if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) == 0) {
return;
}
if (self::sizeRow($sheet, $row_start + 1) == 0) {
return;
}
if (self::sizeRow($sheet, $row_end + 1) == 0) {
return;
}
// Convert the pixel values to the percentage value expected by Excel
$x1 = $x1 / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024;
$y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256;
$x2 = ($width + 1) / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object
$y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object
$startCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_start) . ($row_start + 1);
$endCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_end) . ($row_end + 1);
$twoAnchor = array(
'startCoordinates' => $startCoordinates,
'startOffsetX' => $x1,
'startOffsetY' => $y1,
'endCoordinates' => $endCoordinates,
'endOffsetX' => $x2,
'endOffsetY' => $y2,
);
return $twoAnchor;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Excel5.php | PHP | asf20 | 11,732 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Escher_DgContainer_SpgrContainer
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer
{
/**
* Parent Shape Group Container
*
* @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer
*/
private $_parent;
/**
* Shape Container collection
*
* @var array
*/
private $_children = array();
/**
* Set parent Shape Group Container
*
* @param PHPExcel_Shared_Escher_DgContainer_SpgrContainer $parent
*/
public function setParent($parent)
{
$this->_parent = $parent;
}
/**
* Get the parent Shape Group Container if any
*
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer|null
*/
public function getParent()
{
return $this->_parent;
}
/**
* Add a child. This will be either spgrContainer or spContainer
*
* @param mixed $child
*/
public function addChild($child)
{
$this->_children[] = $child;
$child->setParent($this);
}
/**
* Get collection of Shape Containers
*/
public function getChildren()
{
return $this->_children;
}
/**
* Recursively get all spContainers within this spgrContainer
*
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer[]
*/
public function getAllSpContainers()
{
$allSpContainers = array();
foreach ($this->_children as $child) {
if ($child instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer) {
$allSpContainers = array_merge($allSpContainers, $child->getAllSpContainers());
} else {
$allSpContainers[] = $child;
}
}
return $allSpContainers;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php | PHP | asf20 | 2,763 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
{
/**
* Parent Shape Group Container
*
* @var PHPExcel_Shared_Escher_DgContainer_SpgrContainer
*/
private $_parent;
/**
* Is this a group shape?
*
* @var boolean
*/
private $_spgr = false;
/**
* Shape type
*
* @var int
*/
private $_spType;
/**
* Shape index (usually group shape has index 0, and the rest: 1,2,3...)
*
* @var boolean
*/
private $_spId;
/**
* Array of options
*
* @var array
*/
private $_OPT;
/**
* Cell coordinates of upper-left corner of shape, e.g. 'A1'
*
* @var string
*/
private $_startCoordinates;
/**
* Horizontal offset of upper-left corner of shape measured in 1/1024 of column width
*
* @var int
*/
private $_startOffsetX;
/**
* Vertical offset of upper-left corner of shape measured in 1/256 of row height
*
* @var int
*/
private $_startOffsetY;
/**
* Cell coordinates of bottom-right corner of shape, e.g. 'B2'
*
* @var string
*/
private $_endCoordinates;
/**
* Horizontal offset of bottom-right corner of shape measured in 1/1024 of column width
*
* @var int
*/
private $_endOffsetX;
/**
* Vertical offset of bottom-right corner of shape measured in 1/256 of row height
*
* @var int
*/
private $_endOffsetY;
/**
* Set parent Shape Group Container
*
* @param PHPExcel_Shared_Escher_DgContainer_SpgrContainer $parent
*/
public function setParent($parent)
{
$this->_parent = $parent;
}
/**
* Get the parent Shape Group Container
*
* @return PHPExcel_Shared_Escher_DgContainer_SpgrContainer
*/
public function getParent()
{
return $this->_parent;
}
/**
* Set whether this is a group shape
*
* @param boolean $value
*/
public function setSpgr($value = false)
{
$this->_spgr = $value;
}
/**
* Get whether this is a group shape
*
* @return boolean
*/
public function getSpgr()
{
return $this->_spgr;
}
/**
* Set the shape type
*
* @param int $value
*/
public function setSpType($value)
{
$this->_spType = $value;
}
/**
* Get the shape type
*
* @return int
*/
public function getSpType()
{
return $this->_spType;
}
/**
* Set the shape index
*
* @param int $value
*/
public function setSpId($value)
{
$this->_spId = $value;
}
/**
* Get the shape index
*
* @return int
*/
public function getSpId()
{
return $this->_spId;
}
/**
* Set an option for the Shape Group Container
*
* @param int $property The number specifies the option
* @param mixed $value
*/
public function setOPT($property, $value)
{
$this->_OPT[$property] = $value;
}
/**
* Get an option for the Shape Group Container
*
* @param int $property The number specifies the option
* @return mixed
*/
public function getOPT($property)
{
if (isset($this->_OPT[$property])) {
return $this->_OPT[$property];
}
return null;
}
/**
* Get the collection of options
*
* @return array
*/
public function getOPTCollection()
{
return $this->_OPT;
}
/**
* Set cell coordinates of upper-left corner of shape
*
* @param string $value
*/
public function setStartCoordinates($value = 'A1')
{
$this->_startCoordinates = $value;
}
/**
* Get cell coordinates of upper-left corner of shape
*
* @return string
*/
public function getStartCoordinates()
{
return $this->_startCoordinates;
}
/**
* Set offset in x-direction of upper-left corner of shape measured in 1/1024 of column width
*
* @param int $startOffsetX
*/
public function setStartOffsetX($startOffsetX = 0)
{
$this->_startOffsetX = $startOffsetX;
}
/**
* Get offset in x-direction of upper-left corner of shape measured in 1/1024 of column width
*
* @return int
*/
public function getStartOffsetX()
{
return $this->_startOffsetX;
}
/**
* Set offset in y-direction of upper-left corner of shape measured in 1/256 of row height
*
* @param int $startOffsetY
*/
public function setStartOffsetY($startOffsetY = 0)
{
$this->_startOffsetY = $startOffsetY;
}
/**
* Get offset in y-direction of upper-left corner of shape measured in 1/256 of row height
*
* @return int
*/
public function getStartOffsetY()
{
return $this->_startOffsetY;
}
/**
* Set cell coordinates of bottom-right corner of shape
*
* @param string $value
*/
public function setEndCoordinates($value = 'A1')
{
$this->_endCoordinates = $value;
}
/**
* Get cell coordinates of bottom-right corner of shape
*
* @return string
*/
public function getEndCoordinates()
{
return $this->_endCoordinates;
}
/**
* Set offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width
*
* @param int $startOffsetX
*/
public function setEndOffsetX($endOffsetX = 0)
{
$this->_endOffsetX = $endOffsetX;
}
/**
* Get offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width
*
* @return int
*/
public function getEndOffsetX()
{
return $this->_endOffsetX;
}
/**
* Set offset in y-direction of bottom-right corner of shape measured in 1/256 of row height
*
* @param int $endOffsetY
*/
public function setEndOffsetY($endOffsetY = 0)
{
$this->_endOffsetY = $endOffsetY;
}
/**
* Get offset in y-direction of bottom-right corner of shape measured in 1/256 of row height
*
* @return int
*/
public function getEndOffsetY()
{
return $this->_endOffsetY;
}
/**
* Get the nesting level of this spContainer. This is the number of spgrContainers between this spContainer and
* the dgContainer. A value of 1 = immediately within first spgrContainer
* Higher nesting level occurs if and only if spContainer is part of a shape group
*
* @return int Nesting level
*/
public function getNestingLevel()
{
$nestingLevel = 0;
$parent = $this->getParent();
while ($parent instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer) {
++$nestingLevel;
$parent = $parent->getParent();
}
return $nestingLevel;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php | PHP | asf20 | 7,371 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Escher_DgContainer
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DgContainer
{
/**
* Drawing index, 1-based.
*
* @var int
*/
private $_dgId;
/**
* Last shape index in this drawing
*
* @var int
*/
private $_lastSpId;
private $_spgrContainer = null;
public function getDgId()
{
return $this->_dgId;
}
public function setDgId($value)
{
$this->_dgId = $value;
}
public function getLastSpId()
{
return $this->_lastSpId;
}
public function setLastSpId($value)
{
$this->_lastSpId = $value;
}
public function getSpgrContainer()
{
return $this->_spgrContainer;
}
public function setSpgrContainer($spgrContainer)
{
return $this->_spgrContainer = $spgrContainer;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Escher/DgContainer.php | PHP | asf20 | 1,944 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer
{
/**
* BLIP Store Entries. Each of them holds one BLIP (Big Large Image or Picture)
*
* @var array
*/
private $_BSECollection = array();
/**
* Add a BLIP Store Entry
*
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE $BSE
*/
public function addBSE($BSE)
{
$this->_BSECollection[] = $BSE;
$BSE->setParent($this);
}
/**
* Get the collection of BLIP Store Entries
*
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE[]
*/
public function getBSECollection()
{
return $this->_BSECollection;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php | PHP | asf20 | 1,905 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
{
/**
* The parent BSE
*
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
*/
private $_parent;
/**
* Raw image data
*
* @var string
*/
private $_data;
/**
* Get the raw image data
*
* @return string
*/
public function getData()
{
return $this->_data;
}
/**
* Set the raw image data
*
* @param string
*/
public function setData($data)
{
$this->_data = $data;
}
/**
* Set parent BSE
*
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE $parent
*/
public function setParent($parent)
{
$this->_parent = $parent;
}
/**
* Get parent BSE
*
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE $parent
*/
public function getParent()
{
return $this->_parent;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php | PHP | asf20 | 2,135 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
{
const BLIPTYPE_ERROR = 0x00;
const BLIPTYPE_UNKNOWN = 0x01;
const BLIPTYPE_EMF = 0x02;
const BLIPTYPE_WMF = 0x03;
const BLIPTYPE_PICT = 0x04;
const BLIPTYPE_JPEG = 0x05;
const BLIPTYPE_PNG = 0x06;
const BLIPTYPE_DIB = 0x07;
const BLIPTYPE_TIFF = 0x11;
const BLIPTYPE_CMYKJPEG = 0x12;
/**
* The parent BLIP Store Entry Container
*
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer
*/
private $_parent;
/**
* The BLIP (Big Large Image or Picture)
*
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
*/
private $_blip;
/**
* The BLIP type
*
* @var int
*/
private $_blipType;
/**
* Set parent BLIP Store Entry Container
*
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer $parent
*/
public function setParent($parent)
{
$this->_parent = $parent;
}
/**
* Get the BLIP
*
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
*/
public function getBlip()
{
return $this->_blip;
}
/**
* Set the BLIP
*
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip $blip
*/
public function setBlip($blip)
{
$this->_blip = $blip;
$blip->setParent($this);
}
/**
* Get the BLIP type
*
* @return int
*/
public function getBlipType()
{
return $this->_blipType;
}
/**
* Set the BLIP type
*
* @param int
*/
public function setBlipType($blipType)
{
$this->_blipType = $blipType;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php | PHP | asf20 | 2,807 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_Escher_DggContainer
*
* @category PHPExcel
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_Escher_DggContainer
{
/**
* Maximum shape index of all shapes in all drawings increased by one
*
* @var int
*/
private $_spIdMax;
/**
* Total number of drawings saved
*
* @var int
*/
private $_cDgSaved;
/**
* Total number of shapes saved (including group shapes)
*
* @var int
*/
private $_cSpSaved;
/**
* BLIP Store Container
*
* @var PHPExcel_Shared_Escher_DggContainer_BstoreContainer
*/
private $_bstoreContainer;
/**
* Array of options for the drawing group
*
* @var array
*/
private $_OPT = array();
/**
* Array of identifier clusters containg information about the maximum shape identifiers
*
* @var array
*/
private $_IDCLs = array();
/**
* Get maximum shape index of all shapes in all drawings (plus one)
*
* @return int
*/
public function getSpIdMax()
{
return $this->_spIdMax;
}
/**
* Set maximum shape index of all shapes in all drawings (plus one)
*
* @param int
*/
public function setSpIdMax($value)
{
$this->_spIdMax = $value;
}
/**
* Get total number of drawings saved
*
* @return int
*/
public function getCDgSaved()
{
return $this->_cDgSaved;
}
/**
* Set total number of drawings saved
*
* @param int
*/
public function setCDgSaved($value)
{
$this->_cDgSaved = $value;
}
/**
* Get total number of shapes saved (including group shapes)
*
* @return int
*/
public function getCSpSaved()
{
return $this->_cSpSaved;
}
/**
* Set total number of shapes saved (including group shapes)
*
* @param int
*/
public function setCSpSaved($value)
{
$this->_cSpSaved = $value;
}
/**
* Get BLIP Store Container
*
* @return PHPExcel_Shared_Escher_DggContainer_BstoreContainer
*/
public function getBstoreContainer()
{
return $this->_bstoreContainer;
}
/**
* Set BLIP Store Container
*
* @param PHPExcel_Shared_Escher_DggContainer_BstoreContainer $bstoreContainer
*/
public function setBstoreContainer($bstoreContainer)
{
$this->_bstoreContainer = $bstoreContainer;
}
/**
* Set an option for the drawing group
*
* @param int $property The number specifies the option
* @param mixed $value
*/
public function setOPT($property, $value)
{
$this->_OPT[$property] = $value;
}
/**
* Get an option for the drawing group
*
* @param int $property The number specifies the option
* @return mixed
*/
public function getOPT($property)
{
if (isset($this->_OPT[$property])) {
return $this->_OPT[$property];
}
return null;
}
/**
* Get identifier clusters
*
* @return array
*/
public function getIDCLs()
{
return $this->_IDCLs;
}
/**
* Set identifier clusters. array(<drawingId> => <max shape id>, ...)
*
* @param array $pValue
*/
public function setIDCLs($pValue)
{
$this->_IDCLs = $pValue;
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/Escher/DggContainer.php | PHP | asf20 | 4,121 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_ZipStreamWrapper
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_ZipStreamWrapper {
/**
* Internal ZipAcrhive
*
* @var ZipAcrhive
*/
private $_archive;
/**
* Filename in ZipAcrhive
*
* @var string
*/
private $_fileNameInArchive = '';
/**
* Position in file
*
* @var int
*/
private $_position = 0;
/**
* Data
*
* @var mixed
*/
private $_data = '';
/**
* Register wrapper
*/
public static function register() {
@stream_wrapper_unregister("zip");
@stream_wrapper_register("zip", __CLASS__);
}
/**
* Open stream
*/
public function stream_open($path, $mode, $options, &$opened_path) {
// Check for mode
if ($mode{0} != 'r') {
throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
}
$pos = strrpos($path, '#');
$url['host'] = substr($path, 6, $pos - 6); // 6: strlen('zip://')
$url['fragment'] = substr($path, $pos + 1);
// Open archive
$this->_archive = new ZipArchive();
$this->_archive->open($url['host']);
$this->_fileNameInArchive = $url['fragment'];
$this->_position = 0;
$this->_data = $this->_archive->getFromName( $this->_fileNameInArchive );
return true;
}
/**
* Stat stream
*/
public function stream_stat() {
return $this->_archive->statName( $this->_fileNameInArchive );
}
/**
* Read stream
*/
function stream_read($count) {
$ret = substr($this->_data, $this->_position, $count);
$this->_position += strlen($ret);
return $ret;
}
/**
* Tell stream
*/
public function stream_tell() {
return $this->_position;
}
/**
* EOF stream
*/
public function stream_eof() {
return $this->_position >= strlen($this->_data);
}
/**
* Seek stream
*/
public function stream_seek($offset, $whence) {
switch ($whence) {
case SEEK_SET:
if ($offset < strlen($this->_data) && $offset >= 0) {
$this->_position = $offset;
return true;
} else {
return false;
}
break;
case SEEK_CUR:
if ($offset >= 0) {
$this->_position += $offset;
return true;
} else {
return false;
}
break;
case SEEK_END:
if (strlen($this->_data) + $offset >= 0) {
$this->_position = strlen($this->_data) + $offset;
return true;
} else {
return false;
}
break;
default:
return false;
}
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/ZipStreamWrapper.php | PHP | asf20 | 4,161 |
<?php
include_once "includes/header.php";
include_once "includes/navbar.php";
?>
<h2>Magic Square Example</h2>
<p>
The Jama distribution comes with a magic square example that is used to
test and benchmark the LU, QR, SVD and symmetric Eig decompositions.
The example outputs a multi-column table with these column headings:
</p>
<table border='1' cellpadding='5' cellspacing='0' align='center'>
<tr>
<td><b>n</b></td>
<td>Order of magic square.</td>
</tr>
<tr>
<td><b>trace</b></td>
<td>Diagonal sum, should be the magic sum, (n^3 + n)/2.</td>
</tr>
<tr>
<td><b>max_eig</b></td>
<td>Maximum eigenvalue of (A + A')/2, should equal trace.</td>
</tr>
<tr>
<td><b>rank</b></td>
<td>Linear algebraic rank, should equal n if n is odd, be less than n if n is even.</td>
</tr>
<tr>
<td><b>cond</b></td>
<td>L_2 condition number, ratio of singular values.</td>
</tr>
<tr>
<td><b>lu_res</b></td>
<td>test of LU factorization, norm1(L*U-A(p,:))/(n*eps).</td>
</tr>
<tr>
<td><b>qr_res</b></td>
<td>test of QR factorization, norm1(Q*R-A)/(n*eps).</td>
</tr>
</table>
<p>
Running the Java-based version of the matix square example produces these results:
</p>
<table border='1' align='center'>
<tr>
<th> n </th>
<th> trace </th>
<th> max_eig </th>
<th> rank </th>
<th> cond </th>
<th> lu_res </th>
<th> qr_res </th>
</tr>
<tr>
<td>3</td><td>15</td><td>15.000</td><td>3</td><td>4.330</td><td>0.000</td><td>11.333</td>
</tr>
<tr>
<td>4</td><td>34</td><td>34.000</td><td>3</td><td> Inf</td><td>0.000</td><td>13.500</td>
<tr>
<td>5</td><td>65</td><td>65.000</td><td>5</td><td>5.462</td><td>0.000</td><td>14.400</td>
</tr>
<tr>
<td>6</td><td>111</td><td>111.000</td><td>5</td><td> Inf</td><td>5.333</td><td>16.000</td>
</tr>
<tr>
<td>7</td><td>175</td><td>175.000</td><td>7</td><td>7.111</td><td>2.286</td><td>37.714</td>
</tr>
<tr>
<td>8</td><td>260</td><td>260.000</td><td>3</td><td> Inf</td><td>0.000</td><td>59.000</td>
</tr>
<tr>
<td>9</td><td>369</td><td>369.000</td><td>9</td><td>9.102</td><td>7.111</td><td>53.333</td>
</tr>
<tr>
<td>10</td><td>505</td><td>505.000</td><td>7</td><td> Inf</td><td>3.200</td><td>159.200</td>
</tr>
<tr>
<td>11</td><td>671</td><td>671.000</td><td>11</td><td>11.102</td><td>2.909</td><td>215.273</td>
</tr>
<tr>
<td>12</td><td>870</td><td>870.000</td><td>3</td><td> Inf</td><td>0.000</td><td>185.333</td>
</tr>
<tr>
<td>13</td><td>1105</td><td>1105.000</td><td>13</td><td>13.060</td><td>4.923</td><td>313.846</td>
</tr>
<tr>
<td>14</td><td>1379</td><td>1379.000</td><td>9</td><td> Inf</td><td>4.571</td><td>540.571</td>
</tr>
<tr>
<td>15</td><td>1695</td><td>1695.000</td><td>15</td><td>15.062</td><td>4.267</td><td>242.133</td>
</tr>
<tr>
<td>16</td><td>2056</td><td>2056.000</td><td>3</td><td> Inf</td><td>0.000</td><td>488.500</td>
</tr>
<tr>
<td>17</td><td>2465</td><td>2465.000</td><td>17</td><td>17.042</td><td>7.529</td><td>267.294</td>
</tr>
<tr>
<td>18</td><td>2925</td><td>2925.000</td><td>11</td><td> Inf</td><td>7.111</td><td>520.889</td>
</tr>
<tr>
<td>19</td><td>3439</td><td>3439.000</td><td>19</td><td>19.048</td><td>16.842</td><td>387.368</td>
</tr>
<tr>
<td>20</td><td>4010</td><td>4010.000</td><td>3</td><td> Inf</td><td>14.400</td><td>584.800</td>
</tr>
<tr>
<td>21</td><td>4641</td><td>4641.000</td><td>21</td><td>21.035</td><td>6.095</td><td>1158.095</td>
</tr>
<tr>
<td>22</td><td>5335</td><td>5335.000</td><td>13</td><td> Inf</td><td>6.545</td><td>1132.364</td>
</tr>
<tr>
<td>23</td><td>6095</td><td>6095.000</td><td>23</td><td>23.037</td><td>11.130</td><td>1268.870</td>
</tr>
<tr>
<td>24</td><td>6924</td><td>6924.000</td><td>3</td><td> Inf</td><td>10.667</td><td>827.500</td>
</tr>
<tr>
<td>25</td><td>7825</td><td>7825.000</td><td>25</td><td>25.029</td><td>35.840</td><td>1190.400</td>
</tr>
<tr>
<td>26</td><td>8801</td><td>8801.000</td><td>15</td><td> Inf</td><td>4.923</td><td>1859.077</td>
</tr>
<tr>
<td>27</td><td>9855</td><td>9855.000</td><td>27</td><td>27.032</td><td>37.926</td><td>1365.333</td>
</tr>
<tr>
<td>28</td><td>10990</td><td>10990.000</td><td>3</td><td> Inf</td><td>34.286</td><td>1365.714</td>
</tr>
<tr>
<td>29</td><td>12209</td><td>12209.000</td><td>29</td><td>29.025</td><td>30.897</td><td>1647.448</td>
</tr>
<tr>
<td>30</td><td>13515</td><td>13515.000</td><td>17</td><td> Inf</td><td>8.533</td><td>2571.733</td>
</tr>
<tr>
<td>31</td><td>14911</td><td>14911.000</td><td>31</td><td>31.027</td><td>33.032</td><td>1426.581</td>
</tr>
<tr>
<td>32</td><td>16400</td><td>16400.000</td><td>3</td><td> Inf</td><td>0.000</td><td>1600.125</td>
</tr>
</table>
<center>Elapsed Time = 0.710 seconds</center>
<p>
The magic square example does not fare well when <a href='../examples/MagicSquareExample.php'>run as a PHP script</a>. For a 32x32 matrix array
it takes around a second to complete just the last row of computations in the above table.
Hopefully this result will spur PHP developers to find optimizations and better attuned algorithms
to speed things up. Matrix algebra is a great testing ground for ideas about time and memory
performance optimation. Keep in perspective that PHP JAMA scripts are still plenty fast for use as
a tool for learning about matrix algebra and quickly extending your knowledge with new scripts
to apply knowledge.
</p>
<p>
To learn more about the subject of magic squares you can visit the <a href='http://mathforum.org/alejandre/magic.square.html'>Drexel Math Forum on Magic Squares</a>.
You can also learn more by carefully examining the <code>MagicSquareExample.php</code> source code below.
</p>
<?php
highlight_file("../examples/MagicSquareExample.php");
include_once "includes/footer.php";
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/docs/example.php | PHP | asf20 | 6,009 |
<?php
include_once "includes/header.php";
include_once "includes/navbar.php";
?>
<p>
JAMA is a proposed standard matrix class for Java. The JAMA introduction
describes "JAMA : A Java Matrix Package" in this way:
</p>
<blockquote>
JAMA is a basic linear algebra package for Java. It provides user-level classes for
constructing and manipulating real, dense matrices. It is meant to provide sufficient
functionality for routine problems, packaged in a way that is natural and understandable
to non-experts. It is intended to serve as the standard matrix class for Java, and
will be proposed as such to the Java Grande Forum and then to Sun. A straightforward
public-domain reference implementation has been developed by the MathWorks and NIST as
a strawman for such a class. We are releasing this version in order to obtain public
comment. There is no guarantee that future versions of JAMA will be compatible with this one.
</blockquote>
<p>
The development team below has successfully ported the JAMA API to PHP. You can explore
this site to learn more about this project and it's current development status.
</p>
<?php
include_once "includes/credits.php";
include_once "includes/footer.php";
?> | zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/docs/index.php | PHP | asf20 | 1,217 |
<?php
/**
* Script to create REGRESS package for download
*
* @author Mike Bommarito
* @author Paul Meagher
* @version 0.3
* @modified Apr 2, 2006
*
* Note: Script requires the PEAR Archive_Tar package be installed:
*
* @see http://pear.php.net/package/Archive_Tar
*/
// name and directory of package
$pkgName = "JAMA";
// root of PHP/Math build directory
$buildDir = substr(dirname(__FILE__), 0, -5 - strlen($pkgName));
// switch to PHP/Math build directory
chdir($buildDir);
$tarName = "$pkgName.tar.gz";
$tarPath = $buildDir.$pkgName."/downloads/".$tarName;
if($_GET['op'] == "download") {
require_once('Archive/Tar.php');
$tar = new Archive_Tar($tarPath);
// create $pkgName archive under $pkgName folder
$files = glob("$pkgName/*.php");
$files = array_merge($files, glob("$pkgName/*.TXT"));
$files = array_merge($files, glob("$pkgName/docs/*.php"));
$files = array_merge($files, glob("$pkgName/docs/includes/*.php"));
$files = array_merge($files, glob("$pkgName/examples/*.php"));
$files = array_merge($files, glob("$pkgName/tests/*.php"));
$files = array_merge($files, glob("$pkgName/utils/*.php"));
$tar->create($files);
// create the download url
$webDir = substr($_SERVER['PHP_SELF'], 0, -18);
$urlPath = "http://".$_SERVER['HTTP_HOST'].$webDir."/downloads";
// redirect to download url
header("Location: $urlPath/$tarName");
}
include_once "includes/header.php";
include_once "includes/navbar.php";
?>
<p>
Download current version:
</p>
<ul>
<li><a href='<?php echo $_SERVER['PHP_SELF']."?op=download"; ?>'><?php echo $tarName ?></a></li>
</ul>
<?php
include_once "includes/footer.php";
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/docs/download.php | PHP | asf20 | 1,670 |
<center>
<hr />
[ <a href="index.php">index.php</a> ] [ <a href="docs.php">docs.php</a> ] [ <a href="package.php">package.php</a> ] [ <a href="test.php">test.php</a> ] [ <a href="example.php">example.php</a> ] [ <a href="download.php">download.php</a> ]
<hr />
</center>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/docs/includes/navbar.php | Hack | asf20 | 279 |
<div id="credits">
<p>
Brought to you by:
</p>
<ul>
<li><a href="http://math.nist.gov/">National Institute of Standards and Technology</a></li>
<li><a href="http://math.nist.gov/">MathWorks</a></li>
<li><a href="http://math.nist.gov/javanumerics/jama/">JAMA : A Java Matrix Package</a></li>
<li>Paul Meagher</li>
<li>Michael Bommarito</li>
<li>Lukasz Karapuda</li>
<li>Bartek Matosiuk</li>
</ul>
</div>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/docs/includes/credits.php | Hack | asf20 | 435 |
</body>
</html>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/docs/includes/footer.php | Hack | asf20 | 17 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>JAMA v1.0.1</title>
<meta name="description" content="JAMA v1.0.1 - Port of the proposed standard Java Matrix Library to PHP" />
<meta name="robots" content="index, follow" />
<meta name="keywords" content="php, matrix, matrix library, cholesky decomposition, eigenvalue decomposition, eigenvector, lu decomposition, qr decomposition, singular value decomposition" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/docs/includes/header.php | Hack | asf20 | 660 |
<?php
include_once "includes/header.php";
include_once "includes/navbar.php";
?>
<p>
The first script your should run when you install Jama is the TestMatrix.php script.
</p>
<p>
This will run the unit tests for methods in the <code>Matrix.php</code> class. Because
the Matrix.php class can be used to invoke all the decomposition methods the <code>TestMatrix.php</code>
script is a test suite for the whole Jama package.
</p>
<p>
The original <code>TestMatrix.java</code> code uses try/catch error handling. We will
eventually create a build of JAMA that will take advantage of PHP5's new try/catch error
handling capabilities. This will improve our ability to replicate all the unit tests that
appeared in the original (except for some print methods that may not be worth porting).
</p>
<p>
You can <a href='../test/TestMatrix.php'>run the TestMatrix.php script</a> to see what
unit tests are currently implemented. The source of the <code>TestMatrix.php</code> script
is provided below. It is worth studying carefully for an example of how to do matrix algebra
programming with Jama.
</p>
<?php
highlight_file("../test/TestMatrix.php");
include_once "includes/footer.php";
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/docs/test.php | PHP | asf20 | 1,191 |
<?php
include_once "includes/header.php";
include_once "includes/navbar.php";
?>
<p>
Source Listing:
</p>
<ul>
<?php
chdir("../");
$files = glob("*.php");
$files = array_merge($files, glob("util/*.php"));
foreach ($files as $fileName) {
?>
<li><a href="package.php?view=<?php echo sha1($fileName);?>"><?php echo $fileName;?></a> - <?php echo date ("F d Y - g:i a", filemtime($fileName));?></li>
<?php
}
?>
</ul>
<?php
if( isset($_REQUEST['view']) ) {
$hash = $_REQUEST['view'];
$n = array_search($hash, array_map(sha1, $files));
$fileName = $files[$n];
?>
<hr />
Viewing: <?php echo $fileName;?>
<hr />
<?php
highlight_file($fileName);
?>
<hr />
<?php
}
include_once "includes/footer.php";
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/docs/package.php | PHP | asf20 | 746 |
<?php
require_once "includes/header.php";
require_once "includes/navbar.php";
require_once "sections/Home.php";
require_once "includes/footer.php";
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/docs/docs.php | PHP | asf20 | 152 |
<?php
/**
* @package JAMA
*
* Pythagorean Theorem:
*
* a = 3
* b = 4
* r = sqrt(square(a) + square(b))
* r = 5
*
* r = sqrt(a^2 + b^2) without under/overflow.
*/
function hypo($a, $b) {
if (abs($a) > abs($b)) {
$r = $b / $a;
$r = abs($a) * sqrt(1 + $r * $r);
} elseif ($b != 0) {
$r = $a / $b;
$r = abs($b) * sqrt(1 + $r * $r);
} else {
$r = 0.0;
}
return $r;
} // function hypo()
/**
* Mike Bommarito's version.
* Compute n-dimensional hyotheneuse.
*
function hypot() {
$s = 0;
foreach (func_get_args() as $d) {
if (is_numeric($d)) {
$s += pow($d, 2);
} else {
throw new Exception(JAMAError(ArgumentTypeException));
}
}
return sqrt($s);
}
*/
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/utils/Maths.php | PHP | asf20 | 690 |
<?php
/**
* @package JAMA
*
* Error handling
* @author Michael Bommarito
* @version 01292005
*/
//Language constant
define('JAMALANG', 'EN');
//All errors may be defined by the following format:
//define('ExceptionName', N);
//$error['lang'][ExceptionName] = 'Error message';
$error = array();
/*
I've used Babelfish and a little poor knowledge of Romance/Germanic languages for the translations here.
Feel free to correct anything that looks amiss to you.
*/
define('PolymorphicArgumentException', -1);
$error['EN'][PolymorphicArgumentException] = "Invalid argument pattern for polymorphic function.";
$error['FR'][PolymorphicArgumentException] = "Modèle inadmissible d'argument pour la fonction polymorphe.".
$error['DE'][PolymorphicArgumentException] = "Unzulässiges Argumentmuster für polymorphe Funktion.";
define('ArgumentTypeException', -2);
$error['EN'][ArgumentTypeException] = "Invalid argument type.";
$error['FR'][ArgumentTypeException] = "Type inadmissible d'argument.";
$error['DE'][ArgumentTypeException] = "Unzulässige Argumentart.";
define('ArgumentBoundsException', -3);
$error['EN'][ArgumentBoundsException] = "Invalid argument range.";
$error['FR'][ArgumentBoundsException] = "Gamme inadmissible d'argument.";
$error['DE'][ArgumentBoundsException] = "Unzulässige Argumentstrecke.";
define('MatrixDimensionException', -4);
$error['EN'][MatrixDimensionException] = "Matrix dimensions are not equal.";
$error['FR'][MatrixDimensionException] = "Les dimensions de Matrix ne sont pas égales.";
$error['DE'][MatrixDimensionException] = "Matrixmaße sind nicht gleich.";
define('PrecisionLossException', -5);
$error['EN'][PrecisionLossException] = "Significant precision loss detected.";
$error['FR'][PrecisionLossException] = "Perte significative de précision détectée.";
$error['DE'][PrecisionLossException] = "Bedeutender Präzision Verlust ermittelte.";
define('MatrixSPDException', -6);
$error['EN'][MatrixSPDException] = "Can only perform operation on symmetric positive definite matrix.";
$error['FR'][MatrixSPDException] = "Perte significative de précision détectée.";
$error['DE'][MatrixSPDException] = "Bedeutender Präzision Verlust ermittelte.";
define('MatrixSingularException', -7);
$error['EN'][MatrixSingularException] = "Can only perform operation on singular matrix.";
define('MatrixRankException', -8);
$error['EN'][MatrixRankException] = "Can only perform operation on full-rank matrix.";
define('ArrayLengthException', -9);
$error['EN'][ArrayLengthException] = "Array length must be a multiple of m.";
define('RowLengthException', -10);
$error['EN'][RowLengthException] = "All rows must have the same length.";
/**
* Custom error handler
* @param int $num Error number
*/
function JAMAError($errorNumber = null) {
global $error;
if (isset($errorNumber)) {
if (isset($error[JAMALANG][$errorNumber])) {
return $error[JAMALANG][$errorNumber];
} else {
return $error['EN'][$errorNumber];
}
} else {
return ("Invalid argument to JAMAError()");
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/utils/Error.php | PHP | asf20 | 3,031 |
<?php
require_once "../Matrix.php";
class TestMatrix {
function TestMatrix() {
// define test variables
$errorCount = 0;
$warningCount = 0;
$columnwise = array(1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.);
$rowwise = array(1.,4.,7.,10.,2.,5.,8.,11.,3.,6.,9.,12.);
$avals = array(array(1.,4.,7.,10.),array(2.,5.,8.,11.),array(3.,6.,9.,12.));
$rankdef = $avals;
$tvals = array(array(1.,2.,3.),array(4.,5.,6.),array(7.,8.,9.),array(10.,11.,12.));
$subavals = array(array(5.,8.,11.),array(6.,9.,12.));
$rvals = array(array(1.,4.,7.),array(2.,5.,8.,11.),array(3.,6.,9.,12.));
$pvals = array(array(1.,1.,1.),array(1.,2.,3.),array(1.,3.,6.));
$ivals = array(array(1.,0.,0.,0.),array(0.,1.,0.,0.),array(0.,0.,1.,0.));
$evals = array(array(0.,1.,0.,0.),array(1.,0.,2.e-7,0.),array(0.,-2.e-7,0.,1.),array(0.,0.,1.,0.));
$square = array(array(166.,188.,210.),array(188.,214.,240.),array(210.,240.,270.));
$sqSolution = array(array(13.),array(15.));
$condmat = array(array(1.,3.),array(7.,9.));
$rows = 3;
$cols = 4;
$invalidID = 5; /* should trigger bad shape for construction with val */
$raggedr = 0; /* (raggedr,raggedc) should be out of bounds in ragged array */
$raggedc = 4;
$validID = 3; /* leading dimension of intended test Matrices */
$nonconformld = 4; /* leading dimension which is valid, but nonconforming */
$ib = 1; /* index ranges for sub Matrix */
$ie = 2;
$jb = 1;
$je = 3;
$rowindexset = array(1,2);
$badrowindexset = array(1,3);
$columnindexset = array(1,2,3);
$badcolumnindexset = array(1,2,4);
$columnsummax = 33.;
$rowsummax = 30.;
$sumofdiagonals = 15;
$sumofsquares = 650;
/**
* Test matrix methods
*/
/**
* Constructors and constructor-like methods:
*
* Matrix(double[], int)
* Matrix(double[][])
* Matrix(int, int)
* Matrix(int, int, double)
* Matrix(int, int, double[][])
* constructWithCopy(double[][])
* random(int,int)
* identity(int)
*/
echo "<p>Testing constructors and constructor-like methods...</p>";
$A = new Matrix($columnwise, 3);
if($A instanceof Matrix) {
$this->try_success("Column-packed constructor...");
} else
$errorCount = $this->try_failure($errorCount, "Column-packed constructor...", "Unable to construct Matrix");
$T = new Matrix($tvals);
if($T instanceof Matrix)
$this->try_success("2D array constructor...");
else
$errorCount = $this->try_failure($errorCount, "2D array constructor...", "Unable to construct Matrix");
$A = new Matrix($columnwise, $validID);
$B = new Matrix($avals);
$tmp = $B->get(0,0);
$avals[0][0] = 0.0;
$C = $B->minus($A);
$avals[0][0] = $tmp;
$B = Matrix::constructWithCopy($avals);
$tmp = $B->get(0,0);
$avals[0][0] = 0.0;
/** check that constructWithCopy behaves properly **/
if ( ( $tmp - $B->get(0,0) ) != 0.0 )
$errorCount = $this->try_failure($errorCount,"constructWithCopy... ","copy not effected... data visible outside");
else
$this->try_success("constructWithCopy... ","");
$I = new Matrix($ivals);
if ( $this->checkMatrices($I,Matrix::identity(3,4)) )
$this->try_success("identity... ","");
else
$errorCount = $this->try_failure($errorCount,"identity... ","identity Matrix not successfully created");
/**
* Access Methods:
*
* getColumnDimension()
* getRowDimension()
* getArray()
* getArrayCopy()
* getColumnPackedCopy()
* getRowPackedCopy()
* get(int,int)
* getMatrix(int,int,int,int)
* getMatrix(int,int,int[])
* getMatrix(int[],int,int)
* getMatrix(int[],int[])
* set(int,int,double)
* setMatrix(int,int,int,int,Matrix)
* setMatrix(int,int,int[],Matrix)
* setMatrix(int[],int,int,Matrix)
* setMatrix(int[],int[],Matrix)
*/
print "<p>Testing access methods...</p>";
$B = new Matrix($avals);
if($B->getRowDimension() == $rows)
$this->try_success("getRowDimension...");
else
$errorCount = $this->try_failure($errorCount, "getRowDimension...");
if($B->getColumnDimension() == $cols)
$this->try_success("getColumnDimension...");
else
$errorCount = $this->try_failure($errorCount, "getColumnDimension...");
$barray = $B->getArray();
if($this->checkArrays($barray, $avals))
$this->try_success("getArray...");
else
$errorCount = $this->try_failure($errorCount, "getArray...");
$bpacked = $B->getColumnPackedCopy();
if($this->checkArrays($bpacked, $columnwise))
$this->try_success("getColumnPackedCopy...");
else
$errorCount = $this->try_failure($errorCount, "getColumnPackedCopy...");
$bpacked = $B->getRowPackedCopy();
if($this->checkArrays($bpacked, $rowwise))
$this->try_success("getRowPackedCopy...");
else
$errorCount = $this->try_failure($errorCount, "getRowPackedCopy...");
/**
* Array-like methods:
* minus
* minusEquals
* plus
* plusEquals
* arrayLeftDivide
* arrayLeftDivideEquals
* arrayRightDivide
* arrayRightDivideEquals
* arrayTimes
* arrayTimesEquals
* uminus
*/
print "<p>Testing array-like methods...</p>";
/**
* I/O methods:
* read
* print
* serializable:
* writeObject
* readObject
*/
print "<p>Testing I/O methods...</p>";
/**
* Test linear algebra methods
*/
echo "<p>Testing linear algebra methods...<p>";
$A = new Matrix($columnwise, 3);
if( $this->checkMatrices($A->transpose(), $T) )
$this->try_success("Transpose check...");
else
$errorCount = $this->try_failure($errorCount, "Transpose check...", "Matrices are not equal");
if($this->checkScalars($A->norm1(), $columnsummax))
$this->try_success("Maximum column sum...");
else
$errorCount = $this->try_failure($errorCount, "Maximum column sum...", "Incorrect: " . $A->norm1() . " != " . $columnsummax);
if($this->checkScalars($A->normInf(), $rowsummax))
$this->try_success("Maximum row sum...");
else
$errorCount = $this->try_failure($errorCount, "Maximum row sum...", "Incorrect: " . $A->normInf() . " != " . $rowsummax );
if($this->checkScalars($A->normF(), sqrt($sumofsquares)))
$this->try_success("Frobenius norm...");
else
$errorCount = $this->try_failure($errorCount, "Frobenius norm...", "Incorrect:" . $A->normF() . " != " . sqrt($sumofsquares));
if($this->checkScalars($A->trace(), $sumofdiagonals))
$this->try_success("Matrix trace...");
else
$errorCount = $this->try_failure($errorCount, "Matrix trace...", "Incorrect: " . $A->trace() . " != " . $sumofdiagonals);
$B = $A->getMatrix(0, $A->getRowDimension(), 0, $A->getRowDimension());
if( $B->det() == 0 )
$this->try_success("Matrix determinant...");
else
$errorCount = $this->try_failure($errorCount, "Matrix determinant...", "Incorrect: " . $B->det() . " != " . 0);
$A = new Matrix($columnwise,3);
$SQ = new Matrix($square);
if ($this->checkMatrices($SQ, $A->times($A->transpose())))
$this->try_success("times(Matrix)...");
else {
$errorCount = $this->try_failure($errorCount, "times(Matrix)...", "Unable to multiply matrices");
$SQ->toHTML();
$AT->toHTML();
}
$A = new Matrix($columnwise, 4);
$QR = $A->qr();
$R = $QR->getR();
$Q = $QR->getQ();
if($this->checkMatrices($A, $Q->times($R)))
$this->try_success("QRDecomposition...","");
else
$errorCount = $this->try_failure($errorCount,"QRDecomposition...","incorrect qr decomposition calculation");
$A = new Matrix($columnwise, 4);
$SVD = $A->svd();
$U = $SVD->getU();
$S = $SVD->getS();
$V = $SVD->getV();
if ($this->checkMatrices($A, $U->times($S->times($V->transpose()))))
$this->try_success("SingularValueDecomposition...","");
else
$errorCount = $this->try_failure($errorCount,"SingularValueDecomposition...","incorrect singular value decomposition calculation");
$n = $A->getColumnDimension();
$A = $A->getMatrix(0,$n-1,0,$n-1);
$A->set(0,0,0.);
$LU = $A->lu();
$L = $LU->getL();
if ( $this->checkMatrices($A->getMatrix($LU->getPivot(),0,$n-1), $L->times($LU->getU())) )
$this->try_success("LUDecomposition...","");
else
$errorCount = $this->try_failure($errorCount,"LUDecomposition...","incorrect LU decomposition calculation");
$X = $A->inverse();
if ( $this->checkMatrices($A->times($X),Matrix::identity(3,3)) )
$this->try_success("inverse()...","");
else
$errorCount = $this->try_failure($errorCount, "inverse()...","incorrect inverse calculation");
$DEF = new Matrix($rankdef);
if($this->checkScalars($DEF->rank(), min($DEF->getRowDimension(), $DEF->getColumnDimension())-1))
$this->try_success("Rank...");
else
$this->try_failure("Rank...", "incorrect rank calculation");
$B = new Matrix($condmat);
$SVD = $B->svd();
$singularvalues = $SVD->getSingularValues();
if($this->checkScalars($B->cond(), $singularvalues[0]/$singularvalues[min($B->getRowDimension(), $B->getColumnDimension())-1]))
$this->try_success("Condition number...");
else
$this->try_failure("Condition number...", "incorrect condition number calculation");
$SUB = new Matrix($subavals);
$O = new Matrix($SUB->getRowDimension(),1,1.0);
$SOL = new Matrix($sqSolution);
$SQ = $SUB->getMatrix(0,$SUB->getRowDimension()-1,0,$SUB->getRowDimension()-1);
if ( $this->checkMatrices($SQ->solve($SOL),$O) )
$this->try_success("solve()...","");
else
$errorCount = $this->try_failure($errorCount,"solve()...","incorrect lu solve calculation");
$A = new Matrix($pvals);
$Chol = $A->chol();
$L = $Chol->getL();
if ( $this->checkMatrices($A, $L->times($L->transpose())) )
$this->try_success("CholeskyDecomposition...","");
else
$errorCount = $this->try_failure($errorCount,"CholeskyDecomposition...","incorrect Cholesky decomposition calculation");
$X = $Chol->solve(Matrix::identity(3,3));
if ( $this->checkMatrices($A->times($X), Matrix::identity(3,3)) )
$this->try_success("CholeskyDecomposition solve()...","");
else
$errorCount = $this->try_failure($errorCount,"CholeskyDecomposition solve()...","incorrect Choleskydecomposition solve calculation");
$Eig = $A->eig();
$D = $Eig->getD();
$V = $Eig->getV();
if( $this->checkMatrices($A->times($V),$V->times($D)) )
$this->try_success("EigenvalueDecomposition (symmetric)...","");
else
$errorCount = $this->try_failure($errorCount,"EigenvalueDecomposition (symmetric)...","incorrect symmetric Eigenvalue decomposition calculation");
$A = new Matrix($evals);
$Eig = $A->eig();
$D = $Eig->getD();
$V = $Eig->getV();
if ( $this->checkMatrices($A->times($V),$V->times($D)) )
$this->try_success("EigenvalueDecomposition (nonsymmetric)...","");
else
$errorCount = $this->try_failure($errorCount,"EigenvalueDecomposition (nonsymmetric)...","incorrect nonsymmetric Eigenvalue decomposition calculation");
print("<b>{$errorCount} total errors</b>.");
}
/**
* Print appropriate messages for successful outcome try
* @param string $s
* @param string $e
*/
function try_success($s, $e = "") {
print "> ". $s ."success<br />";
if ($e != "")
print "> Message: ". $e ."<br />";
}
/**
* Print appropriate messages for unsuccessful outcome try
* @param int $count
* @param string $s
* @param string $e
* @return int incremented counter
*/
function try_failure($count, $s, $e="") {
print "> ". $s ."*** failure ***<br />> Message: ". $e ."<br />";
return ++$count;
}
/**
* Print appropriate messages for unsuccessful outcome try
* @param int $count
* @param string $s
* @param string $e
* @return int incremented counter
*/
function try_warning($count, $s, $e="") {
print "> ". $s ."*** warning ***<br />> Message: ". $e ."<br />";
return ++$count;
}
/**
* Check magnitude of difference of "scalars".
* @param float $x
* @param float $y
*/
function checkScalars($x, $y) {
$eps = pow(2.0,-52.0);
if ($x == 0 & abs($y) < 10*$eps) return;
if ($y == 0 & abs($x) < 10*$eps) return;
if (abs($x-$y) > 10 * $eps * max(abs($x),abs($y)))
return false;
else
return true;
}
/**
* Check norm of difference of "vectors".
* @param float $x[]
* @param float $y[]
*/
function checkVectors($x, $y) {
$nx = count($x);
$ny = count($y);
if ($nx == $ny)
for($i=0; $i < $nx; ++$i)
$this->checkScalars($x[$i],$y[$i]);
else
die("Attempt to compare vectors of different lengths");
}
/**
* Check norm of difference of "arrays".
* @param float $x[][]
* @param float $y[][]
*/
function checkArrays($x, $y) {
$A = new Matrix($x);
$B = new Matrix($y);
return $this->checkMatrices($A,$B);
}
/**
* Check norm of difference of "matrices".
* @param matrix $X
* @param matrix $Y
*/
function checkMatrices($X = null, $Y = null) {
if( $X == null || $Y == null )
return false;
$eps = pow(2.0,-52.0);
if ($X->norm1() == 0. & $Y->norm1() < 10*$eps) return true;
if ($Y->norm1() == 0. & $X->norm1() < 10*$eps) return true;
$A = $X->minus($Y);
if ($A->norm1() > 1000 * $eps * max($X->norm1(),$Y->norm1()))
die("The norm of (X-Y) is too large: ".$A->norm1());
else
return true;
}
}
$test = new TestMatrix;
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/tests/TestMatrix.php | PHP | asf20 | 13,963 |
<?php
/**
* @package JAMA
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/*
* Matrix class
*
* @author Paul Meagher
* @author Michael Bommarito
* @author Lukasz Karapuda
* @author Bartek Matosiuk
* @version 1.8
* @license PHP v3.0
* @see http://math.nist.gov/javanumerics/jama/
*/
class PHPExcel_Shared_JAMA_Matrix {
const PolymorphicArgumentException = "Invalid argument pattern for polymorphic function.";
const ArgumentTypeException = "Invalid argument type.";
const ArgumentBoundsException = "Invalid argument range.";
const MatrixDimensionException = "Matrix dimensions are not equal.";
const ArrayLengthException = "Array length must be a multiple of m.";
/**
* Matrix storage
*
* @var array
* @access public
*/
public $A = array();
/**
* Matrix row dimension
*
* @var int
* @access private
*/
private $m;
/**
* Matrix column dimension
*
* @var int
* @access private
*/
private $n;
/**
* Polymorphic constructor
*
* As PHP has no support for polymorphic constructors, we hack our own sort of polymorphism using func_num_args, func_get_arg, and gettype. In essence, we're just implementing a simple RTTI filter and calling the appropriate constructor.
*/
public function __construct() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
//Rectangular matrix - m x n initialized from 2D array
case 'array':
$this->m = count($args[0]);
$this->n = count($args[0][0]);
$this->A = $args[0];
break;
//Square matrix - n x n
case 'integer':
$this->m = $args[0];
$this->n = $args[0];
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
break;
//Rectangular matrix - m x n
case 'integer,integer':
$this->m = $args[0];
$this->n = $args[1];
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
break;
//Rectangular matrix - m x n initialized from packed array
case 'array,integer':
$this->m = $args[1];
if ($this->m != 0) {
$this->n = count($args[0]) / $this->m;
} else {
$this->n = 0;
}
if (($this->m * $this->n) == count($args[0])) {
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$this->A[$i][$j] = $args[0][$i + $j * $this->m];
}
}
} else {
throw new Exception(self::ArrayLengthException);
}
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function __construct()
/**
* getArray
*
* @return array Matrix array
*/
public function getArray() {
return $this->A;
} // function getArray()
/**
* getRowDimension
*
* @return int Row dimension
*/
public function getRowDimension() {
return $this->m;
} // function getRowDimension()
/**
* getColumnDimension
*
* @return int Column dimension
*/
public function getColumnDimension() {
return $this->n;
} // function getColumnDimension()
/**
* get
*
* Get the i,j-th element of the matrix.
* @param int $i Row position
* @param int $j Column position
* @return mixed Element (int/float/double)
*/
public function get($i = null, $j = null) {
return $this->A[$i][$j];
} // function get()
/**
* getMatrix
*
* Get a submatrix
* @param int $i0 Initial row index
* @param int $iF Final row index
* @param int $j0 Initial column index
* @param int $jF Final column index
* @return Matrix Submatrix
*/
public function getMatrix() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
//A($i0...; $j0...)
case 'integer,integer':
list($i0, $j0) = $args;
if ($i0 >= 0) { $m = $this->m - $i0; } else { throw new Exception(self::ArgumentBoundsException); }
if ($j0 >= 0) { $n = $this->n - $j0; } else { throw new Exception(self::ArgumentBoundsException); }
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
for($i = $i0; $i < $this->m; ++$i) {
for($j = $j0; $j < $this->n; ++$j) {
$R->set($i, $j, $this->A[$i][$j]);
}
}
return $R;
break;
//A($i0...$iF; $j0...$jF)
case 'integer,integer,integer,integer':
list($i0, $iF, $j0, $jF) = $args;
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new Exception(self::ArgumentBoundsException); }
if (($jF > $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new Exception(self::ArgumentBoundsException); }
$R = new PHPExcel_Shared_JAMA_Matrix($m+1, $n+1);
for($i = $i0; $i <= $iF; ++$i) {
for($j = $j0; $j <= $jF; ++$j) {
$R->set($i - $i0, $j - $j0, $this->A[$i][$j]);
}
}
return $R;
break;
//$R = array of row indices; $C = array of column indices
case 'array,array':
list($RL, $CL) = $args;
if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(self::ArgumentBoundsException); }
if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(self::ArgumentBoundsException); }
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
for($i = 0; $i < $m; ++$i) {
for($j = 0; $j < $n; ++$j) {
$R->set($i - $i0, $j - $j0, $this->A[$RL[$i]][$CL[$j]]);
}
}
return $R;
break;
//$RL = array of row indices; $CL = array of column indices
case 'array,array':
list($RL, $CL) = $args;
if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(self::ArgumentBoundsException); }
if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(self::ArgumentBoundsException); }
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
for($i = 0; $i < $m; ++$i) {
for($j = 0; $j < $n; ++$j) {
$R->set($i, $j, $this->A[$RL[$i]][$CL[$j]]);
}
}
return $R;
break;
//A($i0...$iF); $CL = array of column indices
case 'integer,integer,array':
list($i0, $iF, $CL) = $args;
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { $m = $iF - $i0; } else { throw new Exception(self::ArgumentBoundsException); }
if (count($CL) > 0) { $n = count($CL); } else { throw new Exception(self::ArgumentBoundsException); }
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
for($i = $i0; $i < $iF; ++$i) {
for($j = 0; $j < $n; ++$j) {
$R->set($i - $i0, $j, $this->A[$RL[$i]][$j]);
}
}
return $R;
break;
//$RL = array of row indices
case 'array,integer,integer':
list($RL, $j0, $jF) = $args;
if (count($RL) > 0) { $m = count($RL); } else { throw new Exception(self::ArgumentBoundsException); }
if (($jF >= $j0) && ($this->n >= $jF) && ($j0 >= 0)) { $n = $jF - $j0; } else { throw new Exception(self::ArgumentBoundsException); }
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n+1);
for($i = 0; $i < $m; ++$i) {
for($j = $j0; $j <= $jF; ++$j) {
$R->set($i, $j - $j0, $this->A[$RL[$i]][$j]);
}
}
return $R;
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function getMatrix()
/**
* checkMatrixDimensions
*
* Is matrix B the same size?
* @param Matrix $B Matrix B
* @return boolean
*/
public function checkMatrixDimensions($B = null) {
if ($B instanceof PHPExcel_Shared_JAMA_Matrix) {
if (($this->m == $B->getRowDimension()) && ($this->n == $B->getColumnDimension())) {
return true;
} else {
throw new Exception(self::MatrixDimensionException);
}
} else {
throw new Exception(self::ArgumentTypeException);
}
} // function checkMatrixDimensions()
/**
* set
*
* Set the i,j-th element of the matrix.
* @param int $i Row position
* @param int $j Column position
* @param mixed $c Int/float/double value
* @return mixed Element (int/float/double)
*/
public function set($i = null, $j = null, $c = null) {
// Optimized set version just has this
$this->A[$i][$j] = $c;
} // function set()
/**
* identity
*
* Generate an identity matrix.
* @param int $m Row dimension
* @param int $n Column dimension
* @return Matrix Identity matrix
*/
public function identity($m = null, $n = null) {
return $this->diagonal($m, $n, 1);
} // function identity()
/**
* diagonal
*
* Generate a diagonal matrix
* @param int $m Row dimension
* @param int $n Column dimension
* @param mixed $c Diagonal value
* @return Matrix Diagonal matrix
*/
public function diagonal($m = null, $n = null, $c = 1) {
$R = new PHPExcel_Shared_JAMA_Matrix($m, $n);
for($i = 0; $i < $m; ++$i) {
$R->set($i, $i, $c);
}
return $R;
} // function diagonal()
/**
* getMatrixByRow
*
* Get a submatrix by row index/range
* @param int $i0 Initial row index
* @param int $iF Final row index
* @return Matrix Submatrix
*/
public function getMatrixByRow($i0 = null, $iF = null) {
if (is_int($i0)) {
if (is_int($iF)) {
return $this->getMatrix($i0, 0, $iF + 1, $this->n);
} else {
return $this->getMatrix($i0, 0, $i0 + 1, $this->n);
}
} else {
throw new Exception(self::ArgumentTypeException);
}
} // function getMatrixByRow()
/**
* getMatrixByCol
*
* Get a submatrix by column index/range
* @param int $i0 Initial column index
* @param int $iF Final column index
* @return Matrix Submatrix
*/
public function getMatrixByCol($j0 = null, $jF = null) {
if (is_int($j0)) {
if (is_int($jF)) {
return $this->getMatrix(0, $j0, $this->m, $jF + 1);
} else {
return $this->getMatrix(0, $j0, $this->m, $j0 + 1);
}
} else {
throw new Exception(self::ArgumentTypeException);
}
} // function getMatrixByCol()
/**
* transpose
*
* Tranpose matrix
* @return Matrix Transposed matrix
*/
public function transpose() {
$R = new PHPExcel_Shared_JAMA_Matrix($this->n, $this->m);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$R->set($j, $i, $this->A[$i][$j]);
}
}
return $R;
} // function transpose()
/**
* trace
*
* Sum of diagonal elements
* @return float Sum of diagonal elements
*/
public function trace() {
$s = 0;
$n = min($this->m, $this->n);
for($i = 0; $i < $n; ++$i) {
$s += $this->A[$i][$i];
}
return $s;
} // function trace()
/**
* uminus
*
* Unary minus matrix -A
* @return Matrix Unary minus matrix
*/
public function uminus() {
} // function uminus()
/**
* plus
*
* A + B
* @param mixed $B Matrix/Array
* @return Matrix Sum
*/
public function plus() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$M->set($i, $j, $M->get($i, $j) + $this->A[$i][$j]);
}
}
return $M;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function plus()
/**
* plusEquals
*
* A = A + B
* @param mixed $B Matrix/Array
* @return Matrix Sum
*/
public function plusEquals() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$validValues = True;
$value = $M->get($i, $j);
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
}
if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
$value = trim($value,'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
}
if ($validValues) {
$this->A[$i][$j] += $value;
} else {
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
}
}
}
return $this;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function plusEquals()
/**
* minus
*
* A - B
* @param mixed $B Matrix/Array
* @return Matrix Sum
*/
public function minus() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$M->set($i, $j, $M->get($i, $j) - $this->A[$i][$j]);
}
}
return $M;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function minus()
/**
* minusEquals
*
* A = A - B
* @param mixed $B Matrix/Array
* @return Matrix Sum
*/
public function minusEquals() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$validValues = True;
$value = $M->get($i, $j);
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
}
if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
$value = trim($value,'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
}
if ($validValues) {
$this->A[$i][$j] -= $value;
} else {
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
}
}
}
return $this;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function minusEquals()
/**
* arrayTimes
*
* Element-by-element multiplication
* Cij = Aij * Bij
* @param mixed $B Matrix/Array
* @return Matrix Matrix Cij
*/
public function arrayTimes() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$M->set($i, $j, $M->get($i, $j) * $this->A[$i][$j]);
}
}
return $M;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function arrayTimes()
/**
* arrayTimesEquals
*
* Element-by-element multiplication
* Aij = Aij * Bij
* @param mixed $B Matrix/Array
* @return Matrix Matrix Aij
*/
public function arrayTimesEquals() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$validValues = True;
$value = $M->get($i, $j);
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
}
if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
$value = trim($value,'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
}
if ($validValues) {
$this->A[$i][$j] *= $value;
} else {
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
}
}
}
return $this;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function arrayTimesEquals()
/**
* arrayRightDivide
*
* Element-by-element right division
* A / B
* @param Matrix $B Matrix B
* @return Matrix Division result
*/
public function arrayRightDivide() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$validValues = True;
$value = $M->get($i, $j);
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
}
if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
$value = trim($value,'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
}
if ($validValues) {
if ($value == 0) {
// Trap for Divide by Zero error
$M->set($i, $j, '#DIV/0!');
} else {
$M->set($i, $j, $this->A[$i][$j] / $value);
}
} else {
$M->set($i, $j, PHPExcel_Calculation_Functions::NaN());
}
}
}
return $M;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function arrayRightDivide()
/**
* arrayRightDivideEquals
*
* Element-by-element right division
* Aij = Aij / Bij
* @param mixed $B Matrix/Array
* @return Matrix Matrix Aij
*/
public function arrayRightDivideEquals() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$this->A[$i][$j] = $this->A[$i][$j] / $M->get($i, $j);
}
}
return $M;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function arrayRightDivideEquals()
/**
* arrayLeftDivide
*
* Element-by-element Left division
* A / B
* @param Matrix $B Matrix B
* @return Matrix Division result
*/
public function arrayLeftDivide() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$M->set($i, $j, $M->get($i, $j) / $this->A[$i][$j]);
}
}
return $M;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function arrayLeftDivide()
/**
* arrayLeftDivideEquals
*
* Element-by-element Left division
* Aij = Aij / Bij
* @param mixed $B Matrix/Array
* @return Matrix Matrix Aij
*/
public function arrayLeftDivideEquals() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$this->A[$i][$j] = $M->get($i, $j) / $this->A[$i][$j];
}
}
return $M;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function arrayLeftDivideEquals()
/**
* times
*
* Matrix multiplication
* @param mixed $n Matrix/Array/Scalar
* @return Matrix Product
*/
public function times() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
if ($this->n == $B->m) {
$C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n);
for($j = 0; $j < $B->n; ++$j) {
for ($k = 0; $k < $this->n; ++$k) {
$Bcolj[$k] = $B->A[$k][$j];
}
for($i = 0; $i < $this->m; ++$i) {
$Arowi = $this->A[$i];
$s = 0;
for($k = 0; $k < $this->n; ++$k) {
$s += $Arowi[$k] * $Bcolj[$k];
}
$C->A[$i][$j] = $s;
}
}
return $C;
} else {
throw new Exception(JAMAError(MatrixDimensionMismatch));
}
break;
case 'array':
$B = new PHPExcel_Shared_JAMA_Matrix($args[0]);
if ($this->n == $B->m) {
$C = new PHPExcel_Shared_JAMA_Matrix($this->m, $B->n);
for($i = 0; $i < $C->m; ++$i) {
for($j = 0; $j < $C->n; ++$j) {
$s = "0";
for($k = 0; $k < $C->n; ++$k) {
$s += $this->A[$i][$k] * $B->A[$k][$j];
}
$C->A[$i][$j] = $s;
}
}
return $C;
} else {
throw new Exception(JAMAError(MatrixDimensionMismatch));
}
return $M;
break;
case 'integer':
$C = new PHPExcel_Shared_JAMA_Matrix($this->A);
for($i = 0; $i < $C->m; ++$i) {
for($j = 0; $j < $C->n; ++$j) {
$C->A[$i][$j] *= $args[0];
}
}
return $C;
break;
case 'double':
$C = new PHPExcel_Shared_JAMA_Matrix($this->m, $this->n);
for($i = 0; $i < $C->m; ++$i) {
for($j = 0; $j < $C->n; ++$j) {
$C->A[$i][$j] = $args[0] * $this->A[$i][$j];
}
}
return $C;
break;
case 'float':
$C = new PHPExcel_Shared_JAMA_Matrix($this->A);
for($i = 0; $i < $C->m; ++$i) {
for($j = 0; $j < $C->n; ++$j) {
$C->A[$i][$j] *= $args[0];
}
}
return $C;
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function times()
/**
* power
*
* A = A ^ B
* @param mixed $B Matrix/Array
* @return Matrix Sum
*/
public function power() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
break;
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$validValues = True;
$value = $M->get($i, $j);
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
}
if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
$value = trim($value,'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
}
if ($validValues) {
$this->A[$i][$j] = pow($this->A[$i][$j],$value);
} else {
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
}
}
}
return $this;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function power()
/**
* concat
*
* A = A & B
* @param mixed $B Matrix/Array
* @return Matrix Sum
*/
public function concat() {
if (func_num_args() > 0) {
$args = func_get_args();
$match = implode(",", array_map('gettype', $args));
switch($match) {
case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new Exception(self::ArgumentTypeException); }
case 'array':
$M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
break;
default:
throw new Exception(self::PolymorphicArgumentException);
break;
}
$this->checkMatrixDimensions($M);
for($i = 0; $i < $this->m; ++$i) {
for($j = 0; $j < $this->n; ++$j) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"').trim($M->get($i, $j),'"');
}
}
return $this;
} else {
throw new Exception(self::PolymorphicArgumentException);
}
} // function concat()
/**
* Solve A*X = B.
*
* @param Matrix $B Right hand side
* @return Matrix ... Solution if A is square, least squares solution otherwise
*/
public function solve($B) {
if ($this->m == $this->n) {
$LU = new PHPExcel_Shared_JAMA_LUDecomposition($this);
return $LU->solve($B);
} else {
$QR = new QRDecomposition($this);
return $QR->solve($B);
}
} // function solve()
/**
* Matrix inverse or pseudoinverse.
*
* @return Matrix ... Inverse(A) if A is square, pseudoinverse otherwise.
*/
public function inverse() {
return $this->solve($this->identity($this->m, $this->m));
} // function inverse()
/**
* det
*
* Calculate determinant
* @return float Determinant
*/
public function det() {
$L = new PHPExcel_Shared_JAMA_LUDecomposition($this);
return $L->det();
} // function det()
} // class PHPExcel_Shared_JAMA_Matrix
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/Matrix.php | PHP | asf20 | 28,846 |
<?php
/**
* @package JAMA
*
* Class to obtain eigenvalues and eigenvectors of a real matrix.
*
* If A is symmetric, then A = V*D*V' where the eigenvalue matrix D
* is diagonal and the eigenvector matrix V is orthogonal (i.e.
* A = V.times(D.times(V.transpose())) and V.times(V.transpose())
* equals the identity matrix).
*
* If A is not symmetric, then the eigenvalue matrix D is block diagonal
* with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues,
* lambda + i*mu, in 2-by-2 blocks, [lambda, mu; -mu, lambda]. The
* columns of V represent the eigenvectors in the sense that A*V = V*D,
* i.e. A.times(V) equals V.times(D). The matrix V may be badly
* conditioned, or even singular, so the validity of the equation
* A = V*D*inverse(V) depends upon V.cond().
*
* @author Paul Meagher
* @license PHP v3.0
* @version 1.1
*/
class EigenvalueDecomposition {
/**
* Row and column dimension (square matrix).
* @var int
*/
private $n;
/**
* Internal symmetry flag.
* @var int
*/
private $issymmetric;
/**
* Arrays for internal storage of eigenvalues.
* @var array
*/
private $d = array();
private $e = array();
/**
* Array for internal storage of eigenvectors.
* @var array
*/
private $V = array();
/**
* Array for internal storage of nonsymmetric Hessenberg form.
* @var array
*/
private $H = array();
/**
* Working storage for nonsymmetric algorithm.
* @var array
*/
private $ort;
/**
* Used for complex scalar division.
* @var float
*/
private $cdivr;
private $cdivi;
/**
* Symmetric Householder reduction to tridiagonal form.
*
* @access private
*/
private function tred2 () {
// This is derived from the Algol procedures tred2 by
// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
// Fortran subroutine in EISPACK.
$this->d = $this->V[$this->n-1];
// Householder reduction to tridiagonal form.
for ($i = $this->n-1; $i > 0; --$i) {
$i_ = $i -1;
// Scale to avoid under/overflow.
$h = $scale = 0.0;
$scale += array_sum(array_map(abs, $this->d));
if ($scale == 0.0) {
$this->e[$i] = $this->d[$i_];
$this->d = array_slice($this->V[$i_], 0, $i_);
for ($j = 0; $j < $i; ++$j) {
$this->V[$j][$i] = $this->V[$i][$j] = 0.0;
}
} else {
// Generate Householder vector.
for ($k = 0; $k < $i; ++$k) {
$this->d[$k] /= $scale;
$h += pow($this->d[$k], 2);
}
$f = $this->d[$i_];
$g = sqrt($h);
if ($f > 0) {
$g = -$g;
}
$this->e[$i] = $scale * $g;
$h = $h - $f * $g;
$this->d[$i_] = $f - $g;
for ($j = 0; $j < $i; ++$j) {
$this->e[$j] = 0.0;
}
// Apply similarity transformation to remaining columns.
for ($j = 0; $j < $i; ++$j) {
$f = $this->d[$j];
$this->V[$j][$i] = $f;
$g = $this->e[$j] + $this->V[$j][$j] * $f;
for ($k = $j+1; $k <= $i_; ++$k) {
$g += $this->V[$k][$j] * $this->d[$k];
$this->e[$k] += $this->V[$k][$j] * $f;
}
$this->e[$j] = $g;
}
$f = 0.0;
for ($j = 0; $j < $i; ++$j) {
$this->e[$j] /= $h;
$f += $this->e[$j] * $this->d[$j];
}
$hh = $f / (2 * $h);
for ($j=0; $j < $i; ++$j) {
$this->e[$j] -= $hh * $this->d[$j];
}
for ($j = 0; $j < $i; ++$j) {
$f = $this->d[$j];
$g = $this->e[$j];
for ($k = $j; $k <= $i_; ++$k) {
$this->V[$k][$j] -= ($f * $this->e[$k] + $g * $this->d[$k]);
}
$this->d[$j] = $this->V[$i-1][$j];
$this->V[$i][$j] = 0.0;
}
}
$this->d[$i] = $h;
}
// Accumulate transformations.
for ($i = 0; $i < $this->n-1; ++$i) {
$this->V[$this->n-1][$i] = $this->V[$i][$i];
$this->V[$i][$i] = 1.0;
$h = $this->d[$i+1];
if ($h != 0.0) {
for ($k = 0; $k <= $i; ++$k) {
$this->d[$k] = $this->V[$k][$i+1] / $h;
}
for ($j = 0; $j <= $i; ++$j) {
$g = 0.0;
for ($k = 0; $k <= $i; ++$k) {
$g += $this->V[$k][$i+1] * $this->V[$k][$j];
}
for ($k = 0; $k <= $i; ++$k) {
$this->V[$k][$j] -= $g * $this->d[$k];
}
}
}
for ($k = 0; $k <= $i; ++$k) {
$this->V[$k][$i+1] = 0.0;
}
}
$this->d = $this->V[$this->n-1];
$this->V[$this->n-1] = array_fill(0, $j, 0.0);
$this->V[$this->n-1][$this->n-1] = 1.0;
$this->e[0] = 0.0;
}
/**
* Symmetric tridiagonal QL algorithm.
*
* This is derived from the Algol procedures tql2, by
* Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
* Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
* Fortran subroutine in EISPACK.
*
* @access private
*/
private function tql2() {
for ($i = 1; $i < $this->n; ++$i) {
$this->e[$i-1] = $this->e[$i];
}
$this->e[$this->n-1] = 0.0;
$f = 0.0;
$tst1 = 0.0;
$eps = pow(2.0,-52.0);
for ($l = 0; $l < $this->n; ++$l) {
// Find small subdiagonal element
$tst1 = max($tst1, abs($this->d[$l]) + abs($this->e[$l]));
$m = $l;
while ($m < $this->n) {
if (abs($this->e[$m]) <= $eps * $tst1)
break;
++$m;
}
// If m == l, $this->d[l] is an eigenvalue,
// otherwise, iterate.
if ($m > $l) {
$iter = 0;
do {
// Could check iteration count here.
$iter += 1;
// Compute implicit shift
$g = $this->d[$l];
$p = ($this->d[$l+1] - $g) / (2.0 * $this->e[$l]);
$r = hypo($p, 1.0);
if ($p < 0)
$r *= -1;
$this->d[$l] = $this->e[$l] / ($p + $r);
$this->d[$l+1] = $this->e[$l] * ($p + $r);
$dl1 = $this->d[$l+1];
$h = $g - $this->d[$l];
for ($i = $l + 2; $i < $this->n; ++$i)
$this->d[$i] -= $h;
$f += $h;
// Implicit QL transformation.
$p = $this->d[$m];
$c = 1.0;
$c2 = $c3 = $c;
$el1 = $this->e[$l + 1];
$s = $s2 = 0.0;
for ($i = $m-1; $i >= $l; --$i) {
$c3 = $c2;
$c2 = $c;
$s2 = $s;
$g = $c * $this->e[$i];
$h = $c * $p;
$r = hypo($p, $this->e[$i]);
$this->e[$i+1] = $s * $r;
$s = $this->e[$i] / $r;
$c = $p / $r;
$p = $c * $this->d[$i] - $s * $g;
$this->d[$i+1] = $h + $s * ($c * $g + $s * $this->d[$i]);
// Accumulate transformation.
for ($k = 0; $k < $this->n; ++$k) {
$h = $this->V[$k][$i+1];
$this->V[$k][$i+1] = $s * $this->V[$k][$i] + $c * $h;
$this->V[$k][$i] = $c * $this->V[$k][$i] - $s * $h;
}
}
$p = -$s * $s2 * $c3 * $el1 * $this->e[$l] / $dl1;
$this->e[$l] = $s * $p;
$this->d[$l] = $c * $p;
// Check for convergence.
} while (abs($this->e[$l]) > $eps * $tst1);
}
$this->d[$l] = $this->d[$l] + $f;
$this->e[$l] = 0.0;
}
// Sort eigenvalues and corresponding vectors.
for ($i = 0; $i < $this->n - 1; ++$i) {
$k = $i;
$p = $this->d[$i];
for ($j = $i+1; $j < $this->n; ++$j) {
if ($this->d[$j] < $p) {
$k = $j;
$p = $this->d[$j];
}
}
if ($k != $i) {
$this->d[$k] = $this->d[$i];
$this->d[$i] = $p;
for ($j = 0; $j < $this->n; ++$j) {
$p = $this->V[$j][$i];
$this->V[$j][$i] = $this->V[$j][$k];
$this->V[$j][$k] = $p;
}
}
}
}
/**
* Nonsymmetric reduction to Hessenberg form.
*
* This is derived from the Algol procedures orthes and ortran,
* by Martin and Wilkinson, Handbook for Auto. Comp.,
* Vol.ii-Linear Algebra, and the corresponding
* Fortran subroutines in EISPACK.
*
* @access private
*/
private function orthes () {
$low = 0;
$high = $this->n-1;
for ($m = $low+1; $m <= $high-1; ++$m) {
// Scale column.
$scale = 0.0;
for ($i = $m; $i <= $high; ++$i) {
$scale = $scale + abs($this->H[$i][$m-1]);
}
if ($scale != 0.0) {
// Compute Householder transformation.
$h = 0.0;
for ($i = $high; $i >= $m; --$i) {
$this->ort[$i] = $this->H[$i][$m-1] / $scale;
$h += $this->ort[$i] * $this->ort[$i];
}
$g = sqrt($h);
if ($this->ort[$m] > 0) {
$g *= -1;
}
$h -= $this->ort[$m] * $g;
$this->ort[$m] -= $g;
// Apply Householder similarity transformation
// H = (I -u * u' / h) * H * (I -u * u') / h)
for ($j = $m; $j < $this->n; ++$j) {
$f = 0.0;
for ($i = $high; $i >= $m; --$i) {
$f += $this->ort[$i] * $this->H[$i][$j];
}
$f /= $h;
for ($i = $m; $i <= $high; ++$i) {
$this->H[$i][$j] -= $f * $this->ort[$i];
}
}
for ($i = 0; $i <= $high; ++$i) {
$f = 0.0;
for ($j = $high; $j >= $m; --$j) {
$f += $this->ort[$j] * $this->H[$i][$j];
}
$f = $f / $h;
for ($j = $m; $j <= $high; ++$j) {
$this->H[$i][$j] -= $f * $this->ort[$j];
}
}
$this->ort[$m] = $scale * $this->ort[$m];
$this->H[$m][$m-1] = $scale * $g;
}
}
// Accumulate transformations (Algol's ortran).
for ($i = 0; $i < $this->n; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
$this->V[$i][$j] = ($i == $j ? 1.0 : 0.0);
}
}
for ($m = $high-1; $m >= $low+1; --$m) {
if ($this->H[$m][$m-1] != 0.0) {
for ($i = $m+1; $i <= $high; ++$i) {
$this->ort[$i] = $this->H[$i][$m-1];
}
for ($j = $m; $j <= $high; ++$j) {
$g = 0.0;
for ($i = $m; $i <= $high; ++$i) {
$g += $this->ort[$i] * $this->V[$i][$j];
}
// Double division avoids possible underflow
$g = ($g / $this->ort[$m]) / $this->H[$m][$m-1];
for ($i = $m; $i <= $high; ++$i) {
$this->V[$i][$j] += $g * $this->ort[$i];
}
}
}
}
}
/**
* Performs complex division.
*
* @access private
*/
private function cdiv($xr, $xi, $yr, $yi) {
if (abs($yr) > abs($yi)) {
$r = $yi / $yr;
$d = $yr + $r * $yi;
$this->cdivr = ($xr + $r * $xi) / $d;
$this->cdivi = ($xi - $r * $xr) / $d;
} else {
$r = $yr / $yi;
$d = $yi + $r * $yr;
$this->cdivr = ($r * $xr + $xi) / $d;
$this->cdivi = ($r * $xi - $xr) / $d;
}
}
/**
* Nonsymmetric reduction from Hessenberg to real Schur form.
*
* Code is derived from the Algol procedure hqr2,
* by Martin and Wilkinson, Handbook for Auto. Comp.,
* Vol.ii-Linear Algebra, and the corresponding
* Fortran subroutine in EISPACK.
*
* @access private
*/
private function hqr2 () {
// Initialize
$nn = $this->n;
$n = $nn - 1;
$low = 0;
$high = $nn - 1;
$eps = pow(2.0, -52.0);
$exshift = 0.0;
$p = $q = $r = $s = $z = 0;
// Store roots isolated by balanc and compute matrix norm
$norm = 0.0;
for ($i = 0; $i < $nn; ++$i) {
if (($i < $low) OR ($i > $high)) {
$this->d[$i] = $this->H[$i][$i];
$this->e[$i] = 0.0;
}
for ($j = max($i-1, 0); $j < $nn; ++$j) {
$norm = $norm + abs($this->H[$i][$j]);
}
}
// Outer loop over eigenvalue index
$iter = 0;
while ($n >= $low) {
// Look for single small sub-diagonal element
$l = $n;
while ($l > $low) {
$s = abs($this->H[$l-1][$l-1]) + abs($this->H[$l][$l]);
if ($s == 0.0) {
$s = $norm;
}
if (abs($this->H[$l][$l-1]) < $eps * $s) {
break;
}
--$l;
}
// Check for convergence
// One root found
if ($l == $n) {
$this->H[$n][$n] = $this->H[$n][$n] + $exshift;
$this->d[$n] = $this->H[$n][$n];
$this->e[$n] = 0.0;
--$n;
$iter = 0;
// Two roots found
} else if ($l == $n-1) {
$w = $this->H[$n][$n-1] * $this->H[$n-1][$n];
$p = ($this->H[$n-1][$n-1] - $this->H[$n][$n]) / 2.0;
$q = $p * $p + $w;
$z = sqrt(abs($q));
$this->H[$n][$n] = $this->H[$n][$n] + $exshift;
$this->H[$n-1][$n-1] = $this->H[$n-1][$n-1] + $exshift;
$x = $this->H[$n][$n];
// Real pair
if ($q >= 0) {
if ($p >= 0) {
$z = $p + $z;
} else {
$z = $p - $z;
}
$this->d[$n-1] = $x + $z;
$this->d[$n] = $this->d[$n-1];
if ($z != 0.0) {
$this->d[$n] = $x - $w / $z;
}
$this->e[$n-1] = 0.0;
$this->e[$n] = 0.0;
$x = $this->H[$n][$n-1];
$s = abs($x) + abs($z);
$p = $x / $s;
$q = $z / $s;
$r = sqrt($p * $p + $q * $q);
$p = $p / $r;
$q = $q / $r;
// Row modification
for ($j = $n-1; $j < $nn; ++$j) {
$z = $this->H[$n-1][$j];
$this->H[$n-1][$j] = $q * $z + $p * $this->H[$n][$j];
$this->H[$n][$j] = $q * $this->H[$n][$j] - $p * $z;
}
// Column modification
for ($i = 0; $i <= n; ++$i) {
$z = $this->H[$i][$n-1];
$this->H[$i][$n-1] = $q * $z + $p * $this->H[$i][$n];
$this->H[$i][$n] = $q * $this->H[$i][$n] - $p * $z;
}
// Accumulate transformations
for ($i = $low; $i <= $high; ++$i) {
$z = $this->V[$i][$n-1];
$this->V[$i][$n-1] = $q * $z + $p * $this->V[$i][$n];
$this->V[$i][$n] = $q * $this->V[$i][$n] - $p * $z;
}
// Complex pair
} else {
$this->d[$n-1] = $x + $p;
$this->d[$n] = $x + $p;
$this->e[$n-1] = $z;
$this->e[$n] = -$z;
}
$n = $n - 2;
$iter = 0;
// No convergence yet
} else {
// Form shift
$x = $this->H[$n][$n];
$y = 0.0;
$w = 0.0;
if ($l < $n) {
$y = $this->H[$n-1][$n-1];
$w = $this->H[$n][$n-1] * $this->H[$n-1][$n];
}
// Wilkinson's original ad hoc shift
if ($iter == 10) {
$exshift += $x;
for ($i = $low; $i <= $n; ++$i) {
$this->H[$i][$i] -= $x;
}
$s = abs($this->H[$n][$n-1]) + abs($this->H[$n-1][$n-2]);
$x = $y = 0.75 * $s;
$w = -0.4375 * $s * $s;
}
// MATLAB's new ad hoc shift
if ($iter == 30) {
$s = ($y - $x) / 2.0;
$s = $s * $s + $w;
if ($s > 0) {
$s = sqrt($s);
if ($y < $x) {
$s = -$s;
}
$s = $x - $w / (($y - $x) / 2.0 + $s);
for ($i = $low; $i <= $n; ++$i) {
$this->H[$i][$i] -= $s;
}
$exshift += $s;
$x = $y = $w = 0.964;
}
}
// Could check iteration count here.
$iter = $iter + 1;
// Look for two consecutive small sub-diagonal elements
$m = $n - 2;
while ($m >= $l) {
$z = $this->H[$m][$m];
$r = $x - $z;
$s = $y - $z;
$p = ($r * $s - $w) / $this->H[$m+1][$m] + $this->H[$m][$m+1];
$q = $this->H[$m+1][$m+1] - $z - $r - $s;
$r = $this->H[$m+2][$m+1];
$s = abs($p) + abs($q) + abs($r);
$p = $p / $s;
$q = $q / $s;
$r = $r / $s;
if ($m == $l) {
break;
}
if (abs($this->H[$m][$m-1]) * (abs($q) + abs($r)) <
$eps * (abs($p) * (abs($this->H[$m-1][$m-1]) + abs($z) + abs($this->H[$m+1][$m+1])))) {
break;
}
--$m;
}
for ($i = $m + 2; $i <= $n; ++$i) {
$this->H[$i][$i-2] = 0.0;
if ($i > $m+2) {
$this->H[$i][$i-3] = 0.0;
}
}
// Double QR step involving rows l:n and columns m:n
for ($k = $m; $k <= $n-1; ++$k) {
$notlast = ($k != $n-1);
if ($k != $m) {
$p = $this->H[$k][$k-1];
$q = $this->H[$k+1][$k-1];
$r = ($notlast ? $this->H[$k+2][$k-1] : 0.0);
$x = abs($p) + abs($q) + abs($r);
if ($x != 0.0) {
$p = $p / $x;
$q = $q / $x;
$r = $r / $x;
}
}
if ($x == 0.0) {
break;
}
$s = sqrt($p * $p + $q * $q + $r * $r);
if ($p < 0) {
$s = -$s;
}
if ($s != 0) {
if ($k != $m) {
$this->H[$k][$k-1] = -$s * $x;
} elseif ($l != $m) {
$this->H[$k][$k-1] = -$this->H[$k][$k-1];
}
$p = $p + $s;
$x = $p / $s;
$y = $q / $s;
$z = $r / $s;
$q = $q / $p;
$r = $r / $p;
// Row modification
for ($j = $k; $j < $nn; ++$j) {
$p = $this->H[$k][$j] + $q * $this->H[$k+1][$j];
if ($notlast) {
$p = $p + $r * $this->H[$k+2][$j];
$this->H[$k+2][$j] = $this->H[$k+2][$j] - $p * $z;
}
$this->H[$k][$j] = $this->H[$k][$j] - $p * $x;
$this->H[$k+1][$j] = $this->H[$k+1][$j] - $p * $y;
}
// Column modification
for ($i = 0; $i <= min($n, $k+3); ++$i) {
$p = $x * $this->H[$i][$k] + $y * $this->H[$i][$k+1];
if ($notlast) {
$p = $p + $z * $this->H[$i][$k+2];
$this->H[$i][$k+2] = $this->H[$i][$k+2] - $p * $r;
}
$this->H[$i][$k] = $this->H[$i][$k] - $p;
$this->H[$i][$k+1] = $this->H[$i][$k+1] - $p * $q;
}
// Accumulate transformations
for ($i = $low; $i <= $high; ++$i) {
$p = $x * $this->V[$i][$k] + $y * $this->V[$i][$k+1];
if ($notlast) {
$p = $p + $z * $this->V[$i][$k+2];
$this->V[$i][$k+2] = $this->V[$i][$k+2] - $p * $r;
}
$this->V[$i][$k] = $this->V[$i][$k] - $p;
$this->V[$i][$k+1] = $this->V[$i][$k+1] - $p * $q;
}
} // ($s != 0)
} // k loop
} // check convergence
} // while ($n >= $low)
// Backsubstitute to find vectors of upper triangular form
if ($norm == 0.0) {
return;
}
for ($n = $nn-1; $n >= 0; --$n) {
$p = $this->d[$n];
$q = $this->e[$n];
// Real vector
if ($q == 0) {
$l = $n;
$this->H[$n][$n] = 1.0;
for ($i = $n-1; $i >= 0; --$i) {
$w = $this->H[$i][$i] - $p;
$r = 0.0;
for ($j = $l; $j <= $n; ++$j) {
$r = $r + $this->H[$i][$j] * $this->H[$j][$n];
}
if ($this->e[$i] < 0.0) {
$z = $w;
$s = $r;
} else {
$l = $i;
if ($this->e[$i] == 0.0) {
if ($w != 0.0) {
$this->H[$i][$n] = -$r / $w;
} else {
$this->H[$i][$n] = -$r / ($eps * $norm);
}
// Solve real equations
} else {
$x = $this->H[$i][$i+1];
$y = $this->H[$i+1][$i];
$q = ($this->d[$i] - $p) * ($this->d[$i] - $p) + $this->e[$i] * $this->e[$i];
$t = ($x * $s - $z * $r) / $q;
$this->H[$i][$n] = $t;
if (abs($x) > abs($z)) {
$this->H[$i+1][$n] = (-$r - $w * $t) / $x;
} else {
$this->H[$i+1][$n] = (-$s - $y * $t) / $z;
}
}
// Overflow control
$t = abs($this->H[$i][$n]);
if (($eps * $t) * $t > 1) {
for ($j = $i; $j <= $n; ++$j) {
$this->H[$j][$n] = $this->H[$j][$n] / $t;
}
}
}
}
// Complex vector
} else if ($q < 0) {
$l = $n-1;
// Last vector component imaginary so matrix is triangular
if (abs($this->H[$n][$n-1]) > abs($this->H[$n-1][$n])) {
$this->H[$n-1][$n-1] = $q / $this->H[$n][$n-1];
$this->H[$n-1][$n] = -($this->H[$n][$n] - $p) / $this->H[$n][$n-1];
} else {
$this->cdiv(0.0, -$this->H[$n-1][$n], $this->H[$n-1][$n-1] - $p, $q);
$this->H[$n-1][$n-1] = $this->cdivr;
$this->H[$n-1][$n] = $this->cdivi;
}
$this->H[$n][$n-1] = 0.0;
$this->H[$n][$n] = 1.0;
for ($i = $n-2; $i >= 0; --$i) {
// double ra,sa,vr,vi;
$ra = 0.0;
$sa = 0.0;
for ($j = $l; $j <= $n; ++$j) {
$ra = $ra + $this->H[$i][$j] * $this->H[$j][$n-1];
$sa = $sa + $this->H[$i][$j] * $this->H[$j][$n];
}
$w = $this->H[$i][$i] - $p;
if ($this->e[$i] < 0.0) {
$z = $w;
$r = $ra;
$s = $sa;
} else {
$l = $i;
if ($this->e[$i] == 0) {
$this->cdiv(-$ra, -$sa, $w, $q);
$this->H[$i][$n-1] = $this->cdivr;
$this->H[$i][$n] = $this->cdivi;
} else {
// Solve complex equations
$x = $this->H[$i][$i+1];
$y = $this->H[$i+1][$i];
$vr = ($this->d[$i] - $p) * ($this->d[$i] - $p) + $this->e[$i] * $this->e[$i] - $q * $q;
$vi = ($this->d[$i] - $p) * 2.0 * $q;
if ($vr == 0.0 & $vi == 0.0) {
$vr = $eps * $norm * (abs($w) + abs($q) + abs($x) + abs($y) + abs($z));
}
$this->cdiv($x * $r - $z * $ra + $q * $sa, $x * $s - $z * $sa - $q * $ra, $vr, $vi);
$this->H[$i][$n-1] = $this->cdivr;
$this->H[$i][$n] = $this->cdivi;
if (abs($x) > (abs($z) + abs($q))) {
$this->H[$i+1][$n-1] = (-$ra - $w * $this->H[$i][$n-1] + $q * $this->H[$i][$n]) / $x;
$this->H[$i+1][$n] = (-$sa - $w * $this->H[$i][$n] - $q * $this->H[$i][$n-1]) / $x;
} else {
$this->cdiv(-$r - $y * $this->H[$i][$n-1], -$s - $y * $this->H[$i][$n], $z, $q);
$this->H[$i+1][$n-1] = $this->cdivr;
$this->H[$i+1][$n] = $this->cdivi;
}
}
// Overflow control
$t = max(abs($this->H[$i][$n-1]),abs($this->H[$i][$n]));
if (($eps * $t) * $t > 1) {
for ($j = $i; $j <= $n; ++$j) {
$this->H[$j][$n-1] = $this->H[$j][$n-1] / $t;
$this->H[$j][$n] = $this->H[$j][$n] / $t;
}
}
} // end else
} // end for
} // end else for complex case
} // end for
// Vectors of isolated roots
for ($i = 0; $i < $nn; ++$i) {
if ($i < $low | $i > $high) {
for ($j = $i; $j < $nn; ++$j) {
$this->V[$i][$j] = $this->H[$i][$j];
}
}
}
// Back transformation to get eigenvectors of original matrix
for ($j = $nn-1; $j >= $low; --$j) {
for ($i = $low; $i <= $high; ++$i) {
$z = 0.0;
for ($k = $low; $k <= min($j,$high); ++$k) {
$z = $z + $this->V[$i][$k] * $this->H[$k][$j];
}
$this->V[$i][$j] = $z;
}
}
} // end hqr2
/**
* Constructor: Check for symmetry, then construct the eigenvalue decomposition
*
* @access public
* @param A Square matrix
* @return Structure to access D and V.
*/
public function __construct($Arg) {
$this->A = $Arg->getArray();
$this->n = $Arg->getColumnDimension();
$issymmetric = true;
for ($j = 0; ($j < $this->n) & $issymmetric; ++$j) {
for ($i = 0; ($i < $this->n) & $issymmetric; ++$i) {
$issymmetric = ($this->A[$i][$j] == $this->A[$j][$i]);
}
}
if ($issymmetric) {
$this->V = $this->A;
// Tridiagonalize.
$this->tred2();
// Diagonalize.
$this->tql2();
} else {
$this->H = $this->A;
$this->ort = array();
// Reduce to Hessenberg form.
$this->orthes();
// Reduce Hessenberg to real Schur form.
$this->hqr2();
}
}
/**
* Return the eigenvector matrix
*
* @access public
* @return V
*/
public function getV() {
return new Matrix($this->V, $this->n, $this->n);
}
/**
* Return the real parts of the eigenvalues
*
* @access public
* @return real(diag(D))
*/
public function getRealEigenvalues() {
return $this->d;
}
/**
* Return the imaginary parts of the eigenvalues
*
* @access public
* @return imag(diag(D))
*/
public function getImagEigenvalues() {
return $this->e;
}
/**
* Return the block diagonal eigenvalue matrix
*
* @access public
* @return D
*/
public function getD() {
for ($i = 0; $i < $this->n; ++$i) {
$D[$i] = array_fill(0, $this->n, 0.0);
$D[$i][$i] = $this->d[$i];
if ($this->e[$i] == 0) {
continue;
}
$o = ($this->e[$i] > 0) ? $i + 1 : $i - 1;
$D[$i][$o] = $this->e[$i];
}
return new Matrix($D);
}
} // class EigenvalueDecomposition
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/EigenvalueDecomposition.php | PHP | asf20 | 22,708 |
<?php
error_reporting(E_ALL);
/**
* @package JAMA
*/
require_once '../Matrix.php';
require_once 'Stats.php';
/**
* Example of use of Matrix Class, featuring magic squares.
*/
class Benchmark {
public $stat;
/**
* Simple function to replicate PHP 5 behaviour
*/
function microtime_float() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
} // function microtime_float()
function displayStats($times = null) {
$this->stat->setData($times);
$stats = $this->stat->calcFull();
echo '<table style="margin-left:32px;">';
echo '<tr><td style="text-align:right;"><b>n:</b><td style="text-align:right;">' . $stats['count'] . ' </td></tr>';
echo '<tr><td style="text-align:right;"><b>Mean:</b><td style="text-align:right;">' . $stats['mean'] . ' </td></tr>';
echo '<tr><td style="text-align:right;"><b>Min.:</b><td style="text-align:right;">' . $stats['min'] . ' </td></tr>';
echo '<tr><td style="text-align:right;"><b>Max.:</b><td style="text-align:right;">' . $stats['max'] . ' </td></tr>';
echo '<tr><td style="text-align:right;"><b>σ:</b><td style="text-align:right;">' . $stats['stdev'] . ' </td></tr>';
echo '<tr><td style="text-align:right;"><b>Variance:</b><td style="text-align:right;">' . $stats['variance'] . ' </td></tr>';
echo '<tr><td style="text-align:right;"><b>Range:</b><td style="text-align:right;">' . $stats['range'] . ' </td></tr>';
echo '</table>';
return $stats;
} // function displayStats()
function runEig($n = 4, $t = 100) {
$times = array();
for ($i = 0; $i < $t; ++$i) {
$M = Matrix::random($n, $n);
$start_time = $this->microtime_float();
$E = new EigenvalueDecomposition($M);
$stop_time = $this->microtime_float();
$times[] = $stop_time - $start_time;
}
return $times;
} // function runEig()
function runLU($n = 4, $t = 100) {
$times = array();
for ($i = 0; $i < $t; ++$i) {
$M = Matrix::random($n, $n);
$start_time = $this->microtime_float();
$E = new LUDecomposition($M);
$stop_time = $this->microtime_float();
$times[] = $stop_time - $start_time;
}
return $times;
} // function runLU()
function runQR($n = 4, $t = 100) {
$times = array();
for ($i = 0; $i < $t; ++$i) {
$M = Matrix::random($n, $n);
$start_time = $this->microtime_float();
$E = new QRDecomposition($M);
$stop_time = $this->microtime_float();
$times[] = $stop_time - $start_time;
}
return $times;
} // function runQR()
function runCholesky($n = 4, $t = 100) {
$times = array();
for ($i = 0; $i < $t; ++$i) {
$M = Matrix::random($n, $n);
$start_time = $this->microtime_float();
$E = new CholeskyDecomposition($M);
$stop_time = $this->microtime_float();
$times[] = $stop_time - $start_time;
}
return $times;
} // function runCholesky()
function runSVD($n = 4, $t = 100) {
$times = array();
for ($i = 0; $i < $t; ++$i) {
$M = Matrix::random($n, $n);
$start_time = $this->microtime_float();
$E = new SingularValueDecomposition($M);
$stop_time = $this->microtime_float();
$times[] = $stop_time - $start_time;
}
return $times;
} // function runSVD()
function run() {
$n = 8;
$t = 16;
$sum = 0;
echo "<b>Cholesky decomposition: $t random {$n}x{$n} matrices</b><br />";
$r = $this->displayStats($this->runCholesky($n, $t));
$sum += $r['mean'] * $n;
echo '<hr />';
echo "<b>Eigenvalue decomposition: $t random {$n}x{$n} matrices</b><br />";
$r = $this->displayStats($this->runEig($n, $t));
$sum += $r['mean'] * $n;
echo '<hr />';
echo "<b>LU decomposition: $t random {$n}x{$n} matrices</b><br />";
$r = $this->displayStats($this->runLU($n, $t));
$sum += $r['mean'] * $n;
echo '<hr />';
echo "<b>QR decomposition: $t random {$n}x{$n} matrices</b><br />";
$r = $this->displayStats($this->runQR($n, $t));
$sum += $r['mean'] * $n;
echo '<hr />';
echo "<b>Singular Value decomposition: $t random {$n}x{$n} matrices</b><br />";
$r = $this->displayStats($this->runSVD($n, $t));
$sum += $r['mean'] * $n;
return $sum;
} // function run()
public function __construct() {
$this->stat = new Base();
} // function Benchmark()
} // class Benchmark (end MagicSquareExample)
$benchmark = new Benchmark();
switch($_REQUEST['decomposition']) {
case 'cholesky':
$m = array();
for ($i = 2; $i <= 8; $i *= 2) {
$t = 32 / $i;
echo "<b>Cholesky decomposition: $t random {$i}x{$i} matrices</b><br />";
$s = $benchmark->displayStats($benchmark->runCholesky($i, $t));
$m[$i] = $s['mean'];
echo "<br />";
}
echo '<pre>';
foreach($m as $x => $y) {
echo "$x\t" . 1000*$y . "\n";
}
echo '</pre>';
break;
case 'eigenvalue':
$m = array();
for ($i = 2; $i <= 8; $i *= 2) {
$t = 32 / $i;
echo "<b>Eigenvalue decomposition: $t random {$i}x{$i} matrices</b><br />";
$s = $benchmark->displayStats($benchmark->runEig($i, $t));
$m[$i] = $s['mean'];
echo "<br />";
}
echo '<pre>';
foreach($m as $x => $y) {
echo "$x\t" . 1000*$y . "\n";
}
echo '</pre>';
break;
case 'lu':
$m = array();
for ($i = 2; $i <= 8; $i *= 2) {
$t = 32 / $i;
echo "<b>LU decomposition: $t random {$i}x{$i} matrices</b><br />";
$s = $benchmark->displayStats($benchmark->runLU($i, $t));
$m[$i] = $s['mean'];
echo "<br />";
}
echo '<pre>';
foreach($m as $x => $y) {
echo "$x\t" . 1000*$y . "\n";
}
echo '</pre>';
break;
case 'qr':
$m = array();
for ($i = 2; $i <= 8; $i *= 2) {
$t = 32 / $i;
echo "<b>QR decomposition: $t random {$i}x{$i} matrices</b><br />";
$s = $benchmark->displayStats($benchmark->runQR($i, $t));
$m[$i] = $s['mean'];
echo "<br />";
}
echo '<pre>';
foreach($m as $x => $y) {
echo "$x\t" . 1000*$y . "\n";
}
echo '</pre>';
break;
case 'svd':
$m = array();
for($i = 2; $i <= 8; $i *= 2) {
$t = 32 / $i;
echo "<b>Singular value decomposition: $t random {$i}x{$i} matrices</b><br />";
$s = $benchmark->displayStats($benchmark->runSVD($i, $t));
$m[$i] = $s['mean'];
echo "<br />";
}
echo '<pre>';
foreach($m as $x => $y) {
echo "$x\t" . 1000*$y . "\n";
}
echo '</pre>';
break;
case 'all':
$s = $benchmark->run();
print("<br /><b>Total<b>: {$s}s<br />");
break;
default:
?>
<ul>
<li><a href="benchmark.php?decomposition=all">Complete Benchmark</a>
<ul>
<li><a href="benchmark.php?decomposition=cholesky">Cholesky</a></li>
<li><a href="benchmark.php?decomposition=eigenvalue">Eigenvalue</a></li>
<li><a href="benchmark.php?decomposition=lu">LU</a></li>
<li><a href="benchmark.php?decomposition=qr">QR</a></li>
<li><a href="benchmark.php?decomposition=svd">Singular Value</a></li>
</ul>
</li>
</ul>
<?php
break;
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/examples/benchmark.php | PHP | asf20 | 6,781 |
<?php
require_once "../Matrix.php";
/*
* @package JAMA
* @author Michael Bommarito
* @author Paul Meagher
* @version 0.1
*
* Function to fit an order n polynomial function through
* a series of x-y data points using least squares.
*
* @param $X array x values
* @param $Y array y values
* @param $n int order of polynomial to be used for fitting
* @returns array $coeffs of polynomial coefficients
* Pre-Conditions: the system is not underdetermined: sizeof($X) > $n+1
*/
function polyfit($X, $Y, $n) {
for ($i = 0; $i < sizeof($X); ++$i)
for ($j = 0; $j <= $n; ++$j)
$A[$i][$j] = pow($X[$i], $j);
for ($i=0; $i < sizeof($Y); ++$i)
$B[$i] = array($Y[$i]);
$matrixA = new Matrix($A);
$matrixB = new Matrix($B);
$C = $matrixA->solve($matrixB);
return $C->getMatrix(0, $n, 0, 1);
}
function printpoly( $C = null ) {
for($i = $C->m - 1; $i >= 0; --$i) {
$r = $C->get($i, 0);
if ( abs($r) <= pow(10, -9) )
$r = 0;
if ($i == $C->m - 1)
echo $r . "x<sup>$i</sup>";
else if ($i < $C->m - 1)
echo " + " . $r . "x<sup>$i</sup>";
else if ($i == 0)
echo " + " . $r;
}
}
$X = array(0,1,2,3,4,5);
$Y = array(4,3,12,67,228, 579);
$points = new Matrix(array($X, $Y));
$points->toHTML();
printpoly(polyfit($X, $Y, 4));
echo '<hr />';
$X = array(0,1,2,3,4,5);
$Y = array(1,2,5,10,17, 26);
$points = new Matrix(array($X, $Y));
$points->toHTML();
printpoly(polyfit($X, $Y, 2));
echo '<hr />';
$X = array(0,1,2,3,4,5,6);
$Y = array(-90,-104,-178,-252,-26, 1160, 4446);
$points = new Matrix(array($X, $Y));
$points->toHTML();
printpoly(polyfit($X, $Y, 5));
echo '<hr />';
$X = array(0,1,2,3,4);
$Y = array(mt_rand(0, 10), mt_rand(40, 80), mt_rand(240, 400), mt_rand(1800, 2215), mt_rand(8000, 9000));
$points = new Matrix(array($X, $Y));
$points->toHTML();
printpoly(polyfit($X, $Y, 3));
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/examples/polyfit.php | PHP | asf20 | 1,814 |
<?php
require_once "../Matrix.php";
/**
* Given n points (x0,y0)...(xn-1,yn-1), the following methid computes
* the polynomial factors of the n-1't degree polynomial passing through
* the n points.
*
* Example: Passing in three points (2,3) (1,4) and (3,7) will produce
* the results [2.5, -8.5, 10] which means that the points are on the
* curve y = 2.5x² - 8.5x + 10.
*
* @see http://geosoft.no/software/lagrange/LagrangeInterpolation.java.html
* @author Jacob Dreyer
* @author Paul Meagher (port to PHP and minor changes)
*
* @param x[] float
* @param y[] float
*/
class LagrangeInterpolation {
public function findPolynomialFactors($x, $y) {
$n = count($x);
$data = array(); // double[n][n];
$rhs = array(); // double[n];
for ($i = 0; $i < $n; ++$i) {
$v = 1;
for ($j = 0; $j < $n; ++$j) {
$data[$i][$n-$j-1] = $v;
$v *= $x[$i];
}
$rhs[$i] = $y[$i];
}
// Solve m * s = b
$m = new Matrix($data);
$b = new Matrix($rhs, $n);
$s = $m->solve($b);
return $s->getRowPackedCopy();
} // function findPolynomialFactors()
} // class LagrangeInterpolation
$x = array(2.0, 1.0, 3.0);
$y = array(3.0, 4.0, 7.0);
$li = new LagrangeInterpolation;
$f = $li->findPolynomialFactors($x, $y);
for ($i = 0; $i < 3; ++$i) {
echo $f[$i]."<br />";
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation.php | PHP | asf20 | 1,305 |
<?php
/**
* quadratic (p-o)'S'S(p-o)
* solve for o, S
* S is a single scale factor
*/
class LMQuadTest {
/**
* @param array[] $x
* @param array[] $a
*/
function val($x, $a) {
if (count($a) != 3) die ("Wrong number of elements in array a");
if (count($x) != 2) die ("Wrong number of elements in array x");
$ox = $a[0];
$oy = $a[1];
$s = $a[2];
$sdx = $s * ($x[0] - $ox);
$sdy = $s * ($x[1] - $oy);
return ($sdx * $sdx) + ($sdy * $sdy);
} // function val()
/**
* z = (p-o)'S'S(p-o)
* dz/dp = 2S'S(p-o)
*
* z = (s*(px-ox))^2 + (s*(py-oy))^2
* dz/dox = -2(s*(px-ox))*s
* dz/ds = 2*s*[(px-ox)^2 + (py-oy)^2]
*
* z = (s*dx)^2 + (s*dy)^2
* dz/ds = 2(s*dx)*dx + 2(s*dy)*dy
*
* @param array[] $x
* @param array[] $a
* @param int $a_k
* @param array[] $a
*/
function grad($x, $a, $a_k) {
if (count($a) != 3) die ("Wrong number of elements in array a");
if (count($x) != 2) die ("Wrong number of elements in array x");
if ($a_k < 3) die ("a_k=".$a_k);
$ox = $a[0];
$oy = $a[1];
$s = $a[2];
$dx = ($x[0] - $ox);
$dy = ($x[1] - $oy);
if ($a_k == 0)
return -2.*$s*$s*$dx;
elseif ($a_k == 1)
return -2.*$s*$s*$dy;
else
return 2.*$s*($dx*$dx + $dy*$dy);
} // function grad()
/**
* @return array[] $a
*/
function initial() {
$a[0] = 0.05;
$a[1] = 0.1;
$a[2] = 1.0;
return $a;
} // function initial()
/**
* @return Object[] $a
*/
function testdata() {
$npts = 25;
$a[0] = 0.;
$a[1] = 0.;
$a[2] = 0.9;
$i = 0;
for ($r = -2; $r <= 2; ++$r) {
for ($c = -2; $c <= 2; ++$c) {
$x[$i][0] = $c;
$x[$i][1] = $r;
$y[$i] = $this->val($x[$i], $a);
print("Quad ".$c.",".$r." -> ".$y[$i]."<br />");
$s[$i] = 1.;
++$i;
}
}
print("quad x= ");
$qx = new Matrix($x);
$qx->print(10, 2);
print("quad y= ");
$qy = new Matrix($y, $npts);
$qy->print(10, 2);
$o[0] = $x;
$o[1] = $a;
$o[2] = $y;
$o[3] = $s;
return $o;
} // function testdata()
} // class LMQuadTest
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/examples/LMQuadTest.php | PHP | asf20 | 2,030 |
<?php
require_once "../Matrix.php";
/**
* Given n points (x0,y0)...(xn-1,yn-1), the following method computes
* the polynomial factors of the n-1't degree polynomial passing through
* the n points.
*
* Example: Passing in three points (2,3) (1,4) and (3,7) will produce
* the results [2.5, -8.5, 10] which means that the points are on the
* curve y = 2.5x² - 8.5x + 10.
*
* @see http://geosoft.no/software/lagrange/LagrangeInterpolation.java.html
* @see http://source.freehep.org/jcvsweb/ilc/LCSIM/wdview/lcsim/src/org/lcsim/fit/polynomial/PolynomialFitter.java
* @author Jacob Dreyer
* @author Paul Meagher (port to PHP and minor changes)
*
* @param x[] float
* @param y[] float
*/
class LagrangeInterpolation {
public function findPolynomialFactors($x, $y) {
$n = count($x);
$data = array(); // double[n][n];
$rhs = array(); // double[n];
for ($i = 0; $i < $n; ++$i) {
$v = 1;
for ($j = 0; $j < $n; ++$j) {
$data[$i][$n-$j-1] = $v;
$v *= $x[$i];
}
$rhs[$i] = $y[$i];
}
// Solve m * s = b
$m = new Matrix($data);
$b = new Matrix($rhs, $n);
$s = $m->solve($b);
return $s->getRowPackedCopy();
} // function findPolynomialFactors()
} // class LagrangeInterpolation
$x = array(2.0, 1.0, 3.0);
$y = array(3.0, 4.0, 7.0);
$li = new LagrangeInterpolation;
$f = $li->findPolynomialFactors($x, $y);
for ($i = 0; $i < 3; ++$i) {
echo $f[$i]."<br />";
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation2.php | PHP | asf20 | 1,420 |
<?php
/**
* @package JAMA
*/
require_once "../Matrix.php";
/**
* Example of use of Matrix Class, featuring magic squares.
*/
class MagicSquareExample {
/**
* Generate magic square test matrix.
* @param int n dimension of matrix
*/
function magic($n) {
// Odd order
if (($n % 2) == 1) {
$a = ($n+1)/2;
$b = ($n+1);
for ($j = 0; $j < $n; ++$j)
for ($i = 0; $i < $n; ++$i)
$M[$i][$j] = $n*(($i+$j+$a) % $n) + (($i+2*$j+$b) % $n) + 1;
// Doubly Even Order
} else if (($n % 4) == 0) {
for ($j = 0; $j < $n; ++$j) {
for ($i = 0; $i < $n; ++$i) {
if ((($i+1)/2)%2 == (($j+1)/2)%2)
$M[$i][$j] = $n*$n-$n*$i-$j;
else
$M[$i][$j] = $n*$i+$j+1;
}
}
// Singly Even Order
} else {
$p = $n/2;
$k = ($n-2)/4;
$A = $this->magic($p);
$M = array();
for ($j = 0; $j < $p; ++$j) {
for ($i = 0; $i < $p; ++$i) {
$aij = $A->get($i,$j);
$M[$i][$j] = $aij;
$M[$i][$j+$p] = $aij + 2*$p*$p;
$M[$i+$p][$j] = $aij + 3*$p*$p;
$M[$i+$p][$j+$p] = $aij + $p*$p;
}
}
for ($i = 0; $i < $p; ++$i) {
for ($j = 0; $j < $k; ++$j) {
$t = $M[$i][$j];
$M[$i][$j] = $M[$i+$p][$j];
$M[$i+$p][$j] = $t;
}
for ($j = $n-$k+1; $j < $n; ++$j) {
$t = $M[$i][$j];
$M[$i][$j] = $M[$i+$p][$j];
$M[$i+$p][$j] = $t;
}
}
$t = $M[$k][0]; $M[$k][0] = $M[$k+$p][0]; $M[$k+$p][0] = $t;
$t = $M[$k][$k]; $M[$k][$k] = $M[$k+$p][$k]; $M[$k+$p][$k] = $t;
}
return new Matrix($M);
}
/**
* Simple function to replicate PHP 5 behaviour
*/
function microtime_float() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
/**
* Tests LU, QR, SVD and symmetric Eig decompositions.
*
* n = order of magic square.
* trace = diagonal sum, should be the magic sum, (n^3 + n)/2.
* max_eig = maximum eigenvalue of (A + A')/2, should equal trace.
* rank = linear algebraic rank, should equal n if n is odd,
* be less than n if n is even.
* cond = L_2 condition number, ratio of singular values.
* lu_res = test of LU factorization, norm1(L*U-A(p,:))/(n*eps).
* qr_res = test of QR factorization, norm1(Q*R-A)/(n*eps).
*/
function main() {
?>
<p>Test of Matrix Class, using magic squares.</p>
<p>See MagicSquareExample.main() for an explanation.</p>
<table border='1' cellspacing='0' cellpadding='4'>
<tr>
<th>n</th>
<th>trace</th>
<th>max_eig</th>
<th>rank</th>
<th>cond</th>
<th>lu_res</th>
<th>qr_res</th>
</tr>
<?php
$start_time = $this->microtime_float();
$eps = pow(2.0,-52.0);
for ($n = 3; $n <= 6; ++$n) {
echo "<tr>";
echo "<td align='right'>$n</td>";
$M = $this->magic($n);
$t = (int) $M->trace();
echo "<td align='right'>$t</td>";
$O = $M->plus($M->transpose());
$E = new EigenvalueDecomposition($O->times(0.5));
$d = $E->getRealEigenvalues();
echo "<td align='right'>".$d[$n-1]."</td>";
$r = $M->rank();
echo "<td align='right'>".$r."</td>";
$c = $M->cond();
if ($c < 1/$eps)
echo "<td align='right'>".sprintf("%.3f",$c)."</td>";
else
echo "<td align='right'>Inf</td>";
$LU = new LUDecomposition($M);
$L = $LU->getL();
$U = $LU->getU();
$p = $LU->getPivot();
// Java version: R = L.times(U).minus(M.getMatrix(p,0,n-1));
$S = $L->times($U);
$R = $S->minus($M->getMatrix($p,0,$n-1));
$res = $R->norm1()/($n*$eps);
echo "<td align='right'>".sprintf("%.3f",$res)."</td>";
$QR = new QRDecomposition($M);
$Q = $QR->getQ();
$R = $QR->getR();
$S = $Q->times($R);
$R = $S->minus($M);
$res = $R->norm1()/($n*$eps);
echo "<td align='right'>".sprintf("%.3f",$res)."</td>";
echo "</tr>";
}
echo "<table>";
echo "<br />";
$stop_time = $this->microtime_float();
$etime = $stop_time - $start_time;
echo "<p>Elapsed time is ". sprintf("%.4f",$etime) ." seconds.</p>";
}
}
$magic = new MagicSquareExample();
$magic->main();
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/examples/MagicSquareExample.php | PHP | asf20 | 4,495 |
<?php
//
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: Stats.php,v 1.15 2003/06/01 11:40:30 jmcastagnetto Exp $
//
include_once 'PEAR.php';
/**
* @package Math_Stats
*/
// Constants for defining the statistics to calculate /*{{{*/
/**
* STATS_BASIC to generate the basic descriptive statistics
*/
define('STATS_BASIC', 1);
/**
* STATS_FULL to generate also higher moments, mode, median, etc.
*/
define('STATS_FULL', 2);
/*}}}*/
// Constants describing the data set format /*{{{*/
/**
* STATS_DATA_SIMPLE for an array of numeric values. This is the default.
* e.g. $data = array(2,3,4,5,1,1,6);
*/
define('STATS_DATA_SIMPLE', 0);
/**
* STATS_DATA_CUMMULATIVE for an associative array of frequency values,
* where in each array entry, the index is the data point and the
* value the count (frequency):
* e.g. $data = array(3=>4, 2.3=>5, 1.25=>6, 0.5=>3)
*/
define('STATS_DATA_CUMMULATIVE', 1);
/*}}}*/
// Constants defining how to handle nulls /*{{{*/
/**
* STATS_REJECT_NULL, reject data sets with null values. This is the default.
* Any non-numeric value is considered a null in this context.
*/
define('STATS_REJECT_NULL', -1);
/**
* STATS_IGNORE_NULL, ignore null values and prune them from the data.
* Any non-numeric value is considered a null in this context.
*/
define('STATS_IGNORE_NULL', -2);
/**
* STATS_USE_NULL_AS_ZERO, assign the value of 0 (zero) to null values.
* Any non-numeric value is considered a null in this context.
*/
define('STATS_USE_NULL_AS_ZERO', -3);
/*}}}*/
/**
* A class to calculate descriptive statistics from a data set.
* Data sets can be simple arrays of data, or a cummulative hash.
* The second form is useful when passing large data set,
* for example the data set:
*
* <pre>
* $data1 = array (1,2,1,1,1,1,3,3,4.1,3,2,2,4.1,1,1,2,3,3,2,2,1,1,2,2);
* </pre>
*
* can be epxressed more compactly as:
*
* <pre>
* $data2 = array('1'=>9, '2'=>8, '3'=>5, '4.1'=>2);
* </pre>
*
* Example of use:
*
* <pre>
* include_once 'Math/Stats.php';
* $s = new Math_Stats();
* $s->setData($data1);
* // or
* // $s->setData($data2, STATS_DATA_CUMMULATIVE);
* $stats = $s->calcBasic();
* echo 'Mean: '.$stats['mean'].' StDev: '.$stats['stdev'].' <br />\n';
*
* // using data with nulls
* // first ignoring them:
* $data3 = array(1.2, 'foo', 2.4, 3.1, 4.2, 3.2, null, 5.1, 6.2);
* $s->setNullOption(STATS_IGNORE_NULL);
* $s->setData($data3);
* $stats3 = $s->calcFull();
*
* // and then assuming nulls == 0
* $s->setNullOption(STATS_USE_NULL_AS_ZERO);
* $s->setData($data3);
* $stats3 = $s->calcFull();
* </pre>
*
* Originally this class was part of NumPHP (Numeric PHP package)
*
* @author Jesus M. Castagnetto <jmcastagnetto@php.net>
* @version 0.8
* @access public
* @package Math_Stats
*/
class Base {/*{{{*/
// properties /*{{{*/
/**
* The simple or cummulative data set.
* Null by default.
*
* @access private
* @var array
*/
public $_data = null;
/**
* Expanded data set. Only set when cummulative data
* is being used. Null by default.
*
* @access private
* @var array
*/
public $_dataExpanded = null;
/**
* Flag for data type, one of STATS_DATA_SIMPLE or
* STATS_DATA_CUMMULATIVE. Null by default.
*
* @access private
* @var int
*/
public $_dataOption = null;
/**
* Flag for null handling options. One of STATS_REJECT_NULL,
* STATS_IGNORE_NULL or STATS_USE_NULL_AS_ZERO
*
* @access private
* @var int
*/
public $_nullOption;
/**
* Array for caching result values, should be reset
* when using setData()
*
* @access private
* @var array
*/
public $_calculatedValues = array();
/*}}}*/
/**
* Constructor for the class
*
* @access public
* @param optional int $nullOption how to handle null values
* @return object Math_Stats
*/
function Math_Stats($nullOption=STATS_REJECT_NULL) {/*{{{*/
$this->_nullOption = $nullOption;
}/*}}}*/
/**
* Sets and verifies the data, checking for nulls and using
* the current null handling option
*
* @access public
* @param array $arr the data set
* @param optional int $opt data format: STATS_DATA_CUMMULATIVE or STATS_DATA_SIMPLE (default)
* @return mixed true on success, a PEAR_Error object otherwise
*/
function setData($arr, $opt=STATS_DATA_SIMPLE) {/*{{{*/
if (!is_array($arr)) {
return PEAR::raiseError('invalid data, an array of numeric data was expected');
}
$this->_data = null;
$this->_dataExpanded = null;
$this->_dataOption = null;
$this->_calculatedValues = array();
if ($opt == STATS_DATA_SIMPLE) {
$this->_dataOption = $opt;
$this->_data = array_values($arr);
} else if ($opt == STATS_DATA_CUMMULATIVE) {
$this->_dataOption = $opt;
$this->_data = $arr;
$this->_dataExpanded = array();
}
return $this->_validate();
}/*}}}*/
/**
* Returns the data which might have been modified
* according to the current null handling options.
*
* @access public
* @param boolean $expanded whether to return a expanded list, default is false
* @return mixed array of data on success, a PEAR_Error object otherwise
* @see _validate()
*/
function getData($expanded=false) {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if ($this->_dataOption == STATS_DATA_CUMMULATIVE && $expanded) {
return $this->_dataExpanded;
} else {
return $this->_data;
}
}/*}}}*/
/**
* Sets the null handling option.
* Must be called before assigning a new data set containing null values
*
* @access public
* @return mixed true on success, a PEAR_Error object otherwise
* @see _validate()
*/
function setNullOption($nullOption) {/*{{{*/
if ($nullOption == STATS_REJECT_NULL
|| $nullOption == STATS_IGNORE_NULL
|| $nullOption == STATS_USE_NULL_AS_ZERO) {
$this->_nullOption = $nullOption;
return true;
} else {
return PEAR::raiseError('invalid null handling option expecting: '.
'STATS_REJECT_NULL, STATS_IGNORE_NULL or STATS_USE_NULL_AS_ZERO');
}
}/*}}}*/
/**
* Transforms the data by substracting each entry from the mean and
* dividing by its standard deviation. This will reset all pre-calculated
* values to their original (unset) defaults.
*
* @access public
* @return mixed true on success, a PEAR_Error object otherwise
* @see mean()
* @see stDev()
* @see setData()
*/
function studentize() {/*{{{*/
$mean = $this->mean();
if (PEAR::isError($mean)) {
return $mean;
}
$std = $this->stDev();
if (PEAR::isError($std)) {
return $std;
}
if ($std == 0) {
return PEAR::raiseError('cannot studentize data, standard deviation is zero.');
}
$arr = array();
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
foreach ($this->_data as $val=>$freq) {
$newval = ($val - $mean) / $std;
$arr["$newval"] = $freq;
}
} else {
foreach ($this->_data as $val) {
$newval = ($val - $mean) / $std;
$arr[] = $newval;
}
}
return $this->setData($arr, $this->_dataOption);
}/*}}}*/
/**
* Transforms the data by substracting each entry from the mean.
* This will reset all pre-calculated values to their original (unset) defaults.
*
* @access public
* @return mixed true on success, a PEAR_Error object otherwise
* @see mean()
* @see setData()
*/
function center() {/*{{{*/
$mean = $this->mean();
if (PEAR::isError($mean)) {
return $mean;
}
$arr = array();
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
foreach ($this->_data as $val=>$freq) {
$newval = $val - $mean;
$arr["$newval"] = $freq;
}
} else {
foreach ($this->_data as $val) {
$newval = $val - $mean;
$arr[] = $newval;
}
}
return $this->setData($arr, $this->_dataOption);
}/*}}}*/
/**
* Calculates the basic or full statistics for the data set
*
* @access public
* @param int $mode one of STATS_BASIC or STATS_FULL
* @param boolean $returnErrorObject whether the raw PEAR_Error (when true, default),
* or only the error message will be returned (when false), if an error happens.
* @return mixed an associative array of statistics on success, a PEAR_Error object otherwise
* @see calcBasic()
* @see calcFull()
*/
function calc($mode, $returnErrorObject=true) {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if ($mode == STATS_BASIC) {
return $this->calcBasic($returnErrorObject);
} elseif ($mode == STATS_FULL) {
return $this->calcFull($returnErrorObject);
} else {
return PEAR::raiseError('incorrect mode, expected STATS_BASIC or STATS_FULL');
}
}/*}}}*/
/**
* Calculates a basic set of statistics
*
* @access public
* @param boolean $returnErrorObject whether the raw PEAR_Error (when true, default),
* or only the error message will be returned (when false), if an error happens.
* @return mixed an associative array of statistics on success, a PEAR_Error object otherwise
* @see calc()
* @see calcFull()
*/
function calcBasic($returnErrorObject=true) {/*{{{*/
return array (
'min' => $this->__format($this->min(), $returnErrorObject),
'max' => $this->__format($this->max(), $returnErrorObject),
'sum' => $this->__format($this->sum(), $returnErrorObject),
'sum2' => $this->__format($this->sum2(), $returnErrorObject),
'count' => $this->__format($this->count(), $returnErrorObject),
'mean' => $this->__format($this->mean(), $returnErrorObject),
'stdev' => $this->__format($this->stDev(), $returnErrorObject),
'variance' => $this->__format($this->variance(), $returnErrorObject),
'range' => $this->__format($this->range(), $returnErrorObject)
);
}/*}}}*/
/**
* Calculates a full set of statistics
*
* @access public
* @param boolean $returnErrorObject whether the raw PEAR_Error (when true, default),
* or only the error message will be returned (when false), if an error happens.
* @return mixed an associative array of statistics on success, a PEAR_Error object otherwise
* @see calc()
* @see calcBasic()
*/
function calcFull($returnErrorObject=true) {/*{{{*/
return array (
'min' => $this->__format($this->min(), $returnErrorObject),
'max' => $this->__format($this->max(), $returnErrorObject),
'sum' => $this->__format($this->sum(), $returnErrorObject),
'sum2' => $this->__format($this->sum2(), $returnErrorObject),
'count' => $this->__format($this->count(), $returnErrorObject),
'mean' => $this->__format($this->mean(), $returnErrorObject),
'median' => $this->__format($this->median(), $returnErrorObject),
'mode' => $this->__format($this->mode(), $returnErrorObject),
'midrange' => $this->__format($this->midrange(), $returnErrorObject),
'geometric_mean' => $this->__format($this->geometricMean(), $returnErrorObject),
'harmonic_mean' => $this->__format($this->harmonicMean(), $returnErrorObject),
'stdev' => $this->__format($this->stDev(), $returnErrorObject),
'absdev' => $this->__format($this->absDev(), $returnErrorObject),
'variance' => $this->__format($this->variance(), $returnErrorObject),
'range' => $this->__format($this->range(), $returnErrorObject),
'std_error_of_mean' => $this->__format($this->stdErrorOfMean(), $returnErrorObject),
'skewness' => $this->__format($this->skewness(), $returnErrorObject),
'kurtosis' => $this->__format($this->kurtosis(), $returnErrorObject),
'coeff_of_variation' => $this->__format($this->coeffOfVariation(), $returnErrorObject),
'sample_central_moments' => array (
1 => $this->__format($this->sampleCentralMoment(1), $returnErrorObject),
2 => $this->__format($this->sampleCentralMoment(2), $returnErrorObject),
3 => $this->__format($this->sampleCentralMoment(3), $returnErrorObject),
4 => $this->__format($this->sampleCentralMoment(4), $returnErrorObject),
5 => $this->__format($this->sampleCentralMoment(5), $returnErrorObject)
),
'sample_raw_moments' => array (
1 => $this->__format($this->sampleRawMoment(1), $returnErrorObject),
2 => $this->__format($this->sampleRawMoment(2), $returnErrorObject),
3 => $this->__format($this->sampleRawMoment(3), $returnErrorObject),
4 => $this->__format($this->sampleRawMoment(4), $returnErrorObject),
5 => $this->__format($this->sampleRawMoment(5), $returnErrorObject)
),
'frequency' => $this->__format($this->frequency(), $returnErrorObject),
'quartiles' => $this->__format($this->quartiles(), $returnErrorObject),
'interquartile_range' => $this->__format($this->interquartileRange(), $returnErrorObject),
'interquartile_mean' => $this->__format($this->interquartileMean(), $returnErrorObject),
'quartile_deviation' => $this->__format($this->quartileDeviation(), $returnErrorObject),
'quartile_variation_coefficient' => $this->__format($this->quartileVariationCoefficient(), $returnErrorObject),
'quartile_skewness_coefficient' => $this->__format($this->quartileSkewnessCoefficient(), $returnErrorObject)
);
}/*}}}*/
/**
* Calculates the minimum of a data set.
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the minimum value on success, a PEAR_Error object otherwise
* @see calc()
* @see max()
*/
function min() {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if (!array_key_exists('min', $this->_calculatedValues)) {
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
$min = min(array_keys($this->_data));
} else {
$min = min($this->_data);
}
$this->_calculatedValues['min'] = $min;
}
return $this->_calculatedValues['min'];
}/*}}}*/
/**
* Calculates the maximum of a data set.
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the maximum value on success, a PEAR_Error object otherwise
* @see calc()
* @see min()
*/
function max() {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if (!array_key_exists('max', $this->_calculatedValues)) {
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
$max = max(array_keys($this->_data));
} else {
$max = max($this->_data);
}
$this->_calculatedValues['max'] = $max;
}
return $this->_calculatedValues['max'];
}/*}}}*/
/**
* Calculates SUM { xi }
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the sum on success, a PEAR_Error object otherwise
* @see calc()
* @see sum2()
* @see sumN()
*/
function sum() {/*{{{*/
if (!array_key_exists('sum', $this->_calculatedValues)) {
$sum = $this->sumN(1);
if (PEAR::isError($sum)) {
return $sum;
} else {
$this->_calculatedValues['sum'] = $sum;
}
}
return $this->_calculatedValues['sum'];
}/*}}}*/
/**
* Calculates SUM { (xi)^2 }
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the sum on success, a PEAR_Error object otherwise
* @see calc()
* @see sum()
* @see sumN()
*/
function sum2() {/*{{{*/
if (!array_key_exists('sum2', $this->_calculatedValues)) {
$sum2 = $this->sumN(2);
if (PEAR::isError($sum2)) {
return $sum2;
} else {
$this->_calculatedValues['sum2'] = $sum2;
}
}
return $this->_calculatedValues['sum2'];
}/*}}}*/
/**
* Calculates SUM { (xi)^n }
* Handles cummulative data sets correctly
*
* @access public
* @param numeric $n the exponent
* @return mixed the sum on success, a PEAR_Error object otherwise
* @see calc()
* @see sum()
* @see sum2()
*/
function sumN($n) {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
$sumN = 0;
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
foreach($this->_data as $val=>$freq) {
$sumN += $freq * pow((double)$val, (double)$n);
}
} else {
foreach($this->_data as $val) {
$sumN += pow((double)$val, (double)$n);
}
}
return $sumN;
}/*}}}*/
/**
* Calculates PROD { (xi) }, (the product of all observations)
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the product on success, a PEAR_Error object otherwise
* @see productN()
*/
function product() {/*{{{*/
if (!array_key_exists('product', $this->_calculatedValues)) {
$product = $this->productN(1);
if (PEAR::isError($product)) {
return $product;
} else {
$this->_calculatedValues['product'] = $product;
}
}
return $this->_calculatedValues['product'];
}/*}}}*/
/**
* Calculates PROD { (xi)^n }, which is the product of all observations
* Handles cummulative data sets correctly
*
* @access public
* @param numeric $n the exponent
* @return mixed the product on success, a PEAR_Error object otherwise
* @see product()
*/
function productN($n) {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
$prodN = 1.0;
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
foreach($this->_data as $val=>$freq) {
if ($val == 0) {
return 0.0;
}
$prodN *= $freq * pow((double)$val, (double)$n);
}
} else {
foreach($this->_data as $val) {
if ($val == 0) {
return 0.0;
}
$prodN *= pow((double)$val, (double)$n);
}
}
return $prodN;
}/*}}}*/
/**
* Calculates the number of data points in the set
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the count on success, a PEAR_Error object otherwise
* @see calc()
*/
function count() {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if (!array_key_exists('count', $this->_calculatedValues)) {
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
$count = count($this->_dataExpanded);
} else {
$count = count($this->_data);
}
$this->_calculatedValues['count'] = $count;
}
return $this->_calculatedValues['count'];
}/*}}}*/
/**
* Calculates the mean (average) of the data points in the set
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the mean value on success, a PEAR_Error object otherwise
* @see calc()
* @see sum()
* @see count()
*/
function mean() {/*{{{*/
if (!array_key_exists('mean', $this->_calculatedValues)) {
$sum = $this->sum();
if (PEAR::isError($sum)) {
return $sum;
}
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
$this->_calculatedValues['mean'] = $sum / $count;
}
return $this->_calculatedValues['mean'];
}/*}}}*/
/**
* Calculates the range of the data set = max - min
*
* @access public
* @return mixed the value of the range on success, a PEAR_Error object otherwise.
*/
function range() {/*{{{*/
if (!array_key_exists('range', $this->_calculatedValues)) {
$min = $this->min();
if (PEAR::isError($min)) {
return $min;
}
$max = $this->max();
if (PEAR::isError($max)) {
return $max;
}
$this->_calculatedValues['range'] = $max - $min;
}
return $this->_calculatedValues['range'];
}/*}}}*/
/**
* Calculates the variance (unbiased) of the data points in the set
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the variance value on success, a PEAR_Error object otherwise
* @see calc()
* @see __sumdiff()
* @see count()
*/
function variance() {/*{{{*/
if (!array_key_exists('variance', $this->_calculatedValues)) {
$variance = $this->__calcVariance();
if (PEAR::isError($variance)) {
return $variance;
}
$this->_calculatedValues['variance'] = $variance;
}
return $this->_calculatedValues['variance'];
}/*}}}*/
/**
* Calculates the standard deviation (unbiased) of the data points in the set
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the standard deviation on success, a PEAR_Error object otherwise
* @see calc()
* @see variance()
*/
function stDev() {/*{{{*/
if (!array_key_exists('stDev', $this->_calculatedValues)) {
$variance = $this->variance();
if (PEAR::isError($variance)) {
return $variance;
}
$this->_calculatedValues['stDev'] = sqrt($variance);
}
return $this->_calculatedValues['stDev'];
}/*}}}*/
/**
* Calculates the variance (unbiased) of the data points in the set
* given a fixed mean (average) value. Not used in calcBasic(), calcFull()
* or calc().
* Handles cummulative data sets correctly
*
* @access public
* @param numeric $mean the fixed mean value
* @return mixed the variance on success, a PEAR_Error object otherwise
* @see __sumdiff()
* @see count()
* @see variance()
*/
function varianceWithMean($mean) {/*{{{*/
return $this->__calcVariance($mean);
}/*}}}*/
/**
* Calculates the standard deviation (unbiased) of the data points in the set
* given a fixed mean (average) value. Not used in calcBasic(), calcFull()
* or calc().
* Handles cummulative data sets correctly
*
* @access public
* @param numeric $mean the fixed mean value
* @return mixed the standard deviation on success, a PEAR_Error object otherwise
* @see varianceWithMean()
* @see stDev()
*/
function stDevWithMean($mean) {/*{{{*/
$varianceWM = $this->varianceWithMean($mean);
if (PEAR::isError($varianceWM)) {
return $varianceWM;
}
return sqrt($varianceWM);
}/*}}}*/
/**
* Calculates the absolute deviation of the data points in the set
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the absolute deviation on success, a PEAR_Error object otherwise
* @see calc()
* @see __sumabsdev()
* @see count()
* @see absDevWithMean()
*/
function absDev() {/*{{{*/
if (!array_key_exists('absDev', $this->_calculatedValues)) {
$absDev = $this->__calcAbsoluteDeviation();
if (PEAR::isError($absdev)) {
return $absdev;
}
$this->_calculatedValues['absDev'] = $absDev;
}
return $this->_calculatedValues['absDev'];
}/*}}}*/
/**
* Calculates the absolute deviation of the data points in the set
* given a fixed mean (average) value. Not used in calcBasic(), calcFull()
* or calc().
* Handles cummulative data sets correctly
*
* @access public
* @param numeric $mean the fixed mean value
* @return mixed the absolute deviation on success, a PEAR_Error object otherwise
* @see __sumabsdev()
* @see absDev()
*/
function absDevWithMean($mean) {/*{{{*/
return $this->__calcAbsoluteDeviation($mean);
}/*}}}*/
/**
* Calculates the skewness of the data distribution in the set
* The skewness measures the degree of asymmetry of a distribution,
* and is related to the third central moment of a distribution.
* A normal distribution has a skewness = 0
* A distribution with a tail off towards the high end of the scale
* (positive skew) has a skewness > 0
* A distribution with a tail off towards the low end of the scale
* (negative skew) has a skewness < 0
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the skewness value on success, a PEAR_Error object otherwise
* @see __sumdiff()
* @see count()
* @see stDev()
* @see calc()
*/
function skewness() {/*{{{*/
if (!array_key_exists('skewness', $this->_calculatedValues)) {
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
$stDev = $this->stDev();
if (PEAR::isError($stDev)) {
return $stDev;
}
$sumdiff3 = $this->__sumdiff(3);
if (PEAR::isError($sumdiff3)) {
return $sumdiff3;
}
$this->_calculatedValues['skewness'] = ($sumdiff3 / ($count * pow($stDev, 3)));
}
return $this->_calculatedValues['skewness'];
}/*}}}*/
/**
* Calculates the kurtosis of the data distribution in the set
* The kurtosis measures the degrees of peakedness of a distribution.
* It is also called the "excess" or "excess coefficient", and is
* a normalized form of the fourth central moment of a distribution.
* A normal distributions has kurtosis = 0
* A narrow and peaked (leptokurtic) distribution has a
* kurtosis > 0
* A flat and wide (platykurtic) distribution has a kurtosis < 0
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the kurtosis value on success, a PEAR_Error object otherwise
* @see __sumdiff()
* @see count()
* @see stDev()
* @see calc()
*/
function kurtosis() {/*{{{*/
if (!array_key_exists('kurtosis', $this->_calculatedValues)) {
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
$stDev = $this->stDev();
if (PEAR::isError($stDev)) {
return $stDev;
}
$sumdiff4 = $this->__sumdiff(4);
if (PEAR::isError($sumdiff4)) {
return $sumdiff4;
}
$this->_calculatedValues['kurtosis'] = ($sumdiff4 / ($count * pow($stDev, 4))) - 3;
}
return $this->_calculatedValues['kurtosis'];
}/*}}}*/
/**
* Calculates the median of a data set.
* The median is the value such that half of the points are below it
* in a sorted data set.
* If the number of values is odd, it is the middle item.
* If the number of values is even, is the average of the two middle items.
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the median value on success, a PEAR_Error object otherwise
* @see count()
* @see calc()
*/
function median() {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if (!array_key_exists('median', $this->_calculatedValues)) {
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
$arr =& $this->_dataExpanded;
} else {
$arr =& $this->_data;
}
$n = $this->count();
if (PEAR::isError($n)) {
return $n;
}
$h = intval($n / 2);
if ($n % 2 == 0) {
$median = ($arr[$h] + $arr[$h - 1]) / 2;
} else {
$median = $arr[$h + 1];
}
$this->_calculatedValues['median'] = $median;
}
return $this->_calculatedValues['median'];
}/*}}}*/
/**
* Calculates the mode of a data set.
* The mode is the value with the highest frequency in the data set.
* There can be more than one mode.
* Handles cummulative data sets correctly
*
* @access public
* @return mixed an array of mode value on success, a PEAR_Error object otherwise
* @see frequency()
* @see calc()
*/
function mode() {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if (!array_key_exists('mode', $this->_calculatedValues)) {
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
$arr = $this->_data;
} else {
$arr = $this->frequency();
}
arsort($arr);
$mcount = 1;
foreach ($arr as $val=>$freq) {
if ($mcount == 1) {
$mode = array($val);
$mfreq = $freq;
++$mcount;
continue;
}
if ($mfreq == $freq)
$mode[] = $val;
if ($mfreq > $freq)
break;
}
$this->_calculatedValues['mode'] = $mode;
}
return $this->_calculatedValues['mode'];
}/*}}}*/
/**
* Calculates the midrange of a data set.
* The midrange is the average of the minimum and maximum of the data set.
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the midrange value on success, a PEAR_Error object otherwise
* @see min()
* @see max()
* @see calc()
*/
function midrange() {/*{{{*/
if (!array_key_exists('midrange', $this->_calculatedValues)) {
$min = $this->min();
if (PEAR::isError($min)) {
return $min;
}
$max = $this->max();
if (PEAR::isError($max)) {
return $max;
}
$this->_calculatedValues['midrange'] = (($max + $min) / 2);
}
return $this->_calculatedValues['midrange'];
}/*}}}*/
/**
* Calculates the geometrical mean of the data points in the set
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the geometrical mean value on success, a PEAR_Error object otherwise
* @see calc()
* @see product()
* @see count()
*/
function geometricMean() {/*{{{*/
if (!array_key_exists('geometricMean', $this->_calculatedValues)) {
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
$prod = $this->product();
if (PEAR::isError($prod)) {
return $prod;
}
if ($prod == 0.0) {
return 0.0;
}
if ($prod < 0) {
return PEAR::raiseError('The product of the data set is negative, geometric mean undefined.');
}
$this->_calculatedValues['geometricMean'] = pow($prod , 1 / $count);
}
return $this->_calculatedValues['geometricMean'];
}/*}}}*/
/**
* Calculates the harmonic mean of the data points in the set
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the harmonic mean value on success, a PEAR_Error object otherwise
* @see calc()
* @see count()
*/
function harmonicMean() {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if (!array_key_exists('harmonicMean', $this->_calculatedValues)) {
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
$invsum = 0.0;
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
foreach($this->_data as $val=>$freq) {
if ($val == 0) {
return PEAR::raiseError('cannot calculate a '.
'harmonic mean with data values of zero.');
}
$invsum += $freq / $val;
}
} else {
foreach($this->_data as $val) {
if ($val == 0) {
return PEAR::raiseError('cannot calculate a '.
'harmonic mean with data values of zero.');
}
$invsum += 1 / $val;
}
}
$this->_calculatedValues['harmonicMean'] = $count / $invsum;
}
return $this->_calculatedValues['harmonicMean'];
}/*}}}*/
/**
* Calculates the nth central moment (m{n}) of a data set.
*
* The definition of a sample central moment is:
*
* m{n} = 1/N * SUM { (xi - avg)^n }
*
* where: N = sample size, avg = sample mean.
*
* @access public
* @param integer $n moment to calculate
* @return mixed the numeric value of the moment on success, PEAR_Error otherwise
*/
function sampleCentralMoment($n) {/*{{{*/
if (!is_int($n) || $n < 1) {
return PEAR::isError('moment must be a positive integer >= 1.');
}
if ($n == 1) {
return 0;
}
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
if ($count == 0) {
return PEAR::raiseError("Cannot calculate {$n}th sample moment, ".
'there are zero data entries');
}
$sum = $this->__sumdiff($n);
if (PEAR::isError($sum)) {
return $sum;
}
return ($sum / $count);
}/*}}}*/
/**
* Calculates the nth raw moment (m{n}) of a data set.
*
* The definition of a sample central moment is:
*
* m{n} = 1/N * SUM { xi^n }
*
* where: N = sample size, avg = sample mean.
*
* @access public
* @param integer $n moment to calculate
* @return mixed the numeric value of the moment on success, PEAR_Error otherwise
*/
function sampleRawMoment($n) {/*{{{*/
if (!is_int($n) || $n < 1) {
return PEAR::isError('moment must be a positive integer >= 1.');
}
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
if ($count == 0) {
return PEAR::raiseError("Cannot calculate {$n}th raw moment, ".
'there are zero data entries.');
}
$sum = $this->sumN($n);
if (PEAR::isError($sum)) {
return $sum;
}
return ($sum / $count);
}/*}}}*/
/**
* Calculates the coefficient of variation of a data set.
* The coefficient of variation measures the spread of a set of data
* as a proportion of its mean. It is often expressed as a percentage.
* Handles cummulative data sets correctly
*
* @access public
* @return mixed the coefficient of variation on success, a PEAR_Error object otherwise
* @see stDev()
* @see mean()
* @see calc()
*/
function coeffOfVariation() {/*{{{*/
if (!array_key_exists('coeffOfVariation', $this->_calculatedValues)) {
$mean = $this->mean();
if (PEAR::isError($mean)) {
return $mean;
}
if ($mean == 0.0) {
return PEAR::raiseError('cannot calculate the coefficient '.
'of variation, mean of sample is zero');
}
$stDev = $this->stDev();
if (PEAR::isError($stDev)) {
return $stDev;
}
$this->_calculatedValues['coeffOfVariation'] = $stDev / $mean;
}
return $this->_calculatedValues['coeffOfVariation'];
}/*}}}*/
/**
* Calculates the standard error of the mean.
* It is the standard deviation of the sampling distribution of
* the mean. The formula is:
*
* S.E. Mean = SD / (N)^(1/2)
*
* This formula does not assume a normal distribution, and shows
* that the size of the standard error of the mean is inversely
* proportional to the square root of the sample size.
*
* @access public
* @return mixed the standard error of the mean on success, a PEAR_Error object otherwise
* @see stDev()
* @see count()
* @see calc()
*/
function stdErrorOfMean() {/*{{{*/
if (!array_key_exists('stdErrorOfMean', $this->_calculatedValues)) {
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
$stDev = $this->stDev();
if (PEAR::isError($stDev)) {
return $stDev;
}
$this->_calculatedValues['stdErrorOfMean'] = $stDev / sqrt($count);
}
return $this->_calculatedValues['stdErrorOfMean'];
}/*}}}*/
/**
* Calculates the value frequency table of a data set.
* Handles cummulative data sets correctly
*
* @access public
* @return mixed an associative array of value=>frequency items on success, a PEAR_Error object otherwise
* @see min()
* @see max()
* @see calc()
*/
function frequency() {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if (!array_key_exists('frequency', $this->_calculatedValues)) {
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
$freq = $this->_data;
} else {
$freq = array();
foreach ($this->_data as $val) {
$freq["$val"]++;
}
ksort($freq);
}
$this->_calculatedValues['frequency'] = $freq;
}
return $this->_calculatedValues['frequency'];
}/*}}}*/
/**
* The quartiles are defined as the values that divide a sorted
* data set into four equal-sized subsets, and correspond to the
* 25th, 50th, and 75th percentiles.
*
* @access public
* @return mixed an associative array of quartiles on success, a PEAR_Error otherwise
* @see percentile()
*/
function quartiles() {/*{{{*/
if (!array_key_exists('quartiles', $this->_calculatedValues)) {
$q1 = $this->percentile(25);
if (PEAR::isError($q1)) {
return $q1;
}
$q2 = $this->percentile(50);
if (PEAR::isError($q2)) {
return $q2;
}
$q3 = $this->percentile(75);
if (PEAR::isError($q3)) {
return $q3;
}
$this->_calculatedValues['quartiles'] = array (
'25' => $q1,
'50' => $q2,
'75' => $q3
);
}
return $this->_calculatedValues['quartiles'];
}/*}}}*/
/**
* The interquartile mean is defined as the mean of the values left
* after discarding the lower 25% and top 25% ranked values, i.e.:
*
* interquart mean = mean(<P(25),P(75)>)
*
* where: P = percentile
*
* @todo need to double check the equation
* @access public
* @return mixed a numeric value on success, a PEAR_Error otherwise
* @see quartiles()
*/
function interquartileMean() {/*{{{*/
if (!array_key_exists('interquartileMean', $this->_calculatedValues)) {
$quart = $this->quartiles();
if (PEAR::isError($quart)) {
return $quart;
}
$q3 = $quart['75'];
$q1 = $quart['25'];
$sum = 0;
$n = 0;
foreach ($this->getData(true) as $val) {
if ($val >= $q1 && $val <= $q3) {
$sum += $val;
++$n;
}
}
if ($n == 0) {
return PEAR::raiseError('error calculating interquartile mean, '.
'empty interquartile range of values.');
}
$this->_calculatedValues['interquartileMean'] = $sum / $n;
}
return $this->_calculatedValues['interquartileMean'];
}/*}}}*/
/**
* The interquartile range is the distance between the 75th and 25th
* percentiles. Basically the range of the middle 50% of the data set,
* and thus is not affected by outliers or extreme values.
*
* interquart range = P(75) - P(25)
*
* where: P = percentile
*
* @access public
* @return mixed a numeric value on success, a PEAR_Error otherwise
* @see quartiles()
*/
function interquartileRange() {/*{{{*/
if (!array_key_exists('interquartileRange', $this->_calculatedValues)) {
$quart = $this->quartiles();
if (PEAR::isError($quart)) {
return $quart;
}
$q3 = $quart['75'];
$q1 = $quart['25'];
$this->_calculatedValues['interquartileRange'] = $q3 - $q1;
}
return $this->_calculatedValues['interquartileRange'];
}/*}}}*/
/**
* The quartile deviation is half of the interquartile range value
*
* quart dev = (P(75) - P(25)) / 2
*
* where: P = percentile
*
* @access public
* @return mixed a numeric value on success, a PEAR_Error otherwise
* @see quartiles()
* @see interquartileRange()
*/
function quartileDeviation() {/*{{{*/
if (!array_key_exists('quartileDeviation', $this->_calculatedValues)) {
$iqr = $this->interquartileRange();
if (PEAR::isError($iqr)) {
return $iqr;
}
$this->_calculatedValues['quartileDeviation'] = $iqr / 2;
}
return $this->_calculatedValues['quartileDeviation'];
}/*}}}*/
/**
* The quartile variation coefficient is defines as follows:
*
* quart var coeff = 100 * (P(75) - P(25)) / (P(75) + P(25))
*
* where: P = percentile
*
* @todo need to double check the equation
* @access public
* @return mixed a numeric value on success, a PEAR_Error otherwise
* @see quartiles()
*/
function quartileVariationCoefficient() {/*{{{*/
if (!array_key_exists('quartileVariationCoefficient', $this->_calculatedValues)) {
$quart = $this->quartiles();
if (PEAR::isError($quart)) {
return $quart;
}
$q3 = $quart['75'];
$q1 = $quart['25'];
$d = $q3 - $q1;
$s = $q3 + $q1;
$this->_calculatedValues['quartileVariationCoefficient'] = 100 * $d / $s;
}
return $this->_calculatedValues['quartileVariationCoefficient'];
}/*}}}*/
/**
* The quartile skewness coefficient (also known as Bowley Skewness),
* is defined as follows:
*
* quart skewness coeff = (P(25) - 2*P(50) + P(75)) / (P(75) - P(25))
*
* where: P = percentile
*
* @todo need to double check the equation
* @access public
* @return mixed a numeric value on success, a PEAR_Error otherwise
* @see quartiles()
*/
function quartileSkewnessCoefficient() {/*{{{*/
if (!array_key_exists('quartileSkewnessCoefficient', $this->_calculatedValues)) {
$quart = $this->quartiles();
if (PEAR::isError($quart)) {
return $quart;
}
$q3 = $quart['75'];
$q2 = $quart['50'];
$q1 = $quart['25'];
$d = $q3 - 2*$q2 + $q1;
$s = $q3 - $q1;
$this->_calculatedValues['quartileSkewnessCoefficient'] = $d / $s;
}
return $this->_calculatedValues['quartileSkewnessCoefficient'];
}/*}}}*/
/**
* The pth percentile is the value such that p% of the a sorted data set
* is smaller than it, and (100 - p)% of the data is larger.
*
* A quick algorithm to pick the appropriate value from a sorted data
* set is as follows:
*
* - Count the number of values: n
* - Calculate the position of the value in the data list: i = p * (n + 1)
* - if i is an integer, return the data at that position
* - if i < 1, return the minimum of the data set
* - if i > n, return the maximum of the data set
* - otherwise, average the entries at adjacent positions to i
*
* The median is the 50th percentile value.
*
* @todo need to double check generality of the algorithm
*
* @access public
* @param numeric $p the percentile to estimate, e.g. 25 for 25th percentile
* @return mixed a numeric value on success, a PEAR_Error otherwise
* @see quartiles()
* @see median()
*/
function percentile($p) {/*{{{*/
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
$data =& $this->_dataExpanded;
} else {
$data =& $this->_data;
}
$obsidx = $p * ($count + 1) / 100;
if (intval($obsidx) == $obsidx) {
return $data[($obsidx - 1)];
} elseif ($obsidx < 1) {
return $data[0];
} elseif ($obsidx > $count) {
return $data[($count - 1)];
} else {
$left = floor($obsidx - 1);
$right = ceil($obsidx - 1);
return ($data[$left] + $data[$right]) / 2;
}
}/*}}}*/
// private methods
/**
* Utility function to calculate: SUM { (xi - mean)^n }
*
* @access private
* @param numeric $power the exponent
* @param optional double $mean the data set mean value
* @return mixed the sum on success, a PEAR_Error object otherwise
*
* @see stDev()
* @see variaceWithMean();
* @see skewness();
* @see kurtosis();
*/
function __sumdiff($power, $mean=null) {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if (is_null($mean)) {
$mean = $this->mean();
if (PEAR::isError($mean)) {
return $mean;
}
}
$sdiff = 0;
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
foreach ($this->_data as $val=>$freq) {
$sdiff += $freq * pow((double)($val - $mean), (double)$power);
}
} else {
foreach ($this->_data as $val)
$sdiff += pow((double)($val - $mean), (double)$power);
}
return $sdiff;
}/*}}}*/
/**
* Utility function to calculate the variance with or without
* a fixed mean
*
* @access private
* @param $mean the fixed mean to use, null as default
* @return mixed a numeric value on success, a PEAR_Error otherwise
* @see variance()
* @see varianceWithMean()
*/
function __calcVariance($mean = null) {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
$sumdiff2 = $this->__sumdiff(2, $mean);
if (PEAR::isError($sumdiff2)) {
return $sumdiff2;
}
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
if ($count == 1) {
return PEAR::raiseError('cannot calculate variance of a singe data point');
}
return ($sumdiff2 / ($count - 1));
}/*}}}*/
/**
* Utility function to calculate the absolute deviation with or without
* a fixed mean
*
* @access private
* @param $mean the fixed mean to use, null as default
* @return mixed a numeric value on success, a PEAR_Error otherwise
* @see absDev()
* @see absDevWithMean()
*/
function __calcAbsoluteDeviation($mean = null) {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
$count = $this->count();
if (PEAR::isError($count)) {
return $count;
}
$sumabsdev = $this->__sumabsdev($mean);
if (PEAR::isError($sumabsdev)) {
return $sumabsdev;
}
return $sumabsdev / $count;
}/*}}}*/
/**
* Utility function to calculate: SUM { | xi - mean | }
*
* @access private
* @param optional double $mean the mean value for the set or population
* @return mixed the sum on success, a PEAR_Error object otherwise
*
* @see absDev()
* @see absDevWithMean()
*/
function __sumabsdev($mean=null) {/*{{{*/
if ($this->_data == null) {
return PEAR::raiseError('data has not been set');
}
if (is_null($mean)) {
$mean = $this->mean();
}
$sdev = 0;
if ($this->_dataOption == STATS_DATA_CUMMULATIVE) {
foreach ($this->_data as $val=>$freq) {
$sdev += $freq * abs($val - $mean);
}
} else {
foreach ($this->_data as $val) {
$sdev += abs($val - $mean);
}
}
return $sdev;
}/*}}}*/
/**
* Utility function to format a PEAR_Error to be used by calc(),
* calcBasic() and calcFull()
*
* @access private
* @param mixed $v value to be formatted
* @param boolean $returnErrorObject whether the raw PEAR_Error (when true, default),
* or only the error message will be returned (when false)
* @return mixed if the value is a PEAR_Error object, and $useErrorObject
* is false, then a string with the error message will be returned,
* otherwise the value will not be modified and returned as passed.
*/
function __format($v, $useErrorObject=true) {/*{{{*/
if (PEAR::isError($v) && $useErrorObject == false) {
return $v->getMessage();
} else {
return $v;
}
}/*}}}*/
/**
* Utility function to validate the data and modify it
* according to the current null handling option
*
* @access private
* @return mixed true on success, a PEAR_Error object otherwise
*
* @see setData()
*/
function _validate() {/*{{{*/
$flag = ($this->_dataOption == STATS_DATA_CUMMULATIVE);
foreach ($this->_data as $key=>$value) {
$d = ($flag) ? $key : $value;
$v = ($flag) ? $value : $key;
if (!is_numeric($d)) {
switch ($this->_nullOption) {
case STATS_IGNORE_NULL :
unset($this->_data["$key"]);
break;
case STATS_USE_NULL_AS_ZERO:
if ($flag) {
unset($this->_data["$key"]);
$this->_data[0] += $v;
} else {
$this->_data[$key] = 0;
}
break;
case STATS_REJECT_NULL :
default:
return PEAR::raiseError('data rejected, contains NULL values');
break;
}
}
}
if ($flag) {
ksort($this->_data);
$this->_dataExpanded = array();
foreach ($this->_data as $val=>$freq) {
$this->_dataExpanded = array_pad($this->_dataExpanded, count($this->_dataExpanded) + $freq, $val);
}
sort($this->_dataExpanded);
} else {
sort($this->_data);
}
return true;
}/*}}}*/
}/*}}}*/
// vim: ts=4:sw=4:et:
// vim6: fdl=1: fdm=marker:
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/examples/Stats.php | PHP | asf20 | 55,778 |
<?php
include "../Matrix.php";
/**
* Tiling of matrix X in [rowWise by colWise] dimension. Tiling
* creates a larger matrix than the original data X. Example, if
* X is to be tiled in a [3 x 4] manner, then:
*
* / \
* | X X X X |
* C = | X X X X |
* | X X X X |
* \ /
*
* @param X Matrix
* @param rowWise int
* @param colWise int
* @return Matrix
*/
function tile(&$X, $rowWise, $colWise){
$xArray = $X->getArray();
print_r($xArray);
$countRow = 0;
$countColumn = 0;
$m = $X->getRowDimension();
$n = $X->getColumnDimension();
if( $rowWise<1 || $colWise<1 ){
die("tile : Array index is out-of-bound.");
}
$newRowDim = $m*$rowWise;
$newColDim = $n*$colWise;
$result = array();
for($i=0 ; $i<$newRowDim; ++$i) {
$holder = array();
for($j=0 ; $j<$newColDim ; ++$j) {
$holder[$j] = $xArray[$countRow][$countColumn++];
// reset the column-index to zero to avoid reference to out-of-bound index in xArray[][]
if($countColumn == $n) { $countColumn = 0; }
} // end for
++$countRow;
// reset the row-index to zero to avoid reference to out-of-bound index in xArray[][]
if($countRow == $m) { $countRow = 0; }
$result[$i] = $holder;
} // end for
return new Matrix($result);
}
$X =array(1,2,3,4,5,6,7,8,9);
$nRow = 3;
$nCol = 3;
$tiled_matrix = tile(new Matrix($X), $nRow, $nCol);
echo "<pre>";
print_r($tiled_matrix);
echo "</pre>";
?>
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/examples/tile.php | PHP | asf20 | 1,476 |
<?php
// Levenberg-Marquardt in PHP
// http://www.idiom.com/~zilla/Computer/Javanumeric/LM.java
class LevenbergMarquardt {
/**
* Calculate the current sum-squared-error
*
* Chi-squared is the distribution of squared Gaussian errors,
* thus the name.
*
* @param double[][] $x
* @param double[] $a
* @param double[] $y,
* @param double[] $s,
* @param object $f
*/
function chiSquared($x, $a, $y, $s, $f) {
$npts = count($y);
$sum = 0.0;
for ($i = 0; $i < $npts; ++$i) {
$d = $y[$i] - $f->val($x[$i], $a);
$d = $d / $s[$i];
$sum = $sum + ($d*$d);
}
return $sum;
} // function chiSquared()
/**
* Minimize E = sum {(y[k] - f(x[k],a)) / s[k]}^2
* The individual errors are optionally scaled by s[k].
* Note that LMfunc implements the value and gradient of f(x,a),
* NOT the value and gradient of E with respect to a!
*
* @param x array of domain points, each may be multidimensional
* @param y corresponding array of values
* @param a the parameters/state of the model
* @param vary false to indicate the corresponding a[k] is to be held fixed
* @param s2 sigma^2 for point i
* @param lambda blend between steepest descent (lambda high) and
* jump to bottom of quadratic (lambda zero).
* Start with 0.001.
* @param termepsilon termination accuracy (0.01)
* @param maxiter stop and return after this many iterations if not done
* @param verbose set to zero (no prints), 1, 2
*
* @return the new lambda for future iterations.
* Can use this and maxiter to interleave the LM descent with some other
* task, setting maxiter to something small.
*/
function solve($x, $a, $y, $s, $vary, $f, $lambda, $termepsilon, $maxiter, $verbose) {
$npts = count($y);
$nparm = count($a);
if ($verbose > 0) {
print("solve x[".count($x)."][".count($x[0])."]");
print(" a[".count($a)."]");
println(" y[".count(length)."]");
}
$e0 = $this->chiSquared($x, $a, $y, $s, $f);
//double lambda = 0.001;
$done = false;
// g = gradient, H = hessian, d = step to minimum
// H d = -g, solve for d
$H = array();
$g = array();
//double[] d = new double[nparm];
$oos2 = array();
for($i = 0; $i < $npts; ++$i) {
$oos2[$i] = 1./($s[$i]*$s[$i]);
}
$iter = 0;
$term = 0; // termination count test
do {
++$iter;
// hessian approximation
for( $r = 0; $r < $nparm; ++$r) {
for( $c = 0; $c < $nparm; ++$c) {
for( $i = 0; $i < $npts; ++$i) {
if ($i == 0) $H[$r][$c] = 0.;
$xi = $x[$i];
$H[$r][$c] += ($oos2[$i] * $f->grad($xi, $a, $r) * $f->grad($xi, $a, $c));
} //npts
} //c
} //r
// boost diagonal towards gradient descent
for( $r = 0; $r < $nparm; ++$r)
$H[$r][$r] *= (1. + $lambda);
// gradient
for( $r = 0; $r < $nparm; ++$r) {
for( $i = 0; $i < $npts; ++$i) {
if ($i == 0) $g[$r] = 0.;
$xi = $x[$i];
$g[$r] += ($oos2[$i] * ($y[$i]-$f->val($xi,$a)) * $f->grad($xi, $a, $r));
}
} //npts
// scale (for consistency with NR, not necessary)
if ($false) {
for( $r = 0; $r < $nparm; ++$r) {
$g[$r] = -0.5 * $g[$r];
for( $c = 0; $c < $nparm; ++$c) {
$H[$r][$c] *= 0.5;
}
}
}
// solve H d = -g, evaluate error at new location
//double[] d = DoubleMatrix.solve(H, g);
// double[] d = (new Matrix(H)).lu().solve(new Matrix(g, nparm)).getRowPackedCopy();
//double[] na = DoubleVector.add(a, d);
// double[] na = (new Matrix(a, nparm)).plus(new Matrix(d, nparm)).getRowPackedCopy();
// double e1 = chiSquared(x, na, y, s, f);
// if (verbose > 0) {
// System.out.println("\n\niteration "+iter+" lambda = "+lambda);
// System.out.print("a = ");
// (new Matrix(a, nparm)).print(10, 2);
// if (verbose > 1) {
// System.out.print("H = ");
// (new Matrix(H)).print(10, 2);
// System.out.print("g = ");
// (new Matrix(g, nparm)).print(10, 2);
// System.out.print("d = ");
// (new Matrix(d, nparm)).print(10, 2);
// }
// System.out.print("e0 = " + e0 + ": ");
// System.out.print("moved from ");
// (new Matrix(a, nparm)).print(10, 2);
// System.out.print("e1 = " + e1 + ": ");
// if (e1 < e0) {
// System.out.print("to ");
// (new Matrix(na, nparm)).print(10, 2);
// } else {
// System.out.println("move rejected");
// }
// }
// termination test (slightly different than NR)
// if (Math.abs(e1-e0) > termepsilon) {
// term = 0;
// } else {
// term++;
// if (term == 4) {
// System.out.println("terminating after " + iter + " iterations");
// done = true;
// }
// }
// if (iter >= maxiter) done = true;
// in the C++ version, found that changing this to e1 >= e0
// was not a good idea. See comment there.
//
// if (e1 > e0 || Double.isNaN(e1)) { // new location worse than before
// lambda *= 10.;
// } else { // new location better, accept new parameters
// lambda *= 0.1;
// e0 = e1;
// // simply assigning a = na will not get results copied back to caller
// for( int i = 0; i < nparm; i++ ) {
// if (vary[i]) a[i] = na[i];
// }
// }
} while(!$done);
return $lambda;
} // function solve()
} // class LevenbergMarquardt
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/examples/LevenbergMarquardt.php | PHP | asf20 | 5,216 |
<?php
/**
* @package JAMA
*
* For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n
* orthogonal matrix Q and an n-by-n upper triangular matrix R so that
* A = Q*R.
*
* The QR decompostion always exists, even if the matrix does not have
* full rank, so the constructor will never fail. The primary use of the
* QR decomposition is in the least squares solution of nonsquare systems
* of simultaneous linear equations. This will fail if isFullRank()
* returns false.
*
* @author Paul Meagher
* @license PHP v3.0
* @version 1.1
*/
class PHPExcel_Shared_JAMA_QRDecomposition {
const MatrixRankException = "Can only perform operation on full-rank matrix.";
/**
* Array for internal storage of decomposition.
* @var array
*/
private $QR = array();
/**
* Row dimension.
* @var integer
*/
private $m;
/**
* Column dimension.
* @var integer
*/
private $n;
/**
* Array for internal storage of diagonal of R.
* @var array
*/
private $Rdiag = array();
/**
* QR Decomposition computed by Householder reflections.
*
* @param matrix $A Rectangular matrix
* @return Structure to access R and the Householder vectors and compute Q.
*/
public function __construct($A) {
if($A instanceof PHPExcel_Shared_JAMA_Matrix) {
// Initialize.
$this->QR = $A->getArrayCopy();
$this->m = $A->getRowDimension();
$this->n = $A->getColumnDimension();
// Main loop.
for ($k = 0; $k < $this->n; ++$k) {
// Compute 2-norm of k-th column without under/overflow.
$nrm = 0.0;
for ($i = $k; $i < $this->m; ++$i) {
$nrm = hypo($nrm, $this->QR[$i][$k]);
}
if ($nrm != 0.0) {
// Form k-th Householder vector.
if ($this->QR[$k][$k] < 0) {
$nrm = -$nrm;
}
for ($i = $k; $i < $this->m; ++$i) {
$this->QR[$i][$k] /= $nrm;
}
$this->QR[$k][$k] += 1.0;
// Apply transformation to remaining columns.
for ($j = $k+1; $j < $this->n; ++$j) {
$s = 0.0;
for ($i = $k; $i < $this->m; ++$i) {
$s += $this->QR[$i][$k] * $this->QR[$i][$j];
}
$s = -$s/$this->QR[$k][$k];
for ($i = $k; $i < $this->m; ++$i) {
$this->QR[$i][$j] += $s * $this->QR[$i][$k];
}
}
}
$this->Rdiag[$k] = -$nrm;
}
} else {
throw new Exception(PHPExcel_Shared_JAMA_Matrix::ArgumentTypeException);
}
} // function __construct()
/**
* Is the matrix full rank?
*
* @return boolean true if R, and hence A, has full rank, else false.
*/
public function isFullRank() {
for ($j = 0; $j < $this->n; ++$j) {
if ($this->Rdiag[$j] == 0) {
return false;
}
}
return true;
} // function isFullRank()
/**
* Return the Householder vectors
*
* @return Matrix Lower trapezoidal matrix whose columns define the reflections
*/
public function getH() {
for ($i = 0; $i < $this->m; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
if ($i >= $j) {
$H[$i][$j] = $this->QR[$i][$j];
} else {
$H[$i][$j] = 0.0;
}
}
}
return new PHPExcel_Shared_JAMA_Matrix($H);
} // function getH()
/**
* Return the upper triangular factor
*
* @return Matrix upper triangular factor
*/
public function getR() {
for ($i = 0; $i < $this->n; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
if ($i < $j) {
$R[$i][$j] = $this->QR[$i][$j];
} elseif ($i == $j) {
$R[$i][$j] = $this->Rdiag[$i];
} else {
$R[$i][$j] = 0.0;
}
}
}
return new PHPExcel_Shared_JAMA_Matrix($R);
} // function getR()
/**
* Generate and return the (economy-sized) orthogonal factor
*
* @return Matrix orthogonal factor
*/
public function getQ() {
for ($k = $this->n-1; $k >= 0; --$k) {
for ($i = 0; $i < $this->m; ++$i) {
$Q[$i][$k] = 0.0;
}
$Q[$k][$k] = 1.0;
for ($j = $k; $j < $this->n; ++$j) {
if ($this->QR[$k][$k] != 0) {
$s = 0.0;
for ($i = $k; $i < $this->m; ++$i) {
$s += $this->QR[$i][$k] * $Q[$i][$j];
}
$s = -$s/$this->QR[$k][$k];
for ($i = $k; $i < $this->m; ++$i) {
$Q[$i][$j] += $s * $this->QR[$i][$k];
}
}
}
}
/*
for($i = 0; $i < count($Q); ++$i) {
for($j = 0; $j < count($Q); ++$j) {
if(! isset($Q[$i][$j]) ) {
$Q[$i][$j] = 0;
}
}
}
*/
return new PHPExcel_Shared_JAMA_Matrix($Q);
} // function getQ()
/**
* Least squares solution of A*X = B
*
* @param Matrix $B A Matrix with as many rows as A and any number of columns.
* @return Matrix Matrix that minimizes the two norm of Q*R*X-B.
*/
public function solve($B) {
if ($B->getRowDimension() == $this->m) {
if ($this->isFullRank()) {
// Copy right hand side
$nx = $B->getColumnDimension();
$X = $B->getArrayCopy();
// Compute Y = transpose(Q)*B
for ($k = 0; $k < $this->n; ++$k) {
for ($j = 0; $j < $nx; ++$j) {
$s = 0.0;
for ($i = $k; $i < $this->m; ++$i) {
$s += $this->QR[$i][$k] * $X[$i][$j];
}
$s = -$s/$this->QR[$k][$k];
for ($i = $k; $i < $this->m; ++$i) {
$X[$i][$j] += $s * $this->QR[$i][$k];
}
}
}
// Solve R*X = Y;
for ($k = $this->n-1; $k >= 0; --$k) {
for ($j = 0; $j < $nx; ++$j) {
$X[$k][$j] /= $this->Rdiag[$k];
}
for ($i = 0; $i < $k; ++$i) {
for ($j = 0; $j < $nx; ++$j) {
$X[$i][$j] -= $X[$k][$j]* $this->QR[$i][$k];
}
}
}
$X = new PHPExcel_Shared_JAMA_Matrix($X);
return ($X->getMatrix(0, $this->n-1, 0, $nx));
} else {
throw new Exception(self::MatrixRankException);
}
} else {
throw new Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException);
}
} // function solve()
} // PHPExcel_Shared_JAMA_class QRDecomposition
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/QRDecomposition.php | PHP | asf20 | 5,732 |
<?php
/**
* @package JAMA
*
* For an m-by-n matrix A with m >= n, the singular value decomposition is
* an m-by-n orthogonal matrix U, an n-by-n diagonal matrix S, and
* an n-by-n orthogonal matrix V so that A = U*S*V'.
*
* The singular values, sigma[$k] = S[$k][$k], are ordered so that
* sigma[0] >= sigma[1] >= ... >= sigma[n-1].
*
* The singular value decompostion always exists, so the constructor will
* never fail. The matrix condition number and the effective numerical
* rank can be computed from this decomposition.
*
* @author Paul Meagher
* @license PHP v3.0
* @version 1.1
*/
class SingularValueDecomposition {
/**
* Internal storage of U.
* @var array
*/
private $U = array();
/**
* Internal storage of V.
* @var array
*/
private $V = array();
/**
* Internal storage of singular values.
* @var array
*/
private $s = array();
/**
* Row dimension.
* @var int
*/
private $m;
/**
* Column dimension.
* @var int
*/
private $n;
/**
* Construct the singular value decomposition
*
* Derived from LINPACK code.
*
* @param $A Rectangular matrix
* @return Structure to access U, S and V.
*/
public function __construct($Arg) {
// Initialize.
$A = $Arg->getArrayCopy();
$this->m = $Arg->getRowDimension();
$this->n = $Arg->getColumnDimension();
$nu = min($this->m, $this->n);
$e = array();
$work = array();
$wantu = true;
$wantv = true;
$nct = min($this->m - 1, $this->n);
$nrt = max(0, min($this->n - 2, $this->m));
// Reduce A to bidiagonal form, storing the diagonal elements
// in s and the super-diagonal elements in e.
for ($k = 0; $k < max($nct,$nrt); ++$k) {
if ($k < $nct) {
// Compute the transformation for the k-th column and
// place the k-th diagonal in s[$k].
// Compute 2-norm of k-th column without under/overflow.
$this->s[$k] = 0;
for ($i = $k; $i < $this->m; ++$i) {
$this->s[$k] = hypo($this->s[$k], $A[$i][$k]);
}
if ($this->s[$k] != 0.0) {
if ($A[$k][$k] < 0.0) {
$this->s[$k] = -$this->s[$k];
}
for ($i = $k; $i < $this->m; ++$i) {
$A[$i][$k] /= $this->s[$k];
}
$A[$k][$k] += 1.0;
}
$this->s[$k] = -$this->s[$k];
}
for ($j = $k + 1; $j < $this->n; ++$j) {
if (($k < $nct) & ($this->s[$k] != 0.0)) {
// Apply the transformation.
$t = 0;
for ($i = $k; $i < $this->m; ++$i) {
$t += $A[$i][$k] * $A[$i][$j];
}
$t = -$t / $A[$k][$k];
for ($i = $k; $i < $this->m; ++$i) {
$A[$i][$j] += $t * $A[$i][$k];
}
// Place the k-th row of A into e for the
// subsequent calculation of the row transformation.
$e[$j] = $A[$k][$j];
}
}
if ($wantu AND ($k < $nct)) {
// Place the transformation in U for subsequent back
// multiplication.
for ($i = $k; $i < $this->m; ++$i) {
$this->U[$i][$k] = $A[$i][$k];
}
}
if ($k < $nrt) {
// Compute the k-th row transformation and place the
// k-th super-diagonal in e[$k].
// Compute 2-norm without under/overflow.
$e[$k] = 0;
for ($i = $k + 1; $i < $this->n; ++$i) {
$e[$k] = hypo($e[$k], $e[$i]);
}
if ($e[$k] != 0.0) {
if ($e[$k+1] < 0.0) {
$e[$k] = -$e[$k];
}
for ($i = $k + 1; $i < $this->n; ++$i) {
$e[$i] /= $e[$k];
}
$e[$k+1] += 1.0;
}
$e[$k] = -$e[$k];
if (($k+1 < $this->m) AND ($e[$k] != 0.0)) {
// Apply the transformation.
for ($i = $k+1; $i < $this->m; ++$i) {
$work[$i] = 0.0;
}
for ($j = $k+1; $j < $this->n; ++$j) {
for ($i = $k+1; $i < $this->m; ++$i) {
$work[$i] += $e[$j] * $A[$i][$j];
}
}
for ($j = $k + 1; $j < $this->n; ++$j) {
$t = -$e[$j] / $e[$k+1];
for ($i = $k + 1; $i < $this->m; ++$i) {
$A[$i][$j] += $t * $work[$i];
}
}
}
if ($wantv) {
// Place the transformation in V for subsequent
// back multiplication.
for ($i = $k + 1; $i < $this->n; ++$i) {
$this->V[$i][$k] = $e[$i];
}
}
}
}
// Set up the final bidiagonal matrix or order p.
$p = min($this->n, $this->m + 1);
if ($nct < $this->n) {
$this->s[$nct] = $A[$nct][$nct];
}
if ($this->m < $p) {
$this->s[$p-1] = 0.0;
}
if ($nrt + 1 < $p) {
$e[$nrt] = $A[$nrt][$p-1];
}
$e[$p-1] = 0.0;
// If required, generate U.
if ($wantu) {
for ($j = $nct; $j < $nu; ++$j) {
for ($i = 0; $i < $this->m; ++$i) {
$this->U[$i][$j] = 0.0;
}
$this->U[$j][$j] = 1.0;
}
for ($k = $nct - 1; $k >= 0; --$k) {
if ($this->s[$k] != 0.0) {
for ($j = $k + 1; $j < $nu; ++$j) {
$t = 0;
for ($i = $k; $i < $this->m; ++$i) {
$t += $this->U[$i][$k] * $this->U[$i][$j];
}
$t = -$t / $this->U[$k][$k];
for ($i = $k; $i < $this->m; ++$i) {
$this->U[$i][$j] += $t * $this->U[$i][$k];
}
}
for ($i = $k; $i < $this->m; ++$i ) {
$this->U[$i][$k] = -$this->U[$i][$k];
}
$this->U[$k][$k] = 1.0 + $this->U[$k][$k];
for ($i = 0; $i < $k - 1; ++$i) {
$this->U[$i][$k] = 0.0;
}
} else {
for ($i = 0; $i < $this->m; ++$i) {
$this->U[$i][$k] = 0.0;
}
$this->U[$k][$k] = 1.0;
}
}
}
// If required, generate V.
if ($wantv) {
for ($k = $this->n - 1; $k >= 0; --$k) {
if (($k < $nrt) AND ($e[$k] != 0.0)) {
for ($j = $k + 1; $j < $nu; ++$j) {
$t = 0;
for ($i = $k + 1; $i < $this->n; ++$i) {
$t += $this->V[$i][$k]* $this->V[$i][$j];
}
$t = -$t / $this->V[$k+1][$k];
for ($i = $k + 1; $i < $this->n; ++$i) {
$this->V[$i][$j] += $t * $this->V[$i][$k];
}
}
}
for ($i = 0; $i < $this->n; ++$i) {
$this->V[$i][$k] = 0.0;
}
$this->V[$k][$k] = 1.0;
}
}
// Main iteration loop for the singular values.
$pp = $p - 1;
$iter = 0;
$eps = pow(2.0, -52.0);
while ($p > 0) {
// Here is where a test for too many iterations would go.
// This section of the program inspects for negligible
// elements in the s and e arrays. On completion the
// variables kase and k are set as follows:
// kase = 1 if s(p) and e[k-1] are negligible and k<p
// kase = 2 if s(k) is negligible and k<p
// kase = 3 if e[k-1] is negligible, k<p, and
// s(k), ..., s(p) are not negligible (qr step).
// kase = 4 if e(p-1) is negligible (convergence).
for ($k = $p - 2; $k >= -1; --$k) {
if ($k == -1) {
break;
}
if (abs($e[$k]) <= $eps * (abs($this->s[$k]) + abs($this->s[$k+1]))) {
$e[$k] = 0.0;
break;
}
}
if ($k == $p - 2) {
$kase = 4;
} else {
for ($ks = $p - 1; $ks >= $k; --$ks) {
if ($ks == $k) {
break;
}
$t = ($ks != $p ? abs($e[$ks]) : 0.) + ($ks != $k + 1 ? abs($e[$ks-1]) : 0.);
if (abs($this->s[$ks]) <= $eps * $t) {
$this->s[$ks] = 0.0;
break;
}
}
if ($ks == $k) {
$kase = 3;
} else if ($ks == $p-1) {
$kase = 1;
} else {
$kase = 2;
$k = $ks;
}
}
++$k;
// Perform the task indicated by kase.
switch ($kase) {
// Deflate negligible s(p).
case 1:
$f = $e[$p-2];
$e[$p-2] = 0.0;
for ($j = $p - 2; $j >= $k; --$j) {
$t = hypo($this->s[$j],$f);
$cs = $this->s[$j] / $t;
$sn = $f / $t;
$this->s[$j] = $t;
if ($j != $k) {
$f = -$sn * $e[$j-1];
$e[$j-1] = $cs * $e[$j-1];
}
if ($wantv) {
for ($i = 0; $i < $this->n; ++$i) {
$t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$p-1];
$this->V[$i][$p-1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$p-1];
$this->V[$i][$j] = $t;
}
}
}
break;
// Split at negligible s(k).
case 2:
$f = $e[$k-1];
$e[$k-1] = 0.0;
for ($j = $k; $j < $p; ++$j) {
$t = hypo($this->s[$j], $f);
$cs = $this->s[$j] / $t;
$sn = $f / $t;
$this->s[$j] = $t;
$f = -$sn * $e[$j];
$e[$j] = $cs * $e[$j];
if ($wantu) {
for ($i = 0; $i < $this->m; ++$i) {
$t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$k-1];
$this->U[$i][$k-1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$k-1];
$this->U[$i][$j] = $t;
}
}
}
break;
// Perform one qr step.
case 3:
// Calculate the shift.
$scale = max(max(max(max(
abs($this->s[$p-1]),abs($this->s[$p-2])),abs($e[$p-2])),
abs($this->s[$k])), abs($e[$k]));
$sp = $this->s[$p-1] / $scale;
$spm1 = $this->s[$p-2] / $scale;
$epm1 = $e[$p-2] / $scale;
$sk = $this->s[$k] / $scale;
$ek = $e[$k] / $scale;
$b = (($spm1 + $sp) * ($spm1 - $sp) + $epm1 * $epm1) / 2.0;
$c = ($sp * $epm1) * ($sp * $epm1);
$shift = 0.0;
if (($b != 0.0) || ($c != 0.0)) {
$shift = sqrt($b * $b + $c);
if ($b < 0.0) {
$shift = -$shift;
}
$shift = $c / ($b + $shift);
}
$f = ($sk + $sp) * ($sk - $sp) + $shift;
$g = $sk * $ek;
// Chase zeros.
for ($j = $k; $j < $p-1; ++$j) {
$t = hypo($f,$g);
$cs = $f/$t;
$sn = $g/$t;
if ($j != $k) {
$e[$j-1] = $t;
}
$f = $cs * $this->s[$j] + $sn * $e[$j];
$e[$j] = $cs * $e[$j] - $sn * $this->s[$j];
$g = $sn * $this->s[$j+1];
$this->s[$j+1] = $cs * $this->s[$j+1];
if ($wantv) {
for ($i = 0; $i < $this->n; ++$i) {
$t = $cs * $this->V[$i][$j] + $sn * $this->V[$i][$j+1];
$this->V[$i][$j+1] = -$sn * $this->V[$i][$j] + $cs * $this->V[$i][$j+1];
$this->V[$i][$j] = $t;
}
}
$t = hypo($f,$g);
$cs = $f/$t;
$sn = $g/$t;
$this->s[$j] = $t;
$f = $cs * $e[$j] + $sn * $this->s[$j+1];
$this->s[$j+1] = -$sn * $e[$j] + $cs * $this->s[$j+1];
$g = $sn * $e[$j+1];
$e[$j+1] = $cs * $e[$j+1];
if ($wantu && ($j < $this->m - 1)) {
for ($i = 0; $i < $this->m; ++$i) {
$t = $cs * $this->U[$i][$j] + $sn * $this->U[$i][$j+1];
$this->U[$i][$j+1] = -$sn * $this->U[$i][$j] + $cs * $this->U[$i][$j+1];
$this->U[$i][$j] = $t;
}
}
}
$e[$p-2] = $f;
$iter = $iter + 1;
break;
// Convergence.
case 4:
// Make the singular values positive.
if ($this->s[$k] <= 0.0) {
$this->s[$k] = ($this->s[$k] < 0.0 ? -$this->s[$k] : 0.0);
if ($wantv) {
for ($i = 0; $i <= $pp; ++$i) {
$this->V[$i][$k] = -$this->V[$i][$k];
}
}
}
// Order the singular values.
while ($k < $pp) {
if ($this->s[$k] >= $this->s[$k+1]) {
break;
}
$t = $this->s[$k];
$this->s[$k] = $this->s[$k+1];
$this->s[$k+1] = $t;
if ($wantv AND ($k < $this->n - 1)) {
for ($i = 0; $i < $this->n; ++$i) {
$t = $this->V[$i][$k+1];
$this->V[$i][$k+1] = $this->V[$i][$k];
$this->V[$i][$k] = $t;
}
}
if ($wantu AND ($k < $this->m-1)) {
for ($i = 0; $i < $this->m; ++$i) {
$t = $this->U[$i][$k+1];
$this->U[$i][$k+1] = $this->U[$i][$k];
$this->U[$i][$k] = $t;
}
}
++$k;
}
$iter = 0;
--$p;
break;
} // end switch
} // end while
} // end constructor
/**
* Return the left singular vectors
*
* @access public
* @return U
*/
public function getU() {
return new Matrix($this->U, $this->m, min($this->m + 1, $this->n));
}
/**
* Return the right singular vectors
*
* @access public
* @return V
*/
public function getV() {
return new Matrix($this->V);
}
/**
* Return the one-dimensional array of singular values
*
* @access public
* @return diagonal of S.
*/
public function getSingularValues() {
return $this->s;
}
/**
* Return the diagonal matrix of singular values
*
* @access public
* @return S
*/
public function getS() {
for ($i = 0; $i < $this->n; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
$S[$i][$j] = 0.0;
}
$S[$i][$i] = $this->s[$i];
}
return new Matrix($S);
}
/**
* Two norm
*
* @access public
* @return max(S)
*/
public function norm2() {
return $this->s[0];
}
/**
* Two norm condition number
*
* @access public
* @return max(S)/min(S)
*/
public function cond() {
return $this->s[0] / $this->s[min($this->m, $this->n) - 1];
}
/**
* Effective numerical matrix rank
*
* @access public
* @return Number of nonnegligible singular values.
*/
public function rank() {
$eps = pow(2.0, -52.0);
$tol = max($this->m, $this->n) * $this->s[0] * $eps;
$r = 0;
for ($i = 0; $i < count($this->s); ++$i) {
if ($this->s[$i] > $tol) {
++$r;
}
}
return $r;
}
} // class SingularValueDecomposition
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/SingularValueDecomposition.php | PHP | asf20 | 13,005 |
<?php
/**
* @package JAMA
*
* For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n
* unit lower triangular matrix L, an n-by-n upper triangular matrix U,
* and a permutation vector piv of length m so that A(piv,:) = L*U.
* If m < n, then L is m-by-m and U is m-by-n.
*
* The LU decompostion with pivoting always exists, even if the matrix is
* singular, so the constructor will never fail. The primary use of the
* LU decomposition is in the solution of square systems of simultaneous
* linear equations. This will fail if isNonsingular() returns false.
*
* @author Paul Meagher
* @author Bartosz Matosiuk
* @author Michael Bommarito
* @version 1.1
* @license PHP v3.0
*/
class PHPExcel_Shared_JAMA_LUDecomposition {
const MatrixSingularException = "Can only perform operation on singular matrix.";
const MatrixSquareException = "Mismatched Row dimension";
/**
* Decomposition storage
* @var array
*/
private $LU = array();
/**
* Row dimension.
* @var int
*/
private $m;
/**
* Column dimension.
* @var int
*/
private $n;
/**
* Pivot sign.
* @var int
*/
private $pivsign;
/**
* Internal storage of pivot vector.
* @var array
*/
private $piv = array();
/**
* LU Decomposition constructor.
*
* @param $A Rectangular matrix
* @return Structure to access L, U and piv.
*/
public function __construct($A) {
if ($A instanceof PHPExcel_Shared_JAMA_Matrix) {
// Use a "left-looking", dot-product, Crout/Doolittle algorithm.
$this->LU = $A->getArray();
$this->m = $A->getRowDimension();
$this->n = $A->getColumnDimension();
for ($i = 0; $i < $this->m; ++$i) {
$this->piv[$i] = $i;
}
$this->pivsign = 1;
$LUrowi = $LUcolj = array();
// Outer loop.
for ($j = 0; $j < $this->n; ++$j) {
// Make a copy of the j-th column to localize references.
for ($i = 0; $i < $this->m; ++$i) {
$LUcolj[$i] = &$this->LU[$i][$j];
}
// Apply previous transformations.
for ($i = 0; $i < $this->m; ++$i) {
$LUrowi = $this->LU[$i];
// Most of the time is spent in the following dot product.
$kmax = min($i,$j);
$s = 0.0;
for ($k = 0; $k < $kmax; ++$k) {
$s += $LUrowi[$k] * $LUcolj[$k];
}
$LUrowi[$j] = $LUcolj[$i] -= $s;
}
// Find pivot and exchange if necessary.
$p = $j;
for ($i = $j+1; $i < $this->m; ++$i) {
if (abs($LUcolj[$i]) > abs($LUcolj[$p])) {
$p = $i;
}
}
if ($p != $j) {
for ($k = 0; $k < $this->n; ++$k) {
$t = $this->LU[$p][$k];
$this->LU[$p][$k] = $this->LU[$j][$k];
$this->LU[$j][$k] = $t;
}
$k = $this->piv[$p];
$this->piv[$p] = $this->piv[$j];
$this->piv[$j] = $k;
$this->pivsign = $this->pivsign * -1;
}
// Compute multipliers.
if (($j < $this->m) && ($this->LU[$j][$j] != 0.0)) {
for ($i = $j+1; $i < $this->m; ++$i) {
$this->LU[$i][$j] /= $this->LU[$j][$j];
}
}
}
} else {
throw new Exception(PHPExcel_Shared_JAMA_Matrix::ArgumentTypeException);
}
} // function __construct()
/**
* Get lower triangular factor.
*
* @return array Lower triangular factor
*/
public function getL() {
for ($i = 0; $i < $this->m; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
if ($i > $j) {
$L[$i][$j] = $this->LU[$i][$j];
} elseif ($i == $j) {
$L[$i][$j] = 1.0;
} else {
$L[$i][$j] = 0.0;
}
}
}
return new PHPExcel_Shared_JAMA_Matrix($L);
} // function getL()
/**
* Get upper triangular factor.
*
* @return array Upper triangular factor
*/
public function getU() {
for ($i = 0; $i < $this->n; ++$i) {
for ($j = 0; $j < $this->n; ++$j) {
if ($i <= $j) {
$U[$i][$j] = $this->LU[$i][$j];
} else {
$U[$i][$j] = 0.0;
}
}
}
return new PHPExcel_Shared_JAMA_Matrix($U);
} // function getU()
/**
* Return pivot permutation vector.
*
* @return array Pivot vector
*/
public function getPivot() {
return $this->piv;
} // function getPivot()
/**
* Alias for getPivot
*
* @see getPivot
*/
public function getDoublePivot() {
return $this->getPivot();
} // function getDoublePivot()
/**
* Is the matrix nonsingular?
*
* @return true if U, and hence A, is nonsingular.
*/
public function isNonsingular() {
for ($j = 0; $j < $this->n; ++$j) {
if ($this->LU[$j][$j] == 0) {
return false;
}
}
return true;
} // function isNonsingular()
/**
* Count determinants
*
* @return array d matrix deterninat
*/
public function det() {
if ($this->m == $this->n) {
$d = $this->pivsign;
for ($j = 0; $j < $this->n; ++$j) {
$d *= $this->LU[$j][$j];
}
return $d;
} else {
throw new Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException);
}
} // function det()
/**
* Solve A*X = B
*
* @param $B A Matrix with as many rows as A and any number of columns.
* @return X so that L*U*X = B(piv,:)
* @exception IllegalArgumentException Matrix row dimensions must agree.
* @exception RuntimeException Matrix is singular.
*/
public function solve($B) {
if ($B->getRowDimension() == $this->m) {
if ($this->isNonsingular()) {
// Copy right hand side with pivoting
$nx = $B->getColumnDimension();
$X = $B->getMatrix($this->piv, 0, $nx-1);
// Solve L*Y = B(piv,:)
for ($k = 0; $k < $this->n; ++$k) {
for ($i = $k+1; $i < $this->n; ++$i) {
for ($j = 0; $j < $nx; ++$j) {
$X->A[$i][$j] -= $X->A[$k][$j] * $this->LU[$i][$k];
}
}
}
// Solve U*X = Y;
for ($k = $this->n-1; $k >= 0; --$k) {
for ($j = 0; $j < $nx; ++$j) {
$X->A[$k][$j] /= $this->LU[$k][$k];
}
for ($i = 0; $i < $k; ++$i) {
for ($j = 0; $j < $nx; ++$j) {
$X->A[$i][$j] -= $X->A[$k][$j] * $this->LU[$i][$k];
}
}
}
return $X;
} else {
throw new Exception(self::MatrixSingularException);
}
} else {
throw new Exception(self::MatrixSquareException);
}
} // function solve()
} // class PHPExcel_Shared_JAMA_LUDecomposition
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/LUDecomposition.php | PHP | asf20 | 6,105 |
<?php
/**
* @package JAMA
*
* Cholesky decomposition class
*
* For a symmetric, positive definite matrix A, the Cholesky decomposition
* is an lower triangular matrix L so that A = L*L'.
*
* If the matrix is not symmetric or positive definite, the constructor
* returns a partial decomposition and sets an internal flag that may
* be queried by the isSPD() method.
*
* @author Paul Meagher
* @author Michael Bommarito
* @version 1.2
*/
class CholeskyDecomposition {
/**
* Decomposition storage
* @var array
* @access private
*/
private $L = array();
/**
* Matrix row and column dimension
* @var int
* @access private
*/
private $m;
/**
* Symmetric positive definite flag
* @var boolean
* @access private
*/
private $isspd = true;
/**
* CholeskyDecomposition
*
* Class constructor - decomposes symmetric positive definite matrix
* @param mixed Matrix square symmetric positive definite matrix
*/
public function __construct($A = null) {
if ($A instanceof Matrix) {
$this->L = $A->getArray();
$this->m = $A->getRowDimension();
for($i = 0; $i < $this->m; ++$i) {
for($j = $i; $j < $this->m; ++$j) {
for($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) {
$sum -= $this->L[$i][$k] * $this->L[$j][$k];
}
if ($i == $j) {
if ($sum >= 0) {
$this->L[$i][$i] = sqrt($sum);
} else {
$this->isspd = false;
}
} else {
if ($this->L[$i][$i] != 0) {
$this->L[$j][$i] = $sum / $this->L[$i][$i];
}
}
}
for ($k = $i+1; $k < $this->m; ++$k) {
$this->L[$i][$k] = 0.0;
}
}
} else {
throw new Exception(JAMAError(ArgumentTypeException));
}
} // function __construct()
/**
* Is the matrix symmetric and positive definite?
*
* @return boolean
*/
public function isSPD() {
return $this->isspd;
} // function isSPD()
/**
* getL
*
* Return triangular factor.
* @return Matrix Lower triangular matrix
*/
public function getL() {
return new Matrix($this->L);
} // function getL()
/**
* Solve A*X = B
*
* @param $B Row-equal matrix
* @return Matrix L * L' * X = B
*/
public function solve($B = null) {
if ($B instanceof Matrix) {
if ($B->getRowDimension() == $this->m) {
if ($this->isspd) {
$X = $B->getArrayCopy();
$nx = $B->getColumnDimension();
for ($k = 0; $k < $this->m; ++$k) {
for ($i = $k + 1; $i < $this->m; ++$i) {
for ($j = 0; $j < $nx; ++$j) {
$X[$i][$j] -= $X[$k][$j] * $this->L[$i][$k];
}
}
for ($j = 0; $j < $nx; ++$j) {
$X[$k][$j] /= $this->L[$k][$k];
}
}
for ($k = $this->m - 1; $k >= 0; --$k) {
for ($j = 0; $j < $nx; ++$j) {
$X[$k][$j] /= $this->L[$k][$k];
}
for ($i = 0; $i < $k; ++$i) {
for ($j = 0; $j < $nx; ++$j) {
$X[$i][$j] -= $X[$k][$j] * $this->L[$k][$i];
}
}
}
return new Matrix($X, $this->m, $nx);
} else {
throw new Exception(JAMAError(MatrixSPDException));
}
} else {
throw new Exception(JAMAError(MatrixDimensionException));
}
} else {
throw new Exception(JAMAError(ArgumentTypeException));
}
} // function solve()
} // class CholeskyDecomposition
| zysms | trunk/zysms/customer/PHPExcel/Shared/JAMA/CholeskyDecomposition.php | PHP | asf20 | 3,274 |
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2011 PHPExcel
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
*/
/**
* PHPExcel_Shared_PasswordHasher
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_PasswordHasher
{
/**
* Create a password hash from a given string.
*
* This method is based on the algorithm provided by
* Daniel Rentz of OpenOffice and the PEAR package
* Spreadsheet_Excel_Writer by Xavier Noguer <xnoguer@rezebra.com>.
*
* @param string $pPassword Password to hash
* @return string Hashed password
*/
public static function hashPassword($pPassword = '') {
$password = 0x0000;
$i = 1; // char position
// split the plain text password in its component characters
$chars = preg_split('//', $pPassword, -1, PREG_SPLIT_NO_EMPTY);
foreach ($chars as $char) {
$value = ord($char) << $i; // shifted ASCII value
$rotated_bits = $value >> 15; // rotated bits beyond bit 15
$value &= 0x7fff; // first 15 bits
$password ^= ($value | $rotated_bits);
++$i;
}
$password ^= strlen($pPassword);
$password ^= 0xCE4B;
return(strtoupper(dechex($password)));
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/PasswordHasher.php | PHP | asf20 | 2,342 |
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Xavier Noguer <xnoguer@php.net> |
// | Based on OLE::Storage_Lite by Kawai, Takanori |
// +----------------------------------------------------------------------+
//
// $Id: OLE.php,v 1.13 2007/03/07 14:38:25 schmidt Exp $
/**
* Array for storing OLE instances that are accessed from
* OLE_ChainedBlockStream::stream_open().
* @var array
*/
$GLOBALS['_OLE_INSTANCES'] = array();
/**
* OLE package base class.
*
* @author Xavier Noguer <xnoguer@php.net>
* @author Christian Schmidt <schmidt@php.net>
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
class PHPExcel_Shared_OLE
{
const OLE_PPS_TYPE_ROOT = 5;
const OLE_PPS_TYPE_DIR = 1;
const OLE_PPS_TYPE_FILE = 2;
const OLE_DATA_SIZE_SMALL = 0x1000;
const OLE_LONG_INT_SIZE = 4;
const OLE_PPS_SIZE = 0x80;
/**
* The file handle for reading an OLE container
* @var resource
*/
public $_file_handle;
/**
* Array of PPS's found on the OLE container
* @var array
*/
public $_list = array();
/**
* Root directory of OLE container
* @var OLE_PPS_Root
*/
public $root;
/**
* Big Block Allocation Table
* @var array (blockId => nextBlockId)
*/
public $bbat;
/**
* Short Block Allocation Table
* @var array (blockId => nextBlockId)
*/
public $sbat;
/**
* Size of big blocks. This is usually 512.
* @var int number of octets per block.
*/
public $bigBlockSize;
/**
* Size of small blocks. This is usually 64.
* @var int number of octets per block
*/
public $smallBlockSize;
/**
* 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
*/
public function read($file)
{
$fh = fopen($file, "r");
if (!$fh) {
throw new Exception("Can't open file $file");
}
$this->_file_handle = $fh;
$signature = fread($fh, 8);
if ("\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" != $signature) {
throw new Exception("File doesn't seem to be an OLE container.");
}
fseek($fh, 28);
if (fread($fh, 2) != "\xFE\xFF") {
// This shouldn't be a problem in practice
throw new Exception("Only Little-Endian encoding is supported.");
}
// Size of blocks and short blocks in bytes
$this->bigBlockSize = pow(2, self::_readInt2($fh));
$this->smallBlockSize = pow(2, self::_readInt2($fh));
// Skip UID, revision number and version number
fseek($fh, 44);
// Number of blocks in Big Block Allocation Table
$bbatBlockCount = self::_readInt4($fh);
// Root chain 1st block
$directoryFirstBlockId = self::_readInt4($fh);
// Skip unused bytes
fseek($fh, 56);
// Streams shorter than this are stored using small blocks
$this->bigBlockThreshold = self::_readInt4($fh);
// Block id of first sector in Short Block Allocation Table
$sbatFirstBlockId = self::_readInt4($fh);
// Number of blocks in Short Block Allocation Table
$sbbatBlockCount = self::_readInt4($fh);
// Block id of first sector in Master Block Allocation Table
$mbatFirstBlockId = self::_readInt4($fh);
// Number of blocks in Master Block Allocation Table
$mbbatBlockCount = self::_readInt4($fh);
$this->bbat = array();
// Remaining 4 * 109 bytes of current block is beginning of Master
// Block Allocation Table
$mbatBlocks = array();
for ($i = 0; $i < 109; ++$i) {
$mbatBlocks[] = self::_readInt4($fh);
}
// Read rest of Master Block Allocation Table (if any is left)
$pos = $this->_getBlockOffset($mbatFirstBlockId);
for ($i = 0; $i < $mbbatBlockCount; ++$i) {
fseek($fh, $pos);
for ($j = 0; $j < $this->bigBlockSize / 4 - 1; ++$j) {
$mbatBlocks[] = self::_readInt4($fh);
}
// Last block id in each block points to next block
$pos = $this->_getBlockOffset(self::_readInt4($fh));
}
// Read Big Block Allocation Table according to chain specified by
// $mbatBlocks
for ($i = 0; $i < $bbatBlockCount; ++$i) {
$pos = $this->_getBlockOffset($mbatBlocks[$i]);
fseek($fh, $pos);
for ($j = 0 ; $j < $this->bigBlockSize / 4; ++$j) {
$this->bbat[] = self::_readInt4($fh);
}
}
// Read short block allocation table (SBAT)
$this->sbat = array();
$shortBlockCount = $sbbatBlockCount * $this->bigBlockSize / 4;
$sbatFh = $this->getStream($sbatFirstBlockId);
for ($blockId = 0; $blockId < $shortBlockCount; ++$blockId) {
$this->sbat[$blockId] = self::_readInt4($sbatFh);
}
fclose($sbatFh);
$this->_readPpsWks($directoryFirstBlockId);
return true;
}
/**
* @param int block id
* @param int byte offset from beginning of file
* @access public
*/
public function _getBlockOffset($blockId)
{
return 512 + $blockId * $this->bigBlockSize;
}
/**
* Returns a stream for use with fread() etc. External callers should
* use PHPExcel_Shared_OLE_PPS_File::getStream().
* @param int|PPS block id or PPS
* @return resource read-only stream
*/
public function getStream($blockIdOrPps)
{
static $isRegistered = false;
if (!$isRegistered) {
stream_wrapper_register('ole-chainedblockstream',
'PHPExcel_Shared_OLE_ChainedBlockStream');
$isRegistered = true;
}
// Store current instance in global array, so that it can be accessed
// in OLE_ChainedBlockStream::stream_open().
// Object is removed from self::$instances in OLE_Stream::close().
$GLOBALS['_OLE_INSTANCES'][] = $this;
$instanceId = end(array_keys($GLOBALS['_OLE_INSTANCES']));
$path = 'ole-chainedblockstream://oleInstanceId=' . $instanceId;
if ($blockIdOrPps instanceof PHPExcel_Shared_OLE_PPS) {
$path .= '&blockId=' . $blockIdOrPps->_StartBlock;
$path .= '&size=' . $blockIdOrPps->Size;
} else {
$path .= '&blockId=' . $blockIdOrPps;
}
return fopen($path, 'r');
}
/**
* Reads a signed char.
* @param resource file handle
* @return int
* @access public
*/
private static function _readInt1($fh)
{
list(, $tmp) = unpack("c", fread($fh, 1));
return $tmp;
}
/**
* Reads an unsigned short (2 octets).
* @param resource file handle
* @return int
* @access public
*/
private static function _readInt2($fh)
{
list(, $tmp) = unpack("v", fread($fh, 2));
return $tmp;
}
/**
* Reads an unsigned long (4 octets).
* @param resource file handle
* @return int
* @access public
*/
private static function _readInt4($fh)
{
list(, $tmp) = unpack("V", fread($fh, 4));
return $tmp;
}
/**
* Gets information about all PPS's on the OLE container from the PPS WK's
* creates an OLE_PPS object for each one.
*
* @access public
* @param integer the block id of the first block
* @return mixed true on success, PEAR_Error on failure
*/
public function _readPpsWks($blockId)
{
$fh = $this->getStream($blockId);
for ($pos = 0; ; $pos += 128) {
fseek($fh, $pos, SEEK_SET);
$nameUtf16 = fread($fh, 64);
$nameLength = self::_readInt2($fh);
$nameUtf16 = substr($nameUtf16, 0, $nameLength - 2);
// Simple conversion from UTF-16LE to ISO-8859-1
$name = str_replace("\x00", "", $nameUtf16);
$type = self::_readInt1($fh);
switch ($type) {
case self::OLE_PPS_TYPE_ROOT:
$pps = new PHPExcel_Shared_OLE_PPS_Root(null, null, array());
$this->root = $pps;
break;
case self::OLE_PPS_TYPE_DIR:
$pps = new PHPExcel_Shared_OLE_PPS(null, null, null, null, null,
null, null, null, null, array());
break;
case self::OLE_PPS_TYPE_FILE:
$pps = new PHPExcel_Shared_OLE_PPS_File($name);
break;
default:
continue;
}
fseek($fh, 1, SEEK_CUR);
$pps->Type = $type;
$pps->Name = $name;
$pps->PrevPps = self::_readInt4($fh);
$pps->NextPps = self::_readInt4($fh);
$pps->DirPps = self::_readInt4($fh);
fseek($fh, 20, SEEK_CUR);
$pps->Time1st = self::OLE2LocalDate(fread($fh, 8));
$pps->Time2nd = self::OLE2LocalDate(fread($fh, 8));
$pps->_StartBlock = self::_readInt4($fh);
$pps->Size = self::_readInt4($fh);
$pps->No = count($this->_list);
$this->_list[] = $pps;
// check if the PPS tree (starting from root) is complete
if (isset($this->root) &&
$this->_ppsTreeComplete($this->root->No)) {
break;
}
}
fclose($fh);
// Initialize $pps->children on directories
foreach ($this->_list as $pps) {
if ($pps->Type == self::OLE_PPS_TYPE_DIR || $pps->Type == self::OLE_PPS_TYPE_ROOT) {
$nos = array($pps->DirPps);
$pps->children = array();
while ($nos) {
$no = array_pop($nos);
if ($no != -1) {
$childPps = $this->_list[$no];
$nos[] = $childPps->PrevPps;
$nos[] = $childPps->NextPps;
$pps->children[] = $childPps;
}
}
}
}
return true;
}
/**
* It checks whether the PPS tree is complete (all PPS's read)
* starting with the given PPS (not necessarily root)
*
* @access public
* @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
*/
public function _ppsTreeComplete($index)
{
return isset($this->_list[$index]) &&
($pps = $this->_list[$index]) &&
($pps->PrevPps == -1 ||
$this->_ppsTreeComplete($pps->PrevPps)) &&
($pps->NextPps == -1 ||
$this->_ppsTreeComplete($pps->NextPps)) &&
($pps->DirPps == -1 ||
$this->_ppsTreeComplete($pps->DirPps));
}
/**
* 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
*/
public function isFile($index)
{
if (isset($this->_list[$index])) {
return ($this->_list[$index]->Type == self::OLE_PPS_TYPE_FILE);
}
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
*/
public function isRoot($index)
{
if (isset($this->_list[$index])) {
return ($this->_list[$index]->Type == self::OLE_PPS_TYPE_ROOT);
}
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
*/
public 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
* @see OLE_PPS_File::getStream()
*/
public function getData($index, $position, $length)
{
// if position is not valid return empty string
if (!isset($this->_list[$index]) || ($position >= $this->_list[$index]->Size) || ($position < 0)) {
return '';
}
$fh = $this->getStream($this->_list[$index]);
$data = stream_get_contents($fh, $length, $position);
fclose($fh);
return $data;
}
/**
* 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
*/
public function getDataLength($index)
{
if (isset($this->_list[$index])) {
return $this->_list[$index]->Size;
}
return 0;
}
/**
* 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
*/
public static function Asc2Ucs($ascii)
{
$rawname = '';
for ($i = 0; $i < strlen($ascii); ++$i) {
$rawname .= $ascii{$i} . "\x00";
}
return $rawname;
}
/**
* 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
*/
public static function LocalDate2OLE($date = null)
{
if (!isset($date)) {
return "\x00\x00\x00\x00\x00\x00\x00\x00";
}
// factor used for separating numbers into 4 bytes parts
$factor = pow(2, 32);
// days from 1-1-1601 until the beggining of UNIX era
$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));
// multiply just to make MS happy
$big_date *= 10000000;
$high_part = floor($big_date / $factor);
// lower 4 bytes
$low_part = floor((($big_date / $factor) - $high_part) * $factor);
// Make HEX string
$res = '';
for ($i = 0; $i < 4; ++$i) {
$hex = $low_part % 0x100;
$res .= pack('c', $hex);
$low_part /= 0x100;
}
for ($i = 0; $i < 4; ++$i) {
$hex = $high_part % 0x100;
$res .= pack('c', $hex);
$high_part /= 0x100;
}
return $res;
}
/**
* 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
*/
public static function OLE2LocalDate($string)
{
if (strlen($string) != 8) {
return new PEAR_Error("Expecting 8 byte string");
}
// factor used for separating numbers into 4 bytes parts
$factor = pow(2,32);
list(, $high_part) = unpack('V', substr($string, 4, 4));
list(, $low_part) = unpack('V', substr($string, 0, 4));
$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);
}
}
| zysms | trunk/zysms/customer/PHPExcel/Shared/OLE.php | PHP | asf20 | 15,008 |
<?php
//============================================================+
// File name : unicode_data.php
// Version : 1.0.006
// Begin : 2008-01-01
// Last Update : 2010-10-18
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
// Copyright (C) 2008-2010 Nicola Asuni - Tecnick.com S.r.l.
//
// This file is part of TCPDF software library.
//
// TCPDF 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 3 of the
// License, or (at your option) any later version.
//
// TCPDF 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 TCPDF. If not, see <http://www.gnu.org/licenses/>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : Unicode data for TCPDF library.
//
//============================================================+
// THANKS TO
// Efthimios Mavrogeorgiadis
// Saleh AlMatrafe
/**
* Unicode data class for TCPDF library.
* @author Nicola Asuni
* @copyright 2008-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @package com.tecnick.tcpdf
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2.1.000 (2008-01-08)
*/
/**
* This is a PHP class containing Unicde data for TCPDF library
* @name TCPDF_UNICODE_DATA
* @package com.tecnick.tcpdf
* @version 1.0.006
* @author Nicola Asuni - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
*/
class TCPDF_UNICODE_DATA {
/**
* @var Unicode code for Left-to-Right Mark
* @access public
*/
public $uni_LRM = 8206;
/**
* @var Unicode code for Right-to-Left Mark
* @access public
*/
public $uni_RLM = 8207;
/**
* @var Unicode code for Left-to-Right Embedding
* @access public
*/
public $uni_LRE = 8234;
/**
* @var Unicode code for Right-to-Left Embedding
* @access public
*/
public $uni_RLE = 8235;
/**
* @var Unicode code for Pop Directional Format
* @access public
*/
public $uni_PDF = 8236;
/**
* @var Unicode code for Left-to-Right Override
* @access public
*/
public $uni_LRO = 8237;
/**
* @var Unicode code for Right-to-Left Override
* @access public
*/
public $uni_RLO = 8238;
/*
* @var Pattern to test RTL (Righ-To-Left) strings using regular expressions.
* @access public
*/
public $uni_RE_PATTERN_RTL = "/(
\xD6\xBE # R
| \xD7[\x80\x83\x86\x90-\xAA\xB0-\xB4] # R
| \xDF[\x80-\xAA\xB4\xB5\xBA] # R
| \xE2\x80\x8F # R
| \xEF\xAC[\x9D\x9F\xA0-\xA8\xAA-\xB6\xB8-\xBC\xBE] # R
| \xEF\xAD[\x80\x81\x83\x84\x86-\x8F] # R
| \xF0\x90\xA0[\x80-\x85\x88\x8A-\xB5\xB7\xB8\xBC\xBF] # R
| \xF0\x90\xA4[\x80-\x99] # R
| \xF0\x90\xA8[\x80\x90-\x93\x95-\x97\x99-\xB3] # R
| \xF0\x90\xA9[\x80-\x87\x90-\x98] # R
| \xE2\x80[\xAB\xAE] # RLE & RLO
)/x";
/*
* @var Pattern to test Arabic strings using regular expressions.
* Source: http://www.w3.org/International/questions/qa-forms-utf-8
* @access public
*/
public $uni_RE_PATTERN_ARABIC = "/(
\xD8[\x80-\x83\x8B\x8D\x9B\x9E\x9F\xA1-\xBA] # AL
| \xD9[\x80-\x8A\xAD-\xAF\xB1-\xBF] # AL
| \xDA[\x80-\xBF] # AL
| \xDB[\x80-\x95\x9D\xA5\xA6\xAE\xAF\xBA-\xBF] # AL
| \xDC[\x80-\x8D\x90\x92-\xAF] # AL
| \xDD[\x8D-\xAD] # AL
| \xDE[\x80-\xA5\xB1] # AL
| \xEF\xAD[\x90-\xBF] # AL
| \xEF\xAE[\x80-\xB1] # AL
| \xEF\xAF[\x93-\xBF] # AL
| \xEF[\xB0-\xB3][\x80-\xBF] # AL
| \xEF\xB4[\x80-\xBD] # AL
| \xEF\xB5[\x90-\xBF] # AL
| \xEF\xB6[\x80-\x8F\x92-\xBF] # AL
| \xEF\xB7[\x80-\x87\xB0-\xBC] # AL
| \xEF\xB9[\xB0-\xB4\xB6-\xBF] # AL
| \xEF\xBA[\x80-\xBF] # AL
| \xEF\xBB[\x80-\xBC] # AL
| \xD9[\xA0-\xA9\xAB\xAC] # AN
)/x";
/**
* @var Array of Unicode types
* @access public
*/
public $uni_type = array(
0=>'BN',
1=>'BN',
2=>'BN',
3=>'BN',
4=>'BN',
5=>'BN',
6=>'BN',
7=>'BN',
8=>'BN',
9=>'S',
10=>'B',
11=>'S',
12=>'WS',
13=>'B',
14=>'BN',
15=>'BN',
16=>'BN',
17=>'BN',
18=>'BN',
19=>'BN',
20=>'BN',
21=>'BN',
22=>'BN',
23=>'BN',
24=>'BN',
25=>'BN',
26=>'BN',
27=>'BN',
28=>'B',
29=>'B',
30=>'B',
31=>'S',
32=>'WS',
33=>'ON',
34=>'ON',
35=>'ET',
36=>'ET',
37=>'ET',
38=>'ON',
39=>'ON',
40=>'ON',
41=>'ON',
42=>'ON',
43=>'ES',
44=>'CS',
45=>'ES',
46=>'CS',
47=>'CS',
48=>'EN',
49=>'EN',
50=>'EN',
51=>'EN',
52=>'EN',
53=>'EN',
54=>'EN',
55=>'EN',
56=>'EN',
57=>'EN',
58=>'CS',
59=>'ON',
60=>'ON',
61=>'ON',
62=>'ON',
63=>'ON',
64=>'ON',
65=>'L',
66=>'L',
67=>'L',
68=>'L',
69=>'L',
70=>'L',
71=>'L',
72=>'L',
73=>'L',
74=>'L',
75=>'L',
76=>'L',
77=>'L',
78=>'L',
79=>'L',
80=>'L',
81=>'L',
82=>'L',
83=>'L',
84=>'L',
85=>'L',
86=>'L',
87=>'L',
88=>'L',
89=>'L',
90=>'L',
91=>'ON',
92=>'ON',
93=>'ON',
94=>'ON',
95=>'ON',
96=>'ON',
97=>'L',
98=>'L',
99=>'L',
100=>'L',
101=>'L',
102=>'L',
103=>'L',
104=>'L',
105=>'L',
106=>'L',
107=>'L',
108=>'L',
109=>'L',
110=>'L',
111=>'L',
112=>'L',
113=>'L',
114=>'L',
115=>'L',
116=>'L',
117=>'L',
118=>'L',
119=>'L',
120=>'L',
121=>'L',
122=>'L',
123=>'ON',
124=>'ON',
125=>'ON',
126=>'ON',
127=>'BN',
128=>'BN',
129=>'BN',
130=>'BN',
131=>'BN',
132=>'BN',
133=>'B',
134=>'BN',
135=>'BN',
136=>'BN',
137=>'BN',
138=>'BN',
139=>'BN',
140=>'BN',
141=>'BN',
142=>'BN',
143=>'BN',
144=>'BN',
145=>'BN',
146=>'BN',
147=>'BN',
148=>'BN',
149=>'BN',
150=>'BN',
151=>'BN',
152=>'BN',
153=>'BN',
154=>'BN',
155=>'BN',
156=>'BN',
157=>'BN',
158=>'BN',
159=>'BN',
160=>'CS',
161=>'ON',
162=>'ET',
163=>'ET',
164=>'ET',
165=>'ET',
166=>'ON',
167=>'ON',
168=>'ON',
169=>'ON',
170=>'L',
171=>'ON',
172=>'ON',
173=>'BN',
174=>'ON',
175=>'ON',
176=>'ET',
177=>'ET',
178=>'EN',
179=>'EN',
180=>'ON',
181=>'L',
182=>'ON',
183=>'ON',
184=>'ON',
185=>'EN',
186=>'L',
187=>'ON',
188=>'ON',
189=>'ON',
190=>'ON',
191=>'ON',
192=>'L',
193=>'L',
194=>'L',
195=>'L',
196=>'L',
197=>'L',
198=>'L',
199=>'L',
200=>'L',
201=>'L',
202=>'L',
203=>'L',
204=>'L',
205=>'L',
206=>'L',
207=>'L',
208=>'L',
209=>'L',
210=>'L',
211=>'L',
212=>'L',
213=>'L',
214=>'L',
215=>'ON',
216=>'L',
217=>'L',
218=>'L',
219=>'L',
220=>'L',
221=>'L',
222=>'L',
223=>'L',
224=>'L',
225=>'L',
226=>'L',
227=>'L',
228=>'L',
229=>'L',
230=>'L',
231=>'L',
232=>'L',
233=>'L',
234=>'L',
235=>'L',
236=>'L',
237=>'L',
238=>'L',
239=>'L',
240=>'L',
241=>'L',
242=>'L',
243=>'L',
244=>'L',
245=>'L',
246=>'L',
247=>'ON',
248=>'L',
249=>'L',
250=>'L',
251=>'L',
252=>'L',
253=>'L',
254=>'L',
255=>'L',
256=>'L',
257=>'L',
258=>'L',
259=>'L',
260=>'L',
261=>'L',
262=>'L',
263=>'L',
264=>'L',
265=>'L',
266=>'L',
267=>'L',
268=>'L',
269=>'L',
270=>'L',
271=>'L',
272=>'L',
273=>'L',
274=>'L',
275=>'L',
276=>'L',
277=>'L',
278=>'L',
279=>'L',
280=>'L',
281=>'L',
282=>'L',
283=>'L',
284=>'L',
285=>'L',
286=>'L',
287=>'L',
288=>'L',
289=>'L',
290=>'L',
291=>'L',
292=>'L',
293=>'L',
294=>'L',
295=>'L',
296=>'L',
297=>'L',
298=>'L',
299=>'L',
300=>'L',
301=>'L',
302=>'L',
303=>'L',
304=>'L',
305=>'L',
306=>'L',
307=>'L',
308=>'L',
309=>'L',
310=>'L',
311=>'L',
312=>'L',
313=>'L',
314=>'L',
315=>'L',
316=>'L',
317=>'L',
318=>'L',
319=>'L',
320=>'L',
321=>'L',
322=>'L',
323=>'L',
324=>'L',
325=>'L',
326=>'L',
327=>'L',
328=>'L',
329=>'L',
330=>'L',
331=>'L',
332=>'L',
333=>'L',
334=>'L',
335=>'L',
336=>'L',
337=>'L',
338=>'L',
339=>'L',
340=>'L',
341=>'L',
342=>'L',
343=>'L',
344=>'L',
345=>'L',
346=>'L',
347=>'L',
348=>'L',
349=>'L',
350=>'L',
351=>'L',
352=>'L',
353=>'L',
354=>'L',
355=>'L',
356=>'L',
357=>'L',
358=>'L',
359=>'L',
360=>'L',
361=>'L',
362=>'L',
363=>'L',
364=>'L',
365=>'L',
366=>'L',
367=>'L',
368=>'L',
369=>'L',
370=>'L',
371=>'L',
372=>'L',
373=>'L',
374=>'L',
375=>'L',
376=>'L',
377=>'L',
378=>'L',
379=>'L',
380=>'L',
381=>'L',
382=>'L',
383=>'L',
384=>'L',
385=>'L',
386=>'L',
387=>'L',
388=>'L',
389=>'L',
390=>'L',
391=>'L',
392=>'L',
393=>'L',
394=>'L',
395=>'L',
396=>'L',
397=>'L',
398=>'L',
399=>'L',
400=>'L',
401=>'L',
402=>'L',
403=>'L',
404=>'L',
405=>'L',
406=>'L',
407=>'L',
408=>'L',
409=>'L',
410=>'L',
411=>'L',
412=>'L',
413=>'L',
414=>'L',
415=>'L',
416=>'L',
417=>'L',
418=>'L',
419=>'L',
420=>'L',
421=>'L',
422=>'L',
423=>'L',
424=>'L',
425=>'L',
426=>'L',
427=>'L',
428=>'L',
429=>'L',
430=>'L',
431=>'L',
432=>'L',
433=>'L',
434=>'L',
435=>'L',
436=>'L',
437=>'L',
438=>'L',
439=>'L',
440=>'L',
441=>'L',
442=>'L',
443=>'L',
444=>'L',
445=>'L',
446=>'L',
447=>'L',
448=>'L',
449=>'L',
450=>'L',
451=>'L',
452=>'L',
453=>'L',
454=>'L',
455=>'L',
456=>'L',
457=>'L',
458=>'L',
459=>'L',
460=>'L',
461=>'L',
462=>'L',
463=>'L',
464=>'L',
465=>'L',
466=>'L',
467=>'L',
468=>'L',
469=>'L',
470=>'L',
471=>'L',
472=>'L',
473=>'L',
474=>'L',
475=>'L',
476=>'L',
477=>'L',
478=>'L',
479=>'L',
480=>'L',
481=>'L',
482=>'L',
483=>'L',
484=>'L',
485=>'L',
486=>'L',
487=>'L',
488=>'L',
489=>'L',
490=>'L',
491=>'L',
492=>'L',
493=>'L',
494=>'L',
495=>'L',
496=>'L',
497=>'L',
498=>'L',
499=>'L',
500=>'L',
501=>'L',
502=>'L',
503=>'L',
504=>'L',
505=>'L',
506=>'L',
507=>'L',
508=>'L',
509=>'L',
510=>'L',
511=>'L',
512=>'L',
513=>'L',
514=>'L',
515=>'L',
516=>'L',
517=>'L',
518=>'L',
519=>'L',
520=>'L',
521=>'L',
522=>'L',
523=>'L',
524=>'L',
525=>'L',
526=>'L',
527=>'L',
528=>'L',
529=>'L',
530=>'L',
531=>'L',
532=>'L',
533=>'L',
534=>'L',
535=>'L',
536=>'L',
537=>'L',
538=>'L',
539=>'L',
540=>'L',
541=>'L',
542=>'L',
543=>'L',
544=>'L',
545=>'L',
546=>'L',
547=>'L',
548=>'L',
549=>'L',
550=>'L',
551=>'L',
552=>'L',
553=>'L',
554=>'L',
555=>'L',
556=>'L',
557=>'L',
558=>'L',
559=>'L',
560=>'L',
561=>'L',
562=>'L',
563=>'L',
564=>'L',
565=>'L',
566=>'L',
567=>'L',
568=>'L',
569=>'L',
570=>'L',
571=>'L',
572=>'L',
573=>'L',
574=>'L',
575=>'L',
576=>'L',
577=>'L',
578=>'L',
579=>'L',
580=>'L',
581=>'L',
582=>'L',
583=>'L',
584=>'L',
585=>'L',
586=>'L',
587=>'L',
588=>'L',
589=>'L',
590=>'L',
591=>'L',
592=>'L',
593=>'L',
594=>'L',
595=>'L',
596=>'L',
597=>'L',
598=>'L',
599=>'L',
600=>'L',
601=>'L',
602=>'L',
603=>'L',
604=>'L',
605=>'L',
606=>'L',
607=>'L',
608=>'L',
609=>'L',
610=>'L',
611=>'L',
612=>'L',
613=>'L',
614=>'L',
615=>'L',
616=>'L',
617=>'L',
618=>'L',
619=>'L',
620=>'L',
621=>'L',
622=>'L',
623=>'L',
624=>'L',
625=>'L',
626=>'L',
627=>'L',
628=>'L',
629=>'L',
630=>'L',
631=>'L',
632=>'L',
633=>'L',
634=>'L',
635=>'L',
636=>'L',
637=>'L',
638=>'L',
639=>'L',
640=>'L',
641=>'L',
642=>'L',
643=>'L',
644=>'L',
645=>'L',
646=>'L',
647=>'L',
648=>'L',
649=>'L',
650=>'L',
651=>'L',
652=>'L',
653=>'L',
654=>'L',
655=>'L',
656=>'L',
657=>'L',
658=>'L',
659=>'L',
660=>'L',
661=>'L',
662=>'L',
663=>'L',
664=>'L',
665=>'L',
666=>'L',
667=>'L',
668=>'L',
669=>'L',
670=>'L',
671=>'L',
672=>'L',
673=>'L',
674=>'L',
675=>'L',
676=>'L',
677=>'L',
678=>'L',
679=>'L',
680=>'L',
681=>'L',
682=>'L',
683=>'L',
684=>'L',
685=>'L',
686=>'L',
687=>'L',
688=>'L',
689=>'L',
690=>'L',
691=>'L',
692=>'L',
693=>'L',
694=>'L',
695=>'L',
696=>'L',
697=>'ON',
698=>'ON',
699=>'L',
700=>'L',
701=>'L',
702=>'L',
703=>'L',
704=>'L',
705=>'L',
706=>'ON',
707=>'ON',
708=>'ON',
709=>'ON',
710=>'ON',
711=>'ON',
712=>'ON',
713=>'ON',
714=>'ON',
715=>'ON',
716=>'ON',
717=>'ON',
718=>'ON',
719=>'ON',
720=>'L',
721=>'L',
722=>'ON',
723=>'ON',
724=>'ON',
725=>'ON',
726=>'ON',
727=>'ON',
728=>'ON',
729=>'ON',
730=>'ON',
731=>'ON',
732=>'ON',
733=>'ON',
734=>'ON',
735=>'ON',
736=>'L',
737=>'L',
738=>'L',
739=>'L',
740=>'L',
741=>'ON',
742=>'ON',
743=>'ON',
744=>'ON',
745=>'ON',
746=>'ON',
747=>'ON',
748=>'ON',
749=>'ON',
750=>'L',
751=>'ON',
752=>'ON',
753=>'ON',
754=>'ON',
755=>'ON',
756=>'ON',
757=>'ON',
758=>'ON',
759=>'ON',
760=>'ON',
761=>'ON',
762=>'ON',
763=>'ON',
764=>'ON',
765=>'ON',
766=>'ON',
767=>'ON',
768=>'NSM',
769=>'NSM',
770=>'NSM',
771=>'NSM',
772=>'NSM',
773=>'NSM',
774=>'NSM',
775=>'NSM',
776=>'NSM',
777=>'NSM',
778=>'NSM',
779=>'NSM',
780=>'NSM',
781=>'NSM',
782=>'NSM',
783=>'NSM',
784=>'NSM',
785=>'NSM',
786=>'NSM',
787=>'NSM',
788=>'NSM',
789=>'NSM',
790=>'NSM',
791=>'NSM',
792=>'NSM',
793=>'NSM',
794=>'NSM',
795=>'NSM',
796=>'NSM',
797=>'NSM',
798=>'NSM',
799=>'NSM',
800=>'NSM',
801=>'NSM',
802=>'NSM',
803=>'NSM',
804=>'NSM',
805=>'NSM',
806=>'NSM',
807=>'NSM',
808=>'NSM',
809=>'NSM',
810=>'NSM',
811=>'NSM',
812=>'NSM',
813=>'NSM',
814=>'NSM',
815=>'NSM',
816=>'NSM',
817=>'NSM',
818=>'NSM',
819=>'NSM',
820=>'NSM',
821=>'NSM',
822=>'NSM',
823=>'NSM',
824=>'NSM',
825=>'NSM',
826=>'NSM',
827=>'NSM',
828=>'NSM',
829=>'NSM',
830=>'NSM',
831=>'NSM',
832=>'NSM',
833=>'NSM',
834=>'NSM',
835=>'NSM',
836=>'NSM',
837=>'NSM',
838=>'NSM',
839=>'NSM',
840=>'NSM',
841=>'NSM',
842=>'NSM',
843=>'NSM',
844=>'NSM',
845=>'NSM',
846=>'NSM',
847=>'NSM',
848=>'NSM',
849=>'NSM',
850=>'NSM',
851=>'NSM',
852=>'NSM',
853=>'NSM',
854=>'NSM',
855=>'NSM',
856=>'NSM',
857=>'NSM',
858=>'NSM',
859=>'NSM',
860=>'NSM',
861=>'NSM',
862=>'NSM',
863=>'NSM',
864=>'NSM',
865=>'NSM',
866=>'NSM',
867=>'NSM',
868=>'NSM',
869=>'NSM',
870=>'NSM',
871=>'NSM',
872=>'NSM',
873=>'NSM',
874=>'NSM',
875=>'NSM',
876=>'NSM',
877=>'NSM',
878=>'NSM',
879=>'NSM',
884=>'ON',
885=>'ON',
890=>'L',
891=>'L',
892=>'L',
893=>'L',
894=>'ON',
900=>'ON',
901=>'ON',
902=>'L',
903=>'ON',
904=>'L',
905=>'L',
906=>'L',
908=>'L',
910=>'L',
911=>'L',
912=>'L',
913=>'L',
914=>'L',
915=>'L',
916=>'L',
917=>'L',
918=>'L',
919=>'L',
920=>'L',
921=>'L',
922=>'L',
923=>'L',
924=>'L',
925=>'L',
926=>'L',
927=>'L',
928=>'L',
929=>'L',
931=>'L',
932=>'L',
933=>'L',
934=>'L',
935=>'L',
936=>'L',
937=>'L',
938=>'L',
939=>'L',
940=>'L',
941=>'L',
942=>'L',
943=>'L',
944=>'L',
945=>'L',
946=>'L',
947=>'L',
948=>'L',
949=>'L',
950=>'L',
951=>'L',
952=>'L',
953=>'L',
954=>'L',
955=>'L',
956=>'L',
957=>'L',
958=>'L',
959=>'L',
960=>'L',
961=>'L',
962=>'L',
963=>'L',
964=>'L',
965=>'L',
966=>'L',
967=>'L',
968=>'L',
969=>'L',
970=>'L',
971=>'L',
972=>'L',
973=>'L',
974=>'L',
976=>'L',
977=>'L',
978=>'L',
979=>'L',
980=>'L',
981=>'L',
982=>'L',
983=>'L',
984=>'L',
985=>'L',
986=>'L',
987=>'L',
988=>'L',
989=>'L',
990=>'L',
991=>'L',
992=>'L',
993=>'L',
994=>'L',
995=>'L',
996=>'L',
997=>'L',
998=>'L',
999=>'L',
1000=>'L',
1001=>'L',
1002=>'L',
1003=>'L',
1004=>'L',
1005=>'L',
1006=>'L',
1007=>'L',
1008=>'L',
1009=>'L',
1010=>'L',
1011=>'L',
1012=>'L',
1013=>'L',
1014=>'ON',
1015=>'L',
1016=>'L',
1017=>'L',
1018=>'L',
1019=>'L',
1020=>'L',
1021=>'L',
1022=>'L',
1023=>'L',
1024=>'L',
1025=>'L',
1026=>'L',
1027=>'L',
1028=>'L',
1029=>'L',
1030=>'L',
1031=>'L',
1032=>'L',
1033=>'L',
1034=>'L',
1035=>'L',
1036=>'L',
1037=>'L',
1038=>'L',
1039=>'L',
1040=>'L',
1041=>'L',
1042=>'L',
1043=>'L',
1044=>'L',
1045=>'L',
1046=>'L',
1047=>'L',
1048=>'L',
1049=>'L',
1050=>'L',
1051=>'L',
1052=>'L',
1053=>'L',
1054=>'L',
1055=>'L',
1056=>'L',
1057=>'L',
1058=>'L',
1059=>'L',
1060=>'L',
1061=>'L',
1062=>'L',
1063=>'L',
1064=>'L',
1065=>'L',
1066=>'L',
1067=>'L',
1068=>'L',
1069=>'L',
1070=>'L',
1071=>'L',
1072=>'L',
1073=>'L',
1074=>'L',
1075=>'L',
1076=>'L',
1077=>'L',
1078=>'L',
1079=>'L',
1080=>'L',
1081=>'L',
1082=>'L',
1083=>'L',
1084=>'L',
1085=>'L',
1086=>'L',
1087=>'L',
1088=>'L',
1089=>'L',
1090=>'L',
1091=>'L',
1092=>'L',
1093=>'L',
1094=>'L',
1095=>'L',
1096=>'L',
1097=>'L',
1098=>'L',
1099=>'L',
1100=>'L',
1101=>'L',
1102=>'L',
1103=>'L',
1104=>'L',
1105=>'L',
1106=>'L',
1107=>'L',
1108=>'L',
1109=>'L',
1110=>'L',
1111=>'L',
1112=>'L',
1113=>'L',
1114=>'L',
1115=>'L',
1116=>'L',
1117=>'L',
1118=>'L',
1119=>'L',
1120=>'L',
1121=>'L',
1122=>'L',
1123=>'L',
1124=>'L',
1125=>'L',
1126=>'L',
1127=>'L',
1128=>'L',
1129=>'L',
1130=>'L',
1131=>'L',
1132=>'L',
1133=>'L',
1134=>'L',
1135=>'L',
1136=>'L',
1137=>'L',
1138=>'L',
1139=>'L',
1140=>'L',
1141=>'L',
1142=>'L',
1143=>'L',
1144=>'L',
1145=>'L',
1146=>'L',
1147=>'L',
1148=>'L',
1149=>'L',
1150=>'L',
1151=>'L',
1152=>'L',
1153=>'L',
1154=>'L',
1155=>'NSM',
1156=>'NSM',
1157=>'NSM',
1158=>'NSM',
1160=>'NSM',
1161=>'NSM',
1162=>'L',
1163=>'L',
1164=>'L',
1165=>'L',
1166=>'L',
1167=>'L',
1168=>'L',
1169=>'L',
1170=>'L',
1171=>'L',
1172=>'L',
1173=>'L',
1174=>'L',
1175=>'L',
1176=>'L',
1177=>'L',
1178=>'L',
1179=>'L',
1180=>'L',
1181=>'L',
1182=>'L',
1183=>'L',
1184=>'L',
1185=>'L',
1186=>'L',
1187=>'L',
1188=>'L',
1189=>'L',
1190=>'L',
1191=>'L',
1192=>'L',
1193=>'L',
1194=>'L',
1195=>'L',
1196=>'L',
1197=>'L',
1198=>'L',
1199=>'L',
1200=>'L',
1201=>'L',
1202=>'L',
1203=>'L',
1204=>'L',
1205=>'L',
1206=>'L',
1207=>'L',
1208=>'L',
1209=>'L',
1210=>'L',
1211=>'L',
1212=>'L',
1213=>'L',
1214=>'L',
1215=>'L',
1216=>'L',
1217=>'L',
1218=>'L',
1219=>'L',
1220=>'L',
1221=>'L',
1222=>'L',
1223=>'L',
1224=>'L',
1225=>'L',
1226=>'L',
1227=>'L',
1228=>'L',
1229=>'L',
1230=>'L',
1231=>'L',
1232=>'L',
1233=>'L',
1234=>'L',
1235=>'L',
1236=>'L',
1237=>'L',
1238=>'L',
1239=>'L',
1240=>'L',
1241=>'L',
1242=>'L',
1243=>'L',
1244=>'L',
1245=>'L',
1246=>'L',
1247=>'L',
1248=>'L',
1249=>'L',
1250=>'L',
1251=>'L',
1252=>'L',
1253=>'L',
1254=>'L',
1255=>'L',
1256=>'L',
1257=>'L',
1258=>'L',
1259=>'L',
1260=>'L',
1261=>'L',
1262=>'L',
1263=>'L',
1264=>'L',
1265=>'L',
1266=>'L',
1267=>'L',
1268=>'L',
1269=>'L',
1270=>'L',
1271=>'L',
1272=>'L',
1273=>'L',
1274=>'L',
1275=>'L',
1276=>'L',
1277=>'L',
1278=>'L',
1279=>'L',
1280=>'L',
1281=>'L',
1282=>'L',
1283=>'L',
1284=>'L',
1285=>'L',
1286=>'L',
1287=>'L',
1288=>'L',
1289=>'L',
1290=>'L',
1291=>'L',
1292=>'L',
1293=>'L',
1294=>'L',
1295=>'L',
1296=>'L',
1297=>'L',
1298=>'L',
1299=>'L',
1329=>'L',
1330=>'L',
1331=>'L',
1332=>'L',
1333=>'L',
1334=>'L',
1335=>'L',
1336=>'L',
1337=>'L',
1338=>'L',
1339=>'L',
1340=>'L',
1341=>'L',
1342=>'L',
1343=>'L',
1344=>'L',
1345=>'L',
1346=>'L',
1347=>'L',
1348=>'L',
1349=>'L',
1350=>'L',
1351=>'L',
1352=>'L',
1353=>'L',
1354=>'L',
1355=>'L',
1356=>'L',
1357=>'L',
1358=>'L',
1359=>'L',
1360=>'L',
1361=>'L',
1362=>'L',
1363=>'L',
1364=>'L',
1365=>'L',
1366=>'L',
1369=>'L',
1370=>'L',
1371=>'L',
1372=>'L',
1373=>'L',
1374=>'L',
1375=>'L',
1377=>'L',
1378=>'L',
1379=>'L',
1380=>'L',
1381=>'L',
1382=>'L',
1383=>'L',
1384=>'L',
1385=>'L',
1386=>'L',
1387=>'L',
1388=>'L',
1389=>'L',
1390=>'L',
1391=>'L',
1392=>'L',
1393=>'L',
1394=>'L',
1395=>'L',
1396=>'L',
1397=>'L',
1398=>'L',
1399=>'L',
1400=>'L',
1401=>'L',
1402=>'L',
1403=>'L',
1404=>'L',
1405=>'L',
1406=>'L',
1407=>'L',
1408=>'L',
1409=>'L',
1410=>'L',
1411=>'L',
1412=>'L',
1413=>'L',
1414=>'L',
1415=>'L',
1417=>'L',
1418=>'ON',
1425=>'NSM',
1426=>'NSM',
1427=>'NSM',
1428=>'NSM',
1429=>'NSM',
1430=>'NSM',
1431=>'NSM',
1432=>'NSM',
1433=>'NSM',
1434=>'NSM',
1435=>'NSM',
1436=>'NSM',
1437=>'NSM',
1438=>'NSM',
1439=>'NSM',
1440=>'NSM',
1441=>'NSM',
1442=>'NSM',
1443=>'NSM',
1444=>'NSM',
1445=>'NSM',
1446=>'NSM',
1447=>'NSM',
1448=>'NSM',
1449=>'NSM',
1450=>'NSM',
1451=>'NSM',
1452=>'NSM',
1453=>'NSM',
1454=>'NSM',
1455=>'NSM',
1456=>'NSM',
1457=>'NSM',
1458=>'NSM',
1459=>'NSM',
1460=>'NSM',
1461=>'NSM',
1462=>'NSM',
1463=>'NSM',
1464=>'NSM',
1465=>'NSM',
1466=>'NSM',
1467=>'NSM',
1468=>'NSM',
1469=>'NSM',
1470=>'R',
1471=>'NSM',
1472=>'R',
1473=>'NSM',
1474=>'NSM',
1475=>'R',
1476=>'NSM',
1477=>'NSM',
1478=>'R',
1479=>'NSM',
1488=>'R',
1489=>'R',
1490=>'R',
1491=>'R',
1492=>'R',
1493=>'R',
1494=>'R',
1495=>'R',
1496=>'R',
1497=>'R',
1498=>'R',
1499=>'R',
1500=>'R',
1501=>'R',
1502=>'R',
1503=>'R',
1504=>'R',
1505=>'R',
1506=>'R',
1507=>'R',
1508=>'R',
1509=>'R',
1510=>'R',
1511=>'R',
1512=>'R',
1513=>'R',
1514=>'R',
1520=>'R',
1521=>'R',
1522=>'R',
1523=>'R',
1524=>'R',
1536=>'AL',
1537=>'AL',
1538=>'AL',
1539=>'AL',
1547=>'AL',
1548=>'CS',
1549=>'AL',
1550=>'ON',
1551=>'ON',
1552=>'NSM',
1553=>'NSM',
1554=>'NSM',
1555=>'NSM',
1556=>'NSM',
1557=>'NSM',
1563=>'AL',
1566=>'AL',
1567=>'AL',
1569=>'AL',
1570=>'AL',
1571=>'AL',
1572=>'AL',
1573=>'AL',
1574=>'AL',
1575=>'AL',
1576=>'AL',
1577=>'AL',
1578=>'AL',
1579=>'AL',
1580=>'AL',
1581=>'AL',
1582=>'AL',
1583=>'AL',
1584=>'AL',
1585=>'AL',
1586=>'AL',
1587=>'AL',
1588=>'AL',
1589=>'AL',
1590=>'AL',
1591=>'AL',
1592=>'AL',
1593=>'AL',
1594=>'AL',
1600=>'AL',
1601=>'AL',
1602=>'AL',
1603=>'AL',
1604=>'AL',
1605=>'AL',
1606=>'AL',
1607=>'AL',
1608=>'AL',
1609=>'AL',
1610=>'AL',
1611=>'NSM',
1612=>'NSM',
1613=>'NSM',
1614=>'NSM',
1615=>'NSM',
1616=>'NSM',
1617=>'NSM',
1618=>'NSM',
1619=>'NSM',
1620=>'NSM',
1621=>'NSM',
1622=>'NSM',
1623=>'NSM',
1624=>'NSM',
1625=>'NSM',
1626=>'NSM',
1627=>'NSM',
1628=>'NSM',
1629=>'NSM',
1630=>'NSM',
1632=>'AN',
1633=>'AN',
1634=>'AN',
1635=>'AN',
1636=>'AN',
1637=>'AN',
1638=>'AN',
1639=>'AN',
1640=>'AN',
1641=>'AN',
1642=>'ET',
1643=>'AN',
1644=>'AN',
1645=>'AL',
1646=>'AL',
1647=>'AL',
1648=>'NSM',
1649=>'AL',
1650=>'AL',
1651=>'AL',
1652=>'AL',
1653=>'AL',
1654=>'AL',
1655=>'AL',
1656=>'AL',
1657=>'AL',
1658=>'AL',
1659=>'AL',
1660=>'AL',
1661=>'AL',
1662=>'AL',
1663=>'AL',
1664=>'AL',
1665=>'AL',
1666=>'AL',
1667=>'AL',
1668=>'AL',
1669=>'AL',
1670=>'AL',
1671=>'AL',
1672=>'AL',
1673=>'AL',
1674=>'AL',
1675=>'AL',
1676=>'AL',
1677=>'AL',
1678=>'AL',
1679=>'AL',
1680=>'AL',
1681=>'AL',
1682=>'AL',
1683=>'AL',
1684=>'AL',
1685=>'AL',
1686=>'AL',
1687=>'AL',
1688=>'AL',
1689=>'AL',
1690=>'AL',
1691=>'AL',
1692=>'AL',
1693=>'AL',
1694=>'AL',
1695=>'AL',
1696=>'AL',
1697=>'AL',
1698=>'AL',
1699=>'AL',
1700=>'AL',
1701=>'AL',
1702=>'AL',
1703=>'AL',
1704=>'AL',
1705=>'AL',
1706=>'AL',
1707=>'AL',
1708=>'AL',
1709=>'AL',
1710=>'AL',
1711=>'AL',
1712=>'AL',
1713=>'AL',
1714=>'AL',
1715=>'AL',
1716=>'AL',
1717=>'AL',
1718=>'AL',
1719=>'AL',
1720=>'AL',
1721=>'AL',
1722=>'AL',
1723=>'AL',
1724=>'AL',
1725=>'AL',
1726=>'AL',
1727=>'AL',
1728=>'AL',
1729=>'AL',
1730=>'AL',
1731=>'AL',
1732=>'AL',
1733=>'AL',
1734=>'AL',
1735=>'AL',
1736=>'AL',
1737=>'AL',
1738=>'AL',
1739=>'AL',
1740=>'AL',
1741=>'AL',
1742=>'AL',
1743=>'AL',
1744=>'AL',
1745=>'AL',
1746=>'AL',
1747=>'AL',
1748=>'AL',
1749=>'AL',
1750=>'NSM',
1751=>'NSM',
1752=>'NSM',
1753=>'NSM',
1754=>'NSM',
1755=>'NSM',
1756=>'NSM',
1757=>'AL',
1758=>'NSM',
1759=>'NSM',
1760=>'NSM',
1761=>'NSM',
1762=>'NSM',
1763=>'NSM',
1764=>'NSM',
1765=>'AL',
1766=>'AL',
1767=>'NSM',
1768=>'NSM',
1769=>'ON',
1770=>'NSM',
1771=>'NSM',
1772=>'NSM',
1773=>'NSM',
1774=>'AL',
1775=>'AL',
1776=>'EN',
1777=>'EN',
1778=>'EN',
1779=>'EN',
1780=>'EN',
1781=>'EN',
1782=>'EN',
1783=>'EN',
1784=>'EN',
1785=>'EN',
1786=>'AL',
1787=>'AL',
1788=>'AL',
1789=>'AL',
1790=>'AL',
1791=>'AL',
1792=>'AL',
1793=>'AL',
1794=>'AL',
1795=>'AL',
1796=>'AL',
1797=>'AL',
1798=>'AL',
1799=>'AL',
1800=>'AL',
1801=>'AL',
1802=>'AL',
1803=>'AL',
1804=>'AL',
1805=>'AL',
1807=>'BN',
1808=>'AL',
1809=>'NSM',
1810=>'AL',
1811=>'AL',
1812=>'AL',
1813=>'AL',
1814=>'AL',
1815=>'AL',
1816=>'AL',
1817=>'AL',
1818=>'AL',
1819=>'AL',
1820=>'AL',
1821=>'AL',
1822=>'AL',
1823=>'AL',
1824=>'AL',
1825=>'AL',
1826=>'AL',
1827=>'AL',
1828=>'AL',
1829=>'AL',
1830=>'AL',
1831=>'AL',
1832=>'AL',
1833=>'AL',
1834=>'AL',
1835=>'AL',
1836=>'AL',
1837=>'AL',
1838=>'AL',
1839=>'AL',
1840=>'NSM',
1841=>'NSM',
1842=>'NSM',
1843=>'NSM',
1844=>'NSM',
1845=>'NSM',
1846=>'NSM',
1847=>'NSM',
1848=>'NSM',
1849=>'NSM',
1850=>'NSM',
1851=>'NSM',
1852=>'NSM',
1853=>'NSM',
1854=>'NSM',
1855=>'NSM',
1856=>'NSM',
1857=>'NSM',
1858=>'NSM',
1859=>'NSM',
1860=>'NSM',
1861=>'NSM',
1862=>'NSM',
1863=>'NSM',
1864=>'NSM',
1865=>'NSM',
1866=>'NSM',
1869=>'AL',
1870=>'AL',
1871=>'AL',
1872=>'AL',
1873=>'AL',
1874=>'AL',
1875=>'AL',
1876=>'AL',
1877=>'AL',
1878=>'AL',
1879=>'AL',
1880=>'AL',
1881=>'AL',
1882=>'AL',
1883=>'AL',
1884=>'AL',
1885=>'AL',
1886=>'AL',
1887=>'AL',
1888=>'AL',
1889=>'AL',
1890=>'AL',
1891=>'AL',
1892=>'AL',
1893=>'AL',
1894=>'AL',
1895=>'AL',
1896=>'AL',
1897=>'AL',
1898=>'AL',
1899=>'AL',
1900=>'AL',
1901=>'AL',
1920=>'AL',
1921=>'AL',
1922=>'AL',
1923=>'AL',
1924=>'AL',
1925=>'AL',
1926=>'AL',
1927=>'AL',
1928=>'AL',
1929=>'AL',
1930=>'AL',
1931=>'AL',
1932=>'AL',
1933=>'AL',
1934=>'AL',
1935=>'AL',
1936=>'AL',
1937=>'AL',
1938=>'AL',
1939=>'AL',
1940=>'AL',
1941=>'AL',
1942=>'AL',
1943=>'AL',
1944=>'AL',
1945=>'AL',
1946=>'AL',
1947=>'AL',
1948=>'AL',
1949=>'AL',
1950=>'AL',
1951=>'AL',
1952=>'AL',
1953=>'AL',
1954=>'AL',
1955=>'AL',
1956=>'AL',
1957=>'AL',
1958=>'NSM',
1959=>'NSM',
1960=>'NSM',
1961=>'NSM',
1962=>'NSM',
1963=>'NSM',
1964=>'NSM',
1965=>'NSM',
1966=>'NSM',
1967=>'NSM',
1968=>'NSM',
1969=>'AL',
1984=>'R',
1985=>'R',
1986=>'R',
1987=>'R',
1988=>'R',
1989=>'R',
1990=>'R',
1991=>'R',
1992=>'R',
1993=>'R',
1994=>'R',
1995=>'R',
1996=>'R',
1997=>'R',
1998=>'R',
1999=>'R',
2000=>'R',
2001=>'R',
2002=>'R',
2003=>'R',
2004=>'R',
2005=>'R',
2006=>'R',
2007=>'R',
2008=>'R',
2009=>'R',
2010=>'R',
2011=>'R',
2012=>'R',
2013=>'R',
2014=>'R',
2015=>'R',
2016=>'R',
2017=>'R',
2018=>'R',
2019=>'R',
2020=>'R',
2021=>'R',
2022=>'R',
2023=>'R',
2024=>'R',
2025=>'R',
2026=>'R',
2027=>'NSM',
2028=>'NSM',
2029=>'NSM',
2030=>'NSM',
2031=>'NSM',
2032=>'NSM',
2033=>'NSM',
2034=>'NSM',
2035=>'NSM',
2036=>'R',
2037=>'R',
2038=>'ON',
2039=>'ON',
2040=>'ON',
2041=>'ON',
2042=>'R',
2305=>'NSM',
2306=>'NSM',
2307=>'L',
2308=>'L',
2309=>'L',
2310=>'L',
2311=>'L',
2312=>'L',
2313=>'L',
2314=>'L',
2315=>'L',
2316=>'L',
2317=>'L',
2318=>'L',
2319=>'L',
2320=>'L',
2321=>'L',
2322=>'L',
2323=>'L',
2324=>'L',
2325=>'L',
2326=>'L',
2327=>'L',
2328=>'L',
2329=>'L',
2330=>'L',
2331=>'L',
2332=>'L',
2333=>'L',
2334=>'L',
2335=>'L',
2336=>'L',
2337=>'L',
2338=>'L',
2339=>'L',
2340=>'L',
2341=>'L',
2342=>'L',
2343=>'L',
2344=>'L',
2345=>'L',
2346=>'L',
2347=>'L',
2348=>'L',
2349=>'L',
2350=>'L',
2351=>'L',
2352=>'L',
2353=>'L',
2354=>'L',
2355=>'L',
2356=>'L',
2357=>'L',
2358=>'L',
2359=>'L',
2360=>'L',
2361=>'L',
2364=>'NSM',
2365=>'L',
2366=>'L',
2367=>'L',
2368=>'L',
2369=>'NSM',
2370=>'NSM',
2371=>'NSM',
2372=>'NSM',
2373=>'NSM',
2374=>'NSM',
2375=>'NSM',
2376=>'NSM',
2377=>'L',
2378=>'L',
2379=>'L',
2380=>'L',
2381=>'NSM',
2384=>'L',
2385=>'NSM',
2386=>'NSM',
2387=>'NSM',
2388=>'NSM',
2392=>'L',
2393=>'L',
2394=>'L',
2395=>'L',
2396=>'L',
2397=>'L',
2398=>'L',
2399=>'L',
2400=>'L',
2401=>'L',
2402=>'NSM',
2403=>'NSM',
2404=>'L',
2405=>'L',
2406=>'L',
2407=>'L',
2408=>'L',
2409=>'L',
2410=>'L',
2411=>'L',
2412=>'L',
2413=>'L',
2414=>'L',
2415=>'L',
2416=>'L',
2427=>'L',
2428=>'L',
2429=>'L',
2430=>'L',
2431=>'L',
2433=>'NSM',
2434=>'L',
2435=>'L',
2437=>'L',
2438=>'L',
2439=>'L',
2440=>'L',
2441=>'L',
2442=>'L',
2443=>'L',
2444=>'L',
2447=>'L',
2448=>'L',
2451=>'L',
2452=>'L',
2453=>'L',
2454=>'L',
2455=>'L',
2456=>'L',
2457=>'L',
2458=>'L',
2459=>'L',
2460=>'L',
2461=>'L',
2462=>'L',
2463=>'L',
2464=>'L',
2465=>'L',
2466=>'L',
2467=>'L',
2468=>'L',
2469=>'L',
2470=>'L',
2471=>'L',
2472=>'L',
2474=>'L',
2475=>'L',
2476=>'L',
2477=>'L',
2478=>'L',
2479=>'L',
2480=>'L',
2482=>'L',
2486=>'L',
2487=>'L',
2488=>'L',
2489=>'L',
2492=>'NSM',
2493=>'L',
2494=>'L',
2495=>'L',
2496=>'L',
2497=>'NSM',
2498=>'NSM',
2499=>'NSM',
2500=>'NSM',
2503=>'L',
2504=>'L',
2507=>'L',
2508=>'L',
2509=>'NSM',
2510=>'L',
2519=>'L',
2524=>'L',
2525=>'L',
2527=>'L',
2528=>'L',
2529=>'L',
2530=>'NSM',
2531=>'NSM',
2534=>'L',
2535=>'L',
2536=>'L',
2537=>'L',
2538=>'L',
2539=>'L',
2540=>'L',
2541=>'L',
2542=>'L',
2543=>'L',
2544=>'L',
2545=>'L',
2546=>'ET',
2547=>'ET',
2548=>'L',
2549=>'L',
2550=>'L',
2551=>'L',
2552=>'L',
2553=>'L',
2554=>'L',
2561=>'NSM',
2562=>'NSM',
2563=>'L',
2565=>'L',
2566=>'L',
2567=>'L',
2568=>'L',
2569=>'L',
2570=>'L',
2575=>'L',
2576=>'L',
2579=>'L',
2580=>'L',
2581=>'L',
2582=>'L',
2583=>'L',
2584=>'L',
2585=>'L',
2586=>'L',
2587=>'L',
2588=>'L',
2589=>'L',
2590=>'L',
2591=>'L',
2592=>'L',
2593=>'L',
2594=>'L',
2595=>'L',
2596=>'L',
2597=>'L',
2598=>'L',
2599=>'L',
2600=>'L',
2602=>'L',
2603=>'L',
2604=>'L',
2605=>'L',
2606=>'L',
2607=>'L',
2608=>'L',
2610=>'L',
2611=>'L',
2613=>'L',
2614=>'L',
2616=>'L',
2617=>'L',
2620=>'NSM',
2622=>'L',
2623=>'L',
2624=>'L',
2625=>'NSM',
2626=>'NSM',
2631=>'NSM',
2632=>'NSM',
2635=>'NSM',
2636=>'NSM',
2637=>'NSM',
2649=>'L',
2650=>'L',
2651=>'L',
2652=>'L',
2654=>'L',
2662=>'L',
2663=>'L',
2664=>'L',
2665=>'L',
2666=>'L',
2667=>'L',
2668=>'L',
2669=>'L',
2670=>'L',
2671=>'L',
2672=>'NSM',
2673=>'NSM',
2674=>'L',
2675=>'L',
2676=>'L',
2689=>'NSM',
2690=>'NSM',
2691=>'L',
2693=>'L',
2694=>'L',
2695=>'L',
2696=>'L',
2697=>'L',
2698=>'L',
2699=>'L',
2700=>'L',
2701=>'L',
2703=>'L',
2704=>'L',
2705=>'L',
2707=>'L',
2708=>'L',
2709=>'L',
2710=>'L',
2711=>'L',
2712=>'L',
2713=>'L',
2714=>'L',
2715=>'L',
2716=>'L',
2717=>'L',
2718=>'L',
2719=>'L',
2720=>'L',
2721=>'L',
2722=>'L',
2723=>'L',
2724=>'L',
2725=>'L',
2726=>'L',
2727=>'L',
2728=>'L',
2730=>'L',
2731=>'L',
2732=>'L',
2733=>'L',
2734=>'L',
2735=>'L',
2736=>'L',
2738=>'L',
2739=>'L',
2741=>'L',
2742=>'L',
2743=>'L',
2744=>'L',
2745=>'L',
2748=>'NSM',
2749=>'L',
2750=>'L',
2751=>'L',
2752=>'L',
2753=>'NSM',
2754=>'NSM',
2755=>'NSM',
2756=>'NSM',
2757=>'NSM',
2759=>'NSM',
2760=>'NSM',
2761=>'L',
2763=>'L',
2764=>'L',
2765=>'NSM',
2768=>'L',
2784=>'L',
2785=>'L',
2786=>'NSM',
2787=>'NSM',
2790=>'L',
2791=>'L',
2792=>'L',
2793=>'L',
2794=>'L',
2795=>'L',
2796=>'L',
2797=>'L',
2798=>'L',
2799=>'L',
2801=>'ET',
2817=>'NSM',
2818=>'L',
2819=>'L',
2821=>'L',
2822=>'L',
2823=>'L',
2824=>'L',
2825=>'L',
2826=>'L',
2827=>'L',
2828=>'L',
2831=>'L',
2832=>'L',
2835=>'L',
2836=>'L',
2837=>'L',
2838=>'L',
2839=>'L',
2840=>'L',
2841=>'L',
2842=>'L',
2843=>'L',
2844=>'L',
2845=>'L',
2846=>'L',
2847=>'L',
2848=>'L',
2849=>'L',
2850=>'L',
2851=>'L',
2852=>'L',
2853=>'L',
2854=>'L',
2855=>'L',
2856=>'L',
2858=>'L',
2859=>'L',
2860=>'L',
2861=>'L',
2862=>'L',
2863=>'L',
2864=>'L',
2866=>'L',
2867=>'L',
2869=>'L',
2870=>'L',
2871=>'L',
2872=>'L',
2873=>'L',
2876=>'NSM',
2877=>'L',
2878=>'L',
2879=>'NSM',
2880=>'L',
2881=>'NSM',
2882=>'NSM',
2883=>'NSM',
2887=>'L',
2888=>'L',
2891=>'L',
2892=>'L',
2893=>'NSM',
2902=>'NSM',
2903=>'L',
2908=>'L',
2909=>'L',
2911=>'L',
2912=>'L',
2913=>'L',
2918=>'L',
2919=>'L',
2920=>'L',
2921=>'L',
2922=>'L',
2923=>'L',
2924=>'L',
2925=>'L',
2926=>'L',
2927=>'L',
2928=>'L',
2929=>'L',
2946=>'NSM',
2947=>'L',
2949=>'L',
2950=>'L',
2951=>'L',
2952=>'L',
2953=>'L',
2954=>'L',
2958=>'L',
2959=>'L',
2960=>'L',
2962=>'L',
2963=>'L',
2964=>'L',
2965=>'L',
2969=>'L',
2970=>'L',
2972=>'L',
2974=>'L',
2975=>'L',
2979=>'L',
2980=>'L',
2984=>'L',
2985=>'L',
2986=>'L',
2990=>'L',
2991=>'L',
2992=>'L',
2993=>'L',
2994=>'L',
2995=>'L',
2996=>'L',
2997=>'L',
2998=>'L',
2999=>'L',
3000=>'L',
3001=>'L',
3006=>'L',
3007=>'L',
3008=>'NSM',
3009=>'L',
3010=>'L',
3014=>'L',
3015=>'L',
3016=>'L',
3018=>'L',
3019=>'L',
3020=>'L',
3021=>'NSM',
3031=>'L',
3046=>'L',
3047=>'L',
3048=>'L',
3049=>'L',
3050=>'L',
3051=>'L',
3052=>'L',
3053=>'L',
3054=>'L',
3055=>'L',
3056=>'L',
3057=>'L',
3058=>'L',
3059=>'ON',
3060=>'ON',
3061=>'ON',
3062=>'ON',
3063=>'ON',
3064=>'ON',
3065=>'ET',
3066=>'ON',
3073=>'L',
3074=>'L',
3075=>'L',
3077=>'L',
3078=>'L',
3079=>'L',
3080=>'L',
3081=>'L',
3082=>'L',
3083=>'L',
3084=>'L',
3086=>'L',
3087=>'L',
3088=>'L',
3090=>'L',
3091=>'L',
3092=>'L',
3093=>'L',
3094=>'L',
3095=>'L',
3096=>'L',
3097=>'L',
3098=>'L',
3099=>'L',
3100=>'L',
3101=>'L',
3102=>'L',
3103=>'L',
3104=>'L',
3105=>'L',
3106=>'L',
3107=>'L',
3108=>'L',
3109=>'L',
3110=>'L',
3111=>'L',
3112=>'L',
3114=>'L',
3115=>'L',
3116=>'L',
3117=>'L',
3118=>'L',
3119=>'L',
3120=>'L',
3121=>'L',
3122=>'L',
3123=>'L',
3125=>'L',
3126=>'L',
3127=>'L',
3128=>'L',
3129=>'L',
3134=>'NSM',
3135=>'NSM',
3136=>'NSM',
3137=>'L',
3138=>'L',
3139=>'L',
3140=>'L',
3142=>'NSM',
3143=>'NSM',
3144=>'NSM',
3146=>'NSM',
3147=>'NSM',
3148=>'NSM',
3149=>'NSM',
3157=>'NSM',
3158=>'NSM',
3168=>'L',
3169=>'L',
3174=>'L',
3175=>'L',
3176=>'L',
3177=>'L',
3178=>'L',
3179=>'L',
3180=>'L',
3181=>'L',
3182=>'L',
3183=>'L',
3202=>'L',
3203=>'L',
3205=>'L',
3206=>'L',
3207=>'L',
3208=>'L',
3209=>'L',
3210=>'L',
3211=>'L',
3212=>'L',
3214=>'L',
3215=>'L',
3216=>'L',
3218=>'L',
3219=>'L',
3220=>'L',
3221=>'L',
3222=>'L',
3223=>'L',
3224=>'L',
3225=>'L',
3226=>'L',
3227=>'L',
3228=>'L',
3229=>'L',
3230=>'L',
3231=>'L',
3232=>'L',
3233=>'L',
3234=>'L',
3235=>'L',
3236=>'L',
3237=>'L',
3238=>'L',
3239=>'L',
3240=>'L',
3242=>'L',
3243=>'L',
3244=>'L',
3245=>'L',
3246=>'L',
3247=>'L',
3248=>'L',
3249=>'L',
3250=>'L',
3251=>'L',
3253=>'L',
3254=>'L',
3255=>'L',
3256=>'L',
3257=>'L',
3260=>'NSM',
3261=>'L',
3262=>'L',
3263=>'L',
3264=>'L',
3265=>'L',
3266=>'L',
3267=>'L',
3268=>'L',
3270=>'L',
3271=>'L',
3272=>'L',
3274=>'L',
3275=>'L',
3276=>'NSM',
3277=>'NSM',
3285=>'L',
3286=>'L',
3294=>'L',
3296=>'L',
3297=>'L',
3298=>'NSM',
3299=>'NSM',
3302=>'L',
3303=>'L',
3304=>'L',
3305=>'L',
3306=>'L',
3307=>'L',
3308=>'L',
3309=>'L',
3310=>'L',
3311=>'L',
3313=>'ON',
3314=>'ON',
3330=>'L',
3331=>'L',
3333=>'L',
3334=>'L',
3335=>'L',
3336=>'L',
3337=>'L',
3338=>'L',
3339=>'L',
3340=>'L',
3342=>'L',
3343=>'L',
3344=>'L',
3346=>'L',
3347=>'L',
3348=>'L',
3349=>'L',
3350=>'L',
3351=>'L',
3352=>'L',
3353=>'L',
3354=>'L',
3355=>'L',
3356=>'L',
3357=>'L',
3358=>'L',
3359=>'L',
3360=>'L',
3361=>'L',
3362=>'L',
3363=>'L',
3364=>'L',
3365=>'L',
3366=>'L',
3367=>'L',
3368=>'L',
3370=>'L',
3371=>'L',
3372=>'L',
3373=>'L',
3374=>'L',
3375=>'L',
3376=>'L',
3377=>'L',
3378=>'L',
3379=>'L',
3380=>'L',
3381=>'L',
3382=>'L',
3383=>'L',
3384=>'L',
3385=>'L',
3390=>'L',
3391=>'L',
3392=>'L',
3393=>'NSM',
3394=>'NSM',
3395=>'NSM',
3398=>'L',
3399=>'L',
3400=>'L',
3402=>'L',
3403=>'L',
3404=>'L',
3405=>'NSM',
3415=>'L',
3424=>'L',
3425=>'L',
3430=>'L',
3431=>'L',
3432=>'L',
3433=>'L',
3434=>'L',
3435=>'L',
3436=>'L',
3437=>'L',
3438=>'L',
3439=>'L',
3458=>'L',
3459=>'L',
3461=>'L',
3462=>'L',
3463=>'L',
3464=>'L',
3465=>'L',
3466=>'L',
3467=>'L',
3468=>'L',
3469=>'L',
3470=>'L',
3471=>'L',
3472=>'L',
3473=>'L',
3474=>'L',
3475=>'L',
3476=>'L',
3477=>'L',
3478=>'L',
3482=>'L',
3483=>'L',
3484=>'L',
3485=>'L',
3486=>'L',
3487=>'L',
3488=>'L',
3489=>'L',
3490=>'L',
3491=>'L',
3492=>'L',
3493=>'L',
3494=>'L',
3495=>'L',
3496=>'L',
3497=>'L',
3498=>'L',
3499=>'L',
3500=>'L',
3501=>'L',
3502=>'L',
3503=>'L',
3504=>'L',
3505=>'L',
3507=>'L',
3508=>'L',
3509=>'L',
3510=>'L',
3511=>'L',
3512=>'L',
3513=>'L',
3514=>'L',
3515=>'L',
3517=>'L',
3520=>'L',
3521=>'L',
3522=>'L',
3523=>'L',
3524=>'L',
3525=>'L',
3526=>'L',
3530=>'NSM',
3535=>'L',
3536=>'L',
3537=>'L',
3538=>'NSM',
3539=>'NSM',
3540=>'NSM',
3542=>'NSM',
3544=>'L',
3545=>'L',
3546=>'L',
3547=>'L',
3548=>'L',
3549=>'L',
3550=>'L',
3551=>'L',
3570=>'L',
3571=>'L',
3572=>'L',
3585=>'L',
3586=>'L',
3587=>'L',
3588=>'L',
3589=>'L',
3590=>'L',
3591=>'L',
3592=>'L',
3593=>'L',
3594=>'L',
3595=>'L',
3596=>'L',
3597=>'L',
3598=>'L',
3599=>'L',
3600=>'L',
3601=>'L',
3602=>'L',
3603=>'L',
3604=>'L',
3605=>'L',
3606=>'L',
3607=>'L',
3608=>'L',
3609=>'L',
3610=>'L',
3611=>'L',
3612=>'L',
3613=>'L',
3614=>'L',
3615=>'L',
3616=>'L',
3617=>'L',
3618=>'L',
3619=>'L',
3620=>'L',
3621=>'L',
3622=>'L',
3623=>'L',
3624=>'L',
3625=>'L',
3626=>'L',
3627=>'L',
3628=>'L',
3629=>'L',
3630=>'L',
3631=>'L',
3632=>'L',
3633=>'NSM',
3634=>'L',
3635=>'L',
3636=>'NSM',
3637=>'NSM',
3638=>'NSM',
3639=>'NSM',
3640=>'NSM',
3641=>'NSM',
3642=>'NSM',
3647=>'ET',
3648=>'L',
3649=>'L',
3650=>'L',
3651=>'L',
3652=>'L',
3653=>'L',
3654=>'L',
3655=>'NSM',
3656=>'NSM',
3657=>'NSM',
3658=>'NSM',
3659=>'NSM',
3660=>'NSM',
3661=>'NSM',
3662=>'NSM',
3663=>'L',
3664=>'L',
3665=>'L',
3666=>'L',
3667=>'L',
3668=>'L',
3669=>'L',
3670=>'L',
3671=>'L',
3672=>'L',
3673=>'L',
3674=>'L',
3675=>'L',
3713=>'L',
3714=>'L',
3716=>'L',
3719=>'L',
3720=>'L',
3722=>'L',
3725=>'L',
3732=>'L',
3733=>'L',
3734=>'L',
3735=>'L',
3737=>'L',
3738=>'L',
3739=>'L',
3740=>'L',
3741=>'L',
3742=>'L',
3743=>'L',
3745=>'L',
3746=>'L',
3747=>'L',
3749=>'L',
3751=>'L',
3754=>'L',
3755=>'L',
3757=>'L',
3758=>'L',
3759=>'L',
3760=>'L',
3761=>'NSM',
3762=>'L',
3763=>'L',
3764=>'NSM',
3765=>'NSM',
3766=>'NSM',
3767=>'NSM',
3768=>'NSM',
3769=>'NSM',
3771=>'NSM',
3772=>'NSM',
3773=>'L',
3776=>'L',
3777=>'L',
3778=>'L',
3779=>'L',
3780=>'L',
3782=>'L',
3784=>'NSM',
3785=>'NSM',
3786=>'NSM',
3787=>'NSM',
3788=>'NSM',
3789=>'NSM',
3792=>'L',
3793=>'L',
3794=>'L',
3795=>'L',
3796=>'L',
3797=>'L',
3798=>'L',
3799=>'L',
3800=>'L',
3801=>'L',
3804=>'L',
3805=>'L',
3840=>'L',
3841=>'L',
3842=>'L',
3843=>'L',
3844=>'L',
3845=>'L',
3846=>'L',
3847=>'L',
3848=>'L',
3849=>'L',
3850=>'L',
3851=>'L',
3852=>'L',
3853=>'L',
3854=>'L',
3855=>'L',
3856=>'L',
3857=>'L',
3858=>'L',
3859=>'L',
3860=>'L',
3861=>'L',
3862=>'L',
3863=>'L',
3864=>'NSM',
3865=>'NSM',
3866=>'L',
3867=>'L',
3868=>'L',
3869=>'L',
3870=>'L',
3871=>'L',
3872=>'L',
3873=>'L',
3874=>'L',
3875=>'L',
3876=>'L',
3877=>'L',
3878=>'L',
3879=>'L',
3880=>'L',
3881=>'L',
3882=>'L',
3883=>'L',
3884=>'L',
3885=>'L',
3886=>'L',
3887=>'L',
3888=>'L',
3889=>'L',
3890=>'L',
3891=>'L',
3892=>'L',
3893=>'NSM',
3894=>'L',
3895=>'NSM',
3896=>'L',
3897=>'NSM',
3898=>'ON',
3899=>'ON',
3900=>'ON',
3901=>'ON',
3902=>'L',
3903=>'L',
3904=>'L',
3905=>'L',
3906=>'L',
3907=>'L',
3908=>'L',
3909=>'L',
3910=>'L',
3911=>'L',
3913=>'L',
3914=>'L',
3915=>'L',
3916=>'L',
3917=>'L',
3918=>'L',
3919=>'L',
3920=>'L',
3921=>'L',
3922=>'L',
3923=>'L',
3924=>'L',
3925=>'L',
3926=>'L',
3927=>'L',
3928=>'L',
3929=>'L',
3930=>'L',
3931=>'L',
3932=>'L',
3933=>'L',
3934=>'L',
3935=>'L',
3936=>'L',
3937=>'L',
3938=>'L',
3939=>'L',
3940=>'L',
3941=>'L',
3942=>'L',
3943=>'L',
3944=>'L',
3945=>'L',
3946=>'L',
3953=>'NSM',
3954=>'NSM',
3955=>'NSM',
3956=>'NSM',
3957=>'NSM',
3958=>'NSM',
3959=>'NSM',
3960=>'NSM',
3961=>'NSM',
3962=>'NSM',
3963=>'NSM',
3964=>'NSM',
3965=>'NSM',
3966=>'NSM',
3967=>'L',
3968=>'NSM',
3969=>'NSM',
3970=>'NSM',
3971=>'NSM',
3972=>'NSM',
3973=>'L',
3974=>'NSM',
3975=>'NSM',
3976=>'L',
3977=>'L',
3978=>'L',
3979=>'L',
3984=>'NSM',
3985=>'NSM',
3986=>'NSM',
3987=>'NSM',
3988=>'NSM',
3989=>'NSM',
3990=>'NSM',
3991=>'NSM',
3993=>'NSM',
3994=>'NSM',
3995=>'NSM',
3996=>'NSM',
3997=>'NSM',
3998=>'NSM',
3999=>'NSM',
4000=>'NSM',
4001=>'NSM',
4002=>'NSM',
4003=>'NSM',
4004=>'NSM',
4005=>'NSM',
4006=>'NSM',
4007=>'NSM',
4008=>'NSM',
4009=>'NSM',
4010=>'NSM',
4011=>'NSM',
4012=>'NSM',
4013=>'NSM',
4014=>'NSM',
4015=>'NSM',
4016=>'NSM',
4017=>'NSM',
4018=>'NSM',
4019=>'NSM',
4020=>'NSM',
4021=>'NSM',
4022=>'NSM',
4023=>'NSM',
4024=>'NSM',
4025=>'NSM',
4026=>'NSM',
4027=>'NSM',
4028=>'NSM',
4030=>'L',
4031=>'L',
4032=>'L',
4033=>'L',
4034=>'L',
4035=>'L',
4036=>'L',
4037=>'L',
4038=>'NSM',
4039=>'L',
4040=>'L',
4041=>'L',
4042=>'L',
4043=>'L',
4044=>'L',
4047=>'L',
4048=>'L',
4049=>'L',
4096=>'L',
4097=>'L',
4098=>'L',
4099=>'L',
4100=>'L',
4101=>'L',
4102=>'L',
4103=>'L',
4104=>'L',
4105=>'L',
4106=>'L',
4107=>'L',
4108=>'L',
4109=>'L',
4110=>'L',
4111=>'L',
4112=>'L',
4113=>'L',
4114=>'L',
4115=>'L',
4116=>'L',
4117=>'L',
4118=>'L',
4119=>'L',
4120=>'L',
4121=>'L',
4122=>'L',
4123=>'L',
4124=>'L',
4125=>'L',
4126=>'L',
4127=>'L',
4128=>'L',
4129=>'L',
4131=>'L',
4132=>'L',
4133=>'L',
4134=>'L',
4135=>'L',
4137=>'L',
4138=>'L',
4140=>'L',
4141=>'NSM',
4142=>'NSM',
4143=>'NSM',
4144=>'NSM',
4145=>'L',
4146=>'NSM',
4150=>'NSM',
4151=>'NSM',
4152=>'L',
4153=>'NSM',
4160=>'L',
4161=>'L',
4162=>'L',
4163=>'L',
4164=>'L',
4165=>'L',
4166=>'L',
4167=>'L',
4168=>'L',
4169=>'L',
4170=>'L',
4171=>'L',
4172=>'L',
4173=>'L',
4174=>'L',
4175=>'L',
4176=>'L',
4177=>'L',
4178=>'L',
4179=>'L',
4180=>'L',
4181=>'L',
4182=>'L',
4183=>'L',
4184=>'NSM',
4185=>'NSM',
4256=>'L',
4257=>'L',
4258=>'L',
4259=>'L',
4260=>'L',
4261=>'L',
4262=>'L',
4263=>'L',
4264=>'L',
4265=>'L',
4266=>'L',
4267=>'L',
4268=>'L',
4269=>'L',
4270=>'L',
4271=>'L',
4272=>'L',
4273=>'L',
4274=>'L',
4275=>'L',
4276=>'L',
4277=>'L',
4278=>'L',
4279=>'L',
4280=>'L',
4281=>'L',
4282=>'L',
4283=>'L',
4284=>'L',
4285=>'L',
4286=>'L',
4287=>'L',
4288=>'L',
4289=>'L',
4290=>'L',
4291=>'L',
4292=>'L',
4293=>'L',
4304=>'L',
4305=>'L',
4306=>'L',
4307=>'L',
4308=>'L',
4309=>'L',
4310=>'L',
4311=>'L',
4312=>'L',
4313=>'L',
4314=>'L',
4315=>'L',
4316=>'L',
4317=>'L',
4318=>'L',
4319=>'L',
4320=>'L',
4321=>'L',
4322=>'L',
4323=>'L',
4324=>'L',
4325=>'L',
4326=>'L',
4327=>'L',
4328=>'L',
4329=>'L',
4330=>'L',
4331=>'L',
4332=>'L',
4333=>'L',
4334=>'L',
4335=>'L',
4336=>'L',
4337=>'L',
4338=>'L',
4339=>'L',
4340=>'L',
4341=>'L',
4342=>'L',
4343=>'L',
4344=>'L',
4345=>'L',
4346=>'L',
4347=>'L',
4348=>'L',
4352=>'L',
4353=>'L',
4354=>'L',
4355=>'L',
4356=>'L',
4357=>'L',
4358=>'L',
4359=>'L',
4360=>'L',
4361=>'L',
4362=>'L',
4363=>'L',
4364=>'L',
4365=>'L',
4366=>'L',
4367=>'L',
4368=>'L',
4369=>'L',
4370=>'L',
4371=>'L',
4372=>'L',
4373=>'L',
4374=>'L',
4375=>'L',
4376=>'L',
4377=>'L',
4378=>'L',
4379=>'L',
4380=>'L',
4381=>'L',
4382=>'L',
4383=>'L',
4384=>'L',
4385=>'L',
4386=>'L',
4387=>'L',
4388=>'L',
4389=>'L',
4390=>'L',
4391=>'L',
4392=>'L',
4393=>'L',
4394=>'L',
4395=>'L',
4396=>'L',
4397=>'L',
4398=>'L',
4399=>'L',
4400=>'L',
4401=>'L',
4402=>'L',
4403=>'L',
4404=>'L',
4405=>'L',
4406=>'L',
4407=>'L',
4408=>'L',
4409=>'L',
4410=>'L',
4411=>'L',
4412=>'L',
4413=>'L',
4414=>'L',
4415=>'L',
4416=>'L',
4417=>'L',
4418=>'L',
4419=>'L',
4420=>'L',
4421=>'L',
4422=>'L',
4423=>'L',
4424=>'L',
4425=>'L',
4426=>'L',
4427=>'L',
4428=>'L',
4429=>'L',
4430=>'L',
4431=>'L',
4432=>'L',
4433=>'L',
4434=>'L',
4435=>'L',
4436=>'L',
4437=>'L',
4438=>'L',
4439=>'L',
4440=>'L',
4441=>'L',
4447=>'L',
4448=>'L',
4449=>'L',
4450=>'L',
4451=>'L',
4452=>'L',
4453=>'L',
4454=>'L',
4455=>'L',
4456=>'L',
4457=>'L',
4458=>'L',
4459=>'L',
4460=>'L',
4461=>'L',
4462=>'L',
4463=>'L',
4464=>'L',
4465=>'L',
4466=>'L',
4467=>'L',
4468=>'L',
4469=>'L',
4470=>'L',
4471=>'L',
4472=>'L',
4473=>'L',
4474=>'L',
4475=>'L',
4476=>'L',
4477=>'L',
4478=>'L',
4479=>'L',
4480=>'L',
4481=>'L',
4482=>'L',
4483=>'L',
4484=>'L',
4485=>'L',
4486=>'L',
4487=>'L',
4488=>'L',
4489=>'L',
4490=>'L',
4491=>'L',
4492=>'L',
4493=>'L',
4494=>'L',
4495=>'L',
4496=>'L',
4497=>'L',
4498=>'L',
4499=>'L',
4500=>'L',
4501=>'L',
4502=>'L',
4503=>'L',
4504=>'L',
4505=>'L',
4506=>'L',
4507=>'L',
4508=>'L',
4509=>'L',
4510=>'L',
4511=>'L',
4512=>'L',
4513=>'L',
4514=>'L',
4520=>'L',
4521=>'L',
4522=>'L',
4523=>'L',
4524=>'L',
4525=>'L',
4526=>'L',
4527=>'L',
4528=>'L',
4529=>'L',
4530=>'L',
4531=>'L',
4532=>'L',
4533=>'L',
4534=>'L',
4535=>'L',
4536=>'L',
4537=>'L',
4538=>'L',
4539=>'L',
4540=>'L',
4541=>'L',
4542=>'L',
4543=>'L',
4544=>'L',
4545=>'L',
4546=>'L',
4547=>'L',
4548=>'L',
4549=>'L',
4550=>'L',
4551=>'L',
4552=>'L',
4553=>'L',
4554=>'L',
4555=>'L',
4556=>'L',
4557=>'L',
4558=>'L',
4559=>'L',
4560=>'L',
4561=>'L',
4562=>'L',
4563=>'L',
4564=>'L',
4565=>'L',
4566=>'L',
4567=>'L',
4568=>'L',
4569=>'L',
4570=>'L',
4571=>'L',
4572=>'L',
4573=>'L',
4574=>'L',
4575=>'L',
4576=>'L',
4577=>'L',
4578=>'L',
4579=>'L',
4580=>'L',
4581=>'L',
4582=>'L',
4583=>'L',
4584=>'L',
4585=>'L',
4586=>'L',
4587=>'L',
4588=>'L',
4589=>'L',
4590=>'L',
4591=>'L',
4592=>'L',
4593=>'L',
4594=>'L',
4595=>'L',
4596=>'L',
4597=>'L',
4598=>'L',
4599=>'L',
4600=>'L',
4601=>'L',
4608=>'L',
4609=>'L',
4610=>'L',
4611=>'L',
4612=>'L',
4613=>'L',
4614=>'L',
4615=>'L',
4616=>'L',
4617=>'L',
4618=>'L',
4619=>'L',
4620=>'L',
4621=>'L',
4622=>'L',
4623=>'L',
4624=>'L',
4625=>'L',
4626=>'L',
4627=>'L',
4628=>'L',
4629=>'L',
4630=>'L',
4631=>'L',
4632=>'L',
4633=>'L',
4634=>'L',
4635=>'L',
4636=>'L',
4637=>'L',
4638=>'L',
4639=>'L',
4640=>'L',
4641=>'L',
4642=>'L',
4643=>'L',
4644=>'L',
4645=>'L',
4646=>'L',
4647=>'L',
4648=>'L',
4649=>'L',
4650=>'L',
4651=>'L',
4652=>'L',
4653=>'L',
4654=>'L',
4655=>'L',
4656=>'L',
4657=>'L',
4658=>'L',
4659=>'L',
4660=>'L',
4661=>'L',
4662=>'L',
4663=>'L',
4664=>'L',
4665=>'L',
4666=>'L',
4667=>'L',
4668=>'L',
4669=>'L',
4670=>'L',
4671=>'L',
4672=>'L',
4673=>'L',
4674=>'L',
4675=>'L',
4676=>'L',
4677=>'L',
4678=>'L',
4679=>'L',
4680=>'L',
4682=>'L',
4683=>'L',
4684=>'L',
4685=>'L',
4688=>'L',
4689=>'L',
4690=>'L',
4691=>'L',
4692=>'L',
4693=>'L',
4694=>'L',
4696=>'L',
4698=>'L',
4699=>'L',
4700=>'L',
4701=>'L',
4704=>'L',
4705=>'L',
4706=>'L',
4707=>'L',
4708=>'L',
4709=>'L',
4710=>'L',
4711=>'L',
4712=>'L',
4713=>'L',
4714=>'L',
4715=>'L',
4716=>'L',
4717=>'L',
4718=>'L',
4719=>'L',
4720=>'L',
4721=>'L',
4722=>'L',
4723=>'L',
4724=>'L',
4725=>'L',
4726=>'L',
4727=>'L',
4728=>'L',
4729=>'L',
4730=>'L',
4731=>'L',
4732=>'L',
4733=>'L',
4734=>'L',
4735=>'L',
4736=>'L',
4737=>'L',
4738=>'L',
4739=>'L',
4740=>'L',
4741=>'L',
4742=>'L',
4743=>'L',
4744=>'L',
4746=>'L',
4747=>'L',
4748=>'L',
4749=>'L',
4752=>'L',
4753=>'L',
4754=>'L',
4755=>'L',
4756=>'L',
4757=>'L',
4758=>'L',
4759=>'L',
4760=>'L',
4761=>'L',
4762=>'L',
4763=>'L',
4764=>'L',
4765=>'L',
4766=>'L',
4767=>'L',
4768=>'L',
4769=>'L',
4770=>'L',
4771=>'L',
4772=>'L',
4773=>'L',
4774=>'L',
4775=>'L',
4776=>'L',
4777=>'L',
4778=>'L',
4779=>'L',
4780=>'L',
4781=>'L',
4782=>'L',
4783=>'L',
4784=>'L',
4786=>'L',
4787=>'L',
4788=>'L',
4789=>'L',
4792=>'L',
4793=>'L',
4794=>'L',
4795=>'L',
4796=>'L',
4797=>'L',
4798=>'L',
4800=>'L',
4802=>'L',
4803=>'L',
4804=>'L',
4805=>'L',
4808=>'L',
4809=>'L',
4810=>'L',
4811=>'L',
4812=>'L',
4813=>'L',
4814=>'L',
4815=>'L',
4816=>'L',
4817=>'L',
4818=>'L',
4819=>'L',
4820=>'L',
4821=>'L',
4822=>'L',
4824=>'L',
4825=>'L',
4826=>'L',
4827=>'L',
4828=>'L',
4829=>'L',
4830=>'L',
4831=>'L',
4832=>'L',
4833=>'L',
4834=>'L',
4835=>'L',
4836=>'L',
4837=>'L',
4838=>'L',
4839=>'L',
4840=>'L',
4841=>'L',
4842=>'L',
4843=>'L',
4844=>'L',
4845=>'L',
4846=>'L',
4847=>'L',
4848=>'L',
4849=>'L',
4850=>'L',
4851=>'L',
4852=>'L',
4853=>'L',
4854=>'L',
4855=>'L',
4856=>'L',
4857=>'L',
4858=>'L',
4859=>'L',
4860=>'L',
4861=>'L',
4862=>'L',
4863=>'L',
4864=>'L',
4865=>'L',
4866=>'L',
4867=>'L',
4868=>'L',
4869=>'L',
4870=>'L',
4871=>'L',
4872=>'L',
4873=>'L',
4874=>'L',
4875=>'L',
4876=>'L',
4877=>'L',
4878=>'L',
4879=>'L',
4880=>'L',
4882=>'L',
4883=>'L',
4884=>'L',
4885=>'L',
4888=>'L',
4889=>'L',
4890=>'L',
4891=>'L',
4892=>'L',
4893=>'L',
4894=>'L',
4895=>'L',
4896=>'L',
4897=>'L',
4898=>'L',
4899=>'L',
4900=>'L',
4901=>'L',
4902=>'L',
4903=>'L',
4904=>'L',
4905=>'L',
4906=>'L',
4907=>'L',
4908=>'L',
4909=>'L',
4910=>'L',
4911=>'L',
4912=>'L',
4913=>'L',
4914=>'L',
4915=>'L',
4916=>'L',
4917=>'L',
4918=>'L',
4919=>'L',
4920=>'L',
4921=>'L',
4922=>'L',
4923=>'L',
4924=>'L',
4925=>'L',
4926=>'L',
4927=>'L',
4928=>'L',
4929=>'L',
4930=>'L',
4931=>'L',
4932=>'L',
4933=>'L',
4934=>'L',
4935=>'L',
4936=>'L',
4937=>'L',
4938=>'L',
4939=>'L',
4940=>'L',
4941=>'L',
4942=>'L',
4943=>'L',
4944=>'L',
4945=>'L',
4946=>'L',
4947=>'L',
4948=>'L',
4949=>'L',
4950=>'L',
4951=>'L',
4952=>'L',
4953=>'L',
4954=>'L',
4959=>'NSM',
4960=>'L',
4961=>'L',
4962=>'L',
4963=>'L',
4964=>'L',
4965=>'L',
4966=>'L',
4967=>'L',
4968=>'L',
4969=>'L',
4970=>'L',
4971=>'L',
4972=>'L',
4973=>'L',
4974=>'L',
4975=>'L',
4976=>'L',
4977=>'L',
4978=>'L',
4979=>'L',
4980=>'L',
4981=>'L',
4982=>'L',
4983=>'L',
4984=>'L',
4985=>'L',
4986=>'L',
4987=>'L',
4988=>'L',
4992=>'L',
4993=>'L',
4994=>'L',
4995=>'L',
4996=>'L',
4997=>'L',
4998=>'L',
4999=>'L',
5000=>'L',
5001=>'L',
5002=>'L',
5003=>'L',
5004=>'L',
5005=>'L',
5006=>'L',
5007=>'L',
5008=>'ON',
5009=>'ON',
5010=>'ON',
5011=>'ON',
5012=>'ON',
5013=>'ON',
5014=>'ON',
5015=>'ON',
5016=>'ON',
5017=>'ON',
5024=>'L',
5025=>'L',
5026=>'L',
5027=>'L',
5028=>'L',
5029=>'L',
5030=>'L',
5031=>'L',
5032=>'L',
5033=>'L',
5034=>'L',
5035=>'L',
5036=>'L',
5037=>'L',
5038=>'L',
5039=>'L',
5040=>'L',
5041=>'L',
5042=>'L',
5043=>'L',
5044=>'L',
5045=>'L',
5046=>'L',
5047=>'L',
5048=>'L',
5049=>'L',
5050=>'L',
5051=>'L',
5052=>'L',
5053=>'L',
5054=>'L',
5055=>'L',
5056=>'L',
5057=>'L',
5058=>'L',
5059=>'L',
5060=>'L',
5061=>'L',
5062=>'L',
5063=>'L',
5064=>'L',
5065=>'L',
5066=>'L',
5067=>'L',
5068=>'L',
5069=>'L',
5070=>'L',
5071=>'L',
5072=>'L',
5073=>'L',
5074=>'L',
5075=>'L',
5076=>'L',
5077=>'L',
5078=>'L',
5079=>'L',
5080=>'L',
5081=>'L',
5082=>'L',
5083=>'L',
5084=>'L',
5085=>'L',
5086=>'L',
5087=>'L',
5088=>'L',
5089=>'L',
5090=>'L',
5091=>'L',
5092=>'L',
5093=>'L',
5094=>'L',
5095=>'L',
5096=>'L',
5097=>'L',
5098=>'L',
5099=>'L',
5100=>'L',
5101=>'L',
5102=>'L',
5103=>'L',
5104=>'L',
5105=>'L',
5106=>'L',
5107=>'L',
5108=>'L',
5121=>'L',
5122=>'L',
5123=>'L',
5124=>'L',
5125=>'L',
5126=>'L',
5127=>'L',
5128=>'L',
5129=>'L',
5130=>'L',
5131=>'L',
5132=>'L',
5133=>'L',
5134=>'L',
5135=>'L',
5136=>'L',
5137=>'L',
5138=>'L',
5139=>'L',
5140=>'L',
5141=>'L',
5142=>'L',
5143=>'L',
5144=>'L',
5145=>'L',
5146=>'L',
5147=>'L',
5148=>'L',
5149=>'L',
5150=>'L',
5151=>'L',
5152=>'L',
5153=>'L',
5154=>'L',
5155=>'L',
5156=>'L',
5157=>'L',
5158=>'L',
5159=>'L',
5160=>'L',
5161=>'L',
5162=>'L',
5163=>'L',
5164=>'L',
5165=>'L',
5166=>'L',
5167=>'L',
5168=>'L',
5169=>'L',
5170=>'L',
5171=>'L',
5172=>'L',
5173=>'L',
5174=>'L',
5175=>'L',
5176=>'L',
5177=>'L',
5178=>'L',
5179=>'L',
5180=>'L',
5181=>'L',
5182=>'L',
5183=>'L',
5184=>'L',
5185=>'L',
5186=>'L',
5187=>'L',
5188=>'L',
5189=>'L',
5190=>'L',
5191=>'L',
5192=>'L',
5193=>'L',
5194=>'L',
5195=>'L',
5196=>'L',
5197=>'L',
5198=>'L',
5199=>'L',
5200=>'L',
5201=>'L',
5202=>'L',
5203=>'L',
5204=>'L',
5205=>'L',
5206=>'L',
5207=>'L',
5208=>'L',
5209=>'L',
5210=>'L',
5211=>'L',
5212=>'L',
5213=>'L',
5214=>'L',
5215=>'L',
5216=>'L',
5217=>'L',
5218=>'L',
5219=>'L',
5220=>'L',
5221=>'L',
5222=>'L',
5223=>'L',
5224=>'L',
5225=>'L',
5226=>'L',
5227=>'L',
5228=>'L',
5229=>'L',
5230=>'L',
5231=>'L',
5232=>'L',
5233=>'L',
5234=>'L',
5235=>'L',
5236=>'L',
5237=>'L',
5238=>'L',
5239=>'L',
5240=>'L',
5241=>'L',
5242=>'L',
5243=>'L',
5244=>'L',
5245=>'L',
5246=>'L',
5247=>'L',
5248=>'L',
5249=>'L',
5250=>'L',
5251=>'L',
5252=>'L',
5253=>'L',
5254=>'L',
5255=>'L',
5256=>'L',
5257=>'L',
5258=>'L',
5259=>'L',
5260=>'L',
5261=>'L',
5262=>'L',
5263=>'L',
5264=>'L',
5265=>'L',
5266=>'L',
5267=>'L',
5268=>'L',
5269=>'L',
5270=>'L',
5271=>'L',
5272=>'L',
5273=>'L',
5274=>'L',
5275=>'L',
5276=>'L',
5277=>'L',
5278=>'L',
5279=>'L',
5280=>'L',
5281=>'L',
5282=>'L',
5283=>'L',
5284=>'L',
5285=>'L',
5286=>'L',
5287=>'L',
5288=>'L',
5289=>'L',
5290=>'L',
5291=>'L',
5292=>'L',
5293=>'L',
5294=>'L',
5295=>'L',
5296=>'L',
5297=>'L',
5298=>'L',
5299=>'L',
5300=>'L',
5301=>'L',
5302=>'L',
5303=>'L',
5304=>'L',
5305=>'L',
5306=>'L',
5307=>'L',
5308=>'L',
5309=>'L',
5310=>'L',
5311=>'L',
5312=>'L',
5313=>'L',
5314=>'L',
5315=>'L',
5316=>'L',
5317=>'L',
5318=>'L',
5319=>'L',
5320=>'L',
5321=>'L',
5322=>'L',
5323=>'L',
5324=>'L',
5325=>'L',
5326=>'L',
5327=>'L',
5328=>'L',
5329=>'L',
5330=>'L',
5331=>'L',
5332=>'L',
5333=>'L',
5334=>'L',
5335=>'L',
5336=>'L',
5337=>'L',
5338=>'L',
5339=>'L',
5340=>'L',
5341=>'L',
5342=>'L',
5343=>'L',
5344=>'L',
5345=>'L',
5346=>'L',
5347=>'L',
5348=>'L',
5349=>'L',
5350=>'L',
5351=>'L',
5352=>'L',
5353=>'L',
5354=>'L',
5355=>'L',
5356=>'L',
5357=>'L',
5358=>'L',
5359=>'L',
5360=>'L',
5361=>'L',
5362=>'L',
5363=>'L',
5364=>'L',
5365=>'L',
5366=>'L',
5367=>'L',
5368=>'L',
5369=>'L',
5370=>'L',
5371=>'L',
5372=>'L',
5373=>'L',
5374=>'L',
5375=>'L',
5376=>'L',
5377=>'L',
5378=>'L',
5379=>'L',
5380=>'L',
5381=>'L',
5382=>'L',
5383=>'L',
5384=>'L',
5385=>'L',
5386=>'L',
5387=>'L',
5388=>'L',
5389=>'L',
5390=>'L',
5391=>'L',
5392=>'L',
5393=>'L',
5394=>'L',
5395=>'L',
5396=>'L',
5397=>'L',
5398=>'L',
5399=>'L',
5400=>'L',
5401=>'L',
5402=>'L',
5403=>'L',
5404=>'L',
5405=>'L',
5406=>'L',
5407=>'L',
5408=>'L',
5409=>'L',
5410=>'L',
5411=>'L',
5412=>'L',
5413=>'L',
5414=>'L',
5415=>'L',
5416=>'L',
5417=>'L',
5418=>'L',
5419=>'L',
5420=>'L',
5421=>'L',
5422=>'L',
5423=>'L',
5424=>'L',
5425=>'L',
5426=>'L',
5427=>'L',
5428=>'L',
5429=>'L',
5430=>'L',
5431=>'L',
5432=>'L',
5433=>'L',
5434=>'L',
5435=>'L',
5436=>'L',
5437=>'L',
5438=>'L',
5439=>'L',
5440=>'L',
5441=>'L',
5442=>'L',
5443=>'L',
5444=>'L',
5445=>'L',
5446=>'L',
5447=>'L',
5448=>'L',
5449=>'L',
5450=>'L',
5451=>'L',
5452=>'L',
5453=>'L',
5454=>'L',
5455=>'L',
5456=>'L',
5457=>'L',
5458=>'L',
5459=>'L',
5460=>'L',
5461=>'L',
5462=>'L',
5463=>'L',
5464=>'L',
5465=>'L',
5466=>'L',
5467=>'L',
5468=>'L',
5469=>'L',
5470=>'L',
5471=>'L',
5472=>'L',
5473=>'L',
5474=>'L',
5475=>'L',
5476=>'L',
5477=>'L',
5478=>'L',
5479=>'L',
5480=>'L',
5481=>'L',
5482=>'L',
5483=>'L',
5484=>'L',
5485=>'L',
5486=>'L',
5487=>'L',
5488=>'L',
5489=>'L',
5490=>'L',
5491=>'L',
5492=>'L',
5493=>'L',
5494=>'L',
5495=>'L',
5496=>'L',
5497=>'L',
5498=>'L',
5499=>'L',
5500=>'L',
5501=>'L',
5502=>'L',
5503=>'L',
5504=>'L',
5505=>'L',
5506=>'L',
5507=>'L',
5508=>'L',
5509=>'L',
5510=>'L',
5511=>'L',
5512=>'L',
5513=>'L',
5514=>'L',
5515=>'L',
5516=>'L',
5517=>'L',
5518=>'L',
5519=>'L',
5520=>'L',
5521=>'L',
5522=>'L',
5523=>'L',
5524=>'L',
5525=>'L',
5526=>'L',
5527=>'L',
5528=>'L',
5529=>'L',
5530=>'L',
5531=>'L',
5532=>'L',
5533=>'L',
5534=>'L',
5535=>'L',
5536=>'L',
5537=>'L',
5538=>'L',
5539=>'L',
5540=>'L',
5541=>'L',
5542=>'L',
5543=>'L',
5544=>'L',
5545=>'L',
5546=>'L',
5547=>'L',
5548=>'L',
5549=>'L',
5550=>'L',
5551=>'L',
5552=>'L',
5553=>'L',
5554=>'L',
5555=>'L',
5556=>'L',
5557=>'L',
5558=>'L',
5559=>'L',
5560=>'L',
5561=>'L',
5562=>'L',
5563=>'L',
5564=>'L',
5565=>'L',
5566=>'L',
5567=>'L',
5568=>'L',
5569=>'L',
5570=>'L',
5571=>'L',
5572=>'L',
5573=>'L',
5574=>'L',
5575=>'L',
5576=>'L',
5577=>'L',
5578=>'L',
5579=>'L',
5580=>'L',
5581=>'L',
5582=>'L',
5583=>'L',
5584=>'L',
5585=>'L',
5586=>'L',
5587=>'L',
5588=>'L',
5589=>'L',
5590=>'L',
5591=>'L',
5592=>'L',
5593=>'L',
5594=>'L',
5595=>'L',
5596=>'L',
5597=>'L',
5598=>'L',
5599=>'L',
5600=>'L',
5601=>'L',
5602=>'L',
5603=>'L',
5604=>'L',
5605=>'L',
5606=>'L',
5607=>'L',
5608=>'L',
5609=>'L',
5610=>'L',
5611=>'L',
5612=>'L',
5613=>'L',
5614=>'L',
5615=>'L',
5616=>'L',
5617=>'L',
5618=>'L',
5619=>'L',
5620=>'L',
5621=>'L',
5622=>'L',
5623=>'L',
5624=>'L',
5625=>'L',
5626=>'L',
5627=>'L',
5628=>'L',
5629=>'L',
5630=>'L',
5631=>'L',
5632=>'L',
5633=>'L',
5634=>'L',
5635=>'L',
5636=>'L',
5637=>'L',
5638=>'L',
5639=>'L',
5640=>'L',
5641=>'L',
5642=>'L',
5643=>'L',
5644=>'L',
5645=>'L',
5646=>'L',
5647=>'L',
5648=>'L',
5649=>'L',
5650=>'L',
5651=>'L',
5652=>'L',
5653=>'L',
5654=>'L',
5655=>'L',
5656=>'L',
5657=>'L',
5658=>'L',
5659=>'L',
5660=>'L',
5661=>'L',
5662=>'L',
5663=>'L',
5664=>'L',
5665=>'L',
5666=>'L',
5667=>'L',
5668=>'L',
5669=>'L',
5670=>'L',
5671=>'L',
5672=>'L',
5673=>'L',
5674=>'L',
5675=>'L',
5676=>'L',
5677=>'L',
5678=>'L',
5679=>'L',
5680=>'L',
5681=>'L',
5682=>'L',
5683=>'L',
5684=>'L',
5685=>'L',
5686=>'L',
5687=>'L',
5688=>'L',
5689=>'L',
5690=>'L',
5691=>'L',
5692=>'L',
5693=>'L',
5694=>'L',
5695=>'L',
5696=>'L',
5697=>'L',
5698=>'L',
5699=>'L',
5700=>'L',
5701=>'L',
5702=>'L',
5703=>'L',
5704=>'L',
5705=>'L',
5706=>'L',
5707=>'L',
5708=>'L',
5709=>'L',
5710=>'L',
5711=>'L',
5712=>'L',
5713=>'L',
5714=>'L',
5715=>'L',
5716=>'L',
5717=>'L',
5718=>'L',
5719=>'L',
5720=>'L',
5721=>'L',
5722=>'L',
5723=>'L',
5724=>'L',
5725=>'L',
5726=>'L',
5727=>'L',
5728=>'L',
5729=>'L',
5730=>'L',
5731=>'L',
5732=>'L',
5733=>'L',
5734=>'L',
5735=>'L',
5736=>'L',
5737=>'L',
5738=>'L',
5739=>'L',
5740=>'L',
5741=>'L',
5742=>'L',
5743=>'L',
5744=>'L',
5745=>'L',
5746=>'L',
5747=>'L',
5748=>'L',
5749=>'L',
5750=>'L',
5760=>'WS',
5761=>'L',
5762=>'L',
5763=>'L',
5764=>'L',
5765=>'L',
5766=>'L',
5767=>'L',
5768=>'L',
5769=>'L',
5770=>'L',
5771=>'L',
5772=>'L',
5773=>'L',
5774=>'L',
5775=>'L',
5776=>'L',
5777=>'L',
5778=>'L',
5779=>'L',
5780=>'L',
5781=>'L',
5782=>'L',
5783=>'L',
5784=>'L',
5785=>'L',
5786=>'L',
5787=>'ON',
5788=>'ON',
5792=>'L',
5793=>'L',
5794=>'L',
5795=>'L',
5796=>'L',
5797=>'L',
5798=>'L',
5799=>'L',
5800=>'L',
5801=>'L',
5802=>'L',
5803=>'L',
5804=>'L',
5805=>'L',
5806=>'L',
5807=>'L',
5808=>'L',
5809=>'L',
5810=>'L',
5811=>'L',
5812=>'L',
5813=>'L',
5814=>'L',
5815=>'L',
5816=>'L',
5817=>'L',
5818=>'L',
5819=>'L',
5820=>'L',
5821=>'L',
5822=>'L',
5823=>'L',
5824=>'L',
5825=>'L',
5826=>'L',
5827=>'L',
5828=>'L',
5829=>'L',
5830=>'L',
5831=>'L',
5832=>'L',
5833=>'L',
5834=>'L',
5835=>'L',
5836=>'L',
5837=>'L',
5838=>'L',
5839=>'L',
5840=>'L',
5841=>'L',
5842=>'L',
5843=>'L',
5844=>'L',
5845=>'L',
5846=>'L',
5847=>'L',
5848=>'L',
5849=>'L',
5850=>'L',
5851=>'L',
5852=>'L',
5853=>'L',
5854=>'L',
5855=>'L',
5856=>'L',
5857=>'L',
5858=>'L',
5859=>'L',
5860=>'L',
5861=>'L',
5862=>'L',
5863=>'L',
5864=>'L',
5865=>'L',
5866=>'L',
5867=>'L',
5868=>'L',
5869=>'L',
5870=>'L',
5871=>'L',
5872=>'L',
5888=>'L',
5889=>'L',
5890=>'L',
5891=>'L',
5892=>'L',
5893=>'L',
5894=>'L',
5895=>'L',
5896=>'L',
5897=>'L',
5898=>'L',
5899=>'L',
5900=>'L',
5902=>'L',
5903=>'L',
5904=>'L',
5905=>'L',
5906=>'NSM',
5907=>'NSM',
5908=>'NSM',
5920=>'L',
5921=>'L',
5922=>'L',
5923=>'L',
5924=>'L',
5925=>'L',
5926=>'L',
5927=>'L',
5928=>'L',
5929=>'L',
5930=>'L',
5931=>'L',
5932=>'L',
5933=>'L',
5934=>'L',
5935=>'L',
5936=>'L',
5937=>'L',
5938=>'NSM',
5939=>'NSM',
5940=>'NSM',
5941=>'L',
5942=>'L',
5952=>'L',
5953=>'L',
5954=>'L',
5955=>'L',
5956=>'L',
5957=>'L',
5958=>'L',
5959=>'L',
5960=>'L',
5961=>'L',
5962=>'L',
5963=>'L',
5964=>'L',
5965=>'L',
5966=>'L',
5967=>'L',
5968=>'L',
5969=>'L',
5970=>'NSM',
5971=>'NSM',
5984=>'L',
5985=>'L',
5986=>'L',
5987=>'L',
5988=>'L',
5989=>'L',
5990=>'L',
5991=>'L',
5992=>'L',
5993=>'L',
5994=>'L',
5995=>'L',
5996=>'L',
5998=>'L',
5999=>'L',
6000=>'L',
6002=>'NSM',
6003=>'NSM',
6016=>'L',
6017=>'L',
6018=>'L',
6019=>'L',
6020=>'L',
6021=>'L',
6022=>'L',
6023=>'L',
6024=>'L',
6025=>'L',
6026=>'L',
6027=>'L',
6028=>'L',
6029=>'L',
6030=>'L',
6031=>'L',
6032=>'L',
6033=>'L',
6034=>'L',
6035=>'L',
6036=>'L',
6037=>'L',
6038=>'L',
6039=>'L',
6040=>'L',
6041=>'L',
6042=>'L',
6043=>'L',
6044=>'L',
6045=>'L',
6046=>'L',
6047=>'L',
6048=>'L',
6049=>'L',
6050=>'L',
6051=>'L',
6052=>'L',
6053=>'L',
6054=>'L',
6055=>'L',
6056=>'L',
6057=>'L',
6058=>'L',
6059=>'L',
6060=>'L',
6061=>'L',
6062=>'L',
6063=>'L',
6064=>'L',
6065=>'L',
6066=>'L',
6067=>'L',
6068=>'L',
6069=>'L',
6070=>'L',
6071=>'NSM',
6072=>'NSM',
6073=>'NSM',
6074=>'NSM',
6075=>'NSM',
6076=>'NSM',
6077=>'NSM',
6078=>'L',
6079=>'L',
6080=>'L',
6081=>'L',
6082=>'L',
6083=>'L',
6084=>'L',
6085=>'L',
6086=>'NSM',
6087=>'L',
6088=>'L',
6089=>'NSM',
6090=>'NSM',
6091=>'NSM',
6092=>'NSM',
6093=>'NSM',
6094=>'NSM',
6095=>'NSM',
6096=>'NSM',
6097=>'NSM',
6098=>'NSM',
6099=>'NSM',
6100=>'L',
6101=>'L',
6102=>'L',
6103=>'L',
6104=>'L',
6105=>'L',
6106=>'L',
6107=>'ET',
6108=>'L',
6109=>'NSM',
6112=>'L',
6113=>'L',
6114=>'L',
6115=>'L',
6116=>'L',
6117=>'L',
6118=>'L',
6119=>'L',
6120=>'L',
6121=>'L',
6128=>'ON',
6129=>'ON',
6130=>'ON',
6131=>'ON',
6132=>'ON',
6133=>'ON',
6134=>'ON',
6135=>'ON',
6136=>'ON',
6137=>'ON',
6144=>'ON',
6145=>'ON',
6146=>'ON',
6147=>'ON',
6148=>'ON',
6149=>'ON',
6150=>'ON',
6151=>'ON',
6152=>'ON',
6153=>'ON',
6154=>'ON',
6155=>'NSM',
6156=>'NSM',
6157=>'NSM',
6158=>'WS',
6160=>'L',
6161=>'L',
6162=>'L',
6163=>'L',
6164=>'L',
6165=>'L',
6166=>'L',
6167=>'L',
6168=>'L',
6169=>'L',
6176=>'L',
6177=>'L',
6178=>'L',
6179=>'L',
6180=>'L',
6181=>'L',
6182=>'L',
6183=>'L',
6184=>'L',
6185=>'L',
6186=>'L',
6187=>'L',
6188=>'L',
6189=>'L',
6190=>'L',
6191=>'L',
6192=>'L',
6193=>'L',
6194=>'L',
6195=>'L',
6196=>'L',
6197=>'L',
6198=>'L',
6199=>'L',
6200=>'L',
6201=>'L',
6202=>'L',
6203=>'L',
6204=>'L',
6205=>'L',
6206=>'L',
6207=>'L',
6208=>'L',
6209=>'L',
6210=>'L',
6211=>'L',
6212=>'L',
6213=>'L',
6214=>'L',
6215=>'L',
6216=>'L',
6217=>'L',
6218=>'L',
6219=>'L',
6220=>'L',
6221=>'L',
6222=>'L',
6223=>'L',
6224=>'L',
6225=>'L',
6226=>'L',
6227=>'L',
6228=>'L',
6229=>'L',
6230=>'L',
6231=>'L',
6232=>'L',
6233=>'L',
6234=>'L',
6235=>'L',
6236=>'L',
6237=>'L',
6238=>'L',
6239=>'L',
6240=>'L',
6241=>'L',
6242=>'L',
6243=>'L',
6244=>'L',
6245=>'L',
6246=>'L',
6247=>'L',
6248=>'L',
6249=>'L',
6250=>'L',
6251=>'L',
6252=>'L',
6253=>'L',
6254=>'L',
6255=>'L',
6256=>'L',
6257=>'L',
6258=>'L',
6259=>'L',
6260=>'L',
6261=>'L',
6262=>'L',
6263=>'L',
6272=>'L',
6273=>'L',
6274=>'L',
6275=>'L',
6276=>'L',
6277=>'L',
6278=>'L',
6279=>'L',
6280=>'L',
6281=>'L',
6282=>'L',
6283=>'L',
6284=>'L',
6285=>'L',
6286=>'L',
6287=>'L',
6288=>'L',
6289=>'L',
6290=>'L',
6291=>'L',
6292=>'L',
6293=>'L',
6294=>'L',
6295=>'L',
6296=>'L',
6297=>'L',
6298=>'L',
6299=>'L',
6300=>'L',
6301=>'L',
6302=>'L',
6303=>'L',
6304=>'L',
6305=>'L',
6306=>'L',
6307=>'L',
6308=>'L',
6309=>'L',
6310=>'L',
6311=>'L',
6312=>'L',
6313=>'NSM',
6400=>'L',
6401=>'L',
6402=>'L',
6403=>'L',
6404=>'L',
6405=>'L',
6406=>'L',
6407=>'L',
6408=>'L',
6409=>'L',
6410=>'L',
6411=>'L',
6412=>'L',
6413=>'L',
6414=>'L',
6415=>'L',
6416=>'L',
6417=>'L',
6418=>'L',
6419=>'L',
6420=>'L',
6421=>'L',
6422=>'L',
6423=>'L',
6424=>'L',
6425=>'L',
6426=>'L',
6427=>'L',
6428=>'L',
6432=>'NSM',
6433=>'NSM',
6434=>'NSM',
6435=>'L',
6436=>'L',
6437=>'L',
6438=>'L',
6439=>'NSM',
6440=>'NSM',
6441=>'NSM',
6442=>'NSM',
6443=>'NSM',
6448=>'L',
6449=>'L',
6450=>'NSM',
6451=>'L',
6452=>'L',
6453=>'L',
6454=>'L',
6455=>'L',
6456=>'L',
6457=>'NSM',
6458=>'NSM',
6459=>'NSM',
6464=>'ON',
6468=>'ON',
6469=>'ON',
6470=>'L',
6471=>'L',
6472=>'L',
6473=>'L',
6474=>'L',
6475=>'L',
6476=>'L',
6477=>'L',
6478=>'L',
6479=>'L',
6480=>'L',
6481=>'L',
6482=>'L',
6483=>'L',
6484=>'L',
6485=>'L',
6486=>'L',
6487=>'L',
6488=>'L',
6489=>'L',
6490=>'L',
6491=>'L',
6492=>'L',
6493=>'L',
6494=>'L',
6495=>'L',
6496=>'L',
6497=>'L',
6498=>'L',
6499=>'L',
6500=>'L',
6501=>'L',
6502=>'L',
6503=>'L',
6504=>'L',
6505=>'L',
6506=>'L',
6507=>'L',
6508=>'L',
6509=>'L',
6512=>'L',
6513=>'L',
6514=>'L',
6515=>'L',
6516=>'L',
6528=>'L',
6529=>'L',
6530=>'L',
6531=>'L',
6532=>'L',
6533=>'L',
6534=>'L',
6535=>'L',
6536=>'L',
6537=>'L',
6538=>'L',
6539=>'L',
6540=>'L',
6541=>'L',
6542=>'L',
6543=>'L',
6544=>'L',
6545=>'L',
6546=>'L',
6547=>'L',
6548=>'L',
6549=>'L',
6550=>'L',
6551=>'L',
6552=>'L',
6553=>'L',
6554=>'L',
6555=>'L',
6556=>'L',
6557=>'L',
6558=>'L',
6559=>'L',
6560=>'L',
6561=>'L',
6562=>'L',
6563=>'L',
6564=>'L',
6565=>'L',
6566=>'L',
6567=>'L',
6568=>'L',
6569=>'L',
6576=>'L',
6577=>'L',
6578=>'L',
6579=>'L',
6580=>'L',
6581=>'L',
6582=>'L',
6583=>'L',
6584=>'L',
6585=>'L',
6586=>'L',
6587=>'L',
6588=>'L',
6589=>'L',
6590=>'L',
6591=>'L',
6592=>'L',
6593=>'L',
6594=>'L',
6595=>'L',
6596=>'L',
6597=>'L',
6598=>'L',
6599=>'L',
6600=>'L',
6601=>'L',
6608=>'L',
6609=>'L',
6610=>'L',
6611=>'L',
6612=>'L',
6613=>'L',
6614=>'L',
6615=>'L',
6616=>'L',
6617=>'L',
6622=>'ON',
6623=>'ON',
6624=>'ON',
6625=>'ON',
6626=>'ON',
6627=>'ON',
6628=>'ON',
6629=>'ON',
6630=>'ON',
6631=>'ON',
6632=>'ON',
6633=>'ON',
6634=>'ON',
6635=>'ON',
6636=>'ON',
6637=>'ON',
6638=>'ON',
6639=>'ON',
6640=>'ON',
6641=>'ON',
6642=>'ON',
6643=>'ON',
6644=>'ON',
6645=>'ON',
6646=>'ON',
6647=>'ON',
6648=>'ON',
6649=>'ON',
6650=>'ON',
6651=>'ON',
6652=>'ON',
6653=>'ON',
6654=>'ON',
6655=>'ON',
6656=>'L',
6657=>'L',
6658=>'L',
6659=>'L',
6660=>'L',
6661=>'L',
6662=>'L',
6663=>'L',
6664=>'L',
6665=>'L',
6666=>'L',
6667=>'L',
6668=>'L',
6669=>'L',
6670=>'L',
6671=>'L',
6672=>'L',
6673=>'L',
6674=>'L',
6675=>'L',
6676=>'L',
6677=>'L',
6678=>'L',
6679=>'NSM',
6680=>'NSM',
6681=>'L',
6682=>'L',
6683=>'L',
6686=>'L',
6687=>'L',
6912=>'NSM',
6913=>'NSM',
6914=>'NSM',
6915=>'NSM',
6916=>'L',
6917=>'L',
6918=>'L',
6919=>'L',
6920=>'L',
6921=>'L',
6922=>'L',
6923=>'L',
6924=>'L',
6925=>'L',
6926=>'L',
6927=>'L',
6928=>'L',
6929=>'L',
6930=>'L',
6931=>'L',
6932=>'L',
6933=>'L',
6934=>'L',
6935=>'L',
6936=>'L',
6937=>'L',
6938=>'L',
6939=>'L',
6940=>'L',
6941=>'L',
6942=>'L',
6943=>'L',
6944=>'L',
6945=>'L',
6946=>'L',
6947=>'L',
6948=>'L',
6949=>'L',
6950=>'L',
6951=>'L',
6952=>'L',
6953=>'L',
6954=>'L',
6955=>'L',
6956=>'L',
6957=>'L',
6958=>'L',
6959=>'L',
6960=>'L',
6961=>'L',
6962=>'L',
6963=>'L',
6964=>'NSM',
6965=>'L',
6966=>'NSM',
6967=>'NSM',
6968=>'NSM',
6969=>'NSM',
6970=>'NSM',
6971=>'L',
6972=>'NSM',
6973=>'L',
6974=>'L',
6975=>'L',
6976=>'L',
6977=>'L',
6978=>'NSM',
6979=>'L',
6980=>'L',
6981=>'L',
6982=>'L',
6983=>'L',
6984=>'L',
6985=>'L',
6986=>'L',
6987=>'L',
6992=>'L',
6993=>'L',
6994=>'L',
6995=>'L',
6996=>'L',
6997=>'L',
6998=>'L',
6999=>'L',
7000=>'L',
7001=>'L',
7002=>'L',
7003=>'L',
7004=>'L',
7005=>'L',
7006=>'L',
7007=>'L',
7008=>'L',
7009=>'L',
7010=>'L',
7011=>'L',
7012=>'L',
7013=>'L',
7014=>'L',
7015=>'L',
7016=>'L',
7017=>'L',
7018=>'L',
7019=>'NSM',
7020=>'NSM',
7021=>'NSM',
7022=>'NSM',
7023=>'NSM',
7024=>'NSM',
7025=>'NSM',
7026=>'NSM',
7027=>'NSM',
7028=>'L',
7029=>'L',
7030=>'L',
7031=>'L',
7032=>'L',
7033=>'L',
7034=>'L',
7035=>'L',
7036=>'L',
7424=>'L',
7425=>'L',
7426=>'L',
7427=>'L',
7428=>'L',
7429=>'L',
7430=>'L',
7431=>'L',
7432=>'L',
7433=>'L',
7434=>'L',
7435=>'L',
7436=>'L',
7437=>'L',
7438=>'L',
7439=>'L',
7440=>'L',
7441=>'L',
7442=>'L',
7443=>'L',
7444=>'L',
7445=>'L',
7446=>'L',
7447=>'L',
7448=>'L',
7449=>'L',
7450=>'L',
7451=>'L',
7452=>'L',
7453=>'L',
7454=>'L',
7455=>'L',
7456=>'L',
7457=>'L',
7458=>'L',
7459=>'L',
7460=>'L',
7461=>'L',
7462=>'L',
7463=>'L',
7464=>'L',
7465=>'L',
7466=>'L',
7467=>'L',
7468=>'L',
7469=>'L',
7470=>'L',
7471=>'L',
7472=>'L',
7473=>'L',
7474=>'L',
7475=>'L',
7476=>'L',
7477=>'L',
7478=>'L',
7479=>'L',
7480=>'L',
7481=>'L',
7482=>'L',
7483=>'L',
7484=>'L',
7485=>'L',
7486=>'L',
7487=>'L',
7488=>'L',
7489=>'L',
7490=>'L',
7491=>'L',
7492=>'L',
7493=>'L',
7494=>'L',
7495=>'L',
7496=>'L',
7497=>'L',
7498=>'L',
7499=>'L',
7500=>'L',
7501=>'L',
7502=>'L',
7503=>'L',
7504=>'L',
7505=>'L',
7506=>'L',
7507=>'L',
7508=>'L',
7509=>'L',
7510=>'L',
7511=>'L',
7512=>'L',
7513=>'L',
7514=>'L',
7515=>'L',
7516=>'L',
7517=>'L',
7518=>'L',
7519=>'L',
7520=>'L',
7521=>'L',
7522=>'L',
7523=>'L',
7524=>'L',
7525=>'L',
7526=>'L',
7527=>'L',
7528=>'L',
7529=>'L',
7530=>'L',
7531=>'L',
7532=>'L',
7533=>'L',
7534=>'L',
7535=>'L',
7536=>'L',
7537=>'L',
7538=>'L',
7539=>'L',
7540=>'L',
7541=>'L',
7542=>'L',
7543=>'L',
7544=>'L',
7545=>'L',
7546=>'L',
7547=>'L',
7548=>'L',
7549=>'L',
7550=>'L',
7551=>'L',
7552=>'L',
7553=>'L',
7554=>'L',
7555=>'L',
7556=>'L',
7557=>'L',
7558=>'L',
7559=>'L',
7560=>'L',
7561=>'L',
7562=>'L',
7563=>'L',
7564=>'L',
7565=>'L',
7566=>'L',
7567=>'L',
7568=>'L',
7569=>'L',
7570=>'L',
7571=>'L',
7572=>'L',
7573=>'L',
7574=>'L',
7575=>'L',
7576=>'L',
7577=>'L',
7578=>'L',
7579=>'L',
7580=>'L',
7581=>'L',
7582=>'L',
7583=>'L',
7584=>'L',
7585=>'L',
7586=>'L',
7587=>'L',
7588=>'L',
7589=>'L',
7590=>'L',
7591=>'L',
7592=>'L',
7593=>'L',
7594=>'L',
7595=>'L',
7596=>'L',
7597=>'L',
7598=>'L',
7599=>'L',
7600=>'L',
7601=>'L',
7602=>'L',
7603=>'L',
7604=>'L',
7605=>'L',
7606=>'L',
7607=>'L',
7608=>'L',
7609=>'L',
7610=>'L',
7611=>'L',
7612=>'L',
7613=>'L',
7614=>'L',
7615=>'L',
7616=>'NSM',
7617=>'NSM',
7618=>'NSM',
7619=>'NSM',
7620=>'NSM',
7621=>'NSM',
7622=>'NSM',
7623=>'NSM',
7624=>'NSM',
7625=>'NSM',
7626=>'NSM',
7678=>'NSM',
7679=>'NSM',
7680=>'L',
7681=>'L',
7682=>'L',
7683=>'L',
7684=>'L',
7685=>'L',
7686=>'L',
7687=>'L',
7688=>'L',
7689=>'L',
7690=>'L',
7691=>'L',
7692=>'L',
7693=>'L',
7694=>'L',
7695=>'L',
7696=>'L',
7697=>'L',
7698=>'L',
7699=>'L',
7700=>'L',
7701=>'L',
7702=>'L',
7703=>'L',
7704=>'L',
7705=>'L',
7706=>'L',
7707=>'L',
7708=>'L',
7709=>'L',
7710=>'L',
7711=>'L',
7712=>'L',
7713=>'L',
7714=>'L',
7715=>'L',
7716=>'L',
7717=>'L',
7718=>'L',
7719=>'L',
7720=>'L',
7721=>'L',
7722=>'L',
7723=>'L',
7724=>'L',
7725=>'L',
7726=>'L',
7727=>'L',
7728=>'L',
7729=>'L',
7730=>'L',
7731=>'L',
7732=>'L',
7733=>'L',
7734=>'L',
7735=>'L',
7736=>'L',
7737=>'L',
7738=>'L',
7739=>'L',
7740=>'L',
7741=>'L',
7742=>'L',
7743=>'L',
7744=>'L',
7745=>'L',
7746=>'L',
7747=>'L',
7748=>'L',
7749=>'L',
7750=>'L',
7751=>'L',
7752=>'L',
7753=>'L',
7754=>'L',
7755=>'L',
7756=>'L',
7757=>'L',
7758=>'L',
7759=>'L',
7760=>'L',
7761=>'L',
7762=>'L',
7763=>'L',
7764=>'L',
7765=>'L',
7766=>'L',
7767=>'L',
7768=>'L',
7769=>'L',
7770=>'L',
7771=>'L',
7772=>'L',
7773=>'L',
7774=>'L',
7775=>'L',
7776=>'L',
7777=>'L',
7778=>'L',
7779=>'L',
7780=>'L',
7781=>'L',
7782=>'L',
7783=>'L',
7784=>'L',
7785=>'L',
7786=>'L',
7787=>'L',
7788=>'L',
7789=>'L',
7790=>'L',
7791=>'L',
7792=>'L',
7793=>'L',
7794=>'L',
7795=>'L',
7796=>'L',
7797=>'L',
7798=>'L',
7799=>'L',
7800=>'L',
7801=>'L',
7802=>'L',
7803=>'L',
7804=>'L',
7805=>'L',
7806=>'L',
7807=>'L',
7808=>'L',
7809=>'L',
7810=>'L',
7811=>'L',
7812=>'L',
7813=>'L',
7814=>'L',
7815=>'L',
7816=>'L',
7817=>'L',
7818=>'L',
7819=>'L',
7820=>'L',
7821=>'L',
7822=>'L',
7823=>'L',
7824=>'L',
7825=>'L',
7826=>'L',
7827=>'L',
7828=>'L',
7829=>'L',
7830=>'L',
7831=>'L',
7832=>'L',
7833=>'L',
7834=>'L',
7835=>'L',
7840=>'L',
7841=>'L',
7842=>'L',
7843=>'L',
7844=>'L',
7845=>'L',
7846=>'L',
7847=>'L',
7848=>'L',
7849=>'L',
7850=>'L',
7851=>'L',
7852=>'L',
7853=>'L',
7854=>'L',
7855=>'L',
7856=>'L',
7857=>'L',
7858=>'L',
7859=>'L',
7860=>'L',
7861=>'L',
7862=>'L',
7863=>'L',
7864=>'L',
7865=>'L',
7866=>'L',
7867=>'L',
7868=>'L',
7869=>'L',
7870=>'L',
7871=>'L',
7872=>'L',
7873=>'L',
7874=>'L',
7875=>'L',
7876=>'L',
7877=>'L',
7878=>'L',
7879=>'L',
7880=>'L',
7881=>'L',
7882=>'L',
7883=>'L',
7884=>'L',
7885=>'L',
7886=>'L',
7887=>'L',
7888=>'L',
7889=>'L',
7890=>'L',
7891=>'L',
7892=>'L',
7893=>'L',
7894=>'L',
7895=>'L',
7896=>'L',
7897=>'L',
7898=>'L',
7899=>'L',
7900=>'L',
7901=>'L',
7902=>'L',
7903=>'L',
7904=>'L',
7905=>'L',
7906=>'L',
7907=>'L',
7908=>'L',
7909=>'L',
7910=>'L',
7911=>'L',
7912=>'L',
7913=>'L',
7914=>'L',
7915=>'L',
7916=>'L',
7917=>'L',
7918=>'L',
7919=>'L',
7920=>'L',
7921=>'L',
7922=>'L',
7923=>'L',
7924=>'L',
7925=>'L',
7926=>'L',
7927=>'L',
7928=>'L',
7929=>'L',
7936=>'L',
7937=>'L',
7938=>'L',
7939=>'L',
7940=>'L',
7941=>'L',
7942=>'L',
7943=>'L',
7944=>'L',
7945=>'L',
7946=>'L',
7947=>'L',
7948=>'L',
7949=>'L',
7950=>'L',
7951=>'L',
7952=>'L',
7953=>'L',
7954=>'L',
7955=>'L',
7956=>'L',
7957=>'L',
7960=>'L',
7961=>'L',
7962=>'L',
7963=>'L',
7964=>'L',
7965=>'L',
7968=>'L',
7969=>'L',
7970=>'L',
7971=>'L',
7972=>'L',
7973=>'L',
7974=>'L',
7975=>'L',
7976=>'L',
7977=>'L',
7978=>'L',
7979=>'L',
7980=>'L',
7981=>'L',
7982=>'L',
7983=>'L',
7984=>'L',
7985=>'L',
7986=>'L',
7987=>'L',
7988=>'L',
7989=>'L',
7990=>'L',
7991=>'L',
7992=>'L',
7993=>'L',
7994=>'L',
7995=>'L',
7996=>'L',
7997=>'L',
7998=>'L',
7999=>'L',
8000=>'L',
8001=>'L',
8002=>'L',
8003=>'L',
8004=>'L',
8005=>'L',
8008=>'L',
8009=>'L',
8010=>'L',
8011=>'L',
8012=>'L',
8013=>'L',
8016=>'L',
8017=>'L',
8018=>'L',
8019=>'L',
8020=>'L',
8021=>'L',
8022=>'L',
8023=>'L',
8025=>'L',
8027=>'L',
8029=>'L',
8031=>'L',
8032=>'L',
8033=>'L',
8034=>'L',
8035=>'L',
8036=>'L',
8037=>'L',
8038=>'L',
8039=>'L',
8040=>'L',
8041=>'L',
8042=>'L',
8043=>'L',
8044=>'L',
8045=>'L',
8046=>'L',
8047=>'L',
8048=>'L',
8049=>'L',
8050=>'L',
8051=>'L',
8052=>'L',
8053=>'L',
8054=>'L',
8055=>'L',
8056=>'L',
8057=>'L',
8058=>'L',
8059=>'L',
8060=>'L',
8061=>'L',
8064=>'L',
8065=>'L',
8066=>'L',
8067=>'L',
8068=>'L',
8069=>'L',
8070=>'L',
8071=>'L',
8072=>'L',
8073=>'L',
8074=>'L',
8075=>'L',
8076=>'L',
8077=>'L',
8078=>'L',
8079=>'L',
8080=>'L',
8081=>'L',
8082=>'L',
8083=>'L',
8084=>'L',
8085=>'L',
8086=>'L',
8087=>'L',
8088=>'L',
8089=>'L',
8090=>'L',
8091=>'L',
8092=>'L',
8093=>'L',
8094=>'L',
8095=>'L',
8096=>'L',
8097=>'L',
8098=>'L',
8099=>'L',
8100=>'L',
8101=>'L',
8102=>'L',
8103=>'L',
8104=>'L',
8105=>'L',
8106=>'L',
8107=>'L',
8108=>'L',
8109=>'L',
8110=>'L',
8111=>'L',
8112=>'L',
8113=>'L',
8114=>'L',
8115=>'L',
8116=>'L',
8118=>'L',
8119=>'L',
8120=>'L',
8121=>'L',
8122=>'L',
8123=>'L',
8124=>'L',
8125=>'ON',
8126=>'L',
8127=>'ON',
8128=>'ON',
8129=>'ON',
8130=>'L',
8131=>'L',
8132=>'L',
8134=>'L',
8135=>'L',
8136=>'L',
8137=>'L',
8138=>'L',
8139=>'L',
8140=>'L',
8141=>'ON',
8142=>'ON',
8143=>'ON',
8144=>'L',
8145=>'L',
8146=>'L',
8147=>'L',
8150=>'L',
8151=>'L',
8152=>'L',
8153=>'L',
8154=>'L',
8155=>'L',
8157=>'ON',
8158=>'ON',
8159=>'ON',
8160=>'L',
8161=>'L',
8162=>'L',
8163=>'L',
8164=>'L',
8165=>'L',
8166=>'L',
8167=>'L',
8168=>'L',
8169=>'L',
8170=>'L',
8171=>'L',
8172=>'L',
8173=>'ON',
8174=>'ON',
8175=>'ON',
8178=>'L',
8179=>'L',
8180=>'L',
8182=>'L',
8183=>'L',
8184=>'L',
8185=>'L',
8186=>'L',
8187=>'L',
8188=>'L',
8189=>'ON',
8190=>'ON',
8192=>'WS',
8193=>'WS',
8194=>'WS',
8195=>'WS',
8196=>'WS',
8197=>'WS',
8198=>'WS',
8199=>'WS',
8200=>'WS',
8201=>'WS',
8202=>'WS',
8203=>'BN',
8204=>'BN',
8205=>'BN',
8206=>'L',
8207=>'R',
8208=>'ON',
8209=>'ON',
8210=>'ON',
8211=>'ON',
8212=>'ON',
8213=>'ON',
8214=>'ON',
8215=>'ON',
8216=>'ON',
8217=>'ON',
8218=>'ON',
8219=>'ON',
8220=>'ON',
8221=>'ON',
8222=>'ON',
8223=>'ON',
8224=>'ON',
8225=>'ON',
8226=>'ON',
8227=>'ON',
8228=>'ON',
8229=>'ON',
8230=>'ON',
8231=>'ON',
8232=>'WS',
8233=>'B',
8234=>'LRE',
8235=>'RLE',
8236=>'PDF',
8237=>'LRO',
8238=>'RLO',
8239=>'CS',
8240=>'ET',
8241=>'ET',
8242=>'ET',
8243=>'ET',
8244=>'ET',
8245=>'ON',
8246=>'ON',
8247=>'ON',
8248=>'ON',
8249=>'ON',
8250=>'ON',
8251=>'ON',
8252=>'ON',
8253=>'ON',
8254=>'ON',
8255=>'ON',
8256=>'ON',
8257=>'ON',
8258=>'ON',
8259=>'ON',
8260=>'CS',
8261=>'ON',
8262=>'ON',
8263=>'ON',
8264=>'ON',
8265=>'ON',
8266=>'ON',
8267=>'ON',
8268=>'ON',
8269=>'ON',
8270=>'ON',
8271=>'ON',
8272=>'ON',
8273=>'ON',
8274=>'ON',
8275=>'ON',
8276=>'ON',
8277=>'ON',
8278=>'ON',
8279=>'ON',
8280=>'ON',
8281=>'ON',
8282=>'ON',
8283=>'ON',
8284=>'ON',
8285=>'ON',
8286=>'ON',
8287=>'WS',
8288=>'BN',
8289=>'BN',
8290=>'BN',
8291=>'BN',
8298=>'BN',
8299=>'BN',
8300=>'BN',
8301=>'BN',
8302=>'BN',
8303=>'BN',
8304=>'EN',
8305=>'L',
8308=>'EN',
8309=>'EN',
8310=>'EN',
8311=>'EN',
8312=>'EN',
8313=>'EN',
8314=>'ES',
8315=>'ES',
8316=>'ON',
8317=>'ON',
8318=>'ON',
8319=>'L',
8320=>'EN',
8321=>'EN',
8322=>'EN',
8323=>'EN',
8324=>'EN',
8325=>'EN',
8326=>'EN',
8327=>'EN',
8328=>'EN',
8329=>'EN',
8330=>'ES',
8331=>'ES',
8332=>'ON',
8333=>'ON',
8334=>'ON',
8336=>'L',
8337=>'L',
8338=>'L',
8339=>'L',
8340=>'L',
8352=>'ET',
8353=>'ET',
8354=>'ET',
8355=>'ET',
8356=>'ET',
8357=>'ET',
8358=>'ET',
8359=>'ET',
8360=>'ET',
8361=>'ET',
8362=>'ET',
8363=>'ET',
8364=>'ET',
8365=>'ET',
8366=>'ET',
8367=>'ET',
8368=>'ET',
8369=>'ET',
8370=>'ET',
8371=>'ET',
8372=>'ET',
8373=>'ET',
8400=>'NSM',
8401=>'NSM',
8402=>'NSM',
8403=>'NSM',
8404=>'NSM',
8405=>'NSM',
8406=>'NSM',
8407=>'NSM',
8408=>'NSM',
8409=>'NSM',
8410=>'NSM',
8411=>'NSM',
8412=>'NSM',
8413=>'NSM',
8414=>'NSM',
8415=>'NSM',
8416=>'NSM',
8417=>'NSM',
8418=>'NSM',
8419=>'NSM',
8420=>'NSM',
8421=>'NSM',
8422=>'NSM',
8423=>'NSM',
8424=>'NSM',
8425=>'NSM',
8426=>'NSM',
8427=>'NSM',
8428=>'NSM',
8429=>'NSM',
8430=>'NSM',
8431=>'NSM',
8448=>'ON',
8449=>'ON',
8450=>'L',
8451=>'ON',
8452=>'ON',
8453=>'ON',
8454=>'ON',
8455=>'L',
8456=>'ON',
8457=>'ON',
8458=>'L',
8459=>'L',
8460=>'L',
8461=>'L',
8462=>'L',
8463=>'L',
8464=>'L',
8465=>'L',
8466=>'L',
8467=>'L',
8468=>'ON',
8469=>'L',
8470=>'ON',
8471=>'ON',
8472=>'ON',
8473=>'L',
8474=>'L',
8475=>'L',
8476=>'L',
8477=>'L',
8478=>'ON',
8479=>'ON',
8480=>'ON',
8481=>'ON',
8482=>'ON',
8483=>'ON',
8484=>'L',
8485=>'ON',
8486=>'L',
8487=>'ON',
8488=>'L',
8489=>'ON',
8490=>'L',
8491=>'L',
8492=>'L',
8493=>'L',
8494=>'ET',
8495=>'L',
8496=>'L',
8497=>'L',
8498=>'L',
8499=>'L',
8500=>'L',
8501=>'L',
8502=>'L',
8503=>'L',
8504=>'L',
8505=>'L',
8506=>'ON',
8507=>'ON',
8508=>'L',
8509=>'L',
8510=>'L',
8511=>'L',
8512=>'ON',
8513=>'ON',
8514=>'ON',
8515=>'ON',
8516=>'ON',
8517=>'L',
8518=>'L',
8519=>'L',
8520=>'L',
8521=>'L',
8522=>'ON',
8523=>'ON',
8524=>'ON',
8525=>'ON',
8526=>'L',
8531=>'ON',
8532=>'ON',
8533=>'ON',
8534=>'ON',
8535=>'ON',
8536=>'ON',
8537=>'ON',
8538=>'ON',
8539=>'ON',
8540=>'ON',
8541=>'ON',
8542=>'ON',
8543=>'ON',
8544=>'L',
8545=>'L',
8546=>'L',
8547=>'L',
8548=>'L',
8549=>'L',
8550=>'L',
8551=>'L',
8552=>'L',
8553=>'L',
8554=>'L',
8555=>'L',
8556=>'L',
8557=>'L',
8558=>'L',
8559=>'L',
8560=>'L',
8561=>'L',
8562=>'L',
8563=>'L',
8564=>'L',
8565=>'L',
8566=>'L',
8567=>'L',
8568=>'L',
8569=>'L',
8570=>'L',
8571=>'L',
8572=>'L',
8573=>'L',
8574=>'L',
8575=>'L',
8576=>'L',
8577=>'L',
8578=>'L',
8579=>'L',
8580=>'L',
8592=>'ON',
8593=>'ON',
8594=>'ON',
8595=>'ON',
8596=>'ON',
8597=>'ON',
8598=>'ON',
8599=>'ON',
8600=>'ON',
8601=>'ON',
8602=>'ON',
8603=>'ON',
8604=>'ON',
8605=>'ON',
8606=>'ON',
8607=>'ON',
8608=>'ON',
8609=>'ON',
8610=>'ON',
8611=>'ON',
8612=>'ON',
8613=>'ON',
8614=>'ON',
8615=>'ON',
8616=>'ON',
8617=>'ON',
8618=>'ON',
8619=>'ON',
8620=>'ON',
8621=>'ON',
8622=>'ON',
8623=>'ON',
8624=>'ON',
8625=>'ON',
8626=>'ON',
8627=>'ON',
8628=>'ON',
8629=>'ON',
8630=>'ON',
8631=>'ON',
8632=>'ON',
8633=>'ON',
8634=>'ON',
8635=>'ON',
8636=>'ON',
8637=>'ON',
8638=>'ON',
8639=>'ON',
8640=>'ON',
8641=>'ON',
8642=>'ON',
8643=>'ON',
8644=>'ON',
8645=>'ON',
8646=>'ON',
8647=>'ON',
8648=>'ON',
8649=>'ON',
8650=>'ON',
8651=>'ON',
8652=>'ON',
8653=>'ON',
8654=>'ON',
8655=>'ON',
8656=>'ON',
8657=>'ON',
8658=>'ON',
8659=>'ON',
8660=>'ON',
8661=>'ON',
8662=>'ON',
8663=>'ON',
8664=>'ON',
8665=>'ON',
8666=>'ON',
8667=>'ON',
8668=>'ON',
8669=>'ON',
8670=>'ON',
8671=>'ON',
8672=>'ON',
8673=>'ON',
8674=>'ON',
8675=>'ON',
8676=>'ON',
8677=>'ON',
8678=>'ON',
8679=>'ON',
8680=>'ON',
8681=>'ON',
8682=>'ON',
8683=>'ON',
8684=>'ON',
8685=>'ON',
8686=>'ON',
8687=>'ON',
8688=>'ON',
8689=>'ON',
8690=>'ON',
8691=>'ON',
8692=>'ON',
8693=>'ON',
8694=>'ON',
8695=>'ON',
8696=>'ON',
8697=>'ON',
8698=>'ON',
8699=>'ON',
8700=>'ON',
8701=>'ON',
8702=>'ON',
8703=>'ON',
8704=>'ON',
8705=>'ON',
8706=>'ON',
8707=>'ON',
8708=>'ON',
8709=>'ON',
8710=>'ON',
8711=>'ON',
8712=>'ON',
8713=>'ON',
8714=>'ON',
8715=>'ON',
8716=>'ON',
8717=>'ON',
8718=>'ON',
8719=>'ON',
8720=>'ON',
8721=>'ON',
8722=>'ES',
8723=>'ET',
8724=>'ON',
8725=>'ON',
8726=>'ON',
8727=>'ON',
8728=>'ON',
8729=>'ON',
8730=>'ON',
8731=>'ON',
8732=>'ON',
8733=>'ON',
8734=>'ON',
8735=>'ON',
8736=>'ON',
8737=>'ON',
8738=>'ON',
8739=>'ON',
8740=>'ON',
8741=>'ON',
8742=>'ON',
8743=>'ON',
8744=>'ON',
8745=>'ON',
8746=>'ON',
8747=>'ON',
8748=>'ON',
8749=>'ON',
8750=>'ON',
8751=>'ON',
8752=>'ON',
8753=>'ON',
8754=>'ON',
8755=>'ON',
8756=>'ON',
8757=>'ON',
8758=>'ON',
8759=>'ON',
8760=>'ON',
8761=>'ON',
8762=>'ON',
8763=>'ON',
8764=>'ON',
8765=>'ON',
8766=>'ON',
8767=>'ON',
8768=>'ON',
8769=>'ON',
8770=>'ON',
8771=>'ON',
8772=>'ON',
8773=>'ON',
8774=>'ON',
8775=>'ON',
8776=>'ON',
8777=>'ON',
8778=>'ON',
8779=>'ON',
8780=>'ON',
8781=>'ON',
8782=>'ON',
8783=>'ON',
8784=>'ON',
8785=>'ON',
8786=>'ON',
8787=>'ON',
8788=>'ON',
8789=>'ON',
8790=>'ON',
8791=>'ON',
8792=>'ON',
8793=>'ON',
8794=>'ON',
8795=>'ON',
8796=>'ON',
8797=>'ON',
8798=>'ON',
8799=>'ON',
8800=>'ON',
8801=>'ON',
8802=>'ON',
8803=>'ON',
8804=>'ON',
8805=>'ON',
8806=>'ON',
8807=>'ON',
8808=>'ON',
8809=>'ON',
8810=>'ON',
8811=>'ON',
8812=>'ON',
8813=>'ON',
8814=>'ON',
8815=>'ON',
8816=>'ON',
8817=>'ON',
8818=>'ON',
8819=>'ON',
8820=>'ON',
8821=>'ON',
8822=>'ON',
8823=>'ON',
8824=>'ON',
8825=>'ON',
8826=>'ON',
8827=>'ON',
8828=>'ON',
8829=>'ON',
8830=>'ON',
8831=>'ON',
8832=>'ON',
8833=>'ON',
8834=>'ON',
8835=>'ON',
8836=>'ON',
8837=>'ON',
8838=>'ON',
8839=>'ON',
8840=>'ON',
8841=>'ON',
8842=>'ON',
8843=>'ON',
8844=>'ON',
8845=>'ON',
8846=>'ON',
8847=>'ON',
8848=>'ON',
8849=>'ON',
8850=>'ON',
8851=>'ON',
8852=>'ON',
8853=>'ON',
8854=>'ON',
8855=>'ON',
8856=>'ON',
8857=>'ON',
8858=>'ON',
8859=>'ON',
8860=>'ON',
8861=>'ON',
8862=>'ON',
8863=>'ON',
8864=>'ON',
8865=>'ON',
8866=>'ON',
8867=>'ON',
8868=>'ON',
8869=>'ON',
8870=>'ON',
8871=>'ON',
8872=>'ON',
8873=>'ON',
8874=>'ON',
8875=>'ON',
8876=>'ON',
8877=>'ON',
8878=>'ON',
8879=>'ON',
8880=>'ON',
8881=>'ON',
8882=>'ON',
8883=>'ON',
8884=>'ON',
8885=>'ON',
8886=>'ON',
8887=>'ON',
8888=>'ON',
8889=>'ON',
8890=>'ON',
8891=>'ON',
8892=>'ON',
8893=>'ON',
8894=>'ON',
8895=>'ON',
8896=>'ON',
8897=>'ON',
8898=>'ON',
8899=>'ON',
8900=>'ON',
8901=>'ON',
8902=>'ON',
8903=>'ON',
8904=>'ON',
8905=>'ON',
8906=>'ON',
8907=>'ON',
8908=>'ON',
8909=>'ON',
8910=>'ON',
8911=>'ON',
8912=>'ON',
8913=>'ON',
8914=>'ON',
8915=>'ON',
8916=>'ON',
8917=>'ON',
8918=>'ON',
8919=>'ON',
8920=>'ON',
8921=>'ON',
8922=>'ON',
8923=>'ON',
8924=>'ON',
8925=>'ON',
8926=>'ON',
8927=>'ON',
8928=>'ON',
8929=>'ON',
8930=>'ON',
8931=>'ON',
8932=>'ON',
8933=>'ON',
8934=>'ON',
8935=>'ON',
8936=>'ON',
8937=>'ON',
8938=>'ON',
8939=>'ON',
8940=>'ON',
8941=>'ON',
8942=>'ON',
8943=>'ON',
8944=>'ON',
8945=>'ON',
8946=>'ON',
8947=>'ON',
8948=>'ON',
8949=>'ON',
8950=>'ON',
8951=>'ON',
8952=>'ON',
8953=>'ON',
8954=>'ON',
8955=>'ON',
8956=>'ON',
8957=>'ON',
8958=>'ON',
8959=>'ON',
8960=>'ON',
8961=>'ON',
8962=>'ON',
8963=>'ON',
8964=>'ON',
8965=>'ON',
8966=>'ON',
8967=>'ON',
8968=>'ON',
8969=>'ON',
8970=>'ON',
8971=>'ON',
8972=>'ON',
8973=>'ON',
8974=>'ON',
8975=>'ON',
8976=>'ON',
8977=>'ON',
8978=>'ON',
8979=>'ON',
8980=>'ON',
8981=>'ON',
8982=>'ON',
8983=>'ON',
8984=>'ON',
8985=>'ON',
8986=>'ON',
8987=>'ON',
8988=>'ON',
8989=>'ON',
8990=>'ON',
8991=>'ON',
8992=>'ON',
8993=>'ON',
8994=>'ON',
8995=>'ON',
8996=>'ON',
8997=>'ON',
8998=>'ON',
8999=>'ON',
9000=>'ON',
9001=>'ON',
9002=>'ON',
9003=>'ON',
9004=>'ON',
9005=>'ON',
9006=>'ON',
9007=>'ON',
9008=>'ON',
9009=>'ON',
9010=>'ON',
9011=>'ON',
9012=>'ON',
9013=>'ON',
9014=>'L',
9015=>'L',
9016=>'L',
9017=>'L',
9018=>'L',
9019=>'L',
9020=>'L',
9021=>'L',
9022=>'L',
9023=>'L',
9024=>'L',
9025=>'L',
9026=>'L',
9027=>'L',
9028=>'L',
9029=>'L',
9030=>'L',
9031=>'L',
9032=>'L',
9033=>'L',
9034=>'L',
9035=>'L',
9036=>'L',
9037=>'L',
9038=>'L',
9039=>'L',
9040=>'L',
9041=>'L',
9042=>'L',
9043=>'L',
9044=>'L',
9045=>'L',
9046=>'L',
9047=>'L',
9048=>'L',
9049=>'L',
9050=>'L',
9051=>'L',
9052=>'L',
9053=>'L',
9054=>'L',
9055=>'L',
9056=>'L',
9057=>'L',
9058=>'L',
9059=>'L',
9060=>'L',
9061=>'L',
9062=>'L',
9063=>'L',
9064=>'L',
9065=>'L',
9066=>'L',
9067=>'L',
9068=>'L',
9069=>'L',
9070=>'L',
9071=>'L',
9072=>'L',
9073=>'L',
9074=>'L',
9075=>'L',
9076=>'L',
9077=>'L',
9078=>'L',
9079=>'L',
9080=>'L',
9081=>'L',
9082=>'L',
9083=>'ON',
9084=>'ON',
9085=>'ON',
9086=>'ON',
9087=>'ON',
9088=>'ON',
9089=>'ON',
9090=>'ON',
9091=>'ON',
9092=>'ON',
9093=>'ON',
9094=>'ON',
9095=>'ON',
9096=>'ON',
9097=>'ON',
9098=>'ON',
9099=>'ON',
9100=>'ON',
9101=>'ON',
9102=>'ON',
9103=>'ON',
9104=>'ON',
9105=>'ON',
9106=>'ON',
9107=>'ON',
9108=>'ON',
9109=>'L',
9110=>'ON',
9111=>'ON',
9112=>'ON',
9113=>'ON',
9114=>'ON',
9115=>'ON',
9116=>'ON',
9117=>'ON',
9118=>'ON',
9119=>'ON',
9120=>'ON',
9121=>'ON',
9122=>'ON',
9123=>'ON',
9124=>'ON',
9125=>'ON',
9126=>'ON',
9127=>'ON',
9128=>'ON',
9129=>'ON',
9130=>'ON',
9131=>'ON',
9132=>'ON',
9133=>'ON',
9134=>'ON',
9135=>'ON',
9136=>'ON',
9137=>'ON',
9138=>'ON',
9139=>'ON',
9140=>'ON',
9141=>'ON',
9142=>'ON',
9143=>'ON',
9144=>'ON',
9145=>'ON',
9146=>'ON',
9147=>'ON',
9148=>'ON',
9149=>'ON',
9150=>'ON',
9151=>'ON',
9152=>'ON',
9153=>'ON',
9154=>'ON',
9155=>'ON',
9156=>'ON',
9157=>'ON',
9158=>'ON',
9159=>'ON',
9160=>'ON',
9161=>'ON',
9162=>'ON',
9163=>'ON',
9164=>'ON',
9165=>'ON',
9166=>'ON',
9167=>'ON',
9168=>'ON',
9169=>'ON',
9170=>'ON',
9171=>'ON',
9172=>'ON',
9173=>'ON',
9174=>'ON',
9175=>'ON',
9176=>'ON',
9177=>'ON',
9178=>'ON',
9179=>'ON',
9180=>'ON',
9181=>'ON',
9182=>'ON',
9183=>'ON',
9184=>'ON',
9185=>'ON',
9186=>'ON',
9187=>'ON',
9188=>'ON',
9189=>'ON',
9190=>'ON',
9191=>'ON',
9216=>'ON',
9217=>'ON',
9218=>'ON',
9219=>'ON',
9220=>'ON',
9221=>'ON',
9222=>'ON',
9223=>'ON',
9224=>'ON',
9225=>'ON',
9226=>'ON',
9227=>'ON',
9228=>'ON',
9229=>'ON',
9230=>'ON',
9231=>'ON',
9232=>'ON',
9233=>'ON',
9234=>'ON',
9235=>'ON',
9236=>'ON',
9237=>'ON',
9238=>'ON',
9239=>'ON',
9240=>'ON',
9241=>'ON',
9242=>'ON',
9243=>'ON',
9244=>'ON',
9245=>'ON',
9246=>'ON',
9247=>'ON',
9248=>'ON',
9249=>'ON',
9250=>'ON',
9251=>'ON',
9252=>'ON',
9253=>'ON',
9254=>'ON',
9280=>'ON',
9281=>'ON',
9282=>'ON',
9283=>'ON',
9284=>'ON',
9285=>'ON',
9286=>'ON',
9287=>'ON',
9288=>'ON',
9289=>'ON',
9290=>'ON',
9312=>'ON',
9313=>'ON',
9314=>'ON',
9315=>'ON',
9316=>'ON',
9317=>'ON',
9318=>'ON',
9319=>'ON',
9320=>'ON',
9321=>'ON',
9322=>'ON',
9323=>'ON',
9324=>'ON',
9325=>'ON',
9326=>'ON',
9327=>'ON',
9328=>'ON',
9329=>'ON',
9330=>'ON',
9331=>'ON',
9332=>'ON',
9333=>'ON',
9334=>'ON',
9335=>'ON',
9336=>'ON',
9337=>'ON',
9338=>'ON',
9339=>'ON',
9340=>'ON',
9341=>'ON',
9342=>'ON',
9343=>'ON',
9344=>'ON',
9345=>'ON',
9346=>'ON',
9347=>'ON',
9348=>'ON',
9349=>'ON',
9350=>'ON',
9351=>'ON',
9352=>'EN',
9353=>'EN',
9354=>'EN',
9355=>'EN',
9356=>'EN',
9357=>'EN',
9358=>'EN',
9359=>'EN',
9360=>'EN',
9361=>'EN',
9362=>'EN',
9363=>'EN',
9364=>'EN',
9365=>'EN',
9366=>'EN',
9367=>'EN',
9368=>'EN',
9369=>'EN',
9370=>'EN',
9371=>'EN',
9372=>'L',
9373=>'L',
9374=>'L',
9375=>'L',
9376=>'L',
9377=>'L',
9378=>'L',
9379=>'L',
9380=>'L',
9381=>'L',
9382=>'L',
9383=>'L',
9384=>'L',
9385=>'L',
9386=>'L',
9387=>'L',
9388=>'L',
9389=>'L',
9390=>'L',
9391=>'L',
9392=>'L',
9393=>'L',
9394=>'L',
9395=>'L',
9396=>'L',
9397=>'L',
9398=>'L',
9399=>'L',
9400=>'L',
9401=>'L',
9402=>'L',
9403=>'L',
9404=>'L',
9405=>'L',
9406=>'L',
9407=>'L',
9408=>'L',
9409=>'L',
9410=>'L',
9411=>'L',
9412=>'L',
9413=>'L',
9414=>'L',
9415=>'L',
9416=>'L',
9417=>'L',
9418=>'L',
9419=>'L',
9420=>'L',
9421=>'L',
9422=>'L',
9423=>'L',
9424=>'L',
9425=>'L',
9426=>'L',
9427=>'L',
9428=>'L',
9429=>'L',
9430=>'L',
9431=>'L',
9432=>'L',
9433=>'L',
9434=>'L',
9435=>'L',
9436=>'L',
9437=>'L',
9438=>'L',
9439=>'L',
9440=>'L',
9441=>'L',
9442=>'L',
9443=>'L',
9444=>'L',
9445=>'L',
9446=>'L',
9447=>'L',
9448=>'L',
9449=>'L',
9450=>'ON',
9451=>'ON',
9452=>'ON',
9453=>'ON',
9454=>'ON',
9455=>'ON',
9456=>'ON',
9457=>'ON',
9458=>'ON',
9459=>'ON',
9460=>'ON',
9461=>'ON',
9462=>'ON',
9463=>'ON',
9464=>'ON',
9465=>'ON',
9466=>'ON',
9467=>'ON',
9468=>'ON',
9469=>'ON',
9470=>'ON',
9471=>'ON',
9472=>'ON',
9473=>'ON',
9474=>'ON',
9475=>'ON',
9476=>'ON',
9477=>'ON',
9478=>'ON',
9479=>'ON',
9480=>'ON',
9481=>'ON',
9482=>'ON',
9483=>'ON',
9484=>'ON',
9485=>'ON',
9486=>'ON',
9487=>'ON',
9488=>'ON',
9489=>'ON',
9490=>'ON',
9491=>'ON',
9492=>'ON',
9493=>'ON',
9494=>'ON',
9495=>'ON',
9496=>'ON',
9497=>'ON',
9498=>'ON',
9499=>'ON',
9500=>'ON',
9501=>'ON',
9502=>'ON',
9503=>'ON',
9504=>'ON',
9505=>'ON',
9506=>'ON',
9507=>'ON',
9508=>'ON',
9509=>'ON',
9510=>'ON',
9511=>'ON',
9512=>'ON',
9513=>'ON',
9514=>'ON',
9515=>'ON',
9516=>'ON',
9517=>'ON',
9518=>'ON',
9519=>'ON',
9520=>'ON',
9521=>'ON',
9522=>'ON',
9523=>'ON',
9524=>'ON',
9525=>'ON',
9526=>'ON',
9527=>'ON',
9528=>'ON',
9529=>'ON',
9530=>'ON',
9531=>'ON',
9532=>'ON',
9533=>'ON',
9534=>'ON',
9535=>'ON',
9536=>'ON',
9537=>'ON',
9538=>'ON',
9539=>'ON',
9540=>'ON',
9541=>'ON',
9542=>'ON',
9543=>'ON',
9544=>'ON',
9545=>'ON',
9546=>'ON',
9547=>'ON',
9548=>'ON',
9549=>'ON',
9550=>'ON',
9551=>'ON',
9552=>'ON',
9553=>'ON',
9554=>'ON',
9555=>'ON',
9556=>'ON',
9557=>'ON',
9558=>'ON',
9559=>'ON',
9560=>'ON',
9561=>'ON',
9562=>'ON',
9563=>'ON',
9564=>'ON',
9565=>'ON',
9566=>'ON',
9567=>'ON',
9568=>'ON',
9569=>'ON',
9570=>'ON',
9571=>'ON',
9572=>'ON',
9573=>'ON',
9574=>'ON',
9575=>'ON',
9576=>'ON',
9577=>'ON',
9578=>'ON',
9579=>'ON',
9580=>'ON',
9581=>'ON',
9582=>'ON',
9583=>'ON',
9584=>'ON',
9585=>'ON',
9586=>'ON',
9587=>'ON',
9588=>'ON',
9589=>'ON',
9590=>'ON',
9591=>'ON',
9592=>'ON',
9593=>'ON',
9594=>'ON',
9595=>'ON',
9596=>'ON',
9597=>'ON',
9598=>'ON',
9599=>'ON',
9600=>'ON',
9601=>'ON',
9602=>'ON',
9603=>'ON',
9604=>'ON',
9605=>'ON',
9606=>'ON',
9607=>'ON',
9608=>'ON',
9609=>'ON',
9610=>'ON',
9611=>'ON',
9612=>'ON',
9613=>'ON',
9614=>'ON',
9615=>'ON',
9616=>'ON',
9617=>'ON',
9618=>'ON',
9619=>'ON',
9620=>'ON',
9621=>'ON',
9622=>'ON',
9623=>'ON',
9624=>'ON',
9625=>'ON',
9626=>'ON',
9627=>'ON',
9628=>'ON',
9629=>'ON',
9630=>'ON',
9631=>'ON',
9632=>'ON',
9633=>'ON',
9634=>'ON',
9635=>'ON',
9636=>'ON',
9637=>'ON',
9638=>'ON',
9639=>'ON',
9640=>'ON',
9641=>'ON',
9642=>'ON',
9643=>'ON',
9644=>'ON',
9645=>'ON',
9646=>'ON',
9647=>'ON',
9648=>'ON',
9649=>'ON',
9650=>'ON',
9651=>'ON',
9652=>'ON',
9653=>'ON',
9654=>'ON',
9655=>'ON',
9656=>'ON',
9657=>'ON',
9658=>'ON',
9659=>'ON',
9660=>'ON',
9661=>'ON',
9662=>'ON',
9663=>'ON',
9664=>'ON',
9665=>'ON',
9666=>'ON',
9667=>'ON',
9668=>'ON',
9669=>'ON',
9670=>'ON',
9671=>'ON',
9672=>'ON',
9673=>'ON',
9674=>'ON',
9675=>'ON',
9676=>'ON',
9677=>'ON',
9678=>'ON',
9679=>'ON',
9680=>'ON',
9681=>'ON',
9682=>'ON',
9683=>'ON',
9684=>'ON',
9685=>'ON',
9686=>'ON',
9687=>'ON',
9688=>'ON',
9689=>'ON',
9690=>'ON',
9691=>'ON',
9692=>'ON',
9693=>'ON',
9694=>'ON',
9695=>'ON',
9696=>'ON',
9697=>'ON',
9698=>'ON',
9699=>'ON',
9700=>'ON',
9701=>'ON',
9702=>'ON',
9703=>'ON',
9704=>'ON',
9705=>'ON',
9706=>'ON',
9707=>'ON',
9708=>'ON',
9709=>'ON',
9710=>'ON',
9711=>'ON',
9712=>'ON',
9713=>'ON',
9714=>'ON',
9715=>'ON',
9716=>'ON',
9717=>'ON',
9718=>'ON',
9719=>'ON',
9720=>'ON',
9721=>'ON',
9722=>'ON',
9723=>'ON',
9724=>'ON',
9725=>'ON',
9726=>'ON',
9727=>'ON',
9728=>'ON',
9729=>'ON',
9730=>'ON',
9731=>'ON',
9732=>'ON',
9733=>'ON',
9734=>'ON',
9735=>'ON',
9736=>'ON',
9737=>'ON',
9738=>'ON',
9739=>'ON',
9740=>'ON',
9741=>'ON',
9742=>'ON',
9743=>'ON',
9744=>'ON',
9745=>'ON',
9746=>'ON',
9747=>'ON',
9748=>'ON',
9749=>'ON',
9750=>'ON',
9751=>'ON',
9752=>'ON',
9753=>'ON',
9754=>'ON',
9755=>'ON',
9756=>'ON',
9757=>'ON',
9758=>'ON',
9759=>'ON',
9760=>'ON',
9761=>'ON',
9762=>'ON',
9763=>'ON',
9764=>'ON',
9765=>'ON',
9766=>'ON',
9767=>'ON',
9768=>'ON',
9769=>'ON',
9770=>'ON',
9771=>'ON',
9772=>'ON',
9773=>'ON',
9774=>'ON',
9775=>'ON',
9776=>'ON',
9777=>'ON',
9778=>'ON',
9779=>'ON',
9780=>'ON',
9781=>'ON',
9782=>'ON',
9783=>'ON',
9784=>'ON',
9785=>'ON',
9786=>'ON',
9787=>'ON',
9788=>'ON',
9789=>'ON',
9790=>'ON',
9791=>'ON',
9792=>'ON',
9793=>'ON',
9794=>'ON',
9795=>'ON',
9796=>'ON',
9797=>'ON',
9798=>'ON',
9799=>'ON',
9800=>'ON',
9801=>'ON',
9802=>'ON',
9803=>'ON',
9804=>'ON',
9805=>'ON',
9806=>'ON',
9807=>'ON',
9808=>'ON',
9809=>'ON',
9810=>'ON',
9811=>'ON',
9812=>'ON',
9813=>'ON',
9814=>'ON',
9815=>'ON',
9816=>'ON',
9817=>'ON',
9818=>'ON',
9819=>'ON',
9820=>'ON',
9821=>'ON',
9822=>'ON',
9823=>'ON',
9824=>'ON',
9825=>'ON',
9826=>'ON',
9827=>'ON',
9828=>'ON',
9829=>'ON',
9830=>'ON',
9831=>'ON',
9832=>'ON',
9833=>'ON',
9834=>'ON',
9835=>'ON',
9836=>'ON',
9837=>'ON',
9838=>'ON',
9839=>'ON',
9840=>'ON',
9841=>'ON',
9842=>'ON',
9843=>'ON',
9844=>'ON',
9845=>'ON',
9846=>'ON',
9847=>'ON',
9848=>'ON',
9849=>'ON',
9850=>'ON',
9851=>'ON',
9852=>'ON',
9853=>'ON',
9854=>'ON',
9855=>'ON',
9856=>'ON',
9857=>'ON',
9858=>'ON',
9859=>'ON',
9860=>'ON',
9861=>'ON',
9862=>'ON',
9863=>'ON',
9864=>'ON',
9865=>'ON',
9866=>'ON',
9867=>'ON',
9868=>'ON',
9869=>'ON',
9870=>'ON',
9871=>'ON',
9872=>'ON',
9873=>'ON',
9874=>'ON',
9875=>'ON',
9876=>'ON',
9877=>'ON',
9878=>'ON',
9879=>'ON',
9880=>'ON',
9881=>'ON',
9882=>'ON',
9883=>'ON',
9884=>'ON',
9888=>'ON',
9889=>'ON',
9890=>'ON',
9891=>'ON',
9892=>'ON',
9893=>'ON',
9894=>'ON',
9895=>'ON',
9896=>'ON',
9897=>'ON',
9898=>'ON',
9899=>'ON',
9900=>'L',
9901=>'ON',
9902=>'ON',
9903=>'ON',
9904=>'ON',
9905=>'ON',
9906=>'ON',
9985=>'ON',
9986=>'ON',
9987=>'ON',
9988=>'ON',
9990=>'ON',
9991=>'ON',
9992=>'ON',
9993=>'ON',
9996=>'ON',
9997=>'ON',
9998=>'ON',
9999=>'ON',
10000=>'ON',
10001=>'ON',
10002=>'ON',
10003=>'ON',
10004=>'ON',
10005=>'ON',
10006=>'ON',
10007=>'ON',
10008=>'ON',
10009=>'ON',
10010=>'ON',
10011=>'ON',
10012=>'ON',
10013=>'ON',
10014=>'ON',
10015=>'ON',
10016=>'ON',
10017=>'ON',
10018=>'ON',
10019=>'ON',
10020=>'ON',
10021=>'ON',
10022=>'ON',
10023=>'ON',
10025=>'ON',
10026=>'ON',
10027=>'ON',
10028=>'ON',
10029=>'ON',
10030=>'ON',
10031=>'ON',
10032=>'ON',
10033=>'ON',
10034=>'ON',
10035=>'ON',
10036=>'ON',
10037=>'ON',
10038=>'ON',
10039=>'ON',
10040=>'ON',
10041=>'ON',
10042=>'ON',
10043=>'ON',
10044=>'ON',
10045=>'ON',
10046=>'ON',
10047=>'ON',
10048=>'ON',
10049=>'ON',
10050=>'ON',
10051=>'ON',
10052=>'ON',
10053=>'ON',
10054=>'ON',
10055=>'ON',
10056=>'ON',
10057=>'ON',
10058=>'ON',
10059=>'ON',
10061=>'ON',
10063=>'ON',
10064=>'ON',
10065=>'ON',
10066=>'ON',
10070=>'ON',
10072=>'ON',
10073=>'ON',
10074=>'ON',
10075=>'ON',
10076=>'ON',
10077=>'ON',
10078=>'ON',
10081=>'ON',
10082=>'ON',
10083=>'ON',
10084=>'ON',
10085=>'ON',
10086=>'ON',
10087=>'ON',
10088=>'ON',
10089=>'ON',
10090=>'ON',
10091=>'ON',
10092=>'ON',
10093=>'ON',
10094=>'ON',
10095=>'ON',
10096=>'ON',
10097=>'ON',
10098=>'ON',
10099=>'ON',
10100=>'ON',
10101=>'ON',
10102=>'ON',
10103=>'ON',
10104=>'ON',
10105=>'ON',
10106=>'ON',
10107=>'ON',
10108=>'ON',
10109=>'ON',
10110=>'ON',
10111=>'ON',
10112=>'ON',
10113=>'ON',
10114=>'ON',
10115=>'ON',
10116=>'ON',
10117=>'ON',
10118=>'ON',
10119=>'ON',
10120=>'ON',
10121=>'ON',
10122=>'ON',
10123=>'ON',
10124=>'ON',
10125=>'ON',
10126=>'ON',
10127=>'ON',
10128=>'ON',
10129=>'ON',
10130=>'ON',
10131=>'ON',
10132=>'ON',
10136=>'ON',
10137=>'ON',
10138=>'ON',
10139=>'ON',
10140=>'ON',
10141=>'ON',
10142=>'ON',
10143=>'ON',
10144=>'ON',
10145=>'ON',
10146=>'ON',
10147=>'ON',
10148=>'ON',
10149=>'ON',
10150=>'ON',
10151=>'ON',
10152=>'ON',
10153=>'ON',
10154=>'ON',
10155=>'ON',
10156=>'ON',
10157=>'ON',
10158=>'ON',
10159=>'ON',
10161=>'ON',
10162=>'ON',
10163=>'ON',
10164=>'ON',
10165=>'ON',
10166=>'ON',
10167=>'ON',
10168=>'ON',
10169=>'ON',
10170=>'ON',
10171=>'ON',
10172=>'ON',
10173=>'ON',
10174=>'ON',
10176=>'ON',
10177=>'ON',
10178=>'ON',
10179=>'ON',
10180=>'ON',
10181=>'ON',
10182=>'ON',
10183=>'ON',
10184=>'ON',
10185=>'ON',
10186=>'ON',
10192=>'ON',
10193=>'ON',
10194=>'ON',
10195=>'ON',
10196=>'ON',
10197=>'ON',
10198=>'ON',
10199=>'ON',
10200=>'ON',
10201=>'ON',
10202=>'ON',
10203=>'ON',
10204=>'ON',
10205=>'ON',
10206=>'ON',
10207=>'ON',
10208=>'ON',
10209=>'ON',
10210=>'ON',
10211=>'ON',
10212=>'ON',
10213=>'ON',
10214=>'ON',
10215=>'ON',
10216=>'ON',
10217=>'ON',
10218=>'ON',
10219=>'ON',
10224=>'ON',
10225=>'ON',
10226=>'ON',
10227=>'ON',
10228=>'ON',
10229=>'ON',
10230=>'ON',
10231=>'ON',
10232=>'ON',
10233=>'ON',
10234=>'ON',
10235=>'ON',
10236=>'ON',
10237=>'ON',
10238=>'ON',
10239=>'ON',
10240=>'L',
10241=>'L',
10242=>'L',
10243=>'L',
10244=>'L',
10245=>'L',
10246=>'L',
10247=>'L',
10248=>'L',
10249=>'L',
10250=>'L',
10251=>'L',
10252=>'L',
10253=>'L',
10254=>'L',
10255=>'L',
10256=>'L',
10257=>'L',
10258=>'L',
10259=>'L',
10260=>'L',
10261=>'L',
10262=>'L',
10263=>'L',
10264=>'L',
10265=>'L',
10266=>'L',
10267=>'L',
10268=>'L',
10269=>'L',
10270=>'L',
10271=>'L',
10272=>'L',
10273=>'L',
10274=>'L',
10275=>'L',
10276=>'L',
10277=>'L',
10278=>'L',
10279=>'L',
10280=>'L',
10281=>'L',
10282=>'L',
10283=>'L',
10284=>'L',
10285=>'L',
10286=>'L',
10287=>'L',
10288=>'L',
10289=>'L',
10290=>'L',
10291=>'L',
10292=>'L',
10293=>'L',
10294=>'L',
10295=>'L',
10296=>'L',
10297=>'L',
10298=>'L',
10299=>'L',
10300=>'L',
10301=>'L',
10302=>'L',
10303=>'L',
10304=>'L',
10305=>'L',
10306=>'L',
10307=>'L',
10308=>'L',
10309=>'L',
10310=>'L',
10311=>'L',
10312=>'L',
10313=>'L',
10314=>'L',
10315=>'L',
10316=>'L',
10317=>'L',
10318=>'L',
10319=>'L',
10320=>'L',
10321=>'L',
10322=>'L',
10323=>'L',
10324=>'L',
10325=>'L',
10326=>'L',
10327=>'L',
10328=>'L',
10329=>'L',
10330=>'L',
10331=>'L',
10332=>'L',
10333=>'L',
10334=>'L',
10335=>'L',
10336=>'L',
10337=>'L',
10338=>'L',
10339=>'L',
10340=>'L',
10341=>'L',
10342=>'L',
10343=>'L',
10344=>'L',
10345=>'L',
10346=>'L',
10347=>'L',
10348=>'L',
10349=>'L',
10350=>'L',
10351=>'L',
10352=>'L',
10353=>'L',
10354=>'L',
10355=>'L',
10356=>'L',
10357=>'L',
10358=>'L',
10359=>'L',
10360=>'L',
10361=>'L',
10362=>'L',
10363=>'L',
10364=>'L',
10365=>'L',
10366=>'L',
10367=>'L',
10368=>'L',
10369=>'L',
10370=>'L',
10371=>'L',
10372=>'L',
10373=>'L',
10374=>'L',
10375=>'L',
10376=>'L',
10377=>'L',
10378=>'L',
10379=>'L',
10380=>'L',
10381=>'L',
10382=>'L',
10383=>'L',
10384=>'L',
10385=>'L',
10386=>'L',
10387=>'L',
10388=>'L',
10389=>'L',
10390=>'L',
10391=>'L',
10392=>'L',
10393=>'L',
10394=>'L',
10395=>'L',
10396=>'L',
10397=>'L',
10398=>'L',
10399=>'L',
10400=>'L',
10401=>'L',
10402=>'L',
10403=>'L',
10404=>'L',
10405=>'L',
10406=>'L',
10407=>'L',
10408=>'L',
10409=>'L',
10410=>'L',
10411=>'L',
10412=>'L',
10413=>'L',
10414=>'L',
10415=>'L',
10416=>'L',
10417=>'L',
10418=>'L',
10419=>'L',
10420=>'L',
10421=>'L',
10422=>'L',
10423=>'L',
10424=>'L',
10425=>'L',
10426=>'L',
10427=>'L',
10428=>'L',
10429=>'L',
10430=>'L',
10431=>'L',
10432=>'L',
10433=>'L',
10434=>'L',
10435=>'L',
10436=>'L',
10437=>'L',
10438=>'L',
10439=>'L',
10440=>'L',
10441=>'L',
10442=>'L',
10443=>'L',
10444=>'L',
10445=>'L',
10446=>'L',
10447=>'L',
10448=>'L',
10449=>'L',
10450=>'L',
10451=>'L',
10452=>'L',
10453=>'L',
10454=>'L',
10455=>'L',
10456=>'L',
10457=>'L',
10458=>'L',
10459=>'L',
10460=>'L',
10461=>'L',
10462=>'L',
10463=>'L',
10464=>'L',
10465=>'L',
10466=>'L',
10467=>'L',
10468=>'L',
10469=>'L',
10470=>'L',
10471=>'L',
10472=>'L',
10473=>'L',
10474=>'L',
10475=>'L',
10476=>'L',
10477=>'L',
10478=>'L',
10479=>'L',
10480=>'L',
10481=>'L',
10482=>'L',
10483=>'L',
10484=>'L',
10485=>'L',
10486=>'L',
10487=>'L',
10488=>'L',
10489=>'L',
10490=>'L',
10491=>'L',
10492=>'L',
10493=>'L',
10494=>'L',
10495=>'L',
10496=>'ON',
10497=>'ON',
10498=>'ON',
10499=>'ON',
10500=>'ON',
10501=>'ON',
10502=>'ON',
10503=>'ON',
10504=>'ON',
10505=>'ON',
10506=>'ON',
10507=>'ON',
10508=>'ON',
10509=>'ON',
10510=>'ON',
10511=>'ON',
10512=>'ON',
10513=>'ON',
10514=>'ON',
10515=>'ON',
10516=>'ON',
10517=>'ON',
10518=>'ON',
10519=>'ON',
10520=>'ON',
10521=>'ON',
10522=>'ON',
10523=>'ON',
10524=>'ON',
10525=>'ON',
10526=>'ON',
10527=>'ON',
10528=>'ON',
10529=>'ON',
10530=>'ON',
10531=>'ON',
10532=>'ON',
10533=>'ON',
10534=>'ON',
10535=>'ON',
10536=>'ON',
10537=>'ON',
10538=>'ON',
10539=>'ON',
10540=>'ON',
10541=>'ON',
10542=>'ON',
10543=>'ON',
10544=>'ON',
10545=>'ON',
10546=>'ON',
10547=>'ON',
10548=>'ON',
10549=>'ON',
10550=>'ON',
10551=>'ON',
10552=>'ON',
10553=>'ON',
10554=>'ON',
10555=>'ON',
10556=>'ON',
10557=>'ON',
10558=>'ON',
10559=>'ON',
10560=>'ON',
10561=>'ON',
10562=>'ON',
10563=>'ON',
10564=>'ON',
10565=>'ON',
10566=>'ON',
10567=>'ON',
10568=>'ON',
10569=>'ON',
10570=>'ON',
10571=>'ON',
10572=>'ON',
10573=>'ON',
10574=>'ON',
10575=>'ON',
10576=>'ON',
10577=>'ON',
10578=>'ON',
10579=>'ON',
10580=>'ON',
10581=>'ON',
10582=>'ON',
10583=>'ON',
10584=>'ON',
10585=>'ON',
10586=>'ON',
10587=>'ON',
10588=>'ON',
10589=>'ON',
10590=>'ON',
10591=>'ON',
10592=>'ON',
10593=>'ON',
10594=>'ON',
10595=>'ON',
10596=>'ON',
10597=>'ON',
10598=>'ON',
10599=>'ON',
10600=>'ON',
10601=>'ON',
10602=>'ON',
10603=>'ON',
10604=>'ON',
10605=>'ON',
10606=>'ON',
10607=>'ON',
10608=>'ON',
10609=>'ON',
10610=>'ON',
10611=>'ON',
10612=>'ON',
10613=>'ON',
10614=>'ON',
10615=>'ON',
10616=>'ON',
10617=>'ON',
10618=>'ON',
10619=>'ON',
10620=>'ON',
10621=>'ON',
10622=>'ON',
10623=>'ON',
10624=>'ON',
10625=>'ON',
10626=>'ON',
10627=>'ON',
10628=>'ON',
10629=>'ON',
10630=>'ON',
10631=>'ON',
10632=>'ON',
10633=>'ON',
10634=>'ON',
10635=>'ON',
10636=>'ON',
10637=>'ON',
10638=>'ON',
10639=>'ON',
10640=>'ON',
10641=>'ON',
10642=>'ON',
10643=>'ON',
10644=>'ON',
10645=>'ON',
10646=>'ON',
10647=>'ON',
10648=>'ON',
10649=>'ON',
10650=>'ON',
10651=>'ON',
10652=>'ON',
10653=>'ON',
10654=>'ON',
10655=>'ON',
10656=>'ON',
10657=>'ON',
10658=>'ON',
10659=>'ON',
10660=>'ON',
10661=>'ON',
10662=>'ON',
10663=>'ON',
10664=>'ON',
10665=>'ON',
10666=>'ON',
10667=>'ON',
10668=>'ON',
10669=>'ON',
10670=>'ON',
10671=>'ON',
10672=>'ON',
10673=>'ON',
10674=>'ON',
10675=>'ON',
10676=>'ON',
10677=>'ON',
10678=>'ON',
10679=>'ON',
10680=>'ON',
10681=>'ON',
10682=>'ON',
10683=>'ON',
10684=>'ON',
10685=>'ON',
10686=>'ON',
10687=>'ON',
10688=>'ON',
10689=>'ON',
10690=>'ON',
10691=>'ON',
10692=>'ON',
10693=>'ON',
10694=>'ON',
10695=>'ON',
10696=>'ON',
10697=>'ON',
10698=>'ON',
10699=>'ON',
10700=>'ON',
10701=>'ON',
10702=>'ON',
10703=>'ON',
10704=>'ON',
10705=>'ON',
10706=>'ON',
10707=>'ON',
10708=>'ON',
10709=>'ON',
10710=>'ON',
10711=>'ON',
10712=>'ON',
10713=>'ON',
10714=>'ON',
10715=>'ON',
10716=>'ON',
10717=>'ON',
10718=>'ON',
10719=>'ON',
10720=>'ON',
10721=>'ON',
10722=>'ON',
10723=>'ON',
10724=>'ON',
10725=>'ON',
10726=>'ON',
10727=>'ON',
10728=>'ON',
10729=>'ON',
10730=>'ON',
10731=>'ON',
10732=>'ON',
10733=>'ON',
10734=>'ON',
10735=>'ON',
10736=>'ON',
10737=>'ON',
10738=>'ON',
10739=>'ON',
10740=>'ON',
10741=>'ON',
10742=>'ON',
10743=>'ON',
10744=>'ON',
10745=>'ON',
10746=>'ON',
10747=>'ON',
10748=>'ON',
10749=>'ON',
10750=>'ON',
10751=>'ON',
10752=>'ON',
10753=>'ON',
10754=>'ON',
10755=>'ON',
10756=>'ON',
10757=>'ON',
10758=>'ON',
10759=>'ON',
10760=>'ON',
10761=>'ON',
10762=>'ON',
10763=>'ON',
10764=>'ON',
10765=>'ON',
10766=>'ON',
10767=>'ON',
10768=>'ON',
10769=>'ON',
10770=>'ON',
10771=>'ON',
10772=>'ON',
10773=>'ON',
10774=>'ON',
10775=>'ON',
10776=>'ON',
10777=>'ON',
10778=>'ON',
10779=>'ON',
10780=>'ON',
10781=>'ON',
10782=>'ON',
10783=>'ON',
10784=>'ON',
10785=>'ON',
10786=>'ON',
10787=>'ON',
10788=>'ON',
10789=>'ON',
10790=>'ON',
10791=>'ON',
10792=>'ON',
10793=>'ON',
10794=>'ON',
10795=>'ON',
10796=>'ON',
10797=>'ON',
10798=>'ON',
10799=>'ON',
10800=>'ON',
10801=>'ON',
10802=>'ON',
10803=>'ON',
10804=>'ON',
10805=>'ON',
10806=>'ON',
10807=>'ON',
10808=>'ON',
10809=>'ON',
10810=>'ON',
10811=>'ON',
10812=>'ON',
10813=>'ON',
10814=>'ON',
10815=>'ON',
10816=>'ON',
10817=>'ON',
10818=>'ON',
10819=>'ON',
10820=>'ON',
10821=>'ON',
10822=>'ON',
10823=>'ON',
10824=>'ON',
10825=>'ON',
10826=>'ON',
10827=>'ON',
10828=>'ON',
10829=>'ON',
10830=>'ON',
10831=>'ON',
10832=>'ON',
10833=>'ON',
10834=>'ON',
10835=>'ON',
10836=>'ON',
10837=>'ON',
10838=>'ON',
10839=>'ON',
10840=>'ON',
10841=>'ON',
10842=>'ON',
10843=>'ON',
10844=>'ON',
10845=>'ON',
10846=>'ON',
10847=>'ON',
10848=>'ON',
10849=>'ON',
10850=>'ON',
10851=>'ON',
10852=>'ON',
10853=>'ON',
10854=>'ON',
10855=>'ON',
10856=>'ON',
10857=>'ON',
10858=>'ON',
10859=>'ON',
10860=>'ON',
10861=>'ON',
10862=>'ON',
10863=>'ON',
10864=>'ON',
10865=>'ON',
10866=>'ON',
10867=>'ON',
10868=>'ON',
10869=>'ON',
10870=>'ON',
10871=>'ON',
10872=>'ON',
10873=>'ON',
10874=>'ON',
10875=>'ON',
10876=>'ON',
10877=>'ON',
10878=>'ON',
10879=>'ON',
10880=>'ON',
10881=>'ON',
10882=>'ON',
10883=>'ON',
10884=>'ON',
10885=>'ON',
10886=>'ON',
10887=>'ON',
10888=>'ON',
10889=>'ON',
10890=>'ON',
10891=>'ON',
10892=>'ON',
10893=>'ON',
10894=>'ON',
10895=>'ON',
10896=>'ON',
10897=>'ON',
10898=>'ON',
10899=>'ON',
10900=>'ON',
10901=>'ON',
10902=>'ON',
10903=>'ON',
10904=>'ON',
10905=>'ON',
10906=>'ON',
10907=>'ON',
10908=>'ON',
10909=>'ON',
10910=>'ON',
10911=>'ON',
10912=>'ON',
10913=>'ON',
10914=>'ON',
10915=>'ON',
10916=>'ON',
10917=>'ON',
10918=>'ON',
10919=>'ON',
10920=>'ON',
10921=>'ON',
10922=>'ON',
10923=>'ON',
10924=>'ON',
10925=>'ON',
10926=>'ON',
10927=>'ON',
10928=>'ON',
10929=>'ON',
10930=>'ON',
10931=>'ON',
10932=>'ON',
10933=>'ON',
10934=>'ON',
10935=>'ON',
10936=>'ON',
10937=>'ON',
10938=>'ON',
10939=>'ON',
10940=>'ON',
10941=>'ON',
10942=>'ON',
10943=>'ON',
10944=>'ON',
10945=>'ON',
10946=>'ON',
10947=>'ON',
10948=>'ON',
10949=>'ON',
10950=>'ON',
10951=>'ON',
10952=>'ON',
10953=>'ON',
10954=>'ON',
10955=>'ON',
10956=>'ON',
10957=>'ON',
10958=>'ON',
10959=>'ON',
10960=>'ON',
10961=>'ON',
10962=>'ON',
10963=>'ON',
10964=>'ON',
10965=>'ON',
10966=>'ON',
10967=>'ON',
10968=>'ON',
10969=>'ON',
10970=>'ON',
10971=>'ON',
10972=>'ON',
10973=>'ON',
10974=>'ON',
10975=>'ON',
10976=>'ON',
10977=>'ON',
10978=>'ON',
10979=>'ON',
10980=>'ON',
10981=>'ON',
10982=>'ON',
10983=>'ON',
10984=>'ON',
10985=>'ON',
10986=>'ON',
10987=>'ON',
10988=>'ON',
10989=>'ON',
10990=>'ON',
10991=>'ON',
10992=>'ON',
10993=>'ON',
10994=>'ON',
10995=>'ON',
10996=>'ON',
10997=>'ON',
10998=>'ON',
10999=>'ON',
11000=>'ON',
11001=>'ON',
11002=>'ON',
11003=>'ON',
11004=>'ON',
11005=>'ON',
11006=>'ON',
11007=>'ON',
11008=>'ON',
11009=>'ON',
11010=>'ON',
11011=>'ON',
11012=>'ON',
11013=>'ON',
11014=>'ON',
11015=>'ON',
11016=>'ON',
11017=>'ON',
11018=>'ON',
11019=>'ON',
11020=>'ON',
11021=>'ON',
11022=>'ON',
11023=>'ON',
11024=>'ON',
11025=>'ON',
11026=>'ON',
11027=>'ON',
11028=>'ON',
11029=>'ON',
11030=>'ON',
11031=>'ON',
11032=>'ON',
11033=>'ON',
11034=>'ON',
11040=>'ON',
11041=>'ON',
11042=>'ON',
11043=>'ON',
11264=>'L',
11265=>'L',
11266=>'L',
11267=>'L',
11268=>'L',
11269=>'L',
11270=>'L',
11271=>'L',
11272=>'L',
11273=>'L',
11274=>'L',
11275=>'L',
11276=>'L',
11277=>'L',
11278=>'L',
11279=>'L',
11280=>'L',
11281=>'L',
11282=>'L',
11283=>'L',
11284=>'L',
11285=>'L',
11286=>'L',
11287=>'L',
11288=>'L',
11289=>'L',
11290=>'L',
11291=>'L',
11292=>'L',
11293=>'L',
11294=>'L',
11295=>'L',
11296=>'L',
11297=>'L',
11298=>'L',
11299=>'L',
11300=>'L',
11301=>'L',
11302=>'L',
11303=>'L',
11304=>'L',
11305=>'L',
11306=>'L',
11307=>'L',
11308=>'L',
11309=>'L',
11310=>'L',
11312=>'L',
11313=>'L',
11314=>'L',
11315=>'L',
11316=>'L',
11317=>'L',
11318=>'L',
11319=>'L',
11320=>'L',
11321=>'L',
11322=>'L',
11323=>'L',
11324=>'L',
11325=>'L',
11326=>'L',
11327=>'L',
11328=>'L',
11329=>'L',
11330=>'L',
11331=>'L',
11332=>'L',
11333=>'L',
11334=>'L',
11335=>'L',
11336=>'L',
11337=>'L',
11338=>'L',
11339=>'L',
11340=>'L',
11341=>'L',
11342=>'L',
11343=>'L',
11344=>'L',
11345=>'L',
11346=>'L',
11347=>'L',
11348=>'L',
11349=>'L',
11350=>'L',
11351=>'L',
11352=>'L',
11353=>'L',
11354=>'L',
11355=>'L',
11356=>'L',
11357=>'L',
11358=>'L',
11360=>'L',
11361=>'L',
11362=>'L',
11363=>'L',
11364=>'L',
11365=>'L',
11366=>'L',
11367=>'L',
11368=>'L',
11369=>'L',
11370=>'L',
11371=>'L',
11372=>'L',
11380=>'L',
11381=>'L',
11382=>'L',
11383=>'L',
11392=>'L',
11393=>'L',
11394=>'L',
11395=>'L',
11396=>'L',
11397=>'L',
11398=>'L',
11399=>'L',
11400=>'L',
11401=>'L',
11402=>'L',
11403=>'L',
11404=>'L',
11405=>'L',
11406=>'L',
11407=>'L',
11408=>'L',
11409=>'L',
11410=>'L',
11411=>'L',
11412=>'L',
11413=>'L',
11414=>'L',
11415=>'L',
11416=>'L',
11417=>'L',
11418=>'L',
11419=>'L',
11420=>'L',
11421=>'L',
11422=>'L',
11423=>'L',
11424=>'L',
11425=>'L',
11426=>'L',
11427=>'L',
11428=>'L',
11429=>'L',
11430=>'L',
11431=>'L',
11432=>'L',
11433=>'L',
11434=>'L',
11435=>'L',
11436=>'L',
11437=>'L',
11438=>'L',
11439=>'L',
11440=>'L',
11441=>'L',
11442=>'L',
11443=>'L',
11444=>'L',
11445=>'L',
11446=>'L',
11447=>'L',
11448=>'L',
11449=>'L',
11450=>'L',
11451=>'L',
11452=>'L',
11453=>'L',
11454=>'L',
11455=>'L',
11456=>'L',
11457=>'L',
11458=>'L',
11459=>'L',
11460=>'L',
11461=>'L',
11462=>'L',
11463=>'L',
11464=>'L',
11465=>'L',
11466=>'L',
11467=>'L',
11468=>'L',
11469=>'L',
11470=>'L',
11471=>'L',
11472=>'L',
11473=>'L',
11474=>'L',
11475=>'L',
11476=>'L',
11477=>'L',
11478=>'L',
11479=>'L',
11480=>'L',
11481=>'L',
11482=>'L',
11483=>'L',
11484=>'L',
11485=>'L',
11486=>'L',
11487=>'L',
11488=>'L',
11489=>'L',
11490=>'L',
11491=>'L',
11492=>'L',
11493=>'ON',
11494=>'ON',
11495=>'ON',
11496=>'ON',
11497=>'ON',
11498=>'ON',
11513=>'ON',
11514=>'ON',
11515=>'ON',
11516=>'ON',
11517=>'ON',
11518=>'ON',
11519=>'ON',
11520=>'L',
11521=>'L',
11522=>'L',
11523=>'L',
11524=>'L',
11525=>'L',
11526=>'L',
11527=>'L',
11528=>'L',
11529=>'L',
11530=>'L',
11531=>'L',
11532=>'L',
11533=>'L',
11534=>'L',
11535=>'L',
11536=>'L',
11537=>'L',
11538=>'L',
11539=>'L',
11540=>'L',
11541=>'L',
11542=>'L',
11543=>'L',
11544=>'L',
11545=>'L',
11546=>'L',
11547=>'L',
11548=>'L',
11549=>'L',
11550=>'L',
11551=>'L',
11552=>'L',
11553=>'L',
11554=>'L',
11555=>'L',
11556=>'L',
11557=>'L',
11568=>'L',
11569=>'L',
11570=>'L',
11571=>'L',
11572=>'L',
11573=>'L',
11574=>'L',
11575=>'L',
11576=>'L',
11577=>'L',
11578=>'L',
11579=>'L',
11580=>'L',
11581=>'L',
11582=>'L',
11583=>'L',
11584=>'L',
11585=>'L',
11586=>'L',
11587=>'L',
11588=>'L',
11589=>'L',
11590=>'L',
11591=>'L',
11592=>'L',
11593=>'L',
11594=>'L',
11595=>'L',
11596=>'L',
11597=>'L',
11598=>'L',
11599=>'L',
11600=>'L',
11601=>'L',
11602=>'L',
11603=>'L',
11604=>'L',
11605=>'L',
11606=>'L',
11607=>'L',
11608=>'L',
11609=>'L',
11610=>'L',
11611=>'L',
11612=>'L',
11613=>'L',
11614=>'L',
11615=>'L',
11616=>'L',
11617=>'L',
11618=>'L',
11619=>'L',
11620=>'L',
11621=>'L',
11631=>'L',
11648=>'L',
11649=>'L',
11650=>'L',
11651=>'L',
11652=>'L',
11653=>'L',
11654=>'L',
11655=>'L',
11656=>'L',
11657=>'L',
11658=>'L',
11659=>'L',
11660=>'L',
11661=>'L',
11662=>'L',
11663=>'L',
11664=>'L',
11665=>'L',
11666=>'L',
11667=>'L',
11668=>'L',
11669=>'L',
11670=>'L',
11680=>'L',
11681=>'L',
11682=>'L',
11683=>'L',
11684=>'L',
11685=>'L',
11686=>'L',
11688=>'L',
11689=>'L',
11690=>'L',
11691=>'L',
11692=>'L',
11693=>'L',
11694=>'L',
11696=>'L',
11697=>'L',
11698=>'L',
11699=>'L',
11700=>'L',
11701=>'L',
11702=>'L',
11704=>'L',
11705=>'L',
11706=>'L',
11707=>'L',
11708=>'L',
11709=>'L',
11710=>'L',
11712=>'L',
11713=>'L',
11714=>'L',
11715=>'L',
11716=>'L',
11717=>'L',
11718=>'L',
11720=>'L',
11721=>'L',
11722=>'L',
11723=>'L',
11724=>'L',
11725=>'L',
11726=>'L',
11728=>'L',
11729=>'L',
11730=>'L',
11731=>'L',
11732=>'L',
11733=>'L',
11734=>'L',
11736=>'L',
11737=>'L',
11738=>'L',
11739=>'L',
11740=>'L',
11741=>'L',
11742=>'L',
11776=>'ON',
11777=>'ON',
11778=>'ON',
11779=>'ON',
11780=>'ON',
11781=>'ON',
11782=>'ON',
11783=>'ON',
11784=>'ON',
11785=>'ON',
11786=>'ON',
11787=>'ON',
11788=>'ON',
11789=>'ON',
11790=>'ON',
11791=>'ON',
11792=>'ON',
11793=>'ON',
11794=>'ON',
11795=>'ON',
11796=>'ON',
11797=>'ON',
11798=>'ON',
11799=>'ON',
11804=>'ON',
11805=>'ON',
11904=>'ON',
11905=>'ON',
11906=>'ON',
11907=>'ON',
11908=>'ON',
11909=>'ON',
11910=>'ON',
11911=>'ON',
11912=>'ON',
11913=>'ON',
11914=>'ON',
11915=>'ON',
11916=>'ON',
11917=>'ON',
11918=>'ON',
11919=>'ON',
11920=>'ON',
11921=>'ON',
11922=>'ON',
11923=>'ON',
11924=>'ON',
11925=>'ON',
11926=>'ON',
11927=>'ON',
11928=>'ON',
11929=>'ON',
11931=>'ON',
11932=>'ON',
11933=>'ON',
11934=>'ON',
11935=>'ON',
11936=>'ON',
11937=>'ON',
11938=>'ON',
11939=>'ON',
11940=>'ON',
11941=>'ON',
11942=>'ON',
11943=>'ON',
11944=>'ON',
11945=>'ON',
11946=>'ON',
11947=>'ON',
11948=>'ON',
11949=>'ON',
11950=>'ON',
11951=>'ON',
11952=>'ON',
11953=>'ON',
11954=>'ON',
11955=>'ON',
11956=>'ON',
11957=>'ON',
11958=>'ON',
11959=>'ON',
11960=>'ON',
11961=>'ON',
11962=>'ON',
11963=>'ON',
11964=>'ON',
11965=>'ON',
11966=>'ON',
11967=>'ON',
11968=>'ON',
11969=>'ON',
11970=>'ON',
11971=>'ON',
11972=>'ON',
11973=>'ON',
11974=>'ON',
11975=>'ON',
11976=>'ON',
11977=>'ON',
11978=>'ON',
11979=>'ON',
11980=>'ON',
11981=>'ON',
11982=>'ON',
11983=>'ON',
11984=>'ON',
11985=>'ON',
11986=>'ON',
11987=>'ON',
11988=>'ON',
11989=>'ON',
11990=>'ON',
11991=>'ON',
11992=>'ON',
11993=>'ON',
11994=>'ON',
11995=>'ON',
11996=>'ON',
11997=>'ON',
11998=>'ON',
11999=>'ON',
12000=>'ON',
12001=>'ON',
12002=>'ON',
12003=>'ON',
12004=>'ON',
12005=>'ON',
12006=>'ON',
12007=>'ON',
12008=>'ON',
12009=>'ON',
12010=>'ON',
12011=>'ON',
12012=>'ON',
12013=>'ON',
12014=>'ON',
12015=>'ON',
12016=>'ON',
12017=>'ON',
12018=>'ON',
12019=>'ON',
12032=>'ON',
12033=>'ON',
12034=>'ON',
12035=>'ON',
12036=>'ON',
12037=>'ON',
12038=>'ON',
12039=>'ON',
12040=>'ON',
12041=>'ON',
12042=>'ON',
12043=>'ON',
12044=>'ON',
12045=>'ON',
12046=>'ON',
12047=>'ON',
12048=>'ON',
12049=>'ON',
12050=>'ON',
12051=>'ON',
12052=>'ON',
12053=>'ON',
12054=>'ON',
12055=>'ON',
12056=>'ON',
12057=>'ON',
12058=>'ON',
12059=>'ON',
12060=>'ON',
12061=>'ON',
12062=>'ON',
12063=>'ON',
12064=>'ON',
12065=>'ON',
12066=>'ON',
12067=>'ON',
12068=>'ON',
12069=>'ON',
12070=>'ON',
12071=>'ON',
12072=>'ON',
12073=>'ON',
12074=>'ON',
12075=>'ON',
12076=>'ON',
12077=>'ON',
12078=>'ON',
12079=>'ON',
12080=>'ON',
12081=>'ON',
12082=>'ON',
12083=>'ON',
12084=>'ON',
12085=>'ON',
12086=>'ON',
12087=>'ON',
12088=>'ON',
12089=>'ON',
12090=>'ON',
12091=>'ON',
12092=>'ON',
12093=>'ON',
12094=>'ON',
12095=>'ON',
12096=>'ON',
12097=>'ON',
12098=>'ON',
12099=>'ON',
12100=>'ON',
12101=>'ON',
12102=>'ON',
12103=>'ON',
12104=>'ON',
12105=>'ON',
12106=>'ON',
12107=>'ON',
12108=>'ON',
12109=>'ON',
12110=>'ON',
12111=>'ON',
12112=>'ON',
12113=>'ON',
12114=>'ON',
12115=>'ON',
12116=>'ON',
12117=>'ON',
12118=>'ON',
12119=>'ON',
12120=>'ON',
12121=>'ON',
12122=>'ON',
12123=>'ON',
12124=>'ON',
12125=>'ON',
12126=>'ON',
12127=>'ON',
12128=>'ON',
12129=>'ON',
12130=>'ON',
12131=>'ON',
12132=>'ON',
12133=>'ON',
12134=>'ON',
12135=>'ON',
12136=>'ON',
12137=>'ON',
12138=>'ON',
12139=>'ON',
12140=>'ON',
12141=>'ON',
12142=>'ON',
12143=>'ON',
12144=>'ON',
12145=>'ON',
12146=>'ON',
12147=>'ON',
12148=>'ON',
12149=>'ON',
12150=>'ON',
12151=>'ON',
12152=>'ON',
12153=>'ON',
12154=>'ON',
12155=>'ON',
12156=>'ON',
12157=>'ON',
12158=>'ON',
12159=>'ON',
12160=>'ON',
12161=>'ON',
12162=>'ON',
12163=>'ON',
12164=>'ON',
12165=>'ON',
12166=>'ON',
12167=>'ON',
12168=>'ON',
12169=>'ON',
12170=>'ON',
12171=>'ON',
12172=>'ON',
12173=>'ON',
12174=>'ON',
12175=>'ON',
12176=>'ON',
12177=>'ON',
12178=>'ON',
12179=>'ON',
12180=>'ON',
12181=>'ON',
12182=>'ON',
12183=>'ON',
12184=>'ON',
12185=>'ON',
12186=>'ON',
12187=>'ON',
12188=>'ON',
12189=>'ON',
12190=>'ON',
12191=>'ON',
12192=>'ON',
12193=>'ON',
12194=>'ON',
12195=>'ON',
12196=>'ON',
12197=>'ON',
12198=>'ON',
12199=>'ON',
12200=>'ON',
12201=>'ON',
12202=>'ON',
12203=>'ON',
12204=>'ON',
12205=>'ON',
12206=>'ON',
12207=>'ON',
12208=>'ON',
12209=>'ON',
12210=>'ON',
12211=>'ON',
12212=>'ON',
12213=>'ON',
12214=>'ON',
12215=>'ON',
12216=>'ON',
12217=>'ON',
12218=>'ON',
12219=>'ON',
12220=>'ON',
12221=>'ON',
12222=>'ON',
12223=>'ON',
12224=>'ON',
12225=>'ON',
12226=>'ON',
12227=>'ON',
12228=>'ON',
12229=>'ON',
12230=>'ON',
12231=>'ON',
12232=>'ON',
12233=>'ON',
12234=>'ON',
12235=>'ON',
12236=>'ON',
12237=>'ON',
12238=>'ON',
12239=>'ON',
12240=>'ON',
12241=>'ON',
12242=>'ON',
12243=>'ON',
12244=>'ON',
12245=>'ON',
12272=>'ON',
12273=>'ON',
12274=>'ON',
12275=>'ON',
12276=>'ON',
12277=>'ON',
12278=>'ON',
12279=>'ON',
12280=>'ON',
12281=>'ON',
12282=>'ON',
12283=>'ON',
12288=>'WS',
12289=>'ON',
12290=>'ON',
12291=>'ON',
12292=>'ON',
12293=>'L',
12294=>'L',
12295=>'L',
12296=>'ON',
12297=>'ON',
12298=>'ON',
12299=>'ON',
12300=>'ON',
12301=>'ON',
12302=>'ON',
12303=>'ON',
12304=>'ON',
12305=>'ON',
12306=>'ON',
12307=>'ON',
12308=>'ON',
12309=>'ON',
12310=>'ON',
12311=>'ON',
12312=>'ON',
12313=>'ON',
12314=>'ON',
12315=>'ON',
12316=>'ON',
12317=>'ON',
12318=>'ON',
12319=>'ON',
12320=>'ON',
12321=>'L',
12322=>'L',
12323=>'L',
12324=>'L',
12325=>'L',
12326=>'L',
12327=>'L',
12328=>'L',
12329=>'L',
12330=>'NSM',
12331=>'NSM',
12332=>'NSM',
12333=>'NSM',
12334=>'NSM',
12335=>'NSM',
12336=>'ON',
12337=>'L',
12338=>'L',
12339=>'L',
12340=>'L',
12341=>'L',
12342=>'ON',
12343=>'ON',
12344=>'L',
12345=>'L',
12346=>'L',
12347=>'L',
12348=>'L',
12349=>'ON',
12350=>'ON',
12351=>'ON',
12353=>'L',
12354=>'L',
12355=>'L',
12356=>'L',
12357=>'L',
12358=>'L',
12359=>'L',
12360=>'L',
12361=>'L',
12362=>'L',
12363=>'L',
12364=>'L',
12365=>'L',
12366=>'L',
12367=>'L',
12368=>'L',
12369=>'L',
12370=>'L',
12371=>'L',
12372=>'L',
12373=>'L',
12374=>'L',
12375=>'L',
12376=>'L',
12377=>'L',
12378=>'L',
12379=>'L',
12380=>'L',
12381=>'L',
12382=>'L',
12383=>'L',
12384=>'L',
12385=>'L',
12386=>'L',
12387=>'L',
12388=>'L',
12389=>'L',
12390=>'L',
12391=>'L',
12392=>'L',
12393=>'L',
12394=>'L',
12395=>'L',
12396=>'L',
12397=>'L',
12398=>'L',
12399=>'L',
12400=>'L',
12401=>'L',
12402=>'L',
12403=>'L',
12404=>'L',
12405=>'L',
12406=>'L',
12407=>'L',
12408=>'L',
12409=>'L',
12410=>'L',
12411=>'L',
12412=>'L',
12413=>'L',
12414=>'L',
12415=>'L',
12416=>'L',
12417=>'L',
12418=>'L',
12419=>'L',
12420=>'L',
12421=>'L',
12422=>'L',
12423=>'L',
12424=>'L',
12425=>'L',
12426=>'L',
12427=>'L',
12428=>'L',
12429=>'L',
12430=>'L',
12431=>'L',
12432=>'L',
12433=>'L',
12434=>'L',
12435=>'L',
12436=>'L',
12437=>'L',
12438=>'L',
12441=>'NSM',
12442=>'NSM',
12443=>'ON',
12444=>'ON',
12445=>'L',
12446=>'L',
12447=>'L',
12448=>'ON',
12449=>'L',
12450=>'L',
12451=>'L',
12452=>'L',
12453=>'L',
12454=>'L',
12455=>'L',
12456=>'L',
12457=>'L',
12458=>'L',
12459=>'L',
12460=>'L',
12461=>'L',
12462=>'L',
12463=>'L',
12464=>'L',
12465=>'L',
12466=>'L',
12467=>'L',
12468=>'L',
12469=>'L',
12470=>'L',
12471=>'L',
12472=>'L',
12473=>'L',
12474=>'L',
12475=>'L',
12476=>'L',
12477=>'L',
12478=>'L',
12479=>'L',
12480=>'L',
12481=>'L',
12482=>'L',
12483=>'L',
12484=>'L',
12485=>'L',
12486=>'L',
12487=>'L',
12488=>'L',
12489=>'L',
12490=>'L',
12491=>'L',
12492=>'L',
12493=>'L',
12494=>'L',
12495=>'L',
12496=>'L',
12497=>'L',
12498=>'L',
12499=>'L',
12500=>'L',
12501=>'L',
12502=>'L',
12503=>'L',
12504=>'L',
12505=>'L',
12506=>'L',
12507=>'L',
12508=>'L',
12509=>'L',
12510=>'L',
12511=>'L',
12512=>'L',
12513=>'L',
12514=>'L',
12515=>'L',
12516=>'L',
12517=>'L',
12518=>'L',
12519=>'L',
12520=>'L',
12521=>'L',
12522=>'L',
12523=>'L',
12524=>'L',
12525=>'L',
12526=>'L',
12527=>'L',
12528=>'L',
12529=>'L',
12530=>'L',
12531=>'L',
12532=>'L',
12533=>'L',
12534=>'L',
12535=>'L',
12536=>'L',
12537=>'L',
12538=>'L',
12539=>'ON',
12540=>'L',
12541=>'L',
12542=>'L',
12543=>'L',
12549=>'L',
12550=>'L',
12551=>'L',
12552=>'L',
12553=>'L',
12554=>'L',
12555=>'L',
12556=>'L',
12557=>'L',
12558=>'L',
12559=>'L',
12560=>'L',
12561=>'L',
12562=>'L',
12563=>'L',
12564=>'L',
12565=>'L',
12566=>'L',
12567=>'L',
12568=>'L',
12569=>'L',
12570=>'L',
12571=>'L',
12572=>'L',
12573=>'L',
12574=>'L',
12575=>'L',
12576=>'L',
12577=>'L',
12578=>'L',
12579=>'L',
12580=>'L',
12581=>'L',
12582=>'L',
12583=>'L',
12584=>'L',
12585=>'L',
12586=>'L',
12587=>'L',
12588=>'L',
12593=>'L',
12594=>'L',
12595=>'L',
12596=>'L',
12597=>'L',
12598=>'L',
12599=>'L',
12600=>'L',
12601=>'L',
12602=>'L',
12603=>'L',
12604=>'L',
12605=>'L',
12606=>'L',
12607=>'L',
12608=>'L',
12609=>'L',
12610=>'L',
12611=>'L',
12612=>'L',
12613=>'L',
12614=>'L',
12615=>'L',
12616=>'L',
12617=>'L',
12618=>'L',
12619=>'L',
12620=>'L',
12621=>'L',
12622=>'L',
12623=>'L',
12624=>'L',
12625=>'L',
12626=>'L',
12627=>'L',
12628=>'L',
12629=>'L',
12630=>'L',
12631=>'L',
12632=>'L',
12633=>'L',
12634=>'L',
12635=>'L',
12636=>'L',
12637=>'L',
12638=>'L',
12639=>'L',
12640=>'L',
12641=>'L',
12642=>'L',
12643=>'L',
12644=>'L',
12645=>'L',
12646=>'L',
12647=>'L',
12648=>'L',
12649=>'L',
12650=>'L',
12651=>'L',
12652=>'L',
12653=>'L',
12654=>'L',
12655=>'L',
12656=>'L',
12657=>'L',
12658=>'L',
12659=>'L',
12660=>'L',
12661=>'L',
12662=>'L',
12663=>'L',
12664=>'L',
12665=>'L',
12666=>'L',
12667=>'L',
12668=>'L',
12669=>'L',
12670=>'L',
12671=>'L',
12672=>'L',
12673=>'L',
12674=>'L',
12675=>'L',
12676=>'L',
12677=>'L',
12678=>'L',
12679=>'L',
12680=>'L',
12681=>'L',
12682=>'L',
12683=>'L',
12684=>'L',
12685=>'L',
12686=>'L',
12688=>'L',
12689=>'L',
12690=>'L',
12691=>'L',
12692=>'L',
12693=>'L',
12694=>'L',
12695=>'L',
12696=>'L',
12697=>'L',
12698=>'L',
12699=>'L',
12700=>'L',
12701=>'L',
12702=>'L',
12703=>'L',
12704=>'L',
12705=>'L',
12706=>'L',
12707=>'L',
12708=>'L',
12709=>'L',
12710=>'L',
12711=>'L',
12712=>'L',
12713=>'L',
12714=>'L',
12715=>'L',
12716=>'L',
12717=>'L',
12718=>'L',
12719=>'L',
12720=>'L',
12721=>'L',
12722=>'L',
12723=>'L',
12724=>'L',
12725=>'L',
12726=>'L',
12727=>'L',
12736=>'ON',
12737=>'ON',
12738=>'ON',
12739=>'ON',
12740=>'ON',
12741=>'ON',
12742=>'ON',
12743=>'ON',
12744=>'ON',
12745=>'ON',
12746=>'ON',
12747=>'ON',
12748=>'ON',
12749=>'ON',
12750=>'ON',
12751=>'ON',
12784=>'L',
12785=>'L',
12786=>'L',
12787=>'L',
12788=>'L',
12789=>'L',
12790=>'L',
12791=>'L',
12792=>'L',
12793=>'L',
12794=>'L',
12795=>'L',
12796=>'L',
12797=>'L',
12798=>'L',
12799=>'L',
12800=>'L',
12801=>'L',
12802=>'L',
12803=>'L',
12804=>'L',
12805=>'L',
12806=>'L',
12807=>'L',
12808=>'L',
12809=>'L',
12810=>'L',
12811=>'L',
12812=>'L',
12813=>'L',
12814=>'L',
12815=>'L',
12816=>'L',
12817=>'L',
12818=>'L',
12819=>'L',
12820=>'L',
12821=>'L',
12822=>'L',
12823=>'L',
12824=>'L',
12825=>'L',
12826=>'L',
12827=>'L',
12828=>'L',
12829=>'ON',
12830=>'ON',
12832=>'L',
12833=>'L',
12834=>'L',
12835=>'L',
12836=>'L',
12837=>'L',
12838=>'L',
12839=>'L',
12840=>'L',
12841=>'L',
12842=>'L',
12843=>'L',
12844=>'L',
12845=>'L',
12846=>'L',
12847=>'L',
12848=>'L',
12849=>'L',
12850=>'L',
12851=>'L',
12852=>'L',
12853=>'L',
12854=>'L',
12855=>'L',
12856=>'L',
12857=>'L',
12858=>'L',
12859=>'L',
12860=>'L',
12861=>'L',
12862=>'L',
12863=>'L',
12864=>'L',
12865=>'L',
12866=>'L',
12867=>'L',
12880=>'ON',
12881=>'ON',
12882=>'ON',
12883=>'ON',
12884=>'ON',
12885=>'ON',
12886=>'ON',
12887=>'ON',
12888=>'ON',
12889=>'ON',
12890=>'ON',
12891=>'ON',
12892=>'ON',
12893=>'ON',
12894=>'ON',
12895=>'ON',
12896=>'L',
12897=>'L',
12898=>'L',
12899=>'L',
12900=>'L',
12901=>'L',
12902=>'L',
12903=>'L',
12904=>'L',
12905=>'L',
12906=>'L',
12907=>'L',
12908=>'L',
12909=>'L',
12910=>'L',
12911=>'L',
12912=>'L',
12913=>'L',
12914=>'L',
12915=>'L',
12916=>'L',
12917=>'L',
12918=>'L',
12919=>'L',
12920=>'L',
12921=>'L',
12922=>'L',
12923=>'L',
12924=>'ON',
12925=>'ON',
12926=>'ON',
12927=>'L',
12928=>'L',
12929=>'L',
12930=>'L',
12931=>'L',
12932=>'L',
12933=>'L',
12934=>'L',
12935=>'L',
12936=>'L',
12937=>'L',
12938=>'L',
12939=>'L',
12940=>'L',
12941=>'L',
12942=>'L',
12943=>'L',
12944=>'L',
12945=>'L',
12946=>'L',
12947=>'L',
12948=>'L',
12949=>'L',
12950=>'L',
12951=>'L',
12952=>'L',
12953=>'L',
12954=>'L',
12955=>'L',
12956=>'L',
12957=>'L',
12958=>'L',
12959=>'L',
12960=>'L',
12961=>'L',
12962=>'L',
12963=>'L',
12964=>'L',
12965=>'L',
12966=>'L',
12967=>'L',
12968=>'L',
12969=>'L',
12970=>'L',
12971=>'L',
12972=>'L',
12973=>'L',
12974=>'L',
12975=>'L',
12976=>'L',
12977=>'ON',
12978=>'ON',
12979=>'ON',
12980=>'ON',
12981=>'ON',
12982=>'ON',
12983=>'ON',
12984=>'ON',
12985=>'ON',
12986=>'ON',
12987=>'ON',
12988=>'ON',
12989=>'ON',
12990=>'ON',
12991=>'ON',
12992=>'L',
12993=>'L',
12994=>'L',
12995=>'L',
12996=>'L',
12997=>'L',
12998=>'L',
12999=>'L',
13000=>'L',
13001=>'L',
13002=>'L',
13003=>'L',
13004=>'ON',
13005=>'ON',
13006=>'ON',
13007=>'ON',
13008=>'L',
13009=>'L',
13010=>'L',
13011=>'L',
13012=>'L',
13013=>'L',
13014=>'L',
13015=>'L',
13016=>'L',
13017=>'L',
13018=>'L',
13019=>'L',
13020=>'L',
13021=>'L',
13022=>'L',
13023=>'L',
13024=>'L',
13025=>'L',
13026=>'L',
13027=>'L',
13028=>'L',
13029=>'L',
13030=>'L',
13031=>'L',
13032=>'L',
13033=>'L',
13034=>'L',
13035=>'L',
13036=>'L',
13037=>'L',
13038=>'L',
13039=>'L',
13040=>'L',
13041=>'L',
13042=>'L',
13043=>'L',
13044=>'L',
13045=>'L',
13046=>'L',
13047=>'L',
13048=>'L',
13049=>'L',
13050=>'L',
13051=>'L',
13052=>'L',
13053=>'L',
13054=>'L',
13056=>'L',
13057=>'L',
13058=>'L',
13059=>'L',
13060=>'L',
13061=>'L',
13062=>'L',
13063=>'L',
13064=>'L',
13065=>'L',
13066=>'L',
13067=>'L',
13068=>'L',
13069=>'L',
13070=>'L',
13071=>'L',
13072=>'L',
13073=>'L',
13074=>'L',
13075=>'L',
13076=>'L',
13077=>'L',
13078=>'L',
13079=>'L',
13080=>'L',
13081=>'L',
13082=>'L',
13083=>'L',
13084=>'L',
13085=>'L',
13086=>'L',
13087=>'L',
13088=>'L',
13089=>'L',
13090=>'L',
13091=>'L',
13092=>'L',
13093=>'L',
13094=>'L',
13095=>'L',
13096=>'L',
13097=>'L',
13098=>'L',
13099=>'L',
13100=>'L',
13101=>'L',
13102=>'L',
13103=>'L',
13104=>'L',
13105=>'L',
13106=>'L',
13107=>'L',
13108=>'L',
13109=>'L',
13110=>'L',
13111=>'L',
13112=>'L',
13113=>'L',
13114=>'L',
13115=>'L',
13116=>'L',
13117=>'L',
13118=>'L',
13119=>'L',
13120=>'L',
13121=>'L',
13122=>'L',
13123=>'L',
13124=>'L',
13125=>'L',
13126=>'L',
13127=>'L',
13128=>'L',
13129=>'L',
13130=>'L',
13131=>'L',
13132=>'L',
13133=>'L',
13134=>'L',
13135=>'L',
13136=>'L',
13137=>'L',
13138=>'L',
13139=>'L',
13140=>'L',
13141=>'L',
13142=>'L',
13143=>'L',
13144=>'L',
13145=>'L',
13146=>'L',
13147=>'L',
13148=>'L',
13149=>'L',
13150=>'L',
13151=>'L',
13152=>'L',
13153=>'L',
13154=>'L',
13155=>'L',
13156=>'L',
13157=>'L',
13158=>'L',
13159=>'L',
13160=>'L',
13161=>'L',
13162=>'L',
13163=>'L',
13164=>'L',
13165=>'L',
13166=>'L',
13167=>'L',
13168=>'L',
13169=>'L',
13170=>'L',
13171=>'L',
13172=>'L',
13173=>'L',
13174=>'L',
13175=>'ON',
13176=>'ON',
13177=>'ON',
13178=>'ON',
13179=>'L',
13180=>'L',
13181=>'L',
13182=>'L',
13183=>'L',
13184=>'L',
13185=>'L',
13186=>'L',
13187=>'L',
13188=>'L',
13189=>'L',
13190=>'L',
13191=>'L',
13192=>'L',
13193=>'L',
13194=>'L',
13195=>'L',
13196=>'L',
13197=>'L',
13198=>'L',
13199=>'L',
13200=>'L',
13201=>'L',
13202=>'L',
13203=>'L',
13204=>'L',
13205=>'L',
13206=>'L',
13207=>'L',
13208=>'L',
13209=>'L',
13210=>'L',
13211=>'L',
13212=>'L',
13213=>'L',
13214=>'L',
13215=>'L',
13216=>'L',
13217=>'L',
13218=>'L',
13219=>'L',
13220=>'L',
13221=>'L',
13222=>'L',
13223=>'L',
13224=>'L',
13225=>'L',
13226=>'L',
13227=>'L',
13228=>'L',
13229=>'L',
13230=>'L',
13231=>'L',
13232=>'L',
13233=>'L',
13234=>'L',
13235=>'L',
13236=>'L',
13237=>'L',
13238=>'L',
13239=>'L',
13240=>'L',
13241=>'L',
13242=>'L',
13243=>'L',
13244=>'L',
13245=>'L',
13246=>'L',
13247=>'L',
13248=>'L',
13249=>'L',
13250=>'L',
13251=>'L',
13252=>'L',
13253=>'L',
13254=>'L',
13255=>'L',
13256=>'L',
13257=>'L',
13258=>'L',
13259=>'L',
13260=>'L',
13261=>'L',
13262=>'L',
13263=>'L',
13264=>'L',
13265=>'L',
13266=>'L',
13267=>'L',
13268=>'L',
13269=>'L',
13270=>'L',
13271=>'L',
13272=>'L',
13273=>'L',
13274=>'L',
13275=>'L',
13276=>'L',
13277=>'L',
13278=>'ON',
13279=>'ON',
13280=>'L',
13281=>'L',
13282=>'L',
13283=>'L',
13284=>'L',
13285=>'L',
13286=>'L',
13287=>'L',
13288=>'L',
13289=>'L',
13290=>'L',
13291=>'L',
13292=>'L',
13293=>'L',
13294=>'L',
13295=>'L',
13296=>'L',
13297=>'L',
13298=>'L',
13299=>'L',
13300=>'L',
13301=>'L',
13302=>'L',
13303=>'L',
13304=>'L',
13305=>'L',
13306=>'L',
13307=>'L',
13308=>'L',
13309=>'L',
13310=>'L',
13311=>'ON',
13312=>'L',
19893=>'L',
19904=>'ON',
19905=>'ON',
19906=>'ON',
19907=>'ON',
19908=>'ON',
19909=>'ON',
19910=>'ON',
19911=>'ON',
19912=>'ON',
19913=>'ON',
19914=>'ON',
19915=>'ON',
19916=>'ON',
19917=>'ON',
19918=>'ON',
19919=>'ON',
19920=>'ON',
19921=>'ON',
19922=>'ON',
19923=>'ON',
19924=>'ON',
19925=>'ON',
19926=>'ON',
19927=>'ON',
19928=>'ON',
19929=>'ON',
19930=>'ON',
19931=>'ON',
19932=>'ON',
19933=>'ON',
19934=>'ON',
19935=>'ON',
19936=>'ON',
19937=>'ON',
19938=>'ON',
19939=>'ON',
19940=>'ON',
19941=>'ON',
19942=>'ON',
19943=>'ON',
19944=>'ON',
19945=>'ON',
19946=>'ON',
19947=>'ON',
19948=>'ON',
19949=>'ON',
19950=>'ON',
19951=>'ON',
19952=>'ON',
19953=>'ON',
19954=>'ON',
19955=>'ON',
19956=>'ON',
19957=>'ON',
19958=>'ON',
19959=>'ON',
19960=>'ON',
19961=>'ON',
19962=>'ON',
19963=>'ON',
19964=>'ON',
19965=>'ON',
19966=>'ON',
19967=>'ON',
19968=>'L',
40891=>'L',
40960=>'L',
40961=>'L',
40962=>'L',
40963=>'L',
40964=>'L',
40965=>'L',
40966=>'L',
40967=>'L',
40968=>'L',
40969=>'L',
40970=>'L',
40971=>'L',
40972=>'L',
40973=>'L',
40974=>'L',
40975=>'L',
40976=>'L',
40977=>'L',
40978=>'L',
40979=>'L',
40980=>'L',
40981=>'L',
40982=>'L',
40983=>'L',
40984=>'L',
40985=>'L',
40986=>'L',
40987=>'L',
40988=>'L',
40989=>'L',
40990=>'L',
40991=>'L',
40992=>'L',
40993=>'L',
40994=>'L',
40995=>'L',
40996=>'L',
40997=>'L',
40998=>'L',
40999=>'L',
41000=>'L',
41001=>'L',
41002=>'L',
41003=>'L',
41004=>'L',
41005=>'L',
41006=>'L',
41007=>'L',
41008=>'L',
41009=>'L',
41010=>'L',
41011=>'L',
41012=>'L',
41013=>'L',
41014=>'L',
41015=>'L',
41016=>'L',
41017=>'L',
41018=>'L',
41019=>'L',
41020=>'L',
41021=>'L',
41022=>'L',
41023=>'L',
41024=>'L',
41025=>'L',
41026=>'L',
41027=>'L',
41028=>'L',
41029=>'L',
41030=>'L',
41031=>'L',
41032=>'L',
41033=>'L',
41034=>'L',
41035=>'L',
41036=>'L',
41037=>'L',
41038=>'L',
41039=>'L',
41040=>'L',
41041=>'L',
41042=>'L',
41043=>'L',
41044=>'L',
41045=>'L',
41046=>'L',
41047=>'L',
41048=>'L',
41049=>'L',
41050=>'L',
41051=>'L',
41052=>'L',
41053=>'L',
41054=>'L',
41055=>'L',
41056=>'L',
41057=>'L',
41058=>'L',
41059=>'L',
41060=>'L',
41061=>'L',
41062=>'L',
41063=>'L',
41064=>'L',
41065=>'L',
41066=>'L',
41067=>'L',
41068=>'L',
41069=>'L',
41070=>'L',
41071=>'L',
41072=>'L',
41073=>'L',
41074=>'L',
41075=>'L',
41076=>'L',
41077=>'L',
41078=>'L',
41079=>'L',
41080=>'L',
41081=>'L',
41082=>'L',
41083=>'L',
41084=>'L',
41085=>'L',
41086=>'L',
41087=>'L',
41088=>'L',
41089=>'L',
41090=>'L',
41091=>'L',
41092=>'L',
41093=>'L',
41094=>'L',
41095=>'L',
41096=>'L',
41097=>'L',
41098=>'L',
41099=>'L',
41100=>'L',
41101=>'L',
41102=>'L',
41103=>'L',
41104=>'L',
41105=>'L',
41106=>'L',
41107=>'L',
41108=>'L',
41109=>'L',
41110=>'L',
41111=>'L',
41112=>'L',
41113=>'L',
41114=>'L',
41115=>'L',
41116=>'L',
41117=>'L',
41118=>'L',
41119=>'L',
41120=>'L',
41121=>'L',
41122=>'L',
41123=>'L',
41124=>'L',
41125=>'L',
41126=>'L',
41127=>'L',
41128=>'L',
41129=>'L',
41130=>'L',
41131=>'L',
41132=>'L',
41133=>'L',
41134=>'L',
41135=>'L',
41136=>'L',
41137=>'L',
41138=>'L',
41139=>'L',
41140=>'L',
41141=>'L',
41142=>'L',
41143=>'L',
41144=>'L',
41145=>'L',
41146=>'L',
41147=>'L',
41148=>'L',
41149=>'L',
41150=>'L',
41151=>'L',
41152=>'L',
41153=>'L',
41154=>'L',
41155=>'L',
41156=>'L',
41157=>'L',
41158=>'L',
41159=>'L',
41160=>'L',
41161=>'L',
41162=>'L',
41163=>'L',
41164=>'L',
41165=>'L',
41166=>'L',
41167=>'L',
41168=>'L',
41169=>'L',
41170=>'L',
41171=>'L',
41172=>'L',
41173=>'L',
41174=>'L',
41175=>'L',
41176=>'L',
41177=>'L',
41178=>'L',
41179=>'L',
41180=>'L',
41181=>'L',
41182=>'L',
41183=>'L',
41184=>'L',
41185=>'L',
41186=>'L',
41187=>'L',
41188=>'L',
41189=>'L',
41190=>'L',
41191=>'L',
41192=>'L',
41193=>'L',
41194=>'L',
41195=>'L',
41196=>'L',
41197=>'L',
41198=>'L',
41199=>'L',
41200=>'L',
41201=>'L',
41202=>'L',
41203=>'L',
41204=>'L',
41205=>'L',
41206=>'L',
41207=>'L',
41208=>'L',
41209=>'L',
41210=>'L',
41211=>'L',
41212=>'L',
41213=>'L',
41214=>'L',
41215=>'L',
41216=>'L',
41217=>'L',
41218=>'L',
41219=>'L',
41220=>'L',
41221=>'L',
41222=>'L',
41223=>'L',
41224=>'L',
41225=>'L',
41226=>'L',
41227=>'L',
41228=>'L',
41229=>'L',
41230=>'L',
41231=>'L',
41232=>'L',
41233=>'L',
41234=>'L',
41235=>'L',
41236=>'L',
41237=>'L',
41238=>'L',
41239=>'L',
41240=>'L',
41241=>'L',
41242=>'L',
41243=>'L',
41244=>'L',
41245=>'L',
41246=>'L',
41247=>'L',
41248=>'L',
41249=>'L',
41250=>'L',
41251=>'L',
41252=>'L',
41253=>'L',
41254=>'L',
41255=>'L',
41256=>'L',
41257=>'L',
41258=>'L',
41259=>'L',
41260=>'L',
41261=>'L',
41262=>'L',
41263=>'L',
41264=>'L',
41265=>'L',
41266=>'L',
41267=>'L',
41268=>'L',
41269=>'L',
41270=>'L',
41271=>'L',
41272=>'L',
41273=>'L',
41274=>'L',
41275=>'L',
41276=>'L',
41277=>'L',
41278=>'L',
41279=>'L',
41280=>'L',
41281=>'L',
41282=>'L',
41283=>'L',
41284=>'L',
41285=>'L',
41286=>'L',
41287=>'L',
41288=>'L',
41289=>'L',
41290=>'L',
41291=>'L',
41292=>'L',
41293=>'L',
41294=>'L',
41295=>'L',
41296=>'L',
41297=>'L',
41298=>'L',
41299=>'L',
41300=>'L',
41301=>'L',
41302=>'L',
41303=>'L',
41304=>'L',
41305=>'L',
41306=>'L',
41307=>'L',
41308=>'L',
41309=>'L',
41310=>'L',
41311=>'L',
41312=>'L',
41313=>'L',
41314=>'L',
41315=>'L',
41316=>'L',
41317=>'L',
41318=>'L',
41319=>'L',
41320=>'L',
41321=>'L',
41322=>'L',
41323=>'L',
41324=>'L',
41325=>'L',
41326=>'L',
41327=>'L',
41328=>'L',
41329=>'L',
41330=>'L',
41331=>'L',
41332=>'L',
41333=>'L',
41334=>'L',
41335=>'L',
41336=>'L',
41337=>'L',
41338=>'L',
41339=>'L',
41340=>'L',
41341=>'L',
41342=>'L',
41343=>'L',
41344=>'L',
41345=>'L',
41346=>'L',
41347=>'L',
41348=>'L',
41349=>'L',
41350=>'L',
41351=>'L',
41352=>'L',
41353=>'L',
41354=>'L',
41355=>'L',
41356=>'L',
41357=>'L',
41358=>'L',
41359=>'L',
41360=>'L',
41361=>'L',
41362=>'L',
41363=>'L',
41364=>'L',
41365=>'L',
41366=>'L',
41367=>'L',
41368=>'L',
41369=>'L',
41370=>'L',
41371=>'L',
41372=>'L',
41373=>'L',
41374=>'L',
41375=>'L',
41376=>'L',
41377=>'L',
41378=>'L',
41379=>'L',
41380=>'L',
41381=>'L',
41382=>'L',
41383=>'L',
41384=>'L',
41385=>'L',
41386=>'L',
41387=>'L',
41388=>'L',
41389=>'L',
41390=>'L',
41391=>'L',
41392=>'L',
41393=>'L',
41394=>'L',
41395=>'L',
41396=>'L',
41397=>'L',
41398=>'L',
41399=>'L',
41400=>'L',
41401=>'L',
41402=>'L',
41403=>'L',
41404=>'L',
41405=>'L',
41406=>'L',
41407=>'L',
41408=>'L',
41409=>'L',
41410=>'L',
41411=>'L',
41412=>'L',
41413=>'L',
41414=>'L',
41415=>'L',
41416=>'L',
41417=>'L',
41418=>'L',
41419=>'L',
41420=>'L',
41421=>'L',
41422=>'L',
41423=>'L',
41424=>'L',
41425=>'L',
41426=>'L',
41427=>'L',
41428=>'L',
41429=>'L',
41430=>'L',
41431=>'L',
41432=>'L',
41433=>'L',
41434=>'L',
41435=>'L',
41436=>'L',
41437=>'L',
41438=>'L',
41439=>'L',
41440=>'L',
41441=>'L',
41442=>'L',
41443=>'L',
41444=>'L',
41445=>'L',
41446=>'L',
41447=>'L',
41448=>'L',
41449=>'L',
41450=>'L',
41451=>'L',
41452=>'L',
41453=>'L',
41454=>'L',
41455=>'L',
41456=>'L',
41457=>'L',
41458=>'L',
41459=>'L',
41460=>'L',
41461=>'L',
41462=>'L',
41463=>'L',
41464=>'L',
41465=>'L',
41466=>'L',
41467=>'L',
41468=>'L',
41469=>'L',
41470=>'L',
41471=>'L',
41472=>'L',
41473=>'L',
41474=>'L',
41475=>'L',
41476=>'L',
41477=>'L',
41478=>'L',
41479=>'L',
41480=>'L',
41481=>'L',
41482=>'L',
41483=>'L',
41484=>'L',
41485=>'L',
41486=>'L',
41487=>'L',
41488=>'L',
41489=>'L',
41490=>'L',
41491=>'L',
41492=>'L',
41493=>'L',
41494=>'L',
41495=>'L',
41496=>'L',
41497=>'L',
41498=>'L',
41499=>'L',
41500=>'L',
41501=>'L',
41502=>'L',
41503=>'L',
41504=>'L',
41505=>'L',
41506=>'L',
41507=>'L',
41508=>'L',
41509=>'L',
41510=>'L',
41511=>'L',
41512=>'L',
41513=>'L',
41514=>'L',
41515=>'L',
41516=>'L',
41517=>'L',
41518=>'L',
41519=>'L',
41520=>'L',
41521=>'L',
41522=>'L',
41523=>'L',
41524=>'L',
41525=>'L',
41526=>'L',
41527=>'L',
41528=>'L',
41529=>'L',
41530=>'L',
41531=>'L',
41532=>'L',
41533=>'L',
41534=>'L',
41535=>'L',
41536=>'L',
41537=>'L',
41538=>'L',
41539=>'L',
41540=>'L',
41541=>'L',
41542=>'L',
41543=>'L',
41544=>'L',
41545=>'L',
41546=>'L',
41547=>'L',
41548=>'L',
41549=>'L',
41550=>'L',
41551=>'L',
41552=>'L',
41553=>'L',
41554=>'L',
41555=>'L',
41556=>'L',
41557=>'L',
41558=>'L',
41559=>'L',
41560=>'L',
41561=>'L',
41562=>'L',
41563=>'L',
41564=>'L',
41565=>'L',
41566=>'L',
41567=>'L',
41568=>'L',
41569=>'L',
41570=>'L',
41571=>'L',
41572=>'L',
41573=>'L',
41574=>'L',
41575=>'L',
41576=>'L',
41577=>'L',
41578=>'L',
41579=>'L',
41580=>'L',
41581=>'L',
41582=>'L',
41583=>'L',
41584=>'L',
41585=>'L',
41586=>'L',
41587=>'L',
41588=>'L',
41589=>'L',
41590=>'L',
41591=>'L',
41592=>'L',
41593=>'L',
41594=>'L',
41595=>'L',
41596=>'L',
41597=>'L',
41598=>'L',
41599=>'L',
41600=>'L',
41601=>'L',
41602=>'L',
41603=>'L',
41604=>'L',
41605=>'L',
41606=>'L',
41607=>'L',
41608=>'L',
41609=>'L',
41610=>'L',
41611=>'L',
41612=>'L',
41613=>'L',
41614=>'L',
41615=>'L',
41616=>'L',
41617=>'L',
41618=>'L',
41619=>'L',
41620=>'L',
41621=>'L',
41622=>'L',
41623=>'L',
41624=>'L',
41625=>'L',
41626=>'L',
41627=>'L',
41628=>'L',
41629=>'L',
41630=>'L',
41631=>'L',
41632=>'L',
41633=>'L',
41634=>'L',
41635=>'L',
41636=>'L',
41637=>'L',
41638=>'L',
41639=>'L',
41640=>'L',
41641=>'L',
41642=>'L',
41643=>'L',
41644=>'L',
41645=>'L',
41646=>'L',
41647=>'L',
41648=>'L',
41649=>'L',
41650=>'L',
41651=>'L',
41652=>'L',
41653=>'L',
41654=>'L',
41655=>'L',
41656=>'L',
41657=>'L',
41658=>'L',
41659=>'L',
41660=>'L',
41661=>'L',
41662=>'L',
41663=>'L',
41664=>'L',
41665=>'L',
41666=>'L',
41667=>'L',
41668=>'L',
41669=>'L',
41670=>'L',
41671=>'L',
41672=>'L',
41673=>'L',
41674=>'L',
41675=>'L',
41676=>'L',
41677=>'L',
41678=>'L',
41679=>'L',
41680=>'L',
41681=>'L',
41682=>'L',
41683=>'L',
41684=>'L',
41685=>'L',
41686=>'L',
41687=>'L',
41688=>'L',
41689=>'L',
41690=>'L',
41691=>'L',
41692=>'L',
41693=>'L',
41694=>'L',
41695=>'L',
41696=>'L',
41697=>'L',
41698=>'L',
41699=>'L',
41700=>'L',
41701=>'L',
41702=>'L',
41703=>'L',
41704=>'L',
41705=>'L',
41706=>'L',
41707=>'L',
41708=>'L',
41709=>'L',
41710=>'L',
41711=>'L',
41712=>'L',
41713=>'L',
41714=>'L',
41715=>'L',
41716=>'L',
41717=>'L',
41718=>'L',
41719=>'L',
41720=>'L',
41721=>'L',
41722=>'L',
41723=>'L',
41724=>'L',
41725=>'L',
41726=>'L',
41727=>'L',
41728=>'L',
41729=>'L',
41730=>'L',
41731=>'L',
41732=>'L',
41733=>'L',
41734=>'L',
41735=>'L',
41736=>'L',
41737=>'L',
41738=>'L',
41739=>'L',
41740=>'L',
41741=>'L',
41742=>'L',
41743=>'L',
41744=>'L',
41745=>'L',
41746=>'L',
41747=>'L',
41748=>'L',
41749=>'L',
41750=>'L',
41751=>'L',
41752=>'L',
41753=>'L',
41754=>'L',
41755=>'L',
41756=>'L',
41757=>'L',
41758=>'L',
41759=>'L',
41760=>'L',
41761=>'L',
41762=>'L',
41763=>'L',
41764=>'L',
41765=>'L',
41766=>'L',
41767=>'L',
41768=>'L',
41769=>'L',
41770=>'L',
41771=>'L',
41772=>'L',
41773=>'L',
41774=>'L',
41775=>'L',
41776=>'L',
41777=>'L',
41778=>'L',
41779=>'L',
41780=>'L',
41781=>'L',
41782=>'L',
41783=>'L',
41784=>'L',
41785=>'L',
41786=>'L',
41787=>'L',
41788=>'L',
41789=>'L',
41790=>'L',
41791=>'L',
41792=>'L',
41793=>'L',
41794=>'L',
41795=>'L',
41796=>'L',
41797=>'L',
41798=>'L',
41799=>'L',
41800=>'L',
41801=>'L',
41802=>'L',
41803=>'L',
41804=>'L',
41805=>'L',
41806=>'L',
41807=>'L',
41808=>'L',
41809=>'L',
41810=>'L',
41811=>'L',
41812=>'L',
41813=>'L',
41814=>'L',
41815=>'L',
41816=>'L',
41817=>'L',
41818=>'L',
41819=>'L',
41820=>'L',
41821=>'L',
41822=>'L',
41823=>'L',
41824=>'L',
41825=>'L',
41826=>'L',
41827=>'L',
41828=>'L',
41829=>'L',
41830=>'L',
41831=>'L',
41832=>'L',
41833=>'L',
41834=>'L',
41835=>'L',
41836=>'L',
41837=>'L',
41838=>'L',
41839=>'L',
41840=>'L',
41841=>'L',
41842=>'L',
41843=>'L',
41844=>'L',
41845=>'L',
41846=>'L',
41847=>'L',
41848=>'L',
41849=>'L',
41850=>'L',
41851=>'L',
41852=>'L',
41853=>'L',
41854=>'L',
41855=>'L',
41856=>'L',
41857=>'L',
41858=>'L',
41859=>'L',
41860=>'L',
41861=>'L',
41862=>'L',
41863=>'L',
41864=>'L',
41865=>'L',
41866=>'L',
41867=>'L',
41868=>'L',
41869=>'L',
41870=>'L',
41871=>'L',
41872=>'L',
41873=>'L',
41874=>'L',
41875=>'L',
41876=>'L',
41877=>'L',
41878=>'L',
41879=>'L',
41880=>'L',
41881=>'L',
41882=>'L',
41883=>'L',
41884=>'L',
41885=>'L',
41886=>'L',
41887=>'L',
41888=>'L',
41889=>'L',
41890=>'L',
41891=>'L',
41892=>'L',
41893=>'L',
41894=>'L',
41895=>'L',
41896=>'L',
41897=>'L',
41898=>'L',
41899=>'L',
41900=>'L',
41901=>'L',
41902=>'L',
41903=>'L',
41904=>'L',
41905=>'L',
41906=>'L',
41907=>'L',
41908=>'L',
41909=>'L',
41910=>'L',
41911=>'L',
41912=>'L',
41913=>'L',
41914=>'L',
41915=>'L',
41916=>'L',
41917=>'L',
41918=>'L',
41919=>'L',
41920=>'L',
41921=>'L',
41922=>'L',
41923=>'L',
41924=>'L',
41925=>'L',
41926=>'L',
41927=>'L',
41928=>'L',
41929=>'L',
41930=>'L',
41931=>'L',
41932=>'L',
41933=>'L',
41934=>'L',
41935=>'L',
41936=>'L',
41937=>'L',
41938=>'L',
41939=>'L',
41940=>'L',
41941=>'L',
41942=>'L',
41943=>'L',
41944=>'L',
41945=>'L',
41946=>'L',
41947=>'L',
41948=>'L',
41949=>'L',
41950=>'L',
41951=>'L',
41952=>'L',
41953=>'L',
41954=>'L',
41955=>'L',
41956=>'L',
41957=>'L',
41958=>'L',
41959=>'L',
41960=>'L',
41961=>'L',
41962=>'L',
41963=>'L',
41964=>'L',
41965=>'L',
41966=>'L',
41967=>'L',
41968=>'L',
41969=>'L',
41970=>'L',
41971=>'L',
41972=>'L',
41973=>'L',
41974=>'L',
41975=>'L',
41976=>'L',
41977=>'L',
41978=>'L',
41979=>'L',
41980=>'L',
41981=>'L',
41982=>'L',
41983=>'L',
41984=>'L',
41985=>'L',
41986=>'L',
41987=>'L',
41988=>'L',
41989=>'L',
41990=>'L',
41991=>'L',
41992=>'L',
41993=>'L',
41994=>'L',
41995=>'L',
41996=>'L',
41997=>'L',
41998=>'L',
41999=>'L',
42000=>'L',
42001=>'L',
42002=>'L',
42003=>'L',
42004=>'L',
42005=>'L',
42006=>'L',
42007=>'L',
42008=>'L',
42009=>'L',
42010=>'L',
42011=>'L',
42012=>'L',
42013=>'L',
42014=>'L',
42015=>'L',
42016=>'L',
42017=>'L',
42018=>'L',
42019=>'L',
42020=>'L',
42021=>'L',
42022=>'L',
42023=>'L',
42024=>'L',
42025=>'L',
42026=>'L',
42027=>'L',
42028=>'L',
42029=>'L',
42030=>'L',
42031=>'L',
42032=>'L',
42033=>'L',
42034=>'L',
42035=>'L',
42036=>'L',
42037=>'L',
42038=>'L',
42039=>'L',
42040=>'L',
42041=>'L',
42042=>'L',
42043=>'L',
42044=>'L',
42045=>'L',
42046=>'L',
42047=>'L',
42048=>'L',
42049=>'L',
42050=>'L',
42051=>'L',
42052=>'L',
42053=>'L',
42054=>'L',
42055=>'L',
42056=>'L',
42057=>'L',
42058=>'L',
42059=>'L',
42060=>'L',
42061=>'L',
42062=>'L',
42063=>'L',
42064=>'L',
42065=>'L',
42066=>'L',
42067=>'L',
42068=>'L',
42069=>'L',
42070=>'L',
42071=>'L',
42072=>'L',
42073=>'L',
42074=>'L',
42075=>'L',
42076=>'L',
42077=>'L',
42078=>'L',
42079=>'L',
42080=>'L',
42081=>'L',
42082=>'L',
42083=>'L',
42084=>'L',
42085=>'L',
42086=>'L',
42087=>'L',
42088=>'L',
42089=>'L',
42090=>'L',
42091=>'L',
42092=>'L',
42093=>'L',
42094=>'L',
42095=>'L',
42096=>'L',
42097=>'L',
42098=>'L',
42099=>'L',
42100=>'L',
42101=>'L',
42102=>'L',
42103=>'L',
42104=>'L',
42105=>'L',
42106=>'L',
42107=>'L',
42108=>'L',
42109=>'L',
42110=>'L',
42111=>'L',
42112=>'L',
42113=>'L',
42114=>'L',
42115=>'L',
42116=>'L',
42117=>'L',
42118=>'L',
42119=>'L',
42120=>'L',
42121=>'L',
42122=>'L',
42123=>'L',
42124=>'L',
42128=>'ON',
42129=>'ON',
42130=>'ON',
42131=>'ON',
42132=>'ON',
42133=>'ON',
42134=>'ON',
42135=>'ON',
42136=>'ON',
42137=>'ON',
42138=>'ON',
42139=>'ON',
42140=>'ON',
42141=>'ON',
42142=>'ON',
42143=>'ON',
42144=>'ON',
42145=>'ON',
42146=>'ON',
42147=>'ON',
42148=>'ON',
42149=>'ON',
42150=>'ON',
42151=>'ON',
42152=>'ON',
42153=>'ON',
42154=>'ON',
42155=>'ON',
42156=>'ON',
42157=>'ON',
42158=>'ON',
42159=>'ON',
42160=>'ON',
42161=>'ON',
42162=>'ON',
42163=>'ON',
42164=>'ON',
42165=>'ON',
42166=>'ON',
42167=>'ON',
42168=>'ON',
42169=>'ON',
42170=>'ON',
42171=>'ON',
42172=>'ON',
42173=>'ON',
42174=>'ON',
42175=>'ON',
42176=>'ON',
42177=>'ON',
42178=>'ON',
42179=>'ON',
42180=>'ON',
42181=>'ON',
42182=>'ON',
42752=>'ON',
42753=>'ON',
42754=>'ON',
42755=>'ON',
42756=>'ON',
42757=>'ON',
42758=>'ON',
42759=>'ON',
42760=>'ON',
42761=>'ON',
42762=>'ON',
42763=>'ON',
42764=>'ON',
42765=>'ON',
42766=>'ON',
42767=>'ON',
42768=>'ON',
42769=>'ON',
42770=>'ON',
42771=>'ON',
42772=>'ON',
42773=>'ON',
42774=>'ON',
42775=>'ON',
42776=>'ON',
42777=>'ON',
42778=>'ON',
42784=>'ON',
42785=>'ON',
43008=>'L',
43009=>'L',
43010=>'NSM',
43011=>'L',
43012=>'L',
43013=>'L',
43014=>'NSM',
43015=>'L',
43016=>'L',
43017=>'L',
43018=>'L',
43019=>'NSM',
43020=>'L',
43021=>'L',
43022=>'L',
43023=>'L',
43024=>'L',
43025=>'L',
43026=>'L',
43027=>'L',
43028=>'L',
43029=>'L',
43030=>'L',
43031=>'L',
43032=>'L',
43033=>'L',
43034=>'L',
43035=>'L',
43036=>'L',
43037=>'L',
43038=>'L',
43039=>'L',
43040=>'L',
43041=>'L',
43042=>'L',
43043=>'L',
43044=>'L',
43045=>'NSM',
43046=>'NSM',
43047=>'L',
43048=>'ON',
43049=>'ON',
43050=>'ON',
43051=>'ON',
43072=>'L',
43073=>'L',
43074=>'L',
43075=>'L',
43076=>'L',
43077=>'L',
43078=>'L',
43079=>'L',
43080=>'L',
43081=>'L',
43082=>'L',
43083=>'L',
43084=>'L',
43085=>'L',
43086=>'L',
43087=>'L',
43088=>'L',
43089=>'L',
43090=>'L',
43091=>'L',
43092=>'L',
43093=>'L',
43094=>'L',
43095=>'L',
43096=>'L',
43097=>'L',
43098=>'L',
43099=>'L',
43100=>'L',
43101=>'L',
43102=>'L',
43103=>'L',
43104=>'L',
43105=>'L',
43106=>'L',
43107=>'L',
43108=>'L',
43109=>'L',
43110=>'L',
43111=>'L',
43112=>'L',
43113=>'L',
43114=>'L',
43115=>'L',
43116=>'L',
43117=>'L',
43118=>'L',
43119=>'L',
43120=>'L',
43121=>'L',
43122=>'L',
43123=>'L',
43124=>'ON',
43125=>'ON',
43126=>'ON',
43127=>'ON',
44032=>'L',
55203=>'L',
55296=>'L',
56191=>'L',
56192=>'L',
56319=>'L',
56320=>'L',
57343=>'L',
57344=>'L',
63743=>'L',
63744=>'L',
63745=>'L',
63746=>'L',
63747=>'L',
63748=>'L',
63749=>'L',
63750=>'L',
63751=>'L',
63752=>'L',
63753=>'L',
63754=>'L',
63755=>'L',
63756=>'L',
63757=>'L',
63758=>'L',
63759=>'L',
63760=>'L',
63761=>'L',
63762=>'L',
63763=>'L',
63764=>'L',
63765=>'L',
63766=>'L',
63767=>'L',
63768=>'L',
63769=>'L',
63770=>'L',
63771=>'L',
63772=>'L',
63773=>'L',
63774=>'L',
63775=>'L',
63776=>'L',
63777=>'L',
63778=>'L',
63779=>'L',
63780=>'L',
63781=>'L',
63782=>'L',
63783=>'L',
63784=>'L',
63785=>'L',
63786=>'L',
63787=>'L',
63788=>'L',
63789=>'L',
63790=>'L',
63791=>'L',
63792=>'L',
63793=>'L',
63794=>'L',
63795=>'L',
63796=>'L',
63797=>'L',
63798=>'L',
63799=>'L',
63800=>'L',
63801=>'L',
63802=>'L',
63803=>'L',
63804=>'L',
63805=>'L',
63806=>'L',
63807=>'L',
63808=>'L',
63809=>'L',
63810=>'L',
63811=>'L',
63812=>'L',
63813=>'L',
63814=>'L',
63815=>'L',
63816=>'L',
63817=>'L',
63818=>'L',
63819=>'L',
63820=>'L',
63821=>'L',
63822=>'L',
63823=>'L',
63824=>'L',
63825=>'L',
63826=>'L',
63827=>'L',
63828=>'L',
63829=>'L',
63830=>'L',
63831=>'L',
63832=>'L',
63833=>'L',
63834=>'L',
63835=>'L',
63836=>'L',
63837=>'L',
63838=>'L',
63839=>'L',
63840=>'L',
63841=>'L',
63842=>'L',
63843=>'L',
63844=>'L',
63845=>'L',
63846=>'L',
63847=>'L',
63848=>'L',
63849=>'L',
63850=>'L',
63851=>'L',
63852=>'L',
63853=>'L',
63854=>'L',
63855=>'L',
63856=>'L',
63857=>'L',
63858=>'L',
63859=>'L',
63860=>'L',
63861=>'L',
63862=>'L',
63863=>'L',
63864=>'L',
63865=>'L',
63866=>'L',
63867=>'L',
63868=>'L',
63869=>'L',
63870=>'L',
63871=>'L',
63872=>'L',
63873=>'L',
63874=>'L',
63875=>'L',
63876=>'L',
63877=>'L',
63878=>'L',
63879=>'L',
63880=>'L',
63881=>'L',
63882=>'L',
63883=>'L',
63884=>'L',
63885=>'L',
63886=>'L',
63887=>'L',
63888=>'L',
63889=>'L',
63890=>'L',
63891=>'L',
63892=>'L',
63893=>'L',
63894=>'L',
63895=>'L',
63896=>'L',
63897=>'L',
63898=>'L',
63899=>'L',
63900=>'L',
63901=>'L',
63902=>'L',
63903=>'L',
63904=>'L',
63905=>'L',
63906=>'L',
63907=>'L',
63908=>'L',
63909=>'L',
63910=>'L',
63911=>'L',
63912=>'L',
63913=>'L',
63914=>'L',
63915=>'L',
63916=>'L',
63917=>'L',
63918=>'L',
63919=>'L',
63920=>'L',
63921=>'L',
63922=>'L',
63923=>'L',
63924=>'L',
63925=>'L',
63926=>'L',
63927=>'L',
63928=>'L',
63929=>'L',
63930=>'L',
63931=>'L',
63932=>'L',
63933=>'L',
63934=>'L',
63935=>'L',
63936=>'L',
63937=>'L',
63938=>'L',
63939=>'L',
63940=>'L',
63941=>'L',
63942=>'L',
63943=>'L',
63944=>'L',
63945=>'L',
63946=>'L',
63947=>'L',
63948=>'L',
63949=>'L',
63950=>'L',
63951=>'L',
63952=>'L',
63953=>'L',
63954=>'L',
63955=>'L',
63956=>'L',
63957=>'L',
63958=>'L',
63959=>'L',
63960=>'L',
63961=>'L',
63962=>'L',
63963=>'L',
63964=>'L',
63965=>'L',
63966=>'L',
63967=>'L',
63968=>'L',
63969=>'L',
63970=>'L',
63971=>'L',
63972=>'L',
63973=>'L',
63974=>'L',
63975=>'L',
63976=>'L',
63977=>'L',
63978=>'L',
63979=>'L',
63980=>'L',
63981=>'L',
63982=>'L',
63983=>'L',
63984=>'L',
63985=>'L',
63986=>'L',
63987=>'L',
63988=>'L',
63989=>'L',
63990=>'L',
63991=>'L',
63992=>'L',
63993=>'L',
63994=>'L',
63995=>'L',
63996=>'L',
63997=>'L',
63998=>'L',
63999=>'L',
64000=>'L',
64001=>'L',
64002=>'L',
64003=>'L',
64004=>'L',
64005=>'L',
64006=>'L',
64007=>'L',
64008=>'L',
64009=>'L',
64010=>'L',
64011=>'L',
64012=>'L',
64013=>'L',
64014=>'L',
64015=>'L',
64016=>'L',
64017=>'L',
64018=>'L',
64019=>'L',
64020=>'L',
64021=>'L',
64022=>'L',
64023=>'L',
64024=>'L',
64025=>'L',
64026=>'L',
64027=>'L',
64028=>'L',
64029=>'L',
64030=>'L',
64031=>'L',
64032=>'L',
64033=>'L',
64034=>'L',
64035=>'L',
64036=>'L',
64037=>'L',
64038=>'L',
64039=>'L',
64040=>'L',
64041=>'L',
64042=>'L',
64043=>'L',
64044=>'L',
64045=>'L',
64048=>'L',
64049=>'L',
64050=>'L',
64051=>'L',
64052=>'L',
64053=>'L',
64054=>'L',
64055=>'L',
64056=>'L',
64057=>'L',
64058=>'L',
64059=>'L',
64060=>'L',
64061=>'L',
64062=>'L',
64063=>'L',
64064=>'L',
64065=>'L',
64066=>'L',
64067=>'L',
64068=>'L',
64069=>'L',
64070=>'L',
64071=>'L',
64072=>'L',
64073=>'L',
64074=>'L',
64075=>'L',
64076=>'L',
64077=>'L',
64078=>'L',
64079=>'L',
64080=>'L',
64081=>'L',
64082=>'L',
64083=>'L',
64084=>'L',
64085=>'L',
64086=>'L',
64087=>'L',
64088=>'L',
64089=>'L',
64090=>'L',
64091=>'L',
64092=>'L',
64093=>'L',
64094=>'L',
64095=>'L',
64096=>'L',
64097=>'L',
64098=>'L',
64099=>'L',
64100=>'L',
64101=>'L',
64102=>'L',
64103=>'L',
64104=>'L',
64105=>'L',
64106=>'L',
64112=>'L',
64113=>'L',
64114=>'L',
64115=>'L',
64116=>'L',
64117=>'L',
64118=>'L',
64119=>'L',
64120=>'L',
64121=>'L',
64122=>'L',
64123=>'L',
64124=>'L',
64125=>'L',
64126=>'L',
64127=>'L',
64128=>'L',
64129=>'L',
64130=>'L',
64131=>'L',
64132=>'L',
64133=>'L',
64134=>'L',
64135=>'L',
64136=>'L',
64137=>'L',
64138=>'L',
64139=>'L',
64140=>'L',
64141=>'L',
64142=>'L',
64143=>'L',
64144=>'L',
64145=>'L',
64146=>'L',
64147=>'L',
64148=>'L',
64149=>'L',
64150=>'L',
64151=>'L',
64152=>'L',
64153=>'L',
64154=>'L',
64155=>'L',
64156=>'L',
64157=>'L',
64158=>'L',
64159=>'L',
64160=>'L',
64161=>'L',
64162=>'L',
64163=>'L',
64164=>'L',
64165=>'L',
64166=>'L',
64167=>'L',
64168=>'L',
64169=>'L',
64170=>'L',
64171=>'L',
64172=>'L',
64173=>'L',
64174=>'L',
64175=>'L',
64176=>'L',
64177=>'L',
64178=>'L',
64179=>'L',
64180=>'L',
64181=>'L',
64182=>'L',
64183=>'L',
64184=>'L',
64185=>'L',
64186=>'L',
64187=>'L',
64188=>'L',
64189=>'L',
64190=>'L',
64191=>'L',
64192=>'L',
64193=>'L',
64194=>'L',
64195=>'L',
64196=>'L',
64197=>'L',
64198=>'L',
64199=>'L',
64200=>'L',
64201=>'L',
64202=>'L',
64203=>'L',
64204=>'L',
64205=>'L',
64206=>'L',
64207=>'L',
64208=>'L',
64209=>'L',
64210=>'L',
64211=>'L',
64212=>'L',
64213=>'L',
64214=>'L',
64215=>'L',
64216=>'L',
64217=>'L',
64256=>'L',
64257=>'L',
64258=>'L',
64259=>'L',
64260=>'L',
64261=>'L',
64262=>'L',
64275=>'L',
64276=>'L',
64277=>'L',
64278=>'L',
64279=>'L',
64285=>'R',
64286=>'NSM',
64287=>'R',
64288=>'R',
64289=>'R',
64290=>'R',
64291=>'R',
64292=>'R',
64293=>'R',
64294=>'R',
64295=>'R',
64296=>'R',
64297=>'ES',
64298=>'R',
64299=>'R',
64300=>'R',
64301=>'R',
64302=>'R',
64303=>'R',
64304=>'R',
64305=>'R',
64306=>'R',
64307=>'R',
64308=>'R',
64309=>'R',
64310=>'R',
64312=>'R',
64313=>'R',
64314=>'R',
64315=>'R',
64316=>'R',
64318=>'R',
64320=>'R',
64321=>'R',
64323=>'R',
64324=>'R',
64326=>'R',
64327=>'R',
64328=>'R',
64329=>'R',
64330=>'R',
64331=>'R',
64332=>'R',
64333=>'R',
64334=>'R',
64335=>'R',
64336=>'AL',
64337=>'AL',
64338=>'AL',
64339=>'AL',
64340=>'AL',
64341=>'AL',
64342=>'AL',
64343=>'AL',
64344=>'AL',
64345=>'AL',
64346=>'AL',
64347=>'AL',
64348=>'AL',
64349=>'AL',
64350=>'AL',
64351=>'AL',
64352=>'AL',
64353=>'AL',
64354=>'AL',
64355=>'AL',
64356=>'AL',
64357=>'AL',
64358=>'AL',
64359=>'AL',
64360=>'AL',
64361=>'AL',
64362=>'AL',
64363=>'AL',
64364=>'AL',
64365=>'AL',
64366=>'AL',
64367=>'AL',
64368=>'AL',
64369=>'AL',
64370=>'AL',
64371=>'AL',
64372=>'AL',
64373=>'AL',
64374=>'AL',
64375=>'AL',
64376=>'AL',
64377=>'AL',
64378=>'AL',
64379=>'AL',
64380=>'AL',
64381=>'AL',
64382=>'AL',
64383=>'AL',
64384=>'AL',
64385=>'AL',
64386=>'AL',
64387=>'AL',
64388=>'AL',
64389=>'AL',
64390=>'AL',
64391=>'AL',
64392=>'AL',
64393=>'AL',
64394=>'AL',
64395=>'AL',
64396=>'AL',
64397=>'AL',
64398=>'AL',
64399=>'AL',
64400=>'AL',
64401=>'AL',
64402=>'AL',
64403=>'AL',
64404=>'AL',
64405=>'AL',
64406=>'AL',
64407=>'AL',
64408=>'AL',
64409=>'AL',
64410=>'AL',
64411=>'AL',
64412=>'AL',
64413=>'AL',
64414=>'AL',
64415=>'AL',
64416=>'AL',
64417=>'AL',
64418=>'AL',
64419=>'AL',
64420=>'AL',
64421=>'AL',
64422=>'AL',
64423=>'AL',
64424=>'AL',
64425=>'AL',
64426=>'AL',
64427=>'AL',
64428=>'AL',
64429=>'AL',
64430=>'AL',
64431=>'AL',
64432=>'AL',
64433=>'AL',
64467=>'AL',
64468=>'AL',
64469=>'AL',
64470=>'AL',
64471=>'AL',
64472=>'AL',
64473=>'AL',
64474=>'AL',
64475=>'AL',
64476=>'AL',
64477=>'AL',
64478=>'AL',
64479=>'AL',
64480=>'AL',
64481=>'AL',
64482=>'AL',
64483=>'AL',
64484=>'AL',
64485=>'AL',
64486=>'AL',
64487=>'AL',
64488=>'AL',
64489=>'AL',
64490=>'AL',
64491=>'AL',
64492=>'AL',
64493=>'AL',
64494=>'AL',
64495=>'AL',
64496=>'AL',
64497=>'AL',
64498=>'AL',
64499=>'AL',
64500=>'AL',
64501=>'AL',
64502=>'AL',
64503=>'AL',
64504=>'AL',
64505=>'AL',
64506=>'AL',
64507=>'AL',
64508=>'AL',
64509=>'AL',
64510=>'AL',
64511=>'AL',
64512=>'AL',
64513=>'AL',
64514=>'AL',
64515=>'AL',
64516=>'AL',
64517=>'AL',
64518=>'AL',
64519=>'AL',
64520=>'AL',
64521=>'AL',
64522=>'AL',
64523=>'AL',
64524=>'AL',
64525=>'AL',
64526=>'AL',
64527=>'AL',
64528=>'AL',
64529=>'AL',
64530=>'AL',
64531=>'AL',
64532=>'AL',
64533=>'AL',
64534=>'AL',
64535=>'AL',
64536=>'AL',
64537=>'AL',
64538=>'AL',
64539=>'AL',
64540=>'AL',
64541=>'AL',
64542=>'AL',
64543=>'AL',
64544=>'AL',
64545=>'AL',
64546=>'AL',
64547=>'AL',
64548=>'AL',
64549=>'AL',
64550=>'AL',
64551=>'AL',
64552=>'AL',
64553=>'AL',
64554=>'AL',
64555=>'AL',
64556=>'AL',
64557=>'AL',
64558=>'AL',
64559=>'AL',
64560=>'AL',
64561=>'AL',
64562=>'AL',
64563=>'AL',
64564=>'AL',
64565=>'AL',
64566=>'AL',
64567=>'AL',
64568=>'AL',
64569=>'AL',
64570=>'AL',
64571=>'AL',
64572=>'AL',
64573=>'AL',
64574=>'AL',
64575=>'AL',
64576=>'AL',
64577=>'AL',
64578=>'AL',
64579=>'AL',
64580=>'AL',
64581=>'AL',
64582=>'AL',
64583=>'AL',
64584=>'AL',
64585=>'AL',
64586=>'AL',
64587=>'AL',
64588=>'AL',
64589=>'AL',
64590=>'AL',
64591=>'AL',
64592=>'AL',
64593=>'AL',
64594=>'AL',
64595=>'AL',
64596=>'AL',
64597=>'AL',
64598=>'AL',
64599=>'AL',
64600=>'AL',
64601=>'AL',
64602=>'AL',
64603=>'AL',
64604=>'AL',
64605=>'AL',
64606=>'AL',
64607=>'AL',
64608=>'AL',
64609=>'AL',
64610=>'AL',
64611=>'AL',
64612=>'AL',
64613=>'AL',
64614=>'AL',
64615=>'AL',
64616=>'AL',
64617=>'AL',
64618=>'AL',
64619=>'AL',
64620=>'AL',
64621=>'AL',
64622=>'AL',
64623=>'AL',
64624=>'AL',
64625=>'AL',
64626=>'AL',
64627=>'AL',
64628=>'AL',
64629=>'AL',
64630=>'AL',
64631=>'AL',
64632=>'AL',
64633=>'AL',
64634=>'AL',
64635=>'AL',
64636=>'AL',
64637=>'AL',
64638=>'AL',
64639=>'AL',
64640=>'AL',
64641=>'AL',
64642=>'AL',
64643=>'AL',
64644=>'AL',
64645=>'AL',
64646=>'AL',
64647=>'AL',
64648=>'AL',
64649=>'AL',
64650=>'AL',
64651=>'AL',
64652=>'AL',
64653=>'AL',
64654=>'AL',
64655=>'AL',
64656=>'AL',
64657=>'AL',
64658=>'AL',
64659=>'AL',
64660=>'AL',
64661=>'AL',
64662=>'AL',
64663=>'AL',
64664=>'AL',
64665=>'AL',
64666=>'AL',
64667=>'AL',
64668=>'AL',
64669=>'AL',
64670=>'AL',
64671=>'AL',
64672=>'AL',
64673=>'AL',
64674=>'AL',
64675=>'AL',
64676=>'AL',
64677=>'AL',
64678=>'AL',
64679=>'AL',
64680=>'AL',
64681=>'AL',
64682=>'AL',
64683=>'AL',
64684=>'AL',
64685=>'AL',
64686=>'AL',
64687=>'AL',
64688=>'AL',
64689=>'AL',
64690=>'AL',
64691=>'AL',
64692=>'AL',
64693=>'AL',
64694=>'AL',
64695=>'AL',
64696=>'AL',
64697=>'AL',
64698=>'AL',
64699=>'AL',
64700=>'AL',
64701=>'AL',
64702=>'AL',
64703=>'AL',
64704=>'AL',
64705=>'AL',
64706=>'AL',
64707=>'AL',
64708=>'AL',
64709=>'AL',
64710=>'AL',
64711=>'AL',
64712=>'AL',
64713=>'AL',
64714=>'AL',
64715=>'AL',
64716=>'AL',
64717=>'AL',
64718=>'AL',
64719=>'AL',
64720=>'AL',
64721=>'AL',
64722=>'AL',
64723=>'AL',
64724=>'AL',
64725=>'AL',
64726=>'AL',
64727=>'AL',
64728=>'AL',
64729=>'AL',
64730=>'AL',
64731=>'AL',
64732=>'AL',
64733=>'AL',
64734=>'AL',
64735=>'AL',
64736=>'AL',
64737=>'AL',
64738=>'AL',
64739=>'AL',
64740=>'AL',
64741=>'AL',
64742=>'AL',
64743=>'AL',
64744=>'AL',
64745=>'AL',
64746=>'AL',
64747=>'AL',
64748=>'AL',
64749=>'AL',
64750=>'AL',
64751=>'AL',
64752=>'AL',
64753=>'AL',
64754=>'AL',
64755=>'AL',
64756=>'AL',
64757=>'AL',
64758=>'AL',
64759=>'AL',
64760=>'AL',
64761=>'AL',
64762=>'AL',
64763=>'AL',
64764=>'AL',
64765=>'AL',
64766=>'AL',
64767=>'AL',
64768=>'AL',
64769=>'AL',
64770=>'AL',
64771=>'AL',
64772=>'AL',
64773=>'AL',
64774=>'AL',
64775=>'AL',
64776=>'AL',
64777=>'AL',
64778=>'AL',
64779=>'AL',
64780=>'AL',
64781=>'AL',
64782=>'AL',
64783=>'AL',
64784=>'AL',
64785=>'AL',
64786=>'AL',
64787=>'AL',
64788=>'AL',
64789=>'AL',
64790=>'AL',
64791=>'AL',
64792=>'AL',
64793=>'AL',
64794=>'AL',
64795=>'AL',
64796=>'AL',
64797=>'AL',
64798=>'AL',
64799=>'AL',
64800=>'AL',
64801=>'AL',
64802=>'AL',
64803=>'AL',
64804=>'AL',
64805=>'AL',
64806=>'AL',
64807=>'AL',
64808=>'AL',
64809=>'AL',
64810=>'AL',
64811=>'AL',
64812=>'AL',
64813=>'AL',
64814=>'AL',
64815=>'AL',
64816=>'AL',
64817=>'AL',
64818=>'AL',
64819=>'AL',
64820=>'AL',
64821=>'AL',
64822=>'AL',
64823=>'AL',
64824=>'AL',
64825=>'AL',
64826=>'AL',
64827=>'AL',
64828=>'AL',
64829=>'AL',
64830=>'ON',
64831=>'ON',
64848=>'AL',
64849=>'AL',
64850=>'AL',
64851=>'AL',
64852=>'AL',
64853=>'AL',
64854=>'AL',
64855=>'AL',
64856=>'AL',
64857=>'AL',
64858=>'AL',
64859=>'AL',
64860=>'AL',
64861=>'AL',
64862=>'AL',
64863=>'AL',
64864=>'AL',
64865=>'AL',
64866=>'AL',
64867=>'AL',
64868=>'AL',
64869=>'AL',
64870=>'AL',
64871=>'AL',
64872=>'AL',
64873=>'AL',
64874=>'AL',
64875=>'AL',
64876=>'AL',
64877=>'AL',
64878=>'AL',
64879=>'AL',
64880=>'AL',
64881=>'AL',
64882=>'AL',
64883=>'AL',
64884=>'AL',
64885=>'AL',
64886=>'AL',
64887=>'AL',
64888=>'AL',
64889=>'AL',
64890=>'AL',
64891=>'AL',
64892=>'AL',
64893=>'AL',
64894=>'AL',
64895=>'AL',
64896=>'AL',
64897=>'AL',
64898=>'AL',
64899=>'AL',
64900=>'AL',
64901=>'AL',
64902=>'AL',
64903=>'AL',
64904=>'AL',
64905=>'AL',
64906=>'AL',
64907=>'AL',
64908=>'AL',
64909=>'AL',
64910=>'AL',
64911=>'AL',
64914=>'AL',
64915=>'AL',
64916=>'AL',
64917=>'AL',
64918=>'AL',
64919=>'AL',
64920=>'AL',
64921=>'AL',
64922=>'AL',
64923=>'AL',
64924=>'AL',
64925=>'AL',
64926=>'AL',
64927=>'AL',
64928=>'AL',
64929=>'AL',
64930=>'AL',
64931=>'AL',
64932=>'AL',
64933=>'AL',
64934=>'AL',
64935=>'AL',
64936=>'AL',
64937=>'AL',
64938=>'AL',
64939=>'AL',
64940=>'AL',
64941=>'AL',
64942=>'AL',
64943=>'AL',
64944=>'AL',
64945=>'AL',
64946=>'AL',
64947=>'AL',
64948=>'AL',
64949=>'AL',
64950=>'AL',
64951=>'AL',
64952=>'AL',
64953=>'AL',
64954=>'AL',
64955=>'AL',
64956=>'AL',
64957=>'AL',
64958=>'AL',
64959=>'AL',
64960=>'AL',
64961=>'AL',
64962=>'AL',
64963=>'AL',
64964=>'AL',
64965=>'AL',
64966=>'AL',
64967=>'AL',
65008=>'AL',
65009=>'AL',
65010=>'AL',
65011=>'AL',
65012=>'AL',
65013=>'AL',
65014=>'AL',
65015=>'AL',
65016=>'AL',
65017=>'AL',
65018=>'AL',
65019=>'AL',
65020=>'AL',
65021=>'ON',
65024=>'NSM',
65025=>'NSM',
65026=>'NSM',
65027=>'NSM',
65028=>'NSM',
65029=>'NSM',
65030=>'NSM',
65031=>'NSM',
65032=>'NSM',
65033=>'NSM',
65034=>'NSM',
65035=>'NSM',
65036=>'NSM',
65037=>'NSM',
65038=>'NSM',
65039=>'NSM',
65040=>'ON',
65041=>'ON',
65042=>'ON',
65043=>'ON',
65044=>'ON',
65045=>'ON',
65046=>'ON',
65047=>'ON',
65048=>'ON',
65049=>'ON',
65056=>'NSM',
65057=>'NSM',
65058=>'NSM',
65059=>'NSM',
65072=>'ON',
65073=>'ON',
65074=>'ON',
65075=>'ON',
65076=>'ON',
65077=>'ON',
65078=>'ON',
65079=>'ON',
65080=>'ON',
65081=>'ON',
65082=>'ON',
65083=>'ON',
65084=>'ON',
65085=>'ON',
65086=>'ON',
65087=>'ON',
65088=>'ON',
65089=>'ON',
65090=>'ON',
65091=>'ON',
65092=>'ON',
65093=>'ON',
65094=>'ON',
65095=>'ON',
65096=>'ON',
65097=>'ON',
65098=>'ON',
65099=>'ON',
65100=>'ON',
65101=>'ON',
65102=>'ON',
65103=>'ON',
65104=>'CS',
65105=>'ON',
65106=>'CS',
65108=>'ON',
65109=>'CS',
65110=>'ON',
65111=>'ON',
65112=>'ON',
65113=>'ON',
65114=>'ON',
65115=>'ON',
65116=>'ON',
65117=>'ON',
65118=>'ON',
65119=>'ET',
65120=>'ON',
65121=>'ON',
65122=>'ES',
65123=>'ES',
65124=>'ON',
65125=>'ON',
65126=>'ON',
65128=>'ON',
65129=>'ET',
65130=>'ET',
65131=>'ON',
65136=>'AL',
65137=>'AL',
65138=>'AL',
65139=>'AL',
65140=>'AL',
65142=>'AL',
65143=>'AL',
65144=>'AL',
65145=>'AL',
65146=>'AL',
65147=>'AL',
65148=>'AL',
65149=>'AL',
65150=>'AL',
65151=>'AL',
65152=>'AL',
65153=>'AL',
65154=>'AL',
65155=>'AL',
65156=>'AL',
65157=>'AL',
65158=>'AL',
65159=>'AL',
65160=>'AL',
65161=>'AL',
65162=>'AL',
65163=>'AL',
65164=>'AL',
65165=>'AL',
65166=>'AL',
65167=>'AL',
65168=>'AL',
65169=>'AL',
65170=>'AL',
65171=>'AL',
65172=>'AL',
65173=>'AL',
65174=>'AL',
65175=>'AL',
65176=>'AL',
65177=>'AL',
65178=>'AL',
65179=>'AL',
65180=>'AL',
65181=>'AL',
65182=>'AL',
65183=>'AL',
65184=>'AL',
65185=>'AL',
65186=>'AL',
65187=>'AL',
65188=>'AL',
65189=>'AL',
65190=>'AL',
65191=>'AL',
65192=>'AL',
65193=>'AL',
65194=>'AL',
65195=>'AL',
65196=>'AL',
65197=>'AL',
65198=>'AL',
65199=>'AL',
65200=>'AL',
65201=>'AL',
65202=>'AL',
65203=>'AL',
65204=>'AL',
65205=>'AL',
65206=>'AL',
65207=>'AL',
65208=>'AL',
65209=>'AL',
65210=>'AL',
65211=>'AL',
65212=>'AL',
65213=>'AL',
65214=>'AL',
65215=>'AL',
65216=>'AL',
65217=>'AL',
65218=>'AL',
65219=>'AL',
65220=>'AL',
65221=>'AL',
65222=>'AL',
65223=>'AL',
65224=>'AL',
65225=>'AL',
65226=>'AL',
65227=>'AL',
65228=>'AL',
65229=>'AL',
65230=>'AL',
65231=>'AL',
65232=>'AL',
65233=>'AL',
65234=>'AL',
65235=>'AL',
65236=>'AL',
65237=>'AL',
65238=>'AL',
65239=>'AL',
65240=>'AL',
65241=>'AL',
65242=>'AL',
65243=>'AL',
65244=>'AL',
65245=>'AL',
65246=>'AL',
65247=>'AL',
65248=>'AL',
65249=>'AL',
65250=>'AL',
65251=>'AL',
65252=>'AL',
65253=>'AL',
65254=>'AL',
65255=>'AL',
65256=>'AL',
65257=>'AL',
65258=>'AL',
65259=>'AL',
65260=>'AL',
65261=>'AL',
65262=>'AL',
65263=>'AL',
65264=>'AL',
65265=>'AL',
65266=>'AL',
65267=>'AL',
65268=>'AL',
65269=>'AL',
65270=>'AL',
65271=>'AL',
65272=>'AL',
65273=>'AL',
65274=>'AL',
65275=>'AL',
65276=>'AL',
65279=>'BN',
65281=>'ON',
65282=>'ON',
65283=>'ET',
65284=>'ET',
65285=>'ET',
65286=>'ON',
65287=>'ON',
65288=>'ON',
65289=>'ON',
65290=>'ON',
65291=>'ES',
65292=>'CS',
65293=>'ES',
65294=>'CS',
65295=>'CS',
65296=>'EN',
65297=>'EN',
65298=>'EN',
65299=>'EN',
65300=>'EN',
65301=>'EN',
65302=>'EN',
65303=>'EN',
65304=>'EN',
65305=>'EN',
65306=>'CS',
65307=>'ON',
65308=>'ON',
65309=>'ON',
65310=>'ON',
65311=>'ON',
65312=>'ON',
65313=>'L',
65314=>'L',
65315=>'L',
65316=>'L',
65317=>'L',
65318=>'L',
65319=>'L',
65320=>'L',
65321=>'L',
65322=>'L',
65323=>'L',
65324=>'L',
65325=>'L',
65326=>'L',
65327=>'L',
65328=>'L',
65329=>'L',
65330=>'L',
65331=>'L',
65332=>'L',
65333=>'L',
65334=>'L',
65335=>'L',
65336=>'L',
65337=>'L',
65338=>'L',
65339=>'ON',
65340=>'ON',
65341=>'ON',
65342=>'ON',
65343=>'ON',
65344=>'ON',
65345=>'L',
65346=>'L',
65347=>'L',
65348=>'L',
65349=>'L',
65350=>'L',
65351=>'L',
65352=>'L',
65353=>'L',
65354=>'L',
65355=>'L',
65356=>'L',
65357=>'L',
65358=>'L',
65359=>'L',
65360=>'L',
65361=>'L',
65362=>'L',
65363=>'L',
65364=>'L',
65365=>'L',
65366=>'L',
65367=>'L',
65368=>'L',
65369=>'L',
65370=>'L',
65371=>'ON',
65372=>'ON',
65373=>'ON',
65374=>'ON',
65375=>'ON',
65376=>'ON',
65377=>'ON',
65378=>'ON',
65379=>'ON',
65380=>'ON',
65381=>'ON',
65382=>'L',
65383=>'L',
65384=>'L',
65385=>'L',
65386=>'L',
65387=>'L',
65388=>'L',
65389=>'L',
65390=>'L',
65391=>'L',
65392=>'L',
65393=>'L',
65394=>'L',
65395=>'L',
65396=>'L',
65397=>'L',
65398=>'L',
65399=>'L',
65400=>'L',
65401=>'L',
65402=>'L',
65403=>'L',
65404=>'L',
65405=>'L',
65406=>'L',
65407=>'L',
65408=>'L',
65409=>'L',
65410=>'L',
65411=>'L',
65412=>'L',
65413=>'L',
65414=>'L',
65415=>'L',
65416=>'L',
65417=>'L',
65418=>'L',
65419=>'L',
65420=>'L',
65421=>'L',
65422=>'L',
65423=>'L',
65424=>'L',
65425=>'L',
65426=>'L',
65427=>'L',
65428=>'L',
65429=>'L',
65430=>'L',
65431=>'L',
65432=>'L',
65433=>'L',
65434=>'L',
65435=>'L',
65436=>'L',
65437=>'L',
65438=>'L',
65439=>'L',
65440=>'L',
65441=>'L',
65442=>'L',
65443=>'L',
65444=>'L',
65445=>'L',
65446=>'L',
65447=>'L',
65448=>'L',
65449=>'L',
65450=>'L',
65451=>'L',
65452=>'L',
65453=>'L',
65454=>'L',
65455=>'L',
65456=>'L',
65457=>'L',
65458=>'L',
65459=>'L',
65460=>'L',
65461=>'L',
65462=>'L',
65463=>'L',
65464=>'L',
65465=>'L',
65466=>'L',
65467=>'L',
65468=>'L',
65469=>'L',
65470=>'L',
65474=>'L',
65475=>'L',
65476=>'L',
65477=>'L',
65478=>'L',
65479=>'L',
65482=>'L',
65483=>'L',
65484=>'L',
65485=>'L',
65486=>'L',
65487=>'L',
65490=>'L',
65491=>'L',
65492=>'L',
65493=>'L',
65494=>'L',
65495=>'L',
65498=>'L',
65499=>'L',
65500=>'L',
65504=>'ET',
65505=>'ET',
65506=>'ON',
65507=>'ON',
65508=>'ON',
65509=>'ET',
65510=>'ET',
65512=>'ON',
65513=>'ON',
65514=>'ON',
65515=>'ON',
65516=>'ON',
65517=>'ON',
65518=>'ON',
65529=>'ON',
65530=>'ON',
65531=>'ON',
65532=>'ON',
65533=>'ON',
65536=>'L',
65537=>'L',
65538=>'L',
65539=>'L',
65540=>'L',
65541=>'L',
65542=>'L',
65543=>'L',
65544=>'L',
65545=>'L',
65546=>'L',
65547=>'L',
65549=>'L',
65550=>'L',
65551=>'L',
65552=>'L',
65553=>'L',
65554=>'L',
65555=>'L',
65556=>'L',
65557=>'L',
65558=>'L',
65559=>'L',
65560=>'L',
65561=>'L',
65562=>'L',
65563=>'L',
65564=>'L',
65565=>'L',
65566=>'L',
65567=>'L',
65568=>'L',
65569=>'L',
65570=>'L',
65571=>'L',
65572=>'L',
65573=>'L',
65574=>'L',
65576=>'L',
65577=>'L',
65578=>'L',
65579=>'L',
65580=>'L',
65581=>'L',
65582=>'L',
65583=>'L',
65584=>'L',
65585=>'L',
65586=>'L',
65587=>'L',
65588=>'L',
65589=>'L',
65590=>'L',
65591=>'L',
65592=>'L',
65593=>'L',
65594=>'L',
65596=>'L',
65597=>'L',
65599=>'L',
65600=>'L',
65601=>'L',
65602=>'L',
65603=>'L',
65604=>'L',
65605=>'L',
65606=>'L',
65607=>'L',
65608=>'L',
65609=>'L',
65610=>'L',
65611=>'L',
65612=>'L',
65613=>'L',
65616=>'L',
65617=>'L',
65618=>'L',
65619=>'L',
65620=>'L',
65621=>'L',
65622=>'L',
65623=>'L',
65624=>'L',
65625=>'L',
65626=>'L',
65627=>'L',
65628=>'L',
65629=>'L',
65664=>'L',
65665=>'L',
65666=>'L',
65667=>'L',
65668=>'L',
65669=>'L',
65670=>'L',
65671=>'L',
65672=>'L',
65673=>'L',
65674=>'L',
65675=>'L',
65676=>'L',
65677=>'L',
65678=>'L',
65679=>'L',
65680=>'L',
65681=>'L',
65682=>'L',
65683=>'L',
65684=>'L',
65685=>'L',
65686=>'L',
65687=>'L',
65688=>'L',
65689=>'L',
65690=>'L',
65691=>'L',
65692=>'L',
65693=>'L',
65694=>'L',
65695=>'L',
65696=>'L',
65697=>'L',
65698=>'L',
65699=>'L',
65700=>'L',
65701=>'L',
65702=>'L',
65703=>'L',
65704=>'L',
65705=>'L',
65706=>'L',
65707=>'L',
65708=>'L',
65709=>'L',
65710=>'L',
65711=>'L',
65712=>'L',
65713=>'L',
65714=>'L',
65715=>'L',
65716=>'L',
65717=>'L',
65718=>'L',
65719=>'L',
65720=>'L',
65721=>'L',
65722=>'L',
65723=>'L',
65724=>'L',
65725=>'L',
65726=>'L',
65727=>'L',
65728=>'L',
65729=>'L',
65730=>'L',
65731=>'L',
65732=>'L',
65733=>'L',
65734=>'L',
65735=>'L',
65736=>'L',
65737=>'L',
65738=>'L',
65739=>'L',
65740=>'L',
65741=>'L',
65742=>'L',
65743=>'L',
65744=>'L',
65745=>'L',
65746=>'L',
65747=>'L',
65748=>'L',
65749=>'L',
65750=>'L',
65751=>'L',
65752=>'L',
65753=>'L',
65754=>'L',
65755=>'L',
65756=>'L',
65757=>'L',
65758=>'L',
65759=>'L',
65760=>'L',
65761=>'L',
65762=>'L',
65763=>'L',
65764=>'L',
65765=>'L',
65766=>'L',
65767=>'L',
65768=>'L',
65769=>'L',
65770=>'L',
65771=>'L',
65772=>'L',
65773=>'L',
65774=>'L',
65775=>'L',
65776=>'L',
65777=>'L',
65778=>'L',
65779=>'L',
65780=>'L',
65781=>'L',
65782=>'L',
65783=>'L',
65784=>'L',
65785=>'L',
65786=>'L',
65792=>'L',
65793=>'ON',
65794=>'L',
65799=>'L',
65800=>'L',
65801=>'L',
65802=>'L',
65803=>'L',
65804=>'L',
65805=>'L',
65806=>'L',
65807=>'L',
65808=>'L',
65809=>'L',
65810=>'L',
65811=>'L',
65812=>'L',
65813=>'L',
65814=>'L',
65815=>'L',
65816=>'L',
65817=>'L',
65818=>'L',
65819=>'L',
65820=>'L',
65821=>'L',
65822=>'L',
65823=>'L',
65824=>'L',
65825=>'L',
65826=>'L',
65827=>'L',
65828=>'L',
65829=>'L',
65830=>'L',
65831=>'L',
65832=>'L',
65833=>'L',
65834=>'L',
65835=>'L',
65836=>'L',
65837=>'L',
65838=>'L',
65839=>'L',
65840=>'L',
65841=>'L',
65842=>'L',
65843=>'L',
65847=>'L',
65848=>'L',
65849=>'L',
65850=>'L',
65851=>'L',
65852=>'L',
65853=>'L',
65854=>'L',
65855=>'L',
65856=>'ON',
65857=>'ON',
65858=>'ON',
65859=>'ON',
65860=>'ON',
65861=>'ON',
65862=>'ON',
65863=>'ON',
65864=>'ON',
65865=>'ON',
65866=>'ON',
65867=>'ON',
65868=>'ON',
65869=>'ON',
65870=>'ON',
65871=>'ON',
65872=>'ON',
65873=>'ON',
65874=>'ON',
65875=>'ON',
65876=>'ON',
65877=>'ON',
65878=>'ON',
65879=>'ON',
65880=>'ON',
65881=>'ON',
65882=>'ON',
65883=>'ON',
65884=>'ON',
65885=>'ON',
65886=>'ON',
65887=>'ON',
65888=>'ON',
65889=>'ON',
65890=>'ON',
65891=>'ON',
65892=>'ON',
65893=>'ON',
65894=>'ON',
65895=>'ON',
65896=>'ON',
65897=>'ON',
65898=>'ON',
65899=>'ON',
65900=>'ON',
65901=>'ON',
65902=>'ON',
65903=>'ON',
65904=>'ON',
65905=>'ON',
65906=>'ON',
65907=>'ON',
65908=>'ON',
65909=>'ON',
65910=>'ON',
65911=>'ON',
65912=>'ON',
65913=>'ON',
65914=>'ON',
65915=>'ON',
65916=>'ON',
65917=>'ON',
65918=>'ON',
65919=>'ON',
65920=>'ON',
65921=>'ON',
65922=>'ON',
65923=>'ON',
65924=>'ON',
65925=>'ON',
65926=>'ON',
65927=>'ON',
65928=>'ON',
65929=>'ON',
65930=>'ON',
66304=>'L',
66305=>'L',
66306=>'L',
66307=>'L',
66308=>'L',
66309=>'L',
66310=>'L',
66311=>'L',
66312=>'L',
66313=>'L',
66314=>'L',
66315=>'L',
66316=>'L',
66317=>'L',
66318=>'L',
66319=>'L',
66320=>'L',
66321=>'L',
66322=>'L',
66323=>'L',
66324=>'L',
66325=>'L',
66326=>'L',
66327=>'L',
66328=>'L',
66329=>'L',
66330=>'L',
66331=>'L',
66332=>'L',
66333=>'L',
66334=>'L',
66336=>'L',
66337=>'L',
66338=>'L',
66339=>'L',
66352=>'L',
66353=>'L',
66354=>'L',
66355=>'L',
66356=>'L',
66357=>'L',
66358=>'L',
66359=>'L',
66360=>'L',
66361=>'L',
66362=>'L',
66363=>'L',
66364=>'L',
66365=>'L',
66366=>'L',
66367=>'L',
66368=>'L',
66369=>'L',
66370=>'L',
66371=>'L',
66372=>'L',
66373=>'L',
66374=>'L',
66375=>'L',
66376=>'L',
66377=>'L',
66378=>'L',
66432=>'L',
66433=>'L',
66434=>'L',
66435=>'L',
66436=>'L',
66437=>'L',
66438=>'L',
66439=>'L',
66440=>'L',
66441=>'L',
66442=>'L',
66443=>'L',
66444=>'L',
66445=>'L',
66446=>'L',
66447=>'L',
66448=>'L',
66449=>'L',
66450=>'L',
66451=>'L',
66452=>'L',
66453=>'L',
66454=>'L',
66455=>'L',
66456=>'L',
66457=>'L',
66458=>'L',
66459=>'L',
66460=>'L',
66461=>'L',
66463=>'L',
66464=>'L',
66465=>'L',
66466=>'L',
66467=>'L',
66468=>'L',
66469=>'L',
66470=>'L',
66471=>'L',
66472=>'L',
66473=>'L',
66474=>'L',
66475=>'L',
66476=>'L',
66477=>'L',
66478=>'L',
66479=>'L',
66480=>'L',
66481=>'L',
66482=>'L',
66483=>'L',
66484=>'L',
66485=>'L',
66486=>'L',
66487=>'L',
66488=>'L',
66489=>'L',
66490=>'L',
66491=>'L',
66492=>'L',
66493=>'L',
66494=>'L',
66495=>'L',
66496=>'L',
66497=>'L',
66498=>'L',
66499=>'L',
66504=>'L',
66505=>'L',
66506=>'L',
66507=>'L',
66508=>'L',
66509=>'L',
66510=>'L',
66511=>'L',
66512=>'L',
66513=>'L',
66514=>'L',
66515=>'L',
66516=>'L',
66517=>'L',
66560=>'L',
66561=>'L',
66562=>'L',
66563=>'L',
66564=>'L',
66565=>'L',
66566=>'L',
66567=>'L',
66568=>'L',
66569=>'L',
66570=>'L',
66571=>'L',
66572=>'L',
66573=>'L',
66574=>'L',
66575=>'L',
66576=>'L',
66577=>'L',
66578=>'L',
66579=>'L',
66580=>'L',
66581=>'L',
66582=>'L',
66583=>'L',
66584=>'L',
66585=>'L',
66586=>'L',
66587=>'L',
66588=>'L',
66589=>'L',
66590=>'L',
66591=>'L',
66592=>'L',
66593=>'L',
66594=>'L',
66595=>'L',
66596=>'L',
66597=>'L',
66598=>'L',
66599=>'L',
66600=>'L',
66601=>'L',
66602=>'L',
66603=>'L',
66604=>'L',
66605=>'L',
66606=>'L',
66607=>'L',
66608=>'L',
66609=>'L',
66610=>'L',
66611=>'L',
66612=>'L',
66613=>'L',
66614=>'L',
66615=>'L',
66616=>'L',
66617=>'L',
66618=>'L',
66619=>'L',
66620=>'L',
66621=>'L',
66622=>'L',
66623=>'L',
66624=>'L',
66625=>'L',
66626=>'L',
66627=>'L',
66628=>'L',
66629=>'L',
66630=>'L',
66631=>'L',
66632=>'L',
66633=>'L',
66634=>'L',
66635=>'L',
66636=>'L',
66637=>'L',
66638=>'L',
66639=>'L',
66640=>'L',
66641=>'L',
66642=>'L',
66643=>'L',
66644=>'L',
66645=>'L',
66646=>'L',
66647=>'L',
66648=>'L',
66649=>'L',
66650=>'L',
66651=>'L',
66652=>'L',
66653=>'L',
66654=>'L',
66655=>'L',
66656=>'L',
66657=>'L',
66658=>'L',
66659=>'L',
66660=>'L',
66661=>'L',
66662=>'L',
66663=>'L',
66664=>'L',
66665=>'L',
66666=>'L',
66667=>'L',
66668=>'L',
66669=>'L',
66670=>'L',
66671=>'L',
66672=>'L',
66673=>'L',
66674=>'L',
66675=>'L',
66676=>'L',
66677=>'L',
66678=>'L',
66679=>'L',
66680=>'L',
66681=>'L',
66682=>'L',
66683=>'L',
66684=>'L',
66685=>'L',
66686=>'L',
66687=>'L',
66688=>'L',
66689=>'L',
66690=>'L',
66691=>'L',
66692=>'L',
66693=>'L',
66694=>'L',
66695=>'L',
66696=>'L',
66697=>'L',
66698=>'L',
66699=>'L',
66700=>'L',
66701=>'L',
66702=>'L',
66703=>'L',
66704=>'L',
66705=>'L',
66706=>'L',
66707=>'L',
66708=>'L',
66709=>'L',
66710=>'L',
66711=>'L',
66712=>'L',
66713=>'L',
66714=>'L',
66715=>'L',
66716=>'L',
66717=>'L',
66720=>'L',
66721=>'L',
66722=>'L',
66723=>'L',
66724=>'L',
66725=>'L',
66726=>'L',
66727=>'L',
66728=>'L',
66729=>'L',
67584=>'R',
67585=>'R',
67586=>'R',
67587=>'R',
67588=>'R',
67589=>'R',
67592=>'R',
67594=>'R',
67595=>'R',
67596=>'R',
67597=>'R',
67598=>'R',
67599=>'R',
67600=>'R',
67601=>'R',
67602=>'R',
67603=>'R',
67604=>'R',
67605=>'R',
67606=>'R',
67607=>'R',
67608=>'R',
67609=>'R',
67610=>'R',
67611=>'R',
67612=>'R',
67613=>'R',
67614=>'R',
67615=>'R',
67616=>'R',
67617=>'R',
67618=>'R',
67619=>'R',
67620=>'R',
67621=>'R',
67622=>'R',
67623=>'R',
67624=>'R',
67625=>'R',
67626=>'R',
67627=>'R',
67628=>'R',
67629=>'R',
67630=>'R',
67631=>'R',
67632=>'R',
67633=>'R',
67634=>'R',
67635=>'R',
67636=>'R',
67637=>'R',
67639=>'R',
67640=>'R',
67644=>'R',
67647=>'R',
67840=>'R',
67841=>'R',
67842=>'R',
67843=>'R',
67844=>'R',
67845=>'R',
67846=>'R',
67847=>'R',
67848=>'R',
67849=>'R',
67850=>'R',
67851=>'R',
67852=>'R',
67853=>'R',
67854=>'R',
67855=>'R',
67856=>'R',
67857=>'R',
67858=>'R',
67859=>'R',
67860=>'R',
67861=>'R',
67862=>'R',
67863=>'R',
67864=>'R',
67865=>'R',
67871=>'ON',
68096=>'R',
68097=>'NSM',
68098=>'NSM',
68099=>'NSM',
68101=>'NSM',
68102=>'NSM',
68108=>'NSM',
68109=>'NSM',
68110=>'NSM',
68111=>'NSM',
68112=>'R',
68113=>'R',
68114=>'R',
68115=>'R',
68117=>'R',
68118=>'R',
68119=>'R',
68121=>'R',
68122=>'R',
68123=>'R',
68124=>'R',
68125=>'R',
68126=>'R',
68127=>'R',
68128=>'R',
68129=>'R',
68130=>'R',
68131=>'R',
68132=>'R',
68133=>'R',
68134=>'R',
68135=>'R',
68136=>'R',
68137=>'R',
68138=>'R',
68139=>'R',
68140=>'R',
68141=>'R',
68142=>'R',
68143=>'R',
68144=>'R',
68145=>'R',
68146=>'R',
68147=>'R',
68152=>'NSM',
68153=>'NSM',
68154=>'NSM',
68159=>'NSM',
68160=>'R',
68161=>'R',
68162=>'R',
68163=>'R',
68164=>'R',
68165=>'R',
68166=>'R',
68167=>'R',
68176=>'R',
68177=>'R',
68178=>'R',
68179=>'R',
68180=>'R',
68181=>'R',
68182=>'R',
68183=>'R',
68184=>'R',
73728=>'L',
73729=>'L',
73730=>'L',
73731=>'L',
73732=>'L',
73733=>'L',
73734=>'L',
73735=>'L',
73736=>'L',
73737=>'L',
73738=>'L',
73739=>'L',
73740=>'L',
73741=>'L',
73742=>'L',
73743=>'L',
73744=>'L',
73745=>'L',
73746=>'L',
73747=>'L',
73748=>'L',
73749=>'L',
73750=>'L',
73751=>'L',
73752=>'L',
73753=>'L',
73754=>'L',
73755=>'L',
73756=>'L',
73757=>'L',
73758=>'L',
73759=>'L',
73760=>'L',
73761=>'L',
73762=>'L',
73763=>'L',
73764=>'L',
73765=>'L',
73766=>'L',
73767=>'L',
73768=>'L',
73769=>'L',
73770=>'L',
73771=>'L',
73772=>'L',
73773=>'L',
73774=>'L',
73775=>'L',
73776=>'L',
73777=>'L',
73778=>'L',
73779=>'L',
73780=>'L',
73781=>'L',
73782=>'L',
73783=>'L',
73784=>'L',
73785=>'L',
73786=>'L',
73787=>'L',
73788=>'L',
73789=>'L',
73790=>'L',
73791=>'L',
73792=>'L',
73793=>'L',
73794=>'L',
73795=>'L',
73796=>'L',
73797=>'L',
73798=>'L',
73799=>'L',
73800=>'L',
73801=>'L',
73802=>'L',
73803=>'L',
73804=>'L',
73805=>'L',
73806=>'L',
73807=>'L',
73808=>'L',
73809=>'L',
73810=>'L',
73811=>'L',
73812=>'L',
73813=>'L',
73814=>'L',
73815=>'L',
73816=>'L',
73817=>'L',
73818=>'L',
73819=>'L',
73820=>'L',
73821=>'L',
73822=>'L',
73823=>'L',
73824=>'L',
73825=>'L',
73826=>'L',
73827=>'L',
73828=>'L',
73829=>'L',
73830=>'L',
73831=>'L',
73832=>'L',
73833=>'L',
73834=>'L',
73835=>'L',
73836=>'L',
73837=>'L',
73838=>'L',
73839=>'L',
73840=>'L',
73841=>'L',
73842=>'L',
73843=>'L',
73844=>'L',
73845=>'L',
73846=>'L',
73847=>'L',
73848=>'L',
73849=>'L',
73850=>'L',
73851=>'L',
73852=>'L',
73853=>'L',
73854=>'L',
73855=>'L',
73856=>'L',
73857=>'L',
73858=>'L',
73859=>'L',
73860=>'L',
73861=>'L',
73862=>'L',
73863=>'L',
73864=>'L',
73865=>'L',
73866=>'L',
73867=>'L',
73868=>'L',
73869=>'L',
73870=>'L',
73871=>'L',
73872=>'L',
73873=>'L',
73874=>'L',
73875=>'L',
73876=>'L',
73877=>'L',
73878=>'L',
73879=>'L',
73880=>'L',
73881=>'L',
73882=>'L',
73883=>'L',
73884=>'L',
73885=>'L',
73886=>'L',
73887=>'L',
73888=>'L',
73889=>'L',
73890=>'L',
73891=>'L',
73892=>'L',
73893=>'L',
73894=>'L',
73895=>'L',
73896=>'L',
73897=>'L',
73898=>'L',
73899=>'L',
73900=>'L',
73901=>'L',
73902=>'L',
73903=>'L',
73904=>'L',
73905=>'L',
73906=>'L',
73907=>'L',
73908=>'L',
73909=>'L',
73910=>'L',
73911=>'L',
73912=>'L',
73913=>'L',
73914=>'L',
73915=>'L',
73916=>'L',
73917=>'L',
73918=>'L',
73919=>'L',
73920=>'L',
73921=>'L',
73922=>'L',
73923=>'L',
73924=>'L',
73925=>'L',
73926=>'L',
73927=>'L',
73928=>'L',
73929=>'L',
73930=>'L',
73931=>'L',
73932=>'L',
73933=>'L',
73934=>'L',
73935=>'L',
73936=>'L',
73937=>'L',
73938=>'L',
73939=>'L',
73940=>'L',
73941=>'L',
73942=>'L',
73943=>'L',
73944=>'L',
73945=>'L',
73946=>'L',
73947=>'L',
73948=>'L',
73949=>'L',
73950=>'L',
73951=>'L',
73952=>'L',
73953=>'L',
73954=>'L',
73955=>'L',
73956=>'L',
73957=>'L',
73958=>'L',
73959=>'L',
73960=>'L',
73961=>'L',
73962=>'L',
73963=>'L',
73964=>'L',
73965=>'L',
73966=>'L',
73967=>'L',
73968=>'L',
73969=>'L',
73970=>'L',
73971=>'L',
73972=>'L',
73973=>'L',
73974=>'L',
73975=>'L',
73976=>'L',
73977=>'L',
73978=>'L',
73979=>'L',
73980=>'L',
73981=>'L',
73982=>'L',
73983=>'L',
73984=>'L',
73985=>'L',
73986=>'L',
73987=>'L',
73988=>'L',
73989=>'L',
73990=>'L',
73991=>'L',
73992=>'L',
73993=>'L',
73994=>'L',
73995=>'L',
73996=>'L',
73997=>'L',
73998=>'L',
73999=>'L',
74000=>'L',
74001=>'L',
74002=>'L',
74003=>'L',
74004=>'L',
74005=>'L',
74006=>'L',
74007=>'L',
74008=>'L',
74009=>'L',
74010=>'L',
74011=>'L',
74012=>'L',
74013=>'L',
74014=>'L',
74015=>'L',
74016=>'L',
74017=>'L',
74018=>'L',
74019=>'L',
74020=>'L',
74021=>'L',
74022=>'L',
74023=>'L',
74024=>'L',
74025=>'L',
74026=>'L',
74027=>'L',
74028=>'L',
74029=>'L',
74030=>'L',
74031=>'L',
74032=>'L',
74033=>'L',
74034=>'L',
74035=>'L',
74036=>'L',
74037=>'L',
74038=>'L',
74039=>'L',
74040=>'L',
74041=>'L',
74042=>'L',
74043=>'L',
74044=>'L',
74045=>'L',
74046=>'L',
74047=>'L',
74048=>'L',
74049=>'L',
74050=>'L',
74051=>'L',
74052=>'L',
74053=>'L',
74054=>'L',
74055=>'L',
74056=>'L',
74057=>'L',
74058=>'L',
74059=>'L',
74060=>'L',
74061=>'L',
74062=>'L',
74063=>'L',
74064=>'L',
74065=>'L',
74066=>'L',
74067=>'L',
74068=>'L',
74069=>'L',
74070=>'L',
74071=>'L',
74072=>'L',
74073=>'L',
74074=>'L',
74075=>'L',
74076=>'L',
74077=>'L',
74078=>'L',
74079=>'L',
74080=>'L',
74081=>'L',
74082=>'L',
74083=>'L',
74084=>'L',
74085=>'L',
74086=>'L',
74087=>'L',
74088=>'L',
74089=>'L',
74090=>'L',
74091=>'L',
74092=>'L',
74093=>'L',
74094=>'L',
74095=>'L',
74096=>'L',
74097=>'L',
74098=>'L',
74099=>'L',
74100=>'L',
74101=>'L',
74102=>'L',
74103=>'L',
74104=>'L',
74105=>'L',
74106=>'L',
74107=>'L',
74108=>'L',
74109=>'L',
74110=>'L',
74111=>'L',
74112=>'L',
74113=>'L',
74114=>'L',
74115=>'L',
74116=>'L',
74117=>'L',
74118=>'L',
74119=>'L',
74120=>'L',
74121=>'L',
74122=>'L',
74123=>'L',
74124=>'L',
74125=>'L',
74126=>'L',
74127=>'L',
74128=>'L',
74129=>'L',
74130=>'L',
74131=>'L',
74132=>'L',
74133=>'L',
74134=>'L',
74135=>'L',
74136=>'L',
74137=>'L',
74138=>'L',
74139=>'L',
74140=>'L',
74141=>'L',
74142=>'L',
74143=>'L',
74144=>'L',
74145=>'L',
74146=>'L',
74147=>'L',
74148=>'L',
74149=>'L',
74150=>'L',
74151=>'L',
74152=>'L',
74153=>'L',
74154=>'L',
74155=>'L',
74156=>'L',
74157=>'L',
74158=>'L',
74159=>'L',
74160=>'L',
74161=>'L',
74162=>'L',
74163=>'L',
74164=>'L',
74165=>'L',
74166=>'L',
74167=>'L',
74168=>'L',
74169=>'L',
74170=>'L',
74171=>'L',
74172=>'L',
74173=>'L',
74174=>'L',
74175=>'L',
74176=>'L',
74177=>'L',
74178=>'L',
74179=>'L',
74180=>'L',
74181=>'L',
74182=>'L',
74183=>'L',
74184=>'L',
74185=>'L',
74186=>'L',
74187=>'L',
74188=>'L',
74189=>'L',
74190=>'L',
74191=>'L',
74192=>'L',
74193=>'L',
74194=>'L',
74195=>'L',
74196=>'L',
74197=>'L',
74198=>'L',
74199=>'L',
74200=>'L',
74201=>'L',
74202=>'L',
74203=>'L',
74204=>'L',
74205=>'L',
74206=>'L',
74207=>'L',
74208=>'L',
74209=>'L',
74210=>'L',
74211=>'L',
74212=>'L',
74213=>'L',
74214=>'L',
74215=>'L',
74216=>'L',
74217=>'L',
74218=>'L',
74219=>'L',
74220=>'L',
74221=>'L',
74222=>'L',
74223=>'L',
74224=>'L',
74225=>'L',
74226=>'L',
74227=>'L',
74228=>'L',
74229=>'L',
74230=>'L',
74231=>'L',
74232=>'L',
74233=>'L',
74234=>'L',
74235=>'L',
74236=>'L',
74237=>'L',
74238=>'L',
74239=>'L',
74240=>'L',
74241=>'L',
74242=>'L',
74243=>'L',
74244=>'L',
74245=>'L',
74246=>'L',
74247=>'L',
74248=>'L',
74249=>'L',
74250=>'L',
74251=>'L',
74252=>'L',
74253=>'L',
74254=>'L',
74255=>'L',
74256=>'L',
74257=>'L',
74258=>'L',
74259=>'L',
74260=>'L',
74261=>'L',
74262=>'L',
74263=>'L',
74264=>'L',
74265=>'L',
74266=>'L',
74267=>'L',
74268=>'L',
74269=>'L',
74270=>'L',
74271=>'L',
74272=>'L',
74273=>'L',
74274=>'L',
74275=>'L',
74276=>'L',
74277=>'L',
74278=>'L',
74279=>'L',
74280=>'L',
74281=>'L',
74282=>'L',
74283=>'L',
74284=>'L',
74285=>'L',
74286=>'L',
74287=>'L',
74288=>'L',
74289=>'L',
74290=>'L',
74291=>'L',
74292=>'L',
74293=>'L',
74294=>'L',
74295=>'L',
74296=>'L',
74297=>'L',
74298=>'L',
74299=>'L',
74300=>'L',
74301=>'L',
74302=>'L',
74303=>'L',
74304=>'L',
74305=>'L',
74306=>'L',
74307=>'L',
74308=>'L',
74309=>'L',
74310=>'L',
74311=>'L',
74312=>'L',
74313=>'L',
74314=>'L',
74315=>'L',
74316=>'L',
74317=>'L',
74318=>'L',
74319=>'L',
74320=>'L',
74321=>'L',
74322=>'L',
74323=>'L',
74324=>'L',
74325=>'L',
74326=>'L',
74327=>'L',
74328=>'L',
74329=>'L',
74330=>'L',
74331=>'L',
74332=>'L',
74333=>'L',
74334=>'L',
74335=>'L',
74336=>'L',
74337=>'L',
74338=>'L',
74339=>'L',
74340=>'L',
74341=>'L',
74342=>'L',
74343=>'L',
74344=>'L',
74345=>'L',
74346=>'L',
74347=>'L',
74348=>'L',
74349=>'L',
74350=>'L',
74351=>'L',
74352=>'L',
74353=>'L',
74354=>'L',
74355=>'L',
74356=>'L',
74357=>'L',
74358=>'L',
74359=>'L',
74360=>'L',
74361=>'L',
74362=>'L',
74363=>'L',
74364=>'L',
74365=>'L',
74366=>'L',
74367=>'L',
74368=>'L',
74369=>'L',
74370=>'L',
74371=>'L',
74372=>'L',
74373=>'L',
74374=>'L',
74375=>'L',
74376=>'L',
74377=>'L',
74378=>'L',
74379=>'L',
74380=>'L',
74381=>'L',
74382=>'L',
74383=>'L',
74384=>'L',
74385=>'L',
74386=>'L',
74387=>'L',
74388=>'L',
74389=>'L',
74390=>'L',
74391=>'L',
74392=>'L',
74393=>'L',
74394=>'L',
74395=>'L',
74396=>'L',
74397=>'L',
74398=>'L',
74399=>'L',
74400=>'L',
74401=>'L',
74402=>'L',
74403=>'L',
74404=>'L',
74405=>'L',
74406=>'L',
74407=>'L',
74408=>'L',
74409=>'L',
74410=>'L',
74411=>'L',
74412=>'L',
74413=>'L',
74414=>'L',
74415=>'L',
74416=>'L',
74417=>'L',
74418=>'L',
74419=>'L',
74420=>'L',
74421=>'L',
74422=>'L',
74423=>'L',
74424=>'L',
74425=>'L',
74426=>'L',
74427=>'L',
74428=>'L',
74429=>'L',
74430=>'L',
74431=>'L',
74432=>'L',
74433=>'L',
74434=>'L',
74435=>'L',
74436=>'L',
74437=>'L',
74438=>'L',
74439=>'L',
74440=>'L',
74441=>'L',
74442=>'L',
74443=>'L',
74444=>'L',
74445=>'L',
74446=>'L',
74447=>'L',
74448=>'L',
74449=>'L',
74450=>'L',
74451=>'L',
74452=>'L',
74453=>'L',
74454=>'L',
74455=>'L',
74456=>'L',
74457=>'L',
74458=>'L',
74459=>'L',
74460=>'L',
74461=>'L',
74462=>'L',
74463=>'L',
74464=>'L',
74465=>'L',
74466=>'L',
74467=>'L',
74468=>'L',
74469=>'L',
74470=>'L',
74471=>'L',
74472=>'L',
74473=>'L',
74474=>'L',
74475=>'L',
74476=>'L',
74477=>'L',
74478=>'L',
74479=>'L',
74480=>'L',
74481=>'L',
74482=>'L',
74483=>'L',
74484=>'L',
74485=>'L',
74486=>'L',
74487=>'L',
74488=>'L',
74489=>'L',
74490=>'L',
74491=>'L',
74492=>'L',
74493=>'L',
74494=>'L',
74495=>'L',
74496=>'L',
74497=>'L',
74498=>'L',
74499=>'L',
74500=>'L',
74501=>'L',
74502=>'L',
74503=>'L',
74504=>'L',
74505=>'L',
74506=>'L',
74507=>'L',
74508=>'L',
74509=>'L',
74510=>'L',
74511=>'L',
74512=>'L',
74513=>'L',
74514=>'L',
74515=>'L',
74516=>'L',
74517=>'L',
74518=>'L',
74519=>'L',
74520=>'L',
74521=>'L',
74522=>'L',
74523=>'L',
74524=>'L',
74525=>'L',
74526=>'L',
74527=>'L',
74528=>'L',
74529=>'L',
74530=>'L',
74531=>'L',
74532=>'L',
74533=>'L',
74534=>'L',
74535=>'L',
74536=>'L',
74537=>'L',
74538=>'L',
74539=>'L',
74540=>'L',
74541=>'L',
74542=>'L',
74543=>'L',
74544=>'L',
74545=>'L',
74546=>'L',
74547=>'L',
74548=>'L',
74549=>'L',
74550=>'L',
74551=>'L',
74552=>'L',
74553=>'L',
74554=>'L',
74555=>'L',
74556=>'L',
74557=>'L',
74558=>'L',
74559=>'L',
74560=>'L',
74561=>'L',
74562=>'L',
74563=>'L',
74564=>'L',
74565=>'L',
74566=>'L',
74567=>'L',
74568=>'L',
74569=>'L',
74570=>'L',
74571=>'L',
74572=>'L',
74573=>'L',
74574=>'L',
74575=>'L',
74576=>'L',
74577=>'L',
74578=>'L',
74579=>'L',
74580=>'L',
74581=>'L',
74582=>'L',
74583=>'L',
74584=>'L',
74585=>'L',
74586=>'L',
74587=>'L',
74588=>'L',
74589=>'L',
74590=>'L',
74591=>'L',
74592=>'L',
74593=>'L',
74594=>'L',
74595=>'L',
74596=>'L',
74597=>'L',
74598=>'L',
74599=>'L',
74600=>'L',
74601=>'L',
74602=>'L',
74603=>'L',
74604=>'L',
74605=>'L',
74606=>'L',
74752=>'L',
74753=>'L',
74754=>'L',
74755=>'L',
74756=>'L',
74757=>'L',
74758=>'L',
74759=>'L',
74760=>'L',
74761=>'L',
74762=>'L',
74763=>'L',
74764=>'L',
74765=>'L',
74766=>'L',
74767=>'L',
74768=>'L',
74769=>'L',
74770=>'L',
74771=>'L',
74772=>'L',
74773=>'L',
74774=>'L',
74775=>'L',
74776=>'L',
74777=>'L',
74778=>'L',
74779=>'L',
74780=>'L',
74781=>'L',
74782=>'L',
74783=>'L',
74784=>'L',
74785=>'L',
74786=>'L',
74787=>'L',
74788=>'L',
74789=>'L',
74790=>'L',
74791=>'L',
74792=>'L',
74793=>'L',
74794=>'L',
74795=>'L',
74796=>'L',
74797=>'L',
74798=>'L',
74799=>'L',
74800=>'L',
74801=>'L',
74802=>'L',
74803=>'L',
74804=>'L',
74805=>'L',
74806=>'L',
74807=>'L',
74808=>'L',
74809=>'L',
74810=>'L',
74811=>'L',
74812=>'L',
74813=>'L',
74814=>'L',
74815=>'L',
74816=>'L',
74817=>'L',
74818=>'L',
74819=>'L',
74820=>'L',
74821=>'L',
74822=>'L',
74823=>'L',
74824=>'L',
74825=>'L',
74826=>'L',
74827=>'L',
74828=>'L',
74829=>'L',
74830=>'L',
74831=>'L',
74832=>'L',
74833=>'L',
74834=>'L',
74835=>'L',
74836=>'L',
74837=>'L',
74838=>'L',
74839=>'L',
74840=>'L',
74841=>'L',
74842=>'L',
74843=>'L',
74844=>'L',
74845=>'L',
74846=>'L',
74847=>'L',
74848=>'L',
74849=>'L',
74850=>'L',
74864=>'L',
74865=>'L',
74866=>'L',
74867=>'L',
118784=>'L',
118785=>'L',
118786=>'L',
118787=>'L',
118788=>'L',
118789=>'L',
118790=>'L',
118791=>'L',
118792=>'L',
118793=>'L',
118794=>'L',
118795=>'L',
118796=>'L',
118797=>'L',
118798=>'L',
118799=>'L',
118800=>'L',
118801=>'L',
118802=>'L',
118803=>'L',
118804=>'L',
118805=>'L',
118806=>'L',
118807=>'L',
118808=>'L',
118809=>'L',
118810=>'L',
118811=>'L',
118812=>'L',
118813=>'L',
118814=>'L',
118815=>'L',
118816=>'L',
118817=>'L',
118818=>'L',
118819=>'L',
118820=>'L',
118821=>'L',
118822=>'L',
118823=>'L',
118824=>'L',
118825=>'L',
118826=>'L',
118827=>'L',
118828=>'L',
118829=>'L',
118830=>'L',
118831=>'L',
118832=>'L',
118833=>'L',
118834=>'L',
118835=>'L',
118836=>'L',
118837=>'L',
118838=>'L',
118839=>'L',
118840=>'L',
118841=>'L',
118842=>'L',
118843=>'L',
118844=>'L',
118845=>'L',
118846=>'L',
118847=>'L',
118848=>'L',
118849=>'L',
118850=>'L',
118851=>'L',
118852=>'L',
118853=>'L',
118854=>'L',
118855=>'L',
118856=>'L',
118857=>'L',
118858=>'L',
118859=>'L',
118860=>'L',
118861=>'L',
118862=>'L',
118863=>'L',
118864=>'L',
118865=>'L',
118866=>'L',
118867=>'L',
118868=>'L',
118869=>'L',
118870=>'L',
118871=>'L',
118872=>'L',
118873=>'L',
118874=>'L',
118875=>'L',
118876=>'L',
118877=>'L',
118878=>'L',
118879=>'L',
118880=>'L',
118881=>'L',
118882=>'L',
118883=>'L',
118884=>'L',
118885=>'L',
118886=>'L',
118887=>'L',
118888=>'L',
118889=>'L',
118890=>'L',
118891=>'L',
118892=>'L',
118893=>'L',
118894=>'L',
118895=>'L',
118896=>'L',
118897=>'L',
118898=>'L',
118899=>'L',
118900=>'L',
118901=>'L',
118902=>'L',
118903=>'L',
118904=>'L',
118905=>'L',
118906=>'L',
118907=>'L',
118908=>'L',
118909=>'L',
118910=>'L',
118911=>'L',
118912=>'L',
118913=>'L',
118914=>'L',
118915=>'L',
118916=>'L',
118917=>'L',
118918=>'L',
118919=>'L',
118920=>'L',
118921=>'L',
118922=>'L',
118923=>'L',
118924=>'L',
118925=>'L',
118926=>'L',
118927=>'L',
118928=>'L',
118929=>'L',
118930=>'L',
118931=>'L',
118932=>'L',
118933=>'L',
118934=>'L',
118935=>'L',
118936=>'L',
118937=>'L',
118938=>'L',
118939=>'L',
118940=>'L',
118941=>'L',
118942=>'L',
118943=>'L',
118944=>'L',
118945=>'L',
118946=>'L',
118947=>'L',
118948=>'L',
118949=>'L',
118950=>'L',
118951=>'L',
118952=>'L',
118953=>'L',
118954=>'L',
118955=>'L',
118956=>'L',
118957=>'L',
118958=>'L',
118959=>'L',
118960=>'L',
118961=>'L',
118962=>'L',
118963=>'L',
118964=>'L',
118965=>'L',
118966=>'L',
118967=>'L',
118968=>'L',
118969=>'L',
118970=>'L',
118971=>'L',
118972=>'L',
118973=>'L',
118974=>'L',
118975=>'L',
118976=>'L',
118977=>'L',
118978=>'L',
118979=>'L',
118980=>'L',
118981=>'L',
118982=>'L',
118983=>'L',
118984=>'L',
118985=>'L',
118986=>'L',
118987=>'L',
118988=>'L',
118989=>'L',
118990=>'L',
118991=>'L',
118992=>'L',
118993=>'L',
118994=>'L',
118995=>'L',
118996=>'L',
118997=>'L',
118998=>'L',
118999=>'L',
119000=>'L',
119001=>'L',
119002=>'L',
119003=>'L',
119004=>'L',
119005=>'L',
119006=>'L',
119007=>'L',
119008=>'L',
119009=>'L',
119010=>'L',
119011=>'L',
119012=>'L',
119013=>'L',
119014=>'L',
119015=>'L',
119016=>'L',
119017=>'L',
119018=>'L',
119019=>'L',
119020=>'L',
119021=>'L',
119022=>'L',
119023=>'L',
119024=>'L',
119025=>'L',
119026=>'L',
119027=>'L',
119028=>'L',
119029=>'L',
119040=>'L',
119041=>'L',
119042=>'L',
119043=>'L',
119044=>'L',
119045=>'L',
119046=>'L',
119047=>'L',
119048=>'L',
119049=>'L',
119050=>'L',
119051=>'L',
119052=>'L',
119053=>'L',
119054=>'L',
119055=>'L',
119056=>'L',
119057=>'L',
119058=>'L',
119059=>'L',
119060=>'L',
119061=>'L',
119062=>'L',
119063=>'L',
119064=>'L',
119065=>'L',
119066=>'L',
119067=>'L',
119068=>'L',
119069=>'L',
119070=>'L',
119071=>'L',
119072=>'L',
119073=>'L',
119074=>'L',
119075=>'L',
119076=>'L',
119077=>'L',
119078=>'L',
119082=>'L',
119083=>'L',
119084=>'L',
119085=>'L',
119086=>'L',
119087=>'L',
119088=>'L',
119089=>'L',
119090=>'L',
119091=>'L',
119092=>'L',
119093=>'L',
119094=>'L',
119095=>'L',
119096=>'L',
119097=>'L',
119098=>'L',
119099=>'L',
119100=>'L',
119101=>'L',
119102=>'L',
119103=>'L',
119104=>'L',
119105=>'L',
119106=>'L',
119107=>'L',
119108=>'L',
119109=>'L',
119110=>'L',
119111=>'L',
119112=>'L',
119113=>'L',
119114=>'L',
119115=>'L',
119116=>'L',
119117=>'L',
119118=>'L',
119119=>'L',
119120=>'L',
119121=>'L',
119122=>'L',
119123=>'L',
119124=>'L',
119125=>'L',
119126=>'L',
119127=>'L',
119128=>'L',
119129=>'L',
119130=>'L',
119131=>'L',
119132=>'L',
119133=>'L',
119134=>'L',
119135=>'L',
119136=>'L',
119137=>'L',
119138=>'L',
119139=>'L',
119140=>'L',
119141=>'L',
119142=>'L',
119143=>'NSM',
119144=>'NSM',
119145=>'NSM',
119146=>'L',
119147=>'L',
119148=>'L',
119149=>'L',
119150=>'L',
119151=>'L',
119152=>'L',
119153=>'L',
119154=>'L',
119155=>'BN',
119156=>'BN',
119157=>'BN',
119158=>'BN',
119159=>'BN',
119160=>'BN',
119161=>'BN',
119162=>'BN',
119163=>'NSM',
119164=>'NSM',
119165=>'NSM',
119166=>'NSM',
119167=>'NSM',
119168=>'NSM',
119169=>'NSM',
119170=>'NSM',
119171=>'L',
119172=>'L',
119173=>'NSM',
119174=>'NSM',
119175=>'NSM',
119176=>'NSM',
119177=>'NSM',
119178=>'NSM',
119179=>'NSM',
119180=>'L',
119181=>'L',
119182=>'L',
119183=>'L',
119184=>'L',
119185=>'L',
119186=>'L',
119187=>'L',
119188=>'L',
119189=>'L',
119190=>'L',
119191=>'L',
119192=>'L',
119193=>'L',
119194=>'L',
119195=>'L',
119196=>'L',
119197=>'L',
119198=>'L',
119199=>'L',
119200=>'L',
119201=>'L',
119202=>'L',
119203=>'L',
119204=>'L',
119205=>'L',
119206=>'L',
119207=>'L',
119208=>'L',
119209=>'L',
119210=>'NSM',
119211=>'NSM',
119212=>'NSM',
119213=>'NSM',
119214=>'L',
119215=>'L',
119216=>'L',
119217=>'L',
119218=>'L',
119219=>'L',
119220=>'L',
119221=>'L',
119222=>'L',
119223=>'L',
119224=>'L',
119225=>'L',
119226=>'L',
119227=>'L',
119228=>'L',
119229=>'L',
119230=>'L',
119231=>'L',
119232=>'L',
119233=>'L',
119234=>'L',
119235=>'L',
119236=>'L',
119237=>'L',
119238=>'L',
119239=>'L',
119240=>'L',
119241=>'L',
119242=>'L',
119243=>'L',
119244=>'L',
119245=>'L',
119246=>'L',
119247=>'L',
119248=>'L',
119249=>'L',
119250=>'L',
119251=>'L',
119252=>'L',
119253=>'L',
119254=>'L',
119255=>'L',
119256=>'L',
119257=>'L',
119258=>'L',
119259=>'L',
119260=>'L',
119261=>'L',
119296=>'ON',
119297=>'ON',
119298=>'ON',
119299=>'ON',
119300=>'ON',
119301=>'ON',
119302=>'ON',
119303=>'ON',
119304=>'ON',
119305=>'ON',
119306=>'ON',
119307=>'ON',
119308=>'ON',
119309=>'ON',
119310=>'ON',
119311=>'ON',
119312=>'ON',
119313=>'ON',
119314=>'ON',
119315=>'ON',
119316=>'ON',
119317=>'ON',
119318=>'ON',
119319=>'ON',
119320=>'ON',
119321=>'ON',
119322=>'ON',
119323=>'ON',
119324=>'ON',
119325=>'ON',
119326=>'ON',
119327=>'ON',
119328=>'ON',
119329=>'ON',
119330=>'ON',
119331=>'ON',
119332=>'ON',
119333=>'ON',
119334=>'ON',
119335=>'ON',
119336=>'ON',
119337=>'ON',
119338=>'ON',
119339=>'ON',
119340=>'ON',
119341=>'ON',
119342=>'ON',
119343=>'ON',
119344=>'ON',
119345=>'ON',
119346=>'ON',
119347=>'ON',
119348=>'ON',
119349=>'ON',
119350=>'ON',
119351=>'ON',
119352=>'ON',
119353=>'ON',
119354=>'ON',
119355=>'ON',
119356=>'ON',
119357=>'ON',
119358=>'ON',
119359=>'ON',
119360=>'ON',
119361=>'ON',
119362=>'NSM',
119363=>'NSM',
119364=>'NSM',
119365=>'ON',
119552=>'ON',
119553=>'ON',
119554=>'ON',
119555=>'ON',
119556=>'ON',
119557=>'ON',
119558=>'ON',
119559=>'ON',
119560=>'ON',
119561=>'ON',
119562=>'ON',
119563=>'ON',
119564=>'ON',
119565=>'ON',
119566=>'ON',
119567=>'ON',
119568=>'ON',
119569=>'ON',
119570=>'ON',
119571=>'ON',
119572=>'ON',
119573=>'ON',
119574=>'ON',
119575=>'ON',
119576=>'ON',
119577=>'ON',
119578=>'ON',
119579=>'ON',
119580=>'ON',
119581=>'ON',
119582=>'ON',
119583=>'ON',
119584=>'ON',
119585=>'ON',
119586=>'ON',
119587=>'ON',
119588=>'ON',
119589=>'ON',
119590=>'ON',
119591=>'ON',
119592=>'ON',
119593=>'ON',
119594=>'ON',
119595=>'ON',
119596=>'ON',
119597=>'ON',
119598=>'ON',
119599=>'ON',
119600=>'ON',
119601=>'ON',
119602=>'ON',
119603=>'ON',
119604=>'ON',
119605=>'ON',
119606=>'ON',
119607=>'ON',
119608=>'ON',
119609=>'ON',
119610=>'ON',
119611=>'ON',
119612=>'ON',
119613=>'ON',
119614=>'ON',
119615=>'ON',
119616=>'ON',
119617=>'ON',
119618=>'ON',
119619=>'ON',
119620=>'ON',
119621=>'ON',
119622=>'ON',
119623=>'ON',
119624=>'ON',
119625=>'ON',
119626=>'ON',
119627=>'ON',
119628=>'ON',
119629=>'ON',
119630=>'ON',
119631=>'ON',
119632=>'ON',
119633=>'ON',
119634=>'ON',
119635=>'ON',
119636=>'ON',
119637=>'ON',
119638=>'ON',
119648=>'L',
119649=>'L',
119650=>'L',
119651=>'L',
119652=>'L',
119653=>'L',
119654=>'L',
119655=>'L',
119656=>'L',
119657=>'L',
119658=>'L',
119659=>'L',
119660=>'L',
119661=>'L',
119662=>'L',
119663=>'L',
119664=>'L',
119665=>'L',
119808=>'L',
119809=>'L',
119810=>'L',
119811=>'L',
119812=>'L',
119813=>'L',
119814=>'L',
119815=>'L',
119816=>'L',
119817=>'L',
119818=>'L',
119819=>'L',
119820=>'L',
119821=>'L',
119822=>'L',
119823=>'L',
119824=>'L',
119825=>'L',
119826=>'L',
119827=>'L',
119828=>'L',
119829=>'L',
119830=>'L',
119831=>'L',
119832=>'L',
119833=>'L',
119834=>'L',
119835=>'L',
119836=>'L',
119837=>'L',
119838=>'L',
119839=>'L',
119840=>'L',
119841=>'L',
119842=>'L',
119843=>'L',
119844=>'L',
119845=>'L',
119846=>'L',
119847=>'L',
119848=>'L',
119849=>'L',
119850=>'L',
119851=>'L',
119852=>'L',
119853=>'L',
119854=>'L',
119855=>'L',
119856=>'L',
119857=>'L',
119858=>'L',
119859=>'L',
119860=>'L',
119861=>'L',
119862=>'L',
119863=>'L',
119864=>'L',
119865=>'L',
119866=>'L',
119867=>'L',
119868=>'L',
119869=>'L',
119870=>'L',
119871=>'L',
119872=>'L',
119873=>'L',
119874=>'L',
119875=>'L',
119876=>'L',
119877=>'L',
119878=>'L',
119879=>'L',
119880=>'L',
119881=>'L',
119882=>'L',
119883=>'L',
119884=>'L',
119885=>'L',
119886=>'L',
119887=>'L',
119888=>'L',
119889=>'L',
119890=>'L',
119891=>'L',
119892=>'L',
119894=>'L',
119895=>'L',
119896=>'L',
119897=>'L',
119898=>'L',
119899=>'L',
119900=>'L',
119901=>'L',
119902=>'L',
119903=>'L',
119904=>'L',
119905=>'L',
119906=>'L',
119907=>'L',
119908=>'L',
119909=>'L',
119910=>'L',
119911=>'L',
119912=>'L',
119913=>'L',
119914=>'L',
119915=>'L',
119916=>'L',
119917=>'L',
119918=>'L',
119919=>'L',
119920=>'L',
119921=>'L',
119922=>'L',
119923=>'L',
119924=>'L',
119925=>'L',
119926=>'L',
119927=>'L',
119928=>'L',
119929=>'L',
119930=>'L',
119931=>'L',
119932=>'L',
119933=>'L',
119934=>'L',
119935=>'L',
119936=>'L',
119937=>'L',
119938=>'L',
119939=>'L',
119940=>'L',
119941=>'L',
119942=>'L',
119943=>'L',
119944=>'L',
119945=>'L',
119946=>'L',
119947=>'L',
119948=>'L',
119949=>'L',
119950=>'L',
119951=>'L',
119952=>'L',
119953=>'L',
119954=>'L',
119955=>'L',
119956=>'L',
119957=>'L',
119958=>'L',
119959=>'L',
119960=>'L',
119961=>'L',
119962=>'L',
119963=>'L',
119964=>'L',
119966=>'L',
119967=>'L',
119970=>'L',
119973=>'L',
119974=>'L',
119977=>'L',
119978=>'L',
119979=>'L',
119980=>'L',
119982=>'L',
119983=>'L',
119984=>'L',
119985=>'L',
119986=>'L',
119987=>'L',
119988=>'L',
119989=>'L',
119990=>'L',
119991=>'L',
119992=>'L',
119993=>'L',
119995=>'L',
119997=>'L',
119998=>'L',
119999=>'L',
120000=>'L',
120001=>'L',
120002=>'L',
120003=>'L',
120005=>'L',
120006=>'L',
120007=>'L',
120008=>'L',
120009=>'L',
120010=>'L',
120011=>'L',
120012=>'L',
120013=>'L',
120014=>'L',
120015=>'L',
120016=>'L',
120017=>'L',
120018=>'L',
120019=>'L',
120020=>'L',
120021=>'L',
120022=>'L',
120023=>'L',
120024=>'L',
120025=>'L',
120026=>'L',
120027=>'L',
120028=>'L',
120029=>'L',
120030=>'L',
120031=>'L',
120032=>'L',
120033=>'L',
120034=>'L',
120035=>'L',
120036=>'L',
120037=>'L',
120038=>'L',
120039=>'L',
120040=>'L',
120041=>'L',
120042=>'L',
120043=>'L',
120044=>'L',
120045=>'L',
120046=>'L',
120047=>'L',
120048=>'L',
120049=>'L',
120050=>'L',
120051=>'L',
120052=>'L',
120053=>'L',
120054=>'L',
120055=>'L',
120056=>'L',
120057=>'L',
120058=>'L',
120059=>'L',
120060=>'L',
120061=>'L',
120062=>'L',
120063=>'L',
120064=>'L',
120065=>'L',
120066=>'L',
120067=>'L',
120068=>'L',
120069=>'L',
120071=>'L',
120072=>'L',
120073=>'L',
120074=>'L',
120077=>'L',
120078=>'L',
120079=>'L',
120080=>'L',
120081=>'L',
120082=>'L',
120083=>'L',
120084=>'L',
120086=>'L',
120087=>'L',
120088=>'L',
120089=>'L',
120090=>'L',
120091=>'L',
120092=>'L',
120094=>'L',
120095=>'L',
120096=>'L',
120097=>'L',
120098=>'L',
120099=>'L',
120100=>'L',
120101=>'L',
120102=>'L',
120103=>'L',
120104=>'L',
120105=>'L',
120106=>'L',
120107=>'L',
120108=>'L',
120109=>'L',
120110=>'L',
120111=>'L',
120112=>'L',
120113=>'L',
120114=>'L',
120115=>'L',
120116=>'L',
120117=>'L',
120118=>'L',
120119=>'L',
120120=>'L',
120121=>'L',
120123=>'L',
120124=>'L',
120125=>'L',
120126=>'L',
120128=>'L',
120129=>'L',
120130=>'L',
120131=>'L',
120132=>'L',
120134=>'L',
120138=>'L',
120139=>'L',
120140=>'L',
120141=>'L',
120142=>'L',
120143=>'L',
120144=>'L',
120146=>'L',
120147=>'L',
120148=>'L',
120149=>'L',
120150=>'L',
120151=>'L',
120152=>'L',
120153=>'L',
120154=>'L',
120155=>'L',
120156=>'L',
120157=>'L',
120158=>'L',
120159=>'L',
120160=>'L',
120161=>'L',
120162=>'L',
120163=>'L',
120164=>'L',
120165=>'L',
120166=>'L',
120167=>'L',
120168=>'L',
120169=>'L',
120170=>'L',
120171=>'L',
120172=>'L',
120173=>'L',
120174=>'L',
120175=>'L',
120176=>'L',
120177=>'L',
120178=>'L',
120179=>'L',
120180=>'L',
120181=>'L',
120182=>'L',
120183=>'L',
120184=>'L',
120185=>'L',
120186=>'L',
120187=>'L',
120188=>'L',
120189=>'L',
120190=>'L',
120191=>'L',
120192=>'L',
120193=>'L',
120194=>'L',
120195=>'L',
120196=>'L',
120197=>'L',
120198=>'L',
120199=>'L',
120200=>'L',
120201=>'L',
120202=>'L',
120203=>'L',
120204=>'L',
120205=>'L',
120206=>'L',
120207=>'L',
120208=>'L',
120209=>'L',
120210=>'L',
120211=>'L',
120212=>'L',
120213=>'L',
120214=>'L',
120215=>'L',
120216=>'L',
120217=>'L',
120218=>'L',
120219=>'L',
120220=>'L',
120221=>'L',
120222=>'L',
120223=>'L',
120224=>'L',
120225=>'L',
120226=>'L',
120227=>'L',
120228=>'L',
120229=>'L',
120230=>'L',
120231=>'L',
120232=>'L',
120233=>'L',
120234=>'L',
120235=>'L',
120236=>'L',
120237=>'L',
120238=>'L',
120239=>'L',
120240=>'L',
120241=>'L',
120242=>'L',
120243=>'L',
120244=>'L',
120245=>'L',
120246=>'L',
120247=>'L',
120248=>'L',
120249=>'L',
120250=>'L',
120251=>'L',
120252=>'L',
120253=>'L',
120254=>'L',
120255=>'L',
120256=>'L',
120257=>'L',
120258=>'L',
120259=>'L',
120260=>'L',
120261=>'L',
120262=>'L',
120263=>'L',
120264=>'L',
120265=>'L',
120266=>'L',
120267=>'L',
120268=>'L',
120269=>'L',
120270=>'L',
120271=>'L',
120272=>'L',
120273=>'L',
120274=>'L',
120275=>'L',
120276=>'L',
120277=>'L',
120278=>'L',
120279=>'L',
120280=>'L',
120281=>'L',
120282=>'L',
120283=>'L',
120284=>'L',
120285=>'L',
120286=>'L',
120287=>'L',
120288=>'L',
120289=>'L',
120290=>'L',
120291=>'L',
120292=>'L',
120293=>'L',
120294=>'L',
120295=>'L',
120296=>'L',
120297=>'L',
120298=>'L',
120299=>'L',
120300=>'L',
120301=>'L',
120302=>'L',
120303=>'L',
120304=>'L',
120305=>'L',
120306=>'L',
120307=>'L',
120308=>'L',
120309=>'L',
120310=>'L',
120311=>'L',
120312=>'L',
120313=>'L',
120314=>'L',
120315=>'L',
120316=>'L',
120317=>'L',
120318=>'L',
120319=>'L',
120320=>'L',
120321=>'L',
120322=>'L',
120323=>'L',
120324=>'L',
120325=>'L',
120326=>'L',
120327=>'L',
120328=>'L',
120329=>'L',
120330=>'L',
120331=>'L',
120332=>'L',
120333=>'L',
120334=>'L',
120335=>'L',
120336=>'L',
120337=>'L',
120338=>'L',
120339=>'L',
120340=>'L',
120341=>'L',
120342=>'L',
120343=>'L',
120344=>'L',
120345=>'L',
120346=>'L',
120347=>'L',
120348=>'L',
120349=>'L',
120350=>'L',
120351=>'L',
120352=>'L',
120353=>'L',
120354=>'L',
120355=>'L',
120356=>'L',
120357=>'L',
120358=>'L',
120359=>'L',
120360=>'L',
120361=>'L',
120362=>'L',
120363=>'L',
120364=>'L',
120365=>'L',
120366=>'L',
120367=>'L',
120368=>'L',
120369=>'L',
120370=>'L',
120371=>'L',
120372=>'L',
120373=>'L',
120374=>'L',
120375=>'L',
120376=>'L',
120377=>'L',
120378=>'L',
120379=>'L',
120380=>'L',
120381=>'L',
120382=>'L',
120383=>'L',
120384=>'L',
120385=>'L',
120386=>'L',
120387=>'L',
120388=>'L',
120389=>'L',
120390=>'L',
120391=>'L',
120392=>'L',
120393=>'L',
120394=>'L',
120395=>'L',
120396=>'L',
120397=>'L',
120398=>'L',
120399=>'L',
120400=>'L',
120401=>'L',
120402=>'L',
120403=>'L',
120404=>'L',
120405=>'L',
120406=>'L',
120407=>'L',
120408=>'L',
120409=>'L',
120410=>'L',
120411=>'L',
120412=>'L',
120413=>'L',
120414=>'L',
120415=>'L',
120416=>'L',
120417=>'L',
120418=>'L',
120419=>'L',
120420=>'L',
120421=>'L',
120422=>'L',
120423=>'L',
120424=>'L',
120425=>'L',
120426=>'L',
120427=>'L',
120428=>'L',
120429=>'L',
120430=>'L',
120431=>'L',
120432=>'L',
120433=>'L',
120434=>'L',
120435=>'L',
120436=>'L',
120437=>'L',
120438=>'L',
120439=>'L',
120440=>'L',
120441=>'L',
120442=>'L',
120443=>'L',
120444=>'L',
120445=>'L',
120446=>'L',
120447=>'L',
120448=>'L',
120449=>'L',
120450=>'L',
120451=>'L',
120452=>'L',
120453=>'L',
120454=>'L',
120455=>'L',
120456=>'L',
120457=>'L',
120458=>'L',
120459=>'L',
120460=>'L',
120461=>'L',
120462=>'L',
120463=>'L',
120464=>'L',
120465=>'L',
120466=>'L',
120467=>'L',
120468=>'L',
120469=>'L',
120470=>'L',
120471=>'L',
120472=>'L',
120473=>'L',
120474=>'L',
120475=>'L',
120476=>'L',
120477=>'L',
120478=>'L',
120479=>'L',
120480=>'L',
120481=>'L',
120482=>'L',
120483=>'L',
120484=>'L',
120485=>'L',
120488=>'L',
120489=>'L',
120490=>'L',
120491=>'L',
120492=>'L',
120493=>'L',
120494=>'L',
120495=>'L',
120496=>'L',
120497=>'L',
120498=>'L',
120499=>'L',
120500=>'L',
120501=>'L',
120502=>'L',
120503=>'L',
120504=>'L',
120505=>'L',
120506=>'L',
120507=>'L',
120508=>'L',
120509=>'L',
120510=>'L',
120511=>'L',
120512=>'L',
120513=>'L',
120514=>'L',
120515=>'L',
120516=>'L',
120517=>'L',
120518=>'L',
120519=>'L',
120520=>'L',
120521=>'L',
120522=>'L',
120523=>'L',
120524=>'L',
120525=>'L',
120526=>'L',
120527=>'L',
120528=>'L',
120529=>'L',
120530=>'L',
120531=>'L',
120532=>'L',
120533=>'L',
120534=>'L',
120535=>'L',
120536=>'L',
120537=>'L',
120538=>'L',
120539=>'L',
120540=>'L',
120541=>'L',
120542=>'L',
120543=>'L',
120544=>'L',
120545=>'L',
120546=>'L',
120547=>'L',
120548=>'L',
120549=>'L',
120550=>'L',
120551=>'L',
120552=>'L',
120553=>'L',
120554=>'L',
120555=>'L',
120556=>'L',
120557=>'L',
120558=>'L',
120559=>'L',
120560=>'L',
120561=>'L',
120562=>'L',
120563=>'L',
120564=>'L',
120565=>'L',
120566=>'L',
120567=>'L',
120568=>'L',
120569=>'L',
120570=>'L',
120571=>'L',
120572=>'L',
120573=>'L',
120574=>'L',
120575=>'L',
120576=>'L',
120577=>'L',
120578=>'L',
120579=>'L',
120580=>'L',
120581=>'L',
120582=>'L',
120583=>'L',
120584=>'L',
120585=>'L',
120586=>'L',
120587=>'L',
120588=>'L',
120589=>'L',
120590=>'L',
120591=>'L',
120592=>'L',
120593=>'L',
120594=>'L',
120595=>'L',
120596=>'L',
120597=>'L',
120598=>'L',
120599=>'L',
120600=>'L',
120601=>'L',
120602=>'L',
120603=>'L',
120604=>'L',
120605=>'L',
120606=>'L',
120607=>'L',
120608=>'L',
120609=>'L',
120610=>'L',
120611=>'L',
120612=>'L',
120613=>'L',
120614=>'L',
120615=>'L',
120616=>'L',
120617=>'L',
120618=>'L',
120619=>'L',
120620=>'L',
120621=>'L',
120622=>'L',
120623=>'L',
120624=>'L',
120625=>'L',
120626=>'L',
120627=>'L',
120628=>'L',
120629=>'L',
120630=>'L',
120631=>'L',
120632=>'L',
120633=>'L',
120634=>'L',
120635=>'L',
120636=>'L',
120637=>'L',
120638=>'L',
120639=>'L',
120640=>'L',
120641=>'L',
120642=>'L',
120643=>'L',
120644=>'L',
120645=>'L',
120646=>'L',
120647=>'L',
120648=>'L',
120649=>'L',
120650=>'L',
120651=>'L',
120652=>'L',
120653=>'L',
120654=>'L',
120655=>'L',
120656=>'L',
120657=>'L',
120658=>'L',
120659=>'L',
120660=>'L',
120661=>'L',
120662=>'L',
120663=>'L',
120664=>'L',
120665=>'L',
120666=>'L',
120667=>'L',
120668=>'L',
120669=>'L',
120670=>'L',
120671=>'L',
120672=>'L',
120673=>'L',
120674=>'L',
120675=>'L',
120676=>'L',
120677=>'L',
120678=>'L',
120679=>'L',
120680=>'L',
120681=>'L',
120682=>'L',
120683=>'L',
120684=>'L',
120685=>'L',
120686=>'L',
120687=>'L',
120688=>'L',
120689=>'L',
120690=>'L',
120691=>'L',
120692=>'L',
120693=>'L',
120694=>'L',
120695=>'L',
120696=>'L',
120697=>'L',
120698=>'L',
120699=>'L',
120700=>'L',
120701=>'L',
120702=>'L',
120703=>'L',
120704=>'L',
120705=>'L',
120706=>'L',
120707=>'L',
120708=>'L',
120709=>'L',
120710=>'L',
120711=>'L',
120712=>'L',
120713=>'L',
120714=>'L',
120715=>'L',
120716=>'L',
120717=>'L',
120718=>'L',
120719=>'L',
120720=>'L',
120721=>'L',
120722=>'L',
120723=>'L',
120724=>'L',
120725=>'L',
120726=>'L',
120727=>'L',
120728=>'L',
120729=>'L',
120730=>'L',
120731=>'L',
120732=>'L',
120733=>'L',
120734=>'L',
120735=>'L',
120736=>'L',
120737=>'L',
120738=>'L',
120739=>'L',
120740=>'L',
120741=>'L',
120742=>'L',
120743=>'L',
120744=>'L',
120745=>'L',
120746=>'L',
120747=>'L',
120748=>'L',
120749=>'L',
120750=>'L',
120751=>'L',
120752=>'L',
120753=>'L',
120754=>'L',
120755=>'L',
120756=>'L',
120757=>'L',
120758=>'L',
120759=>'L',
120760=>'L',
120761=>'L',
120762=>'L',
120763=>'L',
120764=>'L',
120765=>'L',
120766=>'L',
120767=>'L',
120768=>'L',
120769=>'L',
120770=>'L',
120771=>'L',
120772=>'L',
120773=>'L',
120774=>'L',
120775=>'L',
120776=>'L',
120777=>'L',
120778=>'L',
120779=>'L',
120782=>'EN',
120783=>'EN',
120784=>'EN',
120785=>'EN',
120786=>'EN',
120787=>'EN',
120788=>'EN',
120789=>'EN',
120790=>'EN',
120791=>'EN',
120792=>'EN',
120793=>'EN',
120794=>'EN',
120795=>'EN',
120796=>'EN',
120797=>'EN',
120798=>'EN',
120799=>'EN',
120800=>'EN',
120801=>'EN',
120802=>'EN',
120803=>'EN',
120804=>'EN',
120805=>'EN',
120806=>'EN',
120807=>'EN',
120808=>'EN',
120809=>'EN',
120810=>'EN',
120811=>'EN',
120812=>'EN',
120813=>'EN',
120814=>'EN',
120815=>'EN',
120816=>'EN',
120817=>'EN',
120818=>'EN',
120819=>'EN',
120820=>'EN',
120821=>'EN',
120822=>'EN',
120823=>'EN',
120824=>'EN',
120825=>'EN',
120826=>'EN',
120827=>'EN',
120828=>'EN',
120829=>'EN',
120830=>'EN',
120831=>'EN',
131072=>'L',
173782=>'L',
194560=>'L',
194561=>'L',
194562=>'L',
194563=>'L',
194564=>'L',
194565=>'L',
194566=>'L',
194567=>'L',
194568=>'L',
194569=>'L',
194570=>'L',
194571=>'L',
194572=>'L',
194573=>'L',
194574=>'L',
194575=>'L',
194576=>'L',
194577=>'L',
194578=>'L',
194579=>'L',
194580=>'L',
194581=>'L',
194582=>'L',
194583=>'L',
194584=>'L',
194585=>'L',
194586=>'L',
194587=>'L',
194588=>'L',
194589=>'L',
194590=>'L',
194591=>'L',
194592=>'L',
194593=>'L',
194594=>'L',
194595=>'L',
194596=>'L',
194597=>'L',
194598=>'L',
194599=>'L',
194600=>'L',
194601=>'L',
194602=>'L',
194603=>'L',
194604=>'L',
194605=>'L',
194606=>'L',
194607=>'L',
194608=>'L',
194609=>'L',
194610=>'L',
194611=>'L',
194612=>'L',
194613=>'L',
194614=>'L',
194615=>'L',
194616=>'L',
194617=>'L',
194618=>'L',
194619=>'L',
194620=>'L',
194621=>'L',
194622=>'L',
194623=>'L',
194624=>'L',
194625=>'L',
194626=>'L',
194627=>'L',
194628=>'L',
194629=>'L',
194630=>'L',
194631=>'L',
194632=>'L',
194633=>'L',
194634=>'L',
194635=>'L',
194636=>'L',
194637=>'L',
194638=>'L',
194639=>'L',
194640=>'L',
194641=>'L',
194642=>'L',
194643=>'L',
194644=>'L',
194645=>'L',
194646=>'L',
194647=>'L',
194648=>'L',
194649=>'L',
194650=>'L',
194651=>'L',
194652=>'L',
194653=>'L',
194654=>'L',
194655=>'L',
194656=>'L',
194657=>'L',
194658=>'L',
194659=>'L',
194660=>'L',
194661=>'L',
194662=>'L',
194663=>'L',
194664=>'L',
194665=>'L',
194666=>'L',
194667=>'L',
194668=>'L',
194669=>'L',
194670=>'L',
194671=>'L',
194672=>'L',
194673=>'L',
194674=>'L',
194675=>'L',
194676=>'L',
194677=>'L',
194678=>'L',
194679=>'L',
194680=>'L',
194681=>'L',
194682=>'L',
194683=>'L',
194684=>'L',
194685=>'L',
194686=>'L',
194687=>'L',
194688=>'L',
194689=>'L',
194690=>'L',
194691=>'L',
194692=>'L',
194693=>'L',
194694=>'L',
194695=>'L',
194696=>'L',
194697=>'L',
194698=>'L',
194699=>'L',
194700=>'L',
194701=>'L',
194702=>'L',
194703=>'L',
194704=>'L',
194705=>'L',
194706=>'L',
194707=>'L',
194708=>'L',
194709=>'L',
194710=>'L',
194711=>'L',
194712=>'L',
194713=>'L',
194714=>'L',
194715=>'L',
194716=>'L',
194717=>'L',
194718=>'L',
194719=>'L',
194720=>'L',
194721=>'L',
194722=>'L',
194723=>'L',
194724=>'L',
194725=>'L',
194726=>'L',
194727=>'L',
194728=>'L',
194729=>'L',
194730=>'L',
194731=>'L',
194732=>'L',
194733=>'L',
194734=>'L',
194735=>'L',
194736=>'L',
194737=>'L',
194738=>'L',
194739=>'L',
194740=>'L',
194741=>'L',
194742=>'L',
194743=>'L',
194744=>'L',
194745=>'L',
194746=>'L',
194747=>'L',
194748=>'L',
194749=>'L',
194750=>'L',
194751=>'L',
194752=>'L',
194753=>'L',
194754=>'L',
194755=>'L',
194756=>'L',
194757=>'L',
194758=>'L',
194759=>'L',
194760=>'L',
194761=>'L',
194762=>'L',
194763=>'L',
194764=>'L',
194765=>'L',
194766=>'L',
194767=>'L',
194768=>'L',
194769=>'L',
194770=>'L',
194771=>'L',
194772=>'L',
194773=>'L',
194774=>'L',
194775=>'L',
194776=>'L',
194777=>'L',
194778=>'L',
194779=>'L',
194780=>'L',
194781=>'L',
194782=>'L',
194783=>'L',
194784=>'L',
194785=>'L',
194786=>'L',
194787=>'L',
194788=>'L',
194789=>'L',
194790=>'L',
194791=>'L',
194792=>'L',
194793=>'L',
194794=>'L',
194795=>'L',
194796=>'L',
194797=>'L',
194798=>'L',
194799=>'L',
194800=>'L',
194801=>'L',
194802=>'L',
194803=>'L',
194804=>'L',
194805=>'L',
194806=>'L',
194807=>'L',
194808=>'L',
194809=>'L',
194810=>'L',
194811=>'L',
194812=>'L',
194813=>'L',
194814=>'L',
194815=>'L',
194816=>'L',
194817=>'L',
194818=>'L',
194819=>'L',
194820=>'L',
194821=>'L',
194822=>'L',
194823=>'L',
194824=>'L',
194825=>'L',
194826=>'L',
194827=>'L',
194828=>'L',
194829=>'L',
194830=>'L',
194831=>'L',
194832=>'L',
194833=>'L',
194834=>'L',
194835=>'L',
194836=>'L',
194837=>'L',
194838=>'L',
194839=>'L',
194840=>'L',
194841=>'L',
194842=>'L',
194843=>'L',
194844=>'L',
194845=>'L',
194846=>'L',
194847=>'L',
194848=>'L',
194849=>'L',
194850=>'L',
194851=>'L',
194852=>'L',
194853=>'L',
194854=>'L',
194855=>'L',
194856=>'L',
194857=>'L',
194858=>'L',
194859=>'L',
194860=>'L',
194861=>'L',
194862=>'L',
194863=>'L',
194864=>'L',
194865=>'L',
194866=>'L',
194867=>'L',
194868=>'L',
194869=>'L',
194870=>'L',
194871=>'L',
194872=>'L',
194873=>'L',
194874=>'L',
194875=>'L',
194876=>'L',
194877=>'L',
194878=>'L',
194879=>'L',
194880=>'L',
194881=>'L',
194882=>'L',
194883=>'L',
194884=>'L',
194885=>'L',
194886=>'L',
194887=>'L',
194888=>'L',
194889=>'L',
194890=>'L',
194891=>'L',
194892=>'L',
194893=>'L',
194894=>'L',
194895=>'L',
194896=>'L',
194897=>'L',
194898=>'L',
194899=>'L',
194900=>'L',
194901=>'L',
194902=>'L',
194903=>'L',
194904=>'L',
194905=>'L',
194906=>'L',
194907=>'L',
194908=>'L',
194909=>'L',
194910=>'L',
194911=>'L',
194912=>'L',
194913=>'L',
194914=>'L',
194915=>'L',
194916=>'L',
194917=>'L',
194918=>'L',
194919=>'L',
194920=>'L',
194921=>'L',
194922=>'L',
194923=>'L',
194924=>'L',
194925=>'L',
194926=>'L',
194927=>'L',
194928=>'L',
194929=>'L',
194930=>'L',
194931=>'L',
194932=>'L',
194933=>'L',
194934=>'L',
194935=>'L',
194936=>'L',
194937=>'L',
194938=>'L',
194939=>'L',
194940=>'L',
194941=>'L',
194942=>'L',
194943=>'L',
194944=>'L',
194945=>'L',
194946=>'L',
194947=>'L',
194948=>'L',
194949=>'L',
194950=>'L',
194951=>'L',
194952=>'L',
194953=>'L',
194954=>'L',
194955=>'L',
194956=>'L',
194957=>'L',
194958=>'L',
194959=>'L',
194960=>'L',
194961=>'L',
194962=>'L',
194963=>'L',
194964=>'L',
194965=>'L',
194966=>'L',
194967=>'L',
194968=>'L',
194969=>'L',
194970=>'L',
194971=>'L',
194972=>'L',
194973=>'L',
194974=>'L',
194975=>'L',
194976=>'L',
194977=>'L',
194978=>'L',
194979=>'L',
194980=>'L',
194981=>'L',
194982=>'L',
194983=>'L',
194984=>'L',
194985=>'L',
194986=>'L',
194987=>'L',
194988=>'L',
194989=>'L',
194990=>'L',
194991=>'L',
194992=>'L',
194993=>'L',
194994=>'L',
194995=>'L',
194996=>'L',
194997=>'L',
194998=>'L',
194999=>'L',
195000=>'L',
195001=>'L',
195002=>'L',
195003=>'L',
195004=>'L',
195005=>'L',
195006=>'L',
195007=>'L',
195008=>'L',
195009=>'L',
195010=>'L',
195011=>'L',
195012=>'L',
195013=>'L',
195014=>'L',
195015=>'L',
195016=>'L',
195017=>'L',
195018=>'L',
195019=>'L',
195020=>'L',
195021=>'L',
195022=>'L',
195023=>'L',
195024=>'L',
195025=>'L',
195026=>'L',
195027=>'L',
195028=>'L',
195029=>'L',
195030=>'L',
195031=>'L',
195032=>'L',
195033=>'L',
195034=>'L',
195035=>'L',
195036=>'L',
195037=>'L',
195038=>'L',
195039=>'L',
195040=>'L',
195041=>'L',
195042=>'L',
195043=>'L',
195044=>'L',
195045=>'L',
195046=>'L',
195047=>'L',
195048=>'L',
195049=>'L',
195050=>'L',
195051=>'L',
195052=>'L',
195053=>'L',
195054=>'L',
195055=>'L',
195056=>'L',
195057=>'L',
195058=>'L',
195059=>'L',
195060=>'L',
195061=>'L',
195062=>'L',
195063=>'L',
195064=>'L',
195065=>'L',
195066=>'L',
195067=>'L',
195068=>'L',
195069=>'L',
195070=>'L',
195071=>'L',
195072=>'L',
195073=>'L',
195074=>'L',
195075=>'L',
195076=>'L',
195077=>'L',
195078=>'L',
195079=>'L',
195080=>'L',
195081=>'L',
195082=>'L',
195083=>'L',
195084=>'L',
195085=>'L',
195086=>'L',
195087=>'L',
195088=>'L',
195089=>'L',
195090=>'L',
195091=>'L',
195092=>'L',
195093=>'L',
195094=>'L',
195095=>'L',
195096=>'L',
195097=>'L',
195098=>'L',
195099=>'L',
195100=>'L',
195101=>'L',
917505=>'BN',
917536=>'BN',
917537=>'BN',
917538=>'BN',
917539=>'BN',
917540=>'BN',
917541=>'BN',
917542=>'BN',
917543=>'BN',
917544=>'BN',
917545=>'BN',
917546=>'BN',
917547=>'BN',
917548=>'BN',
917549=>'BN',
917550=>'BN',
917551=>'BN',
917552=>'BN',
917553=>'BN',
917554=>'BN',
917555=>'BN',
917556=>'BN',
917557=>'BN',
917558=>'BN',
917559=>'BN',
917560=>'BN',
917561=>'BN',
917562=>'BN',
917563=>'BN',
917564=>'BN',
917565=>'BN',
917566=>'BN',
917567=>'BN',
917568=>'BN',
917569=>'BN',
917570=>'BN',
917571=>'BN',
917572=>'BN',
917573=>'BN',
917574=>'BN',
917575=>'BN',
917576=>'BN',
917577=>'BN',
917578=>'BN',
917579=>'BN',
917580=>'BN',
917581=>'BN',
917582=>'BN',
917583=>'BN',
917584=>'BN',
917585=>'BN',
917586=>'BN',
917587=>'BN',
917588=>'BN',
917589=>'BN',
917590=>'BN',
917591=>'BN',
917592=>'BN',
917593=>'BN',
917594=>'BN',
917595=>'BN',
917596=>'BN',
917597=>'BN',
917598=>'BN',
917599=>'BN',
917600=>'BN',
917601=>'BN',
917602=>'BN',
917603=>'BN',
917604=>'BN',
917605=>'BN',
917606=>'BN',
917607=>'BN',
917608=>'BN',
917609=>'BN',
917610=>'BN',
917611=>'BN',
917612=>'BN',
917613=>'BN',
917614=>'BN',
917615=>'BN',
917616=>'BN',
917617=>'BN',
917618=>'BN',
917619=>'BN',
917620=>'BN',
917621=>'BN',
917622=>'BN',
917623=>'BN',
917624=>'BN',
917625=>'BN',
917626=>'BN',
917627=>'BN',
917628=>'BN',
917629=>'BN',
917630=>'BN',
917631=>'BN',
917760=>'NSM',
917761=>'NSM',
917762=>'NSM',
917763=>'NSM',
917764=>'NSM',
917765=>'NSM',
917766=>'NSM',
917767=>'NSM',
917768=>'NSM',
917769=>'NSM',
917770=>'NSM',
917771=>'NSM',
917772=>'NSM',
917773=>'NSM',
917774=>'NSM',
917775=>'NSM',
917776=>'NSM',
917777=>'NSM',
917778=>'NSM',
917779=>'NSM',
917780=>'NSM',
917781=>'NSM',
917782=>'NSM',
917783=>'NSM',
917784=>'NSM',
917785=>'NSM',
917786=>'NSM',
917787=>'NSM',
917788=>'NSM',
917789=>'NSM',
917790=>'NSM',
917791=>'NSM',
917792=>'NSM',
917793=>'NSM',
917794=>'NSM',
917795=>'NSM',
917796=>'NSM',
917797=>'NSM',
917798=>'NSM',
917799=>'NSM',
917800=>'NSM',
917801=>'NSM',
917802=>'NSM',
917803=>'NSM',
917804=>'NSM',
917805=>'NSM',
917806=>'NSM',
917807=>'NSM',
917808=>'NSM',
917809=>'NSM',
917810=>'NSM',
917811=>'NSM',
917812=>'NSM',
917813=>'NSM',
917814=>'NSM',
917815=>'NSM',
917816=>'NSM',
917817=>'NSM',
917818=>'NSM',
917819=>'NSM',
917820=>'NSM',
917821=>'NSM',
917822=>'NSM',
917823=>'NSM',
917824=>'NSM',
917825=>'NSM',
917826=>'NSM',
917827=>'NSM',
917828=>'NSM',
917829=>'NSM',
917830=>'NSM',
917831=>'NSM',
917832=>'NSM',
917833=>'NSM',
917834=>'NSM',
917835=>'NSM',
917836=>'NSM',
917837=>'NSM',
917838=>'NSM',
917839=>'NSM',
917840=>'NSM',
917841=>'NSM',
917842=>'NSM',
917843=>'NSM',
917844=>'NSM',
917845=>'NSM',
917846=>'NSM',
917847=>'NSM',
917848=>'NSM',
917849=>'NSM',
917850=>'NSM',
917851=>'NSM',
917852=>'NSM',
917853=>'NSM',
917854=>'NSM',
917855=>'NSM',
917856=>'NSM',
917857=>'NSM',
917858=>'NSM',
917859=>'NSM',
917860=>'NSM',
917861=>'NSM',
917862=>'NSM',
917863=>'NSM',
917864=>'NSM',
917865=>'NSM',
917866=>'NSM',
917867=>'NSM',
917868=>'NSM',
917869=>'NSM',
917870=>'NSM',
917871=>'NSM',
917872=>'NSM',
917873=>'NSM',
917874=>'NSM',
917875=>'NSM',
917876=>'NSM',
917877=>'NSM',
917878=>'NSM',
917879=>'NSM',
917880=>'NSM',
917881=>'NSM',
917882=>'NSM',
917883=>'NSM',
917884=>'NSM',
917885=>'NSM',
917886=>'NSM',
917887=>'NSM',
917888=>'NSM',
917889=>'NSM',
917890=>'NSM',
917891=>'NSM',
917892=>'NSM',
917893=>'NSM',
917894=>'NSM',
917895=>'NSM',
917896=>'NSM',
917897=>'NSM',
917898=>'NSM',
917899=>'NSM',
917900=>'NSM',
917901=>'NSM',
917902=>'NSM',
917903=>'NSM',
917904=>'NSM',
917905=>'NSM',
917906=>'NSM',
917907=>'NSM',
917908=>'NSM',
917909=>'NSM',
917910=>'NSM',
917911=>'NSM',
917912=>'NSM',
917913=>'NSM',
917914=>'NSM',
917915=>'NSM',
917916=>'NSM',
917917=>'NSM',
917918=>'NSM',
917919=>'NSM',
917920=>'NSM',
917921=>'NSM',
917922=>'NSM',
917923=>'NSM',
917924=>'NSM',
917925=>'NSM',
917926=>'NSM',
917927=>'NSM',
917928=>'NSM',
917929=>'NSM',
917930=>'NSM',
917931=>'NSM',
917932=>'NSM',
917933=>'NSM',
917934=>'NSM',
917935=>'NSM',
917936=>'NSM',
917937=>'NSM',
917938=>'NSM',
917939=>'NSM',
917940=>'NSM',
917941=>'NSM',
917942=>'NSM',
917943=>'NSM',
917944=>'NSM',
917945=>'NSM',
917946=>'NSM',
917947=>'NSM',
917948=>'NSM',
917949=>'NSM',
917950=>'NSM',
917951=>'NSM',
917952=>'NSM',
917953=>'NSM',
917954=>'NSM',
917955=>'NSM',
917956=>'NSM',
917957=>'NSM',
917958=>'NSM',
917959=>'NSM',
917960=>'NSM',
917961=>'NSM',
917962=>'NSM',
917963=>'NSM',
917964=>'NSM',
917965=>'NSM',
917966=>'NSM',
917967=>'NSM',
917968=>'NSM',
917969=>'NSM',
917970=>'NSM',
917971=>'NSM',
917972=>'NSM',
917973=>'NSM',
917974=>'NSM',
917975=>'NSM',
917976=>'NSM',
917977=>'NSM',
917978=>'NSM',
917979=>'NSM',
917980=>'NSM',
917981=>'NSM',
917982=>'NSM',
917983=>'NSM',
917984=>'NSM',
917985=>'NSM',
917986=>'NSM',
917987=>'NSM',
917988=>'NSM',
917989=>'NSM',
917990=>'NSM',
917991=>'NSM',
917992=>'NSM',
917993=>'NSM',
917994=>'NSM',
917995=>'NSM',
917996=>'NSM',
917997=>'NSM',
917998=>'NSM',
917999=>'NSM',
983040=>'L',
1048573=>'L',
1048576=>'L',
1114109=>'L'
);
/**
* @var Mirror unicode characters.
* For information on bidi mirroring, see UAX #9: Bidirectional Algorithm,
* at http://www.unicode.org/unicode/reports/tr9/
* @access public
*/
public $uni_mirror = array (
0x0028=>0x0029,
0x0029=>0x0028,
0x003C=>0x003E,
0x003E=>0x003C,
0x005B=>0x005D,
0x005D=>0x005B,
0x007B=>0x007D,
0x007D=>0x007B,
0x00AB=>0x00BB,
0x00BB=>0x00AB,
0x0F3A=>0x0F3B,
0x0F3B=>0x0F3A,
0x0F3C=>0x0F3D,
0x0F3D=>0x0F3C,
0x169B=>0x169C,
0x169C=>0x169B,
0x2018=>0x2019,
0x2019=>0x2018,
0x201C=>0x201D,
0x201D=>0x201C,
0x2039=>0x203A,
0x203A=>0x2039,
0x2045=>0x2046,
0x2046=>0x2045,
0x207D=>0x207E,
0x207E=>0x207D,
0x208D=>0x208E,
0x208E=>0x208D,
0x2208=>0x220B,
0x2209=>0x220C,
0x220A=>0x220D,
0x220B=>0x2208,
0x220C=>0x2209,
0x220D=>0x220A,
0x2215=>0x29F5,
0x223C=>0x223D,
0x223D=>0x223C,
0x2243=>0x22CD,
0x2252=>0x2253,
0x2253=>0x2252,
0x2254=>0x2255,
0x2255=>0x2254,
0x2264=>0x2265,
0x2265=>0x2264,
0x2266=>0x2267,
0x2267=>0x2266,
0x2268=>0x2269,
0x2269=>0x2268,
0x226A=>0x226B,
0x226B=>0x226A,
0x226E=>0x226F,
0x226F=>0x226E,
0x2270=>0x2271,
0x2271=>0x2270,
0x2272=>0x2273,
0x2273=>0x2272,
0x2274=>0x2275,
0x2275=>0x2274,
0x2276=>0x2277,
0x2277=>0x2276,
0x2278=>0x2279,
0x2279=>0x2278,
0x227A=>0x227B,
0x227B=>0x227A,
0x227C=>0x227D,
0x227D=>0x227C,
0x227E=>0x227F,
0x227F=>0x227E,
0x2280=>0x2281,
0x2281=>0x2280,
0x2282=>0x2283,
0x2283=>0x2282,
0x2284=>0x2285,
0x2285=>0x2284,
0x2286=>0x2287,
0x2287=>0x2286,
0x2288=>0x2289,
0x2289=>0x2288,
0x228A=>0x228B,
0x228B=>0x228A,
0x228F=>0x2290,
0x2290=>0x228F,
0x2291=>0x2292,
0x2292=>0x2291,
0x2298=>0x29B8,
0x22A2=>0x22A3,
0x22A3=>0x22A2,
0x22A6=>0x2ADE,
0x22A8=>0x2AE4,
0x22A9=>0x2AE3,
0x22AB=>0x2AE5,
0x22B0=>0x22B1,
0x22B1=>0x22B0,
0x22B2=>0x22B3,
0x22B3=>0x22B2,
0x22B4=>0x22B5,
0x22B5=>0x22B4,
0x22B6=>0x22B7,
0x22B7=>0x22B6,
0x22C9=>0x22CA,
0x22CA=>0x22C9,
0x22CB=>0x22CC,
0x22CC=>0x22CB,
0x22CD=>0x2243,
0x22D0=>0x22D1,
0x22D1=>0x22D0,
0x22D6=>0x22D7,
0x22D7=>0x22D6,
0x22D8=>0x22D9,
0x22D9=>0x22D8,
0x22DA=>0x22DB,
0x22DB=>0x22DA,
0x22DC=>0x22DD,
0x22DD=>0x22DC,
0x22DE=>0x22DF,
0x22DF=>0x22DE,
0x22E0=>0x22E1,
0x22E1=>0x22E0,
0x22E2=>0x22E3,
0x22E3=>0x22E2,
0x22E4=>0x22E5,
0x22E5=>0x22E4,
0x22E6=>0x22E7,
0x22E7=>0x22E6,
0x22E8=>0x22E9,
0x22E9=>0x22E8,
0x22EA=>0x22EB,
0x22EB=>0x22EA,
0x22EC=>0x22ED,
0x22ED=>0x22EC,
0x22F0=>0x22F1,
0x22F1=>0x22F0,
0x22F2=>0x22FA,
0x22F3=>0x22FB,
0x22F4=>0x22FC,
0x22F6=>0x22FD,
0x22F7=>0x22FE,
0x22FA=>0x22F2,
0x22FB=>0x22F3,
0x22FC=>0x22F4,
0x22FD=>0x22F6,
0x22FE=>0x22F7,
0x2308=>0x2309,
0x2309=>0x2308,
0x230A=>0x230B,
0x230B=>0x230A,
0x2329=>0x232A,
0x232A=>0x2329,
0x2768=>0x2769,
0x2769=>0x2768,
0x276A=>0x276B,
0x276B=>0x276A,
0x276C=>0x276D,
0x276D=>0x276C,
0x276E=>0x276F,
0x276F=>0x276E,
0x2770=>0x2771,
0x2771=>0x2770,
0x2772=>0x2773,
0x2773=>0x2772,
0x2774=>0x2775,
0x2775=>0x2774,
0x27C3=>0x27C4,
0x27C4=>0x27C3,
0x27C5=>0x27C6,
0x27C6=>0x27C5,
0x27D5=>0x27D6,
0x27D6=>0x27D5,
0x27DD=>0x27DE,
0x27DE=>0x27DD,
0x27E2=>0x27E3,
0x27E3=>0x27E2,
0x27E4=>0x27E5,
0x27E5=>0x27E4,
0x27E6=>0x27E7,
0x27E7=>0x27E6,
0x27E8=>0x27E9,
0x27E9=>0x27E8,
0x27EA=>0x27EB,
0x27EB=>0x27EA,
0x2983=>0x2984,
0x2984=>0x2983,
0x2985=>0x2986,
0x2986=>0x2985,
0x2987=>0x2988,
0x2988=>0x2987,
0x2989=>0x298A,
0x298A=>0x2989,
0x298B=>0x298C,
0x298C=>0x298B,
0x298D=>0x2990,
0x298E=>0x298F,
0x298F=>0x298E,
0x2990=>0x298D,
0x2991=>0x2992,
0x2992=>0x2991,
0x2993=>0x2994,
0x2994=>0x2993,
0x2995=>0x2996,
0x2996=>0x2995,
0x2997=>0x2998,
0x2998=>0x2997,
0x29B8=>0x2298,
0x29C0=>0x29C1,
0x29C1=>0x29C0,
0x29C4=>0x29C5,
0x29C5=>0x29C4,
0x29CF=>0x29D0,
0x29D0=>0x29CF,
0x29D1=>0x29D2,
0x29D2=>0x29D1,
0x29D4=>0x29D5,
0x29D5=>0x29D4,
0x29D8=>0x29D9,
0x29D9=>0x29D8,
0x29DA=>0x29DB,
0x29DB=>0x29DA,
0x29F5=>0x2215,
0x29F8=>0x29F9,
0x29F9=>0x29F8,
0x29FC=>0x29FD,
0x29FD=>0x29FC,
0x2A2B=>0x2A2C,
0x2A2C=>0x2A2B,
0x2A2D=>0x2A2E,
0x2A2E=>0x2A2D,
0x2A34=>0x2A35,
0x2A35=>0x2A34,
0x2A3C=>0x2A3D,
0x2A3D=>0x2A3C,
0x2A64=>0x2A65,
0x2A65=>0x2A64,
0x2A79=>0x2A7A,
0x2A7A=>0x2A79,
0x2A7D=>0x2A7E,
0x2A7E=>0x2A7D,
0x2A7F=>0x2A80,
0x2A80=>0x2A7F,
0x2A81=>0x2A82,
0x2A82=>0x2A81,
0x2A83=>0x2A84,
0x2A84=>0x2A83,
0x2A8B=>0x2A8C,
0x2A8C=>0x2A8B,
0x2A91=>0x2A92,
0x2A92=>0x2A91,
0x2A93=>0x2A94,
0x2A94=>0x2A93,
0x2A95=>0x2A96,
0x2A96=>0x2A95,
0x2A97=>0x2A98,
0x2A98=>0x2A97,
0x2A99=>0x2A9A,
0x2A9A=>0x2A99,
0x2A9B=>0x2A9C,
0x2A9C=>0x2A9B,
0x2AA1=>0x2AA2,
0x2AA2=>0x2AA1,
0x2AA6=>0x2AA7,
0x2AA7=>0x2AA6,
0x2AA8=>0x2AA9,
0x2AA9=>0x2AA8,
0x2AAA=>0x2AAB,
0x2AAB=>0x2AAA,
0x2AAC=>0x2AAD,
0x2AAD=>0x2AAC,
0x2AAF=>0x2AB0,
0x2AB0=>0x2AAF,
0x2AB3=>0x2AB4,
0x2AB4=>0x2AB3,
0x2ABB=>0x2ABC,
0x2ABC=>0x2ABB,
0x2ABD=>0x2ABE,
0x2ABE=>0x2ABD,
0x2ABF=>0x2AC0,
0x2AC0=>0x2ABF,
0x2AC1=>0x2AC2,
0x2AC2=>0x2AC1,
0x2AC3=>0x2AC4,
0x2AC4=>0x2AC3,
0x2AC5=>0x2AC6,
0x2AC6=>0x2AC5,
0x2ACD=>0x2ACE,
0x2ACE=>0x2ACD,
0x2ACF=>0x2AD0,
0x2AD0=>0x2ACF,
0x2AD1=>0x2AD2,
0x2AD2=>0x2AD1,
0x2AD3=>0x2AD4,
0x2AD4=>0x2AD3,
0x2AD5=>0x2AD6,
0x2AD6=>0x2AD5,
0x2ADE=>0x22A6,
0x2AE3=>0x22A9,
0x2AE4=>0x22A8,
0x2AE5=>0x22AB,
0x2AEC=>0x2AED,
0x2AED=>0x2AEC,
0x2AF7=>0x2AF8,
0x2AF8=>0x2AF7,
0x2AF9=>0x2AFA,
0x2AFA=>0x2AF9,
0x2E02=>0x2E03,
0x2E03=>0x2E02,
0x2E04=>0x2E05,
0x2E05=>0x2E04,
0x2E09=>0x2E0A,
0x2E0A=>0x2E09,
0x2E0C=>0x2E0D,
0x2E0D=>0x2E0C,
0x2E1C=>0x2E1D,
0x2E1D=>0x2E1C,
0x3008=>0x3009,
0x3009=>0x3008,
0x300A=>0x300B,
0x300B=>0x300A,
0x300C=>0x300D,
0x300D=>0x300C,
0x300E=>0x300F,
0x300F=>0x300E,
0x3010=>0x3011,
0x3011=>0x3010,
0x3014=>0x3015,
0x3015=>0x3014,
0x3016=>0x3017,
0x3017=>0x3016,
0x3018=>0x3019,
0x3019=>0x3018,
0x301A=>0x301B,
0x301B=>0x301A,
0x301D=>0x301E,
0x301E=>0x301D,
0xFE59=>0xFE5A,
0xFE5A=>0xFE59,
0xFE5B=>0xFE5C,
0xFE5C=>0xFE5B,
0xFE5D=>0xFE5E,
0xFE5E=>0xFE5D,
0xFE64=>0xFE65,
0xFE65=>0xFE64,
0xFF08=>0xFF09,
0xFF09=>0xFF08,
0xFF1C=>0xFF1E,
0xFF1E=>0xFF1C,
0xFF3B=>0xFF3D,
0xFF3D=>0xFF3B,
0xFF5B=>0xFF5D,
0xFF5D=>0xFF5B,
0xFF5F=>0xFF60,
0xFF60=>0xFF5F,
0xFF62=>0xFF63,
0xFF63=>0xFF62);
/**
* @var Arabic shape substitutions: char code => (isolated, final, initial, medial)
* @access public
*/
public $uni_arabicsubst = array(
1569=>array(65152),
1570=>array(65153, 65154, 65153, 65154),
1571=>array(65155, 65156, 65155, 65156),
1572=>array(65157, 65158),
1573=>array(65159, 65160, 65159, 65160),
1574=>array(65161, 65162, 65163, 65164),
1575=>array(65165, 65166, 65165, 65166),
1576=>array(65167, 65168, 65169, 65170),
1577=>array(65171, 65172),
1578=>array(65173, 65174, 65175, 65176),
1579=>array(65177, 65178, 65179, 65180),
1580=>array(65181, 65182, 65183, 65184),
1581=>array(65185, 65186, 65187, 65188),
1582=>array(65189, 65190, 65191, 65192),
1583=>array(65193, 65194, 65193, 65194),
1584=>array(65195, 65196, 65195, 65196),
1585=>array(65197, 65198, 65197, 65198),
1586=>array(65199, 65200, 65199, 65200),
1587=>array(65201, 65202, 65203, 65204),
1588=>array(65205, 65206, 65207, 65208),
1589=>array(65209, 65210, 65211, 65212),
1590=>array(65213, 65214, 65215, 65216),
1591=>array(65217, 65218, 65219, 65220),
1592=>array(65221, 65222, 65223, 65224),
1593=>array(65225, 65226, 65227, 65228),
1594=>array(65229, 65230, 65231, 65232),
1601=>array(65233, 65234, 65235, 65236),
1602=>array(65237, 65238, 65239, 65240),
1603=>array(65241, 65242, 65243, 65244),
1604=>array(65245, 65246, 65247, 65248),
1605=>array(65249, 65250, 65251, 65252),
1606=>array(65253, 65254, 65255, 65256),
1607=>array(65257, 65258, 65259, 65260),
1608=>array(65261, 65262, 65261, 65262),
1609=>array(65263, 65264, 64488, 64489),
1610=>array(65265, 65266, 65267, 65268),
1649=>array(64336, 64337),
1655=>array(64477),
1657=>array(64358, 64359, 64360, 64361),
1658=>array(64350, 64351, 64352, 64353),
1659=>array(64338, 64339, 64340, 64341),
1662=>array(64342, 64343, 64344, 64345),
1663=>array(64354, 64355, 64356, 64357),
1664=>array(64346, 64347, 64348, 64349),
1667=>array(64374, 64375, 64376, 64377),
1668=>array(64370, 64371, 64372, 64373),
1670=>array(64378, 64379, 64380, 64381),
1671=>array(64382, 64383, 64384, 64385),
1672=>array(64392, 64393),
1676=>array(64388, 64389),
1677=>array(64386, 64387),
1678=>array(64390, 64391),
1681=>array(64396, 64397),
1688=>array(64394, 64395, 64394, 64395),
1700=>array(64362, 64363, 64364, 64365),
1702=>array(64366, 64367, 64368, 64369),
1705=>array(64398, 64399, 64400, 64401),
1709=>array(64467, 64468, 64469, 64470),
1711=>array(64402, 64403, 64404, 64405),
1713=>array(64410, 64411, 64412, 64413),
1715=>array(64406, 64407, 64408, 64409),
1722=>array(64414, 64415),
1723=>array(64416, 64417, 64418, 64419),
1726=>array(64426, 64427, 64428, 64429),
1728=>array(64420, 64421),
1729=>array(64422, 64423, 64424, 64425),
1733=>array(64480, 64481),
1734=>array(64473, 64474),
1735=>array(64471, 64472),
1736=>array(64475, 64476),
1737=>array(64482, 64483),
1739=>array(64478, 64479),
1740=>array(64508, 64509, 64510, 64511),
1744=>array(64484, 64485, 64486, 64487),
1746=>array(64430, 64431),
1747=>array(64432, 64433)
);
/**
* @var Arabic laa letter: char code => isolated, final, initial, medial
* @access public
*/
public $uni_laa_array = array (
1570 =>array(65269, 65270, 65269, 65270),
1571 =>array(65271, 65272, 65271, 65272),
1573 =>array(65273, 65274, 65273, 65274),
1575 =>array(65275, 65276, 65275, 65276)
);
/**
* @var Array of character substitutions for sequences of two diacritics symbols.
* Putting the combining mark and character in the same glyph allows us to avoid the two marks overlapping each other in an illegible manner.
* second NSM char code => substitution char
* @access public
*/
public $uni_diacritics = array (
1612=>64606, # Shadda + Dammatan
1613=>64607, # Shadda + Kasratan
1614=>64608, # Shadda + Fatha
1615=>64609, # Shadda + Damma
1616=>64610 # Shadda + Kasra
);
/**
* @var Array of character substitutions from UTF-8 Unicode to Latin1
* @access public
*/
public $uni_utf8tolatin = array (
8364=>128, # Euro1
338=>140, # OE
352=>138, # Scaron
376=>159, # Ydieresis
381=>142, # Zcaron2
8226=>149, # bullet3
710=>136, # circumflex
8224=>134, # dagger
8225=>135, # daggerdbl
8230=>133, # ellipsis
8212=>151, # emdash
8211=>150, # endash
402=>131, # florin
8249=>139, # guilsinglleft
8250=>155, # guilsinglright
339=>156, # oe
8240=>137, # perthousand
8222=>132, # quotedblbase
8220=>147, # quotedblleft
8221=>148, # quotedblright
8216=>145, # quoteleft
8217=>146, # quoteright
8218=>130, # quotesinglbase
353=>154, # scaron
732=>152, # tilde
8482=>153, # trademark
382=>158 # zcaron2
);
} // --- END OF CLASS ---
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/unicode_data.php | PHP | asf20 | 228,322 |
<?php
//============================================================+
// File name : ita.php
// Begin : 2004-03-03
// Last Update : 2010-08-08
//
// Description : Language module for TCPDF
// (contains translated texts)
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file.
* @author Nicola Asuni
* @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// ENGLISH
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'it';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'pagina';
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/config/lang/ita.php | PHP | asf20 | 1,485 |
<?php
//============================================================+
// File name : eng.php
// Begin : 2004-03-03
// Last Update : 2010-08-08
//
// Description : Language module for TCPDF
// (contains translated texts)
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file.
* @author Nicola Asuni
* @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// ENGLISH
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'en';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'page';
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/config/lang/eng.php | PHP | asf20 | 1,483 |
<?php
//============================================================+
// File name : eng.php
// Begin : 2004-03-03
// Last Update : 2010-08-08
//
// Description : Language module for TCPDF
// (contains translated texts)
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file.
* @author Nicola Asuni
* @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// ENGLISH
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'de';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'seite';
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/config/lang/ger.php | PHP | asf20 | 1,484 |
<?php
//============================================================+
// File name : eng.php
// Begin : 2004-03-03
// Last Update : 2010-08-08
//
// Description : Language module for TCPDF
// (contains translated texts)
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* TCPDF language file (contains translated texts).
* @package com.tecnick.tcpdf
* @abstract TCPDF language file.
* @author Nicola Asuni
* @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-03-03
*/
// ENGLISH
global $l;
$l = Array();
// PAGE META DESCRIPTORS --------------------------------------
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'ltr';
$l['a_meta_language'] = 'pt';
// TRANSLATIONS --------------------------------------
$l['w_page'] = 'página';
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/config/lang/bra.php | PHP | asf20 | 1,486 |
<?php
//============================================================+
// File name : tcpdf_config.php
// Begin : 2004-06-11
// Last Update : 2010-08-19
//
// Description : Configuration file for TCPDF.
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* Configuration file for TCPDF.
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @package com.tecnick.tcpdf
* @version 4.9.005
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-10-27
*/
// If you define the constant K_TCPDF_EXTERNAL_CONFIG, the following settings will be ignored.
if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
// DOCUMENT_ROOT fix for IIS Webserver
if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) {
if(isset($_SERVER['SCRIPT_FILENAME'])) {
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])));
} elseif(isset($_SERVER['PATH_TRANSLATED'])) {
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])));
} else {
// define here your DOCUMENT_ROOT path if the previous fails
$_SERVER['DOCUMENT_ROOT'] = '/var/www';
}
}
// Automatic calculation for the following K_PATH_MAIN constant
$k_path_main = str_replace( '\\', '/', realpath(substr(dirname(__FILE__), 0, 0-strlen('config'))));
if (substr($k_path_main, -1) != '/') {
$k_path_main .= '/';
}
/**
* Installation path (/var/www/tcpdf/).
* By default it is automatically calculated but you can also set it as a fixed string to improve performances.
*/
define ('K_PATH_MAIN', $k_path_main);
// Automatic calculation for the following K_PATH_URL constant
$k_path_url = $k_path_main; // default value for console mode
if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) {
if(isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS'])!='off') {
$k_path_url = 'https://';
} else {
$k_path_url = 'http://';
}
$k_path_url .= $_SERVER['HTTP_HOST'];
$k_path_url .= str_replace( '\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1)));
}
/**
* URL path to tcpdf installation folder (http://localhost/tcpdf/).
* By default it is automatically calculated but you can also set it as a fixed string to improve performances.
*/
define ('K_PATH_URL', $k_path_url);
/**
* path for PDF fonts
* use K_PATH_MAIN.'fonts/old/' for old non-UTF8 fonts
*/
define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/');
/**
* cache directory for temporary files (full path)
*/
define ('K_PATH_CACHE', K_PATH_MAIN.'cache/');
/**
* cache directory for temporary files (url path)
*/
define ('K_PATH_URL_CACHE', K_PATH_URL.'cache/');
/**
*images directory
*/
define ('K_PATH_IMAGES', K_PATH_MAIN.'images/');
/**
* blank image
*/
define ('K_BLANK_IMAGE', K_PATH_IMAGES.'_blank.png');
/**
* page format
*/
define ('PDF_PAGE_FORMAT', 'A4');
/**
* page orientation (P=portrait, L=landscape)
*/
define ('PDF_PAGE_ORIENTATION', 'P');
/**
* document creator
*/
define ('PDF_CREATOR', 'TCPDF');
/**
* document author
*/
define ('PDF_AUTHOR', 'TCPDF');
/**
* header title
*/
define ('PDF_HEADER_TITLE', 'TCPDF Example');
/**
* header description string
*/
define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org");
/**
* image logo
*/
define ('PDF_HEADER_LOGO', 'tcpdf_logo.jpg');
/**
* header logo image width [mm]
*/
define ('PDF_HEADER_LOGO_WIDTH', 30);
/**
* document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]
*/
define ('PDF_UNIT', 'mm');
/**
* header margin
*/
define ('PDF_MARGIN_HEADER', 5);
/**
* footer margin
*/
define ('PDF_MARGIN_FOOTER', 10);
/**
* top margin
*/
define ('PDF_MARGIN_TOP', 27);
/**
* bottom margin
*/
define ('PDF_MARGIN_BOTTOM', 25);
/**
* left margin
*/
define ('PDF_MARGIN_LEFT', 15);
/**
* right margin
*/
define ('PDF_MARGIN_RIGHT', 15);
/**
* default main font name
*/
define ('PDF_FONT_NAME_MAIN', 'helvetica');
/**
* default main font size
*/
define ('PDF_FONT_SIZE_MAIN', 10);
/**
* default data font name
*/
define ('PDF_FONT_NAME_DATA', 'helvetica');
/**
* default data font size
*/
define ('PDF_FONT_SIZE_DATA', 8);
/**
* default monospaced font name
*/
define ('PDF_FONT_MONOSPACED', 'courier');
/**
* ratio used to adjust the conversion of pixels to user units
*/
define ('PDF_IMAGE_SCALE_RATIO', 1.25);
/**
* magnification factor for titles
*/
define('HEAD_MAGNIFICATION', 1.1);
/**
* height of cell repect font height
*/
define('K_CELL_HEIGHT_RATIO', 1.25);
/**
* title magnification respect main font size
*/
define('K_TITLE_MAGNIFICATION', 1.3);
/**
* reduction factor for small font
*/
define('K_SMALL_RATIO', 2/3);
/**
* set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language
*/
define('K_THAI_TOPCHARS', true);
/**
* if true allows to call TCPDF methods using HTML syntax
* IMPORTANT: For security reason, disable this feature if you are printing user HTML content.
*/
define('K_TCPDF_CALLS_IN_HTML', true);
}
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/config/tcpdf_config.php | PHP | asf20 | 5,926 |
<?php
//============================================================+
// File name : tcpdf_config.php
// Begin : 2004-06-11
// Last Update : 2010-08-19
//
// Description : Alternative configuration file for TCPDF.
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com s.r.l.
// Via Della Pace, 11
// 09044 Quartucciu (CA)
// ITALY
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* Alternative configuration file for TCPDF.
* @author Nicola Asuni
* @copyright 2004-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @package com.tecnick.tcpdf
* @version 4.9.005
* @link http://tcpdf.sourceforge.net
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2004-10-27
*/
// DOCUMENT_ROOT fix for IIS Webserver
if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) {
if(isset($_SERVER['SCRIPT_FILENAME'])) {
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])));
} elseif(isset($_SERVER['PATH_TRANSLATED'])) {
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])));
} else {
// define here your DOCUMENT_ROOT path if the previous fails
$_SERVER['DOCUMENT_ROOT'] = '/var/www';
}
}
// Automatic calculation for the following K_PATH_MAIN constant
$k_path_main = str_replace( '\\', '/', realpath(substr(dirname(__FILE__), 0, 0-strlen('config'))));
if (substr($k_path_main, -1) != '/') {
$k_path_main .= '/';
}
/**
* Installation path (/var/www/tcpdf/).
* By default it is automatically calculated but you can also set it as a fixed string to improve performances.
*/
define ('K_PATH_MAIN', $k_path_main);
// Automatic calculation for the following K_PATH_URL constant
if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) {
if(isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS'])!='off') {
$k_path_url = 'https://';
} else {
$k_path_url = 'http://';
}
$k_path_url .= $_SERVER['HTTP_HOST'];
$k_path_url .= str_replace( '\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1)));
}
/**
* URL path to tcpdf installation folder (http://localhost/tcpdf/).
* By default it is automatically calculated but you can also set it as a fixed string to improve performances..
*/
define ('K_PATH_URL', $k_path_url);
/**
* path for PDF fonts
* use K_PATH_MAIN.'fonts/old/' for old non-UTF8 fonts
*/
define ('K_PATH_FONTS', K_PATH_MAIN.'fonts/');
/**
* cache directory for temporary files (full path)
*/
define ('K_PATH_CACHE', K_PATH_MAIN.'cache/');
/**
* cache directory for temporary files (url path)
*/
define ('K_PATH_URL_CACHE', K_PATH_URL.'cache/');
/**
*images directory
*/
define ('K_PATH_IMAGES', K_PATH_MAIN.'images/');
/**
* blank image
*/
define ('K_BLANK_IMAGE', K_PATH_IMAGES.'_blank.png');
/**
* page format
*/
define ('PDF_PAGE_FORMAT', 'A4');
/**
* page orientation (P=portrait, L=landscape)
*/
define ('PDF_PAGE_ORIENTATION', 'P');
/**
* document creator
*/
define ('PDF_CREATOR', 'TCPDF');
/**
* document author
*/
define ('PDF_AUTHOR', 'TCPDF');
/**
* header title
*/
define ('PDF_HEADER_TITLE', 'TCPDF Example');
/**
* header description string
*/
define ('PDF_HEADER_STRING', "by Nicola Asuni - Tecnick.com\nwww.tcpdf.org");
/**
* image logo
*/
define ('PDF_HEADER_LOGO', 'tcpdf_logo.jpg');
/**
* header logo image width [mm]
*/
define ('PDF_HEADER_LOGO_WIDTH', 30);
/**
* document unit of measure [pt=point, mm=millimeter, cm=centimeter, in=inch]
*/
define ('PDF_UNIT', 'mm');
/**
* header margin
*/
define ('PDF_MARGIN_HEADER', 5);
/**
* footer margin
*/
define ('PDF_MARGIN_FOOTER', 10);
/**
* top margin
*/
define ('PDF_MARGIN_TOP', 27);
/**
* bottom margin
*/
define ('PDF_MARGIN_BOTTOM', 25);
/**
* left margin
*/
define ('PDF_MARGIN_LEFT', 15);
/**
* right margin
*/
define ('PDF_MARGIN_RIGHT', 15);
/**
* default main font name
*/
define ('PDF_FONT_NAME_MAIN', 'helvetica');
/**
* default main font size
*/
define ('PDF_FONT_SIZE_MAIN', 10);
/**
* default data font name
*/
define ('PDF_FONT_NAME_DATA', 'helvetica');
/**
* default data font size
*/
define ('PDF_FONT_SIZE_DATA', 8);
/**
* default monospaced font name
*/
define ('PDF_FONT_MONOSPACED', 'courier');
/**
* ratio used to adjust the conversion of pixels to user units
*/
define ('PDF_IMAGE_SCALE_RATIO', 1.25);
/**
* magnification factor for titles
*/
define('HEAD_MAGNIFICATION', 1.1);
/**
* height of cell repect font height
*/
define('K_CELL_HEIGHT_RATIO', 1.25);
/**
* title magnification respect main font size
*/
define('K_TITLE_MAGNIFICATION', 1.3);
/**
* reduction factor for small font
*/
define('K_SMALL_RATIO', 2/3);
/**
* set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language
*/
define('K_THAI_TOPCHARS', true);
/**
* if true allows to call TCPDF methods using HTML syntax
* IMPORTANT: For security reason, disable this feature if you are printing user HTML content.
*/
define('K_TCPDF_CALLS_IN_HTML', true);
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/config/tcpdf_config_alt.php | PHP | asf20 | 5,580 |
<?php
//============================================================+
// File name : qrcode.php
// Version : 1.0.006
// Begin : 2010-03-22
// Last Update : 2010-08-30
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
// Copyright (C) 2010-2010 Nicola Asuni - Tecnick.com S.r.l.
//
// This file is part of TCPDF software library.
//
// TCPDF 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 3 of the
// License, or (at your option) any later version.
//
// TCPDF 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 TCPDF. If not, see <http://www.gnu.org/licenses/>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// DESCRIPTION :
//
// Class to create QR-code arrays for TCPDF class.
// QR Code symbol is a 2D barcode that can be scanned by
// handy terminals such as a mobile phone with CCD.
// The capacity of QR Code is up to 7000 digits or 4000
// characters, and has high robustness.
// This class supports QR Code model 2, described in
// JIS (Japanese Industrial Standards) X0510:2004
// or ISO/IEC 18004.
// Currently the following features are not supported:
// ECI and FNC1 mode, Micro QR Code, QR Code model 1,
// Structured mode.
//
// This class is derived from the following projects:
// ---------------------------------------------------------
// "PHP QR Code encoder"
// License: GNU-LGPLv3
// Copyright (C) 2010 by Dominik Dzienia <deltalab at poczta dot fm>
// http://phpqrcode.sourceforge.net/
// https://sourceforge.net/projects/phpqrcode/
//
// The "PHP QR Code encoder" is based on
// "C libqrencode library" (ver. 3.1.1)
// License: GNU-LGPL 2.1
// Copyright (C) 2006-2010 by Kentaro Fukuchi
// http://megaui.net/fukuchi/works/qrencode/index.en.html
//
// Reed-Solomon code encoder is written by Phil Karn, KA9Q.
// Copyright (C) 2002-2006 Phil Karn, KA9Q
//
// QR Code is registered trademark of DENSO WAVE INCORPORATED
// http://www.denso-wave.com/qrcode/index-e.html
// ---------------------------------------------------------
//============================================================+
/**
* Class to create QR-code arrays for TCPDF class.
* QR Code symbol is a 2D barcode that can be scanned by handy terminals such as a mobile phone with CCD.
* The capacity of QR Code is up to 7000 digits or 4000 characters, and has high robustness.
* This class supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004.
* Currently the following features are not supported: ECI and FNC1 mode, Micro QR Code, QR Code model 1, Structured mode.
*
* This class is derived from "PHP QR Code encoder" by Dominik Dzienia (http://phpqrcode.sourceforge.net/) based on "libqrencode C library 3.1.1." by Kentaro Fukuchi (http://megaui.net/fukuchi/works/qrencode/index.en.html), contains Reed-Solomon code written by Phil Karn, KA9Q. QR Code is registered trademark of DENSO WAVE INCORPORATED (http://www.denso-wave.com/qrcode/index-e.html).
* Please read comments on this class source file for full copyright and license information.
*
* @package com.tecnick.tcpdf
* @abstract Class for generating QR-code array for TCPDF.
* @author Nicola Asuni
* @copyright 2010-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version 1.0.006
*/
// definitions
if (!defined('QRCODEDEFS')) {
/**
* Indicate that definitions for this class are set
*/
define('QRCODEDEFS', true);
// -----------------------------------------------------
// Encoding modes (characters which can be encoded in QRcode)
/**
* Encoding mode
*/
define('QR_MODE_NL', -1);
/**
* Encoding mode numeric (0-9). 3 characters are encoded to 10bit length. In theory, 7089 characters or less can be stored in a QRcode.
*/
define('QR_MODE_NM', 0);
/**
* Encoding mode alphanumeric (0-9A-Z $%*+-./:) 45characters. 2 characters are encoded to 11bit length. In theory, 4296 characters or less can be stored in a QRcode.
*/
define('QR_MODE_AN', 1);
/**
* Encoding mode 8bit byte data. In theory, 2953 characters or less can be stored in a QRcode.
*/
define('QR_MODE_8B', 2);
/**
* Encoding mode KANJI. A KANJI character (multibyte character) is encoded to 13bit length. In theory, 1817 characters or less can be stored in a QRcode.
*/
define('QR_MODE_KJ', 3);
/**
* Encoding mode STRUCTURED (currently unsupported)
*/
define('QR_MODE_ST', 4);
// -----------------------------------------------------
// Levels of error correction.
// QRcode has a function of an error correcting for miss reading that white is black.
// Error correcting is defined in 4 level as below.
/**
* Error correction level L : About 7% or less errors can be corrected.
*/
define('QR_ECLEVEL_L', 0);
/**
* Error correction level M : About 15% or less errors can be corrected.
*/
define('QR_ECLEVEL_M', 1);
/**
* Error correction level Q : About 25% or less errors can be corrected.
*/
define('QR_ECLEVEL_Q', 2);
/**
* Error correction level H : About 30% or less errors can be corrected.
*/
define('QR_ECLEVEL_H', 3);
// -----------------------------------------------------
// Version. Size of QRcode is defined as version.
// Version is from 1 to 40.
// Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases.
// So version 40 is 177*177 matrix.
/**
* Maximum QR Code version.
*/
define('QRSPEC_VERSION_MAX', 40);
/**
* Maximum matrix size for maximum version (version 40 is 177*177 matrix).
*/
define('QRSPEC_WIDTH_MAX', 177);
// -----------------------------------------------------
/**
* Matrix index to get width from $capacity array.
*/
define('QRCAP_WIDTH', 0);
/**
* Matrix index to get number of words from $capacity array.
*/
define('QRCAP_WORDS', 1);
/**
* Matrix index to get remainder from $capacity array.
*/
define('QRCAP_REMINDER', 2);
/**
* Matrix index to get error correction level from $capacity array.
*/
define('QRCAP_EC', 3);
// -----------------------------------------------------
// Structure (currently usupported)
/**
* Number of header bits for structured mode
*/
define('STRUCTURE_HEADER_BITS', 20);
/**
* Max number of symbols for structured mode
*/
define('MAX_STRUCTURED_SYMBOLS', 16);
// -----------------------------------------------------
// Masks
/**
* Down point base value for case 1 mask pattern (concatenation of same color in a line or a column)
*/
define('N1', 3);
/**
* Down point base value for case 2 mask pattern (module block of same color)
*/
define('N2', 3);
/**
* Down point base value for case 3 mask pattern (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column)
*/
define('N3', 40);
/**
* Down point base value for case 4 mask pattern (ration of dark modules in whole)
*/
define('N4', 10);
// -----------------------------------------------------
// Optimization settings
/**
* if true, estimates best mask (spec. default, but extremally slow; set to false to significant performance boost but (propably) worst quality code
*/
define('QR_FIND_BEST_MASK', true);
/**
* if false, checks all masks available, otherwise value tells count of masks need to be checked, mask id are got randomly
*/
define('QR_FIND_FROM_RANDOM', 2);
/**
* when QR_FIND_BEST_MASK === false
*/
define('QR_DEFAULT_MASK', 2);
// -----------------------------------------------------
} // end of definitions
// #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#
if (!class_exists('QRcode', false)) {
// for compatibility with PHP4
if (!function_exists('str_split')) {
/**
* Convert a string to an array (needed for PHP4 compatibility)
* @param string $string The input string.
* @param int $split_length Maximum length of the chunk.
* @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element.
*/
function str_split($string, $split_length=1) {
if ((strlen($string) > $split_length) OR (!$split_length)) {
do {
$c = strlen($string);
$parts[] = substr($string, 0, $split_length);
$string = substr($string, $split_length);
} while ($string !== false);
} else {
$parts = array($string);
}
return $parts;
}
}
// #####################################################
/**
* Class to create QR-code arrays for TCPDF class.
* QR Code symbol is a 2D barcode that can be scanned by handy terminals such as a mobile phone with CCD.
* The capacity of QR Code is up to 7000 digits or 4000 characters, and has high robustness.
* This class supports QR Code model 2, described in JIS (Japanese Industrial Standards) X0510:2004 or ISO/IEC 18004.
* Currently the following features are not supported: ECI and FNC1 mode, Micro QR Code, QR Code model 1, Structured mode.
*
* This class is derived from "PHP QR Code encoder" by Dominik Dzienia (http://phpqrcode.sourceforge.net/) based on "libqrencode C library 3.1.1." by Kentaro Fukuchi (http://megaui.net/fukuchi/works/qrencode/index.en.html), contains Reed-Solomon code written by Phil Karn, KA9Q. QR Code is registered trademark of DENSO WAVE INCORPORATED (http://www.denso-wave.com/qrcode/index-e.html).
* Please read comments on this class source file for full copyright and license information.
*
* @name QRcode
* @package com.tecnick.tcpdf
* @abstract Class for generating QR-code array for TCPDF.
* @author Nicola Asuni
* @copyright 2010-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version 1.0.006
*/
class QRcode {
/**
* @var barcode array to be returned which is readable by TCPDF
* @access protected
*/
protected $barcode_array = array();
/**
* @var QR code version. Size of QRcode is defined as version. Version is from 1 to 40. Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. So version 40 is 177*177 matrix.
* @access protected
*/
protected $version = 0;
/**
* @var Levels of error correction. See definitions for possible values.
* @access protected
*/
protected $level = QR_ECLEVEL_L;
/**
* @var Encoding mode
* @access protected
*/
protected $hint = QR_MODE_8B;
/**
* @var if true the input string will be converted to uppercase
* @access protected
*/
protected $casesensitive = true;
/**
* @var structured QR code (not supported yet)
* @access protected
*/
protected $structured = 0;
/**
* @var mask data
* @access protected
*/
protected $data;
// FrameFiller
/**
* @var width
* @access protected
*/
protected $width;
/**
* @var frame
* @access protected
*/
protected $frame;
/**
* @var X position of bit
* @access protected
*/
protected $x;
/**
* @var Y position of bit
* @access protected
*/
protected $y;
/**
* @var direction
* @access protected
*/
protected $dir;
/**
* @var single bit
* @access protected
*/
protected $bit;
// ---- QRrawcode ----
/**
* @var data code
* @access protected
*/
protected $datacode = array();
/**
* @var error correction code
* @access protected
*/
protected $ecccode = array();
/**
* @var blocks
* @access protected
*/
protected $blocks;
/**
* @var Reed-Solomon blocks
* @access protected
*/
protected $rsblocks = array(); //of RSblock
/**
* @var counter
* @access protected
*/
protected $count;
/**
* @var data length
* @access protected
*/
protected $dataLength;
/**
* @var error correction length
* @access protected
*/
protected $eccLength;
/**
* @var b1
* @access protected
*/
protected $b1;
// ---- QRmask ----
/**
* @var run length
* @access protected
*/
protected $runLength = array();
// ---- QRsplit ----
/**
* @var input data string
* @access protected
*/
protected $dataStr = '';
/**
* @var input items
* @access protected
*/
protected $items;
// Reed-Solomon items
/**
* @var Reed-Solomon items
* @access protected
*/
protected $rsitems = array();
/**
* @var array of frames
* @access protected
*/
protected $frames = array();
/**
* @var alphabet-numeric convesion table
* @access protected
*/
protected $anTable = array(
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, //
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, //
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, //
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, //
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 //
);
/**
* @var array Table of the capacity of symbols
* See Table 1 (pp.13) and Table 12-16 (pp.30-36), JIS X0510:2004.
* @access protected
*/
protected $capacity = array(
array( 0, 0, 0, array( 0, 0, 0, 0)), //
array( 21, 26, 0, array( 7, 10, 13, 17)), // 1
array( 25, 44, 7, array( 10, 16, 22, 28)), //
array( 29, 70, 7, array( 15, 26, 36, 44)), //
array( 33, 100, 7, array( 20, 36, 52, 64)), //
array( 37, 134, 7, array( 26, 48, 72, 88)), // 5
array( 41, 172, 7, array( 36, 64, 96, 112)), //
array( 45, 196, 0, array( 40, 72, 108, 130)), //
array( 49, 242, 0, array( 48, 88, 132, 156)), //
array( 53, 292, 0, array( 60, 110, 160, 192)), //
array( 57, 346, 0, array( 72, 130, 192, 224)), // 10
array( 61, 404, 0, array( 80, 150, 224, 264)), //
array( 65, 466, 0, array( 96, 176, 260, 308)), //
array( 69, 532, 0, array( 104, 198, 288, 352)), //
array( 73, 581, 3, array( 120, 216, 320, 384)), //
array( 77, 655, 3, array( 132, 240, 360, 432)), // 15
array( 81, 733, 3, array( 144, 280, 408, 480)), //
array( 85, 815, 3, array( 168, 308, 448, 532)), //
array( 89, 901, 3, array( 180, 338, 504, 588)), //
array( 93, 991, 3, array( 196, 364, 546, 650)), //
array( 97, 1085, 3, array( 224, 416, 600, 700)), // 20
array(101, 1156, 4, array( 224, 442, 644, 750)), //
array(105, 1258, 4, array( 252, 476, 690, 816)), //
array(109, 1364, 4, array( 270, 504, 750, 900)), //
array(113, 1474, 4, array( 300, 560, 810, 960)), //
array(117, 1588, 4, array( 312, 588, 870, 1050)), // 25
array(121, 1706, 4, array( 336, 644, 952, 1110)), //
array(125, 1828, 4, array( 360, 700, 1020, 1200)), //
array(129, 1921, 3, array( 390, 728, 1050, 1260)), //
array(133, 2051, 3, array( 420, 784, 1140, 1350)), //
array(137, 2185, 3, array( 450, 812, 1200, 1440)), // 30
array(141, 2323, 3, array( 480, 868, 1290, 1530)), //
array(145, 2465, 3, array( 510, 924, 1350, 1620)), //
array(149, 2611, 3, array( 540, 980, 1440, 1710)), //
array(153, 2761, 3, array( 570, 1036, 1530, 1800)), //
array(157, 2876, 0, array( 570, 1064, 1590, 1890)), // 35
array(161, 3034, 0, array( 600, 1120, 1680, 1980)), //
array(165, 3196, 0, array( 630, 1204, 1770, 2100)), //
array(169, 3362, 0, array( 660, 1260, 1860, 2220)), //
array(173, 3532, 0, array( 720, 1316, 1950, 2310)), //
array(177, 3706, 0, array( 750, 1372, 2040, 2430)) // 40
);
/**
* @var array Length indicator
* @access protected
*/
protected $lengthTableBits = array(
array(10, 12, 14),
array( 9, 11, 13),
array( 8, 16, 16),
array( 8, 10, 12)
);
/**
* @var array Table of the error correction code (Reed-Solomon block)
* See Table 12-16 (pp.30-36), JIS X0510:2004.
* @access protected
*/
protected $eccTable = array(
array(array( 0, 0), array( 0, 0), array( 0, 0), array( 0, 0)), //
array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // 1
array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), //
array(array( 1, 0), array( 1, 0), array( 2, 0), array( 2, 0)), //
array(array( 1, 0), array( 2, 0), array( 2, 0), array( 4, 0)), //
array(array( 1, 0), array( 2, 0), array( 2, 2), array( 2, 2)), // 5
array(array( 2, 0), array( 4, 0), array( 4, 0), array( 4, 0)), //
array(array( 2, 0), array( 4, 0), array( 2, 4), array( 4, 1)), //
array(array( 2, 0), array( 2, 2), array( 4, 2), array( 4, 2)), //
array(array( 2, 0), array( 3, 2), array( 4, 4), array( 4, 4)), //
array(array( 2, 2), array( 4, 1), array( 6, 2), array( 6, 2)), // 10
array(array( 4, 0), array( 1, 4), array( 4, 4), array( 3, 8)), //
array(array( 2, 2), array( 6, 2), array( 4, 6), array( 7, 4)), //
array(array( 4, 0), array( 8, 1), array( 8, 4), array(12, 4)), //
array(array( 3, 1), array( 4, 5), array(11, 5), array(11, 5)), //
array(array( 5, 1), array( 5, 5), array( 5, 7), array(11, 7)), // 15
array(array( 5, 1), array( 7, 3), array(15, 2), array( 3, 13)), //
array(array( 1, 5), array(10, 1), array( 1, 15), array( 2, 17)), //
array(array( 5, 1), array( 9, 4), array(17, 1), array( 2, 19)), //
array(array( 3, 4), array( 3, 11), array(17, 4), array( 9, 16)), //
array(array( 3, 5), array( 3, 13), array(15, 5), array(15, 10)), // 20
array(array( 4, 4), array(17, 0), array(17, 6), array(19, 6)), //
array(array( 2, 7), array(17, 0), array( 7, 16), array(34, 0)), //
array(array( 4, 5), array( 4, 14), array(11, 14), array(16, 14)), //
array(array( 6, 4), array( 6, 14), array(11, 16), array(30, 2)), //
array(array( 8, 4), array( 8, 13), array( 7, 22), array(22, 13)), // 25
array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)), //
array(array( 8, 4), array(22, 3), array( 8, 26), array(12, 28)), //
array(array( 3, 10), array( 3, 23), array( 4, 31), array(11, 31)), //
array(array( 7, 7), array(21, 7), array( 1, 37), array(19, 26)), //
array(array( 5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30
array(array(13, 3), array( 2, 29), array(42, 1), array(23, 28)), //
array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)), //
array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)), //
array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)), //
array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), // 35
array(array( 6, 14), array( 6, 34), array(46, 10), array( 2, 64)), //
array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)), //
array(array( 4, 18), array(13, 32), array(48, 14), array(42, 32)), //
array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)), //
array(array(19, 6), array(18, 31), array(34, 34), array(20, 61)) // 40
);
/**
* @var array Positions of alignment patterns.
* This array includes only the second and the third position of the alignment patterns. Rest of them can be calculated from the distance between them.
* See Table 1 in Appendix E (pp.71) of JIS X0510:2004.
* @access protected
*/
protected $alignmentPattern = array(
array( 0, 0),
array( 0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5
array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10
array(30, 54), array(32, 58), array(34, 62), array(26, 46), array(26, 48), // 11-15
array(26, 50), array(30, 54), array(30, 56), array(30, 58), array(34, 62), // 16-20
array(28, 50), array(26, 50), array(30, 54), array(28, 54), array(32, 58), // 21-25
array(30, 58), array(34, 62), array(26, 50), array(30, 54), array(26, 52), // 26-30
array(30, 56), array(34, 60), array(30, 58), array(34, 62), array(30, 54), // 31-35
array(24, 50), array(28, 54), array(32, 58), array(26, 54), array(30, 58) // 35-40
);
/**
* @var array Version information pattern (BCH coded).
* See Table 1 in Appendix D (pp.68) of JIS X0510:2004.
* size: [QRSPEC_VERSION_MAX - 6]
* @access protected
*/
protected $versionPattern = array(
0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, //
0x0f928, 0x10b78, 0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, //
0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, //
0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64, //
0x27541, 0x28c69
);
/**
* @var array Format information
* @access protected
*/
protected $formatInfo = array(
array(0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976), //
array(0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0), //
array(0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed), //
array(0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b) //
);
// -------------------------------------------------
// -------------------------------------------------
/**
* This is the class constructor.
* Creates a QRcode object
* @param string $code code to represent using QRcode
* @param string $eclevel error level: <ul><li>L : About 7% or less errors can be corrected.</li><li>M : About 15% or less errors can be corrected.</li><li>Q : About 25% or less errors can be corrected.</li><li>H : About 30% or less errors can be corrected.</li></ul>
* @access public
* @since 1.0.000
*/
public function __construct($code, $eclevel = 'L') {
$barcode_array = array();
if ((is_null($code)) OR ($code == '\0') OR ($code == '')) {
return false;
}
// set error correction level
$this->level = array_search($eclevel, array('L', 'M', 'Q', 'H'));
if ($this->level === false) {
$this->level = QR_ECLEVEL_L;
}
if (($this->hint != QR_MODE_8B) AND ($this->hint != QR_MODE_KJ)) {
return false;
}
if (($this->version < 0) OR ($this->version > QRSPEC_VERSION_MAX)) {
return false;
}
$this->items = array();
$this->encodeString($code);
if (is_null($this->data)) {
return false;
}
$qrTab = $this->binarize($this->data);
$size = count($qrTab);
$barcode_array['num_rows'] = $size;
$barcode_array['num_cols'] = $size;
$barcode_array['bcode'] = array();
foreach ($qrTab as $line) {
$arrAdd = array();
foreach (str_split($line) as $char) {
$arrAdd[] = ($char=='1')?1:0;
}
$barcode_array['bcode'][] = $arrAdd;
}
$this->barcode_array = $barcode_array;
}
/**
* Returns a barcode array which is readable by TCPDF
* @return array barcode array readable by TCPDF;
* @access public
*/
public function getBarcodeArray() {
return $this->barcode_array;
}
/**
* Convert the frame in binary form
* @param array $frame array to binarize
* @return array frame in binary form
*/
protected function binarize($frame) {
$len = count($frame);
// the frame is square (width = height)
foreach ($frame as &$frameLine) {
for ($i=0; $i<$len; $i++) {
$frameLine[$i] = (ord($frameLine[$i])&1)?'1':'0';
}
}
return $frame;
}
/**
* Encode the input string to QR code
* @param string $string input string to encode
*/
protected function encodeString($string) {
$this->dataStr = $string;
if (!$this->casesensitive) {
$this->toUpper();
}
$ret = $this->splitString();
if ($ret < 0) {
return NULL;
}
$this->encodeMask(-1);
}
/**
* Encode mask
* @param int $mask masking mode
*/
protected function encodeMask($mask) {
$spec = array(0, 0, 0, 0, 0);
$this->datacode = $this->getByteStream($this->items);
if (is_null($this->datacode)) {
return NULL;
}
$spec = $this->getEccSpec($this->version, $this->level, $spec);
$this->b1 = $this->rsBlockNum1($spec);
$this->dataLength = $this->rsDataLength($spec);
$this->eccLength = $this->rsEccLength($spec);
$this->ecccode = array_fill(0, $this->eccLength, 0);
$this->blocks = $this->rsBlockNum($spec);
$ret = $this->init($spec);
if ($ret < 0) {
return NULL;
}
$this->count = 0;
$this->width = $this->getWidth($this->version);
$this->frame = $this->newFrame($this->version);
$this->x = $this->width - 1;
$this->y = $this->width - 1;
$this->dir = -1;
$this->bit = -1;
// inteleaved data and ecc codes
for ($i=0; $i < ($this->dataLength + $this->eccLength); $i++) {
$code = $this->getCode();
$bit = 0x80;
for ($j=0; $j<8; $j++) {
$addr = $this->getNextPosition();
$this->setFrameAt($addr, 0x02 | (($bit & $code) != 0));
$bit = $bit >> 1;
}
}
// remainder bits
$j = $this->getRemainder($this->version);
for ($i=0; $i<$j; $i++) {
$addr = $this->getNextPosition();
$this->setFrameAt($addr, 0x02);
}
// masking
$this->runLength = array_fill(0, QRSPEC_WIDTH_MAX + 1, 0);
if ($mask < 0) {
if (QR_FIND_BEST_MASK) {
$masked = $this->mask($this->width, $this->frame, $this->level);
} else {
$masked = $this->makeMask($this->width, $this->frame, (intval(QR_DEFAULT_MASK) % 8), $this->level);
}
} else {
$masked = $this->makeMask($this->width, $this->frame, $mask, $this->level);
}
if ($masked == NULL) {
return NULL;
}
$this->data = $masked;
}
// - - - - - - - - - - - - - - - - - - - - - - - - -
// FrameFiller
/**
* Set frame value at specified position
* @param array $at x,y position
* @param int $val value of the character to set
*/
protected function setFrameAt($at, $val) {
$this->frame[$at['y']][$at['x']] = chr($val);
}
/**
* Get frame value at specified position
* @param array $at x,y position
* @return value at specified position
*/
protected function getFrameAt($at) {
return ord($this->frame[$at['y']][$at['x']]);
}
/**
* Return the next frame position
* @return array of x,y coordinates
*/
protected function getNextPosition() {
do {
if ($this->bit == -1) {
$this->bit = 0;
return array('x'=>$this->x, 'y'=>$this->y);
}
$x = $this->x;
$y = $this->y;
$w = $this->width;
if ($this->bit == 0) {
$x--;
$this->bit++;
} else {
$x++;
$y += $this->dir;
$this->bit--;
}
if ($this->dir < 0) {
if ($y < 0) {
$y = 0;
$x -= 2;
$this->dir = 1;
if ($x == 6) {
$x--;
$y = 9;
}
}
} else {
if ($y == $w) {
$y = $w - 1;
$x -= 2;
$this->dir = -1;
if ($x == 6) {
$x--;
$y -= 8;
}
}
}
if (($x < 0) OR ($y < 0)) {
return NULL;
}
$this->x = $x;
$this->y = $y;
} while(ord($this->frame[$y][$x]) & 0x80);
return array('x'=>$x, 'y'=>$y);
}
// - - - - - - - - - - - - - - - - - - - - - - - - -
// QRrawcode
/**
* Initialize code.
* @param array $spec array of ECC specification
* @return 0 in case of success, -1 in case of error
*/
protected function init($spec) {
$dl = $this->rsDataCodes1($spec);
$el = $this->rsEccCodes1($spec);
$rs = $this->init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
$blockNo = 0;
$dataPos = 0;
$eccPos = 0;
$endfor = $this->rsBlockNum1($spec);
for ($i=0; $i < $endfor; ++$i) {
$ecc = array_slice($this->ecccode, $eccPos);
$this->rsblocks[$blockNo] = array();
$this->rsblocks[$blockNo]['dataLength'] = $dl;
$this->rsblocks[$blockNo]['data'] = array_slice($this->datacode, $dataPos);
$this->rsblocks[$blockNo]['eccLength'] = $el;
$ecc = $this->encode_rs_char($rs, $this->rsblocks[$blockNo]['data'], $ecc);
$this->rsblocks[$blockNo]['ecc'] = $ecc;
$this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc);
$dataPos += $dl;
$eccPos += $el;
$blockNo++;
}
if ($this->rsBlockNum2($spec) == 0) {
return 0;
}
$dl = $this->rsDataCodes2($spec);
$el = $this->rsEccCodes2($spec);
$rs = $this->init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
if ($rs == NULL) {
return -1;
}
$endfor = $this->rsBlockNum2($spec);
for ($i=0; $i < $endfor; ++$i) {
$ecc = array_slice($this->ecccode, $eccPos);
$this->rsblocks[$blockNo] = array();
$this->rsblocks[$blockNo]['dataLength'] = $dl;
$this->rsblocks[$blockNo]['data'] = array_slice($this->datacode, $dataPos);
$this->rsblocks[$blockNo]['eccLength'] = $el;
$ecc = $this->encode_rs_char($rs, $this->rsblocks[$blockNo]['data'], $ecc);
$this->rsblocks[$blockNo]['ecc'] = $ecc;
$this->ecccode = array_merge(array_slice($this->ecccode, 0, $eccPos), $ecc);
$dataPos += $dl;
$eccPos += $el;
$blockNo++;
}
return 0;
}
/**
* Return Reed-Solomon block code.
* @return array rsblocks
*/
protected function getCode() {
if ($this->count < $this->dataLength) {
$row = $this->count % $this->blocks;
$col = $this->count / $this->blocks;
if ($col >= $this->rsblocks[0]['dataLength']) {
$row += $this->b1;
}
$ret = $this->rsblocks[$row]['data'][$col];
} elseif ($this->count < $this->dataLength + $this->eccLength) {
$row = ($this->count - $this->dataLength) % $this->blocks;
$col = ($this->count - $this->dataLength) / $this->blocks;
$ret = $this->rsblocks[$row]['ecc'][$col];
} else {
return 0;
}
$this->count++;
return $ret;
}
// - - - - - - - - - - - - - - - - - - - - - - - - -
// QRmask
/**
* Write Format Information on frame and returns the number of black bits
* @param int $width frame width
* @param array $frame frame
* @param array $mask masking mode
* @param int $level error correction level
* @return int blacks
*/
protected function writeFormatInformation($width, &$frame, $mask, $level) {
$blacks = 0;
$format = $this->getFormatInfo($mask, $level);
for ($i=0; $i<8; ++$i) {
if ($format & 1) {
$blacks += 2;
$v = 0x85;
} else {
$v = 0x84;
}
$frame[8][$width - 1 - $i] = chr($v);
if ($i < 6) {
$frame[$i][8] = chr($v);
} else {
$frame[$i + 1][8] = chr($v);
}
$format = $format >> 1;
}
for ($i=0; $i<7; ++$i) {
if ($format & 1) {
$blacks += 2;
$v = 0x85;
} else {
$v = 0x84;
}
$frame[$width - 7 + $i][8] = chr($v);
if ($i == 0) {
$frame[8][7] = chr($v);
} else {
$frame[8][6 - $i] = chr($v);
}
$format = $format >> 1;
}
return $blacks;
}
/**
* mask0
* @param int $x X position
* @param int $y Y position
* @return int mask
*/
protected function mask0($x, $y) {
return ($x + $y) & 1;
}
/**
* mask1
* @param int $x X position
* @param int $y Y position
* @return int mask
*/
protected function mask1($x, $y) {
return ($y & 1);
}
/**
* mask2
* @param int $x X position
* @param int $y Y position
* @return int mask
*/
protected function mask2($x, $y) {
return ($x % 3);
}
/**
* mask3
* @param int $x X position
* @param int $y Y position
* @return int mask
*/
protected function mask3($x, $y) {
return ($x + $y) % 3;
}
/**
* mask4
* @param int $x X position
* @param int $y Y position
* @return int mask
*/
protected function mask4($x, $y) {
return (((int)($y / 2)) + ((int)($x / 3))) & 1;
}
/**
* mask5
* @param int $x X position
* @param int $y Y position
* @return int mask
*/
protected function mask5($x, $y) {
return (($x * $y) & 1) + ($x * $y) % 3;
}
/**
* mask6
* @param int $x X position
* @param int $y Y position
* @return int mask
*/
protected function mask6($x, $y) {
return ((($x * $y) & 1) + ($x * $y) % 3) & 1;
}
/**
* mask7
* @param int $x X position
* @param int $y Y position
* @return int mask
*/
protected function mask7($x, $y) {
return ((($x * $y) % 3) + (($x + $y) & 1)) & 1;
}
/**
* Return bitmask
* @param int $maskNo mask number
* @param int $width width
* @param array $frame frame
* @return array bitmask
*/
protected function generateMaskNo($maskNo, $width, $frame) {
$bitMask = array_fill(0, $width, array_fill(0, $width, 0));
for ($y=0; $y<$width; ++$y) {
for ($x=0; $x<$width; ++$x) {
if (ord($frame[$y][$x]) & 0x80) {
$bitMask[$y][$x] = 0;
} else {
$maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y);
$bitMask[$y][$x] = ($maskFunc == 0)?1:0;
}
}
}
return $bitMask;
}
/**
* makeMaskNo
* @param int $maskNo
* @param int $width
* @param int $s
* @param int $d
* @param boolean $maskGenOnly
* @return int b
*/
protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) {
$b = 0;
$bitMask = array();
$bitMask = $this->generateMaskNo($maskNo, $width, $s, $d);
if ($maskGenOnly) {
return;
}
$d = $s;
for ($y=0; $y<$width; ++$y) {
for ($x=0; $x<$width; ++$x) {
if ($bitMask[$y][$x] == 1) {
$d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]);
}
$b += (int)(ord($d[$y][$x]) & 1);
}
}
return $b;
}
/**
* makeMask
* @param int $width
* @param array $frame
* @param int $maskNo
* @param int $level
* @return array mask
*/
protected function makeMask($width, $frame, $maskNo, $level) {
$masked = array_fill(0, $width, str_repeat("\0", $width));
$this->makeMaskNo($maskNo, $width, $frame, $masked);
$this->writeFormatInformation($width, $masked, $maskNo, $level);
return $masked;
}
/**
* calcN1N3
* @param int $length
* @return int demerit
*/
protected function calcN1N3($length) {
$demerit = 0;
for ($i=0; $i<$length; ++$i) {
if ($this->runLength[$i] >= 5) {
$demerit += (N1 + ($this->runLength[$i] - 5));
}
if ($i & 1) {
if (($i >= 3) AND ($i < ($length-2)) AND ($this->runLength[$i] % 3 == 0)) {
$fact = (int)($this->runLength[$i] / 3);
if (($this->runLength[$i-2] == $fact)
AND ($this->runLength[$i-1] == $fact)
AND ($this->runLength[$i+1] == $fact)
AND ($this->runLength[$i+2] == $fact)) {
if (($this->runLength[$i-3] < 0) OR ($this->runLength[$i-3] >= (4 * $fact))) {
$demerit += N3;
} elseif ((($i+3) >= $length) OR ($this->runLength[$i+3] >= (4 * $fact))) {
$demerit += N3;
}
}
}
}
}
return $demerit;
}
/**
* evaluateSymbol
* @param int $width
* @param array $frame
* @return int demerit
*/
protected function evaluateSymbol($width, $frame) {
$head = 0;
$demerit = 0;
for ($y=0; $y<$width; ++$y) {
$head = 0;
$this->runLength[0] = 1;
$frameY = $frame[$y];
if ($y > 0) {
$frameYM = $frame[$y-1];
}
for ($x=0; $x<$width; ++$x) {
if (($x > 0) AND ($y > 0)) {
$b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]);
$w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]);
if (($b22 | ($w22 ^ 1)) & 1) {
$demerit += N2;
}
}
if (($x == 0) AND (ord($frameY[$x]) & 1)) {
$this->runLength[0] = -1;
$head = 1;
$this->runLength[$head] = 1;
} elseif ($x > 0) {
if ((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) {
$head++;
$this->runLength[$head] = 1;
} else {
$this->runLength[$head]++;
}
}
}
$demerit += $this->calcN1N3($head+1);
}
for ($x=0; $x<$width; ++$x) {
$head = 0;
$this->runLength[0] = 1;
for ($y=0; $y<$width; ++$y) {
if (($y == 0) AND (ord($frame[$y][$x]) & 1)) {
$this->runLength[0] = -1;
$head = 1;
$this->runLength[$head] = 1;
} elseif ($y > 0) {
if ((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) {
$head++;
$this->runLength[$head] = 1;
} else {
$this->runLength[$head]++;
}
}
}
$demerit += $this->calcN1N3($head+1);
}
return $demerit;
}
/**
* mask
* @param int $width
* @param array $frame
* @param int $level
* @return array best mask
*/
protected function mask($width, $frame, $level) {
$minDemerit = PHP_INT_MAX;
$bestMaskNum = 0;
$bestMask = array();
$checked_masks = array(0, 1, 2, 3, 4, 5, 6, 7);
if (QR_FIND_FROM_RANDOM !== false) {
$howManuOut = 8 - (QR_FIND_FROM_RANDOM % 9);
for ($i = 0; $i < $howManuOut; ++$i) {
$remPos = rand (0, count($checked_masks)-1);
unset($checked_masks[$remPos]);
$checked_masks = array_values($checked_masks);
}
}
$bestMask = $frame;
foreach ($checked_masks as $i) {
$mask = array_fill(0, $width, str_repeat("\0", $width));
$demerit = 0;
$blacks = 0;
$blacks = $this->makeMaskNo($i, $width, $frame, $mask);
$blacks += $this->writeFormatInformation($width, $mask, $i, $level);
$blacks = (int)(100 * $blacks / ($width * $width));
$demerit = (int)((int)(abs($blacks - 50) / 5) * N4);
$demerit += $this->evaluateSymbol($width, $mask);
if ($demerit < $minDemerit) {
$minDemerit = $demerit;
$bestMask = $mask;
$bestMaskNum = $i;
}
}
return $bestMask;
}
// - - - - - - - - - - - - - - - - - - - - - - - - -
// QRsplit
/**
* Return true if the character at specified position is a number
* @param string $str string
* @param int $pos characted position
* @return boolean true of false
*/
protected function isdigitat($str, $pos) {
if ($pos >= strlen($str)) {
return false;
}
return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9')));
}
/**
* Return true if the character at specified position is an alphanumeric character
* @param string $str string
* @param int $pos characted position
* @return boolean true of false
*/
protected function isalnumat($str, $pos) {
if ($pos >= strlen($str)) {
return false;
}
return ($this->lookAnTable(ord($str[$pos])) >= 0);
}
/**
* identifyMode
* @param int $pos
* @return int mode
*/
protected function identifyMode($pos) {
if ($pos >= strlen($this->dataStr)) {
return QR_MODE_NL;
}
$c = $this->dataStr[$pos];
if ($this->isdigitat($this->dataStr, $pos)) {
return QR_MODE_NM;
} elseif ($this->isalnumat($this->dataStr, $pos)) {
return QR_MODE_AN;
} elseif ($this->hint == QR_MODE_KJ) {
if ($pos+1 < strlen($this->dataStr)) {
$d = $this->dataStr[$pos+1];
$word = (ord($c) << 8) | ord($d);
if (($word >= 0x8140 && $word <= 0x9ffc) OR ($word >= 0xe040 && $word <= 0xebbf)) {
return QR_MODE_KJ;
}
}
}
return QR_MODE_8B;
}
/**
* eatNum
* @return int run
*/
protected function eatNum() {
$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
$p = 0;
while($this->isdigitat($this->dataStr, $p)) {
$p++;
}
$run = $p;
$mode = $this->identifyMode($p);
if ($mode == QR_MODE_8B) {
$dif = $this->estimateBitsModeNum($run) + 4 + $ln
+ $this->estimateBitsMode8(1) // + 4 + l8
- $this->estimateBitsMode8($run + 1); // - 4 - l8
if ($dif > 0) {
return $this->eat8();
}
}
if ($mode == QR_MODE_AN) {
$dif = $this->estimateBitsModeNum($run) + 4 + $ln
+ $this->estimateBitsModeAn(1) // + 4 + la
- $this->estimateBitsModeAn($run + 1);// - 4 - la
if ($dif > 0) {
return $this->eatAn();
}
}
$this->items = $this->appendNewInputItem($this->items, QR_MODE_NM, $run, str_split($this->dataStr));
return $run;
}
/**
* eatAn
* @return int run
*/
protected function eatAn() {
$la = $this->lengthIndicator(QR_MODE_AN, $this->version);
$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
$p = 0;
while($this->isalnumat($this->dataStr, $p)) {
if ($this->isdigitat($this->dataStr, $p)) {
$q = $p;
while($this->isdigitat($this->dataStr, $q)) {
$q++;
}
$dif = $this->estimateBitsModeAn($p) // + 4 + la
+ $this->estimateBitsModeNum($q - $p) + 4 + $ln
- $this->estimateBitsModeAn($q); // - 4 - la
if ($dif < 0) {
break;
} else {
$p = $q;
}
} else {
$p++;
}
}
$run = $p;
if (!$this->isalnumat($this->dataStr, $p)) {
$dif = $this->estimateBitsModeAn($run) + 4 + $la
+ $this->estimateBitsMode8(1) // + 4 + l8
- $this->estimateBitsMode8($run + 1); // - 4 - l8
if ($dif > 0) {
return $this->eat8();
}
}
$this->items = $this->appendNewInputItem($this->items, QR_MODE_AN, $run, str_split($this->dataStr));
return $run;
}
/**
* eatKanji
* @return int run
*/
protected function eatKanji() {
$p = 0;
while($this->identifyMode($p) == QR_MODE_KJ) {
$p += 2;
}
$this->items = $this->appendNewInputItem($this->items, QR_MODE_KJ, $p, str_split($this->dataStr));
return $run;
}
/**
* eat8
* @return int run
*/
protected function eat8() {
$la = $this->lengthIndicator(QR_MODE_AN, $this->version);
$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
$p = 1;
$dataStrLen = strlen($this->dataStr);
while($p < $dataStrLen) {
$mode = $this->identifyMode($p);
if ($mode == QR_MODE_KJ) {
break;
}
if ($mode == QR_MODE_NM) {
$q = $p;
while($this->isdigitat($this->dataStr, $q)) {
$q++;
}
$dif = $this->estimateBitsMode8($p) // + 4 + l8
+ $this->estimateBitsModeNum($q - $p) + 4 + $ln
- $this->estimateBitsMode8($q); // - 4 - l8
if ($dif < 0) {
break;
} else {
$p = $q;
}
} elseif ($mode == QR_MODE_AN) {
$q = $p;
while($this->isalnumat($this->dataStr, $q)) {
$q++;
}
$dif = $this->estimateBitsMode8($p) // + 4 + l8
+ $this->estimateBitsModeAn($q - $p) + 4 + $la
- $this->estimateBitsMode8($q); // - 4 - l8
if ($dif < 0) {
break;
} else {
$p = $q;
}
} else {
$p++;
}
}
$run = $p;
$this->items = $this->appendNewInputItem($this->items, QR_MODE_8B, $run, str_split($this->dataStr));
return $run;
}
/**
* splitString
*/
protected function splitString() {
while (strlen($this->dataStr) > 0) {
if ($this->dataStr == '') {
return 0;
}
$mode = $this->identifyMode(0);
switch ($mode) {
case QR_MODE_NM: {
$length = $this->eatNum();
break;
}
case QR_MODE_AN: {
$length = $this->eatAn();
break;
}
case QR_MODE_KJ: {
if ($hint == QR_MODE_KJ) {
$length = $this->eatKanji();
} else {
$length = $this->eat8();
}
break;
}
default: {
$length = $this->eat8();
break;
}
}
if ($length == 0) {
return 0;
}
if ($length < 0) {
return -1;
}
$this->dataStr = substr($this->dataStr, $length);
}
}
/**
* toUpper
*/
protected function toUpper() {
$stringLen = strlen($this->dataStr);
$p = 0;
while ($p < $stringLen) {
$mode = $this->identifyMode(substr($this->dataStr, $p), $this->hint);
if ($mode == QR_MODE_KJ) {
$p += 2;
} else {
if ((ord($this->dataStr[$p]) >= ord('a')) AND (ord($this->dataStr[$p]) <= ord('z'))) {
$this->dataStr[$p] = chr(ord($this->dataStr[$p]) - 32);
}
$p++;
}
}
return $this->dataStr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - -
// QRinputItem
/**
* newInputItem
* @param int $mode
* @param int $size
* @param array $data
* @param array $bstream
* @return array input item
*/
protected function newInputItem($mode, $size, $data, $bstream=null) {
$setData = array_slice($data, 0, $size);
if (count($setData) < $size) {
$setData = array_merge($setData, array_fill(0, ($size - count($setData)), 0));
}
if (!$this->check($mode, $size, $setData)) {
return NULL;
}
$inputitem = array();
$inputitem['mode'] = $mode;
$inputitem['size'] = $size;
$inputitem['data'] = $setData;
$inputitem['bstream'] = $bstream;
return $inputitem;
}
/**
* encodeModeNum
* @param array $inputitem
* @param int $version
* @return array input item
*/
protected function encodeModeNum($inputitem, $version) {
$words = (int)($inputitem['size'] / 3);
$inputitem['bstream'] = array();
$val = 0x1;
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val);
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_NM, $version), $inputitem['size']);
for ($i=0; $i < $words; ++$i) {
$val = (ord($inputitem['data'][$i*3 ]) - ord('0')) * 100;
$val += (ord($inputitem['data'][$i*3+1]) - ord('0')) * 10;
$val += (ord($inputitem['data'][$i*3+2]) - ord('0'));
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 10, $val);
}
if ($inputitem['size'] - $words * 3 == 1) {
$val = ord($inputitem['data'][$words*3]) - ord('0');
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, $val);
} elseif (($inputitem['size'] - ($words * 3)) == 2) {
$val = (ord($inputitem['data'][$words*3 ]) - ord('0')) * 10;
$val += (ord($inputitem['data'][$words*3+1]) - ord('0'));
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 7, $val);
}
return $inputitem;
}
/**
* encodeModeAn
* @param array $inputitem
* @param int $version
* @return array input item
*/
protected function encodeModeAn($inputitem, $version) {
$words = (int)($inputitem['size'] / 2);
$inputitem['bstream'] = array();
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x02);
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_AN, $version), $inputitem['size']);
for ($i=0; $i < $words; ++$i) {
$val = (int)$this->lookAnTable(ord($inputitem['data'][$i*2 ])) * 45;
$val += (int)$this->lookAnTable(ord($inputitem['data'][$i*2+1]));
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 11, $val);
}
if ($inputitem['size'] & 1) {
$val = $this->lookAnTable(ord($inputitem['data'][($words * 2)]));
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 6, $val);
}
return $inputitem;
}
/**
* encodeMode8
* @param array $inputitem
* @param int $version
* @return array input item
*/
protected function encodeMode8($inputitem, $version) {
$inputitem['bstream'] = array();
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x4);
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_8B, $version), $inputitem['size']);
for ($i=0; $i < $inputitem['size']; ++$i) {
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord($inputitem['data'][$i]));
}
return $inputitem;
}
/**
* encodeModeKanji
* @param array $inputitem
* @param int $version
* @return array input item
*/
protected function encodeModeKanji($inputitem, $version) {
$inputitem['bstream'] = array();
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x8);
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int)($inputitem['size'] / 2));
for ($i=0; $i<$inputitem['size']; $i+=2) {
$val = (ord($inputitem['data'][$i]) << 8) | ord($inputitem['data'][$i+1]);
if ($val <= 0x9ffc) {
$val -= 0x8140;
} else {
$val -= 0xc140;
}
$h = ($val >> 8) * 0xc0;
$val = ($val & 0xff) + $h;
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 13, $val);
}
return $inputitem;
}
/**
* encodeModeStructure
* @param array $inputitem
* @return array input item
*/
protected function encodeModeStructure($inputitem) {
$inputitem['bstream'] = array();
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x03);
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, ord($inputitem['data'][1]) - 1);
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, ord($inputitem['data'][0]) - 1);
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 8, ord($inputitem['data'][2]));
return $inputitem;
}
/**
* encodeBitStream
* @param array $inputitem
* @param int $version
* @return array input item
*/
protected function encodeBitStream($inputitem, $version) {
$inputitem['bstream'] = array();
$words = $this->maximumWords($inputitem['mode'], $version);
if ($inputitem['size'] > $words) {
$st1 = $this->newInputItem($inputitem['mode'], $words, $inputitem['data']);
$st2 = $this->newInputItem($inputitem['mode'], $inputitem['size'] - $words, array_slice($inputitem['data'], $words));
$st1 = $this->encodeBitStream($st1, $version);
$st2 = $this->encodeBitStream($st2, $version);
$inputitem['bstream'] = array();
$inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st1['bstream']);
$inputitem['bstream'] = $this->appendBitstream($inputitem['bstream'], $st2['bstream']);
} else {
switch($inputitem['mode']) {
case QR_MODE_NM: {
$inputitem = $this->encodeModeNum($inputitem, $version);
break;
}
case QR_MODE_AN: {
$inputitem = $this->encodeModeAn($inputitem, $version);
break;
}
case QR_MODE_8B: {
$inputitem = $this->encodeMode8($inputitem, $version);
break;
}
case QR_MODE_KJ: {
$inputitem = $this->encodeModeKanji($inputitem, $version);
break;
}
case QR_MODE_ST: {
$inputitem = $this->encodeModeStructure($inputitem);
break;
}
default: {
break;
}
}
}
return $inputitem;
}
// - - - - - - - - - - - - - - - - - - - - - - - - -
// QRinput
/**
* Append data to an input object.
* The data is copied and appended to the input object.
* @param array items input items
* @param int $mode encoding mode.
* @param int $size size of data (byte).
* @param array $data array of input data.
* @return items
*
*/
protected function appendNewInputItem($items, $mode, $size, $data) {
$items[] = $this->newInputItem($mode, $size, $data);
return $items;
}
/**
* insertStructuredAppendHeader
* @param array $items
* @param int $size
* @param int $index
* @param int $parity
* @return array items
*/
protected function insertStructuredAppendHeader($items, $size, $index, $parity) {
if ($size > MAX_STRUCTURED_SYMBOLS) {
return -1;
}
if (($index <= 0) OR ($index > MAX_STRUCTURED_SYMBOLS)) {
return -1;
}
$buf = array($size, $index, $parity);
$entry = $this->newInputItem(QR_MODE_ST, 3, buf);
array_unshift($items, $entry);
return $items;
}
/**
* calcParity
* @param array $items
* @return int parity
*/
protected function calcParity($items) {
$parity = 0;
foreach ($items as $item) {
if ($item['mode'] != QR_MODE_ST) {
for ($i=$item['size']-1; $i>=0; --$i) {
$parity ^= $item['data'][$i];
}
}
}
return $parity;
}
/**
* checkModeNum
* @param int $size
* @param array $data
* @return boolean true or false
*/
protected function checkModeNum($size, $data) {
for ($i=0; $i<$size; ++$i) {
if ((ord($data[$i]) < ord('0')) OR (ord($data[$i]) > ord('9'))){
return false;
}
}
return true;
}
/**
* estimateBitsModeNum
* @param int $size
* @return int number of bits
*/
protected function estimateBitsModeNum($size) {
$w = (int)$size / 3;
$bits = $w * 10;
switch($size - $w * 3) {
case 1: {
$bits += 4;
break;
}
case 2: {
$bits += 7;
break;
}
default: {
break;
}
}
return $bits;
}
/**
* Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19).
* @param int $c character value
* @return value
*/
protected function lookAnTable($c) {
return (($c > 127)?-1:$this->anTable[$c]);
}
/**
* checkModeAn
* @param int $size
* @param array $data
* @return boolean true or false
*/
protected function checkModeAn($size, $data) {
for ($i=0; $i<$size; ++$i) {
if ($this->lookAnTable(ord($data[$i])) == -1) {
return false;
}
}
return true;
}
/**
* estimateBitsModeAn
* @param int $size
* @return int number of bits
*/
protected function estimateBitsModeAn($size) {
$w = (int)($size / 2);
$bits = $w * 11;
if ($size & 1) {
$bits += 6;
}
return $bits;
}
/**
* estimateBitsMode8
* @param int $size
* @return int number of bits
*/
protected function estimateBitsMode8($size) {
return $size * 8;
}
/**
* estimateBitsModeKanji
* @param int $size
* @return int number of bits
*/
protected function estimateBitsModeKanji($size) {
return (int)(($size / 2) * 13);
}
/**
* checkModeKanji
* @param int $size
* @param array $data
* @return boolean true or false
*/
protected function checkModeKanji($size, $data) {
if ($size & 1) {
return false;
}
for ($i=0; $i<$size; $i+=2) {
$val = (ord($data[$i]) << 8) | ord($data[$i+1]);
if (($val < 0x8140) OR (($val > 0x9ffc) AND ($val < 0xe040)) OR ($val > 0xebbf)) {
return false;
}
}
return true;
}
/**
* Validate the input data.
* @param int $mode encoding mode.
* @param int $size size of data (byte).
* @param array data data to validate
* @return boolean true in case of valid data, false otherwise
*/
protected function check($mode, $size, $data) {
if ($size <= 0) {
return false;
}
switch($mode) {
case QR_MODE_NM: {
return $this->checkModeNum($size, $data);
}
case QR_MODE_AN: {
return $this->checkModeAn($size, $data);
}
case QR_MODE_KJ: {
return $this->checkModeKanji($size, $data);
}
case QR_MODE_8B: {
return true;
}
case QR_MODE_ST: {
return true;
}
default: {
break;
}
}
return false;
}
/**
* estimateBitStreamSize
* @param array $items
* @param int $version
* @return int bits
*/
protected function estimateBitStreamSize($items, $version) {
$bits = 0;
if ($version == 0) {
$version = 1;
}
foreach ($items as $item) {
switch($item['mode']) {
case QR_MODE_NM: {
$bits = $this->estimateBitsModeNum($item['size']);
break;
}
case QR_MODE_AN: {
$bits = $this->estimateBitsModeAn($item['size']);
break;
}
case QR_MODE_8B: {
$bits = $this->estimateBitsMode8($item['size']);
break;
}
case QR_MODE_KJ: {
$bits = $this->estimateBitsModeKanji($item['size']);
break;
}
case QR_MODE_ST: {
return STRUCTURE_HEADER_BITS;
}
default: {
return 0;
}
}
$l = $this->lengthIndicator($item['mode'], $version);
$m = 1 << $l;
$num = (int)(($item['size'] + $m - 1) / $m);
$bits += $num * (4 + $l);
}
return $bits;
}
/**
* estimateVersion
* @param array $items
* @return int version
*/
protected function estimateVersion($items) {
$version = 0;
$prev = 0;
do {
$prev = $version;
$bits = $this->estimateBitStreamSize($items, $prev);
$version = $this->getMinimumVersion((int)(($bits + 7) / 8), $this->level);
if ($version < 0) {
return -1;
}
} while ($version > $prev);
return $version;
}
/**
* lengthOfCode
* @param int $mode
* @param int $version
* @param int $bits
* @return int size
*/
protected function lengthOfCode($mode, $version, $bits) {
$payload = $bits - 4 - $this->lengthIndicator($mode, $version);
switch($mode) {
case QR_MODE_NM: {
$chunks = (int)($payload / 10);
$remain = $payload - $chunks * 10;
$size = $chunks * 3;
if ($remain >= 7) {
$size += 2;
} elseif ($remain >= 4) {
$size += 1;
}
break;
}
case QR_MODE_AN: {
$chunks = (int)($payload / 11);
$remain = $payload - $chunks * 11;
$size = $chunks * 2;
if ($remain >= 6) {
++$size;
}
break;
}
case QR_MODE_8B: {
$size = (int)($payload / 8);
break;
}
case QR_MODE_KJ: {
$size = (int)(($payload / 13) * 2);
break;
}
case QR_MODE_ST: {
$size = (int)($payload / 8);
break;
}
default: {
$size = 0;
break;
}
}
$maxsize = $this->maximumWords($mode, $version);
if ($size < 0) {
$size = 0;
}
if ($size > $maxsize) {
$size = $maxsize;
}
return $size;
}
/**
* createBitStream
* @param array $items
* @return array of items and total bits
*/
protected function createBitStream($items) {
$total = 0;
foreach ($items as $key => $item) {
$items[$key] = $this->encodeBitStream($item, $this->version);
$bits = count($items[$key]['bstream']);
$total += $bits;
}
return array($items, $total);
}
/**
* convertData
* @param array $items
* @return array items
*/
protected function convertData($items) {
$ver = $this->estimateVersion($items);
if ($ver > $this->version) {
$this->version = $ver;
}
for (;;) {
$cbs = $this->createBitStream($items);
$items = $cbs[0];
$bits = $cbs[1];
if ($bits < 0) {
return -1;
}
$ver = $this->getMinimumVersion((int)(($bits + 7) / 8), $this->level);
if ($ver < 0) {
return -1;
} elseif ($ver > $this->version) {
$this->version = $ver;
} else {
break;
}
}
return $items;
}
/**
* Append Padding Bit to bitstream
* @param array $bstream
* @return array bitstream
*/
protected function appendPaddingBit($bstream) {
if (is_null($bstream)) {
return null;
}
$bits = count($bstream);
$maxwords = $this->getDataLength($this->version, $this->level);
$maxbits = $maxwords * 8;
if ($maxbits == $bits) {
return 0;
}
if ($maxbits - $bits < 5) {
return $this->appendNum($bstream, $maxbits - $bits, 0);
}
$bits += 4;
$words = (int)(($bits + 7) / 8);
$padding = array();
$padding = $this->appendNum($padding, $words * 8 - $bits + 4, 0);
$padlen = $maxwords - $words;
if ($padlen > 0) {
$padbuf = array();
for ($i=0; $i<$padlen; ++$i) {
$padbuf[$i] = ($i&1)?0x11:0xec;
}
$padding = $this->appendBytes($padding, $padlen, $padbuf);
}
return $this->appendBitstream($bstream, $padding);
}
/**
* mergeBitStream
* @param array $bstream
* @return array bitstream
*/
protected function mergeBitStream($items) {
$items = $this->convertData($items);
if (!is_array($items)) {
return null;
}
$bstream = array();
foreach ($items as $item) {
$bstream = $this->appendBitstream($bstream, $item['bstream']);
}
return $bstream;
}
/**
* Returns a stream of bits.
* @param int $items
* @return array padded merged byte stream
*/
protected function getBitStream($items) {
$bstream = $this->mergeBitStream($items);
return $this->appendPaddingBit($bstream);
}
/**
* Pack all bit streams padding bits into a byte array.
* @param int $items
* @return array padded merged byte stream
*/
protected function getByteStream($items) {
$bstream = $this->getBitStream($items);
return $this->bitstreamToByte($bstream);
}
// - - - - - - - - - - - - - - - - - - - - - - - - -
// QRbitstream
/**
* Return an array with zeros
* @param int $setLength array size
* @return array
*/
protected function allocate($setLength) {
return array_fill(0, $setLength, 0);
}
/**
* Return new bitstream from number
* @param int $bits number of bits
* @param int $num number
* @return array bitstream
*/
protected function newFromNum($bits, $num) {
$bstream = $this->allocate($bits);
$mask = 1 << ($bits - 1);
for ($i=0; $i<$bits; ++$i) {
if ($num & $mask) {
$bstream[$i] = 1;
} else {
$bstream[$i] = 0;
}
$mask = $mask >> 1;
}
return $bstream;
}
/**
* Return new bitstream from bytes
* @param int $size size
* @param array $data bytes
* @return array bitstream
*/
protected function newFromBytes($size, $data) {
$bstream = $this->allocate($size * 8);
$p=0;
for ($i=0; $i<$size; ++$i) {
$mask = 0x80;
for ($j=0; $j<8; ++$j) {
if ($data[$i] & $mask) {
$bstream[$p] = 1;
} else {
$bstream[$p] = 0;
}
$p++;
$mask = $mask >> 1;
}
}
return $bstream;
}
/**
* Append one bitstream to another
* @param array $bitstream original bitstream
* @param array $append bitstream to append
* @return array bitstream
*/
protected function appendBitstream($bitstream, $append) {
if ((!is_array($append)) OR (count($append) == 0)) {
return $bitstream;
}
if (count($bitstream) == 0) {
return $append;
}
return array_values(array_merge($bitstream, $append));
}
/**
* Append one bitstream created from number to another
* @param array $bitstream original bitstream
* @param int $bits number of bits
* @param int $num number
* @return array bitstream
*/
protected function appendNum($bitstream, $bits, $num) {
if ($bits == 0) {
return 0;
}
$b = $this->newFromNum($bits, $num);
return $this->appendBitstream($bitstream, $b);
}
/**
* Append one bitstream created from bytes to another
* @param array $bitstream original bitstream
* @param int $size size
* @param array $data bytes
* @return array bitstream
*/
protected function appendBytes($bitstream, $size, $data) {
if ($size == 0) {
return 0;
}
$b = $this->newFromBytes($size, $data);
return $this->appendBitstream($bitstream, $b);
}
/**
* Convert bitstream to bytes
* @param array $bitstream original bitstream
* @return array of bytes
*/
protected function bitstreamToByte($bstream) {
if (is_null($bstream)) {
return null;
}
$size = count($bstream);
if ($size == 0) {
return array();
}
$data = array_fill(0, (int)(($size + 7) / 8), 0);
$bytes = (int)($size / 8);
$p = 0;
for ($i=0; $i<$bytes; $i++) {
$v = 0;
for ($j=0; $j<8; $j++) {
$v = $v << 1;
$v |= $bstream[$p];
$p++;
}
$data[$i] = $v;
}
if ($size & 7) {
$v = 0;
for ($j=0; $j<($size & 7); $j++) {
$v = $v << 1;
$v |= $bstream[$p];
$p++;
}
$data[$bytes] = $v;
}
return $data;
}
// - - - - - - - - - - - - - - - - - - - - - - - - -
// QRspec
/**
* Replace a value on the array at the specified position
* @param array $srctab
* @param int $x X position
* @param int $y Y position
* @param string $repl value to replace
* @param int $replLen length of the repl string
* @return array srctab
*/
protected function qrstrset($srctab, $x, $y, $repl, $replLen=false) {
$srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl));
return $srctab;
}
/**
* Return maximum data code length (bytes) for the version.
* @param int $version version
* @param int $level error correction level
* @return int maximum size (bytes)
*/
protected function getDataLength($version, $level) {
return $this->capacity[$version][QRCAP_WORDS] - $this->capacity[$version][QRCAP_EC][$level];
}
/**
* Return maximum error correction code length (bytes) for the version.
* @param int $version version
* @param int $level error correction level
* @return int ECC size (bytes)
*/
protected function getECCLength($version, $level){
return $this->capacity[$version][QRCAP_EC][$level];
}
/**
* Return the width of the symbol for the version.
* @param int $version version
* @return int width
*/
protected function getWidth($version) {
return $this->capacity[$version][QRCAP_WIDTH];
}
/**
* Return the numer of remainder bits.
* @param int $version version
* @return int number of remainder bits
*/
protected function getRemainder($version) {
return $this->capacity[$version][QRCAP_REMINDER];
}
/**
* Return a version number that satisfies the input code length.
* @param int $size input code length (byte)
* @param int $level error correction level
* @return int version number
*/
protected function getMinimumVersion($size, $level) {
for ($i=1; $i <= QRSPEC_VERSION_MAX; ++$i) {
$words = $this->capacity[$i][QRCAP_WORDS] - $this->capacity[$i][QRCAP_EC][$level];
if ($words >= $size) {
return $i;
}
}
return -1;
}
/**
* Return the size of length indicator for the mode and version.
* @param int $mode encoding mode
* @param int $version version
* @return int the size of the appropriate length indicator (bits).
*/
protected function lengthIndicator($mode, $version) {
if ($mode == QR_MODE_ST) {
return 0;
}
if ($version <= 9) {
$l = 0;
} elseif ($version <= 26) {
$l = 1;
} else {
$l = 2;
}
return $this->lengthTableBits[$mode][$l];
}
/**
* Return the maximum length for the mode and version.
* @param int $mode encoding mode
* @param int $version version
* @return int the maximum length (bytes)
*/
protected function maximumWords($mode, $version) {
if ($mode == QR_MODE_ST) {
return 3;
}
if ($version <= 9) {
$l = 0;
} else if ($version <= 26) {
$l = 1;
} else {
$l = 2;
}
$bits = $this->lengthTableBits[$mode][$l];
$words = (1 << $bits) - 1;
if ($mode == QR_MODE_KJ) {
$words *= 2; // the number of bytes is required
}
return $words;
}
/**
* Return an array of ECC specification.
* @param int $version version
* @param int $level error correction level
* @param array $spec an array of ECC specification contains as following: {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code}
* @return array spec
*/
protected function getEccSpec($version, $level, $spec) {
if (count($spec) < 5) {
$spec = array(0, 0, 0, 0, 0);
}
$b1 = $this->eccTable[$version][$level][0];
$b2 = $this->eccTable[$version][$level][1];
$data = $this->getDataLength($version, $level);
$ecc = $this->getECCLength($version, $level);
if ($b2 == 0) {
$spec[0] = $b1;
$spec[1] = (int)($data / $b1);
$spec[2] = (int)($ecc / $b1);
$spec[3] = 0;
$spec[4] = 0;
} else {
$spec[0] = $b1;
$spec[1] = (int)($data / ($b1 + $b2));
$spec[2] = (int)($ecc / ($b1 + $b2));
$spec[3] = $b2;
$spec[4] = $spec[1] + 1;
}
return $spec;
}
/**
* Put an alignment marker.
* @param array $frame frame
* @param int $width width
* @param int $ox X center coordinate of the pattern
* @param int $oy Y center coordinate of the pattern
* @return array frame
*/
protected function putAlignmentMarker($frame, $ox, $oy) {
$finder = array(
"\xa1\xa1\xa1\xa1\xa1",
"\xa1\xa0\xa0\xa0\xa1",
"\xa1\xa0\xa1\xa0\xa1",
"\xa1\xa0\xa0\xa0\xa1",
"\xa1\xa1\xa1\xa1\xa1"
);
$yStart = $oy - 2;
$xStart = $ox - 2;
for ($y=0; $y < 5; $y++) {
$frame = $this->qrstrset($frame, $xStart, $yStart+$y, $finder[$y]);
}
return $frame;
}
/**
* Put an alignment pattern.
* @param int $version version
* @param array $fram frame
* @param int $width width
* @return array frame
*/
protected function putAlignmentPattern($version, $frame, $width) {
if ($version < 2) {
return $frame;
}
$d = $this->alignmentPattern[$version][1] - $this->alignmentPattern[$version][0];
if ($d < 0) {
$w = 2;
} else {
$w = (int)(($width - $this->alignmentPattern[$version][0]) / $d + 2);
}
if ($w * $w - 3 == 1) {
$x = $this->alignmentPattern[$version][0];
$y = $this->alignmentPattern[$version][0];
$frame = $this->putAlignmentMarker($frame, $x, $y);
return $frame;
}
$cx = $this->alignmentPattern[$version][0];
$wo = $w - 1;
for ($x=1; $x < $wo; ++$x) {
$frame = $this->putAlignmentMarker($frame, 6, $cx);
$frame = $this->putAlignmentMarker($frame, $cx, 6);
$cx += $d;
}
$cy = $this->alignmentPattern[$version][0];
for ($y=0; $y < $wo; ++$y) {
$cx = $this->alignmentPattern[$version][0];
for ($x=0; $x < $wo; ++$x) {
$frame = $this->putAlignmentMarker($frame, $cx, $cy);
$cx += $d;
}
$cy += $d;
}
return $frame;
}
/**
* Return BCH encoded version information pattern that is used for the symbol of version 7 or greater. Use lower 18 bits.
* @param int $version version
* @return BCH encoded version information pattern
*/
protected function getVersionPattern($version) {
if (($version < 7) OR ($version > QRSPEC_VERSION_MAX)) {
return 0;
}
return $this->versionPattern[($version - 7)];
}
/**
* Return BCH encoded format information pattern.
* @param array $mask
* @param int $level error correction level
* @return BCH encoded format information pattern
*/
protected function getFormatInfo($mask, $level) {
if (($mask < 0) OR ($mask > 7)) {
return 0;
}
if (($level < 0) OR ($level > 3)) {
return 0;
}
return $this->formatInfo[$level][$mask];
}
/**
* Put a finder pattern.
* @param array $frame frame
* @param int $width width
* @param int $ox X center coordinate of the pattern
* @param int $oy Y center coordinate of the pattern
* @return array frame
*/
protected function putFinderPattern($frame, $ox, $oy) {
$finder = array(
"\xc1\xc1\xc1\xc1\xc1\xc1\xc1",
"\xc1\xc0\xc0\xc0\xc0\xc0\xc1",
"\xc1\xc0\xc1\xc1\xc1\xc0\xc1",
"\xc1\xc0\xc1\xc1\xc1\xc0\xc1",
"\xc1\xc0\xc1\xc1\xc1\xc0\xc1",
"\xc1\xc0\xc0\xc0\xc0\xc0\xc1",
"\xc1\xc1\xc1\xc1\xc1\xc1\xc1"
);
for ($y=0; $y < 7; $y++) {
$frame = $this->qrstrset($frame, $ox, ($oy + $y), $finder[$y]);
}
return $frame;
}
/**
* Return a copy of initialized frame.
* @param int $version version
* @return Array of unsigned char.
*/
protected function createFrame($version) {
$width = $this->capacity[$version][QRCAP_WIDTH];
$frameLine = str_repeat ("\0", $width);
$frame = array_fill(0, $width, $frameLine);
// Finder pattern
$frame = $this->putFinderPattern($frame, 0, 0);
$frame = $this->putFinderPattern($frame, $width - 7, 0);
$frame = $this->putFinderPattern($frame, 0, $width - 7);
// Separator
$yOffset = $width - 7;
for ($y=0; $y < 7; ++$y) {
$frame[$y][7] = "\xc0";
$frame[$y][$width - 8] = "\xc0";
$frame[$yOffset][7] = "\xc0";
++$yOffset;
}
$setPattern = str_repeat("\xc0", 8);
$frame = $this->qrstrset($frame, 0, 7, $setPattern);
$frame = $this->qrstrset($frame, $width-8, 7, $setPattern);
$frame = $this->qrstrset($frame, 0, $width - 8, $setPattern);
// Format info
$setPattern = str_repeat("\x84", 9);
$frame = $this->qrstrset($frame, 0, 8, $setPattern);
$frame = $this->qrstrset($frame, $width - 8, 8, $setPattern, 8);
$yOffset = $width - 8;
for ($y=0; $y < 8; ++$y,++$yOffset) {
$frame[$y][8] = "\x84";
$frame[$yOffset][8] = "\x84";
}
// Timing pattern
$wo = $width - 15;
for ($i=1; $i < $wo; ++$i) {
$frame[6][7+$i] = chr(0x90 | ($i & 1));
$frame[7+$i][6] = chr(0x90 | ($i & 1));
}
// Alignment pattern
$frame = $this->putAlignmentPattern($version, $frame, $width);
// Version information
if ($version >= 7) {
$vinf = $this->getVersionPattern($version);
$v = $vinf;
for ($x=0; $x<6; ++$x) {
for ($y=0; $y<3; ++$y) {
$frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1));
$v = $v >> 1;
}
}
$v = $vinf;
for ($y=0; $y<6; ++$y) {
for ($x=0; $x<3; ++$x) {
$frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1));
$v = $v >> 1;
}
}
}
// and a little bit...
$frame[$width - 8][8] = "\x81";
return $frame;
}
/**
* Set new frame for the specified version.
* @param int $version version
* @return Array of unsigned char.
*/
protected function newFrame($version) {
if (($version < 1) OR ($version > QRSPEC_VERSION_MAX)) {
return NULL;
}
if (!isset($this->frames[$version])) {
$this->frames[$version] = $this->createFrame($version);
}
if (is_null($this->frames[$version])) {
return NULL;
}
return $this->frames[$version];
}
/**
* Return block number 0
* @param array $spec
* @return int value
*/
protected function rsBlockNum($spec) {
return ($spec[0] + $spec[3]);
}
/**
* Return block number 1
* @param array $spec
* @return int value
*/
protected function rsBlockNum1($spec) {
return $spec[0];
}
/**
* Return data codes 1
* @param array $spec
* @return int value
*/
protected function rsDataCodes1($spec) {
return $spec[1];
}
/**
* Return ecc codes 1
* @param array $spec
* @return int value
*/
protected function rsEccCodes1($spec) {
return $spec[2];
}
/**
* Return block number 2
* @param array $spec
* @return int value
*/
protected function rsBlockNum2($spec) {
return $spec[3];
}
/**
* Return data codes 2
* @param array $spec
* @return int value
*/
protected function rsDataCodes2($spec) {
return $spec[4];
}
/**
* Return ecc codes 2
* @param array $spec
* @return int value
*/
protected function rsEccCodes2($spec) {
return $spec[2];
}
/**
* Return data length
* @param array $spec
* @return int value
*/
protected function rsDataLength($spec) {
return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]);
}
/**
* Return ecc length
* @param array $spec
* @return int value
*/
protected function rsEccLength($spec) {
return ($spec[0] + $spec[3]) * $spec[2];
}
// - - - - - - - - - - - - - - - - - - - - - - - - -
// QRrs
/**
* Initialize a Reed-Solomon codec and add it to existing rsitems
* @param int $symsize symbol size, bits
* @param int $gfpoly Field generator polynomial coefficients
* @param int $fcr first root of RS code generator polynomial, index form
* @param int $prim primitive element to generate polynomial roots
* @param int $nroots RS code generator polynomial degree (number of roots)
* @param int $pad padding bytes at front of shortened block
* @return array Array of RS values:<ul><li>mm = Bits per symbol;</li><li>nn = Symbols per block;</li><li>alpha_to = log lookup table array;</li><li>index_of = Antilog lookup table array;</li><li>genpoly = Generator polynomial array;</li><li>nroots = Number of generator;</li><li>roots = number of parity symbols;</li><li>fcr = First consecutive root, index form;</li><li>prim = Primitive element, index form;</li><li>iprim = prim-th root of 1, index form;</li><li>pad = Padding bytes in shortened block;</li><li>gfpoly</ul>.
*/
protected function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) {
foreach ($this->rsitems as $rs) {
if (($rs['pad'] != $pad) OR ($rs['nroots'] != $nroots) OR ($rs['mm'] != $symsize)
OR ($rs['gfpoly'] != $gfpoly) OR ($rs['fcr'] != $fcr) OR ($rs['prim'] != $prim)) {
continue;
}
return $rs;
}
$rs = $this->init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad);
array_unshift($this->rsitems, $rs);
return $rs;
}
// - - - - - - - - - - - - - - - - - - - - - - - - -
// QRrsItem
/**
* modnn
* @param array RS values
* @param int $x X position
* @return int X osition
*/
protected function modnn($rs, $x) {
while ($x >= $rs['nn']) {
$x -= $rs['nn'];
$x = ($x >> $rs['mm']) + ($x & $rs['nn']);
}
return $x;
}
/**
* Initialize a Reed-Solomon codec and returns an array of values.
* @param int $symsize symbol size, bits
* @param int $gfpoly Field generator polynomial coefficients
* @param int $fcr first root of RS code generator polynomial, index form
* @param int $prim primitive element to generate polynomial roots
* @param int $nroots RS code generator polynomial degree (number of roots)
* @param int $pad padding bytes at front of shortened block
* @return array Array of RS values:<ul><li>mm = Bits per symbol;</li><li>nn = Symbols per block;</li><li>alpha_to = log lookup table array;</li><li>index_of = Antilog lookup table array;</li><li>genpoly = Generator polynomial array;</li><li>nroots = Number of generator;</li><li>roots = number of parity symbols;</li><li>fcr = First consecutive root, index form;</li><li>prim = Primitive element, index form;</li><li>iprim = prim-th root of 1, index form;</li><li>pad = Padding bytes in shortened block;</li><li>gfpoly</ul>.
*/
protected function init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) {
// Based on Reed solomon encoder by Phil Karn, KA9Q (GNU-LGPLv2)
$rs = null;
// Check parameter ranges
if (($symsize < 0) OR ($symsize > 8)) {
return $rs;
}
if (($fcr < 0) OR ($fcr >= (1<<$symsize))) {
return $rs;
}
if (($prim <= 0) OR ($prim >= (1<<$symsize))) {
return $rs;
}
if (($nroots < 0) OR ($nroots >= (1<<$symsize))) {
return $rs;
}
if (($pad < 0) OR ($pad >= ((1<<$symsize) -1 - $nroots))) {
return $rs;
}
$rs = array();
$rs['mm'] = $symsize;
$rs['nn'] = (1 << $symsize) - 1;
$rs['pad'] = $pad;
$rs['alpha_to'] = array_fill(0, ($rs['nn'] + 1), 0);
$rs['index_of'] = array_fill(0, ($rs['nn'] + 1), 0);
// PHP style macro replacement ;)
$NN =& $rs['nn'];
$A0 =& $NN;
// Generate Galois field lookup tables
$rs['index_of'][0] = $A0; // log(zero) = -inf
$rs['alpha_to'][$A0] = 0; // alpha**-inf = 0
$sr = 1;
for ($i=0; $i<$rs['nn']; ++$i) {
$rs['index_of'][$sr] = $i;
$rs['alpha_to'][$i] = $sr;
$sr <<= 1;
if ($sr & (1 << $symsize)) {
$sr ^= $gfpoly;
}
$sr &= $rs['nn'];
}
if ($sr != 1) {
// field generator polynomial is not primitive!
return NULL;
}
// Form RS code generator polynomial from its roots
$rs['genpoly'] = array_fill(0, ($nroots + 1), 0);
$rs['fcr'] = $fcr;
$rs['prim'] = $prim;
$rs['nroots'] = $nroots;
$rs['gfpoly'] = $gfpoly;
// Find prim-th root of 1, used in decoding
for ($iprim=1; ($iprim % $prim) != 0; $iprim += $rs['nn']) {
; // intentional empty-body loop!
}
$rs['iprim'] = (int)($iprim / $prim);
$rs['genpoly'][0] = 1;
for ($i = 0,$root=$fcr*$prim; $i < $nroots; $i++, $root += $prim) {
$rs['genpoly'][$i+1] = 1;
// Multiply rs->genpoly[] by @**(root + x)
for ($j = $i; $j > 0; --$j) {
if ($rs['genpoly'][$j] != 0) {
$rs['genpoly'][$j] = $rs['genpoly'][$j-1] ^ $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][$j]] + $root)];
} else {
$rs['genpoly'][$j] = $rs['genpoly'][$j-1];
}
}
// rs->genpoly[0] can never be zero
$rs['genpoly'][0] = $rs['alpha_to'][$this->modnn($rs, $rs['index_of'][$rs['genpoly'][0]] + $root)];
}
// convert rs->genpoly[] to index form for quicker encoding
for ($i = 0; $i <= $nroots; ++$i) {
$rs['genpoly'][$i] = $rs['index_of'][$rs['genpoly'][$i]];
}
return $rs;
}
/**
* Encode a Reed-Solomon codec and returns the parity array
* @param array $rs RS values
* @param array $data data
* @param array $parity parity
* @return parity array
*/
protected function encode_rs_char($rs, $data, $parity) {
$MM =& $rs['mm']; // bits per symbol
$NN =& $rs['nn']; // the total number of symbols in a RS block
$ALPHA_TO =& $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form
$INDEX_OF =& $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form
$GENPOLY =& $rs['genpoly']; // an array of NROOTS+1 elements containing the generator polynomial in index form
$NROOTS =& $rs['nroots']; // the number of roots in the RS code generator polynomial, which is the same as the number of parity symbols in a block
$FCR =& $rs['fcr']; // first consecutive root, index form
$PRIM =& $rs['prim']; // primitive element, index form
$IPRIM =& $rs['iprim']; // prim-th root of 1, index form
$PAD =& $rs['pad']; // the number of pad symbols in a block
$A0 =& $NN;
$parity = array_fill(0, $NROOTS, 0);
for ($i=0; $i < ($NN - $NROOTS - $PAD); $i++) {
$feedback = $INDEX_OF[$data[$i] ^ $parity[0]];
if ($feedback != $A0) {
// feedback term is non-zero
// This line is unnecessary when GENPOLY[NROOTS] is unity, as it must
// always be for the polynomials constructed by init_rs()
$feedback = $this->modnn($rs, $NN - $GENPOLY[$NROOTS] + $feedback);
for ($j=1; $j < $NROOTS; ++$j) {
$parity[$j] ^= $ALPHA_TO[$this->modnn($rs, $feedback + $GENPOLY[($NROOTS - $j)])];
}
}
// Shift
array_shift($parity);
if ($feedback != $A0) {
array_push($parity, $ALPHA_TO[$this->modnn($rs, $feedback + $GENPOLY[0])]);
} else {
array_push($parity, 0);
}
}
return $parity;
}
} // end QRcode class
} // END OF "class_exists QRcode"
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/qrcode.php | PHP | asf20 | 83,191 |
<?php
//============================================================+
// File name : htmlcolors.php
// Version : 1.0.007
// Begin : 2002-04-09
// Last Update : 2010-10-18
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
// Copyright (C) 2002-2010 Nicola Asuni - Tecnick.com S.r.l.
//
// This file is part of TCPDF software library.
//
// TCPDF 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 3 of the
// License, or (at your option) any later version.
//
// TCPDF 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 TCPDF. If not, see <http://www.gnu.org/licenses/>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : Array of WEB safe colors
//
//============================================================+
/**
* Array of WEB safe colors.
* @author Nicola Asuni
* @copyright 2002-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @package com.tecnick.tcpdf
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @since 2.9.000 (2008-03-26)
*/
/**
* Array of WEB safe colors
*/
$webcolor = array (
'aliceblue' => 'f0f8ff',
'antiquewhite' => 'faebd7',
'aqua' => '00ffff',
'aquamarine' => '7fffd4',
'azure' => 'f0ffff',
'beige' => 'f5f5dc',
'bisque' => 'ffe4c4',
'black' => '000000',
'blanchedalmond' => 'ffebcd',
'blue' => '0000ff',
'blueviolet' => '8a2be2',
'brown' => 'a52a2a',
'burlywood' => 'deb887',
'cadetblue' => '5f9ea0',
'chartreuse' => '7fff00',
'chocolate' => 'd2691e',
'coral' => 'ff7f50',
'cornflowerblue' => '6495ed',
'cornsilk' => 'fff8dc',
'crimson' => 'dc143c',
'cyan' => '00ffff',
'darkblue' => '00008b',
'darkcyan' => '008b8b',
'darkgoldenrod' => 'b8860b',
'dkgray' => 'a9a9a9',
'darkgray' => 'a9a9a9',
'darkgrey' => 'a9a9a9',
'darkgreen' => '006400',
'darkkhaki' => 'bdb76b',
'darkmagenta' => '8b008b',
'darkolivegreen' => '556b2f',
'darkorange' => 'ff8c00',
'darkorchid' => '9932cc',
'darkred' => '8b0000',
'darksalmon' => 'e9967a',
'darkseagreen' => '8fbc8f',
'darkslateblue' => '483d8b',
'darkslategray' => '2f4f4f',
'darkslategrey' => '2f4f4f',
'darkturquoise' => '00ced1',
'darkviolet' => '9400d3',
'deeppink' => 'ff1493',
'deepskyblue' => '00bfff',
'dimgray' => '696969',
'dimgrey' => '696969',
'dodgerblue' => '1e90ff',
'firebrick' => 'b22222',
'floralwhite' => 'fffaf0',
'forestgreen' => '228b22',
'fuchsia' => 'ff00ff',
'gainsboro' => 'dcdcdc',
'ghostwhite' => 'f8f8ff',
'gold' => 'ffd700',
'goldenrod' => 'daa520',
'gray' => '808080',
'grey' => '808080',
'green' => '008000',
'greenyellow' => 'adff2f',
'honeydew' => 'f0fff0',
'hotpink' => 'ff69b4',
'indianred' => 'cd5c5c',
'indigo' => '4b0082',
'ivory' => 'fffff0',
'khaki' => 'f0e68c',
'lavender' => 'e6e6fa',
'lavenderblush' => 'fff0f5',
'lawngreen' => '7cfc00',
'lemonchiffon' => 'fffacd',
'lightblue' => 'add8e6',
'lightcoral' => 'f08080',
'lightcyan' => 'e0ffff',
'lightgoldenrodyellow' => 'fafad2',
'ltgray' => 'd3d3d3',
'lightgray' => 'd3d3d3',
'lightgrey' => 'd3d3d3',
'lightgreen' => '90ee90',
'lightpink' => 'ffb6c1',
'lightsalmon' => 'ffa07a',
'lightseagreen' => '20b2aa',
'lightskyblue' => '87cefa',
'lightslategray' => '778899',
'lightslategrey' => '778899',
'lightsteelblue' => 'b0c4de',
'lightyellow' => 'ffffe0',
'lime' => '00ff00',
'limegreen' => '32cd32',
'linen' => 'faf0e6',
'magenta' => 'ff00ff',
'maroon' => '800000',
'mediumaquamarine' => '66cdaa',
'mediumblue' => '0000cd',
'mediumorchid' => 'ba55d3',
'mediumpurple' => '9370d8',
'mediumseagreen' => '3cb371',
'mediumslateblue' => '7b68ee',
'mediumspringgreen' => '00fa9a',
'mediumturquoise' => '48d1cc',
'mediumvioletred' => 'c71585',
'midnightblue' => '191970',
'mintcream' => 'f5fffa',
'mistyrose' => 'ffe4e1',
'moccasin' => 'ffe4b5',
'navajowhite' => 'ffdead',
'navy' => '000080',
'oldlace' => 'fdf5e6',
'olive' => '808000',
'olivedrab' => '6b8e23',
'orange' => 'ffa500',
'orangered' => 'ff4500',
'orchid' => 'da70d6',
'palegoldenrod' => 'eee8aa',
'palegreen' => '98fb98',
'paleturquoise' => 'afeeee',
'palevioletred' => 'd87093',
'papayawhip' => 'ffefd5',
'peachpuff' => 'ffdab9',
'peru' => 'cd853f',
'pink' => 'ffc0cb',
'plum' => 'dda0dd',
'powderblue' => 'b0e0e6',
'purple' => '800080',
'red' => 'ff0000',
'rosybrown' => 'bc8f8f',
'royalblue' => '4169e1',
'saddlebrown' => '8b4513',
'salmon' => 'fa8072',
'sandybrown' => 'f4a460',
'seagreen' => '2e8b57',
'seashell' => 'fff5ee',
'sienna' => 'a0522d',
'silver' => 'c0c0c0',
'skyblue' => '87ceeb',
'slateblue' => '6a5acd',
'slategray' => '708090',
'slategrey' => '708090',
'snow' => 'fffafa',
'springgreen' => '00ff7f',
'steelblue' => '4682b4',
'tan' => 'd2b48c',
'teal' => '008080',
'thistle' => 'd8bfd8',
'tomato' => 'ff6347',
'turquoise' => '40e0d0',
'violet' => 'ee82ee',
'wheat' => 'f5deb3',
'white' => 'ffffff',
'whitesmoke' => 'f5f5f5',
'yellow' => 'ffff00',
'yellowgreen' => '9acd32'
);
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/htmlcolors.php | PHP | asf20 | 5,742 |
<?php
//============================================================+
// File name : barcodes.php
// Version : 1.0.011
// Begin : 2008-06-09
// Last Update : 2010-08-08
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
// Copyright (C) 2008-2010 Nicola Asuni - Tecnick.com S.r.l.
//
// This file is part of TCPDF software library.
//
// TCPDF 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 3 of the
// License, or (at your option) any later version.
//
// TCPDF 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 TCPDF. If not, see <http://www.gnu.org/licenses/>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : PHP class to creates array representations for
// common 1D barcodes to be used with TCPDF.
//
//============================================================+
/**
* PHP class to creates array representations for common 1D barcodes to be used with TCPDF.
* @package com.tecnick.tcpdf
* @abstract Functions for generating string representation of common 1D barcodes.
* @author Nicola Asuni
* @copyright 2008-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version 1.0.011
*/
/**
* PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www.tcpdf.org).<br>
* @name TCPDFBarcode
* @package com.tecnick.tcpdf
* @version 1.0.011
* @author Nicola Asuni
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
*/
class TCPDFBarcode {
/**
* @var array representation of barcode.
* @access protected
*/
protected $barcode_array;
/**
* This is the class constructor.
* Return an array representations for common 1D barcodes:<ul>
* <li>$arrcode['code'] code to be printed on text label</li>
* <li>$arrcode['maxh'] max bar height</li>
* <li>$arrcode['maxw'] max bar width</li>
* <li>$arrcode['bcode'][$k] single bar or space in $k position</li>
* <li>$arrcode['bcode'][$k]['t'] bar type: true = bar, false = space.</li>
* <li>$arrcode['bcode'][$k]['w'] bar width in units.</li>
* <li>$arrcode['bcode'][$k]['h'] bar height in units.</li>
* <li>$arrcode['bcode'][$k]['p'] bar top position (0 = top, 1 = middle)</li></ul>
* @param string $code code to print
* @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
*/
public function __construct($code, $type) {
$this->setBarcode($code, $type);
}
/**
* Return an array representations of barcode.
* @return array
*/
public function getBarcodeArray() {
return $this->barcode_array;
}
/**
* Set the barcode.
* @param string $code code to print
* @param string $type type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extention</li><li>EAN5 : 5-Digits UPC-Based Extention</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
* @return array
*/
public function setBarcode($code, $type) {
switch (strtoupper($type)) {
case 'C39': { // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
$arrcode = $this->barcode_code39($code, false, false);
break;
}
case 'C39+': { // CODE 39 with checksum
$arrcode = $this->barcode_code39($code, false, true);
break;
}
case 'C39E': { // CODE 39 EXTENDED
$arrcode = $this->barcode_code39($code, true, false);
break;
}
case 'C39E+': { // CODE 39 EXTENDED + CHECKSUM
$arrcode = $this->barcode_code39($code, true, true);
break;
}
case 'C93': { // CODE 93 - USS-93
$arrcode = $this->barcode_code93($code);
break;
}
case 'S25': { // Standard 2 of 5
$arrcode = $this->barcode_s25($code, false);
break;
}
case 'S25+': { // Standard 2 of 5 + CHECKSUM
$arrcode = $this->barcode_s25($code, true);
break;
}
case 'I25': { // Interleaved 2 of 5
$arrcode = $this->barcode_i25($code, false);
break;
}
case 'I25+': { // Interleaved 2 of 5 + CHECKSUM
$arrcode = $this->barcode_i25($code, true);
break;
}
case 'C128A': { // CODE 128 A
$arrcode = $this->barcode_c128($code, 'A');
break;
}
case 'C128B': { // CODE 128 B
$arrcode = $this->barcode_c128($code, 'B');
break;
}
case 'C128C': { // CODE 128 C
$arrcode = $this->barcode_c128($code, 'C');
break;
}
case 'EAN2': { // 2-Digits UPC-Based Extention
$arrcode = $this->barcode_eanext($code, 2);
break;
}
case 'EAN5': { // 5-Digits UPC-Based Extention
$arrcode = $this->barcode_eanext($code, 5);
break;
}
case 'EAN8': { // EAN 8
$arrcode = $this->barcode_eanupc($code, 8);
break;
}
case 'EAN13': { // EAN 13
$arrcode = $this->barcode_eanupc($code, 13);
break;
}
case 'UPCA': { // UPC-A
$arrcode = $this->barcode_eanupc($code, 12);
break;
}
case 'UPCE': { // UPC-E
$arrcode = $this->barcode_eanupc($code, 6);
break;
}
case 'MSI': { // MSI (Variation of Plessey code)
$arrcode = $this->barcode_msi($code, false);
break;
}
case 'MSI+': { // MSI + CHECKSUM (modulo 11)
$arrcode = $this->barcode_msi($code, true);
break;
}
case 'POSTNET': { // POSTNET
$arrcode = $this->barcode_postnet($code, false);
break;
}
case 'PLANET': { // PLANET
$arrcode = $this->barcode_postnet($code, true);
break;
}
case 'RMS4CC': { // RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
$arrcode = $this->barcode_rms4cc($code, false);
break;
}
case 'KIX': { // KIX (Klant index - Customer index)
$arrcode = $this->barcode_rms4cc($code, true);
break;
}
case 'IMB': { // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
$arrcode = $this->barcode_imb($code);
break;
}
case 'CODABAR': { // CODABAR
$arrcode = $this->barcode_codabar($code);
break;
}
case 'CODE11': { // CODE 11
$arrcode = $this->barcode_code11($code);
break;
}
case 'PHARMA': { // PHARMACODE
$arrcode = $this->barcode_pharmacode($code);
break;
}
case 'PHARMA2T': { // PHARMACODE TWO-TRACKS
$arrcode = $this->barcode_pharmacode2t($code);
break;
}
default: {
$this->barcode_array = false;
$arrcode = false;
break;
}
}
$this->barcode_array = $arrcode;
}
/**
* CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
* General-purpose code in very wide use world-wide
* @param string $code code to represent.
* @param boolean $checksum if true add a checksum to the code
* @return array barcode representation.
* @access protected
*/
protected function barcode_code39($code, $extended=false, $checksum=false) {
$chr['0'] = '111221211';
$chr['1'] = '211211112';
$chr['2'] = '112211112';
$chr['3'] = '212211111';
$chr['4'] = '111221112';
$chr['5'] = '211221111';
$chr['6'] = '112221111';
$chr['7'] = '111211212';
$chr['8'] = '211211211';
$chr['9'] = '112211211';
$chr['A'] = '211112112';
$chr['B'] = '112112112';
$chr['C'] = '212112111';
$chr['D'] = '111122112';
$chr['E'] = '211122111';
$chr['F'] = '112122111';
$chr['G'] = '111112212';
$chr['H'] = '211112211';
$chr['I'] = '112112211';
$chr['J'] = '111122211';
$chr['K'] = '211111122';
$chr['L'] = '112111122';
$chr['M'] = '212111121';
$chr['N'] = '111121122';
$chr['O'] = '211121121';
$chr['P'] = '112121121';
$chr['Q'] = '111111222';
$chr['R'] = '211111221';
$chr['S'] = '112111221';
$chr['T'] = '111121221';
$chr['U'] = '221111112';
$chr['V'] = '122111112';
$chr['W'] = '222111111';
$chr['X'] = '121121112';
$chr['Y'] = '221121111';
$chr['Z'] = '122121111';
$chr['-'] = '121111212';
$chr['.'] = '221111211';
$chr[' '] = '122111211';
$chr['$'] = '121212111';
$chr['/'] = '121211121';
$chr['+'] = '121112121';
$chr['%'] = '111212121';
$chr['*'] = '121121211';
$code = strtoupper($code);
if ($extended) {
// extended mode
$code = $this->encode_code39_ext($code);
}
if ($code === false) {
return false;
}
if ($checksum) {
// checksum
$code .= $this->checksum_code39($code);
}
// add start and stop codes
$code = '*'.$code.'*';
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
$char = $code{$i};
if(!isset($chr[$char])) {
// invalid character
return false;
}
for ($j = 0; $j < 9; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $chr[$char]{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
$bararray['bcode'][$k] = array('t' => false, 'w' => 1, 'h' => 1, 'p' => 0);
$bararray['maxw'] += 1;
++$k;
}
return $bararray;
}
/**
* Encode a string to be used for CODE 39 Extended mode.
* @param string $code code to represent.
* @return encoded string.
* @access protected
*/
protected function encode_code39_ext($code) {
$encode = array(
chr(0) => '%U', chr(1) => '$A', chr(2) => '$B', chr(3) => '$C',
chr(4) => '$D', chr(5) => '$E', chr(6) => '$F', chr(7) => '$G',
chr(8) => '$H', chr(9) => '$I', chr(10) => '$J', chr(11) => '£K',
chr(12) => '$L', chr(13) => '$M', chr(14) => '$N', chr(15) => '$O',
chr(16) => '$P', chr(17) => '$Q', chr(18) => '$R', chr(19) => '$S',
chr(20) => '$T', chr(21) => '$U', chr(22) => '$V', chr(23) => '$W',
chr(24) => '$X', chr(25) => '$Y', chr(26) => '$Z', chr(27) => '%A',
chr(28) => '%B', chr(29) => '%C', chr(30) => '%D', chr(31) => '%E',
chr(32) => ' ', chr(33) => '/A', chr(34) => '/B', chr(35) => '/C',
chr(36) => '/D', chr(37) => '/E', chr(38) => '/F', chr(39) => '/G',
chr(40) => '/H', chr(41) => '/I', chr(42) => '/J', chr(43) => '/K',
chr(44) => '/L', chr(45) => '-', chr(46) => '.', chr(47) => '/O',
chr(48) => '0', chr(49) => '1', chr(50) => '2', chr(51) => '3',
chr(52) => '4', chr(53) => '5', chr(54) => '6', chr(55) => '7',
chr(56) => '8', chr(57) => '9', chr(58) => '/Z', chr(59) => '%F',
chr(60) => '%G', chr(61) => '%H', chr(62) => '%I', chr(63) => '%J',
chr(64) => '%V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C',
chr(68) => 'D', chr(69) => 'E', chr(70) => 'F', chr(71) => 'G',
chr(72) => 'H', chr(73) => 'I', chr(74) => 'J', chr(75) => 'K',
chr(76) => 'L', chr(77) => 'M', chr(78) => 'N', chr(79) => 'O',
chr(80) => 'P', chr(81) => 'Q', chr(82) => 'R', chr(83) => 'S',
chr(84) => 'T', chr(85) => 'U', chr(86) => 'V', chr(87) => 'W',
chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => '%K',
chr(92) => '%L', chr(93) => '%M', chr(94) => '%N', chr(95) => '%O',
chr(96) => '%W', chr(97) => '+A', chr(98) => '+B', chr(99) => '+C',
chr(100) => '+D', chr(101) => '+E', chr(102) => '+F', chr(103) => '+G',
chr(104) => '+H', chr(105) => '+I', chr(106) => '+J', chr(107) => '+K',
chr(108) => '+L', chr(109) => '+M', chr(110) => '+N', chr(111) => '+O',
chr(112) => '+P', chr(113) => '+Q', chr(114) => '+R', chr(115) => '+S',
chr(116) => '+T', chr(117) => '+U', chr(118) => '+V', chr(119) => '+W',
chr(120) => '+X', chr(121) => '+Y', chr(122) => '+Z', chr(123) => '%P',
chr(124) => '%Q', chr(125) => '%R', chr(126) => '%S', chr(127) => '%T');
$code_ext = '';
$clen = strlen($code);
for ($i = 0 ; $i < $clen; ++$i) {
if (ord($code{$i}) > 127) {
return false;
}
$code_ext .= $encode[$code{$i}];
}
return $code_ext;
}
/**
* Calculate CODE 39 checksum (modulo 43).
* @param string $code code to represent.
* @return char checksum.
* @access protected
*/
protected function checksum_code39($code) {
$chars = array(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
$sum = 0;
$clen = strlen($code);
for ($i = 0 ; $i < $clen; ++$i) {
$k = array_keys($chars, $code{$i});
$sum += $k[0];
}
$j = ($sum % 43);
return $chars[$j];
}
/**
* CODE 93 - USS-93
* Compact code similar to Code 39
* @param string $code code to represent.
* @param boolean $checksum if true add a checksum to the code
* @return array barcode representation.
* @access protected
*/
protected function barcode_code93($code) {
$chr['0'] = '131112';
$chr['1'] = '111213';
$chr['2'] = '111312';
$chr['3'] = '111411';
$chr['4'] = '121113';
$chr['5'] = '121212';
$chr['6'] = '121311';
$chr['7'] = '111114';
$chr['8'] = '131211';
$chr['9'] = '141111';
$chr['A'] = '211113';
$chr['B'] = '211212';
$chr['C'] = '211311';
$chr['D'] = '221112';
$chr['E'] = '221211';
$chr['F'] = '231111';
$chr['G'] = '112113';
$chr['H'] = '112212';
$chr['I'] = '112311';
$chr['J'] = '122112';
$chr['K'] = '132111';
$chr['L'] = '111123';
$chr['M'] = '111222';
$chr['N'] = '111321';
$chr['O'] = '121122';
$chr['P'] = '131121';
$chr['Q'] = '212112';
$chr['R'] = '212211';
$chr['S'] = '211122';
$chr['T'] = '211221';
$chr['U'] = '221121';
$chr['V'] = '222111';
$chr['W'] = '112122';
$chr['X'] = '112221';
$chr['Y'] = '122121';
$chr['Z'] = '123111';
$chr['-'] = '121131';
$chr['.'] = '311112';
$chr[' '] = '311211';
$chr['$'] = '321111';
$chr['/'] = '112131';
$chr['+'] = '113121';
$chr['%'] = '211131';
$chr[128] = '121221'; // ($)
$chr[129] = '311121'; // (/)
$chr[130] = '122211'; // (+)
$chr[131] = '312111'; // (%)
$chr['*'] = '111141';
$code = strtoupper($code);
$encode = array(
chr(0) => chr(131).'U', chr(1) => chr(128).'A', chr(2) => chr(128).'B', chr(3) => chr(128).'C',
chr(4) => chr(128).'D', chr(5) => chr(128).'E', chr(6) => chr(128).'F', chr(7) => chr(128).'G',
chr(8) => chr(128).'H', chr(9) => chr(128).'I', chr(10) => chr(128).'J', chr(11) => '£K',
chr(12) => chr(128).'L', chr(13) => chr(128).'M', chr(14) => chr(128).'N', chr(15) => chr(128).'O',
chr(16) => chr(128).'P', chr(17) => chr(128).'Q', chr(18) => chr(128).'R', chr(19) => chr(128).'S',
chr(20) => chr(128).'T', chr(21) => chr(128).'U', chr(22) => chr(128).'V', chr(23) => chr(128).'W',
chr(24) => chr(128).'X', chr(25) => chr(128).'Y', chr(26) => chr(128).'Z', chr(27) => chr(131).'A',
chr(28) => chr(131).'B', chr(29) => chr(131).'C', chr(30) => chr(131).'D', chr(31) => chr(131).'E',
chr(32) => ' ', chr(33) => chr(129).'A', chr(34) => chr(129).'B', chr(35) => chr(129).'C',
chr(36) => chr(129).'D', chr(37) => chr(129).'E', chr(38) => chr(129).'F', chr(39) => chr(129).'G',
chr(40) => chr(129).'H', chr(41) => chr(129).'I', chr(42) => chr(129).'J', chr(43) => chr(129).'K',
chr(44) => chr(129).'L', chr(45) => '-', chr(46) => '.', chr(47) => chr(129).'O',
chr(48) => '0', chr(49) => '1', chr(50) => '2', chr(51) => '3',
chr(52) => '4', chr(53) => '5', chr(54) => '6', chr(55) => '7',
chr(56) => '8', chr(57) => '9', chr(58) => chr(129).'Z', chr(59) => chr(131).'F',
chr(60) => chr(131).'G', chr(61) => chr(131).'H', chr(62) => chr(131).'I', chr(63) => chr(131).'J',
chr(64) => chr(131).'V', chr(65) => 'A', chr(66) => 'B', chr(67) => 'C',
chr(68) => 'D', chr(69) => 'E', chr(70) => 'F', chr(71) => 'G',
chr(72) => 'H', chr(73) => 'I', chr(74) => 'J', chr(75) => 'K',
chr(76) => 'L', chr(77) => 'M', chr(78) => 'N', chr(79) => 'O',
chr(80) => 'P', chr(81) => 'Q', chr(82) => 'R', chr(83) => 'S',
chr(84) => 'T', chr(85) => 'U', chr(86) => 'V', chr(87) => 'W',
chr(88) => 'X', chr(89) => 'Y', chr(90) => 'Z', chr(91) => chr(131).'K',
chr(92) => chr(131).'L', chr(93) => chr(131).'M', chr(94) => chr(131).'N', chr(95) => chr(131).'O',
chr(96) => chr(131).'W', chr(97) => chr(130).'A', chr(98) => chr(130).'B', chr(99) => chr(130).'C',
chr(100) => chr(130).'D', chr(101) => chr(130).'E', chr(102) => chr(130).'F', chr(103) => chr(130).'G',
chr(104) => chr(130).'H', chr(105) => chr(130).'I', chr(106) => chr(130).'J', chr(107) => chr(130).'K',
chr(108) => chr(130).'L', chr(109) => chr(130).'M', chr(110) => chr(130).'N', chr(111) => chr(130).'O',
chr(112) => chr(130).'P', chr(113) => chr(130).'Q', chr(114) => chr(130).'R', chr(115) => chr(130).'S',
chr(116) => chr(130).'T', chr(117) => chr(130).'U', chr(118) => chr(130).'V', chr(119) => chr(130).'W',
chr(120) => chr(130).'X', chr(121) => chr(130).'Y', chr(122) => chr(130).'Z', chr(123) => chr(131).'P',
chr(124) => chr(131).'Q', chr(125) => chr(131).'R', chr(126) => chr(131).'S', chr(127) => chr(131).'T');
$code_ext = '';
$clen = strlen($code);
for ($i = 0 ; $i < $clen; ++$i) {
if (ord($code{$i}) > 127) {
return false;
}
$code_ext .= $encode[$code{$i}];
}
// checksum
$code .= $this->checksum_code93($code);
// add start and stop codes
$code = '*'.$code.'*';
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
$char = $code{$i};
if(!isset($chr[$char])) {
// invalid character
return false;
}
for ($j = 0; $j < 6; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $chr[$char]{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
}
$bararray['bcode'][$k] = array('t' => true, 'w' => 1, 'h' => 1, 'p' => 0);
$bararray['maxw'] += 1;
++$k;
return $bararray;
}
/**
* Calculate CODE 93 checksum (modulo 47).
* @param string $code code to represent.
* @return string checksum code.
* @access protected
*/
protected function checksum_code93($code) {
$chars = array(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%');
// translate special characters
$code = strtr($code, chr(128).chr(129).chr(130).chr(131), '$/+%');
$len = strlen($code);
// calculate check digit C
$p = 1;
$check = 0;
for ($i = ($len - 1); $i >= 0; --$i) {
$k = array_keys($chars, $code{$i});
$check += ($k[0] * $p);
++$p;
if ($p > 20) {
$p = 1;
}
}
$check %= 47;
$c = $chars[$check];
$code .= $c;
// calculate check digit K
$p = 1;
$check = 0;
for ($i = $len; $i >= 0; --$i) {
$k = array_keys($chars, $code{$i});
$check += ($k[0] * $p);
++$p;
if ($p > 15) {
$p = 1;
}
}
$check %= 47;
$k = $chars[$check];
return $c.$k;
}
/**
* Checksum for standard 2 of 5 barcodes.
* @param string $code code to process.
* @return int checksum.
* @access protected
*/
protected function checksum_s25($code) {
$len = strlen($code);
$sum = 0;
for ($i = 0; $i < $len; $i+=2) {
$sum += $code{$i};
}
$sum *= 3;
for ($i = 1; $i < $len; $i+=2) {
$sum += ($code{$i});
}
$r = $sum % 10;
if($r > 0) {
$r = (10 - $r);
}
return $r;
}
/**
* MSI.
* Variation of Plessey code, with similar applications
* Contains digits (0 to 9) and encodes the data only in the width of bars.
* @param string $code code to represent.
* @param boolean $checksum if true add a checksum to the code (modulo 11)
* @return array barcode representation.
* @access protected
*/
protected function barcode_msi($code, $checksum=false) {
$chr['0'] = '100100100100';
$chr['1'] = '100100100110';
$chr['2'] = '100100110100';
$chr['3'] = '100100110110';
$chr['4'] = '100110100100';
$chr['5'] = '100110100110';
$chr['6'] = '100110110100';
$chr['7'] = '100110110110';
$chr['8'] = '110100100100';
$chr['9'] = '110100100110';
$chr['A'] = '110100110100';
$chr['B'] = '110100110110';
$chr['C'] = '110110100100';
$chr['D'] = '110110100110';
$chr['E'] = '110110110100';
$chr['F'] = '110110110110';
if ($checksum) {
// add checksum
$clen = strlen($code);
$p = 2;
$check = 0;
for ($i = ($clen - 1); $i >= 0; --$i) {
$check += (hexdec($code{$i}) * $p);
++$p;
if ($p > 7) {
$p = 2;
}
}
$check %= 11;
if ($check > 0) {
$check = 11 - $check;
}
$code .= $check;
}
$seq = '110'; // left guard
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
$digit = $code{$i};
if (!isset($chr[$digit])) {
// invalid character
return false;
}
$seq .= $chr[$digit];
}
$seq .= '1001'; // right guard
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
return $this->binseq_to_array($seq, $bararray);
}
/**
* Standard 2 of 5 barcodes.
* Used in airline ticket marking, photofinishing
* Contains digits (0 to 9) and encodes the data only in the width of bars.
* @param string $code code to represent.
* @param boolean $checksum if true add a checksum to the code
* @return array barcode representation.
* @access protected
*/
protected function barcode_s25($code, $checksum=false) {
$chr['0'] = '10101110111010';
$chr['1'] = '11101010101110';
$chr['2'] = '10111010101110';
$chr['3'] = '11101110101010';
$chr['4'] = '10101110101110';
$chr['5'] = '11101011101010';
$chr['6'] = '10111011101010';
$chr['7'] = '10101011101110';
$chr['8'] = '10101110111010';
$chr['9'] = '10111010111010';
if ($checksum) {
// add checksum
$code .= $this->checksum_s25($code);
}
if((strlen($code) % 2) != 0) {
// add leading zero if code-length is odd
$code = '0'.$code;
}
$seq = '11011010';
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
$digit = $code{$i};
if (!isset($chr[$digit])) {
// invalid character
return false;
}
$seq .= $chr[$digit];
}
$seq .= '1101011';
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
return $this->binseq_to_array($seq, $bararray);
}
/**
* Convert binary barcode sequence to TCPDF barcode array
* @param string $seq barcode as binary sequence
* òparam array $bararray TCPDF barcode array to fill up
* @return array barcode representation.
* @access protected
*/
protected function binseq_to_array($seq, $bararray) {
$len = strlen($seq);
$w = 0;
$k = 0;
for ($i = 0; $i < $len; ++$i) {
$w += 1;
if (($i == ($len - 1)) OR (($i < ($len - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
if ($seq{$i} == '1') {
$t = true; // bar
} else {
$t = false; // space
}
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
$w = 0;
}
}
return $bararray;
}
/**
* Interleaved 2 of 5 barcodes.
* Compact numeric code, widely used in industry, air cargo
* Contains digits (0 to 9) and encodes the data in the width of both bars and spaces.
* @param string $code code to represent.
* @param boolean $checksum if true add a checksum to the code
* @return array barcode representation.
* @access protected
*/
protected function barcode_i25($code, $checksum=false) {
$chr['0'] = '11221';
$chr['1'] = '21112';
$chr['2'] = '12112';
$chr['3'] = '22111';
$chr['4'] = '11212';
$chr['5'] = '21211';
$chr['6'] = '12211';
$chr['7'] = '11122';
$chr['8'] = '21121';
$chr['9'] = '12121';
$chr['A'] = '11';
$chr['Z'] = '21';
if ($checksum) {
// add checksum
$code .= $this->checksum_s25($code);
}
if((strlen($code) % 2) != 0) {
// add leading zero if code-length is odd
$code = '0'.$code;
}
// add start and stop codes
$code = 'AA'.strtolower($code).'ZA';
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$clen = strlen($code);
for ($i = 0; $i < $clen; $i = ($i + 2)) {
$char_bar = $code{$i};
$char_space = $code{$i+1};
if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) {
// invalid character
return false;
}
// create a bar-space sequence
$seq = '';
$chrlen = strlen($chr[$char_bar]);
for ($s = 0; $s < $chrlen; $s++){
$seq .= $chr[$char_bar]{$s} . $chr[$char_space]{$s};
}
$seqlen = strlen($seq);
for ($j = 0; $j < $seqlen; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $seq{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
}
return $bararray;
}
/**
* C128 barcodes.
* Very capable code, excellent density, high reliability; in very wide use world-wide
* @param string $code code to represent.
* @param string $type barcode type: A, B or C
* @return array barcode representation.
* @access protected
*/
protected function barcode_c128($code, $type='B') {
$chr = array(
'212222', /* 00 */
'222122', /* 01 */
'222221', /* 02 */
'121223', /* 03 */
'121322', /* 04 */
'131222', /* 05 */
'122213', /* 06 */
'122312', /* 07 */
'132212', /* 08 */
'221213', /* 09 */
'221312', /* 10 */
'231212', /* 11 */
'112232', /* 12 */
'122132', /* 13 */
'122231', /* 14 */
'113222', /* 15 */
'123122', /* 16 */
'123221', /* 17 */
'223211', /* 18 */
'221132', /* 19 */
'221231', /* 20 */
'213212', /* 21 */
'223112', /* 22 */
'312131', /* 23 */
'311222', /* 24 */
'321122', /* 25 */
'321221', /* 26 */
'312212', /* 27 */
'322112', /* 28 */
'322211', /* 29 */
'212123', /* 30 */
'212321', /* 31 */
'232121', /* 32 */
'111323', /* 33 */
'131123', /* 34 */
'131321', /* 35 */
'112313', /* 36 */
'132113', /* 37 */
'132311', /* 38 */
'211313', /* 39 */
'231113', /* 40 */
'231311', /* 41 */
'112133', /* 42 */
'112331', /* 43 */
'132131', /* 44 */
'113123', /* 45 */
'113321', /* 46 */
'133121', /* 47 */
'313121', /* 48 */
'211331', /* 49 */
'231131', /* 50 */
'213113', /* 51 */
'213311', /* 52 */
'213131', /* 53 */
'311123', /* 54 */
'311321', /* 55 */
'331121', /* 56 */
'312113', /* 57 */
'312311', /* 58 */
'332111', /* 59 */
'314111', /* 60 */
'221411', /* 61 */
'431111', /* 62 */
'111224', /* 63 */
'111422', /* 64 */
'121124', /* 65 */
'121421', /* 66 */
'141122', /* 67 */
'141221', /* 68 */
'112214', /* 69 */
'112412', /* 70 */
'122114', /* 71 */
'122411', /* 72 */
'142112', /* 73 */
'142211', /* 74 */
'241211', /* 75 */
'221114', /* 76 */
'413111', /* 77 */
'241112', /* 78 */
'134111', /* 79 */
'111242', /* 80 */
'121142', /* 81 */
'121241', /* 82 */
'114212', /* 83 */
'124112', /* 84 */
'124211', /* 85 */
'411212', /* 86 */
'421112', /* 87 */
'421211', /* 88 */
'212141', /* 89 */
'214121', /* 90 */
'412121', /* 91 */
'111143', /* 92 */
'111341', /* 93 */
'131141', /* 94 */
'114113', /* 95 */
'114311', /* 96 */
'411113', /* 97 */
'411311', /* 98 */
'113141', /* 99 */
'114131', /* 100 */
'311141', /* 101 */
'411131', /* 102 */
'211412', /* 103 START A */
'211214', /* 104 START B */
'211232', /* 105 START C */
'233111', /* STOP */
'200000' /* END */
);
$keys = '';
switch(strtoupper($type)) {
case 'A': {
$startid = 103;
$keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_';
for ($i = 0; $i < 32; ++$i) {
$keys .= chr($i);
}
break;
}
case 'B': {
$startid = 104;
$keys = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'.chr(127);
break;
}
case 'C': {
$startid = 105;
$keys = '';
if ((strlen($code) % 2) != 0) {
// The length of barcode value must be even ($code). You must pad the number with zeros
return false;
}
for ($i = 0; $i <= 99; ++$i) {
$keys .= chr($i);
}
$new_code = '';
$hclen = (strlen($code) / 2);
for ($i = 0; $i < $hclen; ++$i) {
$new_code .= chr(intval($code{(2 * $i)}.$code{(2 * $i + 1)}));
}
$code = $new_code;
break;
}
default: {
return false;
}
}
// calculate check character
$sum = $startid;
$clen = strlen($code);
for ($i = 0; $i < $clen; ++$i) {
$sum += (strpos($keys, $code{$i}) * ($i+1));
}
$check = ($sum % 103);
// add start, check and stop codes
$code = chr($startid).$code.chr($check).chr(106).chr(107);
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$len = strlen($code);
for ($i = 0; $i < $len; ++$i) {
$ck = strpos($keys, $code{$i});
if (($i == 0) OR ($i > ($len-4))) {
$char_num = ord($code{$i});
$seq = $chr[$char_num];
} elseif(($ck >= 0) AND isset($chr[$ck])) {
$seq = $chr[$ck];
} else {
// invalid character
return false;
}
for ($j = 0; $j < 6; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $seq{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
}
return $bararray;
}
/**
* EAN13 and UPC-A barcodes.
* EAN13: European Article Numbering international retail product code
* UPC-A: Universal product code seen on almost all retail products in the USA and Canada
* UPC-E: Short version of UPC symbol
* @param string $code code to represent.
* @param string $len barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A
* @return array barcode representation.
* @access protected
*/
protected function barcode_eanupc($code, $len=13) {
$upce = false;
if ($len == 6) {
$len = 12; // UPC-A
$upce = true; // UPC-E mode
}
$data_len = $len - 1;
//Padding
$code = str_pad($code, $data_len, '0', STR_PAD_LEFT);
$code_len = strlen($code);
// calculate check digit
$sum_a = 0;
for ($i = 1; $i < $data_len; $i+=2) {
$sum_a += $code{$i};
}
if ($len > 12) {
$sum_a *= 3;
}
$sum_b = 0;
for ($i = 0; $i < $data_len; $i+=2) {
$sum_b += ($code{$i});
}
if ($len < 13) {
$sum_b *= 3;
}
$r = ($sum_a + $sum_b) % 10;
if($r > 0) {
$r = (10 - $r);
}
if ($code_len == $data_len) {
// add check digit
$code .= $r;
} elseif ($r !== intval($code{$data_len})) {
// wrong checkdigit
return false;
}
if ($len == 12) {
// UPC-A
$code = '0'.$code;
++$len;
}
if ($upce) {
// convert UPC-A to UPC-E
$tmp = substr($code, 4, 3);
if (($tmp == '000') OR ($tmp == '100') OR ($tmp == '200')) {
// manufacturer code ends in 000, 100, or 200
$upce_code = substr($code, 2, 2).substr($code, 9, 3).substr($code, 4, 1);
} else {
$tmp = substr($code, 5, 2);
if ($tmp == '00') {
// manufacturer code ends in 00
$upce_code = substr($code, 2, 3).substr($code, 10, 2).'3';
} else {
$tmp = substr($code, 6, 1);
if ($tmp == '0') {
// manufacturer code ends in 0
$upce_code = substr($code, 2, 4).substr($code, 11, 1).'4';
} else {
// manufacturer code does not end in zero
$upce_code = substr($code, 2, 5).substr($code, 11, 1);
}
}
}
}
//Convert digits to bars
$codes = array(
'A'=>array( // left odd parity
'0'=>'0001101',
'1'=>'0011001',
'2'=>'0010011',
'3'=>'0111101',
'4'=>'0100011',
'5'=>'0110001',
'6'=>'0101111',
'7'=>'0111011',
'8'=>'0110111',
'9'=>'0001011'),
'B'=>array( // left even parity
'0'=>'0100111',
'1'=>'0110011',
'2'=>'0011011',
'3'=>'0100001',
'4'=>'0011101',
'5'=>'0111001',
'6'=>'0000101',
'7'=>'0010001',
'8'=>'0001001',
'9'=>'0010111'),
'C'=>array( // right
'0'=>'1110010',
'1'=>'1100110',
'2'=>'1101100',
'3'=>'1000010',
'4'=>'1011100',
'5'=>'1001110',
'6'=>'1010000',
'7'=>'1000100',
'8'=>'1001000',
'9'=>'1110100')
);
$parities = array(
'0'=>array('A','A','A','A','A','A'),
'1'=>array('A','A','B','A','B','B'),
'2'=>array('A','A','B','B','A','B'),
'3'=>array('A','A','B','B','B','A'),
'4'=>array('A','B','A','A','B','B'),
'5'=>array('A','B','B','A','A','B'),
'6'=>array('A','B','B','B','A','A'),
'7'=>array('A','B','A','B','A','B'),
'8'=>array('A','B','A','B','B','A'),
'9'=>array('A','B','B','A','B','A')
);
$upce_parities = array();
$upce_parities[0] = array(
'0'=>array('B','B','B','A','A','A'),
'1'=>array('B','B','A','B','A','A'),
'2'=>array('B','B','A','A','B','A'),
'3'=>array('B','B','A','A','A','B'),
'4'=>array('B','A','B','B','A','A'),
'5'=>array('B','A','A','B','B','A'),
'6'=>array('B','A','A','A','B','B'),
'7'=>array('B','A','B','A','B','A'),
'8'=>array('B','A','B','A','A','B'),
'9'=>array('B','A','A','B','A','B')
);
$upce_parities[1] = array(
'0'=>array('A','A','A','B','B','B'),
'1'=>array('A','A','B','A','B','B'),
'2'=>array('A','A','B','B','A','B'),
'3'=>array('A','A','B','B','B','A'),
'4'=>array('A','B','A','A','B','B'),
'5'=>array('A','B','B','A','A','B'),
'6'=>array('A','B','B','B','A','A'),
'7'=>array('A','B','A','B','A','B'),
'8'=>array('A','B','A','B','B','A'),
'9'=>array('A','B','B','A','B','A')
);
$k = 0;
$seq = '101'; // left guard bar
if ($upce) {
$bararray = array('code' => $upce_code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$p = $upce_parities[$code{1}][$r];
for ($i = 0; $i < 6; ++$i) {
$seq .= $codes[$p[$i]][$upce_code{$i}];
}
$seq .= '010101'; // right guard bar
} else {
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$half_len = ceil($len / 2);
if ($len == 8) {
for ($i = 0; $i < $half_len; ++$i) {
$seq .= $codes['A'][$code{$i}];
}
} else {
$p = $parities[$code{0}];
for ($i = 1; $i < $half_len; ++$i) {
$seq .= $codes[$p[$i-1]][$code{$i}];
}
}
$seq .= '01010'; // center guard bar
for ($i = $half_len; $i < $len; ++$i) {
$seq .= $codes['C'][$code{$i}];
}
$seq .= '101'; // right guard bar
}
$clen = strlen($seq);
$w = 0;
for ($i = 0; $i < $clen; ++$i) {
$w += 1;
if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i+1)}))) {
if ($seq{$i} == '1') {
$t = true; // bar
} else {
$t = false; // space
}
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
$w = 0;
}
}
return $bararray;
}
/**
* UPC-Based Extentions
* 2-Digit Ext.: Used to indicate magazines and newspaper issue numbers
* 5-Digit Ext.: Used to mark suggested retail price of books
* @param string $code code to represent.
* @param string $len barcode type: 2 = 2-Digit, 5 = 5-Digit
* @return array barcode representation.
* @access protected
*/
protected function barcode_eanext($code, $len=5) {
//Padding
$code = str_pad($code, $len, '0', STR_PAD_LEFT);
// calculate check digit
if ($len == 2) {
$r = $code % 4;
} elseif ($len == 5) {
$r = (3 * ($code{0} + $code{2} + $code{4})) + (9 * ($code{1} + $code{3}));
$r %= 10;
} else {
return false;
}
//Convert digits to bars
$codes = array(
'A'=>array( // left odd parity
'0'=>'0001101',
'1'=>'0011001',
'2'=>'0010011',
'3'=>'0111101',
'4'=>'0100011',
'5'=>'0110001',
'6'=>'0101111',
'7'=>'0111011',
'8'=>'0110111',
'9'=>'0001011'),
'B'=>array( // left even parity
'0'=>'0100111',
'1'=>'0110011',
'2'=>'0011011',
'3'=>'0100001',
'4'=>'0011101',
'5'=>'0111001',
'6'=>'0000101',
'7'=>'0010001',
'8'=>'0001001',
'9'=>'0010111')
);
$parities = array();
$parities[2] = array(
'0'=>array('A','A'),
'1'=>array('A','B'),
'2'=>array('B','A'),
'3'=>array('B','B')
);
$parities[5] = array(
'0'=>array('B','B','A','A','A'),
'1'=>array('B','A','B','A','A'),
'2'=>array('B','A','A','B','A'),
'3'=>array('B','A','A','A','B'),
'4'=>array('A','B','B','A','A'),
'5'=>array('A','A','B','B','A'),
'6'=>array('A','A','A','B','B'),
'7'=>array('A','B','A','B','A'),
'8'=>array('A','B','A','A','B'),
'9'=>array('A','A','B','A','B')
);
$p = $parities[$len][$r];
$seq = '1011'; // left guard bar
$seq .= $codes[$p[0]][$code{0}];
for ($i = 1; $i < $len; ++$i) {
$seq .= '01'; // separator
$seq .= $codes[$p[$i]][$code{$i}];
}
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
return $this->binseq_to_array($seq, $bararray);
}
/**
* POSTNET and PLANET barcodes.
* Used by U.S. Postal Service for automated mail sorting
* @param string $code zip code to represent. Must be a string containing a zip code of the form DDDDD or DDDDD-DDDD.
* @param boolean $planet if true print the PLANET barcode, otherwise print POSTNET
* @return array barcode representation.
* @access protected
*/
protected function barcode_postnet($code, $planet=false) {
// bar lenght
if ($planet) {
$barlen = Array(
0 => Array(1,1,2,2,2),
1 => Array(2,2,2,1,1),
2 => Array(2,2,1,2,1),
3 => Array(2,2,1,1,2),
4 => Array(2,1,2,2,1),
5 => Array(2,1,2,1,2),
6 => Array(2,1,1,2,2),
7 => Array(1,2,2,2,1),
8 => Array(1,2,2,1,2),
9 => Array(1,2,1,2,2)
);
} else {
$barlen = Array(
0 => Array(2,2,1,1,1),
1 => Array(1,1,1,2,2),
2 => Array(1,1,2,1,2),
3 => Array(1,1,2,2,1),
4 => Array(1,2,1,1,2),
5 => Array(1,2,1,2,1),
6 => Array(1,2,2,1,1),
7 => Array(2,1,1,1,2),
8 => Array(2,1,1,2,1),
9 => Array(2,1,2,1,1)
);
}
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
$k = 0;
$code = str_replace('-', '', $code);
$code = str_replace(' ', '', $code);
$len = strlen($code);
// calculate checksum
$sum = 0;
for ($i = 0; $i < $len; ++$i) {
$sum += intval($code{$i});
}
$chkd = ($sum % 10);
if($chkd > 0) {
$chkd = (10 - $chkd);
}
$code .= $chkd;
$len = strlen($code);
// start bar
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
for ($i = 0; $i < $len; ++$i) {
for ($j = 0; $j < 5; ++$j) {
$h = $barlen[$code{$i}][$j];
$p = floor(1 / $h);
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
}
}
// end bar
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 1;
return $bararray;
}
/**
* RMS4CC - CBC - KIX
* RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - KIX (Klant index - Customer index)
* RM4SCC is the name of the barcode symbology used by the Royal Mail for its Cleanmail service.
* @param string $code code to print
* @param boolean $kix if true prints the KIX variation (doesn't use the start and end symbols, and the checksum) - in this case the house number must be sufficed with an X and placed at the end of the code.
* @return array barcode representation.
* @access protected
*/
protected function barcode_rms4cc($code, $kix=false) {
$notkix = !$kix;
// bar mode
// 1 = pos 1, length 2
// 2 = pos 1, length 3
// 3 = pos 2, length 1
// 4 = pos 2, length 2
$barmode = array(
'0' => array(3,3,2,2),
'1' => array(3,4,1,2),
'2' => array(3,4,2,1),
'3' => array(4,3,1,2),
'4' => array(4,3,2,1),
'5' => array(4,4,1,1),
'6' => array(3,1,4,2),
'7' => array(3,2,3,2),
'8' => array(3,2,4,1),
'9' => array(4,1,3,2),
'A' => array(4,1,4,1),
'B' => array(4,2,3,1),
'C' => array(3,1,2,4),
'D' => array(3,2,1,4),
'E' => array(3,2,2,3),
'F' => array(4,1,1,4),
'G' => array(4,1,2,3),
'H' => array(4,2,1,3),
'I' => array(1,3,4,2),
'J' => array(1,4,3,2),
'K' => array(1,4,4,1),
'L' => array(2,3,3,2),
'M' => array(2,3,4,1),
'N' => array(2,4,3,1),
'O' => array(1,3,2,4),
'P' => array(1,4,1,4),
'Q' => array(1,4,2,3),
'R' => array(2,3,1,4),
'S' => array(2,3,2,3),
'T' => array(2,4,1,3),
'U' => array(1,1,4,4),
'V' => array(1,2,3,4),
'W' => array(1,2,4,3),
'X' => array(2,1,3,4),
'Y' => array(2,1,4,3),
'Z' => array(2,2,3,3)
);
$code = strtoupper($code);
$len = strlen($code);
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array());
if ($notkix) {
// table for checksum calculation (row,col)
$checktable = array(
'0' => array(1,1),
'1' => array(1,2),
'2' => array(1,3),
'3' => array(1,4),
'4' => array(1,5),
'5' => array(1,0),
'6' => array(2,1),
'7' => array(2,2),
'8' => array(2,3),
'9' => array(2,4),
'A' => array(2,5),
'B' => array(2,0),
'C' => array(3,1),
'D' => array(3,2),
'E' => array(3,3),
'F' => array(3,4),
'G' => array(3,5),
'H' => array(3,0),
'I' => array(4,1),
'J' => array(4,2),
'K' => array(4,3),
'L' => array(4,4),
'M' => array(4,5),
'N' => array(4,0),
'O' => array(5,1),
'P' => array(5,2),
'Q' => array(5,3),
'R' => array(5,4),
'S' => array(5,5),
'T' => array(5,0),
'U' => array(0,1),
'V' => array(0,2),
'W' => array(0,3),
'X' => array(0,4),
'Y' => array(0,5),
'Z' => array(0,0)
);
$row = 0;
$col = 0;
for ($i = 0; $i < $len; ++$i) {
$row += $checktable[$code{$i}][0];
$col += $checktable[$code{$i}][1];
}
$row %= 6;
$col %= 6;
$chk = array_keys($checktable, array($row,$col));
$code .= $chk[0];
++$len;
}
$k = 0;
if ($notkix) {
// start bar
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
}
for ($i = 0; $i < $len; ++$i) {
for ($j = 0; $j < 4; ++$j) {
switch ($barmode[$code{$i}][$j]) {
case 1: {
$p = 0;
$h = 2;
break;
}
case 2: {
$p = 0;
$h = 3;
break;
}
case 3: {
$p = 1;
$h = 1;
break;
}
case 4: {
$p = 1;
$h = 2;
break;
}
}
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
}
}
if ($notkix) {
// stop bar
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => 3, 'p' => 0);
$bararray['maxw'] += 1;
}
return $bararray;
}
/**
* CODABAR barcodes.
* Older code often used in library systems, sometimes in blood banks
* @param string $code code to represent.
* @return array barcode representation.
* @access protected
*/
protected function barcode_codabar($code) {
$chr = array(
'0' => '11111221',
'1' => '11112211',
'2' => '11121121',
'3' => '22111111',
'4' => '11211211',
'5' => '21111211',
'6' => '12111121',
'7' => '12112111',
'8' => '12211111',
'9' => '21121111',
'-' => '11122111',
'$' => '11221111',
':' => '21112121',
'/' => '21211121',
'.' => '21212111',
'+' => '11222221',
'A' => '11221211',
'B' => '12121121',
'C' => '11121221',
'D' => '11122211'
);
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$w = 0;
$seq = '';
$code = 'A'.strtoupper($code).'A';
$len = strlen($code);
for ($i = 0; $i < $len; ++$i) {
if (!isset($chr[$code{$i}])) {
return false;
}
$seq = $chr[$code{$i}];
for ($j = 0; $j < 8; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $seq{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
}
return $bararray;
}
/**
* CODE11 barcodes.
* Used primarily for labeling telecommunications equipment
* @param string $code code to represent.
* @return array barcode representation.
* @access protected
*/
protected function barcode_code11($code) {
$chr = array(
'0' => '111121',
'1' => '211121',
'2' => '121121',
'3' => '221111',
'4' => '112121',
'5' => '212111',
'6' => '122111',
'7' => '111221',
'8' => '211211',
'9' => '211111',
'-' => '112111',
'S' => '112211'
);
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
$k = 0;
$w = 0;
$seq = '';
$len = strlen($code);
// calculate check digit C
$p = 1;
$check = 0;
for ($i = ($len - 1); $i >= 0; --$i) {
$digit = $code{$i};
if ($digit == '-') {
$dval = 10;
} else {
$dval = intval($digit);
}
$check += ($dval * $p);
++$p;
if ($p > 10) {
$p = 1;
}
}
$check %= 11;
if ($check == 10) {
$check = '-';
}
$code .= $check;
if ($len > 10) {
// calculate check digit K
$p = 1;
$check = 0;
for ($i = $len; $i >= 0; --$i) {
$digit = $code{$i};
if ($digit == '-') {
$dval = 10;
} else {
$dval = intval($digit);
}
$check += ($dval * $p);
++$p;
if ($p > 9) {
$p = 1;
}
}
$check %= 11;
$code .= $check;
++$len;
}
$code = 'S'.$code.'S';
$len += 3;
for ($i = 0; $i < $len; ++$i) {
if (!isset($chr[$code{$i}])) {
return false;
}
$seq = $chr[$code{$i}];
for ($j = 0; $j < 6; ++$j) {
if (($j % 2) == 0) {
$t = true; // bar
} else {
$t = false; // space
}
$w = $seq{$j};
$bararray['bcode'][$k] = array('t' => $t, 'w' => $w, 'h' => 1, 'p' => 0);
$bararray['maxw'] += $w;
++$k;
}
}
return $bararray;
}
/**
* Pharmacode
* Contains digits (0 to 9)
* @param string $code code to represent.
* @return array barcode representation.
* @access protected
*/
protected function barcode_pharmacode($code) {
$seq = '';
$code = intval($code);
while ($code > 0) {
if (($code % 2) == 0) {
$seq .= '11100';
$code -= 2;
} else {
$seq .= '100';
$code -= 1;
}
$code /= 2;
}
$seq = substr($seq, 0, -2);
$seq = strrev($seq);
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
return $this->binseq_to_array($seq, $bararray);
}
/**
* Pharmacode two-track
* Contains digits (0 to 9)
* @param string $code code to represent.
* @return array barcode representation.
* @access protected
*/
protected function barcode_pharmacode2t($code) {
$seq = '';
$code = intval($code);
do {
switch ($code % 3) {
case 0: {
$seq .= '3';
$code = ($code - 3) / 3;
break;
}
case 1: {
$seq .= '1';
$code = ($code - 1) / 3;
break;
}
case 2: {
$seq .= '2';
$code = ($code - 2) / 3;
break;
}
}
} while($code != 0);
$seq = strrev($seq);
$k = 0;
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
$len = strlen($seq);
for ($i = 0; $i < $len; ++$i) {
switch ($seq{$i}) {
case '1': {
$p = 1;
$h = 1;
break;
}
case '2': {
$p = 0;
$h = 1;
break;
}
case '3': {
$p = 0;
$h = 2;
break;
}
}
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
}
unset($bararray['bcode'][($k - 1)]);
--$bararray['maxw'];
return $bararray;
}
/**
* IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
* (requires PHP bcmath extension)
* Intelligent Mail barcode is a 65-bar code for use on mail in the United States.
* The fields are described as follows:<ul><li>The Barcode Identifier shall be assigned by USPS to encode the presort identification that is currently printed in human readable form on the optional endorsement line (OEL) as well as for future USPS use. This shall be two digits, with the second digit in the range of 0–4. The allowable encoding ranges shall be 00–04, 10–14, 20–24, 30–34, 40–44, 50–54, 60–64, 70–74, 80–84, and 90–94.</li><li>The Service Type Identifier shall be assigned by USPS for any combination of services requested on the mailpiece. The allowable encoding range shall be 000http://it2.php.net/manual/en/function.dechex.php–999. Each 3-digit value shall correspond to a particular mail class with a particular combination of service(s). Each service program, such as OneCode Confirm and OneCode ACS, shall provide the list of Service Type Identifier values.</li><li>The Mailer or Customer Identifier shall be assigned by USPS as a unique, 6 or 9 digit number that identifies a business entity. The allowable encoding range for the 6 digit Mailer ID shall be 000000- 899999, while the allowable encoding range for the 9 digit Mailer ID shall be 900000000-999999999.</li><li>The Serial or Sequence Number shall be assigned by the mailer for uniquely identifying and tracking mailpieces. The allowable encoding range shall be 000000000–999999999 when used with a 6 digit Mailer ID and 000000-999999 when used with a 9 digit Mailer ID. e. The Delivery Point ZIP Code shall be assigned by the mailer for routing the mailpiece. This shall replace POSTNET for routing the mailpiece to its final delivery point. The length may be 0, 5, 9, or 11 digits. The allowable encoding ranges shall be no ZIP Code, 00000–99999, 000000000–999999999, and 00000000000–99999999999.</li></ul>
* @param string $code code to print, separate the ZIP (routing code) from the rest using a minus char '-' (BarcodeID_ServiceTypeID_MailerID_SerialNumber-RoutingCode)
* @return array barcode representation.
* @access protected
*/
protected function barcode_imb($code) {
$asc_chr = array(4,0,2,6,3,5,1,9,8,7,1,2,0,6,4,8,2,9,5,3,0,1,3,7,4,6,8,9,2,0,5,1,9,4,3,8,6,7,1,2,4,3,9,5,7,8,3,0,2,1,4,0,9,1,7,0,2,4,6,3,7,1,9,5,8);
$dsc_chr = array(7,1,9,5,8,0,2,4,6,3,5,8,9,7,3,0,6,1,7,4,6,8,9,2,5,1,7,5,4,3,8,7,6,0,2,5,4,9,3,0,1,6,8,2,0,4,5,9,6,7,5,2,6,3,8,5,1,9,8,7,4,0,2,6,3);
$asc_pos = array(3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9,6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2);
$dsc_pos = array(2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11,0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10);
$code_arr = explode('-', $code);
$tracking_number = $code_arr[0];
if (isset($code_arr[1])) {
$routing_code = $code_arr[1];
} else {
$routing_code = '';
}
// Conversion of Routing Code
switch (strlen($routing_code)) {
case 0: {
$binary_code = 0;
break;
}
case 5: {
$binary_code = bcadd($routing_code, '1');
break;
}
case 9: {
$binary_code = bcadd($routing_code, '100001');
break;
}
case 11: {
$binary_code = bcadd($routing_code, '1000100001');
break;
}
default: {
return false;
break;
}
}
$binary_code = bcmul($binary_code, 10);
$binary_code = bcadd($binary_code, $tracking_number{0});
$binary_code = bcmul($binary_code, 5);
$binary_code = bcadd($binary_code, $tracking_number{1});
$binary_code .= substr($tracking_number, 2, 18);
// convert to hexadecimal
$binary_code = $this->dec_to_hex($binary_code);
// pad to get 13 bytes
$binary_code = str_pad($binary_code, 26, '0', STR_PAD_LEFT);
// convert string to array of bytes
$binary_code_arr = chunk_split($binary_code, 2, "\r");
$binary_code_arr = substr($binary_code_arr, 0, -1);
$binary_code_arr = explode("\r", $binary_code_arr);
// calculate frame check sequence
$fcs = $this->imb_crc11fcs($binary_code_arr);
// exclude first 2 bits from first byte
$first_byte = sprintf('%2s', dechex((hexdec($binary_code_arr[0]) << 2) >> 2));
$binary_code_102bit = $first_byte.substr($binary_code, 2);
// convert binary data to codewords
$codewords = array();
$data = $this->hex_to_dec($binary_code_102bit);
$codewords[0] = bcmod($data, 636) * 2;
$data = bcdiv($data, 636);
for ($i = 1; $i < 9; ++$i) {
$codewords[$i] = bcmod($data, 1365);
$data = bcdiv($data, 1365);
}
$codewords[9] = $data;
if (($fcs >> 10) == 1) {
$codewords[9] += 659;
}
// generate lookup tables
$table2of13 = $this->imb_tables(2, 78);
$table5of13 = $this->imb_tables(5, 1287);
// convert codewords to characters
$characters = array();
$bitmask = 512;
foreach($codewords as $k => $val) {
if ($val <= 1286) {
$chrcode = $table5of13[$val];
} else {
$chrcode = $table2of13[($val - 1287)];
}
if (($fcs & $bitmask) > 0) {
// bitwise invert
$chrcode = ((~$chrcode) & 8191);
}
$characters[] = $chrcode;
$bitmask /= 2;
}
$characters = array_reverse($characters);
// build bars
$k = 0;
$bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array());
for ($i = 0; $i < 65; ++$i) {
$asc = (($characters[$asc_chr[$i]] & pow(2, $asc_pos[$i])) > 0);
$dsc = (($characters[$dsc_chr[$i]] & pow(2, $dsc_pos[$i])) > 0);
if ($asc AND $dsc) {
// full bar (F)
$p = 0;
$h = 3;
} elseif ($asc) {
// ascender (A)
$p = 0;
$h = 2;
} elseif ($dsc) {
// descender (D)
$p = 1;
$h = 2;
} else {
// tracker (T)
$p = 1;
$h = 1;
}
$bararray['bcode'][$k++] = array('t' => 1, 'w' => 1, 'h' => $h, 'p' => $p);
$bararray['bcode'][$k++] = array('t' => 0, 'w' => 1, 'h' => 2, 'p' => 0);
$bararray['maxw'] += 2;
}
unset($bararray['bcode'][($k - 1)]);
--$bararray['maxw'];
return $bararray;
}
/**
* Convert large integer number to hexadecimal representation.
* (requires PHP bcmath extension)
* @param string $number number to convert specified as a string
* @return string hexadecimal representation
*/
public function dec_to_hex($number) {
$i = 0;
$hex = array();
if($number == 0) {
return '00';
}
while($number > 0) {
if($number == 0) {
array_push($hex, '0');
} else {
array_push($hex, strtoupper(dechex(bcmod($number, '16'))));
$number = bcdiv($number, '16', 0);
}
}
$hex = array_reverse($hex);
return implode($hex);
}
/**
* Convert large hexadecimal number to decimal representation (string).
* (requires PHP bcmath extension)
* @param string $hex hexadecimal number to convert specified as a string
* @return string hexadecimal representation
*/
public function hex_to_dec($hex) {
$dec = 0;
$bitval = 1;
$len = strlen($hex);
for($pos = ($len - 1); $pos >= 0; --$pos) {
$dec = bcadd($dec, bcmul(hexdec($hex{$pos}), $bitval));
$bitval = bcmul($bitval, 16);
}
return $dec;
}
/**
* Intelligent Mail Barcode calculation of Frame Check Sequence
* @param string $code_arr array of hexadecimal values (13 bytes holding 102 bits right justified).
* @return int 11 bit Frame Check Sequence as integer (decimal base)
* @access protected
*/
protected function imb_crc11fcs($code_arr) {
$genpoly = 0x0F35; // generator polynomial
$fcs = 0x07FF; // Frame Check Sequence
// do most significant byte skipping the 2 most significant bits
$data = hexdec($code_arr[0]) << 5;
for ($bit = 2; $bit < 8; ++$bit) {
if (($fcs ^ $data) & 0x400) {
$fcs = ($fcs << 1) ^ $genpoly;
} else {
$fcs = ($fcs << 1);
}
$fcs &= 0x7FF;
$data <<= 1;
}
// do rest of bytes
for ($byte = 1; $byte < 13; ++$byte) {
$data = hexdec($code_arr[$byte]) << 3;
for ($bit = 0; $bit < 8; ++$bit) {
if (($fcs ^ $data) & 0x400) {
$fcs = ($fcs << 1) ^ $genpoly;
} else {
$fcs = ($fcs << 1);
}
$fcs &= 0x7FF;
$data <<= 1;
}
}
return $fcs;
}
/**
* Reverse unsigned short value
* @param int $num value to reversr
* @return int reversed value
* @access protected
*/
protected function imb_reverse_us($num) {
$rev = 0;
for ($i = 0; $i < 16; ++$i) {
$rev <<= 1;
$rev |= ($num & 1);
$num >>= 1;
}
return $rev;
}
/**
* generate Nof13 tables used for Intelligent Mail Barcode
* @param int $n is the type of table: 2 for 2of13 table, 5 for 5of13table
* @param int $size size of table (78 for n=2 and 1287 for n=5)
* @return array requested table
* @access protected
*/
protected function imb_tables($n, $size) {
$table = array();
$lli = 0; // LUT lower index
$lui = $size - 1; // LUT upper index
for ($count = 0; $count < 8192; ++$count) {
$bit_count = 0;
for ($bit_index = 0; $bit_index < 13; ++$bit_index) {
$bit_count += intval(($count & (1 << $bit_index)) != 0);
}
// if we don't have the right number of bits on, go on to the next value
if ($bit_count == $n) {
$reverse = ($this->imb_reverse_us($count) >> 3);
// if the reverse is less than count, we have already visited this pair before
if ($reverse >= $count) {
// If count is symmetric, place it at the first free slot from the end of the list.
// Otherwise, place it at the first free slot from the beginning of the list AND place $reverse ath the next free slot from the beginning of the list
if ($reverse == $count) {
$table[$lui] = $count;
--$lui;
} else {
$table[$lli] = $count;
++$lli;
$table[$lli] = $reverse;
++$lli;
}
}
}
}
return $table;
}
} // end of class
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/barcodes.php | PHP | asf20 | 60,253 |
<?php
//============================================================+
// File name : pdf417.php
// Version : 1.0.003
// Begin : 2010-06-03
// Last Update : 2010-08-08
// Author : Nicola Asuni - Tecnick.com S.r.l - Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
// Copyright (C) 2010-2010 Nicola Asuni - Tecnick.com S.r.l.
//
// This file is part of TCPDF software library.
//
// TCPDF 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 3 of the
// License, or (at your option) any later version.
//
// TCPDF 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 TCPDF. If not, see <http://www.gnu.org/licenses/>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// DESCRIPTION :
//
// Class to create PDF417 barcode arrays for TCPDF class.
// PDF417 (ISO/IEC 15438:2006) is a 2-dimensional stacked bar code created by Symbol Technologies in 1991.
// It is one of the most popular 2D codes because of its ability to be read with slightly modified handheld laser or linear CCD scanners.
// TECHNICAL DATA / FEATURES OF PDF417:
// Encodable Character Set: All 128 ASCII Characters (including extended)
// Code Type: Continuous, Multi-Row
// Symbol Height: 3 - 90 Rows
// Symbol Width: 90X - 583X
// Bidirectional Decoding: Yes
// Error Correction Characters: 2 - 512
// Maximum Data Characters: 1850 text, 2710 digits, 1108 bytes
//
//============================================================+
/**
* Class to create PDF417 barcode arrays for TCPDF class.
* PDF417 (ISO/IEC 15438:2006) is a 2-dimensional stacked bar code created by Symbol Technologies in 1991.
* (requires PHP bcmath extension)
* @package com.tecnick.tcpdf
* @abstract Class to create PDF417 barcode arrays for TCPDF class.
* @author Nicola Asuni
* @copyright 2010-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version 1.0.003
*/
// definitions
if (!defined('PDF417DEFS')) {
/**
* Indicate that definitions for this class are set
*/
define('PDF417DEFS', true);
// -----------------------------------------------------
/**
* Row height respect X dimension of single module
*/
define('ROWHEIGHT', 4);
/**
* Horizontal quiet zone in modules
*/
define('QUIETH', 2);
/**
* Vertical quiet zone in modules
*/
define('QUIETV', 2);
} // end of definitions
// #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#
if (!class_exists('PDF417', false)) {
/**
* Class to create PDF417 barcode arrays for TCPDF class.
* PDF417 (ISO/IEC 15438:2006) is a 2-dimensional stacked bar code created by Symbol Technologies in 1991.
* @name PDF417
* @package com.tecnick.tcpdf
* @abstract Class to create PDF417 barcode arrays for TCPDF class.
* @author Nicola Asuni
* @copyright 2010-2010 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
* @version 1.0.003
*/
class PDF417 {
/**
* @var barcode array to be returned which is readable by TCPDF
* @access protected
*/
protected $barcode_array = array();
/**
* @var start pattern
* @access protected
*/
protected $start_pattern = '11111111010101000';
/**
* @var start pattern
* @access protected
*/
protected $stop_pattern = '111111101000101001';
/**
* @var Text Compaction Sub-Modes (values 0xFB - 0xFF are used for submode changers)
* @access protected
*/
protected $textsubmodes = array(
array(0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x20,0xFD,0xFE,0xFF), // Alpha
array(0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x20,0xFD,0xFE,0xFF), // Lower
array(0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x26,0x0d,0x09,0x2c,0x3a,0x23,0x2d,0x2e,0x24,0x2f,0x2b,0x25,0x2a,0x3d,0x5e,0xFB,0x20,0xFD,0xFE,0xFF), // Mixed
array(0x3b,0x3c,0x3e,0x40,0x5b,0x5c,0x5d,0x5f,0x60,0x7e,0x21,0x0d,0x09,0x2c,0x3a,0x0a,0x2d,0x2e,0x24,0x2f,0x22,0x7c,0x2a,0x28,0x29,0x3f,0x7b,0x7d,0x27,0xFF) // Puntuaction
);
/**
* @var Switching codes for Text Compaction Sub-Modes
* @access protected
*/
protected $textlatch = array(
'01' => array(27), '02' => array(28), '03' => array(28,25), //
'10' => array(28,28), '12' => array(28), '13' => array(28,25), //
'20' => array(28), '21' => array(27), '23' => array(25), //
'30' => array(29), '31' => array(29,27), '32' => array(29,28) //
);
/**
* @var clusters of codewords (0, 3, 6)<br/>
* Values are hex equivalents of binary representation of bars (1 = bar, 0 = space).<br/>
* The codewords numbered from 900 to 928 have special meaning, some enable to switch between modes in order to optimise the code:<ul>
* <li>900 : Switch to "Text" mode</li>
* <li>901 : Switch to "Byte" mode</li>
* <li>902 : Switch to "Numeric" mode</li>
* <li>903 - 912 : Reserved</li>
* <li>913 : Switch to "Octet" only for the next codeword</li>
* <li>914 - 920 : Reserved</li>
* <li>921 : Initialization</li>
* <li>922 : Terminator codeword for Macro PDF control block</li>
* <li>923 : Sequence tag to identify the beginning of optional fields in the Macro PDF control block</li>
* <li>924 : Switch to "Byte" mode (If the total number of byte is multiple of 6)</li>
* <li>925 : Identifier for a user defined Extended Channel Interpretation (ECI)</li>
* <li>926 : Identifier for a general purpose ECI format</li>
* <li>927 : Identifier for an ECI of a character set or code page</li>
* <li>928 : Macro marker codeword to indicate the beginning of a Macro PDF Control Block</li>
* </ul>
* @access protected
*/
protected $clusters = array(
array( // cluster 0 -----------------------------------------------------------------------
0x1d5c0,0x1eaf0,0x1f57c,0x1d4e0,0x1ea78,0x1f53e,0x1a8c0,0x1d470,0x1a860,0x15040, // 10
0x1a830,0x15020,0x1adc0,0x1d6f0,0x1eb7c,0x1ace0,0x1d678,0x1eb3e,0x158c0,0x1ac70, // 20
0x15860,0x15dc0,0x1aef0,0x1d77c,0x15ce0,0x1ae78,0x1d73e,0x15c70,0x1ae3c,0x15ef0, // 30
0x1af7c,0x15e78,0x1af3e,0x15f7c,0x1f5fa,0x1d2e0,0x1e978,0x1f4be,0x1a4c0,0x1d270, // 40
0x1e93c,0x1a460,0x1d238,0x14840,0x1a430,0x1d21c,0x14820,0x1a418,0x14810,0x1a6e0, // 50
0x1d378,0x1e9be,0x14cc0,0x1a670,0x1d33c,0x14c60,0x1a638,0x1d31e,0x14c30,0x1a61c, // 60
0x14ee0,0x1a778,0x1d3be,0x14e70,0x1a73c,0x14e38,0x1a71e,0x14f78,0x1a7be,0x14f3c, // 70
0x14f1e,0x1a2c0,0x1d170,0x1e8bc,0x1a260,0x1d138,0x1e89e,0x14440,0x1a230,0x1d11c, // 80
0x14420,0x1a218,0x14410,0x14408,0x146c0,0x1a370,0x1d1bc,0x14660,0x1a338,0x1d19e, // 90
0x14630,0x1a31c,0x14618,0x1460c,0x14770,0x1a3bc,0x14738,0x1a39e,0x1471c,0x147bc, // 100
0x1a160,0x1d0b8,0x1e85e,0x14240,0x1a130,0x1d09c,0x14220,0x1a118,0x1d08e,0x14210, // 110
0x1a10c,0x14208,0x1a106,0x14360,0x1a1b8,0x1d0de,0x14330,0x1a19c,0x14318,0x1a18e, // 120
0x1430c,0x14306,0x1a1de,0x1438e,0x14140,0x1a0b0,0x1d05c,0x14120,0x1a098,0x1d04e, // 130
0x14110,0x1a08c,0x14108,0x1a086,0x14104,0x141b0,0x14198,0x1418c,0x140a0,0x1d02e, // 140
0x1a04c,0x1a046,0x14082,0x1cae0,0x1e578,0x1f2be,0x194c0,0x1ca70,0x1e53c,0x19460, // 150
0x1ca38,0x1e51e,0x12840,0x19430,0x12820,0x196e0,0x1cb78,0x1e5be,0x12cc0,0x19670, // 160
0x1cb3c,0x12c60,0x19638,0x12c30,0x12c18,0x12ee0,0x19778,0x1cbbe,0x12e70,0x1973c, // 170
0x12e38,0x12e1c,0x12f78,0x197be,0x12f3c,0x12fbe,0x1dac0,0x1ed70,0x1f6bc,0x1da60, // 180
0x1ed38,0x1f69e,0x1b440,0x1da30,0x1ed1c,0x1b420,0x1da18,0x1ed0e,0x1b410,0x1da0c, // 190
0x192c0,0x1c970,0x1e4bc,0x1b6c0,0x19260,0x1c938,0x1e49e,0x1b660,0x1db38,0x1ed9e, // 200
0x16c40,0x12420,0x19218,0x1c90e,0x16c20,0x1b618,0x16c10,0x126c0,0x19370,0x1c9bc, // 210
0x16ec0,0x12660,0x19338,0x1c99e,0x16e60,0x1b738,0x1db9e,0x16e30,0x12618,0x16e18, // 220
0x12770,0x193bc,0x16f70,0x12738,0x1939e,0x16f38,0x1b79e,0x16f1c,0x127bc,0x16fbc, // 230
0x1279e,0x16f9e,0x1d960,0x1ecb8,0x1f65e,0x1b240,0x1d930,0x1ec9c,0x1b220,0x1d918, // 240
0x1ec8e,0x1b210,0x1d90c,0x1b208,0x1b204,0x19160,0x1c8b8,0x1e45e,0x1b360,0x19130, // 250
0x1c89c,0x16640,0x12220,0x1d99c,0x1c88e,0x16620,0x12210,0x1910c,0x16610,0x1b30c, // 260
0x19106,0x12204,0x12360,0x191b8,0x1c8de,0x16760,0x12330,0x1919c,0x16730,0x1b39c, // 270
0x1918e,0x16718,0x1230c,0x12306,0x123b8,0x191de,0x167b8,0x1239c,0x1679c,0x1238e, // 280
0x1678e,0x167de,0x1b140,0x1d8b0,0x1ec5c,0x1b120,0x1d898,0x1ec4e,0x1b110,0x1d88c, // 290
0x1b108,0x1d886,0x1b104,0x1b102,0x12140,0x190b0,0x1c85c,0x16340,0x12120,0x19098, // 300
0x1c84e,0x16320,0x1b198,0x1d8ce,0x16310,0x12108,0x19086,0x16308,0x1b186,0x16304, // 310
0x121b0,0x190dc,0x163b0,0x12198,0x190ce,0x16398,0x1b1ce,0x1638c,0x12186,0x16386, // 320
0x163dc,0x163ce,0x1b0a0,0x1d858,0x1ec2e,0x1b090,0x1d84c,0x1b088,0x1d846,0x1b084, // 330
0x1b082,0x120a0,0x19058,0x1c82e,0x161a0,0x12090,0x1904c,0x16190,0x1b0cc,0x19046, // 340
0x16188,0x12084,0x16184,0x12082,0x120d8,0x161d8,0x161cc,0x161c6,0x1d82c,0x1d826, // 350
0x1b042,0x1902c,0x12048,0x160c8,0x160c4,0x160c2,0x18ac0,0x1c570,0x1e2bc,0x18a60, // 360
0x1c538,0x11440,0x18a30,0x1c51c,0x11420,0x18a18,0x11410,0x11408,0x116c0,0x18b70, // 370
0x1c5bc,0x11660,0x18b38,0x1c59e,0x11630,0x18b1c,0x11618,0x1160c,0x11770,0x18bbc, // 380
0x11738,0x18b9e,0x1171c,0x117bc,0x1179e,0x1cd60,0x1e6b8,0x1f35e,0x19a40,0x1cd30, // 390
0x1e69c,0x19a20,0x1cd18,0x1e68e,0x19a10,0x1cd0c,0x19a08,0x1cd06,0x18960,0x1c4b8, // 400
0x1e25e,0x19b60,0x18930,0x1c49c,0x13640,0x11220,0x1cd9c,0x1c48e,0x13620,0x19b18, // 410
0x1890c,0x13610,0x11208,0x13608,0x11360,0x189b8,0x1c4de,0x13760,0x11330,0x1cdde, // 420
0x13730,0x19b9c,0x1898e,0x13718,0x1130c,0x1370c,0x113b8,0x189de,0x137b8,0x1139c, // 430
0x1379c,0x1138e,0x113de,0x137de,0x1dd40,0x1eeb0,0x1f75c,0x1dd20,0x1ee98,0x1f74e, // 440
0x1dd10,0x1ee8c,0x1dd08,0x1ee86,0x1dd04,0x19940,0x1ccb0,0x1e65c,0x1bb40,0x19920, // 450
0x1eedc,0x1e64e,0x1bb20,0x1dd98,0x1eece,0x1bb10,0x19908,0x1cc86,0x1bb08,0x1dd86, // 460
0x19902,0x11140,0x188b0,0x1c45c,0x13340,0x11120,0x18898,0x1c44e,0x17740,0x13320, // 470
0x19998,0x1ccce,0x17720,0x1bb98,0x1ddce,0x18886,0x17710,0x13308,0x19986,0x17708, // 480
0x11102,0x111b0,0x188dc,0x133b0,0x11198,0x188ce,0x177b0,0x13398,0x199ce,0x17798, // 490
0x1bbce,0x11186,0x13386,0x111dc,0x133dc,0x111ce,0x177dc,0x133ce,0x1dca0,0x1ee58, // 500
0x1f72e,0x1dc90,0x1ee4c,0x1dc88,0x1ee46,0x1dc84,0x1dc82,0x198a0,0x1cc58,0x1e62e, // 510
0x1b9a0,0x19890,0x1ee6e,0x1b990,0x1dccc,0x1cc46,0x1b988,0x19884,0x1b984,0x19882, // 520
0x1b982,0x110a0,0x18858,0x1c42e,0x131a0,0x11090,0x1884c,0x173a0,0x13190,0x198cc, // 530
0x18846,0x17390,0x1b9cc,0x11084,0x17388,0x13184,0x11082,0x13182,0x110d8,0x1886e, // 540
0x131d8,0x110cc,0x173d8,0x131cc,0x110c6,0x173cc,0x131c6,0x110ee,0x173ee,0x1dc50, // 550
0x1ee2c,0x1dc48,0x1ee26,0x1dc44,0x1dc42,0x19850,0x1cc2c,0x1b8d0,0x19848,0x1cc26, // 560
0x1b8c8,0x1dc66,0x1b8c4,0x19842,0x1b8c2,0x11050,0x1882c,0x130d0,0x11048,0x18826, // 570
0x171d0,0x130c8,0x19866,0x171c8,0x1b8e6,0x11042,0x171c4,0x130c2,0x171c2,0x130ec, // 580
0x171ec,0x171e6,0x1ee16,0x1dc22,0x1cc16,0x19824,0x19822,0x11028,0x13068,0x170e8, // 590
0x11022,0x13062,0x18560,0x10a40,0x18530,0x10a20,0x18518,0x1c28e,0x10a10,0x1850c, // 600
0x10a08,0x18506,0x10b60,0x185b8,0x1c2de,0x10b30,0x1859c,0x10b18,0x1858e,0x10b0c, // 610
0x10b06,0x10bb8,0x185de,0x10b9c,0x10b8e,0x10bde,0x18d40,0x1c6b0,0x1e35c,0x18d20, // 620
0x1c698,0x18d10,0x1c68c,0x18d08,0x1c686,0x18d04,0x10940,0x184b0,0x1c25c,0x11b40, // 630
0x10920,0x1c6dc,0x1c24e,0x11b20,0x18d98,0x1c6ce,0x11b10,0x10908,0x18486,0x11b08, // 640
0x18d86,0x10902,0x109b0,0x184dc,0x11bb0,0x10998,0x184ce,0x11b98,0x18dce,0x11b8c, // 650
0x10986,0x109dc,0x11bdc,0x109ce,0x11bce,0x1cea0,0x1e758,0x1f3ae,0x1ce90,0x1e74c, // 660
0x1ce88,0x1e746,0x1ce84,0x1ce82,0x18ca0,0x1c658,0x19da0,0x18c90,0x1c64c,0x19d90, // 670
0x1cecc,0x1c646,0x19d88,0x18c84,0x19d84,0x18c82,0x19d82,0x108a0,0x18458,0x119a0, // 680
0x10890,0x1c66e,0x13ba0,0x11990,0x18ccc,0x18446,0x13b90,0x19dcc,0x10884,0x13b88, // 690
0x11984,0x10882,0x11982,0x108d8,0x1846e,0x119d8,0x108cc,0x13bd8,0x119cc,0x108c6, // 700
0x13bcc,0x119c6,0x108ee,0x119ee,0x13bee,0x1ef50,0x1f7ac,0x1ef48,0x1f7a6,0x1ef44, // 710
0x1ef42,0x1ce50,0x1e72c,0x1ded0,0x1ef6c,0x1e726,0x1dec8,0x1ef66,0x1dec4,0x1ce42, // 720
0x1dec2,0x18c50,0x1c62c,0x19cd0,0x18c48,0x1c626,0x1bdd0,0x19cc8,0x1ce66,0x1bdc8, // 730
0x1dee6,0x18c42,0x1bdc4,0x19cc2,0x1bdc2,0x10850,0x1842c,0x118d0,0x10848,0x18426, // 740
0x139d0,0x118c8,0x18c66,0x17bd0,0x139c8,0x19ce6,0x10842,0x17bc8,0x1bde6,0x118c2, // 750
0x17bc4,0x1086c,0x118ec,0x10866,0x139ec,0x118e6,0x17bec,0x139e6,0x17be6,0x1ef28, // 760
0x1f796,0x1ef24,0x1ef22,0x1ce28,0x1e716,0x1de68,0x1ef36,0x1de64,0x1ce22,0x1de62, // 770
0x18c28,0x1c616,0x19c68,0x18c24,0x1bce8,0x19c64,0x18c22,0x1bce4,0x19c62,0x1bce2, // 780
0x10828,0x18416,0x11868,0x18c36,0x138e8,0x11864,0x10822,0x179e8,0x138e4,0x11862, // 790
0x179e4,0x138e2,0x179e2,0x11876,0x179f6,0x1ef12,0x1de34,0x1de32,0x19c34,0x1bc74, // 800
0x1bc72,0x11834,0x13874,0x178f4,0x178f2,0x10540,0x10520,0x18298,0x10510,0x10508, // 810
0x10504,0x105b0,0x10598,0x1058c,0x10586,0x105dc,0x105ce,0x186a0,0x18690,0x1c34c, // 820
0x18688,0x1c346,0x18684,0x18682,0x104a0,0x18258,0x10da0,0x186d8,0x1824c,0x10d90, // 830
0x186cc,0x10d88,0x186c6,0x10d84,0x10482,0x10d82,0x104d8,0x1826e,0x10dd8,0x186ee, // 840
0x10dcc,0x104c6,0x10dc6,0x104ee,0x10dee,0x1c750,0x1c748,0x1c744,0x1c742,0x18650, // 850
0x18ed0,0x1c76c,0x1c326,0x18ec8,0x1c766,0x18ec4,0x18642,0x18ec2,0x10450,0x10cd0, // 860
0x10448,0x18226,0x11dd0,0x10cc8,0x10444,0x11dc8,0x10cc4,0x10442,0x11dc4,0x10cc2, // 870
0x1046c,0x10cec,0x10466,0x11dec,0x10ce6,0x11de6,0x1e7a8,0x1e7a4,0x1e7a2,0x1c728, // 880
0x1cf68,0x1e7b6,0x1cf64,0x1c722,0x1cf62,0x18628,0x1c316,0x18e68,0x1c736,0x19ee8, // 890
0x18e64,0x18622,0x19ee4,0x18e62,0x19ee2,0x10428,0x18216,0x10c68,0x18636,0x11ce8, // 900
0x10c64,0x10422,0x13de8,0x11ce4,0x10c62,0x13de4,0x11ce2,0x10436,0x10c76,0x11cf6, // 910
0x13df6,0x1f7d4,0x1f7d2,0x1e794,0x1efb4,0x1e792,0x1efb2,0x1c714,0x1cf34,0x1c712, // 920
0x1df74,0x1cf32,0x1df72,0x18614,0x18e34,0x18612,0x19e74,0x18e32,0x1bef4), // 929
array( // cluster 3 -----------------------------------------------------------------------
0x1f560,0x1fab8,0x1ea40,0x1f530,0x1fa9c,0x1ea20,0x1f518,0x1fa8e,0x1ea10,0x1f50c, // 10
0x1ea08,0x1f506,0x1ea04,0x1eb60,0x1f5b8,0x1fade,0x1d640,0x1eb30,0x1f59c,0x1d620, // 20
0x1eb18,0x1f58e,0x1d610,0x1eb0c,0x1d608,0x1eb06,0x1d604,0x1d760,0x1ebb8,0x1f5de, // 30
0x1ae40,0x1d730,0x1eb9c,0x1ae20,0x1d718,0x1eb8e,0x1ae10,0x1d70c,0x1ae08,0x1d706, // 40
0x1ae04,0x1af60,0x1d7b8,0x1ebde,0x15e40,0x1af30,0x1d79c,0x15e20,0x1af18,0x1d78e, // 50
0x15e10,0x1af0c,0x15e08,0x1af06,0x15f60,0x1afb8,0x1d7de,0x15f30,0x1af9c,0x15f18, // 60
0x1af8e,0x15f0c,0x15fb8,0x1afde,0x15f9c,0x15f8e,0x1e940,0x1f4b0,0x1fa5c,0x1e920, // 70
0x1f498,0x1fa4e,0x1e910,0x1f48c,0x1e908,0x1f486,0x1e904,0x1e902,0x1d340,0x1e9b0, // 80
0x1f4dc,0x1d320,0x1e998,0x1f4ce,0x1d310,0x1e98c,0x1d308,0x1e986,0x1d304,0x1d302, // 90
0x1a740,0x1d3b0,0x1e9dc,0x1a720,0x1d398,0x1e9ce,0x1a710,0x1d38c,0x1a708,0x1d386, // 100
0x1a704,0x1a702,0x14f40,0x1a7b0,0x1d3dc,0x14f20,0x1a798,0x1d3ce,0x14f10,0x1a78c, // 110
0x14f08,0x1a786,0x14f04,0x14fb0,0x1a7dc,0x14f98,0x1a7ce,0x14f8c,0x14f86,0x14fdc, // 120
0x14fce,0x1e8a0,0x1f458,0x1fa2e,0x1e890,0x1f44c,0x1e888,0x1f446,0x1e884,0x1e882, // 130
0x1d1a0,0x1e8d8,0x1f46e,0x1d190,0x1e8cc,0x1d188,0x1e8c6,0x1d184,0x1d182,0x1a3a0, // 140
0x1d1d8,0x1e8ee,0x1a390,0x1d1cc,0x1a388,0x1d1c6,0x1a384,0x1a382,0x147a0,0x1a3d8, // 150
0x1d1ee,0x14790,0x1a3cc,0x14788,0x1a3c6,0x14784,0x14782,0x147d8,0x1a3ee,0x147cc, // 160
0x147c6,0x147ee,0x1e850,0x1f42c,0x1e848,0x1f426,0x1e844,0x1e842,0x1d0d0,0x1e86c, // 170
0x1d0c8,0x1e866,0x1d0c4,0x1d0c2,0x1a1d0,0x1d0ec,0x1a1c8,0x1d0e6,0x1a1c4,0x1a1c2, // 180
0x143d0,0x1a1ec,0x143c8,0x1a1e6,0x143c4,0x143c2,0x143ec,0x143e6,0x1e828,0x1f416, // 190
0x1e824,0x1e822,0x1d068,0x1e836,0x1d064,0x1d062,0x1a0e8,0x1d076,0x1a0e4,0x1a0e2, // 200
0x141e8,0x1a0f6,0x141e4,0x141e2,0x1e814,0x1e812,0x1d034,0x1d032,0x1a074,0x1a072, // 210
0x1e540,0x1f2b0,0x1f95c,0x1e520,0x1f298,0x1f94e,0x1e510,0x1f28c,0x1e508,0x1f286, // 220
0x1e504,0x1e502,0x1cb40,0x1e5b0,0x1f2dc,0x1cb20,0x1e598,0x1f2ce,0x1cb10,0x1e58c, // 230
0x1cb08,0x1e586,0x1cb04,0x1cb02,0x19740,0x1cbb0,0x1e5dc,0x19720,0x1cb98,0x1e5ce, // 240
0x19710,0x1cb8c,0x19708,0x1cb86,0x19704,0x19702,0x12f40,0x197b0,0x1cbdc,0x12f20, // 250
0x19798,0x1cbce,0x12f10,0x1978c,0x12f08,0x19786,0x12f04,0x12fb0,0x197dc,0x12f98, // 260
0x197ce,0x12f8c,0x12f86,0x12fdc,0x12fce,0x1f6a0,0x1fb58,0x16bf0,0x1f690,0x1fb4c, // 270
0x169f8,0x1f688,0x1fb46,0x168fc,0x1f684,0x1f682,0x1e4a0,0x1f258,0x1f92e,0x1eda0, // 280
0x1e490,0x1fb6e,0x1ed90,0x1f6cc,0x1f246,0x1ed88,0x1e484,0x1ed84,0x1e482,0x1ed82, // 290
0x1c9a0,0x1e4d8,0x1f26e,0x1dba0,0x1c990,0x1e4cc,0x1db90,0x1edcc,0x1e4c6,0x1db88, // 300
0x1c984,0x1db84,0x1c982,0x1db82,0x193a0,0x1c9d8,0x1e4ee,0x1b7a0,0x19390,0x1c9cc, // 310
0x1b790,0x1dbcc,0x1c9c6,0x1b788,0x19384,0x1b784,0x19382,0x1b782,0x127a0,0x193d8, // 320
0x1c9ee,0x16fa0,0x12790,0x193cc,0x16f90,0x1b7cc,0x193c6,0x16f88,0x12784,0x16f84, // 330
0x12782,0x127d8,0x193ee,0x16fd8,0x127cc,0x16fcc,0x127c6,0x16fc6,0x127ee,0x1f650, // 340
0x1fb2c,0x165f8,0x1f648,0x1fb26,0x164fc,0x1f644,0x1647e,0x1f642,0x1e450,0x1f22c, // 350
0x1ecd0,0x1e448,0x1f226,0x1ecc8,0x1f666,0x1ecc4,0x1e442,0x1ecc2,0x1c8d0,0x1e46c, // 360
0x1d9d0,0x1c8c8,0x1e466,0x1d9c8,0x1ece6,0x1d9c4,0x1c8c2,0x1d9c2,0x191d0,0x1c8ec, // 370
0x1b3d0,0x191c8,0x1c8e6,0x1b3c8,0x1d9e6,0x1b3c4,0x191c2,0x1b3c2,0x123d0,0x191ec, // 380
0x167d0,0x123c8,0x191e6,0x167c8,0x1b3e6,0x167c4,0x123c2,0x167c2,0x123ec,0x167ec, // 390
0x123e6,0x167e6,0x1f628,0x1fb16,0x162fc,0x1f624,0x1627e,0x1f622,0x1e428,0x1f216, // 400
0x1ec68,0x1f636,0x1ec64,0x1e422,0x1ec62,0x1c868,0x1e436,0x1d8e8,0x1c864,0x1d8e4, // 410
0x1c862,0x1d8e2,0x190e8,0x1c876,0x1b1e8,0x1d8f6,0x1b1e4,0x190e2,0x1b1e2,0x121e8, // 420
0x190f6,0x163e8,0x121e4,0x163e4,0x121e2,0x163e2,0x121f6,0x163f6,0x1f614,0x1617e, // 430
0x1f612,0x1e414,0x1ec34,0x1e412,0x1ec32,0x1c834,0x1d874,0x1c832,0x1d872,0x19074, // 440
0x1b0f4,0x19072,0x1b0f2,0x120f4,0x161f4,0x120f2,0x161f2,0x1f60a,0x1e40a,0x1ec1a, // 450
0x1c81a,0x1d83a,0x1903a,0x1b07a,0x1e2a0,0x1f158,0x1f8ae,0x1e290,0x1f14c,0x1e288, // 460
0x1f146,0x1e284,0x1e282,0x1c5a0,0x1e2d8,0x1f16e,0x1c590,0x1e2cc,0x1c588,0x1e2c6, // 470
0x1c584,0x1c582,0x18ba0,0x1c5d8,0x1e2ee,0x18b90,0x1c5cc,0x18b88,0x1c5c6,0x18b84, // 480
0x18b82,0x117a0,0x18bd8,0x1c5ee,0x11790,0x18bcc,0x11788,0x18bc6,0x11784,0x11782, // 490
0x117d8,0x18bee,0x117cc,0x117c6,0x117ee,0x1f350,0x1f9ac,0x135f8,0x1f348,0x1f9a6, // 500
0x134fc,0x1f344,0x1347e,0x1f342,0x1e250,0x1f12c,0x1e6d0,0x1e248,0x1f126,0x1e6c8, // 510
0x1f366,0x1e6c4,0x1e242,0x1e6c2,0x1c4d0,0x1e26c,0x1cdd0,0x1c4c8,0x1e266,0x1cdc8, // 520
0x1e6e6,0x1cdc4,0x1c4c2,0x1cdc2,0x189d0,0x1c4ec,0x19bd0,0x189c8,0x1c4e6,0x19bc8, // 530
0x1cde6,0x19bc4,0x189c2,0x19bc2,0x113d0,0x189ec,0x137d0,0x113c8,0x189e6,0x137c8, // 540
0x19be6,0x137c4,0x113c2,0x137c2,0x113ec,0x137ec,0x113e6,0x137e6,0x1fba8,0x175f0, // 550
0x1bafc,0x1fba4,0x174f8,0x1ba7e,0x1fba2,0x1747c,0x1743e,0x1f328,0x1f996,0x132fc, // 560
0x1f768,0x1fbb6,0x176fc,0x1327e,0x1f764,0x1f322,0x1767e,0x1f762,0x1e228,0x1f116, // 570
0x1e668,0x1e224,0x1eee8,0x1f776,0x1e222,0x1eee4,0x1e662,0x1eee2,0x1c468,0x1e236, // 580
0x1cce8,0x1c464,0x1dde8,0x1cce4,0x1c462,0x1dde4,0x1cce2,0x1dde2,0x188e8,0x1c476, // 590
0x199e8,0x188e4,0x1bbe8,0x199e4,0x188e2,0x1bbe4,0x199e2,0x1bbe2,0x111e8,0x188f6, // 600
0x133e8,0x111e4,0x177e8,0x133e4,0x111e2,0x177e4,0x133e2,0x177e2,0x111f6,0x133f6, // 610
0x1fb94,0x172f8,0x1b97e,0x1fb92,0x1727c,0x1723e,0x1f314,0x1317e,0x1f734,0x1f312, // 620
0x1737e,0x1f732,0x1e214,0x1e634,0x1e212,0x1ee74,0x1e632,0x1ee72,0x1c434,0x1cc74, // 630
0x1c432,0x1dcf4,0x1cc72,0x1dcf2,0x18874,0x198f4,0x18872,0x1b9f4,0x198f2,0x1b9f2, // 640
0x110f4,0x131f4,0x110f2,0x173f4,0x131f2,0x173f2,0x1fb8a,0x1717c,0x1713e,0x1f30a, // 650
0x1f71a,0x1e20a,0x1e61a,0x1ee3a,0x1c41a,0x1cc3a,0x1dc7a,0x1883a,0x1987a,0x1b8fa, // 660
0x1107a,0x130fa,0x171fa,0x170be,0x1e150,0x1f0ac,0x1e148,0x1f0a6,0x1e144,0x1e142, // 670
0x1c2d0,0x1e16c,0x1c2c8,0x1e166,0x1c2c4,0x1c2c2,0x185d0,0x1c2ec,0x185c8,0x1c2e6, // 680
0x185c4,0x185c2,0x10bd0,0x185ec,0x10bc8,0x185e6,0x10bc4,0x10bc2,0x10bec,0x10be6, // 690
0x1f1a8,0x1f8d6,0x11afc,0x1f1a4,0x11a7e,0x1f1a2,0x1e128,0x1f096,0x1e368,0x1e124, // 700
0x1e364,0x1e122,0x1e362,0x1c268,0x1e136,0x1c6e8,0x1c264,0x1c6e4,0x1c262,0x1c6e2, // 710
0x184e8,0x1c276,0x18de8,0x184e4,0x18de4,0x184e2,0x18de2,0x109e8,0x184f6,0x11be8, // 720
0x109e4,0x11be4,0x109e2,0x11be2,0x109f6,0x11bf6,0x1f9d4,0x13af8,0x19d7e,0x1f9d2, // 730
0x13a7c,0x13a3e,0x1f194,0x1197e,0x1f3b4,0x1f192,0x13b7e,0x1f3b2,0x1e114,0x1e334, // 740
0x1e112,0x1e774,0x1e332,0x1e772,0x1c234,0x1c674,0x1c232,0x1cef4,0x1c672,0x1cef2, // 750
0x18474,0x18cf4,0x18472,0x19df4,0x18cf2,0x19df2,0x108f4,0x119f4,0x108f2,0x13bf4, // 760
0x119f2,0x13bf2,0x17af0,0x1bd7c,0x17a78,0x1bd3e,0x17a3c,0x17a1e,0x1f9ca,0x1397c, // 770
0x1fbda,0x17b7c,0x1393e,0x17b3e,0x1f18a,0x1f39a,0x1f7ba,0x1e10a,0x1e31a,0x1e73a, // 780
0x1ef7a,0x1c21a,0x1c63a,0x1ce7a,0x1defa,0x1843a,0x18c7a,0x19cfa,0x1bdfa,0x1087a, // 790
0x118fa,0x139fa,0x17978,0x1bcbe,0x1793c,0x1791e,0x138be,0x179be,0x178bc,0x1789e, // 800
0x1785e,0x1e0a8,0x1e0a4,0x1e0a2,0x1c168,0x1e0b6,0x1c164,0x1c162,0x182e8,0x1c176, // 810
0x182e4,0x182e2,0x105e8,0x182f6,0x105e4,0x105e2,0x105f6,0x1f0d4,0x10d7e,0x1f0d2, // 820
0x1e094,0x1e1b4,0x1e092,0x1e1b2,0x1c134,0x1c374,0x1c132,0x1c372,0x18274,0x186f4, // 830
0x18272,0x186f2,0x104f4,0x10df4,0x104f2,0x10df2,0x1f8ea,0x11d7c,0x11d3e,0x1f0ca, // 840
0x1f1da,0x1e08a,0x1e19a,0x1e3ba,0x1c11a,0x1c33a,0x1c77a,0x1823a,0x1867a,0x18efa, // 850
0x1047a,0x10cfa,0x11dfa,0x13d78,0x19ebe,0x13d3c,0x13d1e,0x11cbe,0x13dbe,0x17d70, // 860
0x1bebc,0x17d38,0x1be9e,0x17d1c,0x17d0e,0x13cbc,0x17dbc,0x13c9e,0x17d9e,0x17cb8, // 870
0x1be5e,0x17c9c,0x17c8e,0x13c5e,0x17cde,0x17c5c,0x17c4e,0x17c2e,0x1c0b4,0x1c0b2, // 880
0x18174,0x18172,0x102f4,0x102f2,0x1e0da,0x1c09a,0x1c1ba,0x1813a,0x1837a,0x1027a, // 890
0x106fa,0x10ebe,0x11ebc,0x11e9e,0x13eb8,0x19f5e,0x13e9c,0x13e8e,0x11e5e,0x13ede, // 900
0x17eb0,0x1bf5c,0x17e98,0x1bf4e,0x17e8c,0x17e86,0x13e5c,0x17edc,0x13e4e,0x17ece, // 910
0x17e58,0x1bf2e,0x17e4c,0x17e46,0x13e2e,0x17e6e,0x17e2c,0x17e26,0x10f5e,0x11f5c, // 920
0x11f4e,0x13f58,0x19fae,0x13f4c,0x13f46,0x11f2e,0x13f6e,0x13f2c,0x13f26), // 929
array( // cluster 6 -----------------------------------------------------------------------
0x1abe0,0x1d5f8,0x153c0,0x1a9f0,0x1d4fc,0x151e0,0x1a8f8,0x1d47e,0x150f0,0x1a87c, // 10
0x15078,0x1fad0,0x15be0,0x1adf8,0x1fac8,0x159f0,0x1acfc,0x1fac4,0x158f8,0x1ac7e, // 20
0x1fac2,0x1587c,0x1f5d0,0x1faec,0x15df8,0x1f5c8,0x1fae6,0x15cfc,0x1f5c4,0x15c7e, // 30
0x1f5c2,0x1ebd0,0x1f5ec,0x1ebc8,0x1f5e6,0x1ebc4,0x1ebc2,0x1d7d0,0x1ebec,0x1d7c8, // 40
0x1ebe6,0x1d7c4,0x1d7c2,0x1afd0,0x1d7ec,0x1afc8,0x1d7e6,0x1afc4,0x14bc0,0x1a5f0, // 50
0x1d2fc,0x149e0,0x1a4f8,0x1d27e,0x148f0,0x1a47c,0x14878,0x1a43e,0x1483c,0x1fa68, // 60
0x14df0,0x1a6fc,0x1fa64,0x14cf8,0x1a67e,0x1fa62,0x14c7c,0x14c3e,0x1f4e8,0x1fa76, // 70
0x14efc,0x1f4e4,0x14e7e,0x1f4e2,0x1e9e8,0x1f4f6,0x1e9e4,0x1e9e2,0x1d3e8,0x1e9f6, // 80
0x1d3e4,0x1d3e2,0x1a7e8,0x1d3f6,0x1a7e4,0x1a7e2,0x145e0,0x1a2f8,0x1d17e,0x144f0, // 90
0x1a27c,0x14478,0x1a23e,0x1443c,0x1441e,0x1fa34,0x146f8,0x1a37e,0x1fa32,0x1467c, // 100
0x1463e,0x1f474,0x1477e,0x1f472,0x1e8f4,0x1e8f2,0x1d1f4,0x1d1f2,0x1a3f4,0x1a3f2, // 110
0x142f0,0x1a17c,0x14278,0x1a13e,0x1423c,0x1421e,0x1fa1a,0x1437c,0x1433e,0x1f43a, // 120
0x1e87a,0x1d0fa,0x14178,0x1a0be,0x1413c,0x1411e,0x141be,0x140bc,0x1409e,0x12bc0, // 130
0x195f0,0x1cafc,0x129e0,0x194f8,0x1ca7e,0x128f0,0x1947c,0x12878,0x1943e,0x1283c, // 140
0x1f968,0x12df0,0x196fc,0x1f964,0x12cf8,0x1967e,0x1f962,0x12c7c,0x12c3e,0x1f2e8, // 150
0x1f976,0x12efc,0x1f2e4,0x12e7e,0x1f2e2,0x1e5e8,0x1f2f6,0x1e5e4,0x1e5e2,0x1cbe8, // 160
0x1e5f6,0x1cbe4,0x1cbe2,0x197e8,0x1cbf6,0x197e4,0x197e2,0x1b5e0,0x1daf8,0x1ed7e, // 170
0x169c0,0x1b4f0,0x1da7c,0x168e0,0x1b478,0x1da3e,0x16870,0x1b43c,0x16838,0x1b41e, // 180
0x1681c,0x125e0,0x192f8,0x1c97e,0x16de0,0x124f0,0x1927c,0x16cf0,0x1b67c,0x1923e, // 190
0x16c78,0x1243c,0x16c3c,0x1241e,0x16c1e,0x1f934,0x126f8,0x1937e,0x1fb74,0x1f932, // 200
0x16ef8,0x1267c,0x1fb72,0x16e7c,0x1263e,0x16e3e,0x1f274,0x1277e,0x1f6f4,0x1f272, // 210
0x16f7e,0x1f6f2,0x1e4f4,0x1edf4,0x1e4f2,0x1edf2,0x1c9f4,0x1dbf4,0x1c9f2,0x1dbf2, // 220
0x193f4,0x193f2,0x165c0,0x1b2f0,0x1d97c,0x164e0,0x1b278,0x1d93e,0x16470,0x1b23c, // 230
0x16438,0x1b21e,0x1641c,0x1640e,0x122f0,0x1917c,0x166f0,0x12278,0x1913e,0x16678, // 240
0x1b33e,0x1663c,0x1221e,0x1661e,0x1f91a,0x1237c,0x1fb3a,0x1677c,0x1233e,0x1673e, // 250
0x1f23a,0x1f67a,0x1e47a,0x1ecfa,0x1c8fa,0x1d9fa,0x191fa,0x162e0,0x1b178,0x1d8be, // 260
0x16270,0x1b13c,0x16238,0x1b11e,0x1621c,0x1620e,0x12178,0x190be,0x16378,0x1213c, // 270
0x1633c,0x1211e,0x1631e,0x121be,0x163be,0x16170,0x1b0bc,0x16138,0x1b09e,0x1611c, // 280
0x1610e,0x120bc,0x161bc,0x1209e,0x1619e,0x160b8,0x1b05e,0x1609c,0x1608e,0x1205e, // 290
0x160de,0x1605c,0x1604e,0x115e0,0x18af8,0x1c57e,0x114f0,0x18a7c,0x11478,0x18a3e, // 300
0x1143c,0x1141e,0x1f8b4,0x116f8,0x18b7e,0x1f8b2,0x1167c,0x1163e,0x1f174,0x1177e, // 310
0x1f172,0x1e2f4,0x1e2f2,0x1c5f4,0x1c5f2,0x18bf4,0x18bf2,0x135c0,0x19af0,0x1cd7c, // 320
0x134e0,0x19a78,0x1cd3e,0x13470,0x19a3c,0x13438,0x19a1e,0x1341c,0x1340e,0x112f0, // 330
0x1897c,0x136f0,0x11278,0x1893e,0x13678,0x19b3e,0x1363c,0x1121e,0x1361e,0x1f89a, // 340
0x1137c,0x1f9ba,0x1377c,0x1133e,0x1373e,0x1f13a,0x1f37a,0x1e27a,0x1e6fa,0x1c4fa, // 350
0x1cdfa,0x189fa,0x1bae0,0x1dd78,0x1eebe,0x174c0,0x1ba70,0x1dd3c,0x17460,0x1ba38, // 360
0x1dd1e,0x17430,0x1ba1c,0x17418,0x1ba0e,0x1740c,0x132e0,0x19978,0x1ccbe,0x176e0, // 370
0x13270,0x1993c,0x17670,0x1bb3c,0x1991e,0x17638,0x1321c,0x1761c,0x1320e,0x1760e, // 380
0x11178,0x188be,0x13378,0x1113c,0x17778,0x1333c,0x1111e,0x1773c,0x1331e,0x1771e, // 390
0x111be,0x133be,0x177be,0x172c0,0x1b970,0x1dcbc,0x17260,0x1b938,0x1dc9e,0x17230, // 400
0x1b91c,0x17218,0x1b90e,0x1720c,0x17206,0x13170,0x198bc,0x17370,0x13138,0x1989e, // 410
0x17338,0x1b99e,0x1731c,0x1310e,0x1730e,0x110bc,0x131bc,0x1109e,0x173bc,0x1319e, // 420
0x1739e,0x17160,0x1b8b8,0x1dc5e,0x17130,0x1b89c,0x17118,0x1b88e,0x1710c,0x17106, // 430
0x130b8,0x1985e,0x171b8,0x1309c,0x1719c,0x1308e,0x1718e,0x1105e,0x130de,0x171de, // 440
0x170b0,0x1b85c,0x17098,0x1b84e,0x1708c,0x17086,0x1305c,0x170dc,0x1304e,0x170ce, // 450
0x17058,0x1b82e,0x1704c,0x17046,0x1302e,0x1706e,0x1702c,0x17026,0x10af0,0x1857c, // 460
0x10a78,0x1853e,0x10a3c,0x10a1e,0x10b7c,0x10b3e,0x1f0ba,0x1e17a,0x1c2fa,0x185fa, // 470
0x11ae0,0x18d78,0x1c6be,0x11a70,0x18d3c,0x11a38,0x18d1e,0x11a1c,0x11a0e,0x10978, // 480
0x184be,0x11b78,0x1093c,0x11b3c,0x1091e,0x11b1e,0x109be,0x11bbe,0x13ac0,0x19d70, // 490
0x1cebc,0x13a60,0x19d38,0x1ce9e,0x13a30,0x19d1c,0x13a18,0x19d0e,0x13a0c,0x13a06, // 500
0x11970,0x18cbc,0x13b70,0x11938,0x18c9e,0x13b38,0x1191c,0x13b1c,0x1190e,0x13b0e, // 510
0x108bc,0x119bc,0x1089e,0x13bbc,0x1199e,0x13b9e,0x1bd60,0x1deb8,0x1ef5e,0x17a40, // 520
0x1bd30,0x1de9c,0x17a20,0x1bd18,0x1de8e,0x17a10,0x1bd0c,0x17a08,0x1bd06,0x17a04, // 530
0x13960,0x19cb8,0x1ce5e,0x17b60,0x13930,0x19c9c,0x17b30,0x1bd9c,0x19c8e,0x17b18, // 540
0x1390c,0x17b0c,0x13906,0x17b06,0x118b8,0x18c5e,0x139b8,0x1189c,0x17bb8,0x1399c, // 550
0x1188e,0x17b9c,0x1398e,0x17b8e,0x1085e,0x118de,0x139de,0x17bde,0x17940,0x1bcb0, // 560
0x1de5c,0x17920,0x1bc98,0x1de4e,0x17910,0x1bc8c,0x17908,0x1bc86,0x17904,0x17902, // 570
0x138b0,0x19c5c,0x179b0,0x13898,0x19c4e,0x17998,0x1bcce,0x1798c,0x13886,0x17986, // 580
0x1185c,0x138dc,0x1184e,0x179dc,0x138ce,0x179ce,0x178a0,0x1bc58,0x1de2e,0x17890, // 590
0x1bc4c,0x17888,0x1bc46,0x17884,0x17882,0x13858,0x19c2e,0x178d8,0x1384c,0x178cc, // 600
0x13846,0x178c6,0x1182e,0x1386e,0x178ee,0x17850,0x1bc2c,0x17848,0x1bc26,0x17844, // 610
0x17842,0x1382c,0x1786c,0x13826,0x17866,0x17828,0x1bc16,0x17824,0x17822,0x13816, // 620
0x17836,0x10578,0x182be,0x1053c,0x1051e,0x105be,0x10d70,0x186bc,0x10d38,0x1869e, // 630
0x10d1c,0x10d0e,0x104bc,0x10dbc,0x1049e,0x10d9e,0x11d60,0x18eb8,0x1c75e,0x11d30, // 640
0x18e9c,0x11d18,0x18e8e,0x11d0c,0x11d06,0x10cb8,0x1865e,0x11db8,0x10c9c,0x11d9c, // 650
0x10c8e,0x11d8e,0x1045e,0x10cde,0x11dde,0x13d40,0x19eb0,0x1cf5c,0x13d20,0x19e98, // 660
0x1cf4e,0x13d10,0x19e8c,0x13d08,0x19e86,0x13d04,0x13d02,0x11cb0,0x18e5c,0x13db0, // 670
0x11c98,0x18e4e,0x13d98,0x19ece,0x13d8c,0x11c86,0x13d86,0x10c5c,0x11cdc,0x10c4e, // 680
0x13ddc,0x11cce,0x13dce,0x1bea0,0x1df58,0x1efae,0x1be90,0x1df4c,0x1be88,0x1df46, // 690
0x1be84,0x1be82,0x13ca0,0x19e58,0x1cf2e,0x17da0,0x13c90,0x19e4c,0x17d90,0x1becc, // 700
0x19e46,0x17d88,0x13c84,0x17d84,0x13c82,0x17d82,0x11c58,0x18e2e,0x13cd8,0x11c4c, // 710
0x17dd8,0x13ccc,0x11c46,0x17dcc,0x13cc6,0x17dc6,0x10c2e,0x11c6e,0x13cee,0x17dee, // 720
0x1be50,0x1df2c,0x1be48,0x1df26,0x1be44,0x1be42,0x13c50,0x19e2c,0x17cd0,0x13c48, // 730
0x19e26,0x17cc8,0x1be66,0x17cc4,0x13c42,0x17cc2,0x11c2c,0x13c6c,0x11c26,0x17cec, // 740
0x13c66,0x17ce6,0x1be28,0x1df16,0x1be24,0x1be22,0x13c28,0x19e16,0x17c68,0x13c24, // 750
0x17c64,0x13c22,0x17c62,0x11c16,0x13c36,0x17c76,0x1be14,0x1be12,0x13c14,0x17c34, // 760
0x13c12,0x17c32,0x102bc,0x1029e,0x106b8,0x1835e,0x1069c,0x1068e,0x1025e,0x106de, // 770
0x10eb0,0x1875c,0x10e98,0x1874e,0x10e8c,0x10e86,0x1065c,0x10edc,0x1064e,0x10ece, // 780
0x11ea0,0x18f58,0x1c7ae,0x11e90,0x18f4c,0x11e88,0x18f46,0x11e84,0x11e82,0x10e58, // 790
0x1872e,0x11ed8,0x18f6e,0x11ecc,0x10e46,0x11ec6,0x1062e,0x10e6e,0x11eee,0x19f50, // 800
0x1cfac,0x19f48,0x1cfa6,0x19f44,0x19f42,0x11e50,0x18f2c,0x13ed0,0x19f6c,0x18f26, // 810
0x13ec8,0x11e44,0x13ec4,0x11e42,0x13ec2,0x10e2c,0x11e6c,0x10e26,0x13eec,0x11e66, // 820
0x13ee6,0x1dfa8,0x1efd6,0x1dfa4,0x1dfa2,0x19f28,0x1cf96,0x1bf68,0x19f24,0x1bf64, // 830
0x19f22,0x1bf62,0x11e28,0x18f16,0x13e68,0x11e24,0x17ee8,0x13e64,0x11e22,0x17ee4, // 840
0x13e62,0x17ee2,0x10e16,0x11e36,0x13e76,0x17ef6,0x1df94,0x1df92,0x19f14,0x1bf34, // 850
0x19f12,0x1bf32,0x11e14,0x13e34,0x11e12,0x17e74,0x13e32,0x17e72,0x1df8a,0x19f0a, // 860
0x1bf1a,0x11e0a,0x13e1a,0x17e3a,0x1035c,0x1034e,0x10758,0x183ae,0x1074c,0x10746, // 870
0x1032e,0x1076e,0x10f50,0x187ac,0x10f48,0x187a6,0x10f44,0x10f42,0x1072c,0x10f6c, // 880
0x10726,0x10f66,0x18fa8,0x1c7d6,0x18fa4,0x18fa2,0x10f28,0x18796,0x11f68,0x18fb6, // 890
0x11f64,0x10f22,0x11f62,0x10716,0x10f36,0x11f76,0x1cfd4,0x1cfd2,0x18f94,0x19fb4, // 900
0x18f92,0x19fb2,0x10f14,0x11f34,0x10f12,0x13f74,0x11f32,0x13f72,0x1cfca,0x18f8a, // 910
0x19f9a,0x10f0a,0x11f1a,0x13f3a,0x103ac,0x103a6,0x107a8,0x183d6,0x107a4,0x107a2, // 920
0x10396,0x107b6,0x187d4,0x187d2,0x10794,0x10fb4,0x10792,0x10fb2,0x1c7ea) // 929
); // end of $clusters array
/**
* @var Factors of the Reed-Solomon polynomial equations used for error correction; one sub array for each correction level (0-8)
* @access protected
*/
protected $rsfactors = array(
array( // ECL 0 (2 factors) -------------------------------------------------------------------------------
0x01b,0x395), // 2
array( // ECL 1 (4 factors) -------------------------------------------------------------------------------
0x20a,0x238,0x2d3,0x329), // 4
array( // ECL 2 (8 factors) -------------------------------------------------------------------------------
0x0ed,0x134,0x1b4,0x11c,0x286,0x28d,0x1ac,0x17b), // 8
array( // ECL 3 (16 factors) ------------------------------------------------------------------------------
0x112,0x232,0x0e8,0x2f3,0x257,0x20c,0x321,0x084,0x127,0x074,0x1ba,0x1ac,0x127,0x02a,0x0b0,0x041),// 16
array( // ECL 4 (32 factors) ------------------------------------------------------------------------------
0x169,0x23f,0x39a,0x20d,0x0b0,0x24a,0x280,0x141,0x218,0x2e6,0x2a5,0x2e6,0x2af,0x11c,0x0c1,0x205, // 16
0x111,0x1ee,0x107,0x093,0x251,0x320,0x23b,0x140,0x323,0x085,0x0e7,0x186,0x2ad,0x14a,0x03f,0x19a),// 32
array( // ECL 5 (64 factors) ------------------------------------------------------------------------------
0x21b,0x1a6,0x006,0x05d,0x35e,0x303,0x1c5,0x06a,0x262,0x11f,0x06b,0x1f9,0x2dd,0x36d,0x17d,0x264, // 16
0x2d3,0x1dc,0x1ce,0x0ac,0x1ae,0x261,0x35a,0x336,0x21f,0x178,0x1ff,0x190,0x2a0,0x2fa,0x11b,0x0b8, // 32
0x1b8,0x023,0x207,0x01f,0x1cc,0x252,0x0e1,0x217,0x205,0x160,0x25d,0x09e,0x28b,0x0c9,0x1e8,0x1f6, // 48
0x288,0x2dd,0x2cd,0x053,0x194,0x061,0x118,0x303,0x348,0x275,0x004,0x17d,0x34b,0x26f,0x108,0x21f),// 64
array( // ECL 6 (128 factors) -----------------------------------------------------------------------------
0x209,0x136,0x360,0x223,0x35a,0x244,0x128,0x17b,0x035,0x30b,0x381,0x1bc,0x190,0x39d,0x2ed,0x19f, // 16
0x336,0x05d,0x0d9,0x0d0,0x3a0,0x0f4,0x247,0x26c,0x0f6,0x094,0x1bf,0x277,0x124,0x38c,0x1ea,0x2c0, // 32
0x204,0x102,0x1c9,0x38b,0x252,0x2d3,0x2a2,0x124,0x110,0x060,0x2ac,0x1b0,0x2ae,0x25e,0x35c,0x239, // 48
0x0c1,0x0db,0x081,0x0ba,0x0ec,0x11f,0x0c0,0x307,0x116,0x0ad,0x028,0x17b,0x2c8,0x1cf,0x286,0x308, // 64
0x0ab,0x1eb,0x129,0x2fb,0x09c,0x2dc,0x05f,0x10e,0x1bf,0x05a,0x1fb,0x030,0x0e4,0x335,0x328,0x382, // 80
0x310,0x297,0x273,0x17a,0x17e,0x106,0x17c,0x25a,0x2f2,0x150,0x059,0x266,0x057,0x1b0,0x29e,0x268, // 96
0x09d,0x176,0x0f2,0x2d6,0x258,0x10d,0x177,0x382,0x34d,0x1c6,0x162,0x082,0x32e,0x24b,0x324,0x022, // 112
0x0d3,0x14a,0x21b,0x129,0x33b,0x361,0x025,0x205,0x342,0x13b,0x226,0x056,0x321,0x004,0x06c,0x21b),// 128
array( // ECL 7 (256 factors) -----------------------------------------------------------------------------
0x20c,0x37e,0x04b,0x2fe,0x372,0x359,0x04a,0x0cc,0x052,0x24a,0x2c4,0x0fa,0x389,0x312,0x08a,0x2d0, // 16
0x35a,0x0c2,0x137,0x391,0x113,0x0be,0x177,0x352,0x1b6,0x2dd,0x0c2,0x118,0x0c9,0x118,0x33c,0x2f5, // 32
0x2c6,0x32e,0x397,0x059,0x044,0x239,0x00b,0x0cc,0x31c,0x25d,0x21c,0x391,0x321,0x2bc,0x31f,0x089, // 48
0x1b7,0x1a2,0x250,0x29c,0x161,0x35b,0x172,0x2b6,0x145,0x0f0,0x0d8,0x101,0x11c,0x225,0x0d1,0x374, // 64
0x13b,0x046,0x149,0x319,0x1ea,0x112,0x36d,0x0a2,0x2ed,0x32c,0x2ac,0x1cd,0x14e,0x178,0x351,0x209, // 80
0x133,0x123,0x323,0x2c8,0x013,0x166,0x18f,0x38c,0x067,0x1ff,0x033,0x008,0x205,0x0e1,0x121,0x1d6, // 96
0x27d,0x2db,0x042,0x0ff,0x395,0x10d,0x1cf,0x33e,0x2da,0x1b1,0x350,0x249,0x088,0x21a,0x38a,0x05a, // 112
0x002,0x122,0x2e7,0x0c7,0x28f,0x387,0x149,0x031,0x322,0x244,0x163,0x24c,0x0bc,0x1ce,0x00a,0x086, // 128
0x274,0x140,0x1df,0x082,0x2e3,0x047,0x107,0x13e,0x176,0x259,0x0c0,0x25d,0x08e,0x2a1,0x2af,0x0ea, // 144
0x2d2,0x180,0x0b1,0x2f0,0x25f,0x280,0x1c7,0x0c1,0x2b1,0x2c3,0x325,0x281,0x030,0x03c,0x2dc,0x26d, // 160
0x37f,0x220,0x105,0x354,0x28f,0x135,0x2b9,0x2f3,0x2f4,0x03c,0x0e7,0x305,0x1b2,0x1a5,0x2d6,0x210, // 176
0x1f7,0x076,0x031,0x31b,0x020,0x090,0x1f4,0x0ee,0x344,0x18a,0x118,0x236,0x13f,0x009,0x287,0x226, // 192
0x049,0x392,0x156,0x07e,0x020,0x2a9,0x14b,0x318,0x26c,0x03c,0x261,0x1b9,0x0b4,0x317,0x37d,0x2f2, // 208
0x25d,0x17f,0x0e4,0x2ed,0x2f8,0x0d5,0x036,0x129,0x086,0x036,0x342,0x12b,0x39a,0x0bf,0x38e,0x214, // 224
0x261,0x33d,0x0bd,0x014,0x0a7,0x01d,0x368,0x1c1,0x053,0x192,0x029,0x290,0x1f9,0x243,0x1e1,0x0ad, // 240
0x194,0x0fb,0x2b0,0x05f,0x1f1,0x22b,0x282,0x21f,0x133,0x09f,0x39c,0x22e,0x288,0x037,0x1f1,0x00a),// 256
array( // ECL 8 (512 factors) -----------------------------------------------------------------------------
0x160,0x04d,0x175,0x1f8,0x023,0x257,0x1ac,0x0cf,0x199,0x23e,0x076,0x1f2,0x11d,0x17c,0x15e,0x1ec, // 16
0x0c5,0x109,0x398,0x09b,0x392,0x12b,0x0e5,0x283,0x126,0x367,0x132,0x058,0x057,0x0c1,0x160,0x30d, // 32
0x34e,0x04b,0x147,0x208,0x1b3,0x21f,0x0cb,0x29a,0x0f9,0x15a,0x30d,0x26d,0x280,0x10c,0x31a,0x216, // 48
0x21b,0x30d,0x198,0x186,0x284,0x066,0x1dc,0x1f3,0x122,0x278,0x221,0x025,0x35a,0x394,0x228,0x029, // 64
0x21e,0x121,0x07a,0x110,0x17f,0x320,0x1e5,0x062,0x2f0,0x1d8,0x2f9,0x06b,0x310,0x35c,0x292,0x2e5, // 80
0x122,0x0cc,0x2a9,0x197,0x357,0x055,0x063,0x03e,0x1e2,0x0b4,0x014,0x129,0x1c3,0x251,0x391,0x08e, // 96
0x328,0x2ac,0x11f,0x218,0x231,0x04c,0x28d,0x383,0x2d9,0x237,0x2e8,0x186,0x201,0x0c0,0x204,0x102, // 112
0x0f0,0x206,0x31a,0x18b,0x300,0x350,0x033,0x262,0x180,0x0a8,0x0be,0x33a,0x148,0x254,0x312,0x12f, // 128
0x23a,0x17d,0x19f,0x281,0x09c,0x0ed,0x097,0x1ad,0x213,0x0cf,0x2a4,0x2c6,0x059,0x0a8,0x130,0x192, // 144
0x028,0x2c4,0x23f,0x0a2,0x360,0x0e5,0x041,0x35d,0x349,0x200,0x0a4,0x1dd,0x0dd,0x05c,0x166,0x311, // 160
0x120,0x165,0x352,0x344,0x33b,0x2e0,0x2c3,0x05e,0x008,0x1ee,0x072,0x209,0x002,0x1f3,0x353,0x21f, // 176
0x098,0x2d9,0x303,0x05f,0x0f8,0x169,0x242,0x143,0x358,0x31d,0x121,0x033,0x2ac,0x1d2,0x215,0x334, // 192
0x29d,0x02d,0x386,0x1c4,0x0a7,0x156,0x0f4,0x0ad,0x023,0x1cf,0x28b,0x033,0x2bb,0x24f,0x1c4,0x242, // 208
0x025,0x07c,0x12a,0x14c,0x228,0x02b,0x1ab,0x077,0x296,0x309,0x1db,0x352,0x2fc,0x16c,0x242,0x38f, // 224
0x11b,0x2c7,0x1d8,0x1a4,0x0f5,0x120,0x252,0x18a,0x1ff,0x147,0x24d,0x309,0x2bb,0x2b0,0x02b,0x198, // 240
0x34a,0x17f,0x2d1,0x209,0x230,0x284,0x2ca,0x22f,0x03e,0x091,0x369,0x297,0x2c9,0x09f,0x2a0,0x2d9, // 256
0x270,0x03b,0x0c1,0x1a1,0x09e,0x0d1,0x233,0x234,0x157,0x2b5,0x06d,0x260,0x233,0x16d,0x0b5,0x304, // 272
0x2a5,0x136,0x0f8,0x161,0x2c4,0x19a,0x243,0x366,0x269,0x349,0x278,0x35c,0x121,0x218,0x023,0x309, // 288
0x26a,0x24a,0x1a8,0x341,0x04d,0x255,0x15a,0x10d,0x2f5,0x278,0x2b7,0x2ef,0x14b,0x0f7,0x0b8,0x02d, // 304
0x313,0x2a8,0x012,0x042,0x197,0x171,0x036,0x1ec,0x0e4,0x265,0x33e,0x39a,0x1b5,0x207,0x284,0x389, // 320
0x315,0x1a4,0x131,0x1b9,0x0cf,0x12c,0x37c,0x33b,0x08d,0x219,0x17d,0x296,0x201,0x038,0x0fc,0x155, // 336
0x0f2,0x31d,0x346,0x345,0x2d0,0x0e0,0x133,0x277,0x03d,0x057,0x230,0x136,0x2f4,0x299,0x18d,0x328, // 352
0x353,0x135,0x1d9,0x31b,0x17a,0x01f,0x287,0x393,0x1cb,0x326,0x24e,0x2db,0x1a9,0x0d8,0x224,0x0f9, // 368
0x141,0x371,0x2bb,0x217,0x2a1,0x30e,0x0d2,0x32f,0x389,0x12f,0x34b,0x39a,0x119,0x049,0x1d5,0x317, // 384
0x294,0x0a2,0x1f2,0x134,0x09b,0x1a6,0x38b,0x331,0x0bb,0x03e,0x010,0x1a9,0x217,0x150,0x11e,0x1b5, // 400
0x177,0x111,0x262,0x128,0x0b7,0x39b,0x074,0x29b,0x2ef,0x161,0x03e,0x16e,0x2b3,0x17b,0x2af,0x34a, // 416
0x025,0x165,0x2d0,0x2e6,0x14a,0x005,0x027,0x39b,0x137,0x1a8,0x0f2,0x2ed,0x141,0x036,0x29d,0x13c, // 432
0x156,0x12b,0x216,0x069,0x29b,0x1e8,0x280,0x2a0,0x240,0x21c,0x13c,0x1e6,0x2d1,0x262,0x02e,0x290, // 448
0x1bf,0x0ab,0x268,0x1d0,0x0be,0x213,0x129,0x141,0x2fa,0x2f0,0x215,0x0af,0x086,0x00e,0x17d,0x1b1, // 464
0x2cd,0x02d,0x06f,0x014,0x254,0x11c,0x2e0,0x08a,0x286,0x19b,0x36d,0x29d,0x08d,0x397,0x02d,0x30c, // 480
0x197,0x0a4,0x14c,0x383,0x0a5,0x2d6,0x258,0x145,0x1f2,0x28f,0x165,0x2f0,0x300,0x0df,0x351,0x287, // 496
0x03f,0x136,0x35f,0x0fb,0x16e,0x130,0x11a,0x2e2,0x2a3,0x19a,0x185,0x0f4,0x01f,0x079,0x12f,0x107) // 512
);
/**
* This is the class constructor.
* Creates a PDF417 object
* @param string $code code to represent using PDF417
* @param int $ecl error correction level (0-8); default -1 = automatic correction level
* @param float $aspectratio the width to height of the symbol (excluding quiet zones)
* òparam array $macro information for macro block
* @access public
*/
public function __construct($code, $ecl=-1, $aspectratio=2, $macro=array()) {
$barcode_array = array();
if ((is_null($code)) OR ($code == '\0') OR ($code == '')) {
return false;
}
// get the input sequence array
$sequence = $this->getInputSequences($code);
$codewords = array(); // array of code-words
foreach($sequence as $seq) {
$cw = $this->getCompaction($seq[0], $seq[1], true);
$codewords = array_merge($codewords, $cw);
}
if ($codewords[0] == 900) {
// Text Alpha is the default mode, so remove the first code
array_shift($codewords);
}
// count number of codewords
$numcw = count($codewords);
if ($numcw > 925) {
// reached maximum data codeword capacity
return false;
}
// build macro control block codewords
if (!empty($macro)) {
$macrocw = array();
// beginning of macro control block
$macrocw[] = 928;
// segment index
$cw = $this->getCompaction(902, sprintf('%05d', $macro['segment_index']), false);
$macrocw = array_merge($macrocw, $cw);
// file ID
$cw = $this->getCompaction(900, $macro['file_id'], false);
$macrocw = array_merge($macrocw, $cw);
// optional fields
$optmodes = array(900,902,902,900,900,902,902);
$optsize = array(-1,2,4,-1,-1,-1,2);
foreach ($optmodes as $k => $omode) {
if (isset($macro['option_'.$k])) {
$macrocw[] = 923;
$macrocw[] = $k;
if ($optsize[$k] == 2) {
$macro['option_'.$k] = sprintf('%05d', $macro['option_'.$k]);
} elseif ($optsize[$k] == 4) {
$macro['option_'.$k] = sprintf('%010d', $macro['option_'.$k]);
}
$cw = $this->getCompaction($omode, $macro['option_'.$k], false);
$macrocw = array_merge($macrocw, $cw);
}
}
if ($macro['segment_index'] == ($macro['segment_total'] - 1)) {
// end of control block
$macrocw[] = 922;
}
// update total codewords
$numcw += count($macrocw);
}
// set error correction level
$ecl = $this->getErrorCorrectionLevel($ecl, $numcw);
// number of codewords for error correction
$errsize = (2 << $ecl);
// calculate number of columns (number of codewords per row) and rows
$nce = ($numcw + $errsize + 1);
$cols = round((sqrt(4761 + (68 * $aspectratio * ROWHEIGHT * $nce)) - 69) / 34);
// adjust cols
if ($cols < 1) {
$cols = 1;
} elseif ($cols > 30) {
$cols = 30;
}
$rows = ceil($nce / $cols);
$size = ($cols * $rows);
// adjust rows
if (($rows < 3) OR ($rows > 90)) {
if ($rows < 3) {
$rows = 3;
} elseif ($rows > 90) {
$rows = 90;
}
$cols = ceil($size / $rows);
$size = ($cols * $rows);
}
if ($size > 928) {
// set dimensions to get maximum capacity
if (abs($aspectratio - (17 * 29 / 32)) < abs($aspectratio - (17 * 16 / 58))) {
$cols = 29;
$rows = 32;
} else {
$cols = 16;
$rows = 58;
}
$size = 928;
}
// calculate padding
$pad = ($size - $nce);
if ($pad > 0) {
if (($size - $rows) == $nce) {
--$rows;
$size -= $rows;
} else {
// add pading
$codewords = array_merge($codewords, array_fill(0, $pad, 900));
}
}
if (!empty($macro)) {
// add macro section
$codewords = array_merge($codewords, $macrocw);
}
// Symbol Lenght Descriptor (number of data codewords including Symbol Lenght Descriptor and pad codewords)
$sld = $size - $errsize;
// add symbol length description
array_unshift($codewords, $sld);
// calculate error correction
$ecw = $this->getErrorCorrection($codewords, $ecl);
// add error correction codewords
$codewords = array_merge($codewords, $ecw);
// add horizontal quiet zones to start and stop patterns
$pstart = str_repeat('0', QUIETH).$this->start_pattern;
$pstop = $this->stop_pattern.str_repeat('0', QUIETH);
$barcode_array['num_rows'] = ($rows * ROWHEIGHT) + (2 * QUIETV);
$barcode_array['num_cols'] = (($cols + 2) * 17) + 35 + (2 * QUIETH);
$barcode_array['bcode'] = array();
// build rows for vertical quiet zone
if (QUIETV > 0) {
$empty_row = array_fill(0, $barcode_array['num_cols'], 0);
for ($i = 0; $i < QUIETV; ++$i) {
// add vertical quiet rows
$barcode_array['bcode'][] = $empty_row;
}
}
$k = 0; // codeword index
$cid = 0; // initial cluster
// for each row
for ($r = 0; $r < $rows; ++$r) {
// row start code
$row = $pstart;
switch ($cid) {
case 0: {
$L = ((30 * intval($r / 3)) + intval(($rows - 1) / 3));
break;
}
case 1: {
$L = ((30 * intval($r / 3)) + ($ecl * 3) + (($rows - 1) % 3));
break;
}
case 2: {
$L = ((30 * intval($r / 3)) + ($cols - 1));
break;
}
}
// left row indicator
$row .= sprintf('%17b', $this->clusters[$cid][$L]);
// for each column
for ($c = 0; $c < $cols; ++$c) {
$row .= sprintf('%17b', $this->clusters[$cid][$codewords[$k]]);
++$k;
}
switch ($cid) {
case 0: {
$L = ((30 * intval($r / 3)) + ($cols - 1));
break;
}
case 1: {
$L = ((30 * intval($r / 3)) + intval(($rows - 1) / 3));
break;
}
case 2: {
$L = ((30 * intval($r / 3)) + ($ecl * 3) + (($rows - 1) % 3));
break;
}
}
// right row indicator
$row .= sprintf('%17b', $this->clusters[$cid][$L]);
// row stop code
$row .= $pstop;
// convert the string to array
$arow = preg_split('//', $row, -1, PREG_SPLIT_NO_EMPTY);
// duplicate row to get the desired height
for ($h = 0; $h < ROWHEIGHT; ++$h) {
$barcode_array['bcode'][] = $arow;
}
++$cid;
if ($cid > 2) {
$cid = 0;
}
}
if (QUIETV > 0) {
for ($i = 0; $i < QUIETV; ++$i) {
// add vertical quiet rows
$barcode_array['bcode'][] = $empty_row;
}
}
$this->barcode_array = $barcode_array;
}
/**
* Returns a barcode array which is readable by TCPDF
* @return array barcode array readable by TCPDF;
* @access public
*/
public function getBarcodeArray() {
return $this->barcode_array;
}
/**
* Returns the error correction level (0-8) to be used
* @param int $ecl error correction level
* @param int $numcw number of data codewords
* @return int error correction level
* @access protected
*/
protected function getErrorCorrectionLevel($ecl, $numcw) {
// get maximum correction level
$maxecl = 8; // starting error level
$maxerrsize = (928 - $numcw); // available codewords for error
while ($maxecl > 0) {
$errsize = (2 << $ecl);
if ($maxerrsize >= $errsize) {
break;
}
--$maxecl;
}
// check for automatic levels
if (($ecl < 0) OR ($ecl > 8)) {
if ($numcw < 41) {
$ecl = 2;
} elseif ($numcw < 161) {
$ecl = 3;
} elseif ($numcw < 321) {
$ecl = 4;
} elseif ($numcw < 864) {
$ecl = 5;
} else {
$ecl = $maxecl;
}
}
if ($ecl > $maxecl) {
$ecl = $maxecl;
}
return $ecl;
}
/**
* Returns the error correction codewords
* @param array $cw array of codewords including Symbol Lenght Descriptor and pad
* @param int $ecl error correction level 0-8
* @return array of error correction codewords
* @access protected
*/
protected function getErrorCorrection($cw, $ecl) {
// get error correction coefficients
$ecc = $this->rsfactors[$ecl];
// number of error correction factors
$eclsize = (2 << $ecl);
// maximum index for $rsfactors[$ecl]
$eclmaxid = ($eclsize - 1);
// initialize array of error correction codewords
$ecw = array_fill(0, $eclsize, 0);
// for each data codeword
foreach($cw as $k => $d) {
$t1 = ($d + $ecw[$eclmaxid]) % 929;
for ($j = $eclmaxid; $j > 0; --$j) {
$t2 = ($t1 * $ecc[$j]) % 929;
$t3 = 929 - $t2;
$ecw[$j] = ($ecw[($j - 1)] + $t3) % 929;
}
$t2 = ($t1 * $ecc[0]) % 929;
$t3 = 929 - $t2;
$ecw[0] = $t3 % 929;
}
foreach($ecw as $j => $e) {
if ($e != 0) {
$ecw[$j] = 929 - $e;
}
}
$ecw = array_reverse($ecw);
return $ecw;
}
/**
* Create array of sequences from input
* @param string $code code
* @return bidimensional array containing characters and classification
* @access protected
*/
protected function getInputSequences($code) {
$sequence_array = array(); // array to be returned
$numseq = array();
// get numeric sequences
preg_match_all('/([0-9]{13,})/', $code, $numseq, PREG_OFFSET_CAPTURE);
$numseq[1][] = array('', strlen($code));
$offset = 0;
foreach($numseq[1] as $seq) {
$seqlen = strlen($seq[0]);
if ($seq[1] > 0) {
// extract text sequence before the number sequence
$prevseq = substr($code, $offset, ($seq[1] - $offset));
$textseq = array();
// get text sequences
preg_match_all('/([\x09\x0a\x0d\x20-\x7e]{5,})/', $prevseq, $textseq, PREG_OFFSET_CAPTURE);
$textseq[1][] = array('', strlen($prevseq));
$txtoffset = 0;
foreach($textseq[1] as $txtseq) {
$txtseqlen = strlen($txtseq[0]);
if ($txtseq[1] > 0) {
// extract byte sequence before the text sequence
$prevtxtseq = substr($prevseq, $txtoffset, ($txtseq[1] - $txtoffset));
if (strlen($prevtxtseq) > 0) {
// add BYTE sequence
if ((strlen($prevtxtseq) == 1) AND ((count($sequence_array) > 0) AND ($sequence_array[(count($sequence_array) - 1)][0] == 900))) {
$sequence_array[] = array(913, $prevtxtseq);
} elseif ((strlen($prevtxtseq) % 6) == 0) {
$sequence_array[] = array(924, $prevtxtseq);
} else {
$sequence_array[] = array(901, $prevtxtseq);
}
}
}
if ($txtseqlen > 0) {
// add numeric sequence
$sequence_array[] = array(900, $txtseq[0]);
}
$txtoffset = $txtseq[1] + $txtseqlen;
}
}
if ($seqlen > 0) {
// add numeric sequence
$sequence_array[] = array(902, $seq[0]);
}
$offset = $seq[1] + $seqlen;
}
return $sequence_array;
}
/**
* Compact data by mode.
* @param int $mode compaction mode number
* @param string $code data to compact
* @param boolean $addmode if true add the mode codeword at first position
* @return array of codewords
* @access protected
*/
protected function getCompaction($mode, $code, $addmode=true) {
$cw = array(); // array of codewords to return
switch($mode) {
case 900: { // Text Compaction mode latch
$submode = 0; // default Alpha sub-mode
$txtarr = array(); // array of characters and sub-mode switching characters
$codelen = strlen($code);
for ($i = 0; $i < $codelen; ++$i) {
$chval = ord($code{$i});
if (($k = array_search($chval, $this->textsubmodes[$submode])) !== false) {
// we are on the same sub-mode
$txtarr[] = $k;
} else {
// the sub-mode is changed
for ($s = 0; $s < 4; ++$s) {
// search new sub-mode
if (($s != $submode) AND (($k = array_search($chval, $this->textsubmodes[$s])) !== false)) {
// $s is the new submode
if (((($i + 1) == $codelen) OR ((($i + 1) < $codelen) AND (array_search(ord($code{($i + 1)}), $this->textsubmodes[$submode]) !== false))) AND (($s == 3) OR (($s == 0) AND ($submode == 1)))) {
// shift (temporary change only for this char)
if ($s == 3) {
// shift to puntuaction
$txtarr[] = 29;
} else {
// shift from lower to alpha
$txtarr[] = 27;
}
} else {
// latch
$txtarr = array_merge($txtarr, $this->textlatch[''.$submode.$s]);
// set new submode
$submode = $s;
}
// add characted code to array
$txtarr[] = $k;
break;
}
}
}
}
$txtarrlen = count($txtarr);
if (($txtarrlen % 2) != 0) {
// add padding
$txtarr[] = 29;
++$txtarrlen;
}
// calculate codewords
for ($i = 0; $i < $txtarrlen; $i += 2) {
$cw[] = (30 * $txtarr[$i]) + $txtarr[($i + 1)];
}
break;
}
case 901:
case 924: { // Byte Compaction mode latch
while (($codelen = strlen($code)) > 0) {
if ($codelen > 6) {
$rest = substr($code, 6);
$code = substr($code, 0, 6);
$sublen = 6;
} else {
$rest = '';
$sublen = strlen($code);
}
if ($sublen == 6) {
$t = bcmul(''.ord($code{0}), '1099511627776');
$t = bcadd($t, bcmul(''.ord($code{1}), '4294967296'));
$t = bcadd($t, bcmul(''.ord($code{2}), '16777216'));
$t = bcadd($t, bcmul(''.ord($code{3}), '65536'));
$t = bcadd($t, bcmul(''.ord($code{4}), '256'));
$t = bcadd($t, ''.ord($code{5}));
do {
$d = bcmod($t, '900');
$t = bcdiv($t, '900');
array_unshift($cw, $d);
} while ($t != '0');
} else {
for ($i = 0; $i < $sublen; ++$i) {
$cw[] = ord($code{$i});
}
}
$code = $rest;
}
break;
}
case 902: { // Numeric Compaction mode latch
while (($codelen = strlen($code)) > 0) {
if ($codelen > 44) {
$rest = substr($code, 44);
$code = substr($code, 0, 44);
} else {
$rest = '';
}
$t = '1'.$code;
do {
$d = bcmod($t, '900');
$t = bcdiv($t, '900');
array_unshift($cw, $d);
} while ($t != '0');
$code = $rest;
}
break;
}
case 913: { // Byte Compaction mode shift
$cw[] = ord($code);
break;
}
}
if ($addmode) {
// add the compaction mode codeword at the beginning
array_unshift($cw, $mode);
}
return $cw;
}
} // end PDF417 class
} // END OF "class_exists PDF417"
//============================================================+
// END OF FILE
//============================================================+
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/pdf417.php | PHP | asf20 | 55,407 |
<?php
$type = 'cidfont0';
$name = 'KozMinPro-Regular-Acro';
$displayname = 'Kozuka Mincho Pro (Japanese Serif)';
$desc = array(
'Ascent' => 880,
'Descent' => -120,
'CapHeight' => 740,
'Flags' => 6,
'FontBBox' => '[-195 -272 1110 1075]',
'ItalicAngle' => 0,
'StemV' => 86,
'XHeight' => 502,
);
$cidinfo = array(
'Registry' => 'Adobe',
'Ordering' => 'Japan1',
'Supplement' => '4',
);
$enc = 'UniJIS-UCS2-H';
$up = -75;
$ut = 50;
$dw = 1000;
$cw = array(
32 => 278, 33 => 299, 34 => 353, 35 => 614, 36 => 614, 37 => 721, 38 => 735, 39 => 216, 40 => 323, 41 => 323,
42 => 449, 43 => 529, 44 => 219, 45 => 306, 46 => 219, 47 => 453, 48 => 614, 49 => 614, 50 => 614, 51 => 614,
52 => 614, 53 => 614, 54 => 614, 55 => 614, 56 => 614, 57 => 614, 58 => 219, 59 => 219, 60 => 529, 61 => 529,
62 => 529, 63 => 486, 64 => 744, 65 => 646, 66 => 604, 67 => 617, 68 => 681, 69 => 567, 70 => 537, 71 => 647,
72 => 738, 73 => 320, 74 => 433, 75 => 637, 76 => 566, 77 => 904, 78 => 710, 79 => 716, 80 => 605, 81 => 716,
82 => 623, 83 => 517, 84 => 601, 85 => 690, 86 => 668, 87 => 990, 88 => 681, 89 => 634, 90 => 578, 91 => 316,
92 => 614, 93 => 316, 94 => 529, 95 => 500, 96 => 387, 97 => 509, 98 => 566, 99 => 478, 100 => 565, 101 => 503,
102 => 337, 103 => 549, 104 => 580, 105 => 275, 106 => 266, 107 => 544, 108 => 276, 109 => 854, 110 => 579, 111 => 550,
112 => 578, 113 => 566, 114 => 410, 115 => 444, 116 => 340, 117 => 575, 118 => 512, 119 => 760, 120 => 503, 121 => 529,
122 => 453, 123 => 326, 124 => 380, 125 => 326, 126 => 387, 127 => 216, 128 => 453, 129 => 216, 130 => 380, 131 => 529,
132 => 299, 133 => 614, 134 => 614, 135 => 265, 136 => 614, 137 => 475, 138 => 614, 139 => 353, 140 => 451, 141 => 291,
142 => 291, 143 => 588, 144 => 589, 145 => 500, 146 => 476, 147 => 476, 148 => 219, 149 => 494, 150 => 452, 151 => 216,
152 => 353, 153 => 353, 154 => 451, 156 => 1075, 157 => 486, 158 => 387, 159 => 387, 160 => 387, 161 => 387,
162 => 387, 163 => 387, 164 => 387, 165 => 387, 166 => 387, 167 => 387, 168 => 387, 170 => 880, 171 => 448,
172 => 566, 173 => 716, 174 => 903, 175 => 460, 176 => 805, 177 => 275, 178 => 276, 179 => 550, 180 => 886, 181 => 582,
182 => 529, 183 => 738, 184 => 529, 185 => 738, 186 => 357, 187 => 529, 188 => 406, 189 => 406, 190 => 575, 191 => 406,
192 => 934, 193 => 934, 194 => 934, 195 => 646, 196 => 646, 197 => 646, 198 => 646, 199 => 646, 200 => 646, 201 => 617,
202 => 567, 203 => 567, 204 => 567, 205 => 567, 206 => 320, 207 => 320, 208 => 320, 209 => 320, 210 => 681, 211 => 710,
212 => 716, 213 => 716, 214 => 716, 215 => 716, 216 => 716, 217 => 529, 218 => 690, 219 => 690, 220 => 690, 221 => 690,
222 => 634, 223 => 605, 224 => 509, 225 => 509, 226 => 509, 227 => 509, 228 => 509, 229 => 509, 230 => 478, 231 => 503,
232 => 503, 233 => 503, 234 => 503, 235 => 275, 236 => 275, 237 => 275, 238 => 275, 239 => 550, 240 => 579, 241 => 550,
242 => 550, 243 => 550, 244 => 550, 245 => 550, 246 => 529, 247 => 575, 248 => 575, 249 => 575, 250 => 575, 251 => 529,
252 => 578, 253 => 529, 254 => 517, 255 => 634, 256 => 578, 257 => 445, 258 => 444, 259 => 842, 260 => 453, 261 => 614,
);
$_cr = array(
array(231, 632, 500), // half-width
array(8718, 8718, 500),
array(9738, 9757, 250), // quarter-width
array(9758, 9778, 333), // third-width
array(12063, 12087, 500),
);
foreach($_cr as $_r) {
for($i = $_r[0]; $i <= $_r[1]; $i++) {
$cw[$i+31] = $_r[2];
}
}
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/kozminproregular.php | PHP | asf20 | 3,454 |
<?php
$type = 'cidfont0';
$name = 'KozGoPro-Medium-Acro';
$displayname = 'Kozuka Gothic Pro (Japanese Sans-Serif)';
$desc = array(
'Ascent' => 880,
'Descent' => -120,
'CapHeight' => 763,
'Flags' => 4,
'FontBBox' => '[-149 -374 1254 1008]',
'ItalicAngle' => 0,
'StemV' => 99,
'Style' => '<< /Panose <0000020b0700000000000000> >>',
'XHeight' => 549,
);
$cidinfo = array(
'Registry' => 'Adobe',
'Ordering' => 'Japan1',
'Supplement' => '4',
);
$enc = 'UniJIS-UCS2-H';
// underline position, needs checking:
$up = -75;
$ut = 50;
$dw = 1000;
$cw = array(
32 => 224, 33 => 266, 34 => 392, 35 => 551, 36 => 562, 37 => 883, 38 => 677, 39 => 213, 40 => 322, 41 => 322,
42 => 470, 43 => 677, 44 => 247, 45 => 343, 46 => 245, 47 => 370, 48 => 562, 49 => 562, 50 => 562, 51 => 562,
52 => 562, 53 => 562, 54 => 562, 55 => 562, 56 => 562, 57 => 562, 58 => 245, 59 => 247, 60 => 677, 61 => 677,
62 => 677, 63 => 447, 64 => 808, 65 => 661, 66 => 602, 67 => 610, 68 => 708, 69 => 535, 70 => 528, 71 => 689,
72 => 703, 73 => 275, 74 => 404, 75 => 602, 76 => 514, 77 => 871, 78 => 708, 79 => 727, 80 => 585, 81 => 727,
82 => 595, 83 => 539, 84 => 541, 85 => 696, 86 => 619, 87 => 922, 88 => 612, 89 => 591, 90 => 584, 91 => 322,
92 => 562, 93 => 322, 94 => 677, 95 => 568, 96 => 340, 97 => 532, 98 => 612, 99 => 475, 100 => 608, 101 => 543,
102 => 332, 103 => 603, 104 => 601, 105 => 265, 106 => 276, 107 => 524, 108 => 264, 109 => 901, 110 => 601, 111 => 590,
112 => 612, 113 => 607, 114 => 367, 115 => 433, 116 => 369, 117 => 597, 118 => 527, 119 => 800, 120 => 511, 121 => 518,
122 => 468, 123 => 321, 124 => 273, 125 => 321, 126 => 341, 127 => 241, 128 => 362, 129 => 241, 130 => 273, 131 => 677,
132 => 266, 133 => 562, 134 => 562, 135 => 456, 136 => 562, 137 => 571, 138 => 562, 139 => 416, 140 => 472, 141 => 283,
142 => 283, 143 => 587, 144 => 588, 145 => 568, 146 => 545, 147 => 545, 148 => 247, 149 => 561, 150 => 330, 151 => 239,
152 => 418, 153 => 416, 154 => 472, 155 => 1136, 156 => 1288, 157 => 447, 158 => 340, 159 => 340, 160 => 340, 161 => 340,
162 => 340, 163 => 340, 164 => 455, 165 => 340, 166 => 340, 167 => 340, 168 => 340, 169 => 1136, 170 => 857, 171 => 384,
172 => 519, 173 => 727, 174 => 952, 175 => 398, 176 => 834, 177 => 264, 178 => 275, 179 => 590, 180 => 918, 181 => 605,
182 => 677, 183 => 769, 184 => 677, 185 => 473, 186 => 361, 187 => 677, 188 => 347, 189 => 340, 190 => 599, 191 => 284,
192 => 845, 193 => 845, 194 => 845, 195 => 661, 196 => 661, 197 => 661, 198 => 661, 199 => 661, 200 => 661, 201 => 610,
202 => 535, 203 => 535, 204 => 535, 205 => 535, 206 => 275, 207 => 275, 208 => 275, 209 => 275, 210 => 715, 211 => 708,
212 => 727, 213 => 727, 214 => 727, 215 => 727, 216 => 727, 217 => 677, 218 => 696, 219 => 696, 220 => 696, 221 => 696,
222 => 591, 223 => 584, 224 => 532, 225 => 532, 226 => 532, 227 => 532, 228 => 532, 229 => 532, 230 => 475, 231 => 543,
232 => 543, 233 => 543, 234 => 543, 235 => 264, 236 => 264, 237 => 264, 238 => 264, 239 => 584, 240 => 601, 241 => 590,
242 => 590, 243 => 590, 244 => 590, 245 => 590, 246 => 677, 247 => 597, 248 => 597, 249 => 597, 250 => 597, 251 => 518,
252 => 612, 253 => 518, 254 => 539, 255 => 591, 256 => 584, 257 => 446, 258 => 433, 259 => 683, 260 => 468, 261 => 562,
);
$_cr = array(
array(231, 632, 500), // half-width
array(8718, 8718, 500),
array(9738, 9757, 250), // quarter-width
array(9758, 9778, 333), // third-width
array(12063, 12087, 500)
);
foreach($_cr as $_r) {
for($i = $_r[0]; $i <= $_r[1]; $i++) {
$cw[$i+31] = $_r[2];
}
}
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/kozgopromedium.php | PHP | asf20 | 3,577 |
<?php
$type='TrueTypeUnicode';
$name='DejaVuSans-BoldOblique';
$desc=array('Ascent'=>928,'Descent'=>-236,'CapHeight'=>-51,'Flags'=>96,'FontBBox'=>'[-1067 -385 2005 1121]','ItalicAngle'=>-11,'StemV'=>120,'MissingWidth'=>600);
$up=-63;
$ut=44;
$dw=600;
$cw=array(
0=>600,32=>348,33=>456,34=>521,35=>696,36=>696,37=>1002,38=>872,39=>306,40=>457,
41=>457,42=>523,43=>838,44=>380,45=>415,46=>380,47=>365,48=>696,49=>696,50=>696,
51=>696,52=>696,53=>696,54=>696,55=>696,56=>696,57=>696,58=>400,59=>400,60=>838,
61=>838,62=>838,63=>580,64=>1000,65=>774,66=>762,67=>734,68=>830,69=>683,70=>683,
71=>821,72=>837,73=>372,74=>372,75=>775,76=>637,77=>995,78=>837,79=>850,80=>733,
81=>850,82=>770,83=>720,84=>682,85=>812,86=>774,87=>1103,88=>771,89=>724,90=>725,
91=>457,92=>365,93=>457,94=>838,95=>500,96=>500,97=>675,98=>716,99=>593,100=>716,
101=>678,102=>435,103=>716,104=>712,105=>343,106=>343,107=>665,108=>343,109=>1042,110=>712,
111=>687,112=>716,113=>716,114=>493,115=>595,116=>478,117=>712,118=>652,119=>924,120=>645,
121=>652,122=>582,123=>712,124=>365,125=>712,126=>838,8364=>696,8218=>380,402=>435,8222=>644,
8230=>1000,8224=>500,8225=>500,710=>500,8240=>1454,352=>720,8249=>412,338=>1167,381=>725,8216=>380,
8217=>380,8220=>644,8221=>644,8226=>639,8211=>500,8212=>1000,732=>500,8482=>1000,353=>595,8250=>412,
339=>1094,382=>582,376=>724,160=>348,161=>456,162=>696,163=>696,164=>636,165=>696,166=>365,
167=>500,168=>500,169=>1000,170=>564,171=>650,172=>838,173=>415,174=>1000,175=>500,176=>500,
177=>838,178=>438,179=>438,180=>500,181=>736,182=>636,183=>380,184=>500,185=>438,186=>564,
187=>650,188=>1035,189=>1035,190=>1035,191=>580,192=>774,193=>774,194=>774,195=>774,196=>774,
197=>774,198=>1085,199=>734,200=>683,201=>683,202=>683,203=>683,204=>372,205=>372,206=>372,
207=>372,208=>845,209=>837,210=>850,211=>850,212=>850,213=>850,214=>850,215=>838,216=>850,
217=>812,218=>812,219=>812,220=>812,221=>724,222=>742,223=>719,224=>675,225=>675,226=>675,
227=>675,228=>675,229=>675,230=>1048,231=>593,232=>678,233=>678,234=>678,235=>678,236=>343,
237=>343,238=>343,239=>343,240=>687,241=>712,242=>687,243=>687,244=>687,245=>687,246=>687,
247=>838,248=>687,249=>712,250=>712,251=>712,252=>712,253=>652,254=>716,255=>652,256=>774,
257=>675,258=>774,259=>675,260=>774,261=>675,262=>734,263=>593,264=>734,265=>593,266=>734,
267=>593,268=>734,269=>593,270=>830,271=>716,272=>845,273=>716,274=>683,275=>678,276=>683,
277=>678,278=>683,279=>678,280=>683,281=>678,282=>683,283=>678,284=>821,285=>716,286=>821,
287=>716,288=>821,289=>716,290=>821,291=>716,292=>837,293=>712,294=>974,295=>790,296=>372,
297=>343,298=>372,299=>343,300=>372,301=>343,302=>372,303=>343,304=>372,305=>343,306=>744,
307=>686,308=>372,309=>343,310=>775,311=>665,312=>665,313=>637,314=>343,315=>637,316=>343,
317=>637,318=>343,319=>637,320=>343,321=>660,322=>375,323=>837,324=>712,325=>837,326=>712,
327=>837,328=>712,329=>983,330=>837,331=>712,332=>850,333=>687,334=>850,335=>687,336=>850,
337=>687,340=>770,341=>493,342=>770,343=>493,344=>770,345=>493,346=>720,347=>595,348=>720,
349=>595,350=>720,351=>595,354=>682,355=>478,356=>682,357=>478,358=>682,359=>478,360=>812,
361=>712,362=>812,363=>712,364=>812,365=>712,366=>812,367=>712,368=>812,369=>712,370=>812,
371=>712,372=>1103,373=>924,374=>724,375=>652,377=>725,378=>582,379=>725,380=>582,383=>435,
384=>716,385=>811,386=>762,387=>716,388=>762,389=>716,390=>734,391=>734,392=>593,393=>845,
394=>879,395=>762,396=>716,397=>687,398=>683,399=>850,400=>696,401=>683,403=>821,404=>793,
405=>1045,406=>436,407=>389,408=>775,409=>665,410=>360,411=>592,412=>1042,413=>837,414=>712,
415=>850,416=>850,417=>687,418=>1114,419=>962,420=>782,421=>716,422=>770,423=>720,424=>595,
425=>683,426=>552,427=>478,428=>707,429=>478,430=>682,431=>812,432=>712,433=>769,434=>813,
435=>797,436=>778,437=>725,438=>582,439=>772,440=>772,441=>641,442=>582,443=>696,444=>772,
445=>641,446=>573,447=>716,448=>372,449=>659,450=>544,451=>372,452=>1548,453=>1450,454=>1307,
455=>977,456=>979,457=>670,458=>1193,459=>1213,460=>1063,461=>774,462=>675,463=>372,464=>343,
465=>850,466=>687,467=>812,468=>712,469=>812,470=>712,471=>812,472=>712,473=>812,474=>712,
475=>812,476=>712,477=>678,478=>774,479=>675,480=>774,481=>675,482=>1085,483=>1048,484=>821,
485=>716,486=>821,487=>716,488=>775,489=>665,490=>850,491=>687,492=>850,493=>687,494=>772,
495=>582,496=>343,497=>1548,498=>1450,499=>1307,500=>821,501=>716,502=>1289,503=>787,504=>837,
505=>712,506=>774,507=>675,508=>1085,509=>1048,510=>850,511=>687,512=>774,513=>675,514=>774,
515=>675,516=>683,517=>678,518=>683,519=>678,520=>372,521=>343,522=>372,523=>343,524=>850,
525=>687,526=>850,527=>687,528=>770,529=>493,530=>770,531=>493,532=>812,533=>712,534=>812,
535=>712,536=>720,537=>595,538=>682,539=>478,540=>690,541=>607,542=>837,543=>712,544=>837,
545=>865,546=>809,547=>659,548=>725,549=>582,550=>774,551=>675,552=>683,553=>678,554=>850,
555=>687,556=>850,557=>687,558=>850,559=>687,560=>850,561=>687,562=>724,563=>652,564=>492,
565=>867,566=>512,567=>343,568=>1088,569=>1088,570=>774,571=>734,572=>593,573=>637,574=>682,
575=>595,576=>582,577=>782,578=>614,579=>762,580=>812,581=>774,582=>683,583=>678,584=>372,
585=>343,586=>860,587=>791,588=>770,589=>493,590=>724,591=>652,592=>675,593=>716,594=>716,
595=>716,596=>593,597=>593,598=>791,599=>792,600=>678,601=>678,602=>876,603=>557,604=>545,
605=>774,606=>731,607=>343,608=>792,609=>716,610=>627,611=>735,612=>635,613=>712,614=>712,
615=>712,616=>545,617=>440,618=>545,619=>559,620=>693,621=>343,622=>841,623=>1042,624=>1042,
625=>1042,626=>712,627=>793,628=>642,629=>687,630=>909,631=>682,632=>796,633=>538,634=>538,
635=>650,636=>493,637=>493,638=>596,639=>596,640=>642,641=>642,642=>595,643=>415,644=>435,
645=>605,646=>552,647=>478,648=>478,649=>920,650=>769,651=>670,652=>652,653=>924,654=>652,
655=>724,656=>694,657=>684,658=>641,659=>641,660=>573,661=>573,662=>573,663=>573,664=>850,
665=>633,666=>731,667=>685,668=>691,669=>343,670=>732,671=>539,672=>792,673=>573,674=>573,
675=>1156,676=>1214,677=>1155,678=>974,679=>769,680=>929,681=>1026,682=>792,683=>780,684=>591,
685=>415,686=>677,687=>789,688=>456,689=>456,690=>219,691=>315,692=>315,693=>315,694=>411,
695=>591,696=>417,697=>302,698=>521,699=>380,700=>380,701=>380,702=>366,703=>366,704=>326,
705=>326,706=>500,707=>500,708=>500,709=>500,711=>500,712=>306,713=>500,714=>500,715=>500,
716=>306,717=>500,718=>500,719=>500,720=>337,721=>337,722=>366,723=>366,724=>500,725=>500,
726=>416,727=>328,728=>500,729=>500,730=>500,731=>500,733=>500,734=>351,735=>500,736=>412,
737=>219,738=>381,739=>413,740=>326,741=>500,742=>500,743=>500,744=>500,745=>500,748=>500,
749=>500,750=>644,755=>500,759=>500,768=>0,769=>0,770=>0,771=>0,772=>0,773=>0,
774=>0,775=>0,776=>0,777=>0,778=>0,779=>0,780=>0,781=>0,782=>0,783=>0,
784=>0,785=>0,786=>0,787=>0,788=>0,789=>0,790=>0,791=>0,792=>0,793=>0,
794=>0,795=>0,796=>0,797=>0,798=>0,799=>0,800=>0,801=>0,802=>0,803=>0,
804=>0,805=>0,806=>0,807=>0,808=>0,809=>0,810=>0,811=>0,812=>0,813=>0,
814=>0,815=>0,816=>0,817=>0,818=>0,819=>0,820=>0,821=>0,822=>0,823=>0,
824=>0,825=>0,826=>0,827=>0,828=>0,829=>0,830=>0,831=>0,832=>0,833=>0,
834=>0,835=>0,836=>0,837=>0,838=>0,839=>0,840=>0,841=>0,842=>0,843=>0,
844=>0,845=>0,846=>0,847=>0,849=>0,850=>0,851=>0,855=>0,856=>0,858=>0,
860=>0,861=>0,862=>0,863=>0,864=>0,865=>0,866=>0,880=>698,881=>565,882=>1022,
883=>836,884=>302,885=>302,886=>837,887=>701,890=>500,891=>593,892=>550,893=>549,894=>400,
900=>441,901=>500,902=>797,903=>380,904=>846,905=>1009,906=>563,908=>891,910=>980,911=>894,
912=>390,913=>774,914=>762,915=>637,916=>774,917=>683,918=>725,919=>837,920=>850,921=>372,
922=>775,923=>774,924=>995,925=>837,926=>632,927=>850,928=>837,929=>733,931=>683,932=>682,
933=>724,934=>850,935=>771,936=>850,937=>850,938=>372,939=>724,940=>687,941=>557,942=>712,
943=>390,944=>675,945=>687,946=>716,947=>681,948=>687,949=>557,950=>591,951=>712,952=>687,
953=>390,954=>710,955=>633,956=>736,957=>681,958=>591,959=>687,960=>791,961=>716,962=>593,
963=>779,964=>638,965=>675,966=>782,967=>645,968=>794,969=>869,970=>390,971=>675,972=>687,
973=>675,974=>869,975=>775,976=>651,977=>661,978=>746,979=>981,980=>746,981=>796,982=>869,
983=>744,984=>850,985=>687,986=>734,987=>593,988=>683,989=>494,990=>702,991=>660,992=>919,
993=>627,994=>1093,995=>837,996=>832,997=>716,998=>928,999=>744,1000=>733,1001=>650,1002=>789,
1003=>671,1004=>752,1005=>716,1006=>682,1007=>590,1008=>744,1009=>716,1010=>593,1011=>343,1012=>850,
1013=>645,1014=>645,1015=>742,1016=>716,1017=>734,1018=>995,1019=>732,1020=>716,1021=>734,1022=>734,
1023=>698,1024=>683,1025=>683,1026=>878,1027=>637,1028=>734,1029=>720,1030=>372,1031=>372,1032=>372,
1033=>1154,1034=>1130,1035=>878,1036=>817,1037=>837,1038=>771,1039=>837,1040=>774,1041=>762,1042=>762,
1043=>637,1044=>891,1045=>683,1046=>1224,1047=>710,1048=>837,1049=>837,1050=>817,1051=>831,1052=>995,
1053=>837,1054=>850,1055=>837,1056=>733,1057=>734,1058=>682,1059=>771,1060=>992,1061=>771,1062=>928,
1063=>808,1064=>1235,1065=>1326,1066=>939,1067=>1036,1068=>762,1069=>734,1070=>1174,1071=>770,1072=>675,
1073=>698,1074=>633,1075=>522,1076=>808,1077=>678,1078=>995,1079=>581,1080=>701,1081=>701,1082=>679,
1083=>732,1084=>817,1085=>691,1086=>687,1087=>691,1088=>716,1089=>593,1090=>580,1091=>652,1092=>992,
1093=>645,1094=>741,1095=>687,1096=>1062,1097=>1105,1098=>751,1099=>904,1100=>632,1101=>593,1102=>972,
1103=>642,1104=>678,1105=>678,1106=>714,1107=>522,1108=>593,1109=>595,1110=>343,1111=>343,1112=>343,
1113=>991,1114=>956,1115=>734,1116=>679,1117=>701,1118=>652,1119=>691,1120=>1093,1121=>869,1122=>840,
1123=>736,1124=>1012,1125=>839,1126=>992,1127=>832,1128=>1358,1129=>1121,1130=>850,1131=>687,1132=>1236,
1133=>1007,1134=>696,1135=>557,1136=>1075,1137=>1061,1138=>850,1139=>687,1140=>850,1141=>695,1142=>850,
1143=>695,1144=>1148,1145=>1043,1146=>1074,1147=>863,1148=>1405,1149=>1173,1150=>1093,1151=>869,1152=>734,
1153=>593,1154=>652,1155=>0,1156=>0,1157=>0,1158=>0,1159=>0,1160=>418,1161=>418,1162=>938,
1163=>806,1164=>762,1165=>611,1166=>736,1167=>718,1168=>637,1169=>522,1170=>666,1171=>543,1172=>789,
1173=>522,1174=>1224,1175=>995,1176=>710,1177=>581,1178=>775,1179=>679,1180=>817,1181=>679,1182=>817,
1183=>679,1184=>1015,1185=>826,1186=>837,1187=>691,1188=>1103,1189=>871,1190=>1254,1191=>979,1192=>946,
1193=>859,1194=>734,1195=>593,1196=>682,1197=>580,1198=>724,1199=>652,1200=>724,1201=>652,1202=>771,
1203=>645,1204=>1104,1205=>1001,1206=>808,1207=>687,1208=>808,1209=>687,1210=>808,1211=>712,1212=>1026,
1213=>810,1214=>1026,1215=>810,1216=>372,1217=>1224,1218=>995,1219=>778,1220=>629,1221=>933,1222=>804,
1223=>837,1224=>691,1225=>938,1226=>806,1227=>808,1228=>687,1229=>1096,1230=>932,1231=>343,1232=>774,
1233=>675,1234=>774,1235=>675,1236=>1085,1237=>1048,1238=>683,1239=>678,1240=>850,1241=>678,1242=>850,
1243=>678,1244=>1224,1245=>995,1246=>710,1247=>581,1248=>772,1249=>641,1250=>837,1251=>701,1252=>837,
1253=>701,1254=>850,1255=>687,1256=>850,1257=>687,1258=>850,1259=>687,1260=>734,1261=>593,1262=>771,
1263=>652,1264=>771,1265=>652,1266=>771,1267=>652,1268=>808,1269=>687,1270=>637,1271=>522,1272=>1036,
1273=>904,1274=>666,1275=>543,1276=>771,1277=>645,1278=>771,1279=>645,1280=>762,1281=>608,1282=>1159,
1283=>893,1284=>1119,1285=>920,1286=>828,1287=>693,1288=>1242,1289=>1017,1290=>1289,1291=>1013,1292=>839,
1293=>638,1294=>938,1295=>803,1296=>696,1297=>557,1298=>831,1299=>732,1300=>1286,1301=>1070,1302=>1065,
1303=>982,1304=>1082,1305=>960,1306=>850,1307=>716,1308=>1103,1309=>924,1312=>1248,1313=>1022,1314=>1254,
1315=>979,1316=>957,1317=>807,1329=>984,1330=>812,1331=>984,1332=>984,1333=>812,1334=>777,1335=>812,
1336=>812,1337=>975,1338=>984,1339=>812,1340=>710,1341=>1078,1342=>1136,1343=>812,1344=>710,1345=>757,
1346=>984,1347=>876,1348=>984,1349=>793,1350=>984,1351=>812,1352=>812,1353=>812,1354=>958,1355=>777,
1356=>984,1357=>812,1358=>984,1359=>720,1360=>812,1361=>793,1362=>895,1363=>850,1364=>936,1365=>850,
1366=>720,1369=>366,1370=>380,1371=>550,1372=>550,1373=>380,1374=>546,1375=>521,1377=>1042,1378=>712,
1379=>866,1380=>868,1381=>712,1382=>817,1383=>653,1384=>712,1385=>811,1386=>817,1387=>712,1388=>498,
1389=>1018,1390=>716,1391=>712,1392=>712,1393=>716,1394=>819,1395=>712,1396=>751,1397=>343,1398=>882,
1399=>559,1400=>712,1401=>559,1402=>1042,1403=>559,1404=>863,1405=>712,1406=>813,1407=>1042,1408=>712,
1409=>716,1410=>571,1411=>1042,1412=>778,1413=>687,1414=>720,1415=>862,1417=>400,1418=>487,1456=>0,
1457=>0,1458=>0,1459=>0,1460=>0,1461=>0,1462=>0,1463=>0,1464=>0,1465=>0,1466=>0,
1467=>0,1468=>0,1469=>0,1470=>415,1471=>0,1472=>372,1473=>0,1474=>0,1475=>372,1478=>497,
1479=>0,1488=>751,1489=>673,1490=>537,1491=>654,1492=>712,1493=>343,1494=>491,1495=>712,1496=>724,
1497=>343,1498=>649,1499=>650,1500=>679,1501=>712,1502=>775,1503=>343,1504=>497,1505=>773,1506=>678,
1507=>718,1508=>687,1509=>628,1510=>751,1511=>729,1512=>649,1513=>949,1514=>751,1520=>664,1521=>664,
1522=>663,1523=>444,1524=>710,3647=>743,3713=>815,3714=>748,3716=>749,3719=>569,3720=>742,3722=>744,
3725=>761,3732=>706,3733=>704,3734=>747,3735=>819,3737=>730,3738=>727,3739=>727,3740=>922,3741=>827,
3742=>866,3743=>866,3745=>836,3746=>761,3747=>770,3749=>769,3751=>713,3754=>827,3755=>1031,3757=>724,
3758=>784,3759=>934,3760=>688,3761=>0,3762=>610,3763=>610,3764=>0,3765=>0,3766=>0,3767=>0,
3768=>0,3769=>0,3771=>0,3772=>0,3773=>670,3776=>516,3777=>860,3778=>516,3779=>650,3780=>632,
3782=>759,3784=>0,3785=>0,3786=>0,3787=>0,3788=>0,3789=>0,3792=>771,3793=>771,3794=>693,
3795=>836,3796=>729,3797=>729,3798=>849,3799=>790,3800=>759,3801=>910,3804=>1363,3805=>1363,4256=>918,
4257=>744,4258=>739,4259=>837,4260=>649,4261=>773,4262=>857,4263=>889,4264=>530,4265=>633,4266=>857,
4267=>900,4268=>643,4269=>903,4270=>814,4271=>752,4272=>869,4273=>643,4274=>643,4275=>886,4276=>886,
4277=>733,4278=>653,4279=>643,4280=>646,4281=>643,4282=>790,4283=>902,4284=>633,4285=>619,4286=>643,
4287=>778,4288=>892,4289=>601,4290=>742,4291=>616,4292=>633,4293=>742,4304=>553,4305=>552,4306=>596,
4307=>815,4308=>562,4309=>563,4310=>553,4311=>827,4312=>553,4313=>543,4314=>1074,4315=>563,4316=>563,
4317=>812,4318=>552,4319=>591,4320=>822,4321=>563,4322=>690,4323=>583,4324=>813,4325=>562,4326=>813,
4327=>563,4328=>563,4329=>563,4330=>632,4331=>563,4332=>563,4333=>552,4334=>563,4335=>563,4336=>558,
4337=>604,4338=>552,4339=>552,4340=>553,4341=>605,4342=>852,4343=>635,4344=>563,4345=>596,4346=>542,
4347=>684,4348=>368,5121=>774,5122=>774,5123=>774,5124=>774,5125=>905,5126=>905,5127=>905,5129=>905,
5130=>905,5131=>905,5132=>1018,5133=>1009,5134=>1018,5135=>1009,5136=>1018,5137=>1009,5138=>1149,5139=>1140,
5140=>1149,5141=>1140,5142=>905,5143=>1149,5144=>1142,5145=>1149,5146=>1142,5147=>905,5149=>310,5150=>529,
5151=>425,5152=>425,5153=>395,5154=>395,5155=>395,5156=>395,5157=>564,5158=>470,5159=>310,5160=>395,
5161=>395,5162=>395,5163=>1213,5164=>986,5165=>1216,5166=>1297,5167=>774,5168=>774,5169=>774,5170=>774,
5171=>886,5172=>886,5173=>886,5175=>886,5176=>886,5177=>886,5178=>1018,5179=>1009,5180=>1018,5181=>1009,
5182=>1018,5183=>1009,5184=>1149,5185=>1140,5186=>1149,5187=>1140,5188=>1149,5189=>1142,5190=>1149,5191=>1142,
5192=>886,5193=>576,5194=>229,5196=>812,5197=>812,5198=>812,5199=>812,5200=>815,5201=>815,5202=>815,
5204=>815,5205=>815,5206=>815,5207=>1056,5208=>1048,5209=>1056,5210=>1048,5211=>1056,5212=>1048,5213=>1060,
5214=>1054,5215=>1060,5216=>1054,5217=>1060,5218=>1052,5219=>1060,5220=>1052,5221=>1060,5222=>483,5223=>1005,
5224=>1005,5225=>1023,5226=>1017,5227=>743,5228=>743,5229=>743,5230=>743,5231=>743,5232=>743,5233=>743,
5234=>743,5235=>743,5236=>1029,5237=>975,5238=>980,5239=>975,5240=>980,5241=>975,5242=>1029,5243=>975,
5244=>1029,5245=>975,5246=>980,5247=>975,5248=>980,5249=>975,5250=>980,5251=>501,5252=>501,5253=>938,
5254=>938,5255=>938,5256=>938,5257=>743,5258=>743,5259=>743,5260=>743,5261=>743,5262=>743,5263=>743,
5264=>743,5265=>743,5266=>1029,5267=>975,5268=>1029,5269=>975,5270=>1029,5271=>975,5272=>1029,5273=>975,
5274=>1029,5275=>975,5276=>1029,5277=>975,5278=>1029,5279=>975,5280=>1029,5281=>501,5282=>501,5283=>626,
5284=>626,5285=>626,5286=>626,5287=>626,5288=>626,5289=>626,5290=>626,5291=>626,5292=>881,5293=>854,
5294=>863,5295=>874,5296=>863,5297=>874,5298=>881,5299=>874,5300=>881,5301=>874,5302=>863,5303=>874,
5304=>863,5305=>874,5306=>863,5307=>436,5308=>548,5309=>436,5312=>988,5313=>988,5314=>988,5315=>988,
5316=>931,5317=>931,5318=>931,5319=>931,5320=>931,5321=>1238,5322=>1247,5323=>1200,5324=>1228,5325=>1200,
5326=>1228,5327=>931,5328=>660,5329=>497,5330=>660,5331=>988,5332=>988,5333=>988,5334=>988,5335=>931,
5336=>931,5337=>931,5338=>931,5339=>931,5340=>1231,5341=>1247,5342=>1283,5343=>1228,5344=>1283,5345=>1228,
5346=>1228,5347=>1214,5348=>1228,5349=>1214,5350=>1283,5351=>1228,5352=>1283,5353=>1228,5354=>660,5356=>886,
5357=>730,5358=>730,5359=>730,5360=>730,5361=>730,5362=>730,5363=>730,5364=>730,5365=>730,5366=>998,
5367=>958,5368=>967,5369=>989,5370=>967,5371=>989,5372=>998,5373=>958,5374=>998,5375=>958,5376=>967,
5377=>989,5378=>967,5379=>989,5380=>967,5381=>493,5382=>460,5383=>493,5392=>923,5393=>923,5394=>923,
5395=>1136,5396=>1136,5397=>1136,5398=>1136,5399=>1209,5400=>1202,5401=>1209,5402=>1202,5403=>1209,5404=>1202,
5405=>1431,5406=>1420,5407=>1431,5408=>1420,5409=>1431,5410=>1420,5411=>1431,5412=>1420,5413=>746,5414=>776,
5415=>776,5416=>776,5417=>776,5418=>776,5419=>776,5420=>776,5421=>776,5422=>776,5423=>1003,5424=>1003,
5425=>1013,5426=>996,5427=>1013,5428=>996,5429=>1003,5430=>1003,5431=>1003,5432=>1003,5433=>1013,5434=>996,
5435=>1013,5436=>996,5437=>1013,5438=>495,5440=>395,5441=>510,5442=>1033,5443=>1033,5444=>976,5445=>976,
5446=>976,5447=>976,5448=>733,5449=>733,5450=>733,5451=>733,5452=>733,5453=>733,5454=>1003,5455=>959,
5456=>495,5458=>886,5459=>774,5460=>774,5461=>774,5462=>774,5463=>928,5464=>928,5465=>928,5466=>928,
5467=>1172,5468=>1142,5469=>602,5470=>812,5471=>812,5472=>812,5473=>812,5474=>812,5475=>812,5476=>815,
5477=>815,5478=>815,5479=>815,5480=>1060,5481=>1052,5482=>548,5492=>977,5493=>977,5494=>977,5495=>977,
5496=>977,5497=>977,5498=>977,5499=>618,5500=>837,5501=>510,5502=>1238,5503=>1238,5504=>1238,5505=>1238,
5506=>1238,5507=>1238,5508=>1238,5509=>989,5514=>977,5515=>977,5516=>977,5517=>977,5518=>1591,5519=>1591,
5520=>1591,5521=>1295,5522=>1295,5523=>1591,5524=>1591,5525=>848,5526=>1273,5536=>988,5537=>988,5538=>931,
5539=>931,5540=>931,5541=>931,5542=>660,5543=>776,5544=>776,5545=>776,5546=>776,5547=>776,5548=>776,
5549=>776,5550=>495,5551=>743,5598=>830,5601=>830,5702=>496,5703=>496,5742=>413,5743=>1238,5744=>1591,
5745=>2016,5746=>2016,5747=>1720,5748=>1678,5749=>2016,5750=>2016,7424=>652,7425=>833,7426=>1048,7427=>608,
7428=>593,7429=>676,7430=>676,7431=>559,7432=>557,7433=>343,7434=>494,7435=>665,7436=>539,7437=>817,
7438=>701,7439=>687,7440=>593,7441=>660,7442=>660,7443=>660,7444=>1094,7446=>687,7447=>687,7448=>556,
7449=>642,7450=>642,7451=>580,7452=>634,7453=>737,7454=>948,7455=>695,7456=>652,7457=>924,7458=>582,
7459=>646,7462=>539,7463=>652,7464=>691,7465=>556,7466=>781,7467=>732,7468=>487,7469=>683,7470=>480,
7472=>523,7473=>430,7474=>430,7475=>517,7476=>527,7477=>234,7478=>234,7479=>488,7480=>401,7481=>626,
7482=>527,7483=>527,7484=>535,7485=>509,7486=>461,7487=>485,7488=>430,7489=>511,7490=>695,7491=>458,
7492=>458,7493=>479,7494=>712,7495=>479,7496=>479,7497=>479,7498=>479,7499=>386,7500=>386,7501=>479,
7502=>219,7503=>487,7504=>664,7505=>456,7506=>488,7507=>414,7508=>488,7509=>488,7510=>479,7511=>388,
7512=>456,7513=>462,7514=>664,7515=>501,7517=>451,7518=>429,7519=>433,7520=>493,7521=>406,7522=>219,
7523=>315,7524=>456,7525=>501,7526=>451,7527=>429,7528=>451,7529=>493,7530=>406,7543=>716,7544=>527,
7547=>545,7557=>514,7579=>479,7580=>414,7581=>414,7582=>488,7583=>386,7584=>377,7585=>348,7586=>479,
7587=>456,7588=>347,7589=>281,7590=>347,7591=>347,7592=>431,7593=>326,7594=>330,7595=>370,7596=>664,
7597=>664,7598=>562,7599=>562,7600=>448,7601=>488,7602=>542,7603=>422,7604=>396,7605=>388,7606=>583,
7607=>494,7608=>399,7609=>451,7610=>501,7611=>417,7612=>523,7613=>470,7614=>455,7615=>425,7620=>0,
7621=>0,7622=>0,7623=>0,7624=>0,7625=>0,7680=>774,7681=>675,7682=>762,7683=>716,7684=>762,
7685=>716,7686=>762,7687=>716,7688=>734,7689=>593,7690=>830,7691=>716,7692=>830,7693=>716,7694=>830,
7695=>716,7696=>830,7697=>716,7698=>830,7699=>716,7700=>683,7701=>678,7702=>683,7703=>678,7704=>683,
7705=>678,7706=>683,7707=>678,7708=>683,7709=>678,7710=>683,7711=>435,7712=>821,7713=>716,7714=>837,
7715=>712,7716=>837,7717=>712,7718=>837,7719=>712,7720=>837,7721=>712,7722=>837,7723=>712,7724=>372,
7725=>343,7726=>372,7727=>343,7728=>775,7729=>665,7730=>775,7731=>665,7732=>775,7733=>665,7734=>637,
7735=>343,7736=>637,7737=>343,7738=>637,7739=>343,7740=>637,7741=>343,7742=>995,7743=>1042,7744=>995,
7745=>1042,7746=>995,7747=>1042,7748=>837,7749=>712,7750=>837,7751=>712,7752=>837,7753=>712,7754=>837,
7755=>712,7756=>850,7757=>687,7758=>850,7759=>687,7760=>850,7761=>687,7762=>850,7763=>687,7764=>733,
7765=>716,7766=>733,7767=>716,7768=>770,7769=>493,7770=>770,7771=>493,7772=>770,7773=>493,7774=>770,
7775=>493,7776=>720,7777=>595,7778=>720,7779=>595,7780=>720,7781=>595,7782=>720,7783=>595,7784=>720,
7785=>595,7786=>682,7787=>478,7788=>682,7789=>478,7790=>682,7791=>478,7792=>682,7793=>478,7794=>812,
7795=>712,7796=>812,7797=>712,7798=>812,7799=>712,7800=>812,7801=>712,7802=>812,7803=>712,7804=>774,
7805=>652,7806=>774,7807=>652,7808=>1103,7809=>924,7810=>1103,7811=>924,7812=>1103,7813=>924,7814=>1103,
7815=>924,7816=>1103,7817=>924,7818=>771,7819=>645,7820=>771,7821=>645,7822=>724,7823=>652,7824=>725,
7825=>582,7826=>725,7827=>582,7828=>725,7829=>582,7830=>712,7831=>478,7832=>924,7833=>652,7834=>675,
7835=>435,7838=>896,7839=>687,7840=>774,7841=>675,7842=>774,7843=>675,7844=>774,7845=>675,7846=>774,
7847=>675,7848=>774,7849=>675,7850=>774,7851=>675,7852=>774,7853=>675,7854=>774,7855=>675,7856=>774,
7857=>675,7858=>774,7859=>675,7860=>774,7861=>675,7862=>774,7863=>675,7864=>683,7865=>678,7866=>683,
7867=>678,7868=>683,7869=>678,7870=>683,7871=>678,7872=>683,7873=>678,7874=>683,7875=>678,7876=>683,
7877=>678,7878=>683,7879=>678,7880=>372,7881=>343,7882=>372,7883=>343,7884=>850,7885=>687,7886=>850,
7887=>687,7888=>850,7889=>687,7890=>850,7891=>687,7892=>850,7893=>687,7894=>850,7895=>687,7896=>850,
7897=>687,7898=>850,7899=>687,7900=>850,7901=>687,7902=>850,7903=>687,7904=>850,7905=>687,7906=>850,
7907=>687,7908=>812,7909=>712,7910=>812,7911=>712,7912=>812,7913=>712,7914=>812,7915=>712,7916=>812,
7917=>712,7918=>812,7919=>712,7920=>812,7921=>712,7922=>724,7923=>652,7924=>724,7925=>652,7926=>724,
7927=>652,7928=>724,7929=>652,7936=>687,7937=>687,7938=>687,7939=>687,7940=>687,7941=>687,7942=>687,
7943=>687,7944=>774,7945=>774,7946=>1041,7947=>1043,7948=>935,7949=>963,7950=>835,7951=>859,7952=>557,
7953=>557,7954=>557,7955=>557,7956=>557,7957=>557,7960=>792,7961=>794,7962=>1100,7963=>1096,7964=>1023,
7965=>1052,7968=>712,7969=>712,7970=>712,7971=>712,7972=>712,7973=>712,7974=>712,7975=>712,7976=>945,
7977=>951,7978=>1250,7979=>1250,7980=>1180,7981=>1206,7982=>1054,7983=>1063,7984=>390,7985=>390,7986=>390,
7987=>390,7988=>390,7989=>390,7990=>390,7991=>390,7992=>483,7993=>489,7994=>777,7995=>785,7996=>712,
7997=>738,7998=>604,7999=>604,8000=>687,8001=>687,8002=>687,8003=>687,8004=>687,8005=>687,8008=>892,
8009=>933,8010=>1221,8011=>1224,8012=>1053,8013=>1082,8016=>675,8017=>675,8018=>675,8019=>675,8020=>675,
8021=>675,8022=>675,8023=>675,8025=>930,8027=>1184,8029=>1199,8031=>1049,8032=>869,8033=>869,8034=>869,
8035=>869,8036=>869,8037=>869,8038=>869,8039=>869,8040=>909,8041=>958,8042=>1246,8043=>1251,8044=>1076,
8045=>1105,8046=>1028,8047=>1076,8048=>687,8049=>687,8050=>557,8051=>557,8052=>712,8053=>712,8054=>390,
8055=>390,8056=>687,8057=>687,8058=>675,8059=>675,8060=>869,8061=>869,8064=>687,8065=>687,8066=>687,
8067=>687,8068=>687,8069=>687,8070=>687,8071=>687,8072=>774,8073=>774,8074=>1041,8075=>1043,8076=>935,
8077=>963,8078=>835,8079=>859,8080=>712,8081=>712,8082=>712,8083=>712,8084=>712,8085=>712,8086=>712,
8087=>712,8088=>945,8089=>951,8090=>1250,8091=>1250,8092=>1180,8093=>1206,8094=>1054,8095=>1063,8096=>869,
8097=>869,8098=>869,8099=>869,8100=>869,8101=>869,8102=>869,8103=>869,8104=>909,8105=>958,8106=>1246,
8107=>1251,8108=>1076,8109=>1105,8110=>1028,8111=>1076,8112=>687,8113=>687,8114=>687,8115=>687,8116=>687,
8118=>687,8119=>687,8120=>774,8121=>774,8122=>876,8123=>797,8124=>774,8125=>500,8126=>500,8127=>500,
8128=>500,8129=>500,8130=>712,8131=>712,8132=>712,8134=>712,8135=>712,8136=>929,8137=>846,8138=>1080,
8139=>1009,8140=>837,8141=>500,8142=>500,8143=>500,8144=>390,8145=>390,8146=>390,8147=>390,8150=>390,
8151=>390,8152=>372,8153=>372,8154=>621,8155=>563,8157=>500,8158=>500,8159=>500,8160=>675,8161=>675,
8162=>675,8163=>675,8164=>716,8165=>716,8166=>675,8167=>675,8168=>724,8169=>724,8170=>1020,8171=>980,
8172=>838,8173=>500,8174=>500,8175=>500,8178=>869,8179=>869,8180=>869,8182=>869,8183=>869,8184=>1065,
8185=>891,8186=>1084,8187=>894,8188=>850,8189=>500,8190=>500,8192=>500,8193=>1000,8194=>500,8195=>1000,
8196=>330,8197=>250,8198=>167,8199=>696,8200=>380,8201=>200,8202=>100,8203=>0,8204=>0,8205=>0,
8206=>0,8207=>0,8208=>415,8209=>415,8210=>696,8213=>1000,8214=>500,8215=>500,8219=>380,8223=>657,
8227=>639,8228=>380,8229=>685,8231=>348,8234=>0,8235=>0,8236=>0,8237=>0,8238=>0,8239=>200,
8241=>1908,8242=>264,8243=>447,8244=>630,8245=>264,8246=>447,8247=>630,8248=>733,8251=>972,8252=>627,
8253=>580,8254=>500,8255=>828,8256=>828,8257=>329,8258=>1023,8259=>500,8260=>167,8261=>457,8262=>457,
8263=>1030,8264=>829,8265=>829,8266=>513,8267=>687,8268=>500,8269=>500,8270=>523,8271=>400,8272=>828,
8273=>523,8274=>556,8275=>838,8276=>828,8277=>838,8278=>684,8279=>813,8280=>838,8281=>838,8282=>380,
8283=>872,8284=>838,8285=>380,8286=>380,8287=>222,8288=>0,8289=>0,8290=>0,8291=>0,8292=>0,
8298=>0,8299=>0,8300=>0,8301=>0,8302=>0,8303=>0,8304=>438,8305=>219,8308=>438,8309=>438,
8310=>438,8311=>438,8312=>438,8313=>438,8314=>528,8315=>528,8316=>528,8317=>288,8318=>288,8319=>456,
8320=>438,8321=>438,8322=>438,8323=>438,8324=>438,8325=>438,8326=>438,8327=>438,8328=>438,8329=>438,
8330=>528,8331=>528,8332=>528,8333=>288,8334=>288,8336=>458,8337=>479,8338=>488,8339=>413,8340=>479,
8352=>929,8353=>696,8354=>696,8355=>696,8356=>696,8357=>1042,8358=>837,8359=>1488,8360=>1205,8361=>1103,
8362=>854,8363=>714,8365=>696,8366=>682,8367=>1392,8368=>696,8369=>696,8370=>696,8371=>696,8372=>859,
8373=>696,8400=>0,8401=>0,8406=>0,8407=>0,8411=>0,8412=>0,8417=>0,8448=>1106,8449=>1106,
8450=>734,8451=>1211,8452=>896,8453=>1114,8454=>1148,8455=>696,8456=>698,8457=>952,8459=>1073,8460=>913,
8461=>888,8462=>712,8463=>712,8464=>597,8465=>697,8466=>856,8467=>472,8468=>974,8469=>837,8470=>1203,
8471=>1000,8472=>697,8473=>750,8474=>850,8475=>938,8476=>814,8477=>801,8478=>896,8479=>710,8480=>1020,
8481=>1239,8483=>834,8484=>754,8485=>622,8486=>850,8487=>769,8488=>763,8489=>303,8490=>775,8491=>774,
8492=>928,8493=>818,8494=>854,8495=>636,8496=>729,8497=>808,8498=>683,8499=>1184,8500=>465,8501=>794,
8502=>731,8503=>494,8504=>684,8505=>380,8506=>945,8507=>1370,8508=>790,8509=>737,8510=>654,8511=>863,
8512=>840,8513=>786,8514=>576,8515=>637,8516=>760,8517=>830,8518=>716,8519=>678,8520=>343,8521=>343,
8523=>872,8526=>547,8531=>1035,8532=>1035,8533=>1035,8534=>1035,8535=>1035,8536=>1035,8537=>1035,8538=>1035,
8539=>1035,8540=>1035,8541=>1035,8542=>1035,8543=>615,8544=>372,8545=>659,8546=>945,8547=>1099,8548=>774,
8549=>1099,8550=>1386,8551=>1672,8552=>1121,8553=>771,8554=>1120,8555=>1407,8556=>637,8557=>734,8558=>830,
8559=>995,8560=>343,8561=>607,8562=>872,8563=>984,8564=>652,8565=>962,8566=>1227,8567=>1491,8568=>969,
8569=>645,8570=>969,8571=>1233,8572=>343,8573=>593,8574=>716,8575=>1042,8576=>1289,8577=>830,8578=>1289,
8579=>734,8580=>593,8592=>838,8593=>838,8594=>838,8595=>838,8596=>838,8597=>838,8598=>838,8599=>838,
8600=>838,8601=>838,8602=>838,8603=>838,8604=>838,8605=>838,8606=>838,8607=>838,8608=>838,8609=>838,
8610=>838,8611=>838,8612=>838,8613=>838,8614=>838,8615=>838,8616=>838,8617=>838,8618=>838,8619=>838,
8620=>838,8621=>838,8622=>838,8623=>838,8624=>838,8625=>838,8626=>838,8627=>838,8628=>838,8629=>838,
8630=>838,8631=>838,8632=>838,8633=>838,8634=>838,8635=>838,8636=>838,8637=>838,8638=>838,8639=>838,
8640=>838,8641=>838,8642=>838,8643=>838,8644=>838,8645=>838,8646=>838,8647=>838,8648=>838,8649=>838,
8650=>838,8651=>838,8652=>838,8653=>838,8654=>838,8655=>838,8656=>838,8657=>838,8658=>838,8659=>838,
8660=>838,8661=>838,8662=>838,8663=>838,8664=>838,8665=>838,8666=>838,8667=>838,8668=>838,8669=>838,
8670=>838,8671=>838,8672=>838,8673=>838,8674=>838,8675=>838,8676=>838,8677=>838,8678=>838,8679=>838,
8680=>838,8681=>838,8682=>838,8683=>838,8684=>838,8685=>838,8686=>838,8687=>838,8688=>838,8689=>838,
8690=>838,8691=>838,8692=>838,8693=>838,8694=>838,8695=>838,8696=>838,8697=>838,8698=>838,8699=>838,
8700=>838,8701=>838,8702=>838,8703=>838,8704=>774,8705=>696,8706=>544,8707=>683,8708=>683,8709=>856,
8710=>697,8711=>697,8712=>896,8713=>896,8714=>750,8715=>896,8716=>896,8717=>750,8718=>636,8719=>787,
8720=>787,8721=>718,8722=>838,8723=>838,8724=>696,8725=>365,8726=>696,8727=>838,8728=>626,8729=>380,
8730=>667,8731=>667,8732=>667,8733=>712,8734=>833,8735=>838,8736=>896,8737=>896,8738=>838,8739=>500,
8740=>500,8741=>500,8742=>500,8743=>812,8744=>812,8745=>812,8746=>812,8747=>610,8748=>929,8749=>1295,
8750=>563,8751=>977,8752=>1313,8753=>563,8754=>563,8755=>563,8756=>696,8757=>696,8758=>294,8759=>696,
8760=>838,8761=>838,8762=>838,8763=>838,8764=>838,8765=>838,8766=>838,8767=>838,8768=>375,8769=>838,
8770=>838,8771=>838,8772=>838,8773=>838,8774=>838,8775=>838,8776=>838,8777=>838,8778=>838,8779=>838,
8780=>838,8781=>838,8782=>838,8783=>838,8784=>838,8785=>838,8786=>838,8787=>838,8788=>1063,8789=>1063,
8790=>838,8791=>838,8792=>838,8793=>838,8794=>838,8795=>838,8796=>838,8797=>838,8798=>838,8799=>838,
8800=>838,8801=>838,8802=>838,8803=>838,8804=>838,8805=>838,8806=>838,8807=>838,8808=>841,8809=>841,
8810=>1047,8811=>1047,8812=>500,8813=>838,8814=>838,8815=>838,8816=>838,8817=>838,8818=>838,8819=>838,
8820=>838,8821=>838,8822=>838,8823=>838,8824=>838,8825=>838,8826=>838,8827=>838,8828=>838,8829=>838,
8830=>838,8831=>838,8832=>838,8833=>838,8834=>838,8835=>838,8836=>838,8837=>838,8838=>838,8839=>838,
8840=>838,8841=>838,8842=>838,8843=>838,8844=>812,8845=>812,8846=>812,8847=>838,8848=>838,8849=>838,
8850=>838,8851=>796,8852=>796,8853=>838,8854=>838,8855=>838,8856=>838,8857=>838,8858=>838,8859=>838,
8860=>838,8861=>838,8862=>838,8863=>838,8864=>838,8865=>838,8866=>914,8867=>914,8868=>914,8869=>914,
8870=>542,8871=>542,8872=>914,8873=>914,8874=>914,8875=>914,8876=>914,8877=>914,8878=>914,8879=>914,
8880=>838,8881=>838,8882=>838,8883=>838,8884=>838,8885=>838,8886=>1000,8887=>1000,8888=>838,8889=>838,
8890=>542,8891=>812,8892=>812,8893=>812,8894=>838,8895=>838,8896=>843,8897=>843,8898=>843,8899=>843,
8900=>494,8901=>380,8902=>626,8903=>838,8904=>1000,8905=>1000,8906=>1000,8907=>1000,8908=>1000,8909=>838,
8910=>812,8911=>812,8912=>838,8913=>838,8914=>838,8915=>838,8916=>838,8917=>838,8918=>838,8919=>838,
8920=>1422,8921=>1422,8922=>838,8923=>838,8924=>838,8925=>838,8926=>838,8927=>838,8928=>838,8929=>838,
8930=>838,8931=>838,8932=>838,8933=>838,8934=>838,8935=>838,8936=>838,8937=>838,8938=>838,8939=>838,
8940=>838,8941=>838,8942=>1000,8943=>1000,8944=>1000,8945=>1000,8946=>1158,8947=>896,8948=>750,8949=>896,
8950=>896,8951=>750,8952=>896,8953=>896,8954=>1158,8955=>896,8956=>750,8957=>896,8958=>750,8959=>896,
8960=>602,8961=>602,8962=>716,8963=>838,8964=>838,8965=>838,8966=>838,8967=>488,8968=>457,8969=>457,
8970=>457,8971=>457,8972=>809,8973=>809,8974=>809,8975=>809,8976=>838,8977=>539,8984=>928,8985=>838,
8988=>469,8989=>469,8990=>469,8991=>469,8992=>610,8993=>610,8996=>1152,8997=>1152,8998=>1414,8999=>1152,
9000=>1443,9003=>1414,9004=>873,9075=>390,9076=>716,9077=>869,9082=>687,9085=>863,9095=>1152,9108=>873,
9115=>500,9116=>500,9117=>500,9118=>500,9119=>500,9120=>500,9121=>500,9122=>500,9123=>500,9124=>500,
9125=>500,9126=>500,9127=>750,9128=>750,9129=>750,9130=>750,9131=>750,9132=>750,9133=>750,9134=>610,
9166=>838,9167=>945,9187=>873,9189=>769,9250=>716,9251=>716,9312=>847,9313=>847,9314=>847,9315=>847,
9316=>847,9317=>847,9318=>847,9319=>847,9320=>847,9321=>847,9600=>769,9601=>769,9602=>769,9603=>769,
9604=>769,9605=>769,9606=>769,9607=>769,9608=>769,9609=>769,9610=>769,9611=>769,9612=>769,9613=>769,
9614=>769,9615=>769,9616=>769,9617=>769,9618=>769,9619=>769,9620=>769,9621=>769,9622=>769,9623=>769,
9624=>769,9625=>769,9626=>769,9627=>769,9628=>769,9629=>769,9630=>769,9631=>769,9632=>945,9633=>945,
9634=>945,9635=>945,9636=>945,9637=>945,9638=>945,9639=>945,9640=>945,9641=>945,9642=>678,9643=>678,
9644=>945,9645=>945,9646=>550,9647=>550,9648=>769,9649=>769,9650=>769,9651=>769,9652=>502,9653=>502,
9654=>769,9655=>769,9656=>502,9657=>502,9658=>769,9659=>769,9660=>769,9661=>769,9662=>502,9663=>502,
9664=>769,9665=>769,9666=>502,9667=>502,9668=>769,9669=>769,9670=>769,9671=>769,9672=>769,9673=>873,
9674=>494,9675=>873,9676=>873,9677=>873,9678=>873,9679=>873,9680=>873,9681=>873,9682=>873,9683=>873,
9684=>873,9685=>873,9686=>527,9687=>527,9688=>840,9689=>970,9690=>970,9691=>970,9692=>387,9693=>387,
9694=>387,9695=>387,9696=>769,9697=>769,9698=>769,9699=>769,9700=>769,9701=>769,9702=>639,9703=>945,
9704=>945,9705=>945,9706=>945,9707=>945,9708=>769,9709=>769,9710=>769,9711=>1119,9712=>945,9713=>945,
9714=>945,9715=>945,9716=>873,9717=>873,9718=>873,9719=>873,9720=>769,9721=>769,9722=>769,9723=>830,
9724=>830,9725=>732,9726=>732,9727=>769,9728=>896,9729=>1000,9730=>896,9731=>896,9732=>896,9733=>896,
9734=>896,9735=>573,9736=>896,9737=>896,9738=>888,9739=>888,9740=>671,9741=>1013,9742=>1246,9743=>1250,
9744=>896,9745=>896,9746=>896,9747=>532,9748=>896,9749=>896,9750=>896,9751=>896,9752=>896,9753=>896,
9754=>896,9755=>896,9756=>896,9757=>609,9758=>896,9759=>609,9760=>896,9761=>896,9762=>896,9763=>896,
9764=>669,9765=>746,9766=>649,9767=>784,9768=>545,9769=>896,9770=>896,9771=>896,9772=>710,9773=>896,
9774=>896,9775=>896,9776=>896,9777=>896,9778=>896,9779=>896,9780=>896,9781=>896,9782=>896,9783=>896,
9784=>896,9785=>896,9786=>896,9787=>896,9788=>896,9789=>896,9790=>896,9791=>614,9792=>731,9793=>731,
9794=>896,9795=>896,9796=>896,9797=>896,9798=>896,9799=>896,9800=>896,9801=>896,9802=>896,9803=>896,
9804=>896,9805=>896,9806=>896,9807=>896,9808=>896,9809=>896,9810=>896,9811=>896,9812=>896,9813=>896,
9814=>896,9815=>896,9816=>896,9817=>896,9818=>896,9819=>896,9820=>896,9821=>896,9822=>896,9823=>896,
9824=>896,9825=>896,9826=>896,9827=>896,9828=>896,9829=>896,9830=>896,9831=>896,9832=>896,9833=>472,
9834=>638,9835=>896,9836=>896,9837=>472,9838=>357,9839=>484,9840=>748,9841=>766,9842=>896,9843=>896,
9844=>896,9845=>896,9846=>896,9847=>896,9848=>896,9849=>896,9850=>896,9851=>896,9852=>896,9853=>896,
9854=>896,9855=>896,9856=>869,9857=>869,9858=>869,9859=>869,9860=>869,9861=>869,9862=>896,9863=>896,
9864=>896,9865=>896,9866=>896,9867=>896,9868=>896,9869=>896,9870=>896,9871=>896,9872=>896,9873=>896,
9874=>896,9875=>896,9876=>896,9877=>541,9878=>896,9879=>896,9880=>896,9881=>896,9882=>896,9883=>896,
9884=>896,9888=>896,9889=>702,9890=>1003,9891=>1085,9892=>1143,9893=>901,9894=>838,9895=>838,9896=>838,
9897=>838,9898=>838,9899=>838,9900=>838,9901=>838,9902=>838,9903=>838,9904=>844,9905=>838,9906=>731,
9907=>732,9908=>732,9909=>732,9910=>850,9911=>732,9912=>732,9985=>838,9986=>838,9987=>838,9988=>838,
9990=>838,9991=>838,9992=>838,9993=>838,9996=>838,9997=>838,9998=>838,9999=>838,10000=>838,10001=>838,
10002=>838,10003=>838,10004=>838,10005=>838,10006=>838,10007=>838,10008=>838,10009=>838,10010=>838,10011=>838,
10012=>838,10013=>838,10014=>838,10015=>838,10016=>838,10017=>838,10018=>838,10019=>838,10020=>838,10021=>838,
10022=>838,10023=>838,10025=>838,10026=>838,10027=>838,10028=>838,10029=>838,10030=>838,10031=>838,10032=>838,
10033=>838,10034=>838,10035=>838,10036=>838,10037=>838,10038=>838,10039=>838,10040=>838,10041=>838,10042=>838,
10043=>838,10044=>838,10045=>838,10046=>838,10047=>838,10048=>838,10049=>838,10050=>838,10051=>838,10052=>838,
10053=>838,10054=>838,10055=>838,10056=>838,10057=>838,10058=>838,10059=>838,10061=>896,10063=>896,10064=>896,
10065=>896,10066=>896,10070=>896,10072=>838,10073=>838,10074=>838,10075=>322,10076=>322,10077=>538,10078=>538,
10081=>838,10082=>838,10083=>838,10084=>838,10085=>838,10086=>838,10087=>838,10088=>838,10089=>838,10090=>838,
10091=>838,10092=>838,10093=>838,10094=>838,10095=>838,10096=>838,10097=>838,10098=>838,10099=>838,10100=>838,
10101=>838,10102=>847,10103=>847,10104=>847,10105=>847,10106=>847,10107=>847,10108=>847,10109=>847,10110=>847,
10111=>847,10112=>838,10113=>838,10114=>838,10115=>838,10116=>838,10117=>838,10118=>838,10119=>838,10120=>838,
10121=>838,10122=>838,10123=>838,10124=>838,10125=>838,10126=>838,10127=>838,10128=>838,10129=>838,10130=>838,
10131=>838,10132=>838,10136=>838,10137=>838,10138=>838,10139=>838,10140=>838,10141=>838,10142=>838,10143=>838,
10144=>838,10145=>838,10146=>838,10147=>838,10148=>838,10149=>838,10150=>838,10151=>838,10152=>838,10153=>838,
10154=>838,10155=>838,10156=>838,10157=>838,10158=>838,10159=>838,10161=>838,10162=>838,10163=>838,10164=>838,
10165=>838,10166=>838,10167=>838,10168=>838,10169=>838,10170=>838,10171=>838,10172=>838,10173=>838,10174=>838,
10181=>457,10182=>457,10208=>494,10214=>487,10215=>487,10216=>457,10217=>457,10218=>721,10219=>721,10224=>838,
10225=>838,10226=>838,10227=>838,10228=>1157,10229=>1434,10230=>1434,10231=>1434,10232=>1434,10233=>1434,10234=>1434,
10235=>1434,10236=>1434,10237=>1434,10238=>1434,10239=>1434,10240=>781,10241=>781,10242=>781,10243=>781,10244=>781,
10245=>781,10246=>781,10247=>781,10248=>781,10249=>781,10250=>781,10251=>781,10252=>781,10253=>781,10254=>781,
10255=>781,10256=>781,10257=>781,10258=>781,10259=>781,10260=>781,10261=>781,10262=>781,10263=>781,10264=>781,
10265=>781,10266=>781,10267=>781,10268=>781,10269=>781,10270=>781,10271=>781,10272=>781,10273=>781,10274=>781,
10275=>781,10276=>781,10277=>781,10278=>781,10279=>781,10280=>781,10281=>781,10282=>781,10283=>781,10284=>781,
10285=>781,10286=>781,10287=>781,10288=>781,10289=>781,10290=>781,10291=>781,10292=>781,10293=>781,10294=>781,
10295=>781,10296=>781,10297=>781,10298=>781,10299=>781,10300=>781,10301=>781,10302=>781,10303=>781,10304=>781,
10305=>781,10306=>781,10307=>781,10308=>781,10309=>781,10310=>781,10311=>781,10312=>781,10313=>781,10314=>781,
10315=>781,10316=>781,10317=>781,10318=>781,10319=>781,10320=>781,10321=>781,10322=>781,10323=>781,10324=>781,
10325=>781,10326=>781,10327=>781,10328=>781,10329=>781,10330=>781,10331=>781,10332=>781,10333=>781,10334=>781,
10335=>781,10336=>781,10337=>781,10338=>781,10339=>781,10340=>781,10341=>781,10342=>781,10343=>781,10344=>781,
10345=>781,10346=>781,10347=>781,10348=>781,10349=>781,10350=>781,10351=>781,10352=>781,10353=>781,10354=>781,
10355=>781,10356=>781,10357=>781,10358=>781,10359=>781,10360=>781,10361=>781,10362=>781,10363=>781,10364=>781,
10365=>781,10366=>781,10367=>781,10368=>781,10369=>781,10370=>781,10371=>781,10372=>781,10373=>781,10374=>781,
10375=>781,10376=>781,10377=>781,10378=>781,10379=>781,10380=>781,10381=>781,10382=>781,10383=>781,10384=>781,
10385=>781,10386=>781,10387=>781,10388=>781,10389=>781,10390=>781,10391=>781,10392=>781,10393=>781,10394=>781,
10395=>781,10396=>781,10397=>781,10398=>781,10399=>781,10400=>781,10401=>781,10402=>781,10403=>781,10404=>781,
10405=>781,10406=>781,10407=>781,10408=>781,10409=>781,10410=>781,10411=>781,10412=>781,10413=>781,10414=>781,
10415=>781,10416=>781,10417=>781,10418=>781,10419=>781,10420=>781,10421=>781,10422=>781,10423=>781,10424=>781,
10425=>781,10426=>781,10427=>781,10428=>781,10429=>781,10430=>781,10431=>781,10432=>781,10433=>781,10434=>781,
10435=>781,10436=>781,10437=>781,10438=>781,10439=>781,10440=>781,10441=>781,10442=>781,10443=>781,10444=>781,
10445=>781,10446=>781,10447=>781,10448=>781,10449=>781,10450=>781,10451=>781,10452=>781,10453=>781,10454=>781,
10455=>781,10456=>781,10457=>781,10458=>781,10459=>781,10460=>781,10461=>781,10462=>781,10463=>781,10464=>781,
10465=>781,10466=>781,10467=>781,10468=>781,10469=>781,10470=>781,10471=>781,10472=>781,10473=>781,10474=>781,
10475=>781,10476=>781,10477=>781,10478=>781,10479=>781,10480=>781,10481=>781,10482=>781,10483=>781,10484=>781,
10485=>781,10486=>781,10487=>781,10488=>781,10489=>781,10490=>781,10491=>781,10492=>781,10493=>781,10494=>781,
10495=>781,10502=>838,10503=>838,10506=>838,10507=>838,10560=>838,10561=>838,10627=>753,10628=>753,10702=>838,
10703=>1046,10704=>1046,10705=>1000,10706=>1000,10707=>1000,10708=>1000,10709=>1000,10731=>494,10746=>838,10747=>838,
10752=>1000,10753=>1000,10754=>1000,10764=>1661,10765=>563,10766=>563,10767=>563,10768=>563,10769=>563,10770=>563,
10771=>563,10772=>563,10773=>563,10774=>563,10775=>563,10776=>563,10777=>563,10778=>563,10779=>563,10780=>563,
10799=>838,10877=>838,10878=>838,10879=>838,10880=>838,10881=>838,10882=>838,10883=>838,10884=>838,10885=>838,
10886=>838,10887=>838,10888=>838,10889=>838,10890=>838,10891=>838,10892=>838,10893=>838,10894=>838,10895=>838,
10896=>838,10897=>838,10898=>838,10899=>838,10900=>838,10901=>838,10902=>838,10903=>838,10904=>838,10905=>838,
10906=>838,10907=>838,10908=>838,10909=>838,10910=>838,10911=>838,10912=>838,10926=>838,10927=>838,10928=>838,
10929=>838,10930=>838,10931=>838,10932=>838,10933=>838,10934=>838,10935=>838,10936=>838,10937=>838,10938=>838,
11001=>838,11002=>838,11008=>838,11009=>838,11010=>838,11011=>838,11012=>838,11013=>838,11014=>838,11015=>838,
11016=>838,11017=>838,11018=>838,11019=>838,11020=>838,11021=>838,11022=>838,11023=>838,11024=>838,11025=>838,
11026=>945,11027=>945,11028=>945,11029=>945,11030=>769,11031=>769,11032=>769,11033=>769,11034=>945,11039=>869,
11040=>869,11041=>873,11042=>873,11043=>873,11044=>1119,11091=>869,11092=>869,11360=>637,11361=>360,11362=>637,
11363=>733,11364=>770,11365=>675,11366=>478,11367=>956,11368=>712,11369=>775,11370=>665,11371=>725,11372=>582,
11373=>860,11374=>995,11375=>774,11377=>778,11378=>1221,11379=>1056,11380=>652,11381=>698,11382=>565,11383=>782,
11385=>538,11386=>687,11387=>559,11388=>219,11389=>487,11800=>586,11810=>457,11811=>457,11812=>457,11813=>457,
11822=>580,19904=>896,19905=>896,19906=>896,19907=>896,19908=>896,19909=>896,19910=>896,19911=>896,19912=>896,
19913=>896,19914=>896,19915=>896,19916=>896,19917=>896,19918=>896,19919=>896,19920=>896,19921=>896,19922=>896,
19923=>896,19924=>896,19925=>896,19926=>896,19927=>896,19928=>896,19929=>896,19930=>896,19931=>896,19932=>896,
19933=>896,19934=>896,19935=>896,19936=>896,19937=>896,19938=>896,19939=>896,19940=>896,19941=>896,19942=>896,
19943=>896,19944=>896,19945=>896,19946=>896,19947=>896,19948=>896,19949=>896,19950=>896,19951=>896,19952=>896,
19953=>896,19954=>896,19955=>896,19956=>896,19957=>896,19958=>896,19959=>896,19960=>896,19961=>896,19962=>896,
19963=>896,19964=>896,19965=>896,19966=>896,19967=>896,42564=>720,42565=>595,42566=>436,42567=>440,42572=>1405,
42573=>1173,42576=>1234,42577=>1027,42580=>1174,42581=>972,42582=>1100,42583=>969,42594=>1100,42595=>940,42596=>1096,
42597=>915,42598=>1260,42599=>997,42600=>850,42601=>687,42602=>1037,42603=>868,42604=>1406,42605=>1106,42606=>961,
42634=>944,42635=>749,42636=>682,42637=>580,42644=>808,42645=>712,42760=>500,42761=>500,42762=>500,42763=>500,
42764=>500,42765=>500,42766=>500,42767=>500,42768=>500,42769=>500,42770=>500,42771=>500,42772=>500,42773=>500,
42774=>500,42779=>400,42780=>400,42781=>287,42782=>287,42783=>287,42790=>837,42791=>712,42792=>1031,42793=>857,
42794=>696,42795=>557,42800=>559,42801=>595,42802=>1349,42803=>1052,42804=>1285,42805=>1065,42806=>1245,42807=>1052,
42808=>1079,42809=>922,42810=>1079,42811=>922,42812=>1035,42813=>922,42814=>698,42815=>549,42822=>850,42823=>542,
42824=>683,42825=>531,42826=>918,42827=>814,42830=>1406,42831=>1106,42880=>637,42881=>343,42882=>837,42883=>712,
42889=>400,42890=>396,42891=>456,42892=>306,43003=>683,43004=>733,43005=>995,43006=>372,43007=>1325,62917=>687,
64256=>833,64257=>787,64258=>787,64259=>1138,64260=>1139,64261=>808,64262=>1020,64275=>1388,64276=>1384,64277=>1378,
64278=>1384,64279=>1713,64285=>343,64286=>0,64287=>663,64288=>720,64289=>963,64290=>890,64291=>988,64292=>963,
64293=>938,64294=>988,64295=>988,64296=>976,64297=>838,64298=>949,64299=>949,64300=>949,64301=>949,64302=>751,
64303=>751,64304=>751,64305=>673,64306=>537,64307=>654,64308=>712,64309=>343,64310=>491,64312=>724,64313=>467,
64314=>649,64315=>650,64316=>679,64318=>775,64320=>497,64321=>773,64323=>718,64324=>687,64326=>751,64327=>729,
64328=>649,64329=>949,64330=>751,64331=>343,64332=>673,64333=>650,64334=>687,64335=>751,65024=>0,65025=>0,
65026=>0,65027=>0,65028=>0,65029=>0,65030=>0,65031=>0,65032=>0,65033=>0,65034=>0,65035=>0,
65036=>0,65037=>0,65038=>0,65039=>0,65056=>0,65057=>0,65058=>0,65059=>0,65529=>0,65530=>0,
65531=>0,65532=>0,65533=>1113);
$enc='';
$diff='';
$file='dejavusansbi.z';
$ctg='dejavusansbi.ctg.z';
$originalsize=524056;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/dejavusansbi.php | PHP | asf20 | 45,096 |
<?php
$type='TrueTypeUnicode';
$name='FreeSansBoldOblique';
$desc=array('Ascent'=>1000,'Descent'=>-300,'CapHeight'=>22,'Flags'=>96,'FontBBox'=>'[-769 -1175 1591 1639]','ItalicAngle'=>-12,'StemV'=>120,'MissingWidth'=>600);
$up=-145;
$ut=69;
$dw=600;
$cw=array(
32=>278,33=>333,34=>474,35=>556,36=>556,37=>889,38=>722,39=>238,40=>333,41=>333,
42=>389,43=>584,44=>278,45=>333,46=>278,47=>278,48=>556,49=>556,50=>556,51=>556,
52=>556,53=>556,54=>556,55=>556,56=>556,57=>556,58=>333,59=>333,60=>584,61=>584,
62=>584,63=>611,64=>975,65=>722,66=>722,67=>722,68=>722,69=>667,70=>611,71=>778,
72=>722,73=>278,74=>556,75=>722,76=>611,77=>833,78=>722,79=>778,80=>667,81=>778,
82=>722,83=>667,84=>611,85=>722,86=>667,87=>944,88=>667,89=>667,90=>611,91=>333,
92=>278,93=>333,94=>584,95=>556,96=>333,97=>556,98=>611,99=>556,100=>611,101=>556,
102=>333,103=>611,104=>611,105=>278,106=>278,107=>556,108=>278,109=>889,110=>611,111=>611,
112=>611,113=>611,114=>389,115=>556,116=>333,117=>611,118=>556,119=>778,120=>556,121=>556,
122=>500,123=>389,124=>280,125=>389,126=>584,8364=>640,8218=>278,402=>556,8222=>500,8230=>1000,
8224=>556,8225=>556,710=>333,8240=>1000,352=>667,8249=>333,338=>1000,381=>611,8216=>278,8217=>278,
8220=>500,8221=>500,8226=>350,8211=>556,8212=>1000,732=>333,8482=>1000,353=>556,8250=>333,339=>944,
382=>500,376=>667,160=>278,161=>333,162=>556,163=>556,164=>556,165=>556,166=>280,167=>556,
168=>333,169=>737,170=>370,171=>556,172=>584,173=>333,174=>737,175=>333,176=>606,177=>584,
178=>350,179=>350,180=>333,181=>667,182=>556,183=>278,184=>333,185=>248,186=>365,187=>556,
188=>869,189=>869,190=>869,191=>611,192=>722,193=>722,194=>722,195=>722,196=>722,197=>722,
198=>1000,199=>722,200=>667,201=>667,202=>667,203=>667,204=>278,205=>278,206=>278,207=>278,
208=>722,209=>722,210=>778,211=>778,212=>778,213=>778,214=>778,215=>584,216=>778,217=>722,
218=>722,219=>722,220=>722,221=>667,222=>667,223=>611,224=>556,225=>556,226=>556,227=>556,
228=>556,229=>556,230=>889,231=>556,232=>556,233=>556,234=>556,235=>556,236=>278,237=>278,
238=>278,239=>278,240=>611,241=>611,242=>611,243=>611,244=>611,245=>611,246=>611,247=>584,
248=>611,249=>611,250=>611,251=>611,252=>611,253=>556,254=>611,255=>556,256=>722,257=>556,
258=>722,259=>556,260=>722,261=>556,262=>722,263=>556,264=>722,265=>556,266=>722,267=>556,
268=>722,269=>556,270=>722,271=>722,272=>722,273=>611,274=>667,275=>556,276=>667,277=>556,
278=>667,279=>556,280=>667,281=>556,282=>667,283=>556,284=>778,285=>611,286=>778,287=>611,
288=>778,289=>611,290=>778,291=>611,292=>722,293=>611,294=>722,295=>611,296=>278,297=>278,
298=>278,299=>278,300=>278,301=>278,302=>278,303=>268,304=>278,305=>278,306=>796,307=>487,
308=>556,309=>278,310=>722,311=>556,312=>529,313=>611,314=>278,315=>611,316=>278,317=>611,
318=>384,319=>611,320=>556,321=>611,322=>278,323=>722,324=>611,325=>722,326=>611,327=>722,
328=>611,329=>611,330=>722,331=>611,332=>778,333=>611,334=>778,335=>611,336=>778,337=>611,
340=>722,341=>389,342=>722,343=>389,344=>722,345=>389,346=>667,347=>556,348=>667,349=>556,
350=>667,351=>556,354=>611,355=>333,356=>611,357=>404,358=>611,359=>404,360=>722,361=>611,
362=>722,363=>611,364=>722,365=>611,366=>722,367=>611,368=>722,369=>611,370=>722,371=>611,
372=>944,373=>778,374=>667,375=>556,377=>611,378=>500,379=>611,380=>500,383=>333,384=>611,
385=>963,386=>722,387=>611,388=>687,389=>611,390=>722,391=>752,392=>562,393=>722,394=>968,
395=>722,396=>611,397=>609,398=>667,399=>778,400=>672,401=>611,403=>778,404=>667,405=>889,
406=>278,407=>395,408=>778,409=>556,410=>333,411=>620,412=>889,413=>722,414=>611,415=>778,
416=>778,417=>611,418=>1111,419=>722,420=>914,421=>611,422=>647,423=>667,424=>556,425=>688,
426=>441,427=>333,428=>742,429=>333,430=>611,431=>722,432=>611,433=>780,434=>722,435=>667,
436=>706,437=>611,438=>500,439=>556,440=>556,441=>645,442=>569,443=>579,446=>611,447=>608,
448=>260,449=>370,450=>584,451=>278,452=>1333,453=>1222,454=>1111,455=>1167,456=>889,457=>556,
458=>1278,459=>1000,460=>889,461=>722,462=>556,463=>278,464=>278,465=>778,466=>611,467=>722,
468=>611,469=>722,470=>611,471=>722,472=>611,473=>722,474=>611,475=>722,476=>611,477=>556,
478=>722,479=>556,480=>722,481=>556,482=>1000,483=>889,484=>811,485=>641,486=>778,487=>611,
488=>722,489=>556,490=>778,491=>611,492=>778,493=>611,494=>556,495=>556,496=>278,497=>1333,
498=>1222,499=>1111,500=>778,501=>611,503=>630,504=>722,505=>611,506=>722,507=>556,508=>1000,
509=>889,510=>778,511=>611,512=>722,513=>556,514=>722,515=>556,516=>667,517=>556,518=>667,
519=>556,520=>278,521=>278,522=>278,523=>278,524=>778,525=>611,526=>778,527=>611,528=>722,
529=>389,530=>722,531=>389,532=>722,533=>611,534=>722,535=>611,536=>667,537=>556,538=>611,
539=>333,540=>569,541=>486,542=>722,543=>611,548=>645,549=>500,550=>722,551=>556,552=>667,
553=>556,554=>778,555=>611,556=>778,557=>611,558=>778,559=>611,560=>778,561=>611,562=>667,
563=>556,567=>278,592=>556,593=>611,594=>611,595=>611,596=>556,597=>600,598=>611,599=>611,
600=>556,601=>556,602=>834,603=>570,604=>546,605=>820,606=>570,607=>278,608=>611,609=>611,
610=>556,611=>556,612=>656,613=>619,614=>611,615=>611,616=>278,617=>344,618=>278,619=>473,
620=>527,621=>298,622=>778,623=>889,624=>889,625=>889,626=>611,627=>611,628=>615,629=>590,
630=>878,631=>822,632=>778,633=>389,634=>389,635=>389,636=>389,637=>389,638=>455,639=>455,
640=>620,641=>586,642=>556,643=>333,644=>278,645=>333,646=>544,647=>328,648=>333,649=>623,
650=>726,651=>639,652=>556,653=>778,654=>556,655=>556,656=>500,657=>571,658=>556,659=>642,
660=>611,661=>611,662=>611,664=>611,665=>572,666=>570,667=>616,668=>603,669=>552,670=>556,
671=>454,672=>611,673=>611,674=>611,684=>520,688=>500,689=>500,690=>167,691=>333,692=>333,
693=>333,694=>348,695=>500,696=>345,697=>278,698=>454,699=>278,700=>333,701=>278,702=>333,
703=>333,704=>333,705=>333,706=>333,707=>333,708=>333,709=>333,711=>333,712=>333,713=>333,
714=>333,715=>333,716=>272,717=>333,718=>333,719=>333,720=>333,721=>333,722=>333,723=>333,
724=>333,725=>333,726=>333,727=>333,728=>333,729=>333,730=>333,731=>333,733=>333,734=>333,
735=>510,736=>333,737=>333,738=>333,739=>357,740=>334,741=>526,742=>526,743=>526,744=>526,
745=>526,746=>519,747=>519,748=>333,749=>333,750=>333,751=>333,752=>333,753=>333,754=>333,
755=>333,756=>333,757=>437,758=>437,759=>400,760=>333,761=>200,762=>200,763=>200,764=>200,
765=>332,766=>333,767=>333,768=>0,769=>0,770=>0,771=>0,772=>0,773=>0,774=>0,
775=>0,776=>0,777=>0,778=>0,779=>0,780=>0,781=>0,782=>0,783=>0,784=>0,
785=>0,786=>0,787=>0,788=>0,789=>0,790=>0,791=>0,792=>0,793=>0,794=>0,
795=>0,796=>0,797=>0,798=>0,799=>0,800=>0,801=>0,802=>0,803=>0,804=>0,
805=>0,806=>0,807=>0,808=>0,809=>0,810=>0,811=>0,812=>0,813=>0,814=>0,
815=>0,816=>0,817=>0,818=>0,819=>0,820=>0,821=>0,822=>0,823=>0,824=>0,
825=>0,826=>0,827=>0,828=>0,829=>0,830=>0,831=>0,832=>0,833=>0,834=>0,
835=>0,836=>0,837=>0,838=>0,839=>0,840=>0,841=>0,842=>0,843=>0,844=>0,
845=>0,846=>0,847=>0,848=>0,849=>0,850=>0,851=>0,852=>0,853=>0,854=>0,
855=>0,856=>0,857=>0,858=>0,859=>0,860=>0,861=>0,862=>0,863=>0,864=>0,
865=>0,866=>0,867=>0,868=>0,869=>0,870=>0,871=>0,872=>0,873=>0,874=>0,
875=>0,876=>0,877=>0,878=>0,879=>0,884=>208,885=>247,890=>364,894=>333,900=>239,
901=>446,902=>688,903=>333,904=>903,905=>962,906=>448,908=>904,910=>991,911=>932,912=>346,
913=>764,914=>688,915=>642,916=>744,917=>710,918=>688,919=>743,920=>810,921=>296,922=>744,
923=>744,924=>860,925=>714,926=>690,927=>822,928=>781,929=>698,931=>688,932=>688,933=>744,
934=>777,935=>783,936=>805,937=>780,938=>296,939=>744,940=>640,941=>530,942=>597,943=>339,
944=>575,945=>656,946=>576,947=>591,948=>620,949=>570,950=>522,951=>586,952=>586,953=>346,
954=>576,955=>620,956=>667,957=>564,958=>530,959=>610,960=>721,961=>626,962=>595,963=>676,
964=>592,965=>575,966=>801,967=>632,968=>722,969=>800,970=>346,971=>575,972=>609,973=>604,
974=>769,977=>580,978=>742,979=>857,980=>620,981=>778,982=>740,983=>601,1008=>556,1009=>566,
1012=>778,1013=>328,1024=>667,1025=>667,1026=>790,1027=>617,1028=>731,1029=>667,1030=>278,1031=>278,
1032=>556,1033=>1110,1034=>1088,1035=>790,1036=>722,1037=>757,1038=>698,1039=>722,1040=>722,1041=>722,
1042=>722,1043=>617,1044=>876,1045=>667,1046=>1100,1047=>670,1048=>757,1049=>757,1050=>722,1051=>715,
1052=>874,1053=>753,1054=>778,1055=>753,1056=>680,1057=>722,1058=>611,1059=>698,1060=>909,1061=>657,
1062=>845,1063=>688,1064=>1132,1065=>1217,1066=>835,1067=>980,1068=>678,1069=>735,1070=>1142,1071=>708,
1072=>553,1073=>591,1074=>574,1075=>429,1076=>745,1077=>572,1078=>792,1079=>554,1080=>603,1081=>603,
1082=>559,1083=>583,1084=>664,1085=>603,1086=>588,1087=>603,1088=>605,1089=>549,1090=>440,1091=>541,
1092=>948,1093=>539,1094=>690,1095=>564,1096=>901,1097=>987,1098=>692,1099=>806,1100=>572,1101=>546,
1102=>893,1103=>586,1104=>572,1105=>572,1106=>616,1107=>429,1108=>549,1109=>562,1110=>281,1111=>281,
1112=>282,1113=>888,1114=>897,1115=>606,1116=>559,1117=>603,1118=>541,1119=>603,1136=>830,1137=>761,
1138=>778,1139=>590,1154=>456,1155=>0,1156=>0,1157=>0,1158=>0,1159=>0,1160=>0,1161=>0,
1162=>791,1163=>662,1164=>639,1165=>581,1166=>670,1167=>649,1168=>623,1169=>450,1170=>623,1171=>472,
1172=>674,1173=>528,1174=>1091,1175=>803,1176=>659,1177=>548,1178=>739,1179=>569,1180=>742,1181=>560,
1182=>737,1183=>559,1184=>900,1185=>679,1186=>808,1187=>673,1188=>1004,1189=>761,1190=>1114,1191=>876,
1192=>721,1193=>548,1194=>724,1195=>554,1196=>611,1197=>454,1198=>667,1199=>584,1200=>652,1201=>632,
1202=>667,1203=>550,1204=>951,1205=>748,1206=>759,1207=>630,1208=>669,1209=>580,1210=>672,1211=>576,
1212=>977,1213=>752,1214=>957,1215=>752,1216=>318,1217=>1087,1218=>792,1219=>726,1220=>530,1221=>782,
1222=>674,1223=>749,1224=>603,1225=>823,1226=>682,1227=>675,1228=>573,1229=>941,1230=>754,1231=>310,
1232=>704,1233=>553,1234=>711,1235=>553,1236=>1000,1237=>889,1238=>667,1239=>569,1240=>738,1241=>561,
1242=>738,1243=>561,1244=>1086,1245=>792,1246=>670,1247=>554,1248=>558,1249=>546,1250=>753,1251=>603,
1252=>753,1253=>603,1254=>778,1255=>588,1256=>778,1257=>590,1258=>778,1259=>590,1260=>735,1261=>546,
1262=>698,1263=>541,1264=>698,1265=>541,1266=>698,1267=>541,1268=>686,1269=>564,1270=>617,1271=>475,
1272=>976,1273=>806,1296=>672,1297=>546,1298=>729,1299=>577,1306=>778,1307=>611,1308=>944,1309=>776,
1310=>750,1311=>573,1329=>730,1330=>713,1331=>765,1332=>752,1333=>708,1334=>801,1335=>496,1336=>713,
1337=>855,1338=>686,1339=>727,1340=>420,1341=>897,1342=>841,1343=>708,1344=>660,1345=>666,1346=>747,
1347=>698,1348=>757,1349=>630,1350=>747,1351=>651,1352=>743,1353=>657,1354=>728,1355=>799,1356=>752,
1357=>743,1358=>768,1359=>691,1360=>713,1361=>640,1362=>425,1363=>818,1364=>672,1365=>805,1366=>754,
1369=>333,1370=>222,1371=>250,1372=>333,1373=>333,1374=>352,1375=>362,1377=>873,1378=>613,1379=>634,
1380=>636,1381=>593,1382=>639,1383=>417,1384=>613,1385=>658,1386=>711,1387=>609,1388=>318,1389=>836,
1390=>670,1391=>613,1392=>607,1393=>611,1394=>626,1395=>619,1396=>618,1397=>324,1398=>613,1399=>540,
1400=>591,1401=>392,1402=>873,1403=>577,1404=>603,1405=>600,1406=>626,1407=>951,1408=>613,1409=>612,
1410=>348,1411=>951,1412=>616,1413=>606,1414=>763,1415=>626,1417=>333,1418=>398,1456=>0,1457=>0,
1458=>0,1459=>0,1460=>0,1461=>0,1462=>0,1463=>0,1464=>0,1465=>0,1467=>0,1468=>0,
1469=>0,1470=>516,1471=>0,1472=>297,1473=>0,1474=>0,1475=>333,1476=>0,1488=>714,1489=>651,
1490=>557,1491=>638,1492=>682,1493=>297,1494=>443,1495=>682,1496=>670,1497=>284,1498=>590,1499=>595,
1500=>667,1501=>683,1502=>704,1503=>297,1504=>429,1505=>670,1506=>653,1507=>661,1508=>660,1509=>616,
1510=>671,1511=>672,1512=>600,1513=>840,1514=>756,1520=>554,1521=>550,1522=>542,1523=>238,1524=>474,
4256=>616,4257=>645,4258=>664,4259=>839,4260=>627,4261=>630,4262=>827,4263=>928,4264=>639,4265=>630,
4266=>951,4267=>606,4268=>608,4269=>835,4270=>630,4271=>610,4272=>804,4273=>615,4274=>823,4275=>747,
4276=>870,4277=>627,4278=>840,4279=>627,4280=>665,4281=>610,4282=>799,4283=>598,4284=>665,4285=>664,
4286=>608,4287=>886,4288=>629,4304=>463,4305=>516,4306=>564,4307=>706,4308=>459,4309=>476,4310=>623,
4311=>711,4312=>494,4313=>476,4314=>894,4315=>500,4316=>500,4317=>712,4318=>493,4319=>503,4320=>712,
4321=>503,4322=>710,4323=>670,4324=>707,4325=>459,4326=>691,4327=>465,4328=>492,4329=>480,4330=>656,
4331=>500,4332=>492,4333=>524,4334=>500,4335=>688,4336=>510,4337=>739,4338=>450,4339=>479,4340=>502,
4341=>501,4345=>564,4347=>515,7680=>722,7681=>556,7682=>722,7683=>611,7684=>722,7685=>611,7686=>722,
7687=>611,7688=>722,7689=>556,7690=>722,7691=>611,7692=>722,7693=>611,7694=>722,7695=>611,7696=>722,
7697=>611,7698=>722,7699=>611,7700=>667,7701=>556,7702=>667,7703=>556,7704=>667,7705=>556,7706=>667,
7707=>556,7708=>667,7709=>556,7710=>611,7711=>333,7712=>778,7713=>611,7714=>722,7715=>611,7716=>722,
7717=>611,7718=>722,7719=>611,7720=>722,7721=>611,7722=>722,7723=>611,7724=>278,7725=>278,7726=>278,
7727=>278,7728=>722,7729=>556,7730=>722,7731=>556,7732=>722,7733=>556,7734=>611,7735=>278,7736=>611,
7737=>278,7738=>611,7739=>278,7740=>611,7741=>278,7742=>833,7743=>889,7744=>833,7745=>889,7746=>833,
7747=>889,7748=>722,7749=>611,7750=>722,7751=>611,7752=>722,7753=>611,7754=>722,7755=>611,7756=>778,
7757=>611,7758=>778,7759=>611,7760=>778,7761=>611,7762=>778,7763=>611,7764=>667,7765=>611,7766=>667,
7767=>611,7768=>722,7769=>389,7770=>722,7771=>389,7772=>722,7773=>389,7774=>722,7775=>389,7776=>667,
7777=>556,7778=>667,7779=>556,7780=>667,7781=>556,7782=>667,7783=>556,7784=>667,7785=>556,7786=>611,
7787=>333,7788=>611,7789=>333,7790=>611,7791=>333,7792=>611,7793=>333,7794=>722,7795=>611,7796=>722,
7797=>611,7798=>722,7799=>611,7800=>722,7801=>611,7802=>722,7803=>611,7804=>667,7805=>556,7806=>667,
7807=>556,7808=>944,7809=>778,7810=>944,7811=>778,7812=>944,7813=>778,7814=>944,7815=>778,7816=>944,
7817=>778,7818=>667,7819=>556,7820=>667,7821=>556,7822=>667,7823=>556,7824=>611,7825=>500,7826=>611,
7827=>500,7828=>611,7829=>500,7830=>611,7831=>333,7832=>778,7833=>556,7834=>555,7835=>333,7840=>722,
7841=>556,7842=>722,7843=>556,7844=>722,7845=>556,7846=>722,7847=>556,7848=>722,7849=>556,7850=>722,
7851=>556,7852=>722,7853=>556,7854=>722,7855=>556,7856=>722,7857=>556,7858=>722,7859=>556,7860=>722,
7861=>556,7862=>722,7863=>556,7864=>667,7865=>556,7866=>667,7867=>556,7868=>667,7869=>556,7870=>667,
7871=>556,7872=>667,7873=>556,7874=>667,7875=>556,7876=>667,7877=>556,7878=>667,7879=>556,7880=>278,
7881=>278,7882=>278,7883=>278,7884=>778,7885=>611,7886=>778,7887=>611,7888=>778,7889=>611,7890=>778,
7891=>611,7892=>778,7893=>611,7894=>778,7895=>611,7896=>778,7897=>611,7898=>778,7899=>611,7900=>778,
7901=>611,7902=>778,7903=>611,7904=>778,7905=>611,7906=>778,7907=>611,7908=>722,7909=>611,7910=>722,
7911=>611,7912=>722,7913=>611,7914=>722,7915=>611,7916=>722,7917=>611,7918=>722,7919=>611,7920=>722,
7921=>611,7922=>667,7923=>556,7924=>667,7925=>556,7926=>667,7927=>556,7928=>667,7929=>556,7936=>656,
7937=>656,7938=>656,7939=>656,7940=>656,7941=>656,7942=>656,7943=>656,7944=>764,7945=>764,7946=>916,
7947=>940,7948=>908,7949=>891,7950=>844,7951=>869,7952=>570,7953=>570,7954=>570,7955=>570,7956=>570,
7957=>570,7960=>842,7961=>836,7962=>1025,7963=>1051,7964=>1035,7965=>1049,7968=>586,7969=>586,7970=>586,
7971=>586,7972=>586,7973=>586,7974=>586,7975=>586,7976=>891,7977=>886,7978=>1081,7979=>1108,7980=>1085,
7981=>1096,7982=>1009,7983=>1023,7984=>346,7985=>346,7986=>346,7987=>346,7988=>346,7989=>346,7990=>346,
7991=>346,7992=>467,7993=>476,7994=>631,7995=>661,7996=>631,7997=>633,7998=>568,7999=>571,8000=>610,
8001=>610,8002=>610,8003=>610,8004=>610,8005=>610,8008=>945,8009=>905,8010=>1118,8011=>1121,8012=>1064,
8013=>1062,8016=>575,8017=>575,8018=>575,8019=>575,8020=>575,8021=>575,8022=>575,8023=>575,8025=>964,
8027=>1148,8029=>1162,8031=>1081,8032=>800,8033=>800,8034=>800,8035=>800,8036=>800,8037=>800,8038=>800,
8039=>800,8040=>904,8041=>875,8042=>1092,8043=>1087,8044=>1003,8045=>1002,8046=>1001,8047=>1025,8048=>656,
8049=>656,8050=>570,8051=>570,8052=>586,8053=>586,8054=>346,8055=>346,8056=>610,8057=>610,8058=>575,
8059=>575,8060=>800,8061=>800,8064=>656,8065=>656,8066=>656,8067=>656,8068=>656,8069=>656,8070=>656,
8071=>656,8072=>854,8073=>855,8074=>1006,8075=>1030,8076=>996,8077=>977,8078=>938,8079=>959,8080=>586,
8081=>586,8082=>586,8083=>586,8084=>586,8085=>586,8086=>586,8087=>586,8088=>960,8089=>960,8090=>1155,
8091=>1186,8092=>1161,8093=>1171,8094=>1087,8095=>1102,8096=>800,8097=>800,8098=>800,8099=>800,8100=>800,
8101=>800,8102=>800,8103=>800,8104=>1005,8105=>980,8106=>1201,8107=>1192,8108=>1109,8109=>1108,8110=>1106,
8111=>1130,8112=>656,8113=>656,8114=>656,8115=>656,8116=>640,8118=>656,8119=>656,8120=>764,8121=>764,
8122=>764,8123=>764,8124=>854,8125=>278,8126=>201,8127=>147,8128=>278,8129=>333,8130=>586,8131=>586,
8132=>597,8134=>586,8135=>586,8136=>911,8137=>925,8138=>941,8139=>948,8140=>826,8141=>402,8142=>403,
8143=>147,8144=>346,8145=>346,8146=>346,8147=>346,8150=>346,8151=>346,8152=>296,8153=>296,8154=>511,
8155=>521,8157=>434,8158=>433,8159=>333,8160=>575,8161=>575,8162=>575,8163=>575,8164=>626,8165=>626,
8166=>575,8167=>575,8168=>744,8169=>744,8170=>901,8171=>975,8172=>837,8173=>353,8174=>351,8175=>303,
8178=>800,8179=>800,8180=>800,8182=>800,8183=>800,8184=>979,8185=>918,8186=>936,8187=>877,8188=>895,
8189=>333,8190=>159,8192=>500,8193=>1000,8194=>500,8195=>1000,8196=>333,8197=>250,8198=>167,8199=>556,
8200=>278,8201=>200,8202=>100,8203=>0,8204=>0,8205=>0,8206=>0,8207=>0,8208=>333,8209=>333,
8210=>556,8213=>1000,8214=>437,8215=>556,8219=>278,8223=>503,8227=>350,8228=>278,8229=>666,8231=>278,
8232=>0,8233=>0,8234=>0,8235=>0,8236=>0,8237=>0,8238=>0,8239=>500,8241=>1372,8242=>238,
8243=>426,8244=>614,8245=>238,8246=>379,8247=>571,8248=>450,8251=>622,8252=>666,8253=>617,8254=>556,
8255=>658,8256=>658,8257=>438,8258=>840,8259=>400,8260=>167,8261=>334,8262=>334,8263=>1222,8264=>944,
8265=>944,8266=>556,8267=>556,8268=>537,8269=>537,8270=>389,8271=>333,8272=>658,8273=>389,8274=>634,
8275=>568,8276=>658,8277=>793,8278=>515,8279=>855,8280=>722,8281=>725,8282=>224,8283=>722,8284=>604,
8285=>224,8286=>224,8287=>0,8288=>0,8289=>0,8290=>0,8291=>0,8292=>0,8304=>351,8305=>351,
8308=>351,8309=>351,8310=>351,8311=>351,8312=>351,8313=>351,8314=>351,8315=>351,8316=>351,8317=>351,
8318=>351,8319=>351,8320=>351,8321=>251,8322=>351,8323=>351,8324=>351,8325=>351,8326=>351,8327=>351,
8328=>351,8329=>351,8330=>350,8331=>350,8332=>350,8333=>350,8334=>350,8355=>611,8356=>576,8357=>833,
8358=>724,8360=>1286,8362=>1049,8363=>571,8368=>594,8373=>591,8448=>985,8449=>1007,8451=>1020,8453=>981,
8454=>1042,8455=>667,8457=>930,8465=>606,8468=>883,8470=>1006,8471=>784,8476=>699,8480=>1000,8481=>1230,
8486=>780,8487=>780,8489=>286,8490=>722,8491=>722,8494=>556,8498=>626,8501=>714,8502=>651,8503=>557,
8504=>638,8506=>906,8507=>1155,8513=>778,8514=>611,8515=>611,8516=>667,8523=>710,8525=>1072,8526=>500,
8531=>869,8532=>869,8533=>869,8534=>869,8535=>869,8536=>869,8537=>869,8538=>869,8539=>869,8540=>869,
8541=>869,8542=>869,8543=>869,8544=>278,8545=>556,8546=>834,8547=>945,8548=>667,8549=>945,8550=>1223,
8551=>1501,8552=>945,8553=>667,8554=>945,8555=>1223,8556=>611,8557=>722,8558=>722,8559=>833,8560=>278,
8561=>556,8562=>834,8563=>834,8564=>556,8565=>834,8566=>1112,8567=>1390,8568=>834,8569=>556,8570=>834,
8571=>1112,8572=>278,8573=>556,8574=>611,8575=>889,8592=>964,8593=>964,8594=>964,8595=>964,8596=>964,
8597=>964,8598=>964,8599=>964,8600=>964,8601=>964,8602=>964,8603=>964,8606=>964,8607=>964,8608=>964,
8609=>964,8610=>964,8611=>964,8612=>964,8613=>964,8614=>964,8615=>964,8616=>964,8644=>964,8645=>964,
8646=>964,8647=>964,8648=>964,8649=>964,8650=>964,8706=>608,8710=>729,8721=>856,8722=>584,8723=>584,
8725=>1107,8730=>597,8800=>584,8804=>584,8805=>584,9251=>500,9674=>489,9824=>626,9825=>694,9826=>595,
9827=>776,9828=>626,9829=>694,9830=>595,9831=>776,9833=>333,9834=>556,9835=>778,9836=>778,9837=>556,
9838=>556,9839=>556,11799=>333,64256=>607,64257=>576,64258=>603,64259=>849,64260=>849,64275=>1243,64276=>1226,
64277=>1233,64278=>1238,64279=>1448,64285=>284,64286=>305,64287=>542,64288=>653,64289=>964,64290=>888,64291=>932,
64292=>845,64293=>917,64294=>933,64295=>850,64296=>1006,64297=>584,64298=>840,64299=>840,64300=>840,64301=>840,
64302=>714,64303=>714,64304=>714,64305=>651,64306=>557,64307=>638,64308=>682,64309=>348,64310=>443,64312=>670,
64313=>354,64314=>590,64315=>595,64316=>667,64318=>704,64320=>429,64321=>670,64323=>661,64324=>660,64326=>671,
64327=>672,64328=>600,64329=>840,64330=>756,64331=>212,64332=>591,64333=>550,64334=>568,64335=>714,65533=>788);
$enc='';
$diff='';
$file='freesansbi.z';
$ctg='freesansbi.ctg.z';
$originalsize=269952;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/freesansbi.php | PHP | asf20 | 20,602 |
<?php
$type='TrueTypeUnicode';
$name='FreeSerifItalic';
$desc=array('Ascent'=>900,'Descent'=>-300,'CapHeight'=>-29,'Flags'=>96,'FontBBox'=>'[-879 -434 1673 900]','ItalicAngle'=>-16.5,'StemV'=>70,'MissingWidth'=>600);
$up=-125;
$ut=50;
$dw=600;
$cw=array(
32=>250,33=>333,34=>420,35=>500,36=>500,37=>833,38=>778,39=>214,40=>333,41=>333,
42=>500,43=>675,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,50=>500,51=>500,
52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333,60=>675,61=>675,
62=>675,63=>500,64=>920,65=>611,66=>611,67=>667,68=>722,69=>604,70=>611,71=>722,
72=>722,73=>339,74=>444,75=>652,76=>556,77=>828,78=>657,79=>722,80=>603,81=>722,
82=>616,83=>500,84=>556,85=>722,86=>611,87=>833,88=>611,89=>556,90=>556,91=>389,
92=>278,93=>389,94=>422,95=>500,96=>333,97=>500,98=>500,99=>444,100=>500,101=>444,
102=>278,103=>500,104=>500,105=>278,106=>278,107=>444,108=>278,109=>722,110=>500,111=>500,
112=>500,113=>500,114=>389,115=>389,116=>278,117=>500,118=>444,119=>667,120=>444,121=>444,
122=>389,123=>400,124=>275,125=>400,126=>541,8364=>741,8218=>250,402=>278,8222=>444,8230=>889,
8224=>500,8225=>500,710=>333,8240=>1000,352=>500,8249=>250,338=>944,381=>556,8216=>250,8217=>250,
8220=>444,8221=>444,8226=>350,8211=>500,8212=>1000,732=>333,8482=>980,353=>389,8250=>250,339=>667,
382=>389,376=>556,160=>250,161=>389,162=>500,163=>500,164=>500,165=>500,166=>275,167=>500,
168=>333,169=>760,170=>276,171=>444,172=>675,173=>333,174=>760,175=>333,176=>400,177=>675,
178=>300,179=>300,180=>333,181=>500,182=>523,183=>250,184=>333,185=>250,186=>310,187=>444,
188=>750,189=>750,190=>750,191=>500,192=>611,193=>611,194=>611,195=>611,196=>611,197=>611,
198=>889,199=>667,200=>611,201=>611,202=>611,203=>611,204=>333,205=>333,206=>333,207=>333,
208=>722,209=>667,210=>722,211=>722,212=>722,213=>722,214=>722,215=>675,216=>722,217=>722,
218=>722,219=>722,220=>722,221=>556,222=>611,223=>500,224=>500,225=>500,226=>500,227=>500,
228=>500,229=>500,230=>667,231=>444,232=>444,233=>444,234=>444,235=>444,236=>278,237=>278,
238=>278,239=>278,240=>500,241=>500,242=>500,243=>500,244=>500,245=>500,246=>500,247=>675,
248=>500,249=>500,250=>500,251=>500,252=>500,253=>444,254=>500,255=>444,256=>611,257=>500,
258=>611,259=>500,260=>611,261=>500,262=>667,263=>444,264=>667,265=>444,266=>667,267=>444,
268=>667,269=>444,270=>722,271=>500,272=>722,273=>500,274=>611,275=>444,276=>611,277=>444,
278=>611,279=>444,280=>611,281=>444,282=>611,283=>444,284=>722,285=>500,286=>722,287=>500,
288=>722,289=>500,290=>722,291=>500,292=>722,293=>500,294=>722,295=>500,296=>333,297=>278,
298=>333,299=>278,300=>333,301=>278,302=>333,303=>278,304=>333,305=>278,306=>707,307=>553,
308=>444,309=>278,310=>667,311=>444,312=>444,313=>556,314=>278,315=>556,316=>278,317=>556,
318=>278,319=>556,320=>278,321=>556,322=>278,323=>667,324=>500,325=>667,326=>500,327=>667,
328=>500,329=>500,330=>667,331=>500,332=>722,333=>500,334=>722,335=>500,336=>722,337=>500,
340=>611,341=>389,342=>611,343=>389,344=>611,345=>389,346=>500,347=>389,348=>500,349=>389,
350=>500,351=>389,354=>556,355=>278,356=>556,357=>278,358=>556,359=>278,360=>722,361=>500,
362=>722,363=>500,364=>722,365=>500,366=>722,367=>500,368=>722,369=>500,370=>722,371=>500,
372=>833,373=>667,374=>556,375=>444,377=>556,378=>389,379=>556,380=>389,383=>278,384=>500,
385=>781,386=>610,387=>551,388=>611,389=>549,390=>667,391=>866,392=>703,393=>722,394=>892,
395=>682,396=>500,397=>520,398=>611,399=>722,400=>518,401=>611,403=>863,404=>611,405=>728,
406=>278,407=>333,408=>792,409=>444,410=>278,411=>480,412=>900,413=>779,414=>500,415=>722,
416=>932,417=>608,418=>908,419=>722,420=>772,421=>500,422=>611,423=>500,424=>389,425=>657,
426=>461,427=>313,428=>556,429=>335,430=>556,431=>948,432=>721,433=>747,434=>755,435=>636,
436=>549,437=>556,438=>389,439=>525,440=>556,441=>424,442=>416,443=>500,444=>615,445=>439,
446=>389,447=>500,448=>275,449=>500,450=>600,451=>333,452=>1278,453=>1111,454=>889,455=>1000,
456=>834,457=>556,458=>1101,459=>935,460=>778,461=>611,462=>500,463=>339,464=>278,465=>722,
466=>500,467=>722,468=>500,469=>722,470=>500,471=>722,472=>500,473=>722,474=>500,475=>722,
476=>500,477=>444,478=>611,479=>500,480=>611,481=>500,482=>889,483=>667,484=>722,485=>500,
486=>722,487=>500,488=>652,489=>444,490=>730,491=>500,492=>730,493=>500,494=>525,495=>446,
496=>278,497=>1278,498=>1111,499=>889,500=>817,501=>595,502=>944,503=>607,504=>657,505=>500,
506=>611,507=>500,508=>889,509=>667,510=>722,511=>500,512=>611,513=>500,514=>611,515=>500,
516=>604,517=>444,518=>604,519=>444,520=>339,521=>278,522=>339,523=>278,524=>722,525=>500,
526=>722,527=>500,528=>616,529=>389,530=>616,531=>389,532=>722,533=>500,534=>722,535=>500,
536=>500,537=>389,538=>556,539=>278,540=>424,541=>455,542=>722,543=>500,544=>781,545=>588,
546=>568,547=>468,548=>611,549=>444,550=>611,551=>500,552=>604,553=>444,554=>722,555=>500,
556=>722,557=>500,558=>722,559=>500,560=>722,561=>500,562=>556,563=>444,564=>405,565=>597,
566=>377,567=>278,568=>775,569=>767,570=>722,571=>667,572=>444,573=>611,574=>611,575=>389,
576=>444,577=>444,578=>444,579=>667,580=>750,581=>697,582=>611,583=>444,584=>389,585=>278,
586=>796,587=>590,588=>667,589=>333,590=>722,591=>500,592=>500,593=>564,594=>564,595=>500,
596=>444,597=>444,598=>500,599=>697,600=>444,601=>444,602=>722,603=>416,604=>426,605=>674,
606=>454,607=>278,608=>640,609=>500,610=>484,611=>500,612=>582,613=>500,614=>500,615=>500,
616=>278,617=>278,618=>278,619=>278,620=>278,621=>278,622=>556,623=>722,624=>722,625=>716,
626=>500,627=>500,628=>500,629=>500,630=>668,631=>693,632=>640,633=>389,634=>389,635=>333,
636=>389,637=>333,638=>333,639=>333,640=>487,641=>487,642=>389,643=>278,644=>500,645=>333,
646=>500,647=>278,648=>278,649=>500,650=>517,651=>500,652=>444,653=>667,654=>444,655=>510,
656=>524,657=>444,658=>446,659=>456,660=>444,661=>444,662=>444,663=>444,664=>722,665=>442,
666=>454,667=>665,668=>585,669=>347,670=>444,671=>443,672=>500,673=>444,674=>444,675=>798,
676=>795,677=>805,678=>554,679=>561,680=>678,681=>614,682=>554,683=>554,684=>500,685=>500,
686=>611,687=>611,688=>300,689=>300,690=>278,691=>278,692=>278,693=>309,694=>306,695=>432,
696=>310,697=>250,698=>408,699=>333,700=>500,701=>500,702=>333,703=>333,704=>258,705=>258,
706=>374,707=>374,708=>383,709=>383,711=>333,712=>250,713=>333,714=>333,715=>333,716=>250,
717=>333,718=>333,719=>333,720=>278,721=>278,722=>333,723=>333,724=>333,725=>333,726=>333,
727=>333,728=>333,729=>333,730=>333,731=>333,733=>333,734=>336,735=>352,736=>311,737=>200,
738=>243,739=>328,740=>300,741=>460,742=>460,743=>460,744=>460,745=>460,746=>477,747=>475,
748=>339,749=>330,750=>444,751=>383,752=>383,753=>294,754=>294,755=>327,756=>261,757=>437,
758=>437,759=>333,760=>278,761=>175,762=>175,763=>175,764=>175,765=>337,766=>337,767=>326,
768=>0,769=>0,770=>0,771=>0,772=>0,773=>0,774=>0,775=>0,776=>0,777=>0,
778=>0,779=>0,780=>0,781=>0,782=>0,783=>0,784=>0,785=>0,786=>0,787=>0,
788=>0,789=>0,790=>0,791=>0,792=>0,793=>0,794=>0,795=>0,796=>0,797=>0,
798=>0,799=>0,800=>0,801=>0,802=>0,803=>0,804=>0,805=>0,806=>0,807=>0,
808=>0,809=>0,810=>0,811=>0,812=>0,813=>0,814=>0,815=>0,816=>0,817=>0,
818=>0,819=>0,820=>0,821=>0,822=>0,823=>0,824=>0,825=>0,826=>0,827=>0,
828=>0,829=>0,830=>0,831=>0,832=>0,833=>0,834=>0,835=>0,836=>0,837=>0,
838=>0,839=>0,840=>0,841=>0,842=>0,843=>0,844=>0,845=>0,846=>0,847=>0,
848=>0,849=>0,850=>0,851=>0,852=>0,853=>0,854=>0,855=>0,856=>0,857=>0,
858=>0,859=>0,860=>0,861=>0,862=>0,863=>0,864=>0,865=>0,866=>0,867=>0,
868=>0,869=>0,870=>0,871=>0,872=>0,873=>0,874=>0,875=>0,876=>0,877=>0,
878=>0,879=>0,884=>199,885=>199,890=>332,894=>333,900=>257,901=>333,902=>661,903=>250,
904=>841,905=>950,906=>559,908=>815,910=>877,911=>899,912=>270,913=>661,914=>581,915=>611,
916=>660,917=>611,918=>606,919=>742,920=>672,921=>333,922=>667,923=>641,924=>833,925=>657,
926=>678,927=>682,928=>749,929=>611,931=>657,932=>596,933=>676,934=>722,935=>611,936=>812,
937=>743,938=>333,939=>696,940=>564,941=>416,942=>506,943=>270,944=>504,945=>564,946=>509,
947=>496,948=>520,949=>416,950=>398,951=>506,952=>533,953=>270,954=>491,955=>488,956=>501,
957=>486,958=>430,959=>510,960=>608,961=>506,962=>423,963=>524,964=>425,965=>504,966=>618,
967=>459,968=>693,969=>693,970=>270,971=>504,972=>510,973=>504,974=>693,976=>534,977=>587,
978=>620,979=>820,980=>620,981=>640,982=>684,983=>504,984=>555,985=>534,986=>548,987=>496,
988=>610,989=>470,990=>633,991=>410,992=>687,993=>544,1008=>534,1009=>534,1010=>485,1011=>278,
1012=>722,1013=>280,1014=>280,1015=>610,1016=>500,1017=>704,1018=>832,1019=>703,1020=>533,1021=>704,
1022=>704,1023=>704,1024=>604,1025=>604,1026=>668,1027=>611,1028=>666,1029=>500,1030=>339,1031=>339,
1032=>444,1033=>972,1034=>977,1035=>703,1036=>664,1037=>720,1038=>728,1039=>728,1040=>611,1041=>610,
1042=>611,1043=>611,1044=>682,1045=>604,1046=>976,1047=>592,1048=>720,1049=>720,1050=>664,1051=>719,
1052=>828,1053=>722,1054=>722,1055=>749,1056=>603,1057=>667,1058=>556,1059=>728,1060=>722,1061=>611,
1062=>728,1063=>666,1064=>997,1065=>1005,1066=>710,1067=>891,1068=>594,1069=>632,1070=>1024,1071=>696,
1072=>500,1073=>500,1074=>442,1075=>344,1076=>503,1077=>440,1078=>932,1079=>402,1080=>500,1081=>500,
1082=>491,1083=>487,1084=>624,1085=>500,1086=>500,1087=>500,1088=>500,1089=>441,1090=>722,1091=>500,
1092=>741,1093=>444,1094=>500,1095=>500,1096=>750,1097=>750,1098=>545,1099=>683,1100=>433,1101=>432,
1102=>700,1103=>503,1104=>440,1105=>440,1106=>500,1107=>344,1108=>442,1109=>389,1110=>278,1111=>278,
1112=>278,1113=>686,1114=>696,1115=>500,1116=>491,1117=>500,1118=>500,1119=>500,1120=>964,1121=>684,
1122=>708,1123=>690,1124=>975,1125=>646,1126=>800,1127=>628,1128=>1096,1129=>795,1130=>952,1131=>730,
1132=>1260,1133=>892,1134=>574,1135=>400,1136=>812,1137=>694,1138=>721,1139=>500,1140=>745,1141=>533,
1142=>745,1143=>533,1144=>1193,1145=>967,1146=>868,1147=>602,1148=>964,1149=>684,1150=>964,1151=>684,
1152=>548,1153=>443,1154=>320,1155=>0,1156=>0,1157=>0,1158=>0,1159=>0,1160=>0,1161=>0,
1162=>720,1163=>500,1164=>602,1165=>433,1166=>611,1167=>500,1168=>552,1169=>424,1170=>593,1171=>424,
1172=>611,1173=>432,1174=>992,1175=>932,1176=>592,1177=>396,1178=>681,1179=>491,1180=>700,1181=>532,
1182=>664,1183=>491,1184=>776,1185=>690,1186=>729,1187=>500,1188=>908,1189=>660,1190=>1034,1191=>694,
1192=>667,1193=>531,1194=>666,1195=>443,1196=>556,1197=>775,1198=>556,1199=>574,1200=>555,1201=>574,
1202=>660,1203=>443,1204=>798,1205=>581,1206=>674,1207=>500,1208=>690,1209=>516,1210=>640,1211=>500,
1212=>785,1213=>558,1214=>787,1215=>559,1216=>339,1217=>976,1218=>932,1219=>664,1220=>491,1221=>719,
1222=>487,1223=>722,1224=>500,1225=>722,1226=>500,1227=>666,1228=>500,1229=>828,1230=>624,1231=>339,
1232=>611,1233=>500,1234=>611,1235=>500,1236=>889,1237=>667,1238=>604,1239=>444,1240=>722,1241=>444,
1242=>722,1243=>444,1244=>976,1245=>932,1246=>592,1247=>402,1248=>525,1249=>446,1250=>720,1251=>500,
1252=>720,1253=>500,1254=>722,1255=>500,1256=>722,1257=>500,1258=>722,1259=>500,1260=>632,1261=>432,
1262=>728,1263=>500,1264=>728,1265=>500,1266=>728,1267=>500,1268=>666,1269=>500,1270=>611,1271=>424,
1272=>891,1273=>683,1296=>532,1297=>409,1298=>719,1299=>487,1306=>722,1307=>500,1308=>833,1309=>656,
1310=>664,1311=>491,1425=>0,1426=>0,1427=>0,1428=>0,1429=>0,1430=>0,1431=>418,1432=>0,
1433=>0,1434=>0,1435=>0,1436=>0,1437=>0,1438=>0,1439=>0,1440=>0,1441=>0,1442=>0,
1443=>0,1444=>0,1445=>0,1446=>0,1447=>0,1448=>0,1449=>0,1450=>0,1451=>0,1452=>0,
1453=>0,1454=>0,1455=>0,1456=>0,1457=>0,1458=>0,1459=>0,1460=>0,1461=>0,1462=>0,
1463=>0,1464=>0,1465=>0,1466=>0,1467=>0,1468=>0,1469=>0,1470=>440,1471=>0,1472=>126,
1473=>0,1474=>0,1475=>418,1476=>0,1477=>0,1478=>350,1479=>0,1488=>537,1489=>537,1490=>350,
1491=>537,1492=>537,1493=>350,1494=>350,1495=>537,1496=>537,1497=>350,1498=>537,1499=>537,1500=>537,
1501=>537,1502=>537,1503=>350,1504=>350,1505=>537,1506=>537,1507=>537,1508=>537,1509=>537,1510=>537,
1511=>537,1512=>537,1513=>537,1514=>537,1520=>537,1521=>537,1522=>537,1523=>396,1524=>396,2404=>318,
2405=>446,2433=>0,2434=>300,2435=>312,2437=>594,2438=>776,2439=>469,2440=>513,2441=>535,2442=>561,
2443=>604,2444=>481,2447=>580,2448=>604,2451=>540,2452=>620,2453=>570,2454=>485,2455=>484,2456=>471,
2457=>457,2458=>408,2459=>452,2460=>591,2461=>551,2462=>771,2463=>414,2464=>404,2465=>522,2466=>415,
2467=>450,2468=>551,2469=>477,2470=>478,2471=>449,2472=>448,2474=>535,2475=>611,2476=>443,2477=>534,
2478=>492,2479=>474,2480=>442,2482=>542,2486=>507,2487=>467,2488=>523,2489=>419,2492=>0,2493=>419,
2494=>202,2495=>189,2496=>202,2497=>0,2498=>0,2499=>0,2500=>0,2503=>294,2504=>289,2507=>774,
2508=>825,2509=>0,2510=>356,2519=>219,2524=>523,2525=>420,2527=>469,2528=>604,2529=>481,2530=>0,
2531=>0,2534=>500,2535=>437,2536=>479,2537=>507,2538=>497,2539=>500,2540=>482,2541=>503,2542=>517,
2543=>481,2544=>443,2545=>443,2546=>429,2547=>383,2548=>432,2549=>478,2550=>539,2551=>158,2552=>365,
2553=>280,2554=>357,3585=>512,3586=>453,3587=>512,3588=>519,3589=>529,3590=>561,3591=>411,3592=>437,
3593=>552,3594=>452,3595=>509,3596=>707,3597=>707,3598=>574,3599=>570,3600=>406,3601=>607,3602=>686,
3603=>749,3604=>494,3605=>497,3606=>509,3607=>552,3608=>461,3609=>565,3610=>527,3611=>523,3612=>556,
3613=>551,3614=>570,3615=>570,3616=>571,3617=>531,3618=>493,3619=>433,3620=>513,3621=>491,3622=>571,
3623=>439,3624=>510,3625=>594,3626=>484,3627=>554,3628=>616,3629=>493,3630=>496,3631=>417,3632=>392,
3633=>0,3634=>366,3635=>366,3636=>0,3637=>0,3638=>0,3639=>0,3640=>0,3641=>0,3642=>0,
3647=>662,3648=>297,3649=>544,3650=>298,3651=>329,3652=>328,3653=>326,3654=>488,3655=>0,3656=>0,
3657=>0,3658=>0,3659=>0,3660=>0,3661=>0,3662=>0,3663=>725,3664=>624,3665=>624,3666=>624,
3667=>624,3668=>624,3669=>624,3670=>624,3671=>624,3672=>624,3673=>624,3674=>645,3675=>872,4256=>453,
4257=>448,4258=>546,4259=>619,4260=>478,4261=>481,4262=>459,4263=>707,4264=>467,4265=>471,4266=>842,
4267=>464,4268=>443,4269=>707,4270=>460,4271=>465,4272=>686,4273=>440,4274=>550,4275=>561,4276=>580,
4277=>467,4278=>630,4279=>466,4280=>517,4281=>456,4282=>502,4283=>464,4284=>534,4285=>440,4286=>443,
4287=>522,4288=>460,4289=>463,4290=>536,4291=>455,4292=>468,4293=>449,4304=>454,4305=>452,4306=>544,
4307=>629,4308=>451,4309=>452,4310=>452,4311=>702,4312=>451,4313=>452,4314=>820,4315=>451,4316=>453,
4317=>695,4318=>449,4319=>448,4320=>694,4321=>501,4322=>544,4323=>517,4324=>560,4325=>450,4326=>627,
4327=>452,4328=>491,4329=>452,4330=>485,4331=>452,4332=>485,4333=>443,4334=>500,4335=>582,4336=>455,
4337=>451,4338=>480,4339=>414,4340=>453,4341=>418,4345=>544,4347=>410,5024=>711,5025=>678,5026=>604,
5027=>667,5028=>796,5029=>301,5030=>516,5031=>544,5032=>457,5033=>716,5034=>703,5035=>383,5036=>628,
5037=>709,5038=>455,5039=>601,5040=>472,5041=>574,5042=>730,5043=>939,5044=>498,5045=>528,5046=>667,
5047=>891,5048=>505,5049=>792,5050=>957,5051=>725,5052=>595,5053=>733,5054=>698,5055=>638,5056=>720,
5057=>732,5058=>624,5059=>638,5060=>565,5061=>903,5062=>655,5063=>681,5064=>675,5065=>949,5066=>683,
5067=>547,5068=>693,5069=>732,5070=>529,5071=>569,5072=>536,5073=>677,5074=>631,5075=>382,5076=>973,
5077=>543,5078=>607,5079=>652,5080=>652,5081=>693,5082=>514,5083=>803,5084=>658,5085=>597,5086=>627,
5087=>659,5088=>679,5089=>706,5090=>563,5091=>618,5092=>767,5093=>776,5094=>731,5095=>492,5096=>808,
5097=>823,5098=>796,5099=>689,5100=>716,5101=>518,5102=>521,5103=>719,5104=>563,5105=>776,5106=>634,
5107=>822,5108=>621,7680=>611,7681=>500,7682=>611,7683=>500,7684=>611,7685=>500,7686=>611,7687=>500,
7688=>667,7689=>444,7690=>722,7691=>500,7692=>722,7693=>500,7694=>722,7695=>500,7696=>722,7697=>500,
7698=>722,7699=>500,7700=>611,7701=>444,7702=>611,7703=>444,7704=>604,7705=>444,7706=>604,7707=>444,
7708=>604,7709=>444,7710=>611,7711=>278,7712=>722,7713=>500,7714=>722,7715=>500,7716=>722,7717=>500,
7718=>722,7719=>500,7720=>722,7721=>500,7722=>722,7723=>500,7724=>339,7725=>278,7726=>333,7727=>278,
7728=>652,7729=>444,7730=>652,7731=>444,7732=>652,7733=>444,7734=>556,7735=>278,7736=>556,7737=>278,
7738=>556,7739=>278,7740=>556,7741=>278,7742=>828,7743=>722,7744=>828,7745=>722,7746=>828,7747=>722,
7748=>657,7749=>500,7750=>657,7751=>500,7752=>657,7753=>500,7754=>657,7755=>500,7756=>722,7757=>500,
7758=>722,7759=>500,7760=>722,7761=>500,7762=>722,7763=>500,7764=>603,7765=>500,7766=>603,7767=>500,
7768=>616,7769=>389,7770=>616,7771=>389,7772=>616,7773=>389,7774=>616,7775=>389,7776=>500,7777=>389,
7778=>500,7779=>389,7780=>500,7781=>389,7782=>500,7783=>389,7784=>500,7785=>389,7786=>556,7787=>278,
7788=>556,7789=>278,7790=>556,7791=>278,7792=>556,7793=>278,7794=>722,7795=>500,7796=>722,7797=>500,
7798=>722,7799=>500,7800=>722,7801=>500,7802=>722,7803=>500,7804=>611,7805=>444,7806=>611,7807=>444,
7808=>833,7809=>667,7810=>833,7811=>667,7812=>833,7813=>667,7814=>833,7815=>667,7816=>833,7817=>667,
7818=>611,7819=>444,7820=>611,7821=>444,7822=>556,7823=>444,7824=>556,7825=>389,7826=>556,7827=>389,
7828=>556,7829=>389,7830=>500,7831=>278,7832=>667,7833=>444,7834=>444,7835=>278,7840=>611,7841=>500,
7842=>611,7843=>500,7844=>611,7845=>500,7846=>611,7847=>500,7848=>611,7849=>500,7850=>611,7851=>500,
7852=>611,7853=>500,7854=>611,7855=>500,7856=>611,7857=>500,7858=>611,7859=>500,7860=>611,7861=>500,
7862=>611,7863=>500,7864=>604,7865=>444,7866=>604,7867=>444,7868=>604,7869=>444,7870=>611,7871=>444,
7872=>611,7873=>444,7874=>611,7875=>444,7876=>611,7877=>444,7878=>604,7879=>444,7880=>339,7881=>278,
7882=>339,7883=>278,7884=>722,7885=>500,7886=>722,7887=>500,7888=>722,7889=>500,7890=>722,7891=>500,
7892=>722,7893=>500,7894=>722,7895=>500,7896=>722,7897=>500,7898=>932,7899=>608,7900=>932,7901=>608,
7902=>807,7903=>585,7904=>932,7905=>608,7906=>932,7907=>608,7908=>722,7909=>500,7910=>722,7911=>500,
7912=>948,7913=>721,7914=>948,7915=>721,7916=>807,7917=>585,7918=>948,7919=>721,7920=>948,7921=>721,
7922=>556,7923=>444,7924=>556,7925=>444,7926=>556,7927=>444,7928=>556,7929=>444,7936=>564,7937=>564,
7938=>564,7939=>564,7940=>564,7941=>564,7942=>564,7943=>564,7944=>661,7945=>661,7946=>794,7947=>811,
7948=>792,7949=>803,7950=>661,7951=>648,7952=>416,7953=>416,7954=>416,7955=>416,7956=>416,7957=>416,
7960=>740,7961=>795,7962=>923,7963=>940,7964=>996,7965=>986,7968=>506,7969=>506,7970=>506,7971=>506,
7972=>506,7973=>506,7974=>506,7975=>506,7976=>879,7977=>901,7978=>1036,7979=>1035,7980=>1099,7981=>1100,
7982=>954,7983=>959,7984=>270,7985=>270,7986=>267,7987=>267,7988=>267,7989=>267,7990=>267,7991=>267,
7992=>490,7993=>529,7994=>655,7995=>654,7996=>705,7997=>713,7998=>570,7999=>573,8000=>558,8001=>510,
8002=>510,8003=>510,8004=>510,8005=>510,8008=>797,8009=>867,8010=>1026,8011=>1022,8012=>993,8013=>1017,
8016=>504,8017=>504,8018=>504,8019=>504,8020=>504,8021=>504,8022=>504,8023=>504,8025=>916,8027=>1062,
8029=>1100,8031=>933,8032=>693,8033=>693,8034=>693,8035=>693,8036=>693,8037=>693,8038=>693,8039=>693,
8040=>852,8041=>909,8042=>1072,8043=>1072,8044=>1032,8045=>1047,8046=>930,8047=>946,8048=>564,8049=>564,
8050=>416,8051=>416,8052=>506,8053=>506,8054=>270,8055=>270,8056=>510,8057=>510,8058=>504,8059=>504,
8060=>693,8061=>693,8064=>564,8065=>564,8066=>564,8067=>564,8068=>564,8069=>564,8070=>564,8071=>564,
8072=>821,8073=>854,8074=>998,8075=>1011,8076=>992,8077=>1001,8078=>866,8079=>858,8080=>506,8081=>506,
8082=>506,8083=>506,8084=>506,8085=>506,8086=>506,8087=>506,8088=>999,8089=>1044,8090=>1179,8091=>1165,
8092=>1227,8093=>1229,8094=>1080,8095=>1085,8096=>693,8097=>693,8098=>693,8099=>693,8100=>693,8101=>693,
8102=>693,8103=>693,8104=>1037,8105=>1113,8106=>1264,8107=>1264,8108=>1219,8109=>1241,8110=>1120,8111=>1132,
8112=>564,8113=>564,8114=>564,8115=>564,8116=>564,8118=>564,8119=>564,8120=>661,8121=>661,8122=>661,
8123=>661,8124=>831,8125=>192,8126=>332,8127=>500,8128=>500,8129=>534,8130=>506,8131=>506,8132=>506,
8134=>506,8135=>506,8136=>611,8137=>816,8138=>889,8139=>908,8140=>881,8141=>500,8142=>500,8143=>500,
8144=>270,8145=>270,8146=>270,8147=>270,8150=>270,8151=>270,8152=>333,8153=>333,8154=>497,8155=>521,
8157=>500,8158=>500,8159=>500,8160=>504,8161=>504,8162=>504,8163=>504,8164=>506,8165=>506,8166=>504,
8167=>504,8168=>676,8169=>676,8170=>905,8171=>901,8172=>783,8173=>333,8174=>333,8175=>500,8178=>693,
8179=>693,8180=>693,8182=>693,8183=>693,8184=>907,8185=>833,8186=>963,8187=>875,8188=>952,8189=>500,
8190=>500,8192=>500,8193=>1000,8194=>500,8195=>1000,8196=>333,8197=>250,8198=>167,8199=>500,8200=>250,
8201=>200,8202=>100,8203=>0,8204=>0,8205=>0,8206=>0,8207=>0,8208=>333,8209=>333,8210=>500,
8213=>1000,8214=>293,8215=>465,8219=>250,8223=>444,8227=>350,8228=>250,8229=>500,8231=>250,8232=>0,
8233=>0,8234=>0,8235=>0,8236=>0,8237=>0,8238=>0,8239=>250,8241=>1601,8242=>247,8243=>411,
8244=>611,8245=>220,8246=>440,8247=>660,8248=>469,8251=>629,8252=>666,8253=>500,8254=>500,8255=>953,
8256=>1000,8257=>314,8258=>931,8259=>333,8260=>167,8261=>480,8262=>480,8263=>1000,8264=>833,8265=>833,
8266=>500,8267=>453,8268=>453,8269=>450,8270=>500,8271=>278,8272=>882,8273=>500,8274=>497,8275=>500,
8276=>953,8277=>512,8278=>410,8279=>855,8280=>620,8281=>620,8282=>179,8283=>621,8284=>564,8285=>179,
8286=>179,8287=>111,8288=>0,8289=>0,8290=>0,8291=>0,8292=>0,8304=>300,8305=>235,8308=>300,
8309=>300,8310=>300,8311=>300,8312=>300,8313=>300,8314=>300,8315=>300,8316=>300,8317=>216,8318=>216,
8319=>318,8320=>300,8321=>250,8322=>300,8323=>300,8324=>300,8325=>300,8326=>300,8327=>300,8328=>300,
8329=>300,8330=>300,8331=>300,8332=>300,8333=>216,8334=>216,8352=>698,8353=>667,8354=>667,8355=>611,
8356=>500,8357=>722,8358=>667,8359=>988,8360=>953,8361=>833,8362=>869,8363=>512,8365=>722,8366=>611,
8369=>589,8370=>619,8371=>722,8372=>556,8373=>611,8400=>0,8401=>0,8402=>0,8403=>0,8404=>0,
8405=>0,8406=>0,8407=>0,8408=>0,8409=>0,8410=>0,8411=>0,8412=>0,8413=>0,8414=>0,
8415=>0,8416=>0,8417=>0,8418=>0,8419=>0,8420=>0,8421=>0,8422=>0,8423=>0,8424=>0,
8425=>0,8426=>0,8427=>0,8428=>0,8429=>0,8430=>0,8431=>0,8432=>0,8448=>664,8449=>665,
8451=>954,8453=>693,8454=>787,8457=>822,8462=>500,8463=>500,8468=>777,8470=>823,8471=>760,8478=>616,
8479=>610,8480=>879,8481=>1156,8483=>611,8486=>743,8487=>743,8489=>286,8490=>722,8491=>722,8494=>533,
8498=>556,8501=>537,8502=>537,8503=>350,8504=>537,8506=>906,8507=>1155,8523=>778,8525=>856,8526=>500,
8531=>750,8532=>750,8533=>750,8534=>750,8535=>750,8536=>750,8537=>750,8538=>750,8539=>750,8540=>750,
8541=>750,8542=>750,8543=>750,8544=>339,8545=>678,8546=>1017,8547=>950,8548=>611,8549=>950,8550=>1289,
8551=>1628,8552=>950,8553=>611,8554=>950,8555=>1289,8556=>556,8557=>667,8558=>722,8559=>828,8560=>278,
8561=>556,8562=>834,8563=>722,8564=>444,8565=>722,8566=>1000,8567=>1278,8568=>722,8569=>444,8570=>722,
8571=>1000,8572=>278,8573=>444,8574=>500,8575=>722,8592=>964,8593=>499,8594=>964,8595=>499,8706=>494,
8710=>612,8721=>713,8722=>675,8723=>675,8725=>750,8730=>549,8734=>677,8747=>416,8748=>750,8749=>1083,
8750=>722,8751=>750,8800=>564,8804=>675,8805=>675,8992=>686,8993=>686,9251=>500,9674=>494,9676=>791,
9824=>626,9825=>694,9826=>595,9827=>776,9828=>626,9829=>694,9830=>595,9831=>776,9833=>333,9834=>555,
9835=>722,9836=>722,9837=>415,9838=>377,9839=>402,11799=>333,64256=>526,64257=>500,64258=>500,64259=>747,
64260=>748,64262=>665,64285=>350,64286=>0,64287=>537,64288=>537,64297=>564,64298=>537,64299=>537,64300=>537,
64301=>537,64302=>537,64303=>537,64304=>537,64305=>537,64306=>350,64307=>537,64308=>537,64309=>350,64310=>350,
64312=>537,64313=>350,64314=>537,64315=>537,64316=>537,64318=>537,64320=>350,64321=>537,64323=>537,64324=>537,
64326=>537,64327=>537,64328=>537,64329=>537,64330=>537,64331=>350,64332=>537,64333=>537,64334=>537,64335=>537,
65533=>788);
$enc='';
$diff='';
$file='freeserifi.z';
$ctg='freeserifi.ctg.z';
$originalsize=629968;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/freeserifi.php | PHP | asf20 | 23,653 |
<?php
// core font definition file for TCPDF (www.tcpdf.org)
$type='core';
$dw=788;
$cw=array(0=>0,1=>0,2=>0,3=>0,4=>0,5=>0,6=>0,7=>0,8=>0,9=>0,10=>0,11=>0,12=>0,
13=>0,14=>0,15=>0,16=>0,17=>0,18=>0,19=>0,20=>0,21=>0,22=>0,23=>0,24=>0,25=>0,
26=>0,27=>0,28=>0,29=>0,30=>0,31=>0,32=>278,33=>974,34=>961,35=>974,36=>980,
37=>719,38=>789,39=>790,40=>791,41=>690,42=>960,43=>939,44=>549,45=>855,46=>911,
47=>933,48=>911,49=>945,50=>974,51=>755,52=>846,53=>762,54=>761,55=>571,56=>677,
57=>763,58=>760,59=>759,60=>754,61=>494,62=>552,63=>537,64=>577,65=>692,66=>786,
67=>788,68=>788,69=>790,70=>793,71=>794,72=>816,73=>823,74=>789,75=>841,76=>823,
77=>833,78=>816,79=>831,80=>923,81=>744,82=>723,83=>749,84=>790,85=>792,86=>695,
87=>776,88=>768,89=>792,90=>759,91=>707,92=>708,93=>682,94=>701,95=>826,96=>815,
97=>789,98=>789,99=>707,100=>687,101=>696,102=>689,103=>786,104=>787,105=>713,
106=>791,107=>785,108=>791,109=>873,110=>761,111=>762,112=>762,113=>759,114=>759,
115=>892,116=>892,117=>788,118=>784,119=>438,120=>138,121=>277,122=>415,123=>392,
124=>392,125=>668,126=>668,127=>0,128=>390,129=>390,130=>317,131=>317,132=>276,
133=>276,134=>509,135=>509,136=>410,137=>410,138=>234,139=>234,140=>334,141=>334,
142=>0,143=>0,144=>0,145=>0,146=>0,147=>0,148=>0,149=>0,150=>0,151=>0,152=>0,
153=>0,154=>0,155=>0,156=>0,157=>0,158=>0,159=>0,160=>0,161=>732,162=>544,163=>544,
164=>910,165=>667,166=>760,167=>760,168=>776,169=>595,170=>694,171=>626,172=>788,
173=>788,174=>788,175=>788,176=>788,177=>788,178=>788,179=>788,180=>788,181=>788,
182=>788,183=>788,184=>788,185=>788,186=>788,187=>788,188=>788,189=>788,190=>788,
191=>788,192=>788,193=>788,194=>788,195=>788,196=>788,197=>788,198=>788,199=>788,
200=>788,201=>788,202=>788,203=>788,204=>788,205=>788,206=>788,207=>788,208=>788,
209=>788,210=>788,211=>788,212=>894,213=>838,214=>1016,215=>458,216=>748,217=>924,
218=>748,219=>918,220=>927,221=>928,222=>928,223=>834,224=>873,225=>828,226=>924,
227=>924,228=>917,229=>930,230=>931,231=>463,232=>883,233=>836,234=>836,235=>867,
236=>867,237=>696,238=>696,239=>874,240=>0,241=>874,242=>760,243=>946,244=>771,
245=>865,246=>771,247=>888,248=>967,249=>888,250=>831,251=>873,252=>927,253=>970,
254=>918,255=>0);
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/zapfdingbats.php | PHP | asf20 | 2,257 |
<?php
// core font definition file for TCPDF (www.tcpdf.org)
$type='core';
$dw=500;
$cw=array(0=>250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250,
10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250,
20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250,
30=>250,31=>250,32=>250,33=>389,34=>555,35=>500,36=>500,37=>833,38=>778,39=>278,
40=>333,41=>333,42=>500,43=>570,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,
50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333,
60=>570,61=>570,62=>570,63=>500,64=>832,65=>667,66=>667,67=>667,68=>722,69=>667,
70=>667,71=>722,72=>778,73=>389,74=>500,75=>667,76=>611,77=>889,78=>722,79=>722,
80=>611,81=>722,82=>667,83=>556,84=>611,85=>722,86=>667,87=>889,88=>667,89=>611,
90=>611,91=>333,92=>278,93=>333,94=>570,95=>500,96=>333,97=>500,98=>500,99=>444,
100=>500,101=>444,102=>333,103=>500,104=>556,105=>278,106=>278,107=>500,108=>278,
109=>778,110=>556,111=>500,112=>500,113=>500,114=>389,115=>389,116=>278,117=>556,
118=>444,119=>667,120=>500,121=>444,122=>389,123=>348,124=>220,125=>348,126=>570,
127=>350,128=>500,129=>350,130=>333,131=>500,132=>500,133=>1000,134=>500,135=>500,
136=>333,137=>1000,138=>556,139=>333,140=>944,141=>350,142=>611,143=>350,144=>350,
145=>333,146=>333,147=>500,148=>500,149=>350,150=>500,151=>1000,152=>333,153=>1000,
154=>389,155=>333,156=>722,157=>350,158=>389,159=>611,160=>250,161=>389,162=>500,
163=>500,164=>500,165=>500,166=>220,167=>500,168=>333,169=>747,170=>266,171=>500,
172=>606,173=>333,174=>747,175=>333,176=>400,177=>570,178=>300,179=>300,180=>333,
181=>576,182=>500,183=>250,184=>333,185=>300,186=>300,187=>500,188=>750,189=>750,
190=>750,191=>500,192=>667,193=>667,194=>667,195=>667,196=>667,197=>667,198=>944,
199=>667,200=>667,201=>667,202=>667,203=>667,204=>389,205=>389,206=>389,207=>389,
208=>722,209=>722,210=>722,211=>722,212=>722,213=>722,214=>722,215=>570,216=>722,
217=>722,218=>722,219=>722,220=>722,221=>611,222=>611,223=>500,224=>500,225=>500,
226=>500,227=>500,228=>500,229=>500,230=>722,231=>444,232=>444,233=>444,234=>444,
235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>556,242=>500,243=>500,
244=>500,245=>500,246=>500,247=>570,248=>500,249=>556,250=>556,251=>556,252=>556,
253=>444,254=>500,255=>444);
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/timesbi.php | PHP | asf20 | 2,337 |
<?php
$type='TrueTypeUnicode';
$name='FreeSerif';
$desc=array('Ascent'=>900,'Descent'=>-300,'CapHeight'=>10,'Flags'=>96,'FontBBox'=>'[-879 -1201 1767 2606]','ItalicAngle'=>-33.2,'StemV'=>70,'MissingWidth'=>600);
$up=-125;
$ut=50;
$dw=600;
$cw=array(
32=>250,33=>333,34=>408,35=>500,36=>500,37=>833,38=>778,39=>180,40=>333,41=>333,
42=>500,43=>564,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500,50=>500,51=>500,
52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>278,59=>278,60=>564,61=>564,
62=>564,63=>444,64=>921,65=>722,66=>667,67=>667,68=>722,69=>611,70=>556,71=>722,
72=>722,73=>333,74=>389,75=>722,76=>611,77=>889,78=>722,79=>722,80=>556,81=>722,
82=>667,83=>556,84=>611,85=>722,86=>722,87=>944,88=>722,89=>722,90=>611,91=>333,
92=>278,93=>333,94=>469,95=>500,96=>333,97=>444,98=>500,99=>444,100=>500,101=>444,
102=>333,103=>500,104=>500,105=>278,106=>278,107=>500,108=>278,109=>778,110=>500,111=>500,
112=>500,113=>500,114=>333,115=>389,116=>278,117=>500,118=>500,119=>722,120=>500,121=>500,
122=>444,123=>480,124=>200,125=>480,126=>541,8364=>741,8218=>250,402=>333,8222=>444,8230=>1000,
8224=>500,8225=>500,710=>333,8240=>1000,352=>556,8249=>250,338=>889,381=>611,8216=>250,8217=>250,
8220=>444,8221=>444,8226=>350,8211=>500,8212=>1000,732=>333,8482=>980,353=>389,8250=>250,339=>722,
382=>444,376=>722,160=>250,161=>333,162=>500,163=>500,164=>500,165=>500,166=>200,167=>500,
168=>333,169=>760,170=>276,171=>444,172=>564,173=>333,174=>760,175=>333,176=>400,177=>564,
178=>320,179=>320,180=>333,181=>500,182=>453,183=>250,184=>333,185=>320,186=>310,187=>441,
188=>750,189=>750,190=>750,191=>444,192=>722,193=>722,194=>722,195=>722,196=>722,197=>722,
198=>889,199=>667,200=>611,201=>611,202=>611,203=>611,204=>333,205=>333,206=>333,207=>333,
208=>722,209=>722,210=>722,211=>722,212=>722,213=>722,214=>722,215=>564,216=>722,217=>722,
218=>722,219=>722,220=>722,221=>722,222=>576,223=>500,224=>444,225=>444,226=>444,227=>444,
228=>444,229=>444,230=>667,231=>444,232=>444,233=>444,234=>444,235=>444,236=>278,237=>278,
238=>278,239=>278,240=>501,241=>500,242=>500,243=>500,244=>500,245=>500,246=>500,247=>564,
248=>500,249=>500,250=>500,251=>500,252=>500,253=>500,254=>496,255=>500,256=>722,257=>444,
258=>722,259=>444,260=>722,261=>444,262=>667,263=>444,264=>667,265=>444,266=>667,267=>444,
268=>667,269=>444,270=>722,271=>600,272=>722,273=>500,274=>611,275=>444,276=>611,277=>444,
278=>611,279=>444,280=>611,281=>444,282=>611,283=>444,284=>722,285=>500,286=>722,287=>500,
288=>722,289=>500,290=>722,291=>500,292=>722,293=>500,294=>722,295=>548,296=>333,297=>278,
298=>333,299=>278,300=>333,301=>278,302=>333,303=>278,304=>333,305=>278,306=>703,307=>529,
308=>389,309=>278,310=>722,311=>500,312=>500,313=>611,314=>278,315=>611,316=>278,317=>611,
318=>348,319=>611,320=>444,321=>611,322=>278,323=>722,324=>500,325=>722,326=>500,327=>722,
328=>500,329=>556,330=>722,331=>500,332=>722,333=>500,334=>722,335=>500,336=>722,337=>500,
340=>667,341=>333,342=>667,343=>333,344=>667,345=>333,346=>556,347=>389,348=>556,349=>389,
350=>556,351=>389,354=>611,355=>278,356=>611,357=>278,358=>611,359=>278,360=>722,361=>500,
362=>722,363=>500,364=>722,365=>500,366=>722,367=>500,368=>722,369=>500,370=>722,371=>500,
372=>944,373=>722,374=>722,375=>500,377=>611,378=>444,379=>611,380=>444,383=>333,384=>500,
385=>667,386=>576,387=>500,388=>646,389=>500,390=>667,391=>667,392=>444,393=>722,394=>722,
395=>646,396=>500,397=>534,398=>611,399=>722,400=>518,401=>556,403=>722,404=>665,405=>729,
406=>333,407=>333,408=>810,409=>500,410=>278,411=>480,412=>944,413=>722,414=>500,415=>726,
416=>722,417=>516,418=>1043,419=>778,420=>556,421=>500,422=>667,423=>556,424=>389,425=>627,
426=>592,427=>278,428=>611,429=>278,430=>611,431=>800,432=>518,433=>743,434=>722,435=>822,
436=>667,437=>611,438=>444,439=>530,440=>556,441=>389,442=>394,443=>500,444=>615,445=>439,
446=>421,447=>500,448=>200,449=>400,450=>600,451=>333,452=>1333,453=>1166,454=>944,455=>1000,
456=>889,457=>556,458=>1111,459=>1000,460=>778,461=>722,462=>444,463=>333,464=>278,465=>722,
466=>500,467=>722,468=>500,469=>722,470=>500,471=>722,472=>500,473=>722,474=>500,475=>722,
476=>500,477=>444,478=>722,479=>444,480=>722,481=>444,482=>889,483=>667,484=>722,485=>500,
486=>722,487=>500,488=>722,489=>500,490=>722,491=>500,492=>722,493=>500,494=>530,495=>389,
496=>278,497=>1333,498=>1166,499=>944,500=>722,501=>500,502=>944,503=>522,504=>722,505=>500,
506=>722,507=>444,508=>889,509=>667,510=>722,511=>500,512=>722,513=>444,514=>722,515=>444,
516=>611,517=>444,518=>611,519=>444,520=>333,521=>278,522=>333,523=>278,524=>722,525=>500,
526=>722,527=>500,528=>667,529=>333,530=>667,531=>333,532=>500,533=>500,534=>722,535=>500,
536=>556,537=>389,538=>611,539=>278,540=>424,541=>455,542=>722,543=>500,544=>715,545=>588,
546=>565,547=>468,548=>611,549=>444,550=>722,551=>444,552=>611,553=>444,554=>722,555=>500,
556=>722,557=>500,558=>722,559=>500,560=>722,561=>500,562=>722,563=>500,564=>407,565=>597,
566=>379,567=>278,568=>771,569=>760,570=>722,571=>667,572=>444,573=>611,574=>611,575=>389,
576=>444,577=>444,578=>444,579=>667,580=>722,581=>722,582=>611,583=>444,584=>389,585=>278,
586=>796,587=>590,588=>667,589=>333,590=>722,591=>500,592=>444,593=>500,594=>507,595=>500,
596=>444,597=>444,598=>500,599=>500,600=>444,601=>444,602=>722,603=>426,604=>426,605=>674,
606=>454,607=>278,608=>500,609=>500,610=>484,611=>500,612=>582,613=>500,614=>500,615=>500,
616=>278,617=>278,618=>278,619=>278,620=>278,621=>278,622=>556,623=>778,624=>778,625=>778,
626=>500,627=>500,628=>500,629=>491,630=>668,631=>693,632=>640,633=>333,634=>333,635=>333,
636=>333,637=>333,638=>333,639=>333,640=>446,641=>446,642=>389,643=>333,644=>500,645=>333,
646=>500,647=>278,648=>278,649=>500,650=>517,651=>514,652=>500,653=>722,654=>500,655=>510,
656=>524,657=>444,658=>389,659=>456,660=>444,661=>444,662=>444,663=>444,664=>722,665=>468,
666=>454,667=>665,668=>524,669=>347,670=>500,671=>443,672=>500,673=>444,674=>444,675=>798,
676=>795,677=>805,678=>554,679=>561,680=>678,681=>722,682=>554,683=>554,684=>500,685=>500,
686=>611,687=>611,688=>300,689=>300,690=>278,691=>278,692=>278,693=>309,694=>306,695=>432,
696=>310,697=>250,698=>408,699=>333,700=>333,701=>333,702=>333,703=>333,704=>258,705=>258,
706=>374,707=>374,708=>383,709=>383,711=>333,712=>250,713=>333,714=>333,715=>333,716=>250,
717=>333,718=>333,719=>333,720=>278,721=>278,722=>333,723=>333,724=>333,725=>333,726=>333,
727=>333,728=>333,729=>333,730=>333,731=>333,733=>382,734=>336,735=>352,736=>311,737=>200,
738=>243,739=>328,740=>300,741=>460,742=>460,743=>460,744=>460,745=>460,746=>477,747=>475,
748=>339,749=>333,750=>444,751=>383,752=>383,753=>294,754=>294,755=>327,756=>261,757=>437,
758=>437,759=>333,760=>278,761=>175,762=>175,763=>175,764=>175,765=>337,766=>337,767=>326,
768=>0,769=>0,770=>0,771=>0,772=>0,773=>0,774=>0,775=>0,776=>0,777=>0,
778=>0,779=>0,780=>0,781=>0,782=>0,783=>0,784=>0,785=>0,786=>0,787=>0,
788=>0,789=>0,790=>0,791=>0,792=>0,793=>0,794=>0,795=>0,796=>0,797=>0,
798=>0,799=>0,800=>0,801=>0,802=>0,803=>0,804=>0,805=>0,806=>0,807=>0,
808=>0,809=>0,810=>0,811=>0,812=>0,813=>0,814=>0,815=>0,816=>0,817=>0,
818=>0,819=>0,820=>0,821=>0,822=>0,823=>0,824=>0,825=>0,826=>0,827=>0,
828=>0,829=>0,830=>0,831=>0,832=>0,833=>0,834=>0,835=>0,836=>0,837=>0,
838=>0,839=>0,840=>0,841=>0,842=>0,843=>0,844=>0,845=>0,846=>0,847=>0,
848=>0,849=>0,850=>0,851=>0,852=>0,853=>0,854=>0,855=>0,856=>0,857=>0,
858=>0,859=>0,860=>0,861=>0,862=>0,863=>0,864=>0,865=>0,866=>0,867=>0,
868=>0,869=>0,870=>0,871=>0,872=>0,873=>0,874=>0,875=>0,876=>0,877=>0,
878=>0,879=>0,884=>199,885=>199,890=>332,894=>278,900=>267,901=>333,902=>722,903=>250,
904=>800,905=>902,906=>507,908=>818,910=>861,911=>871,912=>286,913=>722,914=>667,915=>586,
916=>660,917=>611,918=>611,919=>722,920=>726,921=>333,922=>722,923=>722,924=>889,925=>722,
926=>628,927=>722,928=>722,929=>556,931=>627,932=>611,933=>696,934=>742,935=>722,936=>808,
937=>743,938=>333,939=>718,940=>583,941=>426,942=>536,943=>286,944=>514,945=>583,946=>527,
947=>480,948=>534,949=>426,950=>466,951=>536,952=>534,953=>286,954=>544,955=>476,956=>536,
957=>480,958=>514,959=>500,960=>587,961=>528,962=>452,963=>537,964=>420,965=>514,966=>643,
967=>480,968=>693,969=>693,970=>286,971=>514,972=>500,973=>514,974=>693,976=>534,977=>587,
978=>620,979=>809,980=>620,981=>640,982=>684,983=>534,984=>556,985=>500,986=>594,987=>426,
988=>556,989=>445,990=>656,991=>400,992=>722,993=>570,994=>960,995=>673,996=>581,997=>429,
998=>560,999=>407,1000=>450,1001=>321,1002=>842,1003=>593,1004=>564,1005=>413,1006=>618,1007=>438,
1008=>534,1009=>534,1010=>485,1011=>278,1012=>726,1013=>361,1014=>361,1015=>576,1016=>542,1017=>667,
1018=>889,1019=>709,1020=>534,1021=>667,1022=>1000,1023=>1000,1024=>615,1025=>613,1026=>748,1027=>570,
1028=>659,1029=>487,1030=>329,1031=>329,1032=>381,1033=>943,1034=>985,1035=>827,1036=>669,1037=>723,
1038=>709,1039=>723,1040=>711,1041=>576,1042=>626,1043=>570,1044=>639,1045=>613,1046=>937,1047=>580,
1048=>723,1049=>723,1050=>669,1051=>684,1052=>891,1053=>723,1054=>722,1055=>723,1056=>576,1057=>659,
1058=>608,1059=>709,1060=>750,1061=>714,1062=>728,1063=>682,1064=>984,1065=>988,1066=>725,1067=>863,
1068=>576,1069=>659,1070=>966,1071=>648,1072=>434,1073=>495,1074=>468,1075=>386,1076=>488,1077=>436,
1078=>662,1079=>404,1080=>524,1081=>524,1082=>498,1083=>490,1084=>632,1085=>524,1086=>491,1087=>524,
1088=>500,1089=>422,1090=>422,1091=>471,1092=>694,1093=>482,1094=>522,1095=>506,1096=>756,1097=>754,
1098=>503,1099=>626,1100=>431,1101=>430,1102=>664,1103=>492,1104=>434,1105=>434,1106=>479,1107=>386,
1108=>430,1109=>347,1110=>269,1111=>278,1112=>278,1113=>677,1114=>711,1115=>514,1116=>498,1117=>524,
1118=>471,1119=>524,1120=>978,1121=>664,1122=>718,1123=>506,1124=>939,1125=>647,1126=>912,1127=>643,
1128=>1248,1129=>894,1130=>948,1131=>662,1132=>1299,1133=>911,1134=>516,1135=>391,1136=>870,1137=>694,
1138=>726,1139=>491,1140=>780,1141=>550,1142=>780,1143=>550,1144=>1207,1145=>946,1146=>877,1147=>611,
1148=>978,1149=>664,1150=>978,1151=>664,1152=>594,1153=>428,1154=>232,1155=>0,1156=>0,1157=>0,
1158=>0,1159=>0,1160=>0,1161=>0,1162=>715,1163=>522,1164=>562,1165=>430,1166=>556,1167=>511,
1168=>564,1169=>398,1170=>586,1171=>402,1172=>573,1173=>463,1174=>1001,1175=>688,1176=>580,1177=>414,
1178=>698,1179=>517,1180=>734,1181=>537,1182=>671,1183=>498,1184=>842,1185=>573,1186=>732,1187=>524,
1188=>926,1189=>652,1190=>1014,1191=>721,1192=>671,1193=>531,1194=>667,1195=>437,1196=>611,1197=>454,
1198=>722,1199=>563,1200=>722,1201=>562,1202=>783,1203=>517,1204=>967,1205=>693,1206=>691,1207=>510,
1208=>718,1209=>538,1210=>674,1211=>508,1212=>866,1213=>566,1214=>866,1215=>566,1216=>333,1217=>937,
1218=>662,1219=>626,1220=>446,1221=>702,1222=>489,1223=>722,1224=>497,1225=>823,1226=>545,1227=>674,
1228=>504,1229=>889,1230=>630,1231=>333,1232=>711,1233=>434,1234=>711,1235=>434,1236=>889,1237=>644,
1238=>613,1239=>449,1240=>722,1241=>449,1242=>722,1243=>449,1244=>937,1245=>662,1246=>580,1247=>404,
1248=>530,1249=>366,1250=>723,1251=>524,1252=>723,1253=>524,1254=>722,1255=>491,1256=>722,1257=>491,
1258=>722,1259=>491,1260=>659,1261=>430,1262=>709,1263=>471,1264=>709,1265=>471,1266=>709,1267=>471,
1268=>682,1269=>506,1270=>564,1271=>388,1272=>863,1273=>626,1274=>556,1275=>388,1276=>720,1277=>445,
1278=>722,1279=>495,1280=>556,1281=>504,1282=>900,1283=>634,1284=>553,1285=>471,1286=>803,1287=>518,
1288=>964,1289=>637,1290=>968,1291=>682,1292=>722,1293=>433,1294=>710,1295=>504,1296=>532,1297=>409,
1298=>702,1299=>489,1300=>960,1301=>644,1302=>823,1303=>702,1304=>961,1305=>766,1306=>722,1307=>504,
1308=>944,1309=>693,1310=>690,1311=>502,1312=>994,1313=>695,1314=>1011,1315=>727,1425=>0,1426=>0,
1427=>0,1428=>0,1429=>0,1430=>0,1431=>418,1432=>0,1433=>0,1434=>0,1435=>0,1436=>0,
1437=>0,1438=>0,1439=>0,1440=>0,1441=>0,1442=>0,1443=>0,1444=>0,1445=>0,1446=>0,
1447=>0,1448=>0,1449=>0,1450=>0,1451=>0,1452=>0,1453=>0,1454=>0,1455=>0,1456=>0,
1457=>0,1458=>0,1459=>0,1460=>0,1461=>0,1462=>0,1463=>0,1464=>0,1465=>0,1466=>0,
1467=>0,1468=>0,1469=>0,1470=>440,1471=>0,1472=>126,1473=>0,1474=>0,1475=>418,1476=>0,
1477=>0,1478=>350,1479=>0,1488=>537,1489=>537,1490=>350,1491=>537,1492=>537,1493=>350,1494=>350,
1495=>537,1496=>537,1497=>350,1498=>537,1499=>537,1500=>537,1501=>537,1502=>537,1503=>350,1504=>350,
1505=>537,1506=>537,1507=>537,1508=>537,1509=>537,1510=>537,1511=>537,1512=>537,1513=>537,1514=>537,
1520=>537,1521=>537,1522=>537,1523=>396,1524=>396,1548=>226,1563=>250,1567=>473,1569=>350,1570=>321,
1571=>249,1572=>399,1573=>249,1574=>776,1575=>249,1576=>950,1577=>424,1578=>925,1579=>924,1580=>738,
1581=>748,1582=>701,1583=>397,1584=>399,1585=>328,1586=>331,1587=>951,1588=>949,1589=>949,1590=>949,
1591=>557,1592=>550,1593=>625,1594=>602,1601=>801,1602=>696,1603=>757,1604=>655,1605=>549,1606=>651,
1607=>424,1608=>399,1609=>776,1610=>776,1611=>0,1613=>0,1614=>0,1615=>0,1616=>0,1617=>0,
1618=>0,1619=>0,1620=>0,1621=>0,1632=>297,1633=>254,1634=>427,1635=>497,1636=>440,1637=>465,
1638=>466,1639=>421,1640=>459,1641=>424,1643=>212,1652=>300,1662=>926,1670=>750,1688=>338,1711=>874,
1740=>776,1748=>176,1920=>450,1921=>501,1922=>582,1923=>544,1924=>482,1925=>433,1926=>448,1927=>462,
1928=>474,1929=>471,1930=>469,1931=>537,1932=>499,1933=>514,1934=>471,1935=>572,1936=>880,1937=>440,
1938=>476,1939=>594,1940=>469,1941=>448,1942=>441,1943=>519,1944=>573,1945=>459,1946=>447,1947=>496,
1948=>541,1949=>887,1950=>883,1951=>964,1952=>558,1953=>505,1954=>471,1955=>554,1956=>459,1957=>486,
1958=>36,1959=>36,1960=>43,1961=>45,1962=>43,1963=>45,1964=>45,1965=>45,1966=>45,1967=>45,
1968=>0,2305=>415,2306=>398,2307=>398,2309=>862,2310=>1042,2311=>553,2312=>553,2313=>597,2314=>848,
2315=>967,2316=>828,2317=>654,2319=>654,2321=>1042,2323=>1042,2324=>1042,2325=>743,2326=>798,2327=>694,
2328=>694,2329=>730,2330=>734,2331=>888,2332=>814,2333=>834,2334=>734,2335=>629,2336=>629,2337=>653,
2338=>609,2339=>694,2340=>654,2341=>694,2342=>588,2343=>694,2344=>654,2345=>654,2346=>615,2347=>788,
2348=>621,2349=>694,2350=>694,2351=>694,2352=>575,2353=>575,2354=>787,2355=>848,2356=>848,2357=>621,
2359=>615,2360=>734,2361=>609,2364=>398,2365=>569,2366=>341,2367=>341,2368=>341,2369=>0,2370=>0,
2371=>0,2372=>0,2373=>415,2375=>615,2376=>615,2377=>341,2379=>341,2380=>341,2381=>0,2384=>1047,
2392=>743,2393=>798,2394=>694,2395=>814,2396=>653,2397=>609,2398=>788,2400=>967,2401=>828,2402=>0,
2403=>0,2404=>398,2405=>478,2406=>455,2407=>420,2408=>569,2409=>509,2410=>702,2411=>629,2412=>569,
2413=>702,2414=>609,2415=>609,2416=>626,2433=>0,2434=>300,2435=>312,2437=>594,2438=>776,2439=>469,
2440=>513,2441=>535,2442=>561,2443=>604,2444=>481,2447=>580,2448=>604,2451=>540,2452=>620,2453=>570,
2454=>485,2455=>484,2456=>471,2457=>457,2458=>408,2459=>452,2460=>591,2461=>551,2462=>771,2463=>414,
2464=>404,2465=>522,2466=>415,2467=>450,2468=>551,2469=>477,2470=>478,2471=>449,2472=>448,2474=>535,
2475=>611,2476=>443,2477=>534,2478=>492,2479=>474,2480=>442,2482=>542,2486=>507,2487=>467,2488=>523,
2489=>419,2492=>0,2493=>419,2494=>202,2495=>189,2496=>202,2497=>0,2498=>0,2499=>0,2500=>0,
2503=>294,2504=>289,2507=>774,2508=>825,2509=>0,2510=>356,2519=>219,2524=>523,2525=>420,2527=>469,
2528=>604,2529=>481,2530=>0,2531=>0,2534=>500,2535=>437,2536=>479,2537=>507,2538=>497,2539=>500,
2540=>482,2541=>503,2542=>517,2543=>481,2544=>443,2545=>443,2546=>429,2547=>383,2548=>432,2549=>478,
2550=>539,2551=>158,2552=>365,2553=>280,2554=>357,2561=>0,2562=>0,2563=>385,2565=>728,2566=>884,
2567=>656,2568=>656,2569=>580,2570=>580,2575=>482,2576=>728,2579=>580,2580=>728,2581=>534,2582=>518,
2583=>602,2584=>674,2585=>530,2586=>502,2587=>576,2588=>476,2589=>558,2590=>501,2591=>510,2592=>540,
2593=>508,2594=>512,2595=>558,2596=>468,2597=>518,2598=>488,2599=>518,2600=>522,2602=>518,2603=>490,
2604=>546,2605=>500,2606=>530,2607=>654,2608=>522,2610=>710,2611=>710,2613=>498,2614=>530,2616=>530,
2617=>501,2620=>286,2622=>156,2623=>174,2624=>174,2625=>0,2626=>0,2631=>0,2632=>0,2635=>0,
2636=>0,2637=>0,2641=>0,2649=>534,2650=>618,2651=>492,2652=>484,2654=>506,2662=>616,2663=>480,
2664=>560,2665=>480,2666=>468,2667=>492,2668=>514,2669=>538,2670=>572,2671=>560,2672=>0,2673=>0,
2674=>498,2675=>596,2676=>900,2677=>0,2946=>345,2947=>616,2949=>910,2950=>1072,2951=>848,2952=>591,
2953=>492,2954=>1123,2958=>602,2959=>602,2960=>691,2962=>753,2963=>753,2964=>1597,2965=>677,2969=>697,
2970=>607,2972=>691,2974=>871,2975=>589,2979=>1230,2980=>688,2984=>560,2985=>911,2986=>477,2990=>625,
2991=>672,2992=>452,2993=>553,2994=>651,2995=>804,2996=>645,2997=>740,2999=>865,3000=>870,3001=>1067,
3006=>452,3007=>176,3008=>293,3009=>404,3010=>601,3014=>690,3015=>503,3016=>839,3018=>1188,3019=>982,
3020=>1519,3021=>234,3031=>804,3330=>417,3331=>221,3333=>1055,3334=>1195,3335=>792,3336=>1467,3337=>569,
3338=>1243,3339=>676,3340=>897,3342=>1008,3343=>1004,3344=>1538,3346=>585,3347=>981,3348=>1254,3349=>775,
3350=>798,3351=>691,3352=>1095,3353=>809,3354=>726,3355=>963,3356=>703,3357=>1244,3358=>1103,3359=>462,
3360=>531,3361=>983,3362=>1027,3363=>1102,3364=>779,3365=>731,3366=>485,3367=>737,3368=>747,3370=>779,
3371=>961,3372=>1023,3373=>500,3374=>510,3375=>792,3376=>527,3377=>511,3378=>713,3379=>553,3380=>516,
3381=>715,3382=>785,3383=>920,3384=>977,3385=>977,3389=>375,3390=>403,3391=>283,3392=>323,3393=>275,
3394=>258,3395=>378,3396=>378,3398=>542,3399=>478,3400=>1069,3402=>1127,3403=>1038,3404=>676,3405=>89,
3415=>676,3424=>676,3425=>1006,3430=>559,3431=>659,3432=>674,3433=>933,3434=>671,3435=>699,3436=>703,
3437=>688,3438=>677,3439=>684,3440=>375,3458=>355,3459=>241,3461=>501,3465=>591,3466=>613,3467=>630,
3473=>636,3476=>653,3481=>760,3482=>739,3483=>653,3484=>757,3486=>562,3488=>636,3489=>673,3490=>673,
3492=>984,3493=>984,3495=>636,3496=>653,3497=>653,3498=>653,3499=>1066,3501=>739,3502=>636,3503=>501,
3504=>653,3505=>739,3507=>501,3508=>673,3509=>636,3510=>653,3511=>739,3512=>636,3513=>653,3514=>673,
3515=>613,3517=>630,3520=>636,3521=>739,3522=>673,3523=>673,3524=>739,3525=>630,3526=>739,3530=>0,
3535=>328,3536=>288,3537=>319,3538=>0,3539=>0,3540=>0,3542=>0,3544=>380,3545=>495,3551=>492,
3585=>532,3586=>472,3587=>534,3588=>532,3589=>544,3590=>583,3591=>417,3592=>488,3593=>604,3594=>472,
3595=>534,3596=>716,3597=>717,3598=>568,3599=>568,3600=>457,3601=>637,3602=>731,3603=>790,3604=>531,
3605=>542,3606=>522,3607=>577,3608=>468,3609=>603,3610=>554,3611=>554,3612=>556,3613=>556,3614=>604,
3615=>604,3616=>568,3617=>542,3618=>496,3619=>442,3620=>530,3621=>512,3622=>568,3623=>478,3624=>543,
3625=>614,3626=>525,3627=>578,3628=>659,3629=>514,3630=>514,3631=>450,3632=>402,3633=>0,3634=>378,
3635=>415,3636=>0,3637=>0,3638=>0,3639=>0,3640=>0,3641=>0,3642=>0,3647=>620,3648=>286,
3649=>521,3650=>447,3651=>426,3652=>424,3653=>333,3654=>453,3655=>0,3656=>0,3657=>0,3658=>0,
3659=>0,3660=>0,3661=>0,3662=>0,3663=>657,3664=>528,3665=>528,3666=>571,3667=>594,3668=>631,
3669=>632,3670=>478,3671=>713,3672=>597,3673=>565,3674=>615,3675=>1381,4256=>453,4257=>448,4258=>546,
4259=>619,4260=>478,4261=>481,4262=>459,4263=>707,4264=>467,4265=>471,4266=>842,4267=>464,4268=>443,
4269=>707,4270=>460,4271=>465,4272=>686,4273=>440,4274=>550,4275=>561,4276=>580,4277=>467,4278=>630,
4279=>466,4280=>517,4281=>456,4282=>502,4283=>464,4284=>534,4285=>440,4286=>443,4287=>522,4288=>460,
4289=>463,4290=>536,4291=>455,4292=>468,4293=>449,4304=>454,4305=>452,4306=>544,4307=>629,4308=>451,
4309=>452,4310=>452,4311=>702,4312=>451,4313=>452,4314=>820,4315=>451,4316=>453,4317=>695,4318=>449,
4319=>448,4320=>694,4321=>501,4322=>544,4323=>517,4324=>560,4325=>450,4326=>627,4327=>452,4328=>491,
4329=>452,4330=>485,4331=>452,4332=>485,4333=>443,4334=>500,4335=>582,4336=>455,4337=>451,4338=>480,
4339=>414,4340=>453,4341=>418,4345=>528,4347=>410,4608=>583,4609=>770,4610=>560,4611=>525,4612=>525,
4613=>583,4614=>758,4616=>598,4617=>787,4618=>817,4619=>583,4620=>758,4621=>612,4622=>875,4623=>817,
4624=>817,4625=>1050,4626=>1050,4627=>817,4628=>1050,4629=>817,4630=>787,4631=>1021,4632=>933,4633=>1137,
4634=>1067,4635=>980,4636=>1065,4637=>962,4638=>962,4639=>1097,4640=>831,4641=>1021,4642=>851,4643=>735,
4644=>875,4645=>968,4646=>817,4647=>881,4648=>583,4649=>642,4650=>583,4651=>758,4652=>700,4653=>583,
4654=>700,4655=>758,4656=>583,4657=>787,4658=>787,4659=>583,4660=>729,4661=>583,4662=>583,4663=>817,
4664=>642,4665=>817,4666=>846,4667=>642,4668=>758,4669=>744,4670=>642,4671=>817,4672=>700,4673=>700,
4674=>700,4675=>758,4676=>700,4677=>700,4678=>729,4680=>846,4682=>1079,4683=>700,4684=>700,4685=>1021,
4688=>700,4689=>700,4690=>700,4691=>758,4692=>700,4693=>758,4694=>729,4696=>846,4698=>1079,4699=>700,
4700=>700,4701=>1021,4704=>525,4705=>758,4706=>758,4707=>525,4708=>700,4709=>773,4710=>525,4711=>787,
4712=>525,4713=>758,4714=>758,4715=>525,4716=>700,4717=>773,4718=>525,4719=>525,4720=>729,4721=>729,
4722=>729,4723=>802,4724=>729,4725=>729,4726=>758,4727=>729,4728=>758,4729=>758,4730=>758,4731=>817,
4732=>758,4733=>817,4734=>758,4735=>758,4736=>612,4737=>817,4738=>817,4739=>612,4740=>787,4741=>583,
4742=>875,4744=>962,4746=>992,4747=>700,4748=>758,4749=>904,4752=>408,4753=>583,4754=>525,4755=>554,
4756=>481,4757=>554,4758=>642,4759=>671,4760=>700,4761=>758,4762=>729,4763=>700,4764=>671,4765=>700,
4766=>758,4767=>700,4768=>583,4769=>735,4770=>822,4771=>583,4772=>793,4773=>583,4774=>583,4775=>694,
4776=>554,4777=>729,4778=>773,4779=>554,4780=>700,4781=>554,4782=>554,4784=>992,4786=>1021,4787=>671,
4788=>787,4789=>904,4792=>729,4793=>904,4794=>948,4795=>729,4796=>875,4797=>729,4798=>729,4800=>1137,
4802=>1167,4803=>758,4804=>875,4805=>1108,4808=>758,4809=>875,4810=>700,4811=>700,4812=>700,4813=>992,
4814=>758,4816=>554,4817=>787,4818=>758,4819=>583,4820=>758,4821=>496,4822=>612,4824=>525,4825=>700,
4826=>700,4827=>525,4828=>685,4829=>729,4830=>510,4831=>729,4832=>962,4833=>962,4834=>962,4835=>962,
4836=>962,4837=>1021,4838=>962,4839=>962,4840=>467,4841=>525,4842=>671,4843=>612,4844=>612,4845=>671,
4846=>671,4848=>612,4849=>875,4850=>817,4851=>642,4852=>729,4853=>729,4854=>758,4855=>817,4856=>700,
4857=>758,4858=>715,4859=>700,4860=>700,4861=>787,4862=>758,4863=>700,4864=>700,4865=>758,4866=>715,
4867=>700,4868=>700,4869=>787,4870=>758,4871=>700,4872=>467,4873=>671,4874=>671,4875=>612,4876=>612,
4877=>583,4878=>525,4880=>846,4882=>904,4883=>554,4884=>700,4885=>817,4888=>525,4889=>729,4890=>729,
4891=>612,4892=>671,4893=>583,4894=>525,4896=>817,4897=>1021,4898=>1021,4899=>817,4900=>992,4901=>758,
4902=>817,4903=>1021,4904=>1079,4905=>1137,4906=>1137,4907=>1050,4908=>1312,4909=>1050,4910=>1050,4911=>1123,
4912=>647,4913=>793,4914=>822,4915=>647,4916=>793,4917=>764,4918=>583,4919=>647,4920=>583,4921=>793,
4922=>822,4923=>583,4924=>793,4925=>764,4926=>583,4927=>793,4928=>540,4929=>758,4930=>583,4931=>467,
4932=>583,4933=>481,4934=>612,4936=>758,4937=>700,4938=>758,4939=>700,4940=>831,4941=>671,4942=>758,
4943=>700,4944=>758,4945=>758,4946=>758,4947=>817,4948=>758,4949=>758,4950=>817,4951=>758,4952=>642,
4953=>980,4954=>758,4961=>233,4962=>583,4963=>408,4964=>408,4965=>525,4966=>525,4967=>233,4968=>700,
4969=>671,4970=>612,4971=>642,4972=>642,4973=>642,4974=>583,4975=>700,4976=>758,4977=>642,4978=>583,
4979=>700,4980=>729,4981=>720,4982=>583,4983=>758,4984=>700,4985=>904,4986=>612,4987=>583,4988=>875,
5024=>711,5025=>678,5026=>604,5027=>667,5028=>796,5029=>301,5030=>516,5031=>544,5032=>457,5033=>716,
5034=>703,5035=>383,5036=>628,5037=>709,5038=>455,5039=>601,5040=>472,5041=>574,5042=>730,5043=>939,
5044=>498,5045=>528,5046=>667,5047=>891,5048=>505,5049=>792,5050=>957,5051=>725,5052=>595,5053=>733,
5054=>698,5055=>638,5056=>720,5057=>732,5058=>624,5059=>638,5060=>565,5061=>903,5062=>655,5063=>681,
5064=>675,5065=>949,5066=>683,5067=>547,5068=>693,5069=>732,5070=>529,5071=>569,5072=>536,5073=>677,
5074=>631,5075=>382,5076=>973,5077=>543,5078=>607,5079=>652,5080=>652,5081=>693,5082=>514,5083=>803,
5084=>658,5085=>597,5086=>627,5087=>659,5088=>679,5089=>706,5090=>563,5091=>618,5092=>767,5093=>776,
5094=>731,5095=>492,5096=>808,5097=>823,5098=>796,5099=>689,5100=>716,5101=>518,5102=>521,5103=>719,
5104=>563,5105=>776,5106=>634,5107=>822,5108=>621,5920=>502,5921=>502,5922=>500,5923=>498,5924=>500,
5925=>502,5926=>502,5927=>502,5928=>500,5929=>503,5930=>502,5931=>502,5932=>500,5933=>500,5934=>500,
5935=>796,5936=>500,5937=>502,5938=>0,5939=>0,5940=>0,5941=>230,5942=>397,6480=>537,6481=>537,
6482=>531,6483=>678,6484=>682,6485=>628,6486=>732,6487=>721,6488=>598,6489=>583,6490=>702,6491=>554,
6492=>683,6493=>554,6494=>710,6495=>695,6496=>523,6497=>678,6498=>589,6499=>272,6500=>506,6501=>515,
6502=>515,6503=>210,6504=>210,6505=>515,6506=>515,6507=>515,6508=>229,6509=>705,6512=>649,6513=>538,
6514=>568,6515=>520,6516=>544,6656=>820,6657=>958,6658=>758,6659=>859,6660=>958,6661=>727,6662=>904,
6663=>940,6664=>850,6665=>905,6666=>838,6667=>961,6668=>1000,6669=>880,6670=>1189,6671=>1246,6672=>1177,
6673=>757,6674=>1246,6675=>1192,6676=>709,6677=>1192,6678=>1075,6679=>0,6680=>0,6681=>534,6682=>690,
6683=>0,6686=>697,6687=>500,7424=>484,7425=>595,7426=>667,7427=>446,7428=>446,7429=>483,7430=>483,
7431=>409,7432=>426,7433=>278,7434=>260,7435=>483,7436=>409,7437=>595,7438=>483,7439=>483,7440=>426,
7441=>500,7442=>489,7443=>668,7444=>722,7445=>378,7448=>372,7449=>446,7450=>446,7451=>409,7452=>483,
7453=>488,7454=>660,7455=>500,7456=>483,7457=>632,7458=>409,7459=>355,7462=>392,7463=>483,7464=>483,
7465=>372,7466=>541,7467=>470,7468=>484,7469=>595,7470=>446,7471=>446,7472=>483,7473=>409,7474=>409,
7475=>483,7476=>483,7477=>223,7478=>260,7479=>483,7480=>409,7481=>595,7482=>483,7483=>483,7484=>483,
7485=>378,7486=>372,7487=>446,7488=>409,7489=>483,7490=>632,7491=>297,7492=>297,7493=>335,7494=>446,
7495=>335,7496=>335,7497=>297,7498=>297,7499=>285,7500=>285,7501=>335,7502=>186,7503=>335,7504=>521,
7505=>335,7506=>335,7507=>297,7510=>335,7511=>186,7512=>335,7513=>326,7514=>521,7515=>335,7517=>353,
7518=>321,7519=>357,7520=>430,7521=>321,7522=>186,7523=>223,7524=>335,7525=>335,7526=>353,7527=>321,
7528=>353,7529=>430,7530=>321,7531=>754,7532=>500,7533=>500,7534=>333,7535=>778,7536=>500,7537=>500,
7538=>333,7539=>333,7540=>389,7541=>278,7542=>444,7543=>500,7544=>483,7546=>774,7547=>217,7548=>278,
7549=>500,7550=>483,7551=>514,7552=>500,7553=>500,7554=>333,7555=>676,7556=>525,7557=>278,7558=>802,
7559=>507,7560=>500,7561=>333,7562=>389,7563=>384,7564=>500,7565=>500,7566=>444,7680=>722,7681=>444,
7682=>667,7683=>500,7684=>667,7685=>500,7686=>667,7687=>500,7688=>667,7689=>444,7690=>722,7691=>500,
7692=>722,7693=>500,7694=>722,7695=>500,7696=>720,7697=>500,7698=>722,7699=>500,7700=>611,7701=>444,
7702=>611,7703=>444,7704=>611,7705=>444,7706=>611,7707=>444,7708=>611,7709=>444,7710=>556,7711=>333,
7712=>722,7713=>500,7714=>722,7715=>500,7716=>722,7717=>500,7718=>722,7719=>500,7720=>722,7721=>500,
7722=>722,7723=>500,7724=>333,7725=>278,7726=>333,7727=>278,7728=>722,7729=>500,7730=>722,7731=>500,
7732=>722,7733=>500,7734=>611,7735=>278,7736=>611,7737=>278,7738=>611,7739=>278,7740=>611,7741=>278,
7742=>889,7743=>778,7744=>889,7745=>778,7746=>889,7747=>778,7748=>722,7749=>500,7750=>722,7751=>500,
7752=>722,7753=>500,7754=>722,7755=>500,7756=>722,7757=>500,7758=>722,7759=>500,7760=>722,7761=>500,
7762=>722,7763=>500,7764=>556,7765=>500,7766=>556,7767=>500,7768=>667,7769=>333,7770=>667,7771=>333,
7772=>667,7773=>333,7774=>667,7775=>333,7776=>556,7777=>389,7778=>556,7779=>389,7780=>556,7781=>389,
7782=>556,7783=>389,7784=>556,7785=>389,7786=>611,7787=>278,7788=>611,7789=>278,7790=>611,7791=>278,
7792=>611,7793=>278,7794=>722,7795=>500,7796=>722,7797=>500,7798=>722,7799=>500,7800=>722,7801=>500,
7802=>722,7803=>500,7804=>722,7805=>500,7806=>722,7807=>500,7808=>944,7809=>722,7810=>944,7811=>722,
7812=>944,7813=>722,7814=>944,7815=>722,7816=>944,7817=>722,7818=>722,7819=>500,7820=>722,7821=>500,
7822=>722,7823=>500,7824=>611,7825=>444,7826=>611,7827=>444,7828=>611,7829=>444,7830=>500,7831=>278,
7832=>722,7833=>500,7834=>444,7835=>333,7840=>722,7841=>444,7842=>807,7843=>529,7844=>722,7845=>444,
7846=>722,7847=>444,7848=>722,7849=>454,7850=>722,7851=>444,7852=>722,7853=>444,7854=>722,7855=>444,
7856=>722,7857=>444,7858=>722,7859=>454,7860=>722,7861=>444,7862=>722,7863=>444,7864=>611,7865=>444,
7866=>611,7867=>444,7868=>611,7869=>444,7870=>611,7871=>444,7872=>611,7873=>444,7874=>613,7875=>444,
7876=>611,7877=>444,7878=>611,7879=>444,7880=>333,7881=>278,7882=>333,7883=>278,7884=>722,7885=>500,
7886=>722,7887=>500,7888=>722,7889=>500,7890=>722,7891=>500,7892=>722,7893=>500,7894=>722,7895=>500,
7896=>722,7897=>500,7898=>722,7899=>516,7900=>722,7901=>516,7902=>720,7903=>516,7904=>722,7905=>516,
7906=>722,7907=>516,7908=>722,7909=>500,7910=>717,7911=>500,7912=>800,7913=>518,7914=>800,7915=>518,
7916=>800,7917=>518,7918=>800,7919=>518,7920=>800,7921=>518,7922=>722,7923=>500,7924=>722,7925=>500,
7926=>722,7927=>501,7928=>722,7929=>500,7936=>583,7937=>583,7938=>583,7939=>583,7940=>583,7941=>583,
7942=>583,7943=>583,7944=>722,7945=>722,7946=>813,7947=>817,7948=>763,7949=>765,7950=>720,7951=>722,
7952=>426,7953=>426,7954=>426,7955=>426,7956=>426,7957=>426,7960=>770,7961=>770,7962=>902,7963=>919,
7964=>940,7965=>936,7968=>536,7969=>536,7970=>536,7971=>536,7972=>536,7973=>536,7974=>536,7975=>536,
7976=>847,7977=>859,7978=>986,7979=>1010,7980=>1026,7981=>1029,7982=>918,7983=>921,7984=>286,7985=>286,
7986=>302,7987=>320,7988=>300,7989=>306,7990=>312,7991=>303,7992=>475,7993=>507,7994=>617,7995=>654,
7996=>655,7997=>660,7998=>551,7999=>566,8000=>500,8001=>500,8002=>500,8003=>500,8004=>500,8005=>500,
8008=>816,8009=>825,8010=>969,8011=>995,8012=>938,8013=>955,8016=>514,8017=>514,8018=>514,8019=>514,
8020=>514,8021=>514,8022=>514,8023=>514,8025=>818,8027=>988,8029=>989,8031=>893,8032=>693,8033=>693,
8034=>693,8035=>693,8036=>693,8037=>693,8038=>693,8039=>693,8040=>836,8041=>843,8042=>1006,8043=>1024,
8044=>974,8045=>986,8046=>905,8047=>896,8048=>583,8049=>583,8050=>426,8051=>426,8052=>536,8053=>536,
8054=>286,8055=>286,8056=>500,8057=>500,8058=>514,8059=>514,8060=>693,8061=>693,8064=>583,8065=>583,
8066=>583,8067=>583,8068=>583,8069=>583,8070=>583,8071=>583,8072=>888,8073=>889,8074=>984,8075=>991,
8076=>943,8077=>948,8078=>884,8079=>886,8080=>536,8081=>536,8082=>536,8083=>536,8084=>536,8085=>536,
8086=>536,8087=>536,8088=>1017,8089=>1026,8090=>1153,8091=>1179,8092=>1195,8093=>1199,8094=>1088,8095=>1088,
8096=>693,8097=>693,8098=>693,8099=>693,8100=>693,8101=>693,8102=>693,8103=>693,8104=>1034,8105=>1040,
8106=>1210,8107=>1229,8108=>1176,8109=>1186,8110=>1098,8111=>1090,8112=>583,8113=>583,8114=>583,8115=>583,
8116=>583,8118=>583,8119=>583,8120=>722,8121=>722,8122=>722,8123=>722,8124=>889,8125=>250,8126=>332,
8127=>500,8128=>500,8129=>534,8130=>536,8131=>536,8132=>536,8134=>536,8135=>536,8136=>761,8137=>800,
8138=>829,8139=>893,8140=>883,8141=>500,8142=>500,8143=>500,8144=>286,8145=>286,8146=>286,8147=>286,
8150=>286,8151=>286,8152=>333,8153=>333,8154=>447,8155=>537,8157=>500,8158=>500,8159=>500,8160=>514,
8161=>514,8162=>514,8163=>514,8164=>528,8165=>528,8166=>514,8167=>514,8168=>696,8169=>696,8170=>816,
8171=>828,8172=>721,8173=>333,8174=>333,8175=>500,8178=>693,8179=>693,8180=>693,8182=>693,8183=>693,
8184=>832,8185=>899,8186=>847,8187=>852,8188=>928,8189=>500,8190=>500,8192=>500,8193=>1000,8194=>500,
8195=>1000,8196=>333,8197=>250,8198=>167,8199=>500,8200=>250,8201=>200,8202=>100,8203=>0,8204=>0,
8205=>0,8206=>0,8207=>0,8208=>333,8209=>333,8210=>500,8213=>1000,8214=>293,8215=>478,8219=>250,
8223=>444,8227=>350,8228=>620,8229=>620,8231=>250,8232=>0,8233=>0,8234=>0,8235=>0,8236=>0,
8237=>0,8238=>0,8239=>250,8241=>1363,8242=>247,8243=>411,8244=>611,8245=>220,8246=>440,8247=>660,
8248=>469,8251=>629,8252=>666,8253=>444,8254=>500,8255=>953,8256=>953,8257=>314,8258=>931,8259=>333,
8260=>167,8261=>383,8262=>383,8263=>888,8264=>777,8265=>777,8266=>500,8267=>453,8268=>453,8269=>450,
8270=>500,8271=>278,8272=>882,8273=>500,8274=>497,8275=>500,8276=>953,8277=>512,8278=>410,8279=>855,
8280=>620,8281=>620,8282=>179,8283=>621,8284=>564,8285=>179,8286=>179,8287=>111,8288=>0,8289=>0,
8290=>0,8291=>0,8292=>0,8304=>320,8305=>300,8308=>320,8309=>320,8310=>320,8311=>320,8312=>320,
8313=>320,8314=>300,8315=>300,8316=>300,8317=>216,8318=>216,8319=>300,8320=>320,8321=>320,8322=>320,
8323=>320,8324=>320,8325=>320,8326=>320,8327=>320,8328=>320,8329=>320,8330=>300,8331=>300,8332=>300,
8333=>216,8334=>216,8336=>320,8337=>320,8338=>320,8339=>320,8340=>320,8352=>698,8353=>667,8354=>667,
8355=>556,8356=>500,8357=>778,8358=>722,8359=>940,8360=>1026,8361=>813,8362=>869,8363=>512,8365=>722,
8366=>611,8367=>1340,8368=>489,8369=>601,8370=>619,8371=>722,8372=>556,8373=>611,8400=>0,8401=>0,
8402=>0,8403=>0,8404=>0,8405=>0,8406=>0,8407=>0,8408=>0,8409=>0,8410=>0,8411=>0,
8412=>0,8413=>0,8414=>0,8415=>0,8416=>0,8417=>0,8418=>0,8419=>0,8420=>0,8421=>0,
8422=>0,8423=>0,8424=>0,8425=>0,8426=>0,8427=>0,8428=>0,8429=>0,8430=>0,8431=>0,
8432=>0,8448=>751,8449=>723,8450=>674,8451=>954,8452=>556,8453=>781,8454=>806,8455=>518,8456=>667,
8457=>822,8458=>490,8459=>824,8460=>663,8461=>818,8462=>500,8463=>500,8464=>578,8465=>613,8466=>715,
8467=>417,8468=>778,8469=>751,8470=>880,8471=>760,8472=>832,8473=>589,8474=>729,8475=>892,8476=>711,
8477=>755,8478=>667,8479=>667,8480=>879,8481=>1156,8483=>722,8484=>659,8485=>389,8486=>743,8487=>757,
8488=>663,8489=>286,8490=>722,8491=>722,8492=>846,8493=>613,8494=>533,8495=>363,8496=>587,8497=>690,
8498=>556,8499=>1021,8500=>387,8501=>537,8502=>537,8503=>350,8504=>537,8505=>417,8506=>906,8507=>1155,
8513=>663,8514=>485,8515=>485,8516=>637,8522=>516,8523=>778,8525=>899,8526=>500,8531=>750,8532=>750,
8533=>750,8534=>750,8535=>750,8536=>750,8537=>750,8538=>750,8539=>750,8540=>750,8541=>750,8542=>750,
8543=>750,8544=>333,8545=>630,8546=>927,8547=>1019,8548=>722,8549=>1019,8550=>1316,8551=>1629,8552=>1019,
8553=>722,8554=>1019,8555=>1316,8556=>611,8557=>667,8558=>722,8559=>889,8560=>278,8561=>556,8562=>834,
8563=>778,8564=>500,8565=>778,8566=>1056,8567=>1334,8568=>778,8569=>500,8570=>778,8571=>1056,8572=>278,
8573=>444,8574=>500,8575=>778,8592=>964,8593=>472,8594=>964,8595=>500,8596=>964,8597=>499,8598=>964,
8599=>964,8600=>964,8601=>964,8602=>964,8603=>964,8604=>1009,8605=>1009,8606=>964,8607=>500,8608=>964,
8609=>499,8610=>1093,8611=>1093,8612=>1093,8613=>500,8614=>1093,8615=>500,8616=>500,8617=>964,8618=>964,
8619=>964,8620=>964,8621=>1151,8622=>964,8624=>482,8625=>482,8626=>482,8627=>482,8628=>658,8629=>658,
8630=>1069,8631=>1069,8634=>939,8635=>939,8636=>964,8637=>964,8638=>499,8639=>499,8640=>964,8641=>964,
8642=>499,8643=>499,8644=>964,8645=>840,8646=>964,8647=>964,8648=>840,8649=>964,8650=>840,8651=>964,
8652=>964,8653=>964,8654=>964,8655=>964,8656=>964,8657=>550,8658=>964,8659=>550,8660=>964,8661=>550,
8662=>1047,8663=>1047,8664=>1047,8665=>1047,8666=>964,8667=>964,8668=>1092,8669=>1092,8672=>964,8674=>964,
8704=>587,8705=>716,8706=>494,8707=>587,8708=>587,8709=>746,8710=>612,8711=>612,8712=>536,8713=>536,
8714=>439,8715=>536,8716=>536,8717=>439,8718=>506,8719=>823,8720=>823,8721=>713,8722=>564,8723=>564,
8724=>564,8725=>636,8726=>636,8727=>471,8728=>497,8729=>497,8730=>549,8731=>549,8732=>549,8733=>636,
8734=>853,8735=>509,8736=>575,8737=>559,8738=>509,8739=>200,8740=>250,8741=>320,8742=>320,8743=>564,
8744=>564,8745=>654,8746=>654,8747=>416,8748=>750,8749=>1083,8750=>722,8751=>750,8752=>1083,8753=>697,
8754=>722,8755=>722,8756=>565,8757=>568,8758=>250,8759=>629,8760=>564,8761=>758,8762=>564,8763=>636,
8764=>636,8765=>636,8766=>503,8767=>614,8768=>636,8769=>636,8770=>636,8771=>636,8772=>636,8773=>636,
8774=>636,8775=>636,8776=>636,8777=>636,8778=>636,8779=>636,8780=>636,8781=>636,8782=>636,8783=>636,
8784=>564,8785=>564,8786=>564,8787=>564,8788=>735,8789=>755,8790=>564,8791=>564,8792=>564,8793=>564,
8794=>564,8795=>564,8796=>600,8797=>564,8798=>564,8799=>564,8800=>564,8801=>636,8802=>636,8803=>636,
8804=>636,8805=>636,8806=>636,8807=>636,8808=>636,8809=>636,8810=>900,8811=>899,8812=>410,8813=>636,
8814=>636,8815=>636,8816=>636,8817=>636,8818=>636,8819=>636,8820=>636,8821=>636,8822=>636,8823=>636,
8824=>636,8825=>636,8826=>636,8827=>636,8828=>636,8829=>636,8830=>636,8831=>636,8832=>636,8833=>636,
8834=>636,8835=>636,8836=>636,8837=>636,8838=>636,8839=>636,8840=>636,8841=>636,8842=>636,8843=>636,
8844=>654,8845=>654,8846=>654,8847=>636,8848=>636,8849=>636,8850=>636,8851=>636,8852=>636,8853=>636,
8854=>636,8855=>636,8856=>636,8857=>636,8858=>636,8859=>636,8860=>636,8861=>636,8862=>636,8863=>636,
8864=>636,8865=>636,8866=>600,8867=>600,8868=>712,8869=>712,8870=>466,8871=>466,8872=>595,8873=>588,
8874=>710,8875=>706,8876=>595,8877=>596,8878=>588,8879=>706,8880=>636,8881=>636,8882=>636,8883=>636,
8884=>636,8885=>636,8886=>1296,8887=>1296,8888=>966,8889=>564,8890=>626,8891=>564,8892=>564,8893=>566,
8894=>570,8895=>582,8896=>744,8897=>744,8898=>764,8899=>764,8900=>512,8901=>250,8902=>471,8903=>629,
8904=>636,8905=>636,8906=>636,8907=>816,8908=>816,8909=>636,8910=>636,8911=>636,8912=>636,8913=>636,
8914=>654,8915=>654,8916=>654,8917=>636,8918=>564,8919=>564,8920=>1215,8921=>1215,8922=>636,8923=>636,
8924=>636,8925=>636,8926=>636,8927=>636,8928=>636,8929=>636,8930=>636,8931=>636,8932=>636,8933=>636,
8934=>636,8935=>636,8936=>636,8937=>636,8938=>636,8939=>636,8940=>636,8941=>636,8942=>250,8943=>1000,
8944=>1000,8945=>1000,8946=>601,8947=>536,8948=>464,8949=>536,8950=>536,8951=>464,8952=>536,8953=>536,
8954=>601,8955=>536,8956=>464,8957=>536,8958=>464,8959=>600,8960=>780,8961=>442,8962=>794,8968=>474,
8969=>474,8970=>474,8971=>474,8976=>564,8977=>503,8978=>791,8979=>791,8980=>593,8981=>560,8982=>563,
8983=>563,8984=>800,8985=>564,8986=>805,8988=>474,8989=>474,8990=>474,8991=>474,8992=>686,8993=>686,
8994=>658,8995=>658,8996=>800,9000=>800,9001=>329,9002=>329,9031=>777,9032=>777,9040=>777,9047=>777,
9054=>777,9088=>800,9089=>800,9090=>800,9091=>800,9094=>800,9095=>800,9096=>800,9097=>800,9098=>800,
9100=>800,9103=>788,9104=>788,9105=>788,9106=>788,9108=>800,9109=>800,9110=>800,9111=>800,9112=>800,
9113=>800,9114=>800,9115=>384,9116=>384,9117=>384,9118=>384,9119=>384,9120=>384,9121=>388,9122=>388,
9123=>388,9124=>388,9125=>388,9126=>388,9127=>494,9128=>494,9129=>494,9130=>494,9131=>494,9132=>494,
9133=>494,9134=>686,9138=>1287,9139=>1287,9140=>860,9141=>861,9166=>800,9167=>800,9180=>896,9181=>896,
9182=>903,9183=>904,9184=>910,9185=>910,9186=>761,9187=>910,9189=>942,9190=>817,9251=>500,9312=>788,
9313=>788,9314=>788,9315=>788,9316=>788,9317=>788,9318=>788,9319=>788,9320=>788,9321=>788,9472=>889,
9473=>889,9474=>889,9475=>889,9484=>889,9485=>889,9486=>889,9487=>889,9488=>889,9489=>889,9490=>889,
9491=>889,9492=>889,9493=>889,9494=>889,9495=>889,9496=>889,9497=>889,9498=>889,9499=>889,9500=>889,
9501=>889,9502=>889,9503=>889,9504=>889,9505=>889,9506=>889,9507=>889,9508=>889,9509=>889,9510=>889,
9511=>889,9512=>889,9513=>889,9514=>889,9515=>889,9516=>889,9517=>889,9518=>889,9519=>889,9520=>889,
9521=>889,9522=>889,9523=>889,9524=>889,9525=>889,9526=>889,9527=>889,9528=>889,9529=>889,9530=>889,
9531=>889,9532=>889,9533=>889,9534=>889,9535=>889,9536=>889,9537=>889,9538=>889,9539=>889,9540=>889,
9541=>889,9542=>889,9543=>889,9544=>889,9545=>889,9546=>889,9547=>889,9552=>889,9553=>889,9554=>889,
9555=>889,9556=>889,9557=>889,9558=>889,9559=>889,9560=>889,9561=>889,9562=>889,9563=>889,9564=>889,
9565=>889,9566=>889,9567=>889,9568=>889,9569=>889,9570=>889,9571=>889,9572=>889,9573=>889,9574=>889,
9575=>889,9576=>889,9577=>889,9578=>889,9579=>889,9580=>889,9581=>889,9582=>889,9583=>889,9584=>889,
9585=>889,9586=>889,9587=>889,9588=>889,9589=>889,9590=>889,9591=>889,9592=>889,9593=>889,9594=>889,
9595=>889,9596=>600,9597=>889,9598=>600,9599=>889,9600=>761,9601=>761,9602=>761,9603=>761,9604=>761,
9605=>761,9606=>761,9607=>761,9608=>761,9609=>761,9610=>761,9611=>761,9612=>761,9613=>761,9614=>761,
9615=>761,9616=>761,9617=>1000,9619=>1000,9620=>761,9621=>761,9622=>761,9623=>761,9624=>761,9625=>761,
9626=>761,9627=>761,9628=>761,9629=>761,9630=>761,9631=>761,9632=>761,9633=>761,9634=>761,9635=>761,
9636=>761,9637=>761,9638=>761,9639=>761,9640=>761,9641=>761,9642=>532,9643=>532,9644=>761,9645=>761,
9646=>761,9647=>761,9648=>761,9649=>761,9650=>892,9651=>892,9652=>446,9653=>446,9654=>892,9655=>892,
9656=>446,9657=>446,9658=>892,9659=>892,9660=>892,9661=>892,9662=>446,9663=>446,9664=>892,9665=>892,
9666=>446,9667=>446,9668=>892,9669=>892,9670=>788,9671=>788,9672=>788,9673=>791,9674=>494,9675=>791,
9676=>791,9677=>785,9678=>791,9679=>791,9680=>791,9681=>791,9682=>791,9683=>791,9684=>791,9685=>791,
9686=>791,9687=>791,9688=>761,9689=>761,9690=>761,9691=>761,9692=>791,9693=>791,9694=>791,9695=>791,
9696=>791,9697=>791,9698=>761,9699=>761,9700=>761,9701=>761,9702=>791,9703=>761,9704=>761,9705=>761,
9706=>761,9707=>761,9708=>892,9709=>892,9710=>892,9711=>851,9712=>761,9713=>761,9714=>761,9715=>761,
9716=>791,9717=>791,9718=>791,9719=>791,9720=>761,9721=>761,9722=>761,9723=>761,9724=>761,9725=>570,
9726=>570,9727=>761,9728=>800,9729=>800,9730=>748,9731=>800,9732=>800,9733=>811,9734=>816,9735=>468,
9736=>677,9737=>724,9738=>944,9739=>944,9740=>686,9741=>944,9742=>715,9743=>715,9744=>757,9745=>755,
9746=>755,9747=>756,9748=>800,9749=>837,9750=>719,9751=>719,9752=>782,9753=>822,9754=>954,9755=>954,
9756=>933,9757=>489,9758=>933,9759=>489,9760=>517,9761=>660,9762=>724,9763=>732,9764=>886,9765=>577,
9766=>489,9767=>563,9768=>490,9769=>770,9770=>725,9771=>860,9772=>668,9773=>753,9774=>724,9775=>730,
9776=>600,9777=>600,9778=>600,9779=>600,9780=>600,9781=>600,9782=>600,9783=>600,9784=>730,9785=>724,
9786=>724,9787=>724,9788=>799,9789=>659,9790=>659,9791=>495,9792=>495,9793=>495,9794=>686,9795=>661,
9796=>544,9797=>608,9798=>605,9799=>545,9800=>804,9801=>583,9802=>796,9803=>1006,9804=>825,9805=>1189,
9806=>1144,9807=>1189,9808=>683,9809=>808,9810=>1146,9811=>797,9812=>758,9813=>757,9814=>758,9815=>758,
9816=>758,9817=>758,9818=>758,9819=>758,9820=>758,9821=>758,9822=>758,9823=>758,9824=>770,9825=>770,
9826=>770,9827=>770,9828=>770,9829=>770,9830=>770,9831=>770,9832=>895,9833=>333,9834=>555,9835=>722,
9836=>722,9837=>415,9838=>377,9839=>402,9840=>642,9841=>655,9842=>869,9843=>905,9844=>905,9845=>905,
9846=>905,9847=>905,9848=>905,9849=>905,9850=>905,9851=>1016,9852=>1064,9853=>1064,9854=>954,9855=>606,
9856=>522,9857=>522,9858=>522,9859=>522,9860=>522,9861=>522,9862=>845,9863=>844,9864=>844,9865=>844,
9866=>748,9867=>748,9868=>748,9869=>748,9870=>748,9871=>748,9872=>726,9873=>726,9874=>963,9875=>770,
9876=>1038,9877=>388,9878=>997,9879=>787,9880=>508,9881=>809,9882=>1014,9883=>859,9884=>818,9885=>972,
9888=>1000,9889=>546,9890=>784,9891=>786,9892=>738,9893=>542,9894=>601,9895=>700,9896=>511,9897=>861,
9898=>611,9899=>611,9900=>544,9901=>782,9902=>1025,9903=>1141,9904=>1000,9905=>513,9906=>510,9907=>642,
9908=>722,9909=>719,9910=>777,9911=>495,9912=>602,9913=>836,9914=>666,9915=>666,9916=>691,9920=>689,
9921=>689,9922=>689,9923=>689,9985=>974,9986=>961,9987=>974,9988=>980,9990=>789,9991=>790,9992=>791,
9993=>690,9996=>549,9997=>855,9998=>911,9999=>933,10000=>911,10001=>945,10002=>974,10003=>755,10004=>846,
10005=>762,10006=>761,10007=>571,10008=>677,10009=>763,10010=>760,10011=>759,10012=>754,10013=>494,10014=>552,
10015=>537,10016=>577,10017=>692,10018=>786,10019=>788,10020=>788,10021=>790,10022=>793,10023=>794,10025=>823,
10026=>789,10027=>841,10028=>823,10029=>833,10030=>816,10031=>831,10032=>923,10033=>744,10034=>723,10035=>749,
10036=>790,10037=>792,10038=>695,10039=>776,10040=>768,10041=>792,10042=>759,10043=>707,10044=>708,10045=>682,
10046=>701,10047=>826,10048=>815,10049=>789,10050=>789,10051=>707,10052=>687,10053=>696,10054=>689,10055=>786,
10056=>787,10057=>713,10058=>791,10059=>785,10061=>873,10063=>762,10064=>762,10065=>759,10066=>759,10070=>784,
10072=>138,10073=>277,10074=>415,10075=>392,10076=>392,10077=>668,10078=>668,10081=>732,10082=>544,10083=>544,
10084=>910,10085=>667,10086=>760,10087=>760,10088=>390,10089=>390,10090=>317,10091=>317,10092=>276,10093=>276,
10094=>509,10095=>509,10096=>410,10097=>410,10098=>234,10099=>234,10100=>334,10101=>334,10102=>788,10103=>788,
10104=>788,10105=>788,10106=>788,10107=>788,10108=>788,10109=>788,10110=>788,10111=>788,10112=>788,10113=>788,
10114=>788,10115=>788,10116=>788,10117=>788,10118=>788,10119=>788,10120=>788,10121=>788,10122=>788,10123=>788,
10124=>788,10125=>788,10126=>788,10127=>788,10128=>788,10129=>788,10130=>788,10131=>788,10132=>894,10136=>748,
10137=>924,10138=>748,10139=>918,10140=>927,10141=>928,10142=>928,10143=>834,10144=>873,10145=>828,10146=>924,
10147=>924,10148=>917,10149=>930,10150=>931,10151=>463,10152=>883,10153=>836,10154=>836,10155=>867,10156=>867,
10157=>696,10158=>696,10159=>874,10161=>874,10162=>760,10163=>946,10164=>771,10165=>865,10166=>771,10167=>888,
10168=>967,10169=>888,10170=>831,10171=>873,10172=>927,10173=>970,10174=>918,10214=>545,10215=>545,10216=>329,
10217=>329,10218=>496,10219=>496,10229=>1000,10230=>1000,10231=>1000,10232=>1000,10233=>1000,10234=>1000,10235=>1000,
10236=>1000,10752=>860,10753=>860,10754=>860,10755=>766,10756=>766,10757=>756,10758=>756,10761=>745,10781=>702,
10815=>722,11008=>1000,11009=>1000,11010=>1000,11011=>1000,11012=>1222,11013=>1000,11014=>1000,11015=>1000,11016=>1000,
11017=>1000,11018=>1000,11019=>1000,11020=>1244,11021=>1000,11026=>770,11027=>770,11028=>770,11029=>770,11030=>770,
11031=>770,11032=>770,11033=>770,11034=>770,11035=>1000,11036=>1000,11037=>283,11038=>283,11039=>846,11040=>846,
11041=>799,11042=>799,11043=>807,11044=>1000,11045=>461,11046=>461,11047=>461,11048=>461,11049=>360,11050=>360,
11051=>283,11052=>854,11053=>854,11054=>628,11055=>628,11088=>589,11089=>443,11090=>443,11091=>802,11092=>803,
11392=>677,11393=>463,11394=>532,11395=>381,11396=>615,11397=>438,11398=>969,11399=>660,11400=>647,11401=>440,
11402=>593,11403=>402,11404=>573,11405=>407,11406=>698,11407=>512,11408=>726,11409=>493,11410=>267,11411=>201,
11412=>610,11413=>433,11414=>654,11415=>468,11416=>735,11417=>536,11418=>698,11419=>511,11420=>555,11421=>378,
11422=>722,11423=>489,11424=>724,11425=>528,11426=>517,11427=>388,11428=>647,11429=>438,11430=>615,11431=>436,
11432=>651,11433=>462,11434=>762,11435=>538,11436=>654,11437=>461,11438=>635,11439=>461,11440=>964,11441=>677,
11456=>689,11457=>464,11493=>499,11494=>496,11495=>986,11496=>466,11497=>444,11498=>934,11517=>256,11518=>617,
11519=>287,11799=>333,42560=>611,42561=>444,42562=>611,42563=>444,42564=>556,42565=>389,42566=>368,42567=>286,
42572=>1145,42573=>775,42576=>1016,42577=>736,42578=>915,42579=>684,42580=>966,42581=>664,42582=>1042,42583=>648,
42584=>722,42585=>491,42588=>1042,42589=>648,42590=>780,42591=>550,42594=>911,42595=>633,42596=>957,42597=>635,
42598=>1139,42599=>777,42607=>0,42608=>0,42609=>0,42610=>0,42611=>519,42620=>0,42622=>510,64256=>589,
64257=>534,64258=>530,64259=>805,64260=>799,64262=>677,64285=>350,64286=>0,64287=>537,64288=>537,64297=>564,
64298=>537,64299=>537,64300=>537,64301=>537,64302=>537,64303=>537,64304=>537,64305=>537,64306=>350,64307=>537,
64308=>537,64309=>350,64310=>350,64312=>537,64313=>350,64314=>537,64315=>537,64316=>537,64318=>537,64320=>350,
64321=>537,64323=>537,64324=>537,64326=>537,64327=>537,64328=>537,64329=>537,64330=>537,64331=>350,64332=>537,
64333=>537,64334=>537,64335=>537,64342=>926,64343=>926,64344=>308,64345=>308,64378=>750,64379=>750,64380=>580,
64381=>580,64394=>338,64395=>338,64402=>874,64403=>874,64404=>329,64405=>329,64508=>776,64509=>700,64510=>304,
64511=>304,65010=>640,65020=>837,65136=>300,65140=>300,65142=>300,65144=>300,65146=>300,65148=>300,65152=>724,
65153=>321,65154=>275,65155=>249,65156=>275,65157=>399,65158=>399,65159=>249,65160=>275,65161=>776,65162=>776,
65163=>301,65164=>264,65165=>249,65166=>275,65167=>950,65168=>950,65169=>293,65170=>293,65171=>424,65172=>622,
65173=>925,65174=>925,65175=>308,65176=>308,65177=>924,65178=>924,65179=>298,65180=>298,65181=>738,65182=>738,
65183=>574,65184=>574,65185=>748,65186=>750,65187=>600,65188=>600,65189=>701,65190=>775,65191=>596,65192=>596,
65193=>397,65194=>397,65195=>399,65196=>399,65197=>328,65198=>328,65199=>331,65200=>331,65201=>951,65202=>951,
65203=>600,65204=>600,65205=>949,65206=>949,65207=>649,65208=>649,65209=>949,65210=>949,65211=>823,65212=>823,
65213=>949,65214=>949,65215=>805,65216=>805,65217=>557,65218=>557,65219=>460,65220=>460,65221=>550,65222=>550,
65223=>455,65224=>550,65225=>625,65226=>575,65227=>674,65228=>550,65229=>602,65230=>577,65231=>578,65232=>577,
65233=>801,65234=>801,65235=>300,65236=>300,65237=>696,65238=>696,65239=>650,65240=>650,65241=>757,65242=>757,
65243=>318,65244=>318,65245=>655,65246=>655,65247=>206,65248=>206,65249=>549,65250=>549,65251=>403,65252=>403,
65253=>651,65254=>651,65255=>323,65256=>323,65257=>424,65258=>622,65259=>525,65260=>476,65261=>399,65262=>399,
65263=>776,65264=>776,65265=>776,65266=>776,65267=>296,65268=>264,65269=>676,65270=>724,65271=>676,65272=>724,
65273=>676,65274=>724,65275=>676,65276=>724,65279=>0,65533=>788);
$enc='';
$diff='';
$file='freeserif.z';
$ctg='freeserif.ctg.z';
$originalsize=1483772;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/freeserif.php | PHP | asf20 | 48,954 |
<?php
// core font definition file for TCPDF (www.tcpdf.org)
$type='core';
$dw=600;
$cw=array(0=>600,1=>600,2=>600,3=>600,4=>600,5=>600,6=>600,7=>600,8=>600,9=>600,
10=>600,11=>600,12=>600,13=>600,14=>600,15=>600,16=>600,17=>600,18=>600,19=>600,
20=>600,21=>600,22=>600,23=>600,24=>600,25=>600,26=>600,27=>600,28=>600,29=>600,
30=>600,31=>600,32=>600,33=>600,34=>600,35=>600,36=>600,37=>600,38=>600,39=>600,
40=>600,41=>600,42=>600,43=>600,44=>600,45=>600,46=>600,47=>600,48=>600,49=>600,
50=>600,51=>600,52=>600,53=>600,54=>600,55=>600,56=>600,57=>600,58=>600,59=>600,
60=>600,61=>600,62=>600,63=>600,64=>600,65=>600,66=>600,67=>600,68=>600,69=>600,
70=>600,71=>600,72=>600,73=>600,74=>600,75=>600,76=>600,77=>600,78=>600,79=>600,
80=>600,81=>600,82=>600,83=>600,84=>600,85=>600,86=>600,87=>600,88=>600,89=>600,
90=>600,91=>600,92=>600,93=>600,94=>600,95=>600,96=>600,97=>600,98=>600,99=>600,
100=>600,101=>600,102=>600,103=>600,104=>600,105=>600,106=>600,107=>600,108=>600,
109=>600,110=>600,111=>600,112=>600,113=>600,114=>600,115=>600,116=>600,117=>600,
118=>600,119=>600,120=>600,121=>600,122=>600,123=>600,124=>600,125=>600,126=>600,
127=>600,128=>600,129=>600,130=>600,131=>600,132=>600,133=>600,134=>600,135=>600,
136=>600,137=>600,138=>600,139=>600,140=>600,141=>600,142=>600,143=>600,144=>600,
145=>600,146=>600,147=>600,148=>600,149=>600,150=>600,151=>600,152=>600,153=>600,
154=>600,155=>600,156=>600,157=>600,158=>600,159=>600,160=>600,161=>600,162=>600,
163=>600,164=>600,165=>600,166=>600,167=>600,168=>600,169=>600,170=>600,171=>600,
172=>600,173=>600,174=>600,175=>600,176=>600,177=>600,178=>600,179=>600,180=>600,
181=>600,182=>600,183=>600,184=>600,185=>600,186=>600,187=>600,188=>600,189=>600,
190=>600,191=>600,192=>600,193=>600,194=>600,195=>600,196=>600,197=>600,198=>600,
199=>600,200=>600,201=>600,202=>600,203=>600,204=>600,205=>600,206=>600,207=>600,
208=>600,209=>600,210=>600,211=>600,212=>600,213=>600,214=>600,215=>600,216=>600,
217=>600,218=>600,219=>600,220=>600,221=>600,222=>600,223=>600,224=>600,225=>600,
226=>600,227=>600,228=>600,229=>600,230=>600,231=>600,232=>600,233=>600,234=>600,
235=>600,236=>600,237=>600,238=>600,239=>600,240=>600,241=>600,242=>600,243=>600,
244=>600,245=>600,246=>600,247=>600,248=>600,249=>600,250=>600,251=>600,252=>600,
253=>600,254=>600,255=>600);
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/courier.php | PHP | asf20 | 2,333 |
<?php
$type='TrueTypeUnicode';
$name='DejaVuSans-Bold';
$desc=array('Ascent'=>928,'Descent'=>-236,'CapHeight'=>19,'Flags'=>32,'FontBBox'=>'[-1069 -385 1975 1174]','ItalicAngle'=>0,'StemV'=>120,'MissingWidth'=>600);
$up=-63;
$ut=44;
$dw=600;
$cw=array(
0=>600,32=>348,33=>456,34=>521,35=>838,36=>696,37=>1002,38=>872,39=>306,40=>457,
41=>457,42=>523,43=>838,44=>380,45=>415,46=>380,47=>365,48=>696,49=>696,50=>696,
51=>696,52=>696,53=>696,54=>696,55=>696,56=>696,57=>696,58=>400,59=>400,60=>838,
61=>838,62=>838,63=>580,64=>1000,65=>774,66=>762,67=>734,68=>830,69=>683,70=>683,
71=>821,72=>837,73=>372,74=>372,75=>775,76=>637,77=>995,78=>837,79=>850,80=>733,
81=>850,82=>770,83=>720,84=>682,85=>812,86=>774,87=>1103,88=>771,89=>724,90=>725,
91=>457,92=>365,93=>457,94=>838,95=>500,96=>500,97=>675,98=>716,99=>593,100=>716,
101=>678,102=>435,103=>716,104=>712,105=>343,106=>343,107=>665,108=>343,109=>1042,110=>712,
111=>687,112=>716,113=>716,114=>493,115=>595,116=>478,117=>712,118=>652,119=>924,120=>645,
121=>652,122=>582,123=>712,124=>365,125=>712,126=>838,8364=>696,8218=>380,402=>435,8222=>657,
8230=>1000,8224=>500,8225=>500,710=>500,8240=>1440,352=>720,8249=>412,338=>1167,381=>725,8216=>380,
8217=>380,8220=>657,8221=>657,8226=>639,8211=>500,8212=>1000,732=>500,8482=>1000,353=>595,8250=>412,
339=>1094,382=>582,376=>724,160=>348,161=>456,162=>696,163=>696,164=>636,165=>696,166=>365,
167=>500,168=>500,169=>1000,170=>564,171=>646,172=>838,173=>415,174=>1000,175=>500,176=>500,
177=>838,178=>438,179=>438,180=>500,181=>736,182=>636,183=>380,184=>500,185=>438,186=>564,
187=>646,188=>1035,189=>1035,190=>1035,191=>580,192=>774,193=>774,194=>774,195=>774,196=>774,
197=>774,198=>1085,199=>734,200=>683,201=>683,202=>683,203=>683,204=>372,205=>372,206=>372,
207=>372,208=>838,209=>837,210=>850,211=>850,212=>850,213=>850,214=>850,215=>838,216=>850,
217=>812,218=>812,219=>812,220=>812,221=>724,222=>738,223=>719,224=>675,225=>675,226=>675,
227=>675,228=>675,229=>675,230=>1048,231=>593,232=>678,233=>678,234=>678,235=>678,236=>343,
237=>343,238=>343,239=>343,240=>687,241=>712,242=>687,243=>687,244=>687,245=>687,246=>687,
247=>838,248=>687,249=>712,250=>712,251=>712,252=>712,253=>652,254=>716,255=>652,256=>774,
257=>675,258=>774,259=>675,260=>774,261=>675,262=>734,263=>593,264=>734,265=>593,266=>734,
267=>593,268=>734,269=>593,270=>830,271=>716,272=>838,273=>716,274=>683,275=>678,276=>683,
277=>678,278=>683,279=>678,280=>683,281=>678,282=>683,283=>678,284=>821,285=>716,286=>821,
287=>716,288=>821,289=>716,290=>821,291=>716,292=>837,293=>712,294=>974,295=>790,296=>372,
297=>343,298=>372,299=>343,300=>372,301=>343,302=>372,303=>343,304=>372,305=>343,306=>744,
307=>686,308=>372,309=>343,310=>775,311=>665,312=>665,313=>637,314=>343,315=>637,316=>343,
317=>637,318=>479,319=>637,320=>557,321=>642,322=>371,323=>837,324=>712,325=>837,326=>712,
327=>837,328=>712,329=>983,330=>837,331=>712,332=>850,333=>687,334=>850,335=>687,336=>850,
337=>687,340=>770,341=>493,342=>770,343=>493,344=>770,345=>493,346=>720,347=>595,348=>720,
349=>595,350=>720,351=>595,354=>682,355=>478,356=>682,357=>478,358=>682,359=>478,360=>812,
361=>712,362=>812,363=>712,364=>812,365=>712,366=>812,367=>712,368=>812,369=>712,370=>812,
371=>712,372=>1103,373=>924,374=>724,375=>652,377=>725,378=>582,379=>725,380=>582,383=>435,
384=>716,385=>811,386=>762,387=>716,388=>762,389=>716,390=>734,391=>734,392=>593,393=>838,
394=>879,395=>757,396=>716,397=>688,398=>683,399=>849,400=>696,401=>683,403=>821,404=>793,
405=>1045,406=>436,407=>389,408=>775,409=>665,410=>360,411=>592,412=>1042,413=>837,414=>712,
415=>850,416=>874,417=>687,418=>1083,419=>912,420=>782,421=>716,422=>770,423=>720,424=>595,
425=>683,426=>552,427=>478,428=>707,429=>478,430=>682,431=>835,432=>712,433=>850,434=>813,
435=>797,436=>778,437=>725,438=>582,439=>772,440=>772,441=>641,442=>582,443=>696,444=>772,
445=>641,446=>573,447=>716,448=>372,449=>659,450=>544,451=>372,452=>1555,453=>1412,454=>1298,
455=>1009,456=>980,457=>686,458=>1209,459=>1180,460=>1055,461=>774,462=>675,463=>372,464=>343,
465=>850,466=>687,467=>812,468=>712,469=>812,470=>712,471=>812,472=>712,473=>812,474=>712,
475=>812,476=>712,477=>678,478=>774,479=>675,480=>774,481=>675,482=>1085,483=>1048,484=>821,
485=>716,486=>821,487=>716,488=>775,489=>665,490=>850,491=>687,492=>850,493=>687,494=>772,
495=>582,496=>343,497=>1555,498=>1412,499=>1298,500=>821,501=>716,502=>1289,503=>787,504=>837,
505=>712,506=>774,507=>675,508=>1085,509=>1048,510=>850,511=>687,512=>774,513=>675,514=>774,
515=>675,516=>683,517=>678,518=>683,519=>678,520=>372,521=>343,522=>372,523=>343,524=>850,
525=>687,526=>850,527=>687,528=>770,529=>493,530=>770,531=>493,532=>812,533=>712,534=>812,
535=>712,536=>720,537=>595,538=>682,539=>478,540=>690,541=>607,542=>837,543=>712,544=>837,
545=>865,546=>809,547=>659,548=>725,549=>582,550=>774,551=>675,552=>683,553=>678,554=>850,
555=>687,556=>850,557=>687,558=>850,559=>687,560=>850,561=>687,562=>724,563=>652,564=>492,
565=>867,566=>512,567=>343,568=>1088,569=>1088,570=>774,571=>734,572=>593,573=>637,574=>682,
575=>595,576=>582,577=>782,578=>614,579=>762,580=>812,581=>774,582=>683,583=>678,584=>372,
585=>343,586=>860,587=>791,588=>770,589=>493,590=>724,591=>652,592=>675,593=>716,594=>716,
595=>716,596=>593,597=>593,598=>717,599=>792,600=>678,601=>678,602=>876,603=>557,604=>545,
605=>815,606=>731,607=>343,608=>792,609=>716,610=>627,611=>644,612=>635,613=>712,614=>712,
615=>712,616=>545,617=>440,618=>545,619=>559,620=>693,621=>343,622=>841,623=>1042,624=>1042,
625=>1042,626=>712,627=>793,628=>707,629=>687,630=>909,631=>681,632=>796,633=>538,634=>538,
635=>650,636=>493,637=>493,638=>596,639=>596,640=>642,641=>642,642=>595,643=>415,644=>435,
645=>605,646=>552,647=>478,648=>478,649=>920,650=>772,651=>670,652=>652,653=>924,654=>652,
655=>724,656=>694,657=>684,658=>641,659=>641,660=>573,661=>573,662=>573,663=>573,664=>850,
665=>633,666=>731,667=>685,668=>691,669=>343,670=>732,671=>539,672=>792,673=>573,674=>573,
675=>1156,676=>1214,677=>1155,678=>974,679=>769,680=>929,681=>1026,682=>792,683=>780,684=>591,
685=>415,686=>677,687=>789,688=>456,689=>456,690=>219,691=>315,692=>315,693=>315,694=>411,
695=>591,696=>417,697=>302,698=>521,699=>380,700=>380,701=>380,702=>366,703=>366,704=>326,
705=>326,706=>500,707=>500,708=>500,709=>500,711=>500,712=>306,713=>500,714=>500,715=>500,
716=>306,717=>500,718=>500,719=>500,720=>337,721=>337,722=>366,723=>366,724=>500,725=>500,
726=>416,727=>328,728=>500,729=>500,730=>500,731=>500,733=>500,734=>351,735=>500,736=>412,
737=>219,738=>381,739=>413,740=>326,741=>500,742=>500,743=>500,744=>500,745=>500,748=>500,
749=>500,750=>657,755=>500,759=>500,768=>0,769=>0,770=>0,771=>0,772=>0,773=>0,
774=>0,775=>0,776=>0,777=>0,778=>0,779=>0,780=>0,781=>0,782=>0,783=>0,
784=>0,785=>0,786=>0,787=>0,788=>0,789=>0,790=>0,791=>0,792=>0,793=>0,
794=>0,795=>0,796=>0,797=>0,798=>0,799=>0,800=>0,801=>0,802=>0,803=>0,
804=>0,805=>0,806=>0,807=>0,808=>0,809=>0,810=>0,811=>0,812=>0,813=>0,
814=>0,815=>0,816=>0,817=>0,818=>0,819=>0,820=>0,821=>0,822=>0,823=>0,
824=>0,825=>0,826=>0,827=>0,828=>0,829=>0,830=>0,831=>0,832=>0,833=>0,
834=>0,835=>0,836=>0,837=>0,838=>0,839=>0,840=>0,841=>0,842=>0,843=>0,
844=>0,845=>0,846=>0,847=>0,849=>0,850=>0,851=>0,855=>0,856=>0,858=>0,
860=>0,861=>0,862=>0,863=>0,864=>0,865=>0,866=>0,880=>698,881=>565,882=>1022,
883=>836,884=>302,885=>302,886=>837,887=>701,890=>500,891=>593,892=>550,893=>549,894=>400,
900=>441,901=>500,902=>797,903=>380,904=>846,905=>1009,906=>563,908=>891,910=>980,911=>894,
912=>390,913=>774,914=>762,915=>637,916=>774,917=>683,918=>725,919=>837,920=>850,921=>372,
922=>775,923=>774,924=>995,925=>837,926=>632,927=>850,928=>837,929=>733,931=>683,932=>682,
933=>724,934=>850,935=>771,936=>850,937=>850,938=>372,939=>724,940=>687,941=>557,942=>712,
943=>390,944=>675,945=>687,946=>716,947=>681,948=>687,949=>557,950=>591,951=>712,952=>687,
953=>390,954=>710,955=>633,956=>736,957=>681,958=>591,959=>687,960=>791,961=>716,962=>593,
963=>779,964=>638,965=>675,966=>782,967=>645,968=>794,969=>869,970=>390,971=>675,972=>687,
973=>675,974=>869,975=>775,976=>651,977=>661,978=>746,979=>981,980=>746,981=>796,982=>869,
983=>744,984=>850,985=>687,986=>734,987=>593,988=>683,989=>494,990=>702,991=>660,992=>919,
993=>627,994=>1093,995=>837,996=>832,997=>716,998=>928,999=>744,1000=>733,1001=>650,1002=>789,
1003=>671,1004=>752,1005=>716,1006=>682,1007=>590,1008=>744,1009=>716,1010=>593,1011=>343,1012=>850,
1013=>645,1014=>644,1015=>738,1016=>716,1017=>734,1018=>995,1019=>732,1020=>716,1021=>698,1022=>734,
1023=>698,1024=>683,1025=>683,1026=>878,1027=>637,1028=>734,1029=>720,1030=>372,1031=>372,1032=>372,
1033=>1154,1034=>1130,1035=>878,1036=>817,1037=>837,1038=>771,1039=>837,1040=>774,1041=>762,1042=>762,
1043=>637,1044=>891,1045=>683,1046=>1224,1047=>710,1048=>837,1049=>837,1050=>817,1051=>831,1052=>995,
1053=>837,1054=>850,1055=>837,1056=>733,1057=>734,1058=>682,1059=>771,1060=>992,1061=>771,1062=>928,
1063=>808,1064=>1235,1065=>1326,1066=>939,1067=>1036,1068=>762,1069=>734,1070=>1174,1071=>770,1072=>675,
1073=>698,1074=>633,1075=>522,1076=>808,1077=>678,1078=>995,1079=>581,1080=>701,1081=>701,1082=>679,
1083=>732,1084=>817,1085=>691,1086=>687,1087=>691,1088=>716,1089=>593,1090=>580,1091=>652,1092=>992,
1093=>645,1094=>741,1095=>687,1096=>1062,1097=>1105,1098=>751,1099=>904,1100=>632,1101=>593,1102=>972,
1103=>642,1104=>678,1105=>678,1106=>714,1107=>522,1108=>593,1109=>595,1110=>343,1111=>343,1112=>343,
1113=>991,1114=>956,1115=>734,1116=>679,1117=>701,1118=>652,1119=>691,1120=>1093,1121=>869,1122=>840,
1123=>736,1124=>1012,1125=>839,1126=>992,1127=>832,1128=>1358,1129=>1121,1130=>850,1131=>687,1132=>1236,
1133=>1007,1134=>696,1135=>557,1136=>1075,1137=>1061,1138=>850,1139=>687,1140=>850,1141=>695,1142=>850,
1143=>695,1144=>1148,1145=>1043,1146=>1074,1147=>863,1148=>1405,1149=>1173,1150=>1093,1151=>869,1152=>734,
1153=>593,1154=>652,1155=>0,1156=>0,1157=>0,1158=>0,1159=>0,1160=>418,1161=>418,1162=>957,
1163=>807,1164=>762,1165=>611,1166=>733,1167=>716,1168=>637,1169=>522,1170=>666,1171=>543,1172=>808,
1173=>669,1174=>1224,1175=>995,1176=>710,1177=>581,1178=>775,1179=>679,1180=>817,1181=>679,1182=>817,
1183=>679,1184=>1015,1185=>826,1186=>956,1187=>808,1188=>1103,1189=>874,1190=>1273,1191=>1017,1192=>952,
1193=>858,1194=>734,1195=>593,1196=>682,1197=>580,1198=>724,1199=>652,1200=>724,1201=>652,1202=>771,
1203=>645,1204=>1112,1205=>1000,1206=>808,1207=>687,1208=>808,1209=>687,1210=>808,1211=>712,1212=>1026,
1213=>810,1214=>1026,1215=>810,1216=>372,1217=>1224,1218=>995,1219=>775,1220=>630,1221=>951,1222=>805,
1223=>837,1224=>691,1225=>957,1226=>807,1227=>808,1228=>687,1229=>1115,1230=>933,1231=>343,1232=>774,
1233=>675,1234=>774,1235=>675,1236=>1085,1237=>1048,1238=>683,1239=>678,1240=>849,1241=>678,1242=>849,
1243=>678,1244=>1224,1245=>995,1246=>710,1247=>581,1248=>772,1249=>641,1250=>837,1251=>701,1252=>837,
1253=>701,1254=>850,1255=>687,1256=>850,1257=>687,1258=>850,1259=>687,1260=>734,1261=>593,1262=>771,
1263=>652,1264=>771,1265=>652,1266=>771,1267=>652,1268=>808,1269=>687,1270=>637,1271=>522,1272=>1036,
1273=>904,1274=>666,1275=>543,1276=>771,1277=>645,1278=>771,1279=>645,1280=>762,1281=>608,1282=>1159,
1283=>893,1284=>1119,1285=>920,1286=>828,1287=>693,1288=>1242,1289=>1017,1290=>1289,1291=>1013,1292=>839,
1293=>638,1294=>938,1295=>803,1296=>696,1297=>557,1298=>831,1299=>732,1300=>1286,1301=>1068,1302=>1065,
1303=>979,1304=>1082,1305=>1013,1306=>850,1307=>716,1308=>1103,1309=>924,1312=>1267,1313=>1059,1314=>1273,
1315=>1017,1316=>957,1317=>807,1329=>984,1330=>812,1331=>984,1332=>984,1333=>812,1334=>777,1335=>812,
1336=>812,1337=>975,1338=>984,1339=>812,1340=>710,1341=>1078,1342=>1136,1343=>812,1344=>710,1345=>757,
1346=>984,1347=>876,1348=>984,1349=>793,1350=>984,1351=>812,1352=>812,1353=>812,1354=>958,1355=>777,
1356=>984,1357=>812,1358=>984,1359=>720,1360=>812,1361=>793,1362=>895,1363=>850,1364=>936,1365=>850,
1366=>720,1369=>366,1370=>380,1371=>550,1372=>550,1373=>380,1374=>546,1375=>521,1377=>1042,1378=>712,
1379=>866,1380=>868,1381=>712,1382=>817,1383=>653,1384=>712,1385=>811,1386=>817,1387=>712,1388=>498,
1389=>1018,1390=>716,1391=>712,1392=>712,1393=>716,1394=>819,1395=>712,1396=>751,1397=>343,1398=>882,
1399=>559,1400=>712,1401=>559,1402=>1042,1403=>559,1404=>863,1405=>712,1406=>813,1407=>1042,1408=>712,
1409=>716,1410=>571,1411=>1042,1412=>778,1413=>687,1414=>720,1415=>862,1417=>400,1418=>487,1456=>0,
1457=>0,1458=>0,1459=>0,1460=>0,1461=>0,1462=>0,1463=>0,1464=>0,1465=>0,1466=>0,
1467=>0,1468=>0,1469=>0,1470=>415,1471=>0,1472=>372,1473=>0,1474=>0,1475=>372,1478=>497,
1479=>0,1488=>751,1489=>673,1490=>537,1491=>654,1492=>712,1493=>343,1494=>491,1495=>712,1496=>724,
1497=>343,1498=>649,1499=>650,1500=>679,1501=>712,1502=>775,1503=>343,1504=>497,1505=>773,1506=>678,
1507=>718,1508=>687,1509=>628,1510=>751,1511=>729,1512=>649,1513=>949,1514=>751,1520=>664,1521=>664,
1522=>663,1523=>444,1524=>710,1542=>667,1543=>667,1545=>884,1546=>1157,1548=>380,1557=>0,1563=>400,
1567=>580,1569=>511,1570=>343,1571=>343,1572=>622,1573=>343,1574=>917,1575=>343,1576=>1005,1577=>590,
1578=>1005,1579=>1005,1580=>721,1581=>721,1582=>721,1583=>513,1584=>513,1585=>576,1586=>576,1587=>1380,
1588=>1380,1589=>1345,1590=>1345,1591=>1039,1592=>1039,1593=>683,1594=>683,1600=>342,1601=>1162,1602=>894,
1603=>917,1604=>868,1605=>733,1606=>854,1607=>590,1608=>622,1609=>917,1610=>917,1611=>0,1612=>0,
1613=>0,1614=>0,1615=>0,1616=>0,1617=>0,1618=>0,1619=>0,1620=>0,1621=>0,1626=>500,
1632=>610,1633=>610,1634=>610,1635=>610,1636=>610,1637=>610,1638=>610,1639=>610,1640=>610,1641=>610,
1642=>610,1643=>374,1644=>380,1645=>545,1646=>1005,1647=>894,1652=>292,1657=>1005,1658=>1005,1659=>1005,
1660=>1005,1661=>1005,1662=>1005,1663=>1005,1664=>1005,1665=>721,1666=>721,1667=>721,1668=>721,1669=>721,
1670=>721,1671=>721,1681=>576,1682=>576,1685=>681,1688=>576,1697=>1162,1700=>1162,1702=>1162,1705=>1024,
1711=>1024,1717=>868,1722=>854,1727=>721,1734=>622,1740=>917,1742=>917,1749=>590,1776=>610,1777=>610,
1778=>610,1779=>610,1780=>610,1781=>610,1782=>610,1783=>610,1784=>610,1785=>610,1984=>696,1985=>696,
1986=>696,1987=>696,1988=>696,1989=>696,1990=>696,1991=>696,1992=>696,1993=>696,1994=>343,1995=>547,
1996=>543,1997=>652,1998=>691,1999=>691,2000=>594,2001=>691,2002=>904,2003=>551,2004=>551,2005=>627,
2006=>688,2007=>444,2008=>1022,2009=>506,2010=>826,2011=>691,2012=>652,2013=>912,2014=>627,2015=>707,
2016=>506,2017=>652,2018=>574,2019=>627,2020=>627,2021=>627,2022=>574,2023=>574,2027=>0,2028=>0,
2029=>0,2030=>0,2031=>0,2032=>0,2033=>0,2034=>0,2035=>0,2036=>380,2037=>380,2040=>691,
2041=>691,2042=>415,3647=>743,3713=>790,3714=>748,3716=>749,3719=>569,3720=>742,3722=>744,3725=>761,
3732=>706,3733=>704,3734=>747,3735=>819,3737=>730,3738=>727,3739=>727,3740=>922,3741=>827,3742=>866,
3743=>866,3745=>836,3746=>761,3747=>770,3749=>769,3751=>713,3754=>827,3755=>1031,3757=>724,3758=>784,
3759=>934,3760=>688,3761=>0,3762=>610,3763=>610,3764=>0,3765=>0,3766=>0,3767=>0,3768=>0,
3769=>0,3771=>0,3772=>0,3773=>670,3776=>516,3777=>860,3778=>516,3779=>650,3780=>632,3782=>759,
3784=>0,3785=>0,3786=>0,3787=>0,3788=>0,3789=>0,3792=>771,3793=>771,3794=>693,3795=>836,
3796=>729,3797=>729,3798=>849,3799=>790,3800=>759,3801=>910,3804=>1363,3805=>1363,4256=>918,4257=>744,
4258=>739,4259=>837,4260=>649,4261=>773,4262=>857,4263=>889,4264=>530,4265=>633,4266=>857,4267=>900,
4268=>643,4269=>903,4270=>814,4271=>752,4272=>869,4273=>643,4274=>643,4275=>886,4276=>886,4277=>733,
4278=>653,4279=>643,4280=>646,4281=>643,4282=>790,4283=>902,4284=>633,4285=>619,4286=>643,4287=>778,
4288=>892,4289=>601,4290=>742,4291=>616,4292=>633,4293=>742,4304=>553,4305=>552,4306=>596,4307=>815,
4308=>562,4309=>563,4310=>553,4311=>827,4312=>553,4313=>543,4314=>1074,4315=>563,4316=>563,4317=>812,
4318=>552,4319=>591,4320=>822,4321=>563,4322=>690,4323=>583,4324=>813,4325=>562,4326=>813,4327=>563,
4328=>563,4329=>563,4330=>632,4331=>563,4332=>563,4333=>552,4334=>563,4335=>563,4336=>558,4337=>604,
4338=>552,4339=>552,4340=>553,4341=>605,4342=>852,4343=>635,4344=>563,4345=>596,4346=>542,4347=>684,
4348=>368,5121=>774,5122=>774,5123=>774,5124=>774,5125=>905,5126=>905,5127=>905,5129=>905,5130=>905,
5131=>905,5132=>1018,5133=>1009,5134=>1018,5135=>1009,5136=>1018,5137=>1009,5138=>1149,5139=>1140,5140=>1149,
5141=>1140,5142=>905,5143=>1149,5144=>1142,5145=>1149,5146=>1142,5147=>905,5149=>310,5150=>529,5151=>425,
5152=>425,5153=>395,5154=>395,5155=>395,5156=>395,5157=>564,5158=>470,5159=>310,5160=>395,5161=>395,
5162=>395,5163=>1213,5164=>986,5165=>1216,5166=>1297,5167=>774,5168=>774,5169=>774,5170=>774,5171=>886,
5172=>886,5173=>886,5175=>886,5176=>886,5177=>886,5178=>1018,5179=>1009,5180=>1018,5181=>1009,5182=>1018,
5183=>1009,5184=>1149,5185=>1140,5186=>1149,5187=>1140,5188=>1149,5189=>1142,5190=>1149,5191=>1142,5192=>886,
5193=>576,5194=>229,5196=>812,5197=>812,5198=>812,5199=>812,5200=>815,5201=>815,5202=>815,5204=>815,
5205=>815,5206=>815,5207=>1056,5208=>1048,5209=>1056,5210=>1048,5211=>1056,5212=>1048,5213=>1060,5214=>1054,
5215=>1060,5216=>1054,5217=>1060,5218=>1052,5219=>1060,5220=>1052,5221=>1060,5222=>483,5223=>1005,5224=>1005,
5225=>1023,5226=>1017,5227=>743,5228=>743,5229=>743,5230=>743,5231=>743,5232=>743,5233=>743,5234=>743,
5235=>743,5236=>1029,5237=>975,5238=>980,5239=>975,5240=>980,5241=>975,5242=>1029,5243=>975,5244=>1029,
5245=>975,5246=>980,5247=>975,5248=>980,5249=>975,5250=>980,5251=>501,5252=>501,5253=>938,5254=>938,
5255=>938,5256=>938,5257=>743,5258=>743,5259=>743,5260=>743,5261=>743,5262=>743,5263=>743,5264=>743,
5265=>743,5266=>1029,5267=>975,5268=>1029,5269=>975,5270=>1029,5271=>975,5272=>1029,5273=>975,5274=>1029,
5275=>975,5276=>1029,5277=>975,5278=>1029,5279=>975,5280=>1029,5281=>501,5282=>501,5283=>626,5284=>626,
5285=>626,5286=>626,5287=>626,5288=>626,5289=>626,5290=>626,5291=>626,5292=>881,5293=>854,5294=>863,
5295=>874,5296=>863,5297=>874,5298=>881,5299=>874,5300=>881,5301=>874,5302=>863,5303=>874,5304=>863,
5305=>874,5306=>863,5307=>436,5308=>548,5309=>436,5312=>988,5313=>988,5314=>988,5315=>988,5316=>931,
5317=>931,5318=>931,5319=>931,5320=>931,5321=>1238,5322=>1247,5323=>1200,5324=>1228,5325=>1200,5326=>1228,
5327=>931,5328=>660,5329=>497,5330=>660,5331=>988,5332=>988,5333=>988,5334=>988,5335=>931,5336=>931,
5337=>931,5338=>931,5339=>931,5340=>1231,5341=>1247,5342=>1283,5343=>1228,5344=>1283,5345=>1228,5346=>1228,
5347=>1214,5348=>1228,5349=>1214,5350=>1283,5351=>1228,5352=>1283,5353=>1228,5354=>660,5356=>886,5357=>730,
5358=>730,5359=>730,5360=>730,5361=>730,5362=>730,5363=>730,5364=>730,5365=>730,5366=>998,5367=>958,
5368=>967,5369=>989,5370=>967,5371=>989,5372=>998,5373=>958,5374=>998,5375=>958,5376=>967,5377=>989,
5378=>967,5379=>989,5380=>967,5381=>493,5382=>460,5383=>493,5392=>923,5393=>923,5394=>923,5395=>1136,
5396=>1136,5397=>1136,5398=>1136,5399=>1209,5400=>1202,5401=>1209,5402=>1202,5403=>1209,5404=>1202,5405=>1431,
5406=>1420,5407=>1431,5408=>1420,5409=>1431,5410=>1420,5411=>1431,5412=>1420,5413=>746,5414=>776,5415=>776,
5416=>776,5417=>776,5418=>776,5419=>776,5420=>776,5421=>776,5422=>776,5423=>1003,5424=>1003,5425=>1013,
5426=>996,5427=>1013,5428=>996,5429=>1003,5430=>1003,5431=>1003,5432=>1003,5433=>1013,5434=>996,5435=>1013,
5436=>996,5437=>1013,5438=>495,5440=>395,5441=>510,5442=>1033,5443=>1033,5444=>976,5445=>976,5446=>976,
5447=>976,5448=>733,5449=>733,5450=>733,5451=>733,5452=>733,5453=>733,5454=>1003,5455=>959,5456=>495,
5458=>886,5459=>774,5460=>774,5461=>774,5462=>774,5463=>928,5464=>928,5465=>928,5466=>928,5467=>1172,
5468=>1142,5469=>602,5470=>812,5471=>812,5472=>812,5473=>812,5474=>812,5475=>812,5476=>815,5477=>815,
5478=>815,5479=>815,5480=>1060,5481=>1052,5482=>548,5492=>977,5493=>977,5494=>977,5495=>977,5496=>977,
5497=>977,5498=>977,5499=>618,5500=>837,5501=>510,5502=>1238,5503=>1238,5504=>1238,5505=>1238,5506=>1238,
5507=>1238,5508=>1238,5509=>989,5514=>977,5515=>977,5516=>977,5517=>977,5518=>1591,5519=>1591,5520=>1591,
5521=>1295,5522=>1295,5523=>1591,5524=>1591,5525=>848,5526=>1273,5536=>988,5537=>988,5538=>931,5539=>931,
5540=>931,5541=>931,5542=>660,5543=>776,5544=>776,5545=>776,5546=>776,5547=>776,5548=>776,5549=>776,
5550=>495,5551=>743,5598=>830,5601=>830,5702=>496,5703=>496,5742=>413,5743=>1238,5744=>1591,5745=>2016,
5746=>2016,5747=>1720,5748=>1678,5749=>2016,5750=>2016,5760=>543,5761=>637,5762=>945,5763=>1254,5764=>1563,
5765=>1871,5766=>627,5767=>936,5768=>1254,5769=>1559,5770=>1871,5771=>569,5772=>877,5773=>1187,5774=>1497,
5775=>1807,5776=>637,5777=>945,5778=>1240,5779=>1555,5780=>1871,5781=>569,5782=>569,5783=>789,5784=>1234,
5785=>1559,5786=>740,5787=>638,5788=>638,7424=>652,7425=>833,7426=>1048,7427=>608,7428=>593,7429=>676,
7430=>676,7431=>559,7432=>557,7433=>343,7434=>494,7435=>665,7436=>539,7437=>817,7438=>701,7439=>687,
7440=>593,7441=>660,7442=>660,7443=>660,7444=>1094,7446=>687,7447=>687,7448=>556,7449=>642,7450=>642,
7451=>580,7452=>634,7453=>737,7454=>948,7455=>695,7456=>652,7457=>924,7458=>582,7459=>646,7462=>539,
7463=>652,7464=>691,7465=>556,7466=>781,7467=>732,7468=>487,7469=>683,7470=>480,7472=>523,7473=>430,
7474=>430,7475=>517,7476=>527,7477=>234,7478=>234,7479=>488,7480=>401,7481=>626,7482=>527,7483=>527,
7484=>535,7485=>509,7486=>461,7487=>485,7488=>430,7489=>511,7490=>695,7491=>458,7492=>458,7493=>479,
7494=>712,7495=>479,7496=>479,7497=>479,7498=>479,7499=>386,7500=>386,7501=>479,7502=>219,7503=>487,
7504=>664,7505=>456,7506=>488,7507=>414,7508=>488,7509=>488,7510=>479,7511=>388,7512=>456,7513=>462,
7514=>664,7515=>501,7517=>451,7518=>429,7519=>433,7520=>493,7521=>406,7522=>219,7523=>315,7524=>456,
7525=>501,7526=>451,7527=>429,7528=>451,7529=>493,7530=>406,7543=>716,7544=>527,7547=>545,7557=>514,
7579=>479,7580=>414,7581=>414,7582=>488,7583=>386,7584=>377,7585=>348,7586=>479,7587=>456,7588=>347,
7589=>281,7590=>347,7591=>347,7592=>431,7593=>326,7594=>330,7595=>370,7596=>664,7597=>664,7598=>562,
7599=>562,7600=>448,7601=>488,7602=>542,7603=>422,7604=>396,7605=>388,7606=>583,7607=>494,7608=>399,
7609=>451,7610=>501,7611=>417,7612=>523,7613=>470,7614=>455,7615=>425,7620=>0,7621=>0,7622=>0,
7623=>0,7624=>0,7625=>0,7680=>774,7681=>675,7682=>762,7683=>716,7684=>762,7685=>716,7686=>762,
7687=>716,7688=>734,7689=>593,7690=>830,7691=>716,7692=>830,7693=>716,7694=>830,7695=>716,7696=>830,
7697=>716,7698=>830,7699=>716,7700=>683,7701=>678,7702=>683,7703=>678,7704=>683,7705=>678,7706=>683,
7707=>678,7708=>683,7709=>678,7710=>683,7711=>435,7712=>821,7713=>716,7714=>837,7715=>712,7716=>837,
7717=>712,7718=>837,7719=>712,7720=>837,7721=>712,7722=>837,7723=>712,7724=>372,7725=>343,7726=>372,
7727=>343,7728=>775,7729=>665,7730=>775,7731=>665,7732=>775,7733=>665,7734=>637,7735=>343,7736=>637,
7737=>343,7738=>637,7739=>343,7740=>637,7741=>343,7742=>995,7743=>1042,7744=>995,7745=>1042,7746=>995,
7747=>1042,7748=>837,7749=>712,7750=>837,7751=>712,7752=>837,7753=>712,7754=>837,7755=>712,7756=>850,
7757=>687,7758=>850,7759=>687,7760=>850,7761=>687,7762=>850,7763=>687,7764=>733,7765=>716,7766=>733,
7767=>716,7768=>770,7769=>493,7770=>770,7771=>493,7772=>770,7773=>493,7774=>770,7775=>493,7776=>720,
7777=>595,7778=>720,7779=>595,7780=>720,7781=>595,7782=>720,7783=>595,7784=>720,7785=>595,7786=>682,
7787=>478,7788=>682,7789=>478,7790=>682,7791=>478,7792=>682,7793=>478,7794=>812,7795=>712,7796=>812,
7797=>712,7798=>812,7799=>712,7800=>812,7801=>712,7802=>812,7803=>712,7804=>774,7805=>652,7806=>774,
7807=>652,7808=>1103,7809=>924,7810=>1103,7811=>924,7812=>1103,7813=>924,7814=>1103,7815=>924,7816=>1103,
7817=>924,7818=>771,7819=>645,7820=>771,7821=>645,7822=>724,7823=>652,7824=>725,7825=>582,7826=>725,
7827=>582,7828=>725,7829=>582,7830=>712,7831=>478,7832=>924,7833=>652,7834=>675,7835=>435,7838=>896,
7839=>687,7840=>774,7841=>675,7842=>774,7843=>675,7844=>774,7845=>675,7846=>774,7847=>675,7848=>774,
7849=>675,7850=>774,7851=>675,7852=>774,7853=>675,7854=>774,7855=>675,7856=>774,7857=>675,7858=>774,
7859=>675,7860=>774,7861=>675,7862=>774,7863=>675,7864=>683,7865=>678,7866=>683,7867=>678,7868=>683,
7869=>678,7870=>683,7871=>678,7872=>683,7873=>678,7874=>683,7875=>678,7876=>683,7877=>678,7878=>683,
7879=>678,7880=>372,7881=>343,7882=>372,7883=>343,7884=>850,7885=>687,7886=>850,7887=>687,7888=>850,
7889=>687,7890=>850,7891=>687,7892=>850,7893=>687,7894=>850,7895=>687,7896=>850,7897=>687,7898=>874,
7899=>687,7900=>874,7901=>687,7902=>874,7903=>687,7904=>874,7905=>687,7906=>874,7907=>687,7908=>812,
7909=>712,7910=>812,7911=>712,7912=>835,7913=>712,7914=>835,7915=>712,7916=>835,7917=>712,7918=>835,
7919=>712,7920=>835,7921=>712,7922=>724,7923=>652,7924=>724,7925=>652,7926=>724,7927=>652,7928=>724,
7929=>652,7936=>687,7937=>687,7938=>687,7939=>687,7940=>687,7941=>687,7942=>687,7943=>687,7944=>774,
7945=>774,7946=>1041,7947=>1043,7948=>935,7949=>963,7950=>835,7951=>859,7952=>557,7953=>557,7954=>557,
7955=>557,7956=>557,7957=>557,7960=>792,7961=>794,7962=>1100,7963=>1096,7964=>1023,7965=>1052,7968=>712,
7969=>712,7970=>712,7971=>712,7972=>712,7973=>712,7974=>712,7975=>712,7976=>945,7977=>951,7978=>1250,
7979=>1250,7980=>1180,7981=>1206,7982=>1054,7983=>1063,7984=>390,7985=>390,7986=>390,7987=>390,7988=>390,
7989=>390,7990=>390,7991=>390,7992=>483,7993=>489,7994=>777,7995=>785,7996=>712,7997=>738,7998=>604,
7999=>604,8000=>687,8001=>687,8002=>687,8003=>687,8004=>687,8005=>687,8008=>892,8009=>933,8010=>1221,
8011=>1224,8012=>1053,8013=>1082,8016=>675,8017=>675,8018=>675,8019=>675,8020=>675,8021=>675,8022=>675,
8023=>675,8025=>930,8027=>1184,8029=>1199,8031=>1049,8032=>869,8033=>869,8034=>869,8035=>869,8036=>869,
8037=>869,8038=>869,8039=>869,8040=>909,8041=>958,8042=>1246,8043=>1251,8044=>1076,8045=>1105,8046=>1028,
8047=>1076,8048=>687,8049=>687,8050=>557,8051=>557,8052=>712,8053=>712,8054=>390,8055=>390,8056=>687,
8057=>687,8058=>675,8059=>675,8060=>869,8061=>869,8064=>687,8065=>687,8066=>687,8067=>687,8068=>687,
8069=>687,8070=>687,8071=>687,8072=>774,8073=>774,8074=>1041,8075=>1043,8076=>935,8077=>963,8078=>835,
8079=>859,8080=>712,8081=>712,8082=>712,8083=>712,8084=>712,8085=>712,8086=>712,8087=>712,8088=>945,
8089=>951,8090=>1250,8091=>1250,8092=>1180,8093=>1206,8094=>1054,8095=>1063,8096=>869,8097=>869,8098=>869,
8099=>869,8100=>869,8101=>869,8102=>869,8103=>869,8104=>909,8105=>958,8106=>1246,8107=>1251,8108=>1076,
8109=>1105,8110=>1028,8111=>1076,8112=>687,8113=>687,8114=>687,8115=>687,8116=>687,8118=>687,8119=>687,
8120=>774,8121=>774,8122=>876,8123=>797,8124=>774,8125=>500,8126=>500,8127=>500,8128=>500,8129=>500,
8130=>712,8131=>712,8132=>712,8134=>712,8135=>712,8136=>929,8137=>846,8138=>1080,8139=>1009,8140=>837,
8141=>500,8142=>500,8143=>500,8144=>390,8145=>390,8146=>390,8147=>390,8150=>390,8151=>390,8152=>372,
8153=>372,8154=>621,8155=>563,8157=>500,8158=>500,8159=>500,8160=>675,8161=>675,8162=>675,8163=>675,
8164=>716,8165=>716,8166=>675,8167=>675,8168=>724,8169=>724,8170=>1020,8171=>980,8172=>838,8173=>500,
8174=>500,8175=>500,8178=>869,8179=>869,8180=>869,8182=>869,8183=>869,8184=>1065,8185=>891,8186=>1084,
8187=>894,8188=>850,8189=>500,8190=>500,8192=>500,8193=>1000,8194=>500,8195=>1000,8196=>330,8197=>250,
8198=>167,8199=>696,8200=>380,8201=>200,8202=>100,8203=>0,8204=>0,8205=>0,8206=>0,8207=>0,
8208=>415,8209=>415,8210=>696,8213=>1000,8214=>500,8215=>500,8219=>380,8223=>657,8227=>639,8228=>333,
8229=>667,8231=>348,8234=>0,8235=>0,8236=>0,8237=>0,8238=>0,8239=>200,8241=>1887,8242=>264,
8243=>447,8244=>630,8245=>264,8246=>447,8247=>630,8248=>733,8251=>972,8252=>627,8253=>580,8254=>500,
8255=>828,8256=>828,8257=>329,8258=>1023,8259=>500,8260=>167,8261=>457,8262=>457,8263=>1030,8264=>829,
8265=>829,8266=>513,8267=>636,8268=>500,8269=>500,8270=>523,8271=>400,8272=>828,8273=>523,8274=>556,
8275=>1000,8276=>828,8277=>838,8278=>684,8279=>813,8280=>838,8281=>838,8282=>380,8283=>872,8284=>838,
8285=>380,8286=>380,8287=>222,8288=>0,8289=>0,8290=>0,8291=>0,8292=>0,8298=>0,8299=>0,
8300=>0,8301=>0,8302=>0,8303=>0,8304=>438,8305=>219,8308=>438,8309=>438,8310=>438,8311=>438,
8312=>438,8313=>438,8314=>528,8315=>528,8316=>528,8317=>288,8318=>288,8319=>456,8320=>438,8321=>438,
8322=>438,8323=>438,8324=>438,8325=>438,8326=>438,8327=>438,8328=>438,8329=>438,8330=>528,8331=>528,
8332=>528,8333=>288,8334=>288,8336=>458,8337=>479,8338=>488,8339=>413,8340=>479,8352=>929,8353=>696,
8354=>696,8355=>696,8356=>696,8357=>1042,8358=>837,8359=>1518,8360=>1205,8361=>1103,8362=>904,8363=>696,
8365=>696,8366=>682,8367=>1392,8368=>696,8369=>696,8370=>696,8371=>696,8372=>859,8373=>696,8400=>0,
8401=>0,8406=>0,8407=>0,8411=>0,8412=>0,8417=>0,8448=>1120,8449=>1170,8450=>734,8451=>1211,
8452=>896,8453=>1091,8454=>1144,8455=>614,8456=>698,8457=>1086,8459=>1073,8460=>913,8461=>888,8462=>712,
8463=>712,8464=>597,8465=>697,8466=>856,8467=>472,8468=>974,8469=>837,8470=>1203,8471=>1000,8472=>697,
8473=>750,8474=>850,8475=>938,8476=>814,8477=>801,8478=>896,8479=>710,8480=>1020,8481=>1281,8483=>755,
8484=>754,8485=>578,8486=>850,8487=>850,8488=>763,8489=>338,8490=>775,8491=>774,8492=>928,8493=>818,
8494=>854,8495=>636,8496=>729,8497=>808,8498=>683,8499=>1184,8500=>465,8501=>794,8502=>731,8503=>494,
8504=>684,8505=>380,8506=>945,8507=>1348,8508=>790,8509=>737,8510=>654,8511=>863,8512=>840,8513=>775,
8514=>557,8515=>637,8516=>760,8517=>830,8518=>716,8519=>678,8520=>343,8521=>343,8523=>872,8526=>547,
8531=>1035,8532=>1035,8533=>1035,8534=>1035,8535=>1035,8536=>1035,8537=>1035,8538=>1035,8539=>1035,8540=>1035,
8541=>1035,8542=>1035,8543=>615,8544=>372,8545=>659,8546=>945,8547=>1099,8548=>774,8549=>1099,8550=>1386,
8551=>1672,8552=>1121,8553=>771,8554=>1120,8555=>1407,8556=>637,8557=>734,8558=>830,8559=>995,8560=>343,
8561=>607,8562=>872,8563=>984,8564=>652,8565=>962,8566=>1227,8567=>1491,8568=>969,8569=>645,8570=>969,
8571=>1233,8572=>343,8573=>593,8574=>716,8575=>1042,8576=>1289,8577=>830,8578=>1289,8579=>734,8580=>593,
8592=>838,8593=>838,8594=>838,8595=>838,8596=>838,8597=>838,8598=>838,8599=>838,8600=>838,8601=>838,
8602=>838,8603=>838,8604=>838,8605=>838,8606=>838,8607=>838,8608=>838,8609=>838,8610=>838,8611=>838,
8612=>838,8613=>838,8614=>838,8615=>838,8616=>838,8617=>838,8618=>838,8619=>838,8620=>838,8621=>838,
8622=>838,8623=>838,8624=>838,8625=>838,8626=>838,8627=>838,8628=>838,8629=>838,8630=>838,8631=>838,
8632=>838,8633=>838,8634=>838,8635=>838,8636=>838,8637=>838,8638=>838,8639=>838,8640=>838,8641=>838,
8642=>838,8643=>838,8644=>838,8645=>838,8646=>838,8647=>838,8648=>838,8649=>838,8650=>838,8651=>838,
8652=>838,8653=>838,8654=>838,8655=>838,8656=>838,8657=>838,8658=>838,8659=>838,8660=>838,8661=>838,
8662=>838,8663=>838,8664=>838,8665=>838,8666=>838,8667=>838,8668=>838,8669=>838,8670=>838,8671=>838,
8672=>838,8673=>838,8674=>838,8675=>838,8676=>838,8677=>838,8678=>838,8679=>838,8680=>838,8681=>838,
8682=>838,8683=>838,8684=>838,8685=>838,8686=>838,8687=>838,8688=>838,8689=>838,8690=>838,8691=>838,
8692=>838,8693=>838,8694=>838,8695=>838,8696=>838,8697=>838,8698=>838,8699=>838,8700=>838,8701=>838,
8702=>838,8703=>838,8704=>774,8705=>696,8706=>544,8707=>683,8708=>683,8709=>856,8710=>697,8711=>697,
8712=>896,8713=>896,8714=>750,8715=>896,8716=>896,8717=>750,8718=>636,8719=>787,8720=>787,8721=>718,
8722=>838,8723=>838,8724=>696,8725=>365,8726=>696,8727=>838,8728=>626,8729=>380,8730=>667,8731=>667,
8732=>667,8733=>712,8734=>833,8735=>838,8736=>896,8737=>896,8738=>838,8739=>500,8740=>500,8741=>500,
8742=>500,8743=>812,8744=>812,8745=>812,8746=>812,8747=>610,8748=>929,8749=>1295,8750=>563,8751=>977,
8752=>1313,8753=>563,8754=>563,8755=>563,8756=>696,8757=>696,8758=>294,8759=>696,8760=>838,8761=>838,
8762=>838,8763=>838,8764=>838,8765=>838,8766=>838,8767=>838,8768=>375,8769=>838,8770=>838,8771=>838,
8772=>838,8773=>838,8774=>838,8775=>838,8776=>838,8777=>838,8778=>838,8779=>838,8780=>838,8781=>838,
8782=>838,8783=>838,8784=>838,8785=>838,8786=>838,8787=>838,8788=>1063,8789=>1063,8790=>838,8791=>838,
8792=>838,8793=>838,8794=>838,8795=>838,8796=>838,8797=>838,8798=>838,8799=>838,8800=>838,8801=>838,
8802=>838,8803=>838,8804=>838,8805=>838,8806=>838,8807=>838,8808=>841,8809=>841,8810=>1047,8811=>1047,
8812=>500,8813=>838,8814=>838,8815=>838,8816=>838,8817=>838,8818=>838,8819=>838,8820=>838,8821=>838,
8822=>838,8823=>838,8824=>838,8825=>838,8826=>838,8827=>838,8828=>838,8829=>838,8830=>838,8831=>838,
8832=>838,8833=>838,8834=>838,8835=>838,8836=>838,8837=>838,8838=>838,8839=>838,8840=>838,8841=>838,
8842=>838,8843=>838,8844=>812,8845=>812,8846=>812,8847=>838,8848=>838,8849=>838,8850=>838,8851=>796,
8852=>796,8853=>838,8854=>838,8855=>838,8856=>838,8857=>838,8858=>838,8859=>838,8860=>838,8861=>838,
8862=>838,8863=>838,8864=>838,8865=>838,8866=>914,8867=>914,8868=>914,8869=>914,8870=>542,8871=>542,
8872=>914,8873=>914,8874=>914,8875=>914,8876=>914,8877=>914,8878=>914,8879=>914,8880=>838,8881=>838,
8882=>838,8883=>838,8884=>838,8885=>838,8886=>1000,8887=>1000,8888=>838,8889=>838,8890=>542,8891=>812,
8892=>812,8893=>812,8894=>838,8895=>838,8896=>843,8897=>843,8898=>843,8899=>843,8900=>494,8901=>380,
8902=>626,8903=>838,8904=>1000,8905=>1000,8906=>1000,8907=>1000,8908=>1000,8909=>838,8910=>812,8911=>812,
8912=>838,8913=>838,8914=>838,8915=>838,8916=>838,8917=>838,8918=>838,8919=>838,8920=>1422,8921=>1422,
8922=>838,8923=>838,8924=>838,8925=>838,8926=>838,8927=>838,8928=>838,8929=>838,8930=>838,8931=>838,
8932=>838,8933=>838,8934=>838,8935=>838,8936=>838,8937=>838,8938=>838,8939=>838,8940=>838,8941=>838,
8942=>1000,8943=>1000,8944=>1000,8945=>1000,8946=>1158,8947=>896,8948=>750,8949=>896,8950=>896,8951=>750,
8952=>896,8953=>896,8954=>1158,8955=>896,8956=>750,8957=>896,8958=>750,8959=>896,8960=>602,8961=>602,
8962=>716,8963=>838,8964=>838,8965=>838,8966=>838,8967=>488,8968=>457,8969=>457,8970=>457,8971=>457,
8972=>809,8973=>809,8974=>809,8975=>809,8976=>838,8977=>539,8984=>928,8985=>838,8988=>469,8989=>469,
8990=>469,8991=>469,8992=>610,8993=>610,8996=>1152,8997=>1152,8998=>1414,8999=>1152,9000=>1443,9003=>1414,
9004=>873,9075=>390,9076=>716,9077=>869,9082=>687,9085=>863,9095=>1152,9108=>873,9115=>500,9116=>500,
9117=>500,9118=>500,9119=>500,9120=>500,9121=>500,9122=>500,9123=>500,9124=>500,9125=>500,9126=>500,
9127=>750,9128=>750,9129=>750,9130=>750,9131=>750,9132=>750,9133=>750,9134=>610,9166=>838,9167=>945,
9187=>873,9189=>769,9250=>716,9251=>716,9312=>847,9313=>847,9314=>847,9315=>847,9316=>847,9317=>847,
9318=>847,9319=>847,9320=>847,9321=>847,9600=>769,9601=>769,9602=>769,9603=>769,9604=>769,9605=>769,
9606=>769,9607=>769,9608=>769,9609=>769,9610=>769,9611=>769,9612=>769,9613=>769,9614=>769,9615=>769,
9616=>769,9617=>769,9618=>769,9619=>769,9620=>769,9621=>769,9622=>769,9623=>769,9624=>769,9625=>769,
9626=>769,9627=>769,9628=>769,9629=>769,9630=>769,9631=>769,9632=>945,9633=>945,9634=>945,9635=>945,
9636=>945,9637=>945,9638=>945,9639=>945,9640=>945,9641=>945,9642=>678,9643=>678,9644=>945,9645=>945,
9646=>550,9647=>550,9648=>769,9649=>769,9650=>769,9651=>769,9652=>502,9653=>502,9654=>769,9655=>769,
9656=>502,9657=>502,9658=>769,9659=>769,9660=>769,9661=>769,9662=>502,9663=>502,9664=>769,9665=>769,
9666=>502,9667=>502,9668=>769,9669=>769,9670=>769,9671=>769,9672=>769,9673=>873,9674=>494,9675=>873,
9676=>873,9677=>873,9678=>873,9679=>873,9680=>873,9681=>873,9682=>873,9683=>873,9684=>873,9685=>873,
9686=>527,9687=>527,9688=>840,9689=>970,9690=>970,9691=>970,9692=>387,9693=>387,9694=>387,9695=>387,
9696=>769,9697=>769,9698=>769,9699=>769,9700=>769,9701=>769,9702=>639,9703=>945,9704=>945,9705=>945,
9706=>945,9707=>945,9708=>769,9709=>769,9710=>769,9711=>1119,9712=>945,9713=>945,9714=>945,9715=>945,
9716=>873,9717=>873,9718=>873,9719=>873,9720=>769,9721=>769,9722=>769,9723=>830,9724=>830,9725=>732,
9726=>732,9727=>769,9728=>896,9729=>1000,9730=>896,9731=>896,9732=>896,9733=>896,9734=>896,9735=>573,
9736=>896,9737=>896,9738=>888,9739=>888,9740=>671,9741=>1013,9742=>1246,9743=>1250,9744=>896,9745=>896,
9746=>896,9747=>532,9748=>896,9749=>896,9750=>896,9751=>896,9752=>896,9753=>896,9754=>896,9755=>896,
9756=>896,9757=>609,9758=>896,9759=>609,9760=>896,9761=>896,9762=>896,9763=>896,9764=>669,9765=>746,
9766=>649,9767=>784,9768=>545,9769=>896,9770=>896,9771=>896,9772=>710,9773=>896,9774=>896,9775=>896,
9776=>896,9777=>896,9778=>896,9779=>896,9780=>896,9781=>896,9782=>896,9783=>896,9784=>896,9785=>896,
9786=>896,9787=>896,9788=>896,9789=>896,9790=>896,9791=>614,9792=>731,9793=>731,9794=>896,9795=>896,
9796=>896,9797=>896,9798=>896,9799=>896,9800=>896,9801=>896,9802=>896,9803=>896,9804=>896,9805=>896,
9806=>896,9807=>896,9808=>896,9809=>896,9810=>896,9811=>896,9812=>896,9813=>896,9814=>896,9815=>896,
9816=>896,9817=>896,9818=>896,9819=>896,9820=>896,9821=>896,9822=>896,9823=>896,9824=>896,9825=>896,
9826=>896,9827=>896,9828=>896,9829=>896,9830=>896,9831=>896,9832=>896,9833=>472,9834=>638,9835=>896,
9836=>896,9837=>472,9838=>357,9839=>484,9840=>748,9841=>766,9842=>896,9843=>896,9844=>896,9845=>896,
9846=>896,9847=>896,9848=>896,9849=>896,9850=>896,9851=>896,9852=>896,9853=>896,9854=>896,9855=>896,
9856=>869,9857=>869,9858=>869,9859=>869,9860=>869,9861=>869,9862=>896,9863=>896,9864=>896,9865=>896,
9866=>896,9867=>896,9868=>896,9869=>896,9870=>896,9871=>896,9872=>896,9873=>896,9874=>896,9875=>896,
9876=>896,9877=>541,9878=>896,9879=>896,9880=>896,9881=>896,9882=>896,9883=>896,9884=>896,9888=>896,
9889=>702,9890=>1003,9891=>1085,9892=>1143,9893=>901,9894=>838,9895=>838,9896=>838,9897=>838,9898=>838,
9899=>838,9900=>838,9901=>838,9902=>838,9903=>838,9904=>844,9905=>838,9906=>731,9907=>732,9908=>732,
9909=>732,9910=>850,9911=>732,9912=>732,9985=>838,9986=>838,9987=>838,9988=>838,9990=>838,9991=>838,
9992=>838,9993=>838,9996=>838,9997=>838,9998=>838,9999=>838,10000=>838,10001=>838,10002=>838,10003=>838,
10004=>838,10005=>838,10006=>838,10007=>838,10008=>838,10009=>838,10010=>838,10011=>838,10012=>838,10013=>838,
10014=>838,10015=>838,10016=>838,10017=>838,10018=>838,10019=>838,10020=>838,10021=>838,10022=>838,10023=>838,
10025=>838,10026=>838,10027=>838,10028=>838,10029=>838,10030=>838,10031=>838,10032=>838,10033=>838,10034=>838,
10035=>838,10036=>838,10037=>838,10038=>838,10039=>838,10040=>838,10041=>838,10042=>838,10043=>838,10044=>838,
10045=>838,10046=>838,10047=>838,10048=>838,10049=>838,10050=>838,10051=>838,10052=>838,10053=>838,10054=>838,
10055=>838,10056=>838,10057=>838,10058=>838,10059=>838,10061=>896,10063=>896,10064=>896,10065=>896,10066=>896,
10070=>896,10072=>838,10073=>838,10074=>838,10075=>347,10076=>347,10077=>587,10078=>587,10081=>838,10082=>838,
10083=>838,10084=>838,10085=>838,10086=>838,10087=>838,10088=>838,10089=>838,10090=>838,10091=>838,10092=>838,
10093=>838,10094=>838,10095=>838,10096=>838,10097=>838,10098=>838,10099=>838,10100=>838,10101=>838,10102=>847,
10103=>847,10104=>847,10105=>847,10106=>847,10107=>847,10108=>847,10109=>847,10110=>847,10111=>847,10112=>838,
10113=>838,10114=>838,10115=>838,10116=>838,10117=>838,10118=>838,10119=>838,10120=>838,10121=>838,10122=>838,
10123=>838,10124=>838,10125=>838,10126=>838,10127=>838,10128=>838,10129=>838,10130=>838,10131=>838,10132=>838,
10136=>838,10137=>838,10138=>838,10139=>838,10140=>838,10141=>838,10142=>838,10143=>838,10144=>838,10145=>838,
10146=>838,10147=>838,10148=>838,10149=>838,10150=>838,10151=>838,10152=>838,10153=>838,10154=>838,10155=>838,
10156=>838,10157=>838,10158=>838,10159=>838,10161=>838,10162=>838,10163=>838,10164=>838,10165=>838,10166=>838,
10167=>838,10168=>838,10169=>838,10170=>838,10171=>838,10172=>838,10173=>838,10174=>838,10181=>457,10182=>457,
10208=>494,10214=>487,10215=>487,10216=>457,10217=>457,10218=>721,10219=>721,10224=>838,10225=>838,10226=>838,
10227=>838,10228=>1157,10229=>1434,10230=>1434,10231=>1434,10232=>1434,10233=>1434,10234=>1434,10235=>1434,10236=>1434,
10237=>1434,10238=>1434,10239=>1434,10240=>781,10241=>781,10242=>781,10243=>781,10244=>781,10245=>781,10246=>781,
10247=>781,10248=>781,10249=>781,10250=>781,10251=>781,10252=>781,10253=>781,10254=>781,10255=>781,10256=>781,
10257=>781,10258=>781,10259=>781,10260=>781,10261=>781,10262=>781,10263=>781,10264=>781,10265=>781,10266=>781,
10267=>781,10268=>781,10269=>781,10270=>781,10271=>781,10272=>781,10273=>781,10274=>781,10275=>781,10276=>781,
10277=>781,10278=>781,10279=>781,10280=>781,10281=>781,10282=>781,10283=>781,10284=>781,10285=>781,10286=>781,
10287=>781,10288=>781,10289=>781,10290=>781,10291=>781,10292=>781,10293=>781,10294=>781,10295=>781,10296=>781,
10297=>781,10298=>781,10299=>781,10300=>781,10301=>781,10302=>781,10303=>781,10304=>781,10305=>781,10306=>781,
10307=>781,10308=>781,10309=>781,10310=>781,10311=>781,10312=>781,10313=>781,10314=>781,10315=>781,10316=>781,
10317=>781,10318=>781,10319=>781,10320=>781,10321=>781,10322=>781,10323=>781,10324=>781,10325=>781,10326=>781,
10327=>781,10328=>781,10329=>781,10330=>781,10331=>781,10332=>781,10333=>781,10334=>781,10335=>781,10336=>781,
10337=>781,10338=>781,10339=>781,10340=>781,10341=>781,10342=>781,10343=>781,10344=>781,10345=>781,10346=>781,
10347=>781,10348=>781,10349=>781,10350=>781,10351=>781,10352=>781,10353=>781,10354=>781,10355=>781,10356=>781,
10357=>781,10358=>781,10359=>781,10360=>781,10361=>781,10362=>781,10363=>781,10364=>781,10365=>781,10366=>781,
10367=>781,10368=>781,10369=>781,10370=>781,10371=>781,10372=>781,10373=>781,10374=>781,10375=>781,10376=>781,
10377=>781,10378=>781,10379=>781,10380=>781,10381=>781,10382=>781,10383=>781,10384=>781,10385=>781,10386=>781,
10387=>781,10388=>781,10389=>781,10390=>781,10391=>781,10392=>781,10393=>781,10394=>781,10395=>781,10396=>781,
10397=>781,10398=>781,10399=>781,10400=>781,10401=>781,10402=>781,10403=>781,10404=>781,10405=>781,10406=>781,
10407=>781,10408=>781,10409=>781,10410=>781,10411=>781,10412=>781,10413=>781,10414=>781,10415=>781,10416=>781,
10417=>781,10418=>781,10419=>781,10420=>781,10421=>781,10422=>781,10423=>781,10424=>781,10425=>781,10426=>781,
10427=>781,10428=>781,10429=>781,10430=>781,10431=>781,10432=>781,10433=>781,10434=>781,10435=>781,10436=>781,
10437=>781,10438=>781,10439=>781,10440=>781,10441=>781,10442=>781,10443=>781,10444=>781,10445=>781,10446=>781,
10447=>781,10448=>781,10449=>781,10450=>781,10451=>781,10452=>781,10453=>781,10454=>781,10455=>781,10456=>781,
10457=>781,10458=>781,10459=>781,10460=>781,10461=>781,10462=>781,10463=>781,10464=>781,10465=>781,10466=>781,
10467=>781,10468=>781,10469=>781,10470=>781,10471=>781,10472=>781,10473=>781,10474=>781,10475=>781,10476=>781,
10477=>781,10478=>781,10479=>781,10480=>781,10481=>781,10482=>781,10483=>781,10484=>781,10485=>781,10486=>781,
10487=>781,10488=>781,10489=>781,10490=>781,10491=>781,10492=>781,10493=>781,10494=>781,10495=>781,10502=>838,
10503=>838,10506=>838,10507=>838,10560=>838,10561=>838,10627=>753,10628=>753,10702=>838,10703=>1046,10704=>1046,
10705=>1000,10706=>1000,10707=>1000,10708=>1000,10709=>1000,10731=>494,10746=>838,10747=>838,10752=>1000,10753=>1000,
10754=>1000,10764=>1661,10765=>563,10766=>563,10767=>563,10768=>563,10769=>563,10770=>563,10771=>563,10772=>563,
10773=>563,10774=>563,10775=>563,10776=>563,10777=>563,10778=>563,10779=>563,10780=>563,10799=>838,10877=>838,
10878=>838,10879=>838,10880=>838,10881=>838,10882=>838,10883=>838,10884=>838,10885=>838,10886=>838,10887=>838,
10888=>838,10889=>838,10890=>838,10891=>838,10892=>838,10893=>838,10894=>838,10895=>838,10896=>838,10897=>838,
10898=>838,10899=>838,10900=>838,10901=>838,10902=>838,10903=>838,10904=>838,10905=>838,10906=>838,10907=>838,
10908=>838,10909=>838,10910=>838,10911=>838,10912=>838,10926=>838,10927=>838,10928=>838,10929=>838,10930=>838,
10931=>838,10932=>838,10933=>838,10934=>838,10935=>838,10936=>838,10937=>838,10938=>838,11001=>838,11002=>838,
11008=>838,11009=>838,11010=>838,11011=>838,11012=>838,11013=>838,11014=>838,11015=>838,11016=>838,11017=>838,
11018=>838,11019=>838,11020=>838,11021=>838,11022=>838,11023=>838,11024=>838,11025=>838,11026=>945,11027=>945,
11028=>945,11029=>945,11030=>769,11031=>769,11032=>769,11033=>769,11034=>945,11039=>869,11040=>869,11041=>873,
11042=>873,11043=>873,11044=>1119,11091=>869,11092=>869,11360=>637,11361=>360,11362=>637,11363=>733,11364=>770,
11365=>675,11366=>478,11367=>956,11368=>712,11369=>775,11370=>665,11371=>725,11372=>582,11373=>860,11374=>995,
11375=>774,11377=>778,11378=>1221,11379=>1056,11380=>652,11381=>698,11382=>565,11383=>782,11385=>538,11386=>687,
11387=>559,11388=>219,11389=>487,11568=>691,11569=>941,11570=>941,11571=>725,11572=>725,11573=>725,11574=>676,
11575=>774,11576=>774,11577=>683,11578=>683,11579=>802,11580=>989,11581=>761,11582=>623,11583=>761,11584=>941,
11585=>941,11586=>373,11587=>740,11588=>837,11589=>914,11590=>672,11591=>737,11592=>680,11593=>683,11594=>602,
11595=>1039,11596=>778,11597=>837,11598=>683,11599=>372,11600=>778,11601=>373,11602=>725,11603=>691,11604=>941,
11605=>941,11606=>837,11607=>373,11608=>836,11609=>941,11610=>941,11611=>734,11612=>876,11613=>771,11614=>734,
11615=>683,11616=>774,11617=>837,11618=>683,11619=>850,11620=>697,11621=>850,11631=>716,11800=>580,11810=>457,
11811=>457,11812=>457,11813=>457,11822=>580,19904=>896,19905=>896,19906=>896,19907=>896,19908=>896,19909=>896,
19910=>896,19911=>896,19912=>896,19913=>896,19914=>896,19915=>896,19916=>896,19917=>896,19918=>896,19919=>896,
19920=>896,19921=>896,19922=>896,19923=>896,19924=>896,19925=>896,19926=>896,19927=>896,19928=>896,19929=>896,
19930=>896,19931=>896,19932=>896,19933=>896,19934=>896,19935=>896,19936=>896,19937=>896,19938=>896,19939=>896,
19940=>896,19941=>896,19942=>896,19943=>896,19944=>896,19945=>896,19946=>896,19947=>896,19948=>896,19949=>896,
19950=>896,19951=>896,19952=>896,19953=>896,19954=>896,19955=>896,19956=>896,19957=>896,19958=>896,19959=>896,
19960=>896,19961=>896,19962=>896,19963=>896,19964=>896,19965=>896,19966=>896,19967=>896,42564=>720,42565=>595,
42566=>436,42567=>440,42572=>1405,42573=>1173,42576=>1234,42577=>1027,42580=>1174,42581=>972,42582=>1093,42583=>958,
42594=>1085,42595=>924,42596=>1096,42597=>912,42598=>1260,42599=>997,42600=>850,42601=>687,42602=>1037,42603=>868,
42604=>1406,42605=>1106,42606=>961,42634=>963,42635=>787,42636=>682,42637=>580,42644=>808,42645=>712,42760=>500,
42761=>500,42762=>500,42763=>500,42764=>500,42765=>500,42766=>500,42767=>500,42768=>500,42769=>500,42770=>500,
42771=>500,42772=>500,42773=>500,42774=>500,42779=>400,42780=>400,42781=>287,42782=>287,42783=>287,42790=>837,
42791=>712,42792=>1031,42793=>857,42794=>696,42795=>557,42800=>559,42801=>595,42802=>1349,42803=>1052,42804=>1284,
42805=>1064,42806=>1216,42807=>1054,42808=>1079,42809=>922,42810=>1079,42811=>922,42812=>1035,42813=>922,42814=>698,
42815=>549,42822=>850,42823=>542,42824=>683,42825=>531,42826=>918,42827=>814,42830=>1406,42831=>1106,42880=>637,
42881=>343,42882=>837,42883=>712,42889=>400,42890=>386,42891=>456,42892=>306,43003=>683,43004=>733,43005=>995,
43006=>372,43007=>1325,63173=>687,64256=>810,64257=>741,64258=>741,64259=>1115,64260=>1116,64261=>808,64262=>1020,
64275=>1388,64276=>1384,64277=>1378,64278=>1384,64279=>1713,64285=>343,64286=>0,64287=>663,64288=>720,64289=>963,
64290=>890,64291=>988,64292=>963,64293=>938,64294=>988,64295=>988,64296=>976,64297=>838,64298=>949,64299=>949,
64300=>949,64301=>949,64302=>751,64303=>751,64304=>751,64305=>673,64306=>537,64307=>654,64308=>712,64309=>438,
64310=>491,64312=>724,64313=>438,64314=>649,64315=>650,64316=>679,64318=>775,64320=>497,64321=>773,64323=>718,
64324=>687,64326=>751,64327=>729,64328=>649,64329=>949,64330=>751,64331=>343,64332=>673,64333=>650,64334=>687,
64335=>751,64338=>1005,64339=>1059,64340=>375,64341=>408,64342=>1005,64343=>1059,64344=>375,64345=>408,64346=>1005,
64347=>1059,64348=>375,64349=>408,64350=>1005,64351=>1059,64352=>375,64353=>408,64354=>1005,64355=>1059,64356=>375,
64357=>408,64358=>1005,64359=>1059,64360=>375,64361=>408,64362=>1162,64363=>1191,64364=>655,64365=>720,64366=>1162,
64367=>1191,64368=>655,64369=>720,64370=>721,64371=>721,64372=>721,64373=>721,64374=>721,64375=>721,64376=>721,
64377=>721,64378=>721,64379=>721,64380=>721,64381=>721,64382=>721,64383=>721,64384=>721,64385=>721,64394=>576,
64395=>622,64396=>576,64397=>622,64398=>1024,64399=>1024,64400=>582,64401=>582,64402=>1024,64403=>1024,64404=>582,
64405=>582,64414=>854,64415=>900,64473=>622,64474=>627,64488=>375,64489=>408,64508=>917,64509=>1012,64510=>375,
64511=>408,65024=>0,65025=>0,65026=>0,65027=>0,65028=>0,65029=>0,65030=>0,65031=>0,65032=>0,
65033=>0,65034=>0,65035=>0,65036=>0,65037=>0,65038=>0,65039=>0,65056=>0,65057=>0,65058=>0,
65059=>0,65136=>342,65137=>342,65138=>342,65139=>346,65140=>342,65142=>342,65143=>342,65144=>342,65145=>342,
65146=>342,65147=>342,65148=>342,65149=>342,65150=>342,65151=>342,65152=>511,65153=>343,65154=>375,65155=>343,
65156=>375,65157=>622,65158=>627,65159=>343,65160=>375,65161=>917,65162=>917,65163=>375,65164=>408,65165=>343,
65166=>375,65167=>1005,65168=>1059,65169=>375,65170=>408,65171=>590,65172=>606,65173=>1005,65174=>1059,65175=>375,
65176=>408,65177=>1005,65178=>1059,65179=>375,65180=>408,65181=>721,65182=>721,65183=>721,65184=>721,65185=>721,
65186=>721,65187=>721,65188=>721,65189=>721,65190=>721,65191=>721,65192=>721,65193=>513,65194=>578,65195=>513,
65196=>578,65197=>576,65198=>622,65199=>576,65200=>622,65201=>1380,65202=>1414,65203=>983,65204=>1018,65205=>1380,
65206=>1414,65207=>983,65208=>1018,65209=>1345,65210=>1364,65211=>966,65212=>985,65213=>1345,65214=>1364,65215=>966,
65216=>985,65217=>1039,65218=>1071,65219=>942,65220=>974,65221=>1039,65222=>1071,65223=>942,65224=>974,65225=>683,
65226=>683,65227=>683,65228=>564,65229=>683,65230=>683,65231=>683,65232=>564,65233=>1162,65234=>1191,65235=>655,
65236=>720,65237=>894,65238=>901,65239=>655,65240=>720,65241=>917,65242=>931,65243=>582,65244=>582,65245=>868,
65246=>893,65247=>375,65248=>408,65249=>733,65250=>784,65251=>619,65252=>670,65253=>854,65254=>900,65255=>375,
65256=>408,65257=>590,65258=>606,65259=>693,65260=>660,65261=>622,65262=>627,65263=>917,65264=>1012,65265=>917,
65266=>1012,65267=>375,65268=>408,65269=>745,65270=>759,65271=>745,65272=>759,65273=>745,65274=>759,65275=>745,
65276=>759,65279=>0,65529=>0,65530=>0,65531=>0,65532=>0,65533=>1113);
$enc='';
$diff='';
$file='dejavusansb.z';
$ctg='dejavusansb.ctg.z';
$originalsize=573136;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/dejavusansb.php | PHP | asf20 | 50,084 |
<?php
$type='TrueTypeUnicode';
$name='DejaVuSans-Oblique';
$desc=array('Ascent'=>928,'Descent'=>-236,'CapHeight'=>-43,'Flags'=>96,'FontBBox'=>'[-1016 -350 1659 1068]','ItalicAngle'=>-11,'StemV'=>70,'MissingWidth'=>600);
$up=-63;
$ut=44;
$dw=600;
$cw=array(
0=>600,32=>318,33=>401,34=>460,35=>838,36=>636,37=>950,38=>780,39=>275,40=>390,
41=>390,42=>500,43=>838,44=>318,45=>361,46=>318,47=>337,48=>636,49=>636,50=>636,
51=>636,52=>636,53=>636,54=>636,55=>636,56=>636,57=>636,58=>337,59=>337,60=>838,
61=>838,62=>838,63=>531,64=>1000,65=>684,66=>686,67=>698,68=>770,69=>632,70=>575,
71=>775,72=>752,73=>295,74=>295,75=>656,76=>557,77=>863,78=>748,79=>787,80=>603,
81=>787,82=>695,83=>635,84=>611,85=>732,86=>684,87=>989,88=>685,89=>611,90=>685,
91=>390,92=>337,93=>390,94=>838,95=>500,96=>500,97=>613,98=>635,99=>550,100=>635,
101=>615,102=>352,103=>635,104=>634,105=>278,106=>278,107=>579,108=>278,109=>974,110=>634,
111=>612,112=>635,113=>635,114=>411,115=>521,116=>392,117=>634,118=>592,119=>818,120=>592,
121=>592,122=>525,123=>636,124=>337,125=>636,126=>838,8364=>636,8218=>318,402=>352,8222=>518,
8230=>1000,8224=>500,8225=>500,710=>500,8240=>1350,352=>635,8249=>400,338=>1070,381=>685,8216=>318,
8217=>318,8220=>518,8221=>518,8226=>590,8211=>500,8212=>1000,732=>500,8482=>1000,353=>521,8250=>400,
339=>1028,382=>525,376=>611,160=>318,161=>401,162=>636,163=>636,164=>636,165=>636,166=>337,
167=>500,168=>500,169=>1000,170=>471,171=>617,172=>838,173=>361,174=>1000,175=>500,176=>500,
177=>838,178=>401,179=>401,180=>500,181=>636,182=>636,183=>318,184=>500,185=>401,186=>471,
187=>617,188=>969,189=>969,190=>969,191=>531,192=>684,193=>684,194=>684,195=>684,196=>684,
197=>684,198=>974,199=>698,200=>632,201=>632,202=>632,203=>632,204=>295,205=>295,206=>295,
207=>295,208=>775,209=>748,210=>787,211=>787,212=>787,213=>787,214=>787,215=>838,216=>787,
217=>732,218=>732,219=>732,220=>732,221=>611,222=>608,223=>630,224=>613,225=>613,226=>613,
227=>613,228=>613,229=>613,230=>995,231=>550,232=>615,233=>615,234=>615,235=>615,236=>278,
237=>278,238=>278,239=>278,240=>612,241=>634,242=>612,243=>612,244=>612,245=>612,246=>612,
247=>838,248=>612,249=>634,250=>634,251=>634,252=>634,253=>592,254=>635,255=>592,256=>684,
257=>613,258=>684,259=>613,260=>684,261=>613,262=>698,263=>550,264=>698,265=>550,266=>698,
267=>550,268=>698,269=>550,270=>770,271=>635,272=>775,273=>635,274=>632,275=>615,276=>632,
277=>615,278=>632,279=>615,280=>632,281=>615,282=>632,283=>615,284=>775,285=>635,286=>775,
287=>635,288=>775,289=>635,290=>775,291=>635,292=>752,293=>634,294=>916,295=>695,296=>295,
297=>278,298=>295,299=>278,300=>295,301=>278,302=>295,303=>278,304=>295,305=>278,306=>590,
307=>556,308=>295,309=>278,310=>656,311=>579,312=>579,313=>557,314=>278,315=>557,316=>278,
317=>557,318=>278,319=>557,320=>278,321=>562,322=>287,323=>748,324=>634,325=>748,326=>634,
327=>748,328=>634,329=>813,330=>748,331=>634,332=>787,333=>612,334=>787,335=>612,336=>787,
337=>612,340=>695,341=>411,342=>695,343=>411,344=>695,345=>411,346=>635,347=>521,348=>635,
349=>521,350=>635,351=>521,354=>611,355=>392,356=>611,357=>392,358=>611,359=>392,360=>732,
361=>634,362=>732,363=>634,364=>732,365=>634,366=>732,367=>634,368=>732,369=>634,370=>732,
371=>634,372=>989,373=>818,374=>611,375=>592,377=>685,378=>525,379=>685,380=>525,383=>352,
384=>635,385=>735,386=>686,387=>635,388=>686,389=>635,390=>703,391=>698,392=>550,393=>775,
394=>819,395=>686,396=>635,397=>612,398=>632,399=>787,400=>614,401=>575,403=>775,404=>687,
405=>984,406=>354,407=>295,408=>746,409=>579,410=>278,411=>592,412=>974,413=>748,414=>634,
415=>787,416=>913,417=>612,418=>938,419=>737,420=>652,421=>635,422=>695,423=>635,424=>521,
425=>632,426=>336,427=>392,428=>611,429=>392,430=>611,431=>838,432=>634,433=>764,434=>721,
435=>744,436=>730,437=>685,438=>525,439=>666,440=>666,441=>578,442=>525,443=>636,444=>666,
445=>578,446=>510,447=>635,448=>295,449=>492,450=>459,451=>295,452=>1455,453=>1295,454=>1160,
455=>852,456=>835,457=>556,458=>1043,459=>1026,460=>912,461=>684,462=>613,463=>295,464=>278,
465=>787,466=>612,467=>732,468=>634,469=>732,470=>634,471=>732,472=>634,473=>732,474=>634,
475=>732,476=>634,477=>615,478=>684,479=>613,480=>684,481=>613,482=>974,483=>995,484=>775,
485=>635,486=>775,487=>635,488=>656,489=>579,490=>787,491=>612,492=>787,493=>612,494=>666,
495=>525,496=>278,497=>1455,498=>1295,499=>1160,500=>775,501=>635,502=>1113,503=>682,504=>748,
505=>634,506=>684,507=>613,508=>974,509=>995,510=>787,511=>612,512=>684,513=>613,514=>684,
515=>613,516=>632,517=>615,518=>632,519=>615,520=>295,521=>278,522=>295,523=>278,524=>787,
525=>612,526=>787,527=>612,528=>695,529=>411,530=>695,531=>411,532=>732,533=>634,534=>732,
535=>634,536=>635,537=>521,538=>611,539=>392,540=>627,541=>521,542=>752,543=>634,544=>735,
545=>838,546=>698,547=>610,548=>685,549=>525,550=>684,551=>613,552=>632,553=>615,554=>787,
555=>612,556=>787,557=>612,558=>787,559=>612,560=>787,561=>612,562=>611,563=>592,564=>475,
565=>843,566=>477,567=>278,568=>998,569=>998,570=>684,571=>698,572=>550,573=>557,574=>611,
575=>521,576=>525,577=>603,578=>479,579=>686,580=>732,581=>684,582=>632,583=>615,584=>295,
585=>278,586=>781,587=>635,588=>695,589=>411,590=>611,591=>592,592=>613,593=>635,594=>635,
595=>635,596=>550,597=>550,598=>635,599=>727,600=>615,601=>615,602=>844,603=>545,604=>545,
605=>775,606=>664,607=>326,608=>696,609=>635,610=>629,611=>596,612=>596,613=>634,614=>634,
615=>634,616=>372,617=>387,618=>372,619=>396,620=>487,621=>278,622=>706,623=>974,624=>974,
625=>974,626=>646,627=>642,628=>634,629=>612,630=>858,631=>728,632=>660,633=>469,634=>469,
635=>469,636=>469,637=>469,638=>530,639=>530,640=>602,641=>602,642=>521,643=>336,644=>336,
645=>461,646=>336,647=>392,648=>392,649=>634,650=>618,651=>598,652=>592,653=>818,654=>592,
655=>611,656=>525,657=>525,658=>578,659=>578,660=>510,661=>510,662=>510,663=>510,664=>787,
665=>580,666=>664,667=>708,668=>654,669=>292,670=>667,671=>507,672=>727,673=>510,674=>510,
675=>1014,676=>1058,677=>1013,678=>824,679=>610,680=>778,681=>848,682=>641,683=>654,684=>515,
685=>515,686=>570,687=>664,688=>399,689=>399,690=>175,691=>259,692=>295,693=>296,694=>379,
695=>515,696=>373,697=>278,698=>460,699=>318,700=>318,701=>318,702=>307,703=>307,704=>370,
705=>370,706=>500,707=>500,708=>500,709=>500,711=>500,712=>275,713=>500,714=>500,715=>500,
716=>275,717=>500,718=>500,719=>500,720=>337,721=>337,722=>307,723=>307,724=>500,725=>500,
726=>390,727=>317,728=>500,729=>500,730=>500,731=>500,733=>500,734=>315,735=>500,736=>426,
737=>166,738=>373,739=>444,740=>370,741=>493,742=>493,743=>493,744=>493,745=>493,748=>500,
749=>500,750=>518,755=>500,759=>500,768=>0,769=>0,770=>0,771=>0,772=>0,773=>0,
774=>0,775=>0,776=>0,777=>0,778=>0,779=>0,780=>0,781=>0,782=>0,783=>0,
784=>0,785=>0,786=>0,787=>0,788=>0,789=>0,790=>0,791=>0,792=>0,793=>0,
794=>0,795=>0,796=>0,797=>0,798=>0,799=>0,800=>0,801=>0,802=>0,803=>0,
804=>0,805=>0,806=>0,807=>0,808=>0,809=>0,810=>0,811=>0,812=>0,813=>0,
814=>0,815=>0,816=>0,817=>0,818=>0,819=>0,820=>0,821=>0,822=>0,823=>0,
824=>0,825=>0,826=>0,827=>0,828=>0,829=>0,830=>0,831=>0,832=>0,833=>0,
834=>0,835=>0,836=>0,837=>0,838=>0,839=>0,840=>0,841=>0,842=>0,843=>0,
844=>0,845=>0,846=>0,847=>0,849=>0,850=>0,851=>0,855=>0,856=>0,858=>0,
860=>0,861=>0,862=>0,863=>0,864=>0,865=>0,866=>0,880=>654,881=>568,882=>862,
883=>647,884=>278,885=>278,886=>748,887=>650,890=>500,891=>549,892=>550,893=>549,894=>337,
900=>500,901=>500,902=>684,903=>318,904=>767,905=>903,906=>435,908=>839,910=>860,911=>905,
912=>338,913=>684,914=>686,915=>557,916=>684,917=>632,918=>685,919=>752,920=>787,921=>295,
922=>656,923=>684,924=>863,925=>748,926=>632,927=>787,928=>752,929=>603,931=>632,932=>611,
933=>611,934=>787,935=>685,936=>787,937=>764,938=>295,939=>611,940=>659,941=>541,942=>634,
943=>338,944=>579,945=>659,946=>638,947=>592,948=>612,949=>541,950=>544,951=>634,952=>612,
953=>338,954=>589,955=>592,956=>636,957=>559,958=>558,959=>612,960=>602,961=>635,962=>587,
963=>634,964=>602,965=>579,966=>660,967=>592,968=>660,969=>837,970=>338,971=>579,972=>612,
973=>579,974=>837,975=>656,976=>614,977=>619,978=>699,979=>842,980=>699,981=>660,982=>837,
983=>664,984=>787,985=>612,986=>648,987=>587,988=>575,989=>458,990=>660,991=>660,992=>865,
993=>627,994=>934,995=>837,996=>758,997=>659,998=>792,999=>615,1000=>687,1001=>607,1002=>768,
1003=>625,1004=>699,1005=>612,1006=>611,1007=>536,1008=>664,1009=>635,1010=>550,1011=>278,1012=>787,
1013=>615,1014=>615,1015=>608,1016=>635,1017=>698,1018=>863,1019=>651,1020=>635,1021=>703,1022=>698,
1023=>703,1024=>632,1025=>632,1026=>786,1027=>557,1028=>698,1029=>635,1030=>295,1031=>295,1032=>295,
1033=>1094,1034=>1045,1035=>786,1036=>710,1037=>748,1038=>609,1039=>752,1040=>684,1041=>686,1042=>686,
1043=>557,1044=>781,1045=>632,1046=>1077,1047=>641,1048=>748,1049=>748,1050=>710,1051=>752,1052=>863,
1053=>752,1054=>787,1055=>752,1056=>603,1057=>698,1058=>611,1059=>609,1060=>861,1061=>685,1062=>776,
1063=>686,1064=>1069,1065=>1094,1066=>833,1067=>818,1068=>686,1069=>698,1070=>1080,1071=>695,1072=>613,
1073=>617,1074=>589,1075=>525,1076=>691,1077=>615,1078=>901,1079=>532,1080=>650,1081=>650,1082=>604,
1083=>639,1084=>754,1085=>654,1086=>612,1087=>654,1088=>635,1089=>550,1090=>583,1091=>592,1092=>855,
1093=>592,1094=>681,1095=>591,1096=>915,1097=>942,1098=>707,1099=>790,1100=>589,1101=>549,1102=>842,
1103=>602,1104=>615,1105=>615,1106=>625,1107=>525,1108=>549,1109=>521,1110=>278,1111=>278,1112=>278,
1113=>902,1114=>898,1115=>652,1116=>604,1117=>650,1118=>592,1119=>654,1120=>934,1121=>837,1122=>771,
1123=>672,1124=>942,1125=>749,1126=>879,1127=>783,1128=>1160,1129=>1001,1130=>787,1131=>612,1132=>1027,
1133=>824,1134=>636,1135=>541,1136=>856,1137=>876,1138=>787,1139=>612,1140=>781,1141=>665,1142=>781,
1143=>665,1144=>992,1145=>904,1146=>953,1147=>758,1148=>1180,1149=>1028,1150=>934,1151=>837,1152=>698,
1153=>550,1154=>502,1155=>0,1156=>0,1157=>0,1158=>0,1159=>0,1160=>418,1161=>418,1162=>748,
1163=>657,1164=>686,1165=>589,1166=>603,1167=>635,1168=>610,1169=>525,1170=>675,1171=>556,1172=>557,
1173=>491,1174=>1077,1175=>901,1176=>641,1177=>532,1178=>710,1179=>604,1180=>710,1181=>604,1182=>710,
1183=>604,1184=>856,1185=>832,1186=>752,1187=>661,1188=>1014,1189=>877,1190=>1113,1191=>950,1192=>890,
1193=>707,1194=>698,1195=>550,1196=>611,1197=>529,1198=>611,1199=>592,1200=>611,1201=>592,1202=>685,
1203=>592,1204=>934,1205=>807,1206=>686,1207=>591,1208=>686,1209=>591,1210=>686,1211=>634,1212=>929,
1213=>731,1214=>929,1215=>731,1216=>295,1217=>1077,1218=>901,1219=>655,1220=>604,1221=>752,1222=>639,
1223=>752,1224=>661,1225=>752,1226=>661,1227=>686,1228=>591,1229=>863,1230=>754,1231=>278,1232=>684,
1233=>613,1234=>684,1235=>613,1236=>974,1237=>995,1238=>632,1239=>615,1240=>787,1241=>615,1242=>787,
1243=>615,1244=>1077,1245=>901,1246=>641,1247=>532,1248=>666,1249=>578,1250=>748,1251=>650,1252=>748,
1253=>650,1254=>787,1255=>612,1256=>787,1257=>612,1258=>787,1259=>612,1260=>698,1261=>549,1262=>609,
1263=>592,1264=>609,1265=>592,1266=>609,1267=>592,1268=>686,1269=>591,1270=>557,1271=>491,1272=>818,
1273=>790,1274=>675,1275=>556,1276=>685,1277=>592,1278=>685,1279=>592,1280=>686,1281=>589,1282=>1006,
1283=>897,1284=>975,1285=>869,1286=>679,1287=>588,1288=>1072,1289=>957,1290=>1113,1291=>967,1292=>775,
1293=>660,1294=>773,1295=>711,1296=>614,1297=>541,1298=>752,1299=>639,1300=>1195,1301=>997,1302=>900,
1303=>867,1304=>1031,1305=>989,1306=>787,1307=>635,1308=>989,1309=>818,1312=>1113,1313=>942,1314=>1113,
1315=>949,1316=>793,1317=>683,1329=>867,1330=>732,1331=>882,1332=>882,1333=>732,1334=>644,1335=>682,
1336=>732,1337=>851,1338=>882,1339=>732,1340=>557,1341=>824,1342=>986,1343=>732,1344=>707,1345=>644,
1346=>882,1347=>777,1348=>882,1349=>732,1350=>840,1351=>732,1352=>732,1353=>732,1354=>791,1355=>644,
1356=>882,1357=>732,1358=>882,1359=>635,1360=>732,1361=>732,1362=>799,1363=>861,1364=>790,1365=>787,
1366=>635,1369=>307,1370=>318,1371=>500,1372=>500,1373=>392,1374=>526,1375=>500,1377=>974,1378=>634,
1379=>762,1380=>767,1381=>634,1382=>697,1383=>533,1384=>634,1385=>700,1386=>697,1387=>634,1388=>404,
1389=>894,1390=>641,1391=>634,1392=>634,1393=>635,1394=>702,1395=>634,1396=>659,1397=>278,1398=>760,
1399=>516,1400=>634,1401=>453,1402=>974,1403=>516,1404=>769,1405=>634,1406=>696,1407=>974,1408=>634,
1409=>635,1410=>501,1411=>974,1412=>648,1413=>612,1414=>629,1415=>763,1417=>337,1418=>433,1456=>0,
1457=>0,1458=>0,1459=>0,1460=>0,1461=>0,1462=>0,1463=>0,1464=>0,1465=>0,1466=>0,
1467=>0,1468=>0,1469=>0,1470=>361,1471=>0,1472=>295,1473=>0,1474=>0,1475=>295,1478=>456,
1479=>0,1488=>629,1489=>608,1490=>448,1491=>594,1492=>640,1493=>272,1494=>374,1495=>640,1496=>648,
1497=>272,1498=>592,1499=>556,1500=>599,1501=>640,1502=>659,1503=>272,1504=>441,1505=>700,1506=>563,
1507=>640,1508=>604,1509=>521,1510=>581,1511=>663,1512=>592,1513=>808,1514=>657,1520=>471,1521=>454,
1522=>471,1523=>416,1524=>645,3647=>652,3713=>670,3714=>684,3716=>688,3719=>482,3720=>628,3722=>684,
3725=>688,3732=>642,3733=>642,3734=>672,3735=>655,3737=>641,3738=>592,3739=>592,3740=>745,3741=>767,
3742=>687,3743=>687,3745=>702,3746=>688,3747=>684,3749=>649,3751=>632,3754=>703,3755=>819,3757=>633,
3758=>684,3759=>788,3760=>632,3761=>0,3762=>539,3763=>539,3764=>0,3765=>0,3766=>0,3767=>0,
3768=>0,3769=>0,3771=>0,3772=>0,3773=>663,3776=>360,3777=>679,3778=>460,3779=>547,3780=>491,
3782=>674,3784=>0,3785=>0,3786=>0,3787=>0,3788=>0,3789=>0,3792=>636,3793=>641,3794=>641,
3795=>670,3796=>625,3797=>625,3798=>703,3799=>670,3800=>674,3801=>677,3804=>1028,3805=>1028,4256=>840,
4257=>690,4258=>642,4259=>759,4260=>591,4261=>686,4262=>789,4263=>811,4264=>467,4265=>565,4266=>789,
4267=>793,4268=>584,4269=>837,4270=>750,4271=>688,4272=>811,4273=>584,4274=>584,4275=>837,4276=>837,
4277=>646,4278=>604,4279=>584,4280=>596,4281=>584,4282=>721,4283=>795,4284=>584,4285=>566,4286=>584,
4287=>669,4288=>799,4289=>542,4290=>664,4291=>542,4292=>565,4293=>674,4304=>508,4305=>508,4306=>533,
4307=>785,4308=>522,4309=>517,4310=>508,4311=>797,4312=>507,4313=>518,4314=>1058,4315=>522,4316=>523,
4317=>783,4318=>518,4319=>523,4320=>792,4321=>523,4322=>656,4323=>524,4324=>788,4325=>523,4326=>782,
4327=>523,4328=>522,4329=>522,4330=>566,4331=>523,4332=>523,4333=>489,4334=>522,4335=>498,4336=>517,
4337=>560,4338=>508,4339=>508,4340=>508,4341=>563,4342=>824,4343=>595,4344=>522,4345=>554,4346=>553,
4347=>586,4348=>304,5121=>684,5122=>684,5123=>684,5124=>684,5125=>769,5126=>769,5127=>769,5129=>769,
5130=>769,5131=>769,5132=>835,5133=>834,5134=>835,5135=>834,5136=>835,5137=>834,5138=>967,5139=>1007,
5140=>967,5141=>1007,5142=>769,5143=>967,5144=>1007,5145=>967,5146=>1007,5147=>769,5149=>256,5150=>543,
5151=>423,5152=>423,5153=>389,5154=>389,5155=>393,5156=>389,5157=>466,5158=>385,5159=>256,5160=>389,
5161=>389,5162=>389,5163=>1090,5164=>909,5165=>953,5166=>1117,5167=>684,5168=>684,5169=>684,5170=>684,
5171=>729,5172=>729,5173=>729,5175=>729,5176=>729,5177=>729,5178=>835,5179=>684,5180=>835,5181=>834,
5182=>835,5183=>834,5184=>967,5185=>1007,5186=>967,5187=>1007,5188=>967,5189=>1007,5190=>967,5191=>1007,
5192=>729,5193=>508,5194=>192,5196=>732,5197=>732,5198=>732,5199=>732,5200=>730,5201=>730,5202=>730,
5204=>730,5205=>730,5206=>730,5207=>921,5208=>889,5209=>921,5210=>889,5211=>921,5212=>889,5213=>928,
5214=>900,5215=>928,5216=>900,5217=>947,5218=>900,5219=>947,5220=>900,5221=>947,5222=>434,5223=>877,
5224=>877,5225=>866,5226=>890,5227=>628,5228=>628,5229=>628,5230=>628,5231=>628,5232=>628,5233=>628,
5234=>628,5235=>628,5236=>860,5237=>771,5238=>815,5239=>816,5240=>815,5241=>816,5242=>860,5243=>771,
5244=>860,5245=>771,5246=>815,5247=>816,5248=>815,5249=>816,5250=>815,5251=>407,5252=>407,5253=>750,
5254=>775,5255=>750,5256=>775,5257=>628,5258=>628,5259=>628,5260=>628,5261=>628,5262=>628,5263=>628,
5264=>628,5265=>628,5266=>860,5267=>771,5268=>815,5269=>816,5270=>815,5271=>816,5272=>860,5273=>771,
5274=>860,5275=>771,5276=>815,5277=>816,5278=>815,5279=>816,5280=>815,5281=>435,5282=>435,5283=>610,
5284=>557,5285=>557,5286=>557,5287=>610,5288=>610,5289=>610,5290=>557,5291=>557,5292=>749,5293=>769,
5294=>746,5295=>764,5296=>746,5297=>764,5298=>749,5299=>769,5300=>749,5301=>769,5302=>746,5303=>764,
5304=>746,5305=>764,5306=>746,5307=>386,5308=>508,5309=>386,5312=>852,5313=>852,5314=>852,5315=>852,
5316=>852,5317=>852,5318=>852,5319=>852,5320=>852,5321=>1069,5322=>1035,5323=>1059,5324=>852,5325=>1059,
5326=>852,5327=>852,5328=>600,5329=>453,5330=>600,5331=>852,5332=>852,5333=>852,5334=>852,5335=>852,
5336=>852,5337=>852,5338=>852,5339=>852,5340=>1069,5341=>1035,5342=>1059,5343=>1030,5344=>1059,5345=>1030,
5346=>1069,5347=>1035,5348=>1069,5349=>1035,5350=>1083,5351=>1030,5352=>1083,5353=>1030,5354=>600,5356=>729,
5357=>603,5358=>603,5359=>603,5360=>603,5361=>603,5362=>603,5363=>603,5364=>603,5365=>603,5366=>834,
5367=>754,5368=>792,5369=>771,5370=>792,5371=>771,5372=>834,5373=>754,5374=>834,5375=>754,5376=>792,
5377=>771,5378=>792,5379=>771,5380=>792,5381=>418,5382=>420,5383=>418,5392=>712,5393=>712,5394=>712,
5395=>892,5396=>892,5397=>892,5398=>892,5399=>910,5400=>872,5401=>910,5402=>872,5403=>910,5404=>872,
5405=>1140,5406=>1100,5407=>1140,5408=>1100,5409=>1140,5410=>1100,5411=>1140,5412=>1100,5413=>641,5414=>627,
5415=>627,5416=>627,5417=>627,5418=>627,5419=>627,5420=>627,5421=>627,5422=>627,5423=>844,5424=>781,
5425=>816,5426=>818,5427=>816,5428=>818,5429=>844,5430=>781,5431=>844,5432=>781,5433=>816,5434=>818,
5435=>816,5436=>818,5437=>816,5438=>418,5440=>389,5441=>484,5442=>916,5443=>916,5444=>863,5445=>916,
5446=>863,5447=>863,5448=>603,5449=>603,5450=>603,5451=>603,5452=>603,5453=>603,5454=>834,5455=>754,
5456=>418,5458=>729,5459=>684,5460=>684,5461=>684,5462=>684,5463=>726,5464=>726,5465=>726,5466=>726,
5467=>924,5468=>1007,5469=>508,5470=>732,5471=>732,5472=>732,5473=>732,5474=>732,5475=>732,5476=>730,
5477=>730,5478=>730,5479=>730,5480=>947,5481=>900,5482=>508,5492=>831,5493=>831,5494=>831,5495=>831,
5496=>831,5497=>831,5498=>831,5499=>563,5500=>752,5501=>484,5502=>1047,5503=>1047,5504=>1047,5505=>1047,
5506=>1047,5507=>1047,5508=>1047,5509=>825,5514=>831,5515=>831,5516=>831,5517=>831,5518=>1259,5519=>1259,
5520=>1259,5521=>1002,5522=>1002,5523=>1259,5524=>1259,5525=>700,5526=>1073,5536=>852,5537=>852,5538=>799,
5539=>799,5540=>799,5541=>799,5542=>600,5543=>643,5544=>643,5545=>643,5546=>643,5547=>643,5548=>643,
5549=>643,5550=>418,5551=>628,5598=>770,5601=>770,5702=>468,5703=>468,5742=>444,5743=>1047,5744=>1310,
5745=>1632,5746=>1632,5747=>1375,5748=>1375,5749=>1632,5750=>1632,7424=>592,7425=>717,7426=>982,7427=>586,
7428=>550,7429=>605,7430=>605,7431=>491,7432=>541,7433=>278,7434=>395,7435=>579,7436=>583,7437=>754,
7438=>650,7439=>612,7440=>550,7441=>684,7442=>684,7443=>684,7444=>1023,7446=>612,7447=>612,7448=>524,
7449=>602,7450=>602,7451=>583,7452=>574,7453=>737,7454=>948,7455=>638,7456=>592,7457=>818,7458=>525,
7459=>526,7462=>583,7463=>592,7464=>564,7465=>524,7466=>590,7467=>639,7468=>431,7469=>613,7470=>432,
7472=>485,7473=>398,7474=>398,7475=>488,7476=>474,7477=>186,7478=>186,7479=>413,7480=>351,7481=>543,
7482=>471,7483=>471,7484=>496,7485=>439,7486=>380,7487=>438,7488=>385,7489=>461,7490=>623,7491=>392,
7492=>392,7493=>405,7494=>648,7495=>428,7496=>405,7497=>417,7498=>417,7499=>360,7500=>359,7501=>405,
7502=>179,7503=>426,7504=>623,7505=>409,7506=>414,7507=>370,7508=>414,7509=>414,7510=>428,7511=>295,
7512=>405,7513=>470,7514=>623,7515=>417,7517=>402,7518=>373,7519=>385,7520=>416,7521=>364,7522=>179,
7523=>259,7524=>405,7525=>417,7526=>402,7527=>373,7528=>412,7529=>416,7530=>364,7543=>635,7544=>474,
7547=>372,7557=>278,7579=>405,7580=>370,7581=>370,7582=>414,7583=>360,7584=>296,7585=>233,7586=>405,
7587=>405,7588=>261,7589=>250,7590=>261,7591=>261,7592=>234,7593=>250,7594=>235,7595=>376,7596=>623,
7597=>623,7598=>411,7599=>479,7600=>409,7601=>414,7602=>414,7603=>360,7604=>287,7605=>295,7606=>508,
7607=>418,7608=>361,7609=>406,7610=>417,7611=>366,7612=>437,7613=>366,7614=>392,7615=>414,7620=>0,
7621=>0,7622=>0,7623=>0,7624=>0,7625=>0,7680=>684,7681=>613,7682=>686,7683=>635,7684=>686,
7685=>635,7686=>686,7687=>635,7688=>698,7689=>550,7690=>770,7691=>635,7692=>770,7693=>635,7694=>770,
7695=>635,7696=>770,7697=>635,7698=>770,7699=>635,7700=>632,7701=>615,7702=>632,7703=>615,7704=>632,
7705=>615,7706=>632,7707=>615,7708=>632,7709=>615,7710=>575,7711=>352,7712=>775,7713=>635,7714=>752,
7715=>634,7716=>752,7717=>634,7718=>752,7719=>634,7720=>752,7721=>634,7722=>752,7723=>634,7724=>295,
7725=>278,7726=>295,7727=>278,7728=>656,7729=>579,7730=>656,7731=>579,7732=>656,7733=>579,7734=>557,
7735=>278,7736=>557,7737=>278,7738=>557,7739=>278,7740=>557,7741=>278,7742=>863,7743=>974,7744=>863,
7745=>974,7746=>863,7747=>974,7748=>748,7749=>634,7750=>748,7751=>634,7752=>748,7753=>634,7754=>748,
7755=>634,7756=>787,7757=>612,7758=>787,7759=>612,7760=>787,7761=>612,7762=>787,7763=>612,7764=>603,
7765=>635,7766=>603,7767=>635,7768=>695,7769=>411,7770=>695,7771=>411,7772=>695,7773=>411,7774=>695,
7775=>411,7776=>635,7777=>521,7778=>635,7779=>521,7780=>635,7781=>521,7782=>635,7783=>521,7784=>635,
7785=>521,7786=>611,7787=>392,7788=>611,7789=>392,7790=>611,7791=>392,7792=>611,7793=>392,7794=>732,
7795=>634,7796=>732,7797=>634,7798=>732,7799=>634,7800=>732,7801=>634,7802=>732,7803=>634,7804=>684,
7805=>592,7806=>684,7807=>592,7808=>989,7809=>818,7810=>989,7811=>818,7812=>989,7813=>818,7814=>989,
7815=>818,7816=>989,7817=>818,7818=>685,7819=>592,7820=>685,7821=>592,7822=>611,7823=>592,7824=>685,
7825=>525,7826=>685,7827=>525,7828=>685,7829=>525,7830=>634,7831=>392,7832=>818,7833=>592,7834=>613,
7835=>352,7838=>769,7839=>612,7840=>684,7841=>613,7842=>684,7843=>613,7844=>684,7845=>613,7846=>684,
7847=>613,7848=>684,7849=>613,7850=>684,7851=>613,7852=>684,7853=>613,7854=>684,7855=>613,7856=>684,
7857=>613,7858=>684,7859=>613,7860=>684,7861=>613,7862=>684,7863=>613,7864=>632,7865=>615,7866=>632,
7867=>615,7868=>632,7869=>615,7870=>632,7871=>615,7872=>632,7873=>615,7874=>632,7875=>615,7876=>632,
7877=>615,7878=>632,7879=>615,7880=>295,7881=>278,7882=>295,7883=>278,7884=>787,7885=>612,7886=>787,
7887=>612,7888=>787,7889=>612,7890=>787,7891=>612,7892=>787,7893=>612,7894=>787,7895=>612,7896=>787,
7897=>612,7898=>913,7899=>612,7900=>913,7901=>612,7902=>913,7903=>612,7904=>913,7905=>612,7906=>913,
7907=>612,7908=>732,7909=>634,7910=>732,7911=>634,7912=>838,7913=>634,7914=>838,7915=>634,7916=>838,
7917=>634,7918=>838,7919=>634,7920=>838,7921=>634,7922=>611,7923=>592,7924=>611,7925=>592,7926=>611,
7927=>592,7928=>611,7929=>592,7936=>659,7937=>659,7938=>659,7939=>659,7940=>659,7941=>659,7942=>659,
7943=>659,7944=>684,7945=>684,7946=>877,7947=>877,7948=>769,7949=>801,7950=>708,7951=>743,7952=>541,
7953=>541,7954=>541,7955=>541,7956=>541,7957=>541,7960=>711,7961=>711,7962=>966,7963=>975,7964=>898,
7965=>928,7968=>634,7969=>634,7970=>634,7971=>634,7972=>634,7973=>634,7974=>634,7975=>634,7976=>837,
7977=>835,7978=>1086,7979=>1089,7980=>1027,7981=>1051,7982=>934,7983=>947,7984=>338,7985=>338,7986=>338,
7987=>338,7988=>338,7989=>338,7990=>338,7991=>338,7992=>380,7993=>374,7994=>635,7995=>635,7996=>570,
7997=>600,7998=>489,7999=>493,8000=>612,8001=>612,8002=>612,8003=>612,8004=>612,8005=>612,8008=>804,
8009=>848,8010=>1095,8011=>1100,8012=>938,8013=>970,8016=>579,8017=>579,8018=>579,8019=>579,8020=>579,
8021=>579,8022=>579,8023=>579,8025=>784,8027=>998,8029=>1012,8031=>897,8032=>837,8033=>837,8034=>837,
8035=>837,8036=>837,8037=>837,8038=>837,8039=>837,8040=>802,8041=>843,8042=>1089,8043=>1095,8044=>946,
8045=>972,8046=>921,8047=>952,8048=>659,8049=>659,8050=>541,8051=>548,8052=>634,8053=>654,8054=>338,
8055=>338,8056=>612,8057=>612,8058=>579,8059=>579,8060=>837,8061=>837,8064=>659,8065=>659,8066=>659,
8067=>659,8068=>659,8069=>659,8070=>659,8071=>659,8072=>684,8073=>684,8074=>877,8075=>877,8076=>769,
8077=>801,8078=>708,8079=>743,8080=>634,8081=>634,8082=>634,8083=>634,8084=>634,8085=>634,8086=>634,
8087=>634,8088=>837,8089=>835,8090=>1086,8091=>1089,8092=>1027,8093=>1051,8094=>934,8095=>947,8096=>837,
8097=>837,8098=>837,8099=>837,8100=>837,8101=>837,8102=>837,8103=>837,8104=>802,8105=>843,8106=>1089,
8107=>1095,8108=>946,8109=>972,8110=>921,8111=>952,8112=>659,8113=>659,8114=>659,8115=>659,8116=>659,
8118=>659,8119=>659,8120=>684,8121=>684,8122=>716,8123=>692,8124=>684,8125=>500,8126=>500,8127=>500,
8128=>500,8129=>500,8130=>634,8131=>634,8132=>654,8134=>634,8135=>634,8136=>805,8137=>746,8138=>931,
8139=>871,8140=>752,8141=>500,8142=>500,8143=>500,8144=>338,8145=>338,8146=>338,8147=>338,8150=>338,
8151=>338,8152=>295,8153=>295,8154=>475,8155=>408,8157=>500,8158=>500,8159=>500,8160=>579,8161=>579,
8162=>579,8163=>579,8164=>635,8165=>635,8166=>579,8167=>579,8168=>611,8169=>611,8170=>845,8171=>825,
8172=>685,8173=>500,8174=>500,8175=>500,8178=>837,8179=>837,8180=>837,8182=>837,8183=>837,8184=>941,
8185=>813,8186=>922,8187=>826,8188=>764,8189=>500,8190=>500,8192=>500,8193=>1000,8194=>500,8195=>1000,
8196=>330,8197=>250,8198=>167,8199=>636,8200=>318,8201=>200,8202=>100,8203=>0,8204=>0,8205=>0,
8206=>0,8207=>0,8208=>361,8209=>361,8210=>636,8213=>1000,8214=>500,8215=>500,8219=>318,8223=>518,
8227=>590,8228=>333,8229=>667,8231=>318,8234=>0,8235=>0,8236=>0,8237=>0,8238=>0,8239=>200,
8241=>1690,8242=>227,8243=>374,8244=>520,8245=>227,8246=>374,8247=>520,8248=>339,8251=>838,8252=>485,
8253=>531,8254=>500,8255=>804,8256=>804,8257=>250,8258=>1000,8259=>500,8260=>167,8261=>390,8262=>390,
8263=>922,8264=>733,8265=>733,8266=>497,8267=>636,8268=>500,8269=>500,8270=>500,8271=>337,8272=>804,
8273=>500,8274=>450,8275=>1000,8276=>804,8277=>838,8278=>586,8279=>663,8280=>838,8281=>838,8282=>318,
8283=>797,8284=>838,8285=>318,8286=>318,8287=>222,8288=>0,8289=>0,8290=>0,8291=>0,8292=>0,
8298=>0,8299=>0,8300=>0,8301=>0,8302=>0,8303=>0,8304=>401,8305=>179,8308=>401,8309=>401,
8310=>401,8311=>401,8312=>401,8313=>401,8314=>528,8315=>528,8316=>528,8317=>246,8318=>246,8319=>399,
8320=>401,8321=>401,8322=>401,8323=>401,8324=>401,8325=>401,8326=>401,8327=>401,8328=>401,8329=>401,
8330=>528,8331=>528,8332=>528,8333=>246,8334=>246,8336=>392,8337=>417,8338=>414,8339=>444,8340=>417,
8352=>877,8353=>636,8354=>636,8355=>636,8356=>636,8357=>974,8358=>748,8359=>1271,8360=>1074,8361=>989,
8362=>838,8363=>636,8365=>656,8366=>611,8367=>1272,8368=>636,8369=>636,8370=>636,8371=>636,8372=>774,
8373=>641,8400=>0,8401=>0,8406=>0,8407=>0,8411=>0,8412=>0,8417=>0,8448=>970,8449=>970,
8450=>698,8451=>1123,8452=>896,8453=>969,8454=>1032,8455=>614,8456=>698,8457=>952,8459=>988,8460=>754,
8461=>850,8462=>634,8463=>634,8464=>470,8465=>697,8466=>720,8467=>413,8468=>818,8469=>801,8470=>1040,
8471=>1000,8472=>697,8473=>701,8474=>787,8475=>798,8476=>814,8477=>792,8478=>896,8479=>684,8480=>1020,
8481=>1014,8483=>684,8484=>745,8485=>578,8486=>764,8487=>764,8488=>616,8489=>338,8490=>656,8491=>684,
8492=>786,8493=>703,8494=>854,8495=>592,8496=>605,8497=>786,8498=>575,8499=>1069,8500=>462,8501=>745,
8502=>674,8503=>466,8504=>645,8505=>380,8506=>926,8507=>1157,8508=>702,8509=>728,8510=>654,8511=>849,
8512=>811,8513=>775,8514=>557,8515=>557,8516=>611,8517=>819,8518=>708,8519=>615,8520=>351,8521=>351,
8523=>780,8526=>526,8531=>969,8532=>969,8533=>969,8534=>969,8535=>969,8536=>969,8537=>969,8538=>969,
8539=>969,8540=>969,8541=>969,8542=>969,8543=>568,8544=>295,8545=>492,8546=>689,8547=>923,8548=>684,
8549=>922,8550=>1120,8551=>1317,8552=>917,8553=>685,8554=>933,8555=>1131,8556=>557,8557=>698,8558=>770,
8559=>863,8560=>278,8561=>458,8562=>637,8563=>812,8564=>592,8565=>811,8566=>991,8567=>1170,8568=>819,
8569=>592,8570=>822,8571=>1002,8572=>278,8573=>550,8574=>635,8575=>974,8576=>1245,8577=>770,8578=>1245,
8579=>703,8580=>549,8592=>838,8593=>838,8594=>838,8595=>838,8596=>838,8597=>838,8598=>838,8599=>838,
8600=>838,8601=>838,8602=>838,8603=>838,8604=>838,8605=>838,8606=>838,8607=>838,8608=>838,8609=>838,
8610=>838,8611=>838,8612=>838,8613=>838,8614=>838,8615=>838,8616=>838,8617=>838,8618=>838,8619=>838,
8620=>838,8621=>838,8622=>838,8623=>838,8624=>838,8625=>838,8626=>838,8627=>838,8628=>838,8629=>838,
8630=>838,8631=>838,8632=>838,8633=>838,8634=>838,8635=>838,8636=>838,8637=>838,8638=>838,8639=>838,
8640=>838,8641=>838,8642=>838,8643=>838,8644=>838,8645=>838,8646=>838,8647=>838,8648=>838,8649=>838,
8650=>838,8651=>838,8652=>838,8653=>838,8654=>838,8655=>838,8656=>838,8657=>838,8658=>838,8659=>838,
8660=>838,8661=>838,8662=>838,8663=>838,8664=>838,8665=>838,8666=>838,8667=>838,8668=>838,8669=>838,
8670=>838,8671=>838,8672=>838,8673=>838,8674=>838,8675=>838,8676=>838,8677=>838,8678=>838,8679=>838,
8680=>838,8681=>838,8682=>838,8683=>838,8684=>838,8685=>838,8686=>838,8687=>838,8688=>838,8689=>838,
8690=>838,8691=>838,8692=>838,8693=>838,8694=>838,8695=>838,8696=>838,8697=>838,8698=>838,8699=>838,
8700=>838,8701=>838,8702=>838,8703=>838,8704=>684,8705=>636,8706=>517,8707=>632,8708=>632,8709=>871,
8710=>669,8711=>669,8712=>871,8713=>871,8714=>718,8715=>871,8716=>871,8717=>718,8718=>636,8719=>757,
8720=>757,8721=>674,8722=>838,8723=>838,8724=>838,8725=>337,8726=>637,8727=>838,8728=>626,8729=>626,
8730=>637,8731=>637,8732=>637,8733=>714,8734=>833,8735=>838,8736=>896,8737=>896,8738=>838,8739=>500,
8740=>500,8741=>500,8742=>500,8743=>732,8744=>732,8745=>732,8746=>732,8747=>521,8748=>789,8749=>1057,
8750=>521,8751=>789,8752=>1057,8753=>521,8754=>521,8755=>521,8756=>636,8757=>636,8758=>260,8759=>636,
8760=>838,8761=>838,8762=>838,8763=>838,8764=>838,8765=>838,8766=>838,8767=>838,8768=>375,8769=>838,
8770=>838,8771=>838,8772=>838,8773=>838,8774=>838,8775=>838,8776=>838,8777=>838,8778=>838,8779=>838,
8780=>838,8781=>838,8782=>838,8783=>838,8784=>838,8785=>838,8786=>838,8787=>838,8788=>1000,8789=>1000,
8790=>838,8791=>838,8792=>838,8793=>838,8794=>838,8795=>838,8796=>838,8797=>838,8798=>838,8799=>838,
8800=>838,8801=>838,8802=>838,8803=>838,8804=>838,8805=>838,8806=>838,8807=>838,8808=>838,8809=>838,
8810=>1047,8811=>1047,8812=>464,8813=>838,8814=>838,8815=>838,8816=>838,8817=>838,8818=>838,8819=>838,
8820=>838,8821=>838,8822=>838,8823=>838,8824=>838,8825=>838,8826=>838,8827=>838,8828=>838,8829=>838,
8830=>838,8831=>838,8832=>838,8833=>838,8834=>838,8835=>838,8836=>838,8837=>838,8838=>838,8839=>838,
8840=>838,8841=>838,8842=>838,8843=>838,8844=>732,8845=>732,8846=>732,8847=>838,8848=>838,8849=>838,
8850=>838,8851=>780,8852=>780,8853=>838,8854=>838,8855=>838,8856=>838,8857=>838,8858=>838,8859=>838,
8860=>838,8861=>838,8862=>838,8863=>838,8864=>838,8865=>838,8866=>871,8867=>871,8868=>871,8869=>871,
8870=>521,8871=>521,8872=>871,8873=>871,8874=>871,8875=>871,8876=>871,8877=>871,8878=>871,8879=>871,
8880=>838,8881=>838,8882=>838,8883=>838,8884=>838,8885=>838,8886=>1000,8887=>1000,8888=>838,8889=>838,
8890=>521,8891=>732,8892=>732,8893=>732,8894=>838,8895=>838,8896=>820,8897=>820,8898=>820,8899=>820,
8900=>494,8901=>318,8902=>626,8903=>838,8904=>1000,8905=>1000,8906=>1000,8907=>1000,8908=>1000,8909=>838,
8910=>732,8911=>732,8912=>838,8913=>838,8914=>838,8915=>838,8916=>838,8917=>838,8918=>838,8919=>838,
8920=>1422,8921=>1422,8922=>838,8923=>838,8924=>838,8925=>838,8926=>838,8927=>838,8928=>838,8929=>838,
8930=>838,8931=>838,8932=>838,8933=>838,8934=>838,8935=>838,8936=>838,8937=>838,8938=>838,8939=>838,
8940=>838,8941=>838,8942=>1000,8943=>1000,8944=>1000,8945=>1000,8946=>1000,8947=>871,8948=>718,8949=>871,
8950=>871,8951=>718,8952=>871,8953=>871,8954=>1000,8955=>871,8956=>718,8957=>871,8958=>718,8959=>871,
8960=>602,8961=>602,8962=>635,8963=>838,8964=>838,8965=>838,8966=>838,8967=>488,8968=>390,8969=>390,
8970=>390,8971=>390,8972=>809,8973=>809,8974=>809,8975=>809,8976=>838,8977=>513,8984=>1000,8985=>838,
8988=>469,8989=>469,8990=>469,8991=>469,8992=>521,8993=>521,8996=>1152,8997=>1152,8998=>1414,8999=>1152,
9000=>1443,9003=>1414,9004=>873,9075=>338,9076=>635,9077=>837,9082=>659,9085=>757,9095=>1152,9108=>873,
9115=>500,9116=>500,9117=>500,9118=>500,9119=>500,9120=>500,9121=>500,9122=>500,9123=>500,9124=>500,
9125=>500,9126=>500,9127=>750,9128=>750,9129=>750,9130=>750,9131=>750,9132=>750,9133=>750,9134=>521,
9166=>838,9167=>945,9187=>873,9189=>769,9250=>635,9251=>635,9312=>896,9313=>896,9314=>896,9315=>896,
9316=>896,9317=>896,9318=>896,9319=>896,9320=>896,9321=>896,9472=>602,9473=>602,9474=>602,9475=>602,
9476=>602,9477=>602,9478=>602,9479=>602,9480=>602,9481=>602,9482=>602,9483=>602,9484=>602,9485=>602,
9486=>602,9487=>602,9488=>602,9489=>602,9490=>602,9491=>602,9492=>602,9493=>602,9494=>602,9495=>602,
9496=>602,9497=>602,9498=>602,9499=>602,9500=>602,9501=>602,9502=>602,9503=>602,9504=>602,9505=>602,
9506=>602,9507=>602,9508=>602,9509=>602,9510=>602,9511=>602,9512=>602,9513=>602,9514=>602,9515=>602,
9516=>602,9517=>602,9518=>602,9519=>602,9520=>602,9521=>602,9522=>602,9523=>602,9524=>602,9525=>602,
9526=>602,9527=>602,9528=>602,9529=>602,9530=>602,9531=>602,9532=>602,9533=>602,9534=>602,9535=>602,
9536=>602,9537=>602,9538=>602,9539=>602,9540=>602,9541=>602,9542=>602,9543=>602,9544=>602,9545=>602,
9546=>602,9547=>602,9548=>602,9549=>602,9550=>602,9551=>602,9552=>602,9553=>602,9554=>602,9555=>602,
9556=>602,9557=>602,9558=>602,9559=>602,9560=>602,9561=>602,9562=>602,9563=>602,9564=>602,9565=>602,
9566=>602,9567=>602,9568=>602,9569=>602,9570=>602,9571=>602,9572=>602,9573=>602,9574=>602,9575=>602,
9576=>602,9577=>602,9578=>602,9579=>602,9580=>602,9581=>602,9582=>602,9583=>602,9584=>602,9585=>602,
9586=>602,9587=>602,9588=>602,9589=>602,9590=>602,9591=>602,9592=>602,9593=>602,9594=>602,9595=>602,
9596=>602,9597=>602,9598=>602,9599=>602,9600=>769,9601=>769,9602=>769,9603=>769,9604=>769,9605=>769,
9606=>769,9607=>769,9608=>769,9609=>769,9610=>769,9611=>769,9612=>769,9613=>769,9614=>769,9615=>769,
9616=>769,9617=>769,9618=>769,9619=>769,9620=>769,9621=>769,9622=>769,9623=>769,9624=>769,9625=>769,
9626=>769,9627=>769,9628=>769,9629=>769,9630=>769,9631=>769,9632=>945,9633=>945,9634=>945,9635=>945,
9636=>945,9637=>945,9638=>945,9639=>945,9640=>945,9641=>945,9642=>678,9643=>678,9644=>945,9645=>945,
9646=>550,9647=>550,9648=>769,9649=>769,9650=>769,9651=>769,9652=>502,9653=>502,9654=>769,9655=>769,
9656=>502,9657=>502,9658=>769,9659=>769,9660=>769,9661=>769,9662=>502,9663=>502,9664=>769,9665=>769,
9666=>502,9667=>502,9668=>769,9669=>769,9670=>769,9671=>769,9672=>769,9673=>873,9674=>494,9675=>873,
9676=>873,9677=>873,9678=>873,9679=>873,9680=>873,9681=>873,9682=>873,9683=>873,9684=>873,9685=>873,
9686=>527,9687=>527,9688=>791,9689=>970,9690=>970,9691=>970,9692=>387,9693=>387,9694=>387,9695=>387,
9696=>769,9697=>769,9698=>769,9699=>769,9700=>769,9701=>769,9702=>590,9703=>945,9704=>945,9705=>945,
9706=>945,9707=>945,9708=>769,9709=>769,9710=>769,9711=>1119,9712=>945,9713=>945,9714=>945,9715=>945,
9716=>873,9717=>873,9718=>873,9719=>873,9720=>769,9721=>769,9722=>769,9723=>830,9724=>830,9725=>732,
9726=>732,9727=>769,9728=>896,9729=>1000,9730=>896,9731=>896,9732=>896,9733=>896,9734=>896,9735=>573,
9736=>896,9737=>896,9738=>888,9739=>888,9740=>671,9741=>1013,9742=>1246,9743=>1250,9744=>896,9745=>896,
9746=>896,9747=>532,9748=>896,9749=>896,9750=>896,9751=>896,9752=>896,9753=>896,9754=>896,9755=>896,
9756=>896,9757=>609,9758=>896,9759=>609,9760=>896,9761=>896,9762=>896,9763=>896,9764=>669,9765=>746,
9766=>649,9767=>784,9768=>545,9769=>896,9770=>896,9771=>896,9772=>710,9773=>896,9774=>896,9775=>896,
9776=>890,9777=>890,9778=>890,9779=>890,9780=>890,9781=>890,9782=>890,9783=>890,9784=>896,9785=>896,
9786=>896,9787=>896,9788=>896,9789=>896,9790=>896,9791=>614,9792=>731,9793=>731,9794=>896,9795=>896,
9796=>896,9797=>896,9798=>896,9799=>896,9800=>896,9801=>896,9802=>896,9803=>896,9804=>896,9805=>896,
9806=>896,9807=>896,9808=>896,9809=>896,9810=>896,9811=>896,9812=>896,9813=>896,9814=>896,9815=>896,
9816=>896,9817=>896,9818=>896,9819=>896,9820=>896,9821=>896,9822=>896,9823=>896,9824=>896,9825=>896,
9826=>896,9827=>896,9828=>896,9829=>896,9830=>896,9831=>896,9832=>896,9833=>472,9834=>638,9835=>896,
9836=>896,9837=>472,9838=>357,9839=>484,9840=>748,9841=>766,9842=>896,9843=>896,9844=>896,9845=>896,
9846=>896,9847=>896,9848=>896,9849=>896,9850=>896,9851=>896,9852=>896,9853=>896,9854=>896,9855=>896,
9856=>869,9857=>869,9858=>869,9859=>869,9860=>869,9861=>869,9862=>890,9863=>890,9864=>890,9865=>890,
9866=>890,9867=>890,9868=>890,9869=>890,9870=>890,9871=>890,9872=>750,9873=>750,9874=>890,9875=>816,
9876=>716,9877=>537,9878=>852,9879=>890,9880=>684,9881=>890,9882=>708,9883=>890,9884=>890,9888=>890,
9889=>702,9890=>1003,9891=>1085,9892=>1143,9893=>901,9894=>838,9895=>838,9896=>838,9897=>838,9898=>838,
9899=>838,9900=>838,9901=>838,9902=>838,9903=>838,9904=>844,9905=>838,9906=>731,9907=>732,9908=>732,
9909=>732,9910=>850,9911=>732,9912=>732,9985=>838,9986=>838,9987=>838,9988=>838,9990=>838,9991=>838,
9992=>838,9993=>838,9996=>838,9997=>838,9998=>838,9999=>838,10000=>838,10001=>838,10002=>838,10003=>838,
10004=>838,10005=>838,10006=>838,10007=>838,10008=>838,10009=>838,10010=>838,10011=>838,10012=>838,10013=>838,
10014=>838,10015=>838,10016=>838,10017=>838,10018=>838,10019=>838,10020=>838,10021=>838,10022=>838,10023=>838,
10025=>838,10026=>838,10027=>838,10028=>838,10029=>838,10030=>838,10031=>838,10032=>838,10033=>838,10034=>838,
10035=>838,10036=>838,10037=>838,10038=>838,10039=>838,10040=>838,10041=>838,10042=>838,10043=>838,10044=>838,
10045=>838,10046=>838,10047=>838,10048=>838,10049=>838,10050=>838,10051=>838,10052=>838,10053=>838,10054=>838,
10055=>838,10056=>838,10057=>838,10058=>838,10059=>838,10061=>896,10063=>896,10064=>896,10065=>896,10066=>896,
10070=>896,10072=>838,10073=>838,10074=>838,10075=>322,10076=>322,10077=>538,10078=>538,10081=>838,10082=>838,
10083=>838,10084=>838,10085=>838,10086=>838,10087=>838,10088=>838,10089=>838,10090=>838,10091=>838,10092=>838,
10093=>838,10094=>838,10095=>838,10096=>838,10097=>838,10098=>838,10099=>838,10100=>838,10101=>838,10102=>896,
10103=>896,10104=>896,10105=>896,10106=>896,10107=>896,10108=>896,10109=>896,10110=>896,10111=>896,10112=>838,
10113=>838,10114=>838,10115=>838,10116=>838,10117=>838,10118=>838,10119=>838,10120=>838,10121=>838,10122=>838,
10123=>838,10124=>838,10125=>838,10126=>838,10127=>838,10128=>838,10129=>838,10130=>838,10131=>838,10132=>838,
10136=>838,10137=>838,10138=>838,10139=>838,10140=>838,10141=>838,10142=>838,10143=>838,10144=>838,10145=>838,
10146=>838,10147=>838,10148=>838,10149=>838,10150=>838,10151=>838,10152=>838,10153=>838,10154=>838,10155=>838,
10156=>838,10157=>838,10158=>838,10159=>838,10161=>838,10162=>838,10163=>838,10164=>838,10165=>838,10166=>838,
10167=>838,10168=>838,10169=>838,10170=>838,10171=>838,10172=>838,10173=>838,10174=>838,10181=>390,10182=>390,
10208=>494,10214=>495,10215=>495,10216=>390,10217=>390,10218=>556,10219=>556,10224=>838,10225=>838,10226=>838,
10227=>838,10228=>1157,10229=>1434,10230=>1434,10231=>1434,10232=>1434,10233=>1434,10234=>1434,10235=>1434,10236=>1434,
10237=>1434,10238=>1434,10239=>1434,10240=>732,10241=>732,10242=>732,10243=>732,10244=>732,10245=>732,10246=>732,
10247=>732,10248=>732,10249=>732,10250=>732,10251=>732,10252=>732,10253=>732,10254=>732,10255=>732,10256=>732,
10257=>732,10258=>732,10259=>732,10260=>732,10261=>732,10262=>732,10263=>732,10264=>732,10265=>732,10266=>732,
10267=>732,10268=>732,10269=>732,10270=>732,10271=>732,10272=>732,10273=>732,10274=>732,10275=>732,10276=>732,
10277=>732,10278=>732,10279=>732,10280=>732,10281=>732,10282=>732,10283=>732,10284=>732,10285=>732,10286=>732,
10287=>732,10288=>732,10289=>732,10290=>732,10291=>732,10292=>732,10293=>732,10294=>732,10295=>732,10296=>732,
10297=>732,10298=>732,10299=>732,10300=>732,10301=>732,10302=>732,10303=>732,10304=>732,10305=>732,10306=>732,
10307=>732,10308=>732,10309=>732,10310=>732,10311=>732,10312=>732,10313=>732,10314=>732,10315=>732,10316=>732,
10317=>732,10318=>732,10319=>732,10320=>732,10321=>732,10322=>732,10323=>732,10324=>732,10325=>732,10326=>732,
10327=>732,10328=>732,10329=>732,10330=>732,10331=>732,10332=>732,10333=>732,10334=>732,10335=>732,10336=>732,
10337=>732,10338=>732,10339=>732,10340=>732,10341=>732,10342=>732,10343=>732,10344=>732,10345=>732,10346=>732,
10347=>732,10348=>732,10349=>732,10350=>732,10351=>732,10352=>732,10353=>732,10354=>732,10355=>732,10356=>732,
10357=>732,10358=>732,10359=>732,10360=>732,10361=>732,10362=>732,10363=>732,10364=>732,10365=>732,10366=>732,
10367=>732,10368=>732,10369=>732,10370=>732,10371=>732,10372=>732,10373=>732,10374=>732,10375=>732,10376=>732,
10377=>732,10378=>732,10379=>732,10380=>732,10381=>732,10382=>732,10383=>732,10384=>732,10385=>732,10386=>732,
10387=>732,10388=>732,10389=>732,10390=>732,10391=>732,10392=>732,10393=>732,10394=>732,10395=>732,10396=>732,
10397=>732,10398=>732,10399=>732,10400=>732,10401=>732,10402=>732,10403=>732,10404=>732,10405=>732,10406=>732,
10407=>732,10408=>732,10409=>732,10410=>732,10411=>732,10412=>732,10413=>732,10414=>732,10415=>732,10416=>732,
10417=>732,10418=>732,10419=>732,10420=>732,10421=>732,10422=>732,10423=>732,10424=>732,10425=>732,10426=>732,
10427=>732,10428=>732,10429=>732,10430=>732,10431=>732,10432=>732,10433=>732,10434=>732,10435=>732,10436=>732,
10437=>732,10438=>732,10439=>732,10440=>732,10441=>732,10442=>732,10443=>732,10444=>732,10445=>732,10446=>732,
10447=>732,10448=>732,10449=>732,10450=>732,10451=>732,10452=>732,10453=>732,10454=>732,10455=>732,10456=>732,
10457=>732,10458=>732,10459=>732,10460=>732,10461=>732,10462=>732,10463=>732,10464=>732,10465=>732,10466=>732,
10467=>732,10468=>732,10469=>732,10470=>732,10471=>732,10472=>732,10473=>732,10474=>732,10475=>732,10476=>732,
10477=>732,10478=>732,10479=>732,10480=>732,10481=>732,10482=>732,10483=>732,10484=>732,10485=>732,10486=>732,
10487=>732,10488=>732,10489=>732,10490=>732,10491=>732,10492=>732,10493=>732,10494=>732,10495=>732,10502=>838,
10503=>838,10506=>838,10507=>838,10560=>683,10561=>683,10627=>734,10628=>734,10702=>838,10703=>1000,10704=>1000,
10705=>1000,10706=>1000,10707=>1000,10708=>1000,10709=>1000,10731=>494,10746=>838,10747=>838,10752=>1000,10753=>1000,
10754=>1000,10764=>1325,10765=>521,10766=>521,10767=>521,10768=>521,10769=>521,10770=>521,10771=>521,10772=>521,
10773=>521,10774=>521,10775=>521,10776=>521,10777=>521,10778=>521,10779=>521,10780=>521,10799=>838,10877=>838,
10878=>838,10879=>838,10880=>838,10881=>838,10882=>838,10883=>838,10884=>838,10885=>838,10886=>838,10887=>838,
10888=>838,10889=>838,10890=>838,10891=>838,10892=>838,10893=>838,10894=>838,10895=>838,10896=>838,10897=>838,
10898=>838,10899=>838,10900=>838,10901=>838,10902=>838,10903=>838,10904=>838,10905=>838,10906=>838,10907=>838,
10908=>838,10909=>838,10910=>838,10911=>838,10912=>838,10926=>838,10927=>838,10928=>838,10929=>838,10930=>838,
10931=>838,10932=>838,10933=>838,10934=>838,10935=>838,10936=>838,10937=>838,10938=>838,11001=>838,11002=>838,
11008=>838,11009=>838,11010=>838,11011=>838,11012=>838,11013=>838,11014=>838,11015=>838,11016=>838,11017=>838,
11018=>838,11019=>838,11020=>838,11021=>838,11022=>836,11023=>836,11024=>836,11025=>836,11026=>945,11027=>945,
11028=>945,11029=>945,11030=>769,11031=>769,11032=>769,11033=>769,11034=>945,11039=>869,11040=>869,11041=>873,
11042=>873,11043=>873,11044=>1119,11091=>869,11092=>869,11360=>557,11361=>278,11362=>557,11363=>603,11364=>695,
11365=>613,11366=>392,11367=>752,11368=>634,11369=>656,11370=>579,11371=>685,11372=>525,11373=>781,11374=>863,
11375=>684,11377=>734,11378=>1128,11379=>961,11380=>592,11381=>654,11382=>568,11383=>660,11385=>414,11386=>612,
11387=>491,11388=>175,11389=>431,11800=>531,11810=>390,11811=>390,11812=>390,11813=>390,11822=>531,19904=>896,
19905=>896,19906=>896,19907=>896,19908=>896,19909=>896,19910=>896,19911=>896,19912=>896,19913=>896,19914=>896,
19915=>896,19916=>896,19917=>896,19918=>896,19919=>896,19920=>896,19921=>896,19922=>896,19923=>896,19924=>896,
19925=>896,19926=>896,19927=>896,19928=>896,19929=>896,19930=>896,19931=>896,19932=>896,19933=>896,19934=>896,
19935=>896,19936=>896,19937=>896,19938=>896,19939=>896,19940=>896,19941=>896,19942=>896,19943=>896,19944=>896,
19945=>896,19946=>896,19947=>896,19948=>896,19949=>896,19950=>896,19951=>896,19952=>896,19953=>896,19954=>896,
19955=>896,19956=>896,19957=>896,19958=>896,19959=>896,19960=>896,19961=>896,19962=>896,19963=>896,19964=>896,
19965=>896,19966=>896,19967=>896,42564=>635,42565=>521,42566=>354,42567=>338,42572=>1180,42573=>1028,42576=>1029,
42577=>906,42580=>1080,42581=>842,42582=>985,42583=>847,42594=>1024,42595=>925,42596=>1014,42597=>900,42598=>863,
42599=>1008,42600=>787,42601=>612,42602=>855,42603=>712,42604=>1358,42605=>1019,42606=>879,42634=>805,42635=>722,
42636=>611,42637=>583,42644=>686,42645=>634,42760=>493,42761=>493,42762=>493,42763=>493,42764=>493,42765=>493,
42766=>493,42767=>493,42768=>493,42769=>493,42770=>493,42771=>493,42772=>493,42773=>493,42774=>493,42779=>369,
42780=>369,42781=>252,42782=>252,42783=>252,42790=>752,42791=>634,42792=>878,42793=>709,42794=>614,42795=>541,
42800=>491,42801=>521,42802=>1250,42803=>985,42804=>1219,42805=>1000,42806=>1155,42807=>996,42808=>971,42809=>818,
42810=>971,42811=>818,42812=>959,42813=>818,42814=>698,42815=>549,42822=>680,42823=>392,42824=>582,42825=>427,
42826=>807,42827=>704,42830=>1358,42831=>1019,42880=>557,42881=>278,42882=>735,42883=>634,42889=>337,42890=>376,
42891=>401,42892=>275,43003=>575,43004=>603,43005=>863,43006=>295,43007=>1199,63173=>612,64256=>722,64257=>646,
64258=>646,64259=>1000,64260=>1000,64261=>686,64262=>861,64275=>1202,64276=>1202,64277=>1196,64278=>1186,64279=>1529,
64285=>272,64286=>0,64287=>471,64288=>636,64289=>856,64290=>774,64291=>906,64292=>771,64293=>843,64294=>855,
64295=>807,64296=>875,64297=>838,64298=>808,64299=>808,64300=>808,64301=>808,64302=>629,64303=>629,64304=>629,
64305=>608,64306=>448,64307=>594,64308=>640,64309=>272,64310=>374,64311=>1000,64312=>648,64313=>336,64314=>592,
64315=>556,64316=>599,64318=>659,64320=>441,64321=>700,64323=>640,64324=>604,64326=>581,64327=>663,64328=>592,
64329=>808,64330=>657,64331=>272,64332=>608,64333=>556,64334=>604,64335=>629,65024=>0,65025=>0,65026=>0,
65027=>0,65028=>0,65029=>0,65030=>0,65031=>0,65032=>0,65033=>0,65034=>0,65035=>0,65036=>0,
65037=>0,65038=>0,65039=>0,65056=>0,65057=>0,65058=>0,65059=>0,65529=>0,65530=>0,65531=>0,
65532=>0,65533=>1025);
$enc='';
$diff='';
$file='dejavusansi.z';
$ctg='dejavusansi.ctg.z';
$originalsize=523804;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/dejavusansi.php | PHP | asf20 | 46,180 |
<?php
$type='TrueTypeUnicode';
$name='DejaVuSerifCondensed-Italic';
$desc=array('Ascent'=>928,'Descent'=>-236,'CapHeight'=>-59,'Flags'=>96,'FontBBox'=>'[-755 -347 1485 1227]','ItalicAngle'=>-11,'StemV'=>70,'MissingWidth'=>540);
$up=-63;
$ut=44;
$dw=540;
$cw=array(
0=>540,32=>286,33=>361,34=>414,35=>754,36=>572,37=>855,38=>801,39=>247,40=>351,
41=>351,42=>450,43=>754,44=>286,45=>304,46=>286,47=>303,48=>572,49=>572,50=>572,
51=>572,52=>572,53=>572,54=>572,55=>572,56=>572,57=>572,58=>303,59=>303,60=>754,
61=>754,62=>754,63=>482,64=>900,65=>650,66=>661,67=>688,68=>721,69=>657,70=>624,
71=>719,72=>785,73=>355,74=>360,75=>672,76=>598,77=>921,78=>787,79=>738,80=>605,
81=>738,82=>677,83=>616,84=>600,85=>758,86=>650,87=>925,88=>641,89=>594,90=>625,
91=>351,92=>303,93=>351,94=>754,95=>450,96=>450,97=>536,98=>576,99=>504,100=>576,
101=>532,102=>333,103=>576,104=>580,105=>288,106=>279,107=>545,108=>288,109=>853,110=>580,
111=>542,112=>576,113=>576,114=>430,115=>461,116=>361,117=>580,118=>508,119=>770,120=>507,
121=>508,122=>474,123=>572,124=>303,125=>572,126=>754,8364=>572,8218=>286,402=>333,8222=>466,
8230=>900,8224=>450,8225=>450,710=>450,8240=>1208,352=>616,8249=>360,338=>1023,381=>625,8216=>286,
8217=>286,8220=>460,8221=>460,8226=>531,8211=>450,8212=>900,732=>450,8482=>900,353=>461,8250=>360,
339=>890,382=>474,376=>594,160=>286,161=>361,162=>572,163=>572,164=>572,165=>572,166=>303,
167=>450,168=>450,169=>900,170=>427,171=>550,172=>754,173=>304,174=>900,175=>450,176=>450,
177=>754,178=>360,179=>360,180=>450,181=>584,182=>572,183=>286,184=>450,185=>360,186=>423,
187=>550,188=>872,189=>872,190=>872,191=>482,192=>650,193=>650,194=>650,195=>650,196=>650,
197=>650,198=>901,199=>688,200=>657,201=>657,202=>657,203=>657,204=>355,205=>355,206=>355,
207=>355,208=>726,209=>787,210=>738,211=>738,212=>738,213=>738,214=>738,215=>754,216=>738,
217=>758,218=>758,219=>758,220=>758,221=>594,222=>608,223=>601,224=>536,225=>536,226=>536,
227=>536,228=>536,229=>536,230=>846,231=>504,232=>532,233=>532,234=>532,235=>532,236=>288,
237=>288,238=>288,239=>288,240=>542,241=>580,242=>542,243=>542,244=>542,245=>542,246=>542,
247=>754,248=>542,249=>580,250=>580,251=>580,252=>580,253=>508,254=>576,255=>508,256=>650,
257=>536,258=>650,259=>536,260=>650,261=>536,262=>688,263=>504,264=>688,265=>504,266=>688,
267=>504,268=>688,269=>504,270=>721,271=>576,272=>726,273=>576,274=>657,275=>532,276=>657,
277=>532,278=>657,279=>532,280=>657,281=>532,282=>657,283=>532,284=>719,285=>576,286=>719,
287=>576,288=>719,289=>576,290=>719,291=>576,292=>785,293=>580,294=>785,295=>580,296=>355,
297=>288,298=>355,299=>288,300=>355,301=>288,302=>355,303=>288,304=>355,305=>288,306=>721,
307=>479,308=>360,309=>279,310=>672,311=>545,312=>545,313=>598,314=>288,315=>598,316=>288,
317=>598,318=>360,319=>604,320=>418,321=>602,322=>292,323=>787,324=>580,325=>787,326=>580,
327=>787,328=>580,329=>779,330=>758,331=>580,332=>738,333=>542,334=>738,335=>542,336=>738,
337=>542,340=>677,341=>430,342=>677,343=>430,344=>677,345=>430,346=>616,347=>461,348=>616,
349=>461,350=>616,351=>461,354=>600,355=>361,356=>600,357=>361,358=>600,359=>361,360=>758,
361=>580,362=>758,363=>580,364=>758,365=>580,366=>758,367=>580,368=>758,369=>580,370=>758,
371=>580,372=>925,373=>770,374=>594,375=>508,377=>625,378=>474,379=>625,380=>474,383=>333,
384=>576,385=>661,386=>661,387=>576,388=>661,389=>576,390=>688,391=>688,392=>504,393=>726,
394=>721,395=>661,396=>576,397=>542,398=>657,399=>738,400=>561,401=>624,403=>719,404=>641,
405=>839,406=>355,407=>355,408=>672,409=>545,410=>288,411=>570,412=>853,413=>787,414=>580,
415=>738,416=>738,417=>542,418=>936,419=>726,420=>605,421=>576,422=>677,423=>616,424=>461,
425=>636,426=>292,427=>361,428=>600,429=>361,430=>600,431=>758,432=>580,433=>746,434=>684,
435=>664,436=>670,437=>625,438=>474,439=>508,440=>508,441=>508,443=>572,444=>618,445=>508,
446=>482,448=>265,449=>443,450=>413,451=>265,452=>1347,453=>1195,454=>1050,455=>958,456=>876,
457=>567,458=>1148,459=>1066,460=>858,461=>650,462=>536,463=>355,464=>288,465=>738,466=>542,
467=>758,468=>580,469=>758,470=>580,471=>758,472=>580,473=>758,474=>580,475=>758,476=>580,
477=>532,478=>650,479=>536,480=>650,481=>536,482=>901,483=>846,484=>763,485=>576,486=>719,
487=>576,488=>672,489=>545,490=>738,491=>542,492=>738,493=>542,494=>508,495=>508,496=>288,
497=>1347,498=>1195,499=>1050,500=>719,501=>576,502=>1038,504=>787,505=>580,506=>650,507=>536,
508=>901,509=>846,510=>738,511=>542,512=>650,513=>536,514=>650,515=>536,516=>657,517=>532,
518=>657,519=>532,520=>355,521=>288,522=>355,523=>288,524=>738,525=>542,526=>738,527=>542,
528=>677,529=>430,530=>677,531=>430,532=>758,533=>580,534=>758,535=>580,536=>616,537=>461,
538=>600,539=>361,540=>564,541=>469,542=>785,543=>580,544=>758,545=>732,548=>625,549=>474,
550=>650,551=>536,552=>657,553=>532,554=>738,555=>542,556=>738,557=>542,558=>738,559=>542,
560=>738,561=>542,562=>594,563=>508,564=>450,565=>748,566=>444,567=>279,568=>864,569=>864,
570=>650,571=>688,572=>504,573=>598,574=>600,575=>461,576=>474,577=>525,578=>417,581=>650,
592=>536,593=>576,594=>607,595=>576,596=>504,597=>504,598=>582,599=>614,600=>532,601=>532,
602=>759,603=>483,604=>458,605=>695,606=>552,607=>283,608=>615,609=>576,610=>489,611=>641,
612=>507,613=>580,614=>580,615=>580,616=>288,617=>353,618=>288,619=>342,620=>409,621=>326,
622=>633,623=>853,624=>853,625=>853,626=>579,627=>624,628=>581,629=>542,630=>711,631=>583,
632=>542,633=>451,634=>451,635=>496,636=>430,637=>430,638=>407,639=>407,640=>534,641=>534,
642=>461,643=>244,644=>333,645=>438,646=>292,647=>361,648=>361,649=>580,650=>558,651=>547,
652=>508,653=>770,654=>508,655=>589,656=>537,657=>504,658=>508,659=>504,660=>482,661=>482,
662=>482,663=>461,664=>738,665=>506,666=>552,667=>588,668=>600,669=>329,670=>545,671=>581,
672=>615,673=>482,674=>482,675=>896,676=>930,677=>898,678=>728,679=>538,680=>704,681=>804,
682=>582,683=>608,684=>538,685=>398,686=>703,687=>690,688=>389,689=>387,690=>237,691=>312,
692=>312,693=>387,694=>352,695=>485,696=>320,697=>250,699=>286,700=>286,701=>286,702=>276,
703=>276,704=>252,705=>252,711=>450,712=>254,713=>450,716=>254,720=>303,721=>303,722=>276,
723=>276,726=>353,728=>450,729=>450,730=>450,731=>450,733=>450,734=>375,736=>403,737=>218,
738=>303,739=>319,740=>252,741=>444,742=>444,743=>444,744=>444,745=>444,750=>435,768=>0,
769=>0,770=>0,771=>0,772=>0,773=>0,774=>0,775=>0,776=>0,777=>0,778=>0,
779=>0,780=>0,781=>0,782=>0,783=>0,784=>0,785=>0,786=>0,787=>0,788=>0,
789=>0,790=>0,791=>0,792=>0,793=>0,794=>0,795=>0,796=>0,797=>0,798=>0,
799=>0,800=>0,801=>0,802=>0,803=>0,804=>0,805=>0,806=>0,807=>0,808=>0,
809=>0,810=>0,811=>0,812=>0,813=>0,814=>0,815=>0,816=>0,817=>0,818=>0,
819=>0,820=>0,821=>0,822=>0,823=>0,824=>0,825=>0,826=>0,827=>0,828=>0,
829=>0,830=>0,831=>0,835=>0,847=>0,856=>0,865=>0,880=>666,881=>478,884=>250,
885=>250,890=>450,891=>504,892=>504,893=>504,894=>303,900=>450,901=>450,902=>650,903=>286,
904=>810,905=>935,906=>505,908=>751,910=>808,911=>767,912=>353,913=>650,914=>661,915=>624,
916=>650,917=>657,918=>625,919=>785,920=>738,921=>355,922=>672,923=>650,924=>921,925=>787,
926=>633,927=>738,928=>785,929=>605,931=>636,932=>600,933=>594,934=>738,935=>641,936=>789,
937=>746,938=>355,939=>594,940=>607,941=>483,942=>539,943=>353,944=>547,945=>607,946=>520,
947=>538,948=>542,949=>483,950=>488,951=>539,952=>542,953=>353,954=>590,955=>570,956=>584,
957=>547,958=>496,959=>542,960=>591,961=>529,962=>504,963=>614,964=>498,965=>547,966=>630,
967=>545,968=>706,969=>734,970=>353,971=>547,972=>542,973=>547,974=>734,976=>524,977=>643,
978=>618,979=>787,980=>618,981=>613,982=>734,983=>561,984=>738,985=>542,986=>688,987=>504,
988=>624,989=>417,990=>531,991=>593,992=>704,993=>519,1008=>561,1009=>529,1010=>504,1011=>279,
1012=>738,1013=>504,1014=>504,1015=>608,1016=>576,1017=>688,1018=>921,1019=>637,1020=>529,1021=>688,
1022=>688,1023=>688,1024=>657,1025=>657,1026=>719,1027=>596,1028=>688,1029=>616,1030=>355,1031=>355,
1032=>360,1033=>976,1034=>1006,1035=>785,1036=>696,1037=>785,1038=>650,1039=>785,1040=>681,1041=>661,
1042=>661,1043=>596,1044=>731,1045=>657,1046=>1011,1047=>561,1048=>785,1049=>785,1050=>696,1051=>751,
1052=>921,1053=>785,1054=>738,1055=>785,1056=>605,1057=>688,1058=>600,1059=>650,1060=>747,1061=>641,
1062=>785,1063=>695,1064=>1027,1065=>1027,1066=>715,1067=>885,1068=>606,1069=>688,1070=>1074,1071=>727,
1072=>536,1073=>549,1074=>523,1075=>455,1076=>570,1077=>532,1078=>1023,1079=>491,1080=>580,1081=>580,
1082=>537,1083=>573,1084=>746,1085=>593,1086=>542,1087=>580,1088=>576,1089=>504,1090=>853,1091=>522,
1092=>704,1093=>507,1094=>628,1095=>560,1096=>853,1097=>901,1098=>600,1099=>733,1100=>490,1101=>504,
1102=>792,1103=>596,1104=>532,1105=>532,1106=>561,1107=>455,1108=>504,1109=>461,1110=>288,1111=>288,
1112=>279,1113=>773,1114=>790,1115=>580,1116=>537,1117=>580,1118=>522,1119=>580,1122=>686,1123=>794,
1124=>1016,1125=>750,1130=>1011,1131=>828,1136=>849,1137=>812,1138=>738,1139=>497,1140=>773,1141=>610,
1164=>636,1165=>490,1168=>604,1169=>476,1170=>596,1171=>455,1172=>657,1173=>552,1174=>1011,1175=>1023,
1176=>561,1177=>491,1178=>696,1179=>544,1182=>696,1183=>537,1184=>803,1185=>602,1186=>785,1187=>641,
1188=>1025,1189=>771,1190=>1085,1191=>848,1194=>688,1195=>504,1196=>600,1197=>911,1198=>594,1199=>514,
1200=>594,1201=>514,1202=>641,1203=>566,1204=>842,1205=>659,1206=>674,1207=>609,1210=>674,1211=>580,
1216=>355,1217=>1011,1218=>1023,1219=>672,1220=>545,1223=>785,1224=>600,1227=>674,1228=>600,1231=>288,
1232=>681,1233=>536,1234=>681,1235=>536,1236=>901,1237=>846,1238=>657,1239=>532,1240=>738,1241=>532,
1242=>738,1243=>532,1244=>1011,1245=>1023,1246=>561,1247=>491,1248=>508,1249=>508,1250=>785,1251=>580,
1252=>785,1253=>580,1254=>738,1255=>542,1256=>738,1257=>542,1258=>738,1259=>542,1260=>688,1261=>504,
1262=>650,1263=>522,1264=>650,1265=>522,1266=>650,1267=>522,1268=>695,1269=>560,1270=>596,1271=>455,
1272=>885,1273=>733,1296=>561,1297=>491,1298=>751,1299=>573,1300=>1079,1301=>845,1306=>738,1307=>576,
1308=>925,1309=>770,4256=>659,4257=>773,4258=>753,4259=>782,4260=>668,4261=>892,4262=>833,4263=>1000,
4264=>519,4265=>684,4266=>875,4267=>856,4268=>677,4269=>976,4270=>815,4271=>754,4272=>944,4273=>668,
4274=>611,4275=>922,4276=>852,4277=>926,4278=>667,4279=>668,4280=>668,4281=>668,4282=>800,4283=>852,
4284=>651,4285=>688,4286=>668,4287=>871,4288=>909,4289=>641,4290=>786,4291=>669,4292=>762,4293=>864,
4304=>495,4305=>523,4306=>539,4307=>759,4308=>514,4309=>510,4310=>558,4311=>783,4312=>512,4313=>500,
4314=>968,4315=>536,4316=>536,4317=>751,4318=>521,4319=>531,4320=>750,4321=>546,4322=>682,4323=>631,
4324=>742,4325=>535,4326=>781,4327=>520,4328=>543,4329=>536,4330=>616,4331=>537,4332=>501,4333=>527,
4334=>562,4335=>624,4336=>523,4337=>551,4338=>523,4339=>523,4340=>522,4341=>593,4342=>806,4343=>572,
4344=>532,4345=>565,4346=>522,4347=>410,4348=>335,7426=>846,7432=>458,7433=>288,7444=>890,7446=>542,
7447=>542,7453=>663,7454=>853,7455=>853,7468=>409,7469=>567,7470=>417,7472=>454,7473=>413,7474=>413,
7475=>453,7476=>494,7477=>224,7478=>227,7479=>423,7480=>376,7481=>580,7482=>496,7483=>496,7484=>464,
7486=>381,7487=>426,7488=>378,7489=>478,7490=>583,7491=>347,7492=>347,7493=>360,7494=>556,7495=>360,
7496=>360,7497=>348,7498=>348,7499=>385,7500=>306,7501=>360,7502=>157,7503=>328,7504=>552,7505=>359,
7506=>347,7507=>312,7508=>347,7509=>347,7510=>360,7511=>222,7512=>359,7513=>417,7514=>552,7515=>335,
7522=>181,7523=>312,7524=>359,7525=>335,7543=>576,7544=>494,7547=>334,7557=>288,7579=>439,7580=>317,
7581=>317,7582=>426,7583=>385,7584=>209,7585=>285,7586=>439,7587=>359,7588=>181,7589=>181,7590=>181,
7591=>181,7592=>286,7593=>237,7594=>236,7595=>409,7596=>552,7597=>552,7598=>445,7599=>443,7600=>438,
7601=>347,7602=>426,7603=>374,7604=>269,7605=>301,7606=>359,7607=>429,7609=>417,7610=>320,7611=>298,
7612=>376,7613=>376,7614=>406,7615=>426,7620=>0,7621=>0,7622=>0,7623=>0,7624=>0,7625=>0,
7680=>650,7681=>536,7682=>661,7683=>576,7684=>661,7685=>576,7686=>661,7687=>576,7688=>688,7689=>504,
7690=>721,7691=>576,7692=>721,7693=>576,7694=>721,7695=>576,7696=>721,7697=>576,7698=>721,7699=>576,
7700=>657,7701=>532,7702=>657,7703=>532,7704=>657,7705=>532,7706=>657,7707=>532,7708=>657,7709=>532,
7710=>624,7711=>333,7712=>719,7713=>576,7714=>785,7715=>580,7716=>785,7717=>580,7718=>785,7719=>580,
7720=>785,7721=>580,7722=>785,7723=>580,7724=>355,7725=>288,7728=>672,7729=>545,7730=>672,7731=>545,
7732=>672,7733=>545,7734=>598,7735=>288,7736=>598,7737=>288,7738=>598,7739=>288,7740=>598,7741=>288,
7742=>921,7743=>853,7744=>921,7745=>853,7746=>921,7747=>857,7748=>787,7749=>580,7750=>787,7751=>580,
7752=>787,7753=>580,7754=>787,7755=>580,7756=>738,7757=>542,7760=>738,7761=>542,7762=>738,7763=>542,
7764=>605,7765=>576,7766=>605,7767=>576,7768=>677,7769=>430,7770=>677,7771=>430,7772=>677,7773=>430,
7774=>677,7775=>430,7776=>616,7777=>461,7778=>616,7779=>461,7784=>616,7785=>461,7786=>600,7787=>361,
7788=>600,7789=>361,7790=>600,7791=>361,7792=>600,7793=>361,7794=>758,7795=>580,7796=>758,7797=>580,
7798=>758,7799=>580,7800=>758,7801=>580,7802=>758,7803=>580,7804=>650,7805=>508,7806=>650,7807=>508,
7808=>925,7809=>770,7810=>925,7811=>770,7812=>925,7813=>770,7814=>925,7815=>770,7816=>925,7817=>770,
7818=>641,7819=>507,7820=>641,7821=>507,7822=>594,7823=>508,7824=>625,7825=>474,7826=>625,7827=>474,
7828=>625,7829=>474,7830=>580,7831=>361,7832=>770,7833=>508,7834=>813,7835=>333,7838=>746,7839=>542,
7840=>650,7841=>536,7842=>650,7843=>536,7852=>650,7853=>536,7854=>650,7855=>536,7856=>650,7857=>536,
7858=>650,7859=>536,7860=>650,7861=>536,7862=>650,7863=>536,7864=>657,7865=>532,7866=>657,7867=>532,
7868=>657,7869=>532,7878=>657,7879=>532,7880=>355,7881=>288,7882=>355,7883=>288,7884=>738,7885=>542,
7886=>738,7887=>542,7896=>738,7897=>542,7908=>758,7909=>580,7910=>758,7911=>580,7922=>594,7923=>508,
7924=>594,7925=>508,7926=>594,7927=>508,7928=>594,7929=>508,7936=>607,7937=>607,7938=>607,7939=>607,
7940=>607,7941=>607,7942=>607,7943=>607,7944=>650,7945=>650,7946=>782,7947=>782,7948=>660,7949=>687,
7950=>650,7951=>650,7952=>483,7953=>483,7954=>483,7955=>483,7956=>483,7957=>483,7960=>768,7961=>757,
7962=>960,7963=>969,7964=>907,7965=>931,7968=>539,7969=>539,7970=>539,7971=>539,7972=>539,7973=>539,
7974=>539,7975=>539,7976=>898,7977=>893,7978=>1090,7979=>1101,7980=>1043,7981=>1064,7982=>988,7983=>985,
7984=>353,7985=>353,7986=>353,7987=>353,7988=>353,7989=>353,7990=>353,7991=>353,7992=>469,7993=>461,
7994=>661,7995=>664,7996=>611,7997=>635,7998=>561,7999=>553,8000=>542,8001=>542,8002=>542,8003=>542,
8004=>542,8005=>542,8008=>738,8009=>773,8010=>1008,8011=>1015,8012=>843,8013=>867,8016=>547,8017=>547,
8018=>547,8019=>547,8020=>547,8021=>547,8022=>547,8023=>547,8025=>765,8027=>971,8029=>939,8031=>857,
8032=>734,8033=>734,8034=>734,8035=>734,8036=>734,8037=>734,8038=>734,8039=>734,8040=>746,8041=>783,
8042=>1018,8043=>1023,8044=>852,8045=>878,8046=>844,8047=>873,8048=>607,8049=>607,8050=>483,8051=>483,
8052=>539,8053=>539,8054=>353,8055=>353,8056=>542,8057=>542,8058=>547,8059=>547,8060=>734,8061=>734,
8064=>607,8065=>607,8066=>607,8067=>607,8068=>607,8069=>607,8070=>607,8071=>607,8072=>650,8073=>650,
8074=>782,8075=>782,8076=>660,8077=>687,8078=>650,8079=>650,8080=>539,8081=>539,8082=>539,8083=>539,
8084=>539,8085=>539,8086=>539,8087=>539,8088=>898,8089=>893,8090=>1090,8091=>1101,8092=>1043,8093=>1064,
8094=>988,8095=>985,8096=>734,8097=>734,8098=>734,8099=>734,8100=>734,8101=>734,8102=>734,8103=>734,
8104=>746,8105=>783,8106=>1018,8107=>1023,8108=>852,8109=>878,8110=>844,8111=>873,8112=>607,8113=>607,
8114=>607,8115=>607,8116=>607,8118=>607,8119=>607,8120=>650,8121=>650,8122=>650,8123=>650,8124=>650,
8125=>450,8126=>450,8127=>450,8128=>450,8129=>450,8130=>539,8131=>539,8132=>539,8134=>539,8135=>539,
8136=>820,8137=>810,8138=>956,8139=>935,8140=>785,8141=>450,8142=>450,8143=>450,8144=>353,8145=>353,
8146=>353,8147=>353,8150=>353,8151=>353,8152=>355,8153=>355,8154=>529,8155=>505,8157=>450,8158=>450,
8159=>450,8160=>547,8161=>547,8162=>547,8163=>547,8164=>529,8165=>529,8166=>547,8167=>547,8168=>594,
8169=>594,8170=>829,8171=>808,8172=>711,8173=>450,8174=>450,8175=>450,8178=>734,8179=>734,8180=>734,
8182=>734,8183=>734,8184=>865,8185=>751,8186=>886,8187=>767,8188=>746,8189=>450,8190=>450,8192=>450,
8193=>900,8194=>450,8195=>900,8196=>296,8197=>225,8198=>150,8199=>572,8200=>286,8201=>180,8202=>89,
8203=>0,8204=>0,8205=>0,8206=>0,8207=>0,8208=>304,8209=>304,8210=>572,8213=>900,8214=>450,
8215=>450,8219=>286,8223=>460,8227=>531,8228=>301,8229=>600,8234=>0,8235=>0,8236=>0,8237=>0,
8238=>0,8239=>180,8241=>1560,8242=>204,8243=>336,8244=>468,8245=>204,8246=>336,8247=>468,8248=>305,
8252=>475,8253=>482,8254=>450,8258=>900,8260=>150,8261=>351,8262=>351,8263=>878,8264=>678,8265=>678,
8267=>572,8268=>450,8269=>450,8270=>450,8271=>303,8273=>450,8274=>404,8275=>900,8279=>597,8287=>200,
8288=>0,8289=>0,8290=>0,8291=>0,8292=>0,8298=>0,8299=>0,8300=>0,8301=>0,8302=>0,
8303=>0,8304=>360,8305=>181,8308=>360,8309=>360,8310=>360,8311=>360,8312=>360,8313=>360,8314=>475,
8315=>475,8316=>475,8317=>221,8318=>221,8319=>365,8320=>360,8321=>360,8322=>360,8323=>360,8324=>360,
8325=>360,8326=>360,8327=>360,8328=>360,8329=>360,8330=>475,8331=>475,8332=>475,8333=>221,8334=>221,
8336=>347,8337=>348,8338=>347,8339=>319,8340=>348,8358=>594,8367=>951,8369=>635,8372=>702,8373=>572,
8451=>1006,8457=>942,8462=>580,8463=>580,8470=>852,8486=>746,8487=>746,8490=>672,8491=>650,8513=>697,
8514=>501,8515=>501,8516=>549,8523=>801,8531=>872,8532=>872,8533=>872,8534=>872,8535=>872,8536=>872,
8537=>872,8538=>872,8539=>872,8540=>872,8541=>872,8542=>872,8543=>511,8544=>355,8545=>531,8546=>707,
8547=>870,8548=>650,8549=>883,8550=>1059,8551=>1234,8552=>838,8553=>641,8554=>839,8555=>1015,8556=>598,
8557=>688,8558=>721,8559=>921,8560=>288,8561=>576,8562=>863,8563=>796,8564=>508,8565=>796,8566=>1084,
8567=>1372,8568=>795,8569=>507,8570=>795,8571=>1083,8572=>288,8573=>504,8574=>576,8575=>853,8576=>1085,
8577=>721,8578=>1085,8579=>688,8580=>504,8592=>754,8593=>754,8594=>754,8595=>754,8596=>754,8597=>754,
8598=>754,8599=>754,8600=>754,8601=>754,8602=>754,8603=>754,8604=>754,8605=>754,8606=>754,8607=>754,
8608=>754,8609=>754,8610=>754,8611=>754,8612=>754,8613=>754,8614=>754,8615=>754,8616=>754,8617=>754,
8618=>754,8619=>754,8620=>754,8621=>754,8622=>754,8623=>754,8624=>754,8625=>754,8626=>754,8627=>754,
8628=>754,8629=>754,8630=>754,8631=>754,8632=>754,8633=>754,8634=>754,8635=>754,8636=>754,8637=>754,
8638=>754,8639=>754,8640=>754,8641=>754,8642=>754,8643=>754,8644=>754,8645=>754,8646=>754,8647=>754,
8648=>754,8649=>754,8650=>754,8651=>754,8652=>754,8653=>754,8654=>754,8655=>754,8656=>754,8657=>754,
8658=>754,8659=>754,8660=>754,8661=>754,8662=>754,8663=>754,8664=>754,8665=>754,8666=>754,8667=>754,
8668=>754,8669=>754,8670=>754,8671=>754,8672=>754,8673=>754,8674=>754,8675=>754,8676=>754,8677=>754,
8678=>754,8679=>754,8680=>754,8681=>754,8682=>754,8683=>754,8684=>754,8685=>754,8686=>754,8687=>754,
8688=>754,8689=>754,8690=>754,8691=>754,8692=>754,8693=>754,8694=>754,8695=>754,8696=>754,8697=>754,
8698=>754,8699=>754,8700=>754,8701=>754,8702=>754,8703=>754,8704=>543,8706=>465,8707=>488,8708=>488,
8710=>628,8711=>628,8712=>666,8713=>666,8715=>666,8716=>666,8719=>716,8720=>716,8721=>642,8722=>754,
8723=>754,8724=>754,8725=>303,8727=>611,8728=>441,8729=>441,8730=>573,8731=>573,8732=>573,8733=>609,
8734=>750,8735=>754,8736=>754,8739=>262,8740=>431,8741=>416,8742=>570,8743=>659,8744=>659,8745=>754,
8746=>754,8747=>469,8748=>766,8749=>1063,8760=>754,8761=>754,8762=>754,8763=>754,8764=>754,8765=>754,
8770=>754,8771=>754,8776=>754,8784=>754,8785=>754,8786=>754,8787=>754,8788=>930,8789=>930,8800=>754,
8801=>754,8804=>754,8805=>754,8834=>754,8835=>754,8836=>754,8837=>754,8838=>754,8839=>754,8844=>754,
8845=>754,8846=>754,8847=>761,8848=>761,8849=>761,8850=>761,8851=>754,8852=>754,8853=>754,8854=>754,
8855=>754,8856=>754,8857=>754,8858=>754,8859=>754,8860=>754,8861=>754,8862=>754,8863=>754,8864=>754,
8865=>754,8866=>773,8867=>773,8868=>846,8869=>846,8870=>510,8871=>510,8872=>773,8873=>773,8874=>773,
8875=>927,8876=>773,8877=>773,8878=>773,8879=>927,8901=>308,8962=>687,8968=>351,8969=>351,8970=>351,
8971=>351,8976=>754,8977=>461,8984=>900,8985=>754,8992=>469,8993=>469,8997=>900,9000=>1299,9085=>827,
9134=>469,9167=>850,9251=>687,9472=>542,9473=>542,9474=>542,9475=>542,9476=>542,9477=>542,9478=>542,
9479=>542,9480=>542,9481=>542,9482=>542,9483=>542,9484=>542,9485=>542,9486=>542,9487=>542,9488=>542,
9489=>542,9490=>542,9491=>542,9492=>542,9493=>542,9494=>542,9495=>542,9496=>542,9497=>542,9498=>542,
9499=>542,9500=>542,9501=>542,9502=>542,9503=>542,9504=>542,9505=>542,9506=>542,9507=>542,9508=>542,
9509=>542,9510=>542,9511=>542,9512=>542,9513=>542,9514=>542,9515=>542,9516=>542,9517=>542,9518=>542,
9519=>542,9520=>542,9521=>542,9522=>542,9523=>542,9524=>542,9525=>542,9526=>542,9527=>542,9528=>542,
9529=>542,9530=>542,9531=>542,9532=>542,9533=>542,9534=>542,9535=>542,9536=>542,9537=>542,9538=>542,
9539=>542,9540=>542,9541=>542,9542=>542,9543=>542,9544=>542,9545=>542,9546=>542,9547=>542,9548=>542,
9549=>542,9550=>542,9551=>542,9552=>542,9553=>542,9554=>542,9555=>542,9556=>542,9557=>542,9558=>542,
9559=>542,9560=>542,9561=>542,9562=>542,9563=>542,9564=>542,9565=>542,9566=>542,9567=>542,9568=>542,
9569=>542,9570=>542,9571=>542,9572=>542,9573=>542,9574=>542,9575=>542,9576=>542,9577=>542,9578=>542,
9579=>542,9580=>542,9581=>542,9582=>542,9583=>542,9584=>542,9585=>542,9586=>542,9587=>542,9588=>542,
9589=>542,9590=>542,9591=>542,9592=>542,9593=>542,9594=>542,9595=>542,9596=>542,9597=>542,9598=>542,
9599=>542,9600=>692,9601=>692,9602=>692,9603=>692,9604=>692,9605=>692,9606=>692,9607=>692,9608=>692,
9609=>692,9610=>692,9611=>692,9612=>692,9613=>692,9614=>692,9615=>692,9616=>692,9617=>692,9618=>692,
9619=>692,9620=>692,9621=>692,9622=>692,9623=>692,9624=>692,9625=>692,9626=>692,9627=>692,9628=>692,
9629=>692,9630=>692,9631=>692,9632=>850,9633=>850,9634=>850,9635=>850,9636=>850,9637=>850,9638=>850,
9639=>850,9640=>850,9641=>850,9642=>610,9643=>610,9644=>850,9645=>850,9646=>495,9647=>495,9648=>692,
9649=>692,9650=>692,9651=>692,9652=>452,9653=>452,9654=>692,9655=>692,9656=>452,9657=>452,9658=>692,
9659=>692,9660=>692,9661=>692,9662=>452,9663=>452,9664=>692,9665=>692,9666=>452,9667=>452,9668=>692,
9669=>692,9670=>692,9671=>692,9672=>692,9673=>785,9674=>444,9675=>785,9676=>785,9677=>785,9678=>785,
9679=>785,9680=>785,9681=>785,9682=>785,9683=>785,9684=>785,9685=>785,9686=>474,9687=>474,9688=>712,
9689=>873,9690=>873,9691=>873,9692=>348,9693=>348,9694=>348,9695=>348,9696=>785,9697=>785,9698=>692,
9699=>692,9700=>692,9701=>692,9702=>531,9703=>850,9704=>850,9705=>850,9706=>850,9707=>850,9708=>692,
9709=>692,9710=>692,9711=>1007,9712=>850,9713=>850,9714=>850,9715=>850,9716=>785,9717=>785,9718=>785,
9719=>785,9720=>692,9721=>692,9722=>692,9723=>747,9724=>747,9725=>659,9726=>659,9727=>692,9728=>807,
9784=>807,9785=>807,9786=>807,9787=>807,9788=>807,9791=>552,9792=>658,9793=>658,9794=>807,9795=>807,
9796=>807,9797=>807,9798=>807,9799=>807,9824=>807,9825=>807,9826=>807,9827=>807,9828=>807,9829=>807,
9830=>807,9831=>807,9833=>424,9834=>574,9835=>807,9836=>807,9837=>424,9838=>321,9839=>435,10145=>754,
10181=>351,10182=>351,10208=>444,10216=>351,10217=>351,10224=>754,10225=>754,10226=>754,10227=>754,10228=>930,
10229=>1290,10230=>1290,10231=>1290,10232=>1290,10233=>1290,10234=>1290,10235=>1290,10236=>1290,10237=>1290,10238=>1290,
10239=>1290,10240=>659,10241=>659,10242=>659,10243=>659,10244=>659,10245=>659,10246=>659,10247=>659,10248=>659,
10249=>659,10250=>659,10251=>659,10252=>659,10253=>659,10254=>659,10255=>659,10256=>659,10257=>659,10258=>659,
10259=>659,10260=>659,10261=>659,10262=>659,10263=>659,10264=>659,10265=>659,10266=>659,10267=>659,10268=>659,
10269=>659,10270=>659,10271=>659,10272=>659,10273=>659,10274=>659,10275=>659,10276=>659,10277=>659,10278=>659,
10279=>659,10280=>659,10281=>659,10282=>659,10283=>659,10284=>659,10285=>659,10286=>659,10287=>659,10288=>659,
10289=>659,10290=>659,10291=>659,10292=>659,10293=>659,10294=>659,10295=>659,10296=>659,10297=>659,10298=>659,
10299=>659,10300=>659,10301=>659,10302=>659,10303=>659,10304=>659,10305=>659,10306=>659,10307=>659,10308=>659,
10309=>659,10310=>659,10311=>659,10312=>659,10313=>659,10314=>659,10315=>659,10316=>659,10317=>659,10318=>659,
10319=>659,10320=>659,10321=>659,10322=>659,10323=>659,10324=>659,10325=>659,10326=>659,10327=>659,10328=>659,
10329=>659,10330=>659,10331=>659,10332=>659,10333=>659,10334=>659,10335=>659,10336=>659,10337=>659,10338=>659,
10339=>659,10340=>659,10341=>659,10342=>659,10343=>659,10344=>659,10345=>659,10346=>659,10347=>659,10348=>659,
10349=>659,10350=>659,10351=>659,10352=>659,10353=>659,10354=>659,10355=>659,10356=>659,10357=>659,10358=>659,
10359=>659,10360=>659,10361=>659,10362=>659,10363=>659,10364=>659,10365=>659,10366=>659,10367=>659,10368=>659,
10369=>659,10370=>659,10371=>659,10372=>659,10373=>659,10374=>659,10375=>659,10376=>659,10377=>659,10378=>659,
10379=>659,10380=>659,10381=>659,10382=>659,10383=>659,10384=>659,10385=>659,10386=>659,10387=>659,10388=>659,
10389=>659,10390=>659,10391=>659,10392=>659,10393=>659,10394=>659,10395=>659,10396=>659,10397=>659,10398=>659,
10399=>659,10400=>659,10401=>659,10402=>659,10403=>659,10404=>659,10405=>659,10406=>659,10407=>659,10408=>659,
10409=>659,10410=>659,10411=>659,10412=>659,10413=>659,10414=>659,10415=>659,10416=>659,10417=>659,10418=>659,
10419=>659,10420=>659,10421=>659,10422=>659,10423=>659,10424=>659,10425=>659,10426=>659,10427=>659,10428=>659,
10429=>659,10430=>659,10431=>659,10432=>659,10433=>659,10434=>659,10435=>659,10436=>659,10437=>659,10438=>659,
10439=>659,10440=>659,10441=>659,10442=>659,10443=>659,10444=>659,10445=>659,10446=>659,10447=>659,10448=>659,
10449=>659,10450=>659,10451=>659,10452=>659,10453=>659,10454=>659,10455=>659,10456=>659,10457=>659,10458=>659,
10459=>659,10460=>659,10461=>659,10462=>659,10463=>659,10464=>659,10465=>659,10466=>659,10467=>659,10468=>659,
10469=>659,10470=>659,10471=>659,10472=>659,10473=>659,10474=>659,10475=>659,10476=>659,10477=>659,10478=>659,
10479=>659,10480=>659,10481=>659,10482=>659,10483=>659,10484=>659,10485=>659,10486=>659,10487=>659,10488=>659,
10489=>659,10490=>659,10491=>659,10492=>659,10493=>659,10494=>659,10495=>659,10496=>754,10497=>754,10498=>754,
10499=>754,10500=>754,10501=>754,10502=>754,10503=>754,10504=>754,10505=>754,10506=>754,10507=>754,10508=>754,
10509=>754,10510=>754,10511=>754,10512=>754,10513=>754,10514=>754,10515=>754,10516=>754,10517=>754,10518=>754,
10519=>754,10520=>754,10521=>754,10522=>754,10523=>754,10524=>754,10525=>754,10526=>754,10527=>754,10528=>754,
10529=>754,10530=>754,10531=>754,10532=>754,10533=>754,10534=>754,10535=>754,10536=>754,10537=>754,10538=>754,
10539=>754,10540=>754,10541=>754,10542=>754,10543=>754,10544=>754,10545=>754,10546=>754,10547=>754,10548=>754,
10549=>754,10550=>754,10551=>754,10552=>754,10553=>754,10554=>754,10555=>754,10556=>754,10557=>754,10558=>754,
10559=>754,10560=>754,10561=>754,10562=>754,10563=>754,10564=>754,10565=>754,10566=>754,10567=>754,10568=>754,
10569=>754,10570=>754,10571=>754,10572=>754,10573=>754,10574=>754,10575=>754,10576=>754,10577=>754,10578=>754,
10579=>754,10580=>754,10581=>754,10582=>754,10583=>754,10584=>754,10585=>754,10586=>754,10587=>754,10588=>754,
10589=>754,10590=>754,10591=>754,10592=>754,10593=>754,10594=>754,10595=>754,10596=>754,10597=>754,10598=>754,
10599=>754,10600=>754,10601=>754,10602=>754,10603=>754,10604=>754,10605=>754,10606=>754,10607=>754,10608=>754,
10609=>754,10610=>754,10611=>754,10612=>754,10613=>754,10614=>754,10615=>883,10616=>754,10617=>754,10618=>886,
10619=>754,10620=>754,10621=>754,10622=>754,10623=>754,10731=>444,10764=>1361,10765=>469,10766=>469,10799=>754,
11008=>754,11009=>754,11010=>754,11011=>754,11012=>754,11013=>754,11014=>754,11015=>754,11016=>754,11017=>754,
11018=>754,11019=>754,11020=>754,11021=>754,11022=>754,11023=>754,11024=>754,11025=>754,11026=>850,11027=>850,
11028=>850,11029=>850,11030=>692,11031=>692,11032=>692,11033=>692,11034=>850,11364=>677,11367=>785,11368=>580,
11369=>672,11370=>545,11371=>625,11372=>474,11374=>921,11375=>650,11381=>666,11382=>478,11383=>630,11385=>451,
11386=>542,11388=>237,11389=>409,11520=>695,11521=>571,11522=>569,11523=>592,11524=>568,11525=>866,11526=>680,
11527=>864,11528=>555,11529=>581,11530=>866,11531=>568,11532=>581,11533=>866,11534=>580,11535=>779,11536=>865,
11537=>580,11538=>580,11539=>863,11540=>851,11541=>777,11542=>580,11543=>581,11544=>580,11545=>584,11546=>619,
11547=>571,11548=>883,11549=>613,11550=>608,11551=>766,11552=>861,11553=>569,11554=>580,11555=>582,11556=>674,
11557=>822,11800=>482,11810=>351,11811=>351,11812=>351,11813=>351,11822=>482,42564=>616,42565=>461,42566=>355,
42567=>353,42576=>994,42577=>845,42580=>1074,42581=>783,42582=>1025,42583=>787,42760=>444,42761=>444,42762=>444,
42763=>444,42764=>444,42765=>444,42766=>444,42767=>444,42768=>444,42769=>444,42770=>444,42771=>444,42772=>444,
42773=>444,42774=>444,42779=>332,42780=>332,42781=>228,42782=>228,42783=>228,42891=>361,42892=>247,62464=>598,
62465=>607,62466=>651,62467=>861,62468=>607,62469=>602,62470=>661,62471=>896,62472=>607,62473=>607,62474=>1141,
62475=>624,62476=>623,62477=>866,62478=>607,62479=>623,62480=>908,62481=>681,62482=>728,62483=>682,62484=>859,
62485=>622,62486=>852,62487=>621,62488=>628,62489=>623,62490=>665,62491=>623,62492=>628,62493=>608,62494=>665,
62495=>805,62496=>607,62497=>707,62498=>608,62499=>607,62500=>607,62501=>659,62502=>875,62504=>813,63172=>455,
63173=>542,63174=>576,63175=>580,63176=>853,63185=>450,63188=>450,64256=>637,64257=>600,64258=>600,64259=>847,
64260=>887,64261=>669,64262=>824,65024=>0,65025=>0,65026=>0,65027=>0,65028=>0,65029=>0,65030=>0,
65031=>0,65032=>0,65033=>0,65034=>0,65035=>0,65036=>0,65037=>0,65038=>0,65039=>0,65529=>0,
65530=>0,65531=>0,65532=>0,65533=>923);
$enc='';
$diff='';
$file='dejavuserifcondensedi.z';
$ctg='dejavuserifcondensedi.ctg.z';
$originalsize=301244;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/dejavuserifcondensedi.php | PHP | asf20 | 29,985 |
<?php
$type='TrueTypeUnicode';
$name='DejaVuSerifCondensed-Bold';
$desc=array('Ascent'=>939,'Descent'=>-236,'CapHeight'=>4,'Flags'=>32,'FontBBox'=>'[-752 -389 1616 1235]','ItalicAngle'=>0,'StemV'=>120,'MissingWidth'=>540);
$up=-63;
$ut=44;
$dw=540;
$cw=array(
0=>540,32=>313,33=>395,34=>469,35=>754,36=>626,37=>855,38=>813,39=>275,40=>426,
41=>426,42=>470,43=>754,44=>313,45=>374,46=>313,47=>329,48=>626,49=>626,50=>626,
51=>626,52=>626,53=>626,54=>626,55=>626,56=>626,57=>626,58=>332,59=>332,60=>754,
61=>754,62=>754,63=>527,64=>900,65=>698,66=>760,67=>716,68=>780,69=>686,70=>639,
71=>769,72=>850,73=>421,74=>426,75=>782,76=>633,77=>996,78=>822,79=>784,80=>677,
81=>784,82=>748,83=>650,84=>669,85=>785,86=>698,87=>1011,88=>698,89=>642,90=>657,
91=>426,92=>329,93=>426,94=>754,95=>450,96=>450,97=>583,98=>629,99=>548,100=>629,
101=>572,102=>387,103=>629,104=>654,105=>342,106=>325,107=>624,108=>342,109=>952,110=>654,
111=>600,112=>629,113=>629,114=>474,115=>506,116=>416,117=>654,118=>523,119=>774,120=>536,
121=>523,122=>511,123=>579,124=>327,125=>579,126=>754,8364=>626,8218=>313,402=>387,8222=>518,
8230=>900,8224=>470,8225=>470,710=>450,8240=>1246,352=>650,8249=>360,338=>1062,381=>657,8216=>313,
8217=>313,8220=>518,8221=>518,8226=>575,8211=>450,8212=>900,732=>450,8482=>900,353=>506,8250=>360,
339=>925,382=>511,376=>642,160=>313,161=>395,162=>626,163=>626,164=>572,165=>626,166=>327,
167=>470,168=>450,169=>900,170=>438,171=>563,172=>754,173=>374,174=>900,175=>450,176=>450,
177=>754,178=>394,179=>394,180=>450,181=>659,182=>572,183=>313,184=>450,185=>394,186=>450,
187=>563,188=>938,189=>938,190=>938,191=>527,192=>698,193=>698,194=>698,195=>698,196=>698,
197=>698,198=>931,199=>716,200=>686,201=>686,202=>686,203=>686,204=>421,205=>421,206=>421,
207=>421,208=>787,209=>822,210=>784,211=>784,212=>784,213=>784,214=>784,215=>754,216=>784,
217=>785,218=>785,219=>785,220=>785,221=>642,222=>681,223=>684,224=>583,225=>583,226=>583,
227=>583,228=>583,229=>583,230=>877,231=>548,232=>572,233=>572,234=>572,235=>572,236=>342,
237=>342,238=>342,239=>342,240=>600,241=>654,242=>600,243=>600,244=>600,245=>600,246=>600,
247=>754,248=>600,249=>654,250=>654,251=>654,252=>654,253=>523,254=>629,255=>523,256=>698,
257=>583,258=>698,259=>583,260=>698,261=>583,262=>716,263=>548,264=>716,265=>548,266=>716,
267=>548,268=>716,269=>548,270=>780,271=>629,272=>787,273=>629,274=>686,275=>572,276=>686,
277=>572,278=>686,279=>572,280=>686,281=>572,282=>686,283=>572,284=>769,285=>629,286=>769,
287=>629,288=>769,289=>629,290=>769,291=>629,292=>850,293=>654,294=>850,295=>654,296=>421,
297=>342,298=>421,299=>342,300=>421,301=>342,302=>421,303=>342,304=>421,305=>342,306=>848,
307=>676,308=>426,309=>325,310=>782,311=>624,312=>624,313=>633,314=>342,315=>633,316=>342,
317=>633,318=>342,319=>633,320=>342,321=>639,322=>346,323=>822,324=>654,325=>822,326=>654,
327=>822,328=>654,329=>907,330=>785,331=>654,332=>784,333=>600,334=>784,335=>600,336=>784,
337=>600,340=>748,341=>474,342=>748,343=>474,344=>748,345=>474,346=>650,347=>506,348=>650,
349=>506,350=>650,351=>506,354=>669,355=>416,356=>669,357=>416,358=>669,359=>416,360=>785,
361=>654,362=>785,363=>654,364=>785,365=>654,366=>785,367=>654,368=>785,369=>654,370=>785,
371=>654,372=>1011,373=>774,374=>642,375=>523,377=>657,378=>511,379=>657,380=>511,383=>387,
384=>629,385=>760,386=>769,387=>629,388=>769,389=>629,390=>716,391=>716,392=>548,393=>787,
394=>780,395=>769,396=>629,397=>600,398=>686,399=>784,400=>649,401=>639,403=>769,404=>693,
405=>938,406=>421,407=>421,408=>782,409=>624,410=>342,411=>631,412=>952,413=>822,414=>654,
415=>784,416=>784,417=>600,418=>1080,419=>849,420=>677,421=>629,422=>748,423=>650,424=>506,
425=>636,426=>298,427=>416,428=>669,429=>416,430=>669,431=>785,432=>654,433=>801,434=>801,
435=>642,436=>637,437=>657,438=>511,439=>591,440=>591,441=>591,443=>626,444=>678,445=>511,
446=>482,448=>265,449=>443,450=>413,451=>265,452=>1437,453=>1292,454=>1140,455=>1059,456=>958,
457=>667,458=>1248,459=>1148,460=>980,461=>698,462=>583,463=>421,464=>342,465=>784,466=>600,
467=>785,468=>654,469=>785,470=>654,471=>785,472=>654,473=>785,474=>654,475=>785,476=>654,
477=>572,478=>698,479=>583,480=>698,481=>583,482=>931,483=>877,484=>806,485=>629,486=>769,
487=>629,488=>782,489=>624,490=>784,491=>600,492=>784,493=>600,494=>591,495=>511,496=>342,
497=>1437,498=>1292,499=>1140,500=>769,501=>629,502=>1099,504=>822,505=>654,506=>698,507=>583,
508=>931,509=>877,510=>784,511=>600,512=>698,513=>583,514=>698,515=>583,516=>686,517=>572,
518=>686,519=>572,520=>421,521=>342,522=>421,523=>342,524=>784,525=>600,526=>784,527=>600,
528=>748,529=>474,530=>748,531=>474,532=>785,533=>654,534=>785,535=>654,536=>650,537=>506,
538=>669,539=>416,540=>621,541=>546,542=>850,543=>654,544=>785,545=>711,548=>657,549=>511,
550=>698,551=>583,552=>686,553=>572,554=>784,555=>600,556=>784,557=>600,558=>784,559=>600,
560=>784,561=>600,562=>642,563=>523,564=>516,565=>830,566=>508,567=>325,568=>928,569=>928,
570=>698,571=>716,572=>548,573=>633,574=>669,575=>506,576=>511,577=>594,578=>492,581=>698,
592=>583,593=>629,594=>629,595=>629,596=>548,597=>548,598=>629,599=>657,600=>572,601=>572,
602=>816,603=>547,604=>505,605=>816,606=>647,607=>348,608=>629,609=>629,610=>563,611=>641,
612=>564,613=>654,614=>654,615=>654,616=>342,617=>342,618=>342,619=>368,620=>462,621=>342,
622=>716,623=>952,624=>952,625=>952,626=>654,627=>654,628=>641,629=>600,630=>955,631=>674,
632=>600,633=>514,634=>514,635=>514,636=>474,637=>474,638=>406,639=>438,640=>721,641=>721,
642=>506,643=>298,644=>387,645=>486,646=>298,647=>443,648=>416,649=>654,650=>611,651=>624,
652=>577,653=>816,654=>571,655=>654,656=>511,657=>511,658=>511,659=>511,660=>482,661=>482,
662=>482,663=>490,664=>784,665=>625,666=>647,667=>563,668=>659,669=>345,670=>666,671=>581,
672=>629,673=>482,674=>482,675=>1005,676=>1061,677=>1005,678=>819,679=>643,680=>817,681=>935,
682=>711,683=>716,684=>596,685=>398,686=>552,687=>646,688=>469,689=>466,690=>282,691=>372,
692=>372,693=>432,694=>474,695=>595,696=>436,697=>271,699=>313,700=>313,701=>313,702=>330,
703=>330,704=>282,705=>282,711=>450,712=>254,713=>450,716=>254,720=>332,721=>332,722=>330,
723=>330,726=>353,728=>450,729=>450,730=>450,731=>450,733=>450,734=>375,736=>412,737=>263,
738=>355,739=>427,740=>282,741=>450,742=>450,743=>450,744=>450,745=>450,750=>498,768=>0,
769=>0,770=>0,771=>0,772=>0,773=>0,774=>0,775=>0,776=>0,777=>0,778=>0,
779=>0,780=>0,781=>0,782=>0,783=>0,784=>0,785=>0,786=>0,787=>0,788=>0,
789=>0,790=>0,791=>0,792=>0,793=>0,794=>0,795=>0,796=>0,797=>0,798=>0,
799=>0,800=>0,801=>0,802=>0,803=>0,804=>0,805=>0,806=>0,807=>0,808=>0,
809=>0,810=>0,811=>0,812=>0,813=>0,814=>0,815=>0,816=>0,817=>0,818=>0,
819=>0,820=>0,821=>0,822=>0,823=>0,824=>0,825=>0,826=>0,827=>0,828=>0,
829=>0,830=>0,831=>0,835=>0,847=>0,856=>0,865=>0,880=>701,881=>519,884=>271,
885=>271,890=>450,891=>548,892=>548,893=>548,894=>332,900=>450,901=>450,902=>698,903=>313,
904=>852,905=>1006,906=>595,908=>798,910=>857,911=>820,912=>435,913=>698,914=>760,915=>639,
916=>698,917=>686,918=>657,919=>850,920=>784,921=>421,922=>782,923=>698,924=>996,925=>822,
926=>633,927=>784,928=>850,929=>677,931=>636,932=>669,933=>642,934=>784,935=>698,936=>822,
937=>801,938=>421,939=>642,940=>692,941=>547,942=>654,943=>435,944=>624,945=>692,946=>598,
947=>594,948=>600,949=>547,950=>533,951=>654,952=>600,953=>435,954=>674,955=>631,956=>659,
957=>624,958=>533,959=>600,960=>659,961=>598,962=>548,963=>664,964=>605,965=>624,966=>814,
967=>592,968=>847,969=>857,970=>435,971=>624,972=>600,973=>624,974=>857,976=>600,977=>764,
978=>687,979=>872,980=>687,981=>847,982=>857,983=>589,984=>784,985=>600,986=>716,987=>548,
988=>639,989=>475,990=>531,991=>593,992=>716,993=>600,1008=>589,1009=>598,1010=>548,1011=>325,
1012=>784,1013=>548,1014=>548,1015=>681,1016=>629,1017=>716,1018=>996,1019=>774,1020=>623,1021=>716,
1022=>716,1023=>716,1024=>686,1025=>686,1026=>811,1027=>621,1028=>716,1029=>650,1030=>421,1031=>421,
1032=>426,1033=>1081,1034=>1135,1035=>866,1036=>818,1037=>850,1038=>730,1039=>850,1040=>733,1041=>769,
1042=>760,1043=>621,1044=>800,1045=>686,1046=>1181,1047=>649,1048=>850,1049=>850,1050=>818,1051=>795,
1052=>996,1053=>850,1054=>784,1055=>850,1056=>677,1057=>716,1058=>669,1059=>730,1060=>854,1061=>698,
1062=>870,1063=>822,1064=>1141,1065=>1164,1066=>861,1067=>1081,1068=>743,1069=>716,1070=>1158,1071=>793,
1072=>583,1073=>600,1074=>625,1075=>551,1076=>600,1077=>572,1078=>909,1079=>574,1080=>667,1081=>667,
1082=>650,1083=>634,1084=>782,1085=>659,1086=>600,1087=>659,1088=>629,1089=>548,1090=>558,1091=>576,
1092=>812,1093=>536,1094=>665,1095=>659,1096=>967,1097=>974,1098=>690,1099=>902,1100=>611,1101=>548,
1102=>923,1103=>665,1104=>572,1105=>572,1106=>646,1107=>551,1108=>548,1109=>506,1110=>342,1111=>342,
1112=>325,1113=>889,1114=>913,1115=>654,1116=>650,1117=>667,1118=>576,1119=>659,1122=>792,1123=>633,
1124=>1076,1125=>867,1130=>1181,1131=>909,1136=>986,1137=>995,1138=>784,1139=>587,1140=>824,1141=>673,
1164=>761,1165=>606,1168=>630,1169=>556,1170=>621,1171=>551,1172=>781,1173=>645,1174=>1181,1175=>909,
1176=>649,1177=>574,1178=>852,1179=>669,1182=>818,1183=>650,1184=>937,1185=>744,1186=>870,1187=>665,
1188=>1050,1189=>860,1190=>1210,1191=>953,1194=>716,1195=>548,1196=>669,1197=>558,1198=>642,1199=>523,
1200=>642,1201=>523,1202=>779,1203=>584,1204=>919,1205=>726,1206=>835,1207=>665,1210=>819,1211=>654,
1216=>421,1217=>1181,1218=>909,1219=>782,1220=>624,1223=>850,1224=>659,1227=>822,1228=>659,1231=>342,
1232=>733,1233=>583,1234=>733,1235=>583,1236=>931,1237=>877,1238=>686,1239=>572,1240=>784,1241=>572,
1242=>784,1243=>572,1244=>1181,1245=>909,1246=>649,1247=>574,1248=>591,1249=>511,1250=>850,1251=>667,
1252=>850,1253=>667,1254=>784,1255=>600,1256=>784,1257=>600,1258=>784,1259=>600,1260=>716,1261=>548,
1262=>730,1263=>576,1264=>730,1265=>576,1266=>730,1267=>576,1268=>822,1269=>659,1270=>621,1271=>551,
1272=>1081,1273=>902,1296=>649,1297=>574,1298=>795,1299=>634,1300=>1123,1301=>851,1306=>738,1307=>576,
1308=>925,1309=>770,4256=>680,4257=>842,4258=>779,4259=>787,4260=>703,4261=>970,4262=>913,4263=>1091,
4264=>579,4265=>736,4266=>946,4267=>945,4268=>716,4269=>1021,4270=>872,4271=>812,4272=>998,4273=>712,
4274=>680,4275=>968,4276=>878,4277=>959,4278=>729,4279=>750,4280=>739,4281=>750,4282=>817,4283=>969,
4284=>692,4285=>739,4286=>731,4287=>1000,4288=>1010,4289=>721,4290=>803,4291=>722,4292=>792,4293=>957,
4304=>535,4305=>563,4306=>579,4307=>798,4308=>553,4309=>549,4310=>600,4311=>823,4312=>552,4313=>540,
4314=>1008,4315=>576,4316=>576,4317=>791,4318=>561,4319=>571,4320=>790,4321=>599,4322=>702,4323=>676,
4324=>782,4325=>575,4326=>820,4327=>559,4328=>583,4329=>576,4330=>656,4331=>577,4332=>567,4333=>566,
4334=>603,4335=>678,4336=>563,4337=>591,4338=>563,4339=>563,4340=>562,4341=>603,4342=>846,4343=>612,
4344=>572,4345=>605,4346=>562,4347=>529,4348=>318,7426=>846,7432=>458,7433=>288,7444=>890,7446=>600,
7447=>600,7453=>663,7454=>853,7455=>853,7468=>439,7469=>586,7470=>479,7472=>491,7473=>432,7474=>432,
7475=>483,7476=>536,7477=>265,7478=>268,7479=>492,7480=>398,7481=>627,7482=>518,7483=>518,7484=>493,
7486=>426,7487=>471,7488=>409,7489=>422,7490=>494,7491=>419,7492=>419,7493=>448,7494=>591,7495=>448,
7496=>448,7497=>400,7498=>400,7499=>370,7500=>370,7501=>448,7502=>270,7503=>471,7504=>655,7505=>426,
7506=>420,7507=>384,7508=>420,7509=>420,7510=>448,7511=>333,7512=>468,7513=>390,7514=>655,7515=>442,
7522=>215,7523=>372,7524=>468,7525=>442,7543=>576,7544=>536,7547=>342,7557=>342,7579=>448,7580=>384,
7581=>384,7582=>420,7583=>370,7584=>345,7585=>335,7586=>448,7587=>470,7588=>270,7589=>276,7590=>270,
7591=>270,7592=>333,7593=>331,7594=>289,7595=>387,7596=>613,7597=>655,7598=>529,7599=>528,7600=>425,
7601=>420,7602=>470,7603=>360,7604=>348,7605=>333,7606=>468,7607=>427,7609=>439,7610=>442,7611=>371,
7612=>474,7613=>371,7614=>407,7615=>420,7620=>0,7621=>0,7622=>0,7623=>0,7624=>0,7625=>0,
7680=>698,7681=>583,7682=>760,7683=>629,7684=>760,7685=>629,7686=>760,7687=>629,7688=>716,7689=>548,
7690=>780,7691=>629,7692=>780,7693=>629,7694=>780,7695=>629,7696=>780,7697=>629,7698=>780,7699=>629,
7700=>686,7701=>572,7702=>686,7703=>572,7704=>686,7705=>572,7706=>686,7707=>572,7708=>686,7709=>572,
7710=>639,7711=>387,7712=>769,7713=>629,7714=>850,7715=>654,7716=>850,7717=>654,7718=>850,7719=>654,
7720=>850,7721=>654,7722=>850,7723=>654,7724=>421,7725=>342,7728=>782,7729=>624,7730=>782,7731=>624,
7732=>782,7733=>624,7734=>633,7735=>342,7736=>633,7737=>342,7738=>633,7739=>342,7740=>633,7741=>342,
7742=>996,7743=>952,7744=>996,7745=>952,7746=>996,7747=>952,7748=>822,7749=>654,7750=>822,7751=>654,
7752=>822,7753=>654,7754=>822,7755=>654,7756=>784,7757=>600,7760=>784,7761=>600,7762=>784,7763=>600,
7764=>677,7765=>629,7766=>677,7767=>629,7768=>748,7769=>474,7770=>748,7771=>474,7772=>748,7773=>474,
7774=>748,7775=>474,7776=>650,7777=>506,7778=>650,7779=>506,7784=>650,7785=>506,7786=>669,7787=>416,
7788=>669,7789=>416,7790=>669,7791=>416,7792=>669,7793=>416,7794=>785,7795=>654,7796=>785,7797=>654,
7798=>785,7799=>654,7800=>785,7801=>654,7802=>785,7803=>654,7804=>698,7805=>523,7806=>698,7807=>523,
7808=>1011,7809=>774,7810=>1011,7811=>774,7812=>1011,7813=>774,7814=>1011,7815=>774,7816=>1011,7817=>774,
7818=>698,7819=>536,7820=>698,7821=>536,7822=>642,7823=>523,7824=>657,7825=>511,7826=>657,7827=>511,
7828=>657,7829=>511,7830=>654,7831=>416,7832=>774,7833=>523,7834=>913,7835=>387,7838=>852,7839=>600,
7840=>698,7841=>583,7842=>698,7843=>583,7852=>698,7853=>583,7854=>698,7855=>583,7856=>698,7857=>583,
7858=>698,7859=>583,7860=>698,7861=>583,7862=>698,7863=>583,7864=>686,7865=>572,7866=>686,7867=>572,
7868=>686,7869=>572,7878=>686,7879=>572,7880=>421,7881=>342,7882=>421,7883=>342,7884=>784,7885=>600,
7886=>784,7887=>600,7896=>784,7897=>600,7908=>785,7909=>654,7910=>785,7911=>654,7922=>642,7923=>523,
7924=>642,7925=>523,7926=>642,7927=>523,7928=>642,7929=>523,7936=>692,7937=>692,7938=>692,7939=>692,
7940=>692,7941=>692,7942=>692,7943=>692,7944=>698,7945=>698,7946=>880,7947=>880,7948=>748,7949=>764,
7950=>698,7951=>698,7952=>547,7953=>547,7954=>547,7955=>547,7956=>547,7957=>547,7960=>826,7961=>817,
7962=>1052,7963=>1052,7964=>984,7965=>1007,7968=>654,7969=>654,7970=>654,7971=>654,7972=>654,7973=>654,
7974=>654,7975=>654,7976=>990,7977=>984,7978=>1222,7979=>1225,7980=>1151,7981=>1177,7982=>1077,7983=>1074,
7984=>435,7985=>435,7986=>435,7987=>435,7988=>435,7989=>435,7990=>435,7991=>435,7992=>566,7993=>555,
7994=>790,7995=>792,7996=>719,7997=>748,7998=>650,7999=>642,8000=>600,8001=>600,8002=>600,8003=>600,
8004=>600,8005=>600,8008=>810,8009=>841,8010=>1116,8011=>1113,8012=>931,8013=>959,8016=>624,8017=>624,
8018=>624,8019=>624,8020=>624,8021=>624,8022=>624,8023=>624,8025=>830,8027=>1067,8029=>1020,8031=>917,
8032=>857,8033=>857,8034=>857,8035=>857,8036=>857,8037=>857,8038=>857,8039=>857,8040=>838,8041=>867,
8042=>1141,8043=>1146,8044=>949,8045=>979,8046=>920,8047=>954,8048=>692,8049=>692,8050=>547,8051=>547,
8052=>654,8053=>654,8054=>435,8055=>435,8056=>600,8057=>600,8058=>624,8059=>624,8060=>857,8061=>857,
8064=>692,8065=>692,8066=>692,8067=>692,8068=>692,8069=>692,8070=>692,8071=>692,8072=>698,8073=>698,
8074=>880,8075=>880,8076=>748,8077=>764,8078=>698,8079=>698,8080=>654,8081=>654,8082=>654,8083=>654,
8084=>654,8085=>654,8086=>654,8087=>654,8088=>990,8089=>984,8090=>1222,8091=>1225,8092=>1151,8093=>1177,
8094=>1077,8095=>1074,8096=>857,8097=>857,8098=>857,8099=>857,8100=>857,8101=>857,8102=>857,8103=>857,
8104=>838,8105=>867,8106=>1141,8107=>1146,8108=>949,8109=>979,8110=>920,8111=>954,8112=>692,8113=>692,
8114=>692,8115=>692,8116=>692,8118=>692,8119=>692,8120=>698,8121=>698,8122=>729,8123=>698,8124=>698,
8125=>450,8126=>450,8127=>450,8128=>450,8129=>450,8130=>654,8131=>654,8132=>654,8134=>654,8135=>654,
8136=>899,8137=>852,8138=>1072,8139=>1006,8140=>850,8141=>450,8142=>450,8143=>450,8144=>435,8145=>435,
8146=>435,8147=>435,8150=>435,8151=>435,8152=>421,8153=>421,8154=>642,8155=>595,8157=>450,8158=>450,
8159=>450,8160=>624,8161=>624,8162=>624,8163=>624,8164=>598,8165=>598,8166=>624,8167=>624,8168=>642,
8169=>642,8170=>917,8171=>857,8172=>819,8173=>450,8174=>450,8175=>450,8178=>857,8179=>857,8180=>857,
8182=>857,8183=>857,8184=>962,8185=>798,8186=>991,8187=>820,8188=>801,8189=>450,8190=>450,8192=>450,
8193=>900,8194=>450,8195=>900,8196=>296,8197=>225,8198=>150,8199=>626,8200=>313,8201=>180,8202=>89,
8203=>0,8204=>0,8205=>0,8206=>0,8207=>0,8208=>374,8209=>374,8210=>626,8213=>900,8214=>450,
8215=>450,8219=>313,8223=>518,8227=>575,8228=>313,8229=>606,8234=>0,8235=>0,8236=>0,8237=>0,
8238=>0,8239=>180,8241=>1638,8242=>237,8243=>402,8244=>567,8245=>237,8246=>402,8247=>567,8248=>659,
8252=>566,8253=>527,8254=>450,8258=>920,8260=>150,8261=>426,8262=>426,8263=>974,8264=>770,8265=>770,
8267=>572,8268=>450,8269=>450,8270=>470,8271=>332,8273=>470,8274=>500,8275=>900,8279=>731,8287=>200,
8288=>0,8289=>0,8290=>0,8291=>0,8292=>0,8298=>0,8299=>0,8300=>0,8301=>0,8302=>0,
8303=>0,8304=>394,8305=>215,8308=>394,8309=>394,8310=>394,8311=>394,8312=>394,8313=>394,8314=>475,
8315=>475,8316=>475,8317=>268,8318=>268,8319=>467,8320=>394,8321=>394,8322=>394,8323=>394,8324=>394,
8325=>394,8326=>394,8327=>394,8328=>394,8329=>394,8330=>475,8331=>475,8332=>475,8333=>268,8334=>268,
8336=>419,8337=>400,8338=>420,8339=>427,8340=>400,8358=>626,8367=>1039,8369=>710,8372=>788,8373=>626,
8451=>1078,8457=>1001,8462=>654,8463=>654,8470=>978,8486=>801,8487=>801,8490=>782,8491=>698,8513=>697,
8514=>501,8515=>573,8516=>684,8523=>813,8531=>932,8532=>932,8533=>932,8534=>932,8535=>932,8536=>932,
8537=>932,8538=>932,8539=>932,8540=>932,8541=>932,8542=>932,8543=>554,8544=>421,8545=>663,8546=>904,
8547=>984,8548=>698,8549=>1014,8550=>1256,8551=>1498,8552=>962,8553=>698,8554=>970,8555=>1212,8556=>633,
8557=>716,8558=>780,8559=>996,8560=>342,8561=>684,8562=>1025,8563=>865,8564=>523,8565=>865,8566=>1207,
8567=>1548,8568=>878,8569=>536,8570=>878,8571=>1220,8572=>342,8573=>548,8574=>629,8575=>952,8576=>1129,
8577=>780,8578=>1141,8579=>716,8580=>548,8592=>754,8593=>754,8594=>754,8595=>754,8596=>754,8597=>754,
8598=>754,8599=>754,8600=>754,8601=>754,8602=>754,8603=>754,8604=>754,8605=>754,8606=>754,8607=>754,
8608=>754,8609=>754,8610=>754,8611=>754,8612=>754,8613=>754,8614=>754,8615=>754,8616=>754,8617=>754,
8618=>754,8619=>754,8620=>754,8621=>754,8622=>754,8623=>765,8624=>754,8625=>754,8626=>754,8627=>754,
8628=>754,8629=>754,8630=>754,8631=>754,8632=>754,8633=>754,8634=>754,8635=>754,8636=>754,8637=>754,
8638=>754,8639=>754,8640=>754,8641=>754,8642=>754,8643=>754,8644=>754,8645=>754,8646=>754,8647=>754,
8648=>754,8649=>754,8650=>754,8651=>754,8652=>754,8653=>754,8654=>754,8655=>754,8656=>754,8657=>754,
8658=>754,8659=>754,8660=>754,8661=>754,8662=>754,8663=>754,8664=>754,8665=>754,8666=>754,8667=>754,
8668=>754,8669=>754,8670=>754,8671=>754,8672=>754,8673=>754,8674=>754,8675=>754,8676=>754,8677=>754,
8678=>754,8679=>754,8680=>754,8681=>754,8682=>754,8683=>754,8684=>754,8685=>754,8686=>754,8687=>754,
8688=>754,8689=>754,8690=>754,8691=>754,8692=>754,8693=>754,8694=>754,8695=>754,8696=>754,8697=>754,
8698=>754,8699=>754,8700=>754,8701=>754,8702=>754,8703=>754,8704=>577,8706=>480,8707=>558,8708=>558,
8710=>677,8711=>677,8712=>666,8713=>666,8715=>666,8716=>666,8719=>757,8720=>757,8721=>677,8722=>754,
8723=>754,8724=>754,8725=>329,8727=>622,8728=>466,8729=>466,8730=>591,8731=>591,8732=>591,8733=>604,
8734=>750,8735=>754,8736=>754,8739=>292,8740=>546,8741=>476,8742=>696,8743=>730,8744=>730,8745=>754,
8746=>754,8747=>521,8748=>900,8749=>1252,8760=>754,8761=>754,8762=>754,8763=>754,8764=>754,8765=>754,
8770=>754,8771=>754,8776=>754,8784=>754,8785=>754,8786=>754,8787=>754,8788=>974,8789=>974,8800=>754,
8801=>754,8804=>754,8805=>754,8834=>754,8835=>754,8836=>754,8837=>754,8838=>754,8839=>754,8844=>754,
8845=>754,8846=>754,8847=>754,8848=>754,8849=>754,8850=>754,8851=>754,8852=>754,8853=>754,8854=>754,
8855=>754,8856=>754,8857=>754,8858=>754,8859=>754,8860=>754,8861=>754,8862=>754,8863=>754,8864=>754,
8865=>754,8866=>795,8867=>795,8868=>864,8869=>864,8870=>554,8871=>554,8872=>795,8873=>795,8874=>795,
8875=>971,8876=>795,8877=>795,8878=>795,8879=>971,8901=>358,8962=>751,8968=>426,8969=>426,8970=>426,
8971=>426,8976=>754,8977=>484,8984=>835,8985=>754,8992=>521,8993=>521,8997=>900,9000=>1299,9085=>907,
9134=>521,9167=>850,9251=>751,9600=>692,9601=>692,9602=>692,9603=>692,9604=>692,9605=>692,9606=>692,
9607=>692,9608=>692,9609=>692,9610=>692,9611=>692,9612=>692,9613=>692,9614=>692,9615=>692,9616=>692,
9617=>692,9618=>692,9619=>692,9620=>692,9621=>692,9622=>692,9623=>692,9624=>692,9625=>692,9626=>692,
9627=>692,9628=>692,9629=>692,9630=>692,9631=>692,9632=>850,9633=>850,9634=>850,9635=>850,9636=>850,
9637=>850,9638=>850,9639=>850,9640=>850,9641=>850,9642=>610,9643=>610,9644=>850,9645=>850,9646=>495,
9647=>495,9648=>692,9649=>692,9650=>692,9651=>692,9652=>452,9653=>452,9654=>692,9655=>692,9656=>452,
9657=>452,9658=>692,9659=>692,9660=>692,9661=>692,9662=>452,9663=>452,9664=>692,9665=>692,9666=>452,
9667=>452,9668=>692,9669=>692,9670=>692,9671=>692,9672=>692,9673=>785,9674=>444,9675=>785,9676=>785,
9677=>785,9678=>785,9679=>785,9680=>785,9681=>785,9682=>785,9683=>785,9684=>785,9685=>785,9686=>474,
9687=>474,9688=>712,9689=>873,9690=>873,9691=>873,9692=>348,9693=>348,9694=>348,9695=>348,9696=>785,
9697=>785,9698=>692,9699=>692,9700=>692,9701=>692,9702=>531,9703=>850,9704=>850,9705=>850,9706=>850,
9707=>850,9708=>692,9709=>692,9710=>692,9711=>1007,9712=>850,9713=>850,9714=>850,9715=>850,9716=>785,
9717=>785,9718=>785,9719=>785,9720=>692,9721=>692,9722=>692,9723=>747,9724=>747,9725=>659,9726=>659,
9727=>692,9728=>807,9784=>807,9785=>807,9786=>807,9787=>807,9788=>807,9791=>552,9792=>658,9793=>658,
9794=>807,9795=>807,9796=>807,9797=>807,9798=>807,9799=>807,9824=>807,9825=>807,9826=>807,9827=>807,
9828=>807,9829=>807,9830=>807,9831=>807,9833=>424,9834=>574,9835=>807,9836=>807,9837=>424,9838=>321,
9839=>435,10145=>754,10181=>411,10182=>411,10208=>444,10216=>411,10217=>411,10224=>754,10225=>754,10226=>754,
10227=>754,10228=>930,10229=>1290,10230=>1290,10231=>1290,10232=>1290,10233=>1290,10234=>1290,10235=>1290,10236=>1290,
10237=>1290,10238=>1290,10239=>1290,10240=>703,10241=>703,10242=>703,10243=>703,10244=>703,10245=>703,10246=>703,
10247=>703,10248=>703,10249=>703,10250=>703,10251=>703,10252=>703,10253=>703,10254=>703,10255=>703,10256=>703,
10257=>703,10258=>703,10259=>703,10260=>703,10261=>703,10262=>703,10263=>703,10264=>703,10265=>703,10266=>703,
10267=>703,10268=>703,10269=>703,10270=>703,10271=>703,10272=>703,10273=>703,10274=>703,10275=>703,10276=>703,
10277=>703,10278=>703,10279=>703,10280=>703,10281=>703,10282=>703,10283=>703,10284=>703,10285=>703,10286=>703,
10287=>703,10288=>703,10289=>703,10290=>703,10291=>703,10292=>703,10293=>703,10294=>703,10295=>703,10296=>703,
10297=>703,10298=>703,10299=>703,10300=>703,10301=>703,10302=>703,10303=>703,10304=>703,10305=>703,10306=>703,
10307=>703,10308=>703,10309=>703,10310=>703,10311=>703,10312=>703,10313=>703,10314=>703,10315=>703,10316=>703,
10317=>703,10318=>703,10319=>703,10320=>703,10321=>703,10322=>703,10323=>703,10324=>703,10325=>703,10326=>703,
10327=>703,10328=>703,10329=>703,10330=>703,10331=>703,10332=>703,10333=>703,10334=>703,10335=>703,10336=>703,
10337=>703,10338=>703,10339=>703,10340=>703,10341=>703,10342=>703,10343=>703,10344=>703,10345=>703,10346=>703,
10347=>703,10348=>703,10349=>703,10350=>703,10351=>703,10352=>703,10353=>703,10354=>703,10355=>703,10356=>703,
10357=>703,10358=>703,10359=>703,10360=>703,10361=>703,10362=>703,10363=>703,10364=>703,10365=>703,10366=>703,
10367=>703,10368=>703,10369=>703,10370=>703,10371=>703,10372=>703,10373=>703,10374=>703,10375=>703,10376=>703,
10377=>703,10378=>703,10379=>703,10380=>703,10381=>703,10382=>703,10383=>703,10384=>703,10385=>703,10386=>703,
10387=>703,10388=>703,10389=>703,10390=>703,10391=>703,10392=>703,10393=>703,10394=>703,10395=>703,10396=>703,
10397=>703,10398=>703,10399=>703,10400=>703,10401=>703,10402=>703,10403=>703,10404=>703,10405=>703,10406=>703,
10407=>703,10408=>703,10409=>703,10410=>703,10411=>703,10412=>703,10413=>703,10414=>703,10415=>703,10416=>703,
10417=>703,10418=>703,10419=>703,10420=>703,10421=>703,10422=>703,10423=>703,10424=>703,10425=>703,10426=>703,
10427=>703,10428=>703,10429=>703,10430=>703,10431=>703,10432=>703,10433=>703,10434=>703,10435=>703,10436=>703,
10437=>703,10438=>703,10439=>703,10440=>703,10441=>703,10442=>703,10443=>703,10444=>703,10445=>703,10446=>703,
10447=>703,10448=>703,10449=>703,10450=>703,10451=>703,10452=>703,10453=>703,10454=>703,10455=>703,10456=>703,
10457=>703,10458=>703,10459=>703,10460=>703,10461=>703,10462=>703,10463=>703,10464=>703,10465=>703,10466=>703,
10467=>703,10468=>703,10469=>703,10470=>703,10471=>703,10472=>703,10473=>703,10474=>703,10475=>703,10476=>703,
10477=>703,10478=>703,10479=>703,10480=>703,10481=>703,10482=>703,10483=>703,10484=>703,10485=>703,10486=>703,
10487=>703,10488=>703,10489=>703,10490=>703,10491=>703,10492=>703,10493=>703,10494=>703,10495=>703,10496=>754,
10497=>754,10498=>754,10499=>754,10500=>754,10501=>754,10502=>754,10503=>754,10504=>754,10505=>754,10506=>754,
10507=>754,10508=>754,10509=>754,10510=>754,10511=>754,10512=>754,10513=>754,10514=>754,10515=>754,10516=>754,
10517=>754,10518=>754,10519=>754,10520=>754,10521=>754,10522=>754,10523=>754,10524=>754,10525=>754,10526=>754,
10527=>754,10528=>754,10529=>754,10530=>754,10531=>754,10532=>754,10533=>754,10534=>754,10535=>754,10536=>754,
10537=>754,10538=>754,10539=>754,10540=>754,10541=>754,10542=>754,10543=>754,10544=>754,10545=>754,10546=>754,
10547=>754,10548=>754,10549=>754,10550=>754,10551=>754,10552=>754,10553=>754,10554=>754,10555=>754,10556=>754,
10557=>754,10558=>754,10559=>754,10560=>754,10561=>754,10562=>754,10563=>754,10564=>754,10565=>754,10566=>754,
10567=>754,10568=>754,10569=>754,10570=>754,10571=>754,10572=>754,10573=>754,10574=>754,10575=>754,10576=>754,
10577=>754,10578=>754,10579=>754,10580=>754,10581=>754,10582=>754,10583=>754,10584=>754,10585=>754,10586=>754,
10587=>754,10588=>754,10589=>754,10590=>754,10591=>754,10592=>754,10593=>754,10594=>754,10595=>754,10596=>754,
10597=>754,10598=>754,10599=>754,10600=>754,10601=>754,10602=>754,10603=>754,10604=>754,10605=>754,10606=>754,
10607=>754,10608=>754,10609=>754,10610=>754,10611=>754,10612=>754,10613=>754,10614=>754,10615=>929,10616=>754,
10617=>754,10618=>864,10619=>754,10620=>754,10621=>754,10622=>754,10623=>754,10731=>444,10764=>1604,10765=>549,
10766=>549,10799=>754,11008=>754,11009=>754,11010=>754,11011=>754,11012=>754,11013=>754,11014=>754,11015=>754,
11016=>754,11017=>754,11018=>754,11019=>754,11020=>754,11021=>754,11022=>754,11023=>754,11024=>754,11025=>754,
11026=>850,11027=>850,11028=>850,11029=>850,11030=>692,11031=>692,11032=>692,11033=>692,11034=>850,11364=>748,
11367=>850,11368=>654,11369=>782,11370=>624,11371=>657,11372=>511,11374=>996,11375=>698,11381=>701,11382=>541,
11383=>814,11385=>514,11386=>600,11388=>282,11389=>439,11520=>695,11521=>571,11522=>723,11523=>592,11524=>708,
11525=>866,11526=>680,11527=>864,11528=>555,11529=>581,11530=>866,11531=>567,11532=>581,11533=>866,11534=>761,
11535=>779,11536=>865,11537=>580,11538=>580,11539=>863,11540=>851,11541=>777,11542=>580,11543=>581,11544=>580,
11545=>584,11546=>619,11547=>842,11548=>883,11549=>613,11550=>608,11551=>766,11552=>1002,11553=>569,11554=>580,
11555=>582,11556=>674,11557=>822,11800=>527,11810=>426,11811=>426,11812=>426,11813=>426,11822=>527,42564=>650,
42565=>506,42566=>421,42567=>342,42576=>1200,42577=>982,42580=>1158,42581=>923,42582=>1158,42583=>935,42760=>450,
42761=>450,42762=>450,42763=>450,42764=>450,42765=>450,42766=>450,42767=>450,42768=>450,42769=>450,42770=>450,
42771=>450,42772=>450,42773=>450,42774=>450,42779=>346,42780=>346,42781=>249,42782=>249,42783=>249,42891=>395,
42892=>275,62464=>634,62465=>645,62466=>688,62467=>898,62468=>645,62469=>639,62470=>698,62471=>934,62472=>645,
62473=>645,62474=>1178,62475=>660,62476=>659,62477=>903,62478=>645,62479=>659,62480=>945,62481=>717,62482=>765,
62483=>719,62484=>896,62485=>659,62486=>888,62487=>658,62488=>665,62489=>659,62490=>702,62491=>659,62492=>665,
62493=>646,62494=>702,62495=>842,62496=>644,62497=>743,62498=>645,62499=>645,62500=>645,62501=>695,62502=>911,
62504=>813,63173=>600,63185=>450,63188=>450,64256=>738,64257=>654,64258=>654,64259=>1007,64260=>1005,64261=>784,
64262=>874,65024=>0,65025=>0,65026=>0,65027=>0,65028=>0,65029=>0,65030=>0,65031=>0,65032=>0,
65033=>0,65034=>0,65035=>0,65036=>0,65037=>0,65038=>0,65039=>0,65529=>0,65530=>0,65531=>0,
65532=>0,65533=>1002);
$enc='';
$diff='';
$file='dejavuserifcondensedb.z';
$ctg='dejavuserifcondensedb.ctg.z';
$originalsize=282092;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/dejavuserifcondensedb.php | PHP | asf20 | 28,679 |
<?php
// core font definition file for TCPDF (www.tcpdf.org)
$type='core';
$dw=556;
$cw=array(0=>278,1=>278,2=>278,3=>278,4=>278,5=>278,6=>278,7=>278,8=>278,9=>278,
10=>278,11=>278,12=>278,13=>278,14=>278,15=>278,16=>278,17=>278,18=>278,19=>278,
20=>278,21=>278,22=>278,23=>278,24=>278,25=>278,26=>278,27=>278,28=>278,29=>278,
30=>278,31=>278,32=>278,33=>278,34=>355,35=>556,36=>556,37=>889,38=>667,39=>191,
40=>333,41=>333,42=>389,43=>584,44=>278,45=>333,46=>278,47=>278,48=>556,49=>556,
50=>556,51=>556,52=>556,53=>556,54=>556,55=>556,56=>556,57=>556,58=>278,59=>278,
60=>584,61=>584,62=>584,63=>556,64=>1015,65=>667,66=>667,67=>722,68=>722,69=>667,
70=>611,71=>778,72=>722,73=>278,74=>500,75=>667,76=>556,77=>833,78=>722,79=>778,
80=>667,81=>778,82=>722,83=>667,84=>611,85=>722,86=>667,87=>944,88=>667,89=>667,
90=>611,91=>278,92=>278,93=>278,94=>469,95=>556,96=>333,97=>556,98=>556,99=>500,
100=>556,101=>556,102=>278,103=>556,104=>556,105=>222,106=>222,107=>500,108=>222,
109=>833,110=>556,111=>556,112=>556,113=>556,114=>333,115=>500,116=>278,117=>556,
118=>500,119=>722,120=>500,121=>500,122=>500,123=>334,124=>260,125=>334,126=>584,
127=>350,128=>556,129=>350,130=>222,131=>556,132=>333,133=>1000,134=>556,135=>556,
136=>333,137=>1000,138=>667,139=>333,140=>1000,141=>350,142=>611,143=>350,144=>350,
145=>222,146=>222,147=>333,148=>333,149=>350,150=>556,151=>1000,152=>333,153=>1000,
154=>500,155=>333,156=>944,157=>350,158=>500,159=>667,160=>278,161=>333,162=>556,
163=>556,164=>556,165=>556,166=>260,167=>556,168=>333,169=>737,170=>370,171=>556,
172=>584,173=>333,174=>737,175=>333,176=>400,177=>584,178=>333,179=>333,180=>333,
181=>556,182=>537,183=>278,184=>333,185=>333,186=>365,187=>556,188=>834,189=>834,
190=>834,191=>611,192=>667,193=>667,194=>667,195=>667,196=>667,197=>667,198=>1000,
199=>722,200=>667,201=>667,202=>667,203=>667,204=>278,205=>278,206=>278,207=>278,
208=>722,209=>722,210=>778,211=>778,212=>778,213=>778,214=>778,215=>584,216=>778,
217=>722,218=>722,219=>722,220=>722,221=>667,222=>667,223=>611,224=>556,225=>556,
226=>556,227=>556,228=>556,229=>556,230=>889,231=>500,232=>556,233=>556,234=>556,
235=>556,236=>278,237=>278,238=>278,239=>278,240=>556,241=>556,242=>556,243=>556,
244=>556,245=>556,246=>556,247=>584,248=>611,249=>556,250=>556,251=>556,252=>556,
253=>500,254=>556,255=>500);
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/helvetica.php | PHP | asf20 | 2,340 |
<?php
$type='TrueTypeUnicode';
$name='DejaVuSansCondensed-Oblique';
$desc=array('Ascent'=>928,'Descent'=>-236,'CapHeight'=>-39,'Flags'=>96,'FontBBox'=>'[-914 -350 1493 1068]','ItalicAngle'=>-11,'StemV'=>70,'MissingWidth'=>540);
$up=-63;
$ut=44;
$dw=540;
$cw=array(
0=>540,32=>286,33=>360,34=>414,35=>754,36=>572,37=>855,38=>702,39=>247,40=>351,
41=>351,42=>450,43=>754,44=>286,45=>325,46=>286,47=>303,48=>572,49=>572,50=>572,
51=>572,52=>572,53=>572,54=>572,55=>572,56=>572,57=>572,58=>303,59=>303,60=>754,
61=>754,62=>754,63=>478,64=>900,65=>615,66=>617,67=>628,68=>693,69=>568,70=>518,
71=>697,72=>677,73=>265,74=>265,75=>590,76=>501,77=>776,78=>673,79=>708,80=>542,
81=>708,82=>625,83=>571,84=>549,85=>659,86=>615,87=>890,88=>616,89=>549,90=>616,
91=>351,92=>303,93=>351,94=>754,95=>450,96=>450,97=>551,98=>571,99=>495,100=>571,
101=>554,102=>316,103=>571,104=>570,105=>250,106=>250,107=>521,108=>250,109=>876,110=>570,
111=>550,112=>571,113=>571,114=>370,115=>469,116=>353,117=>570,118=>532,119=>736,120=>532,
121=>532,122=>472,123=>572,124=>303,125=>572,126=>754,8364=>572,8218=>286,402=>316,8222=>466,
8230=>900,8224=>450,8225=>450,710=>450,8240=>1215,352=>571,8249=>360,338=>962,381=>616,8216=>286,
8217=>286,8220=>466,8221=>466,8226=>531,8211=>450,8212=>900,732=>450,8482=>900,353=>469,8250=>360,
339=>925,382=>472,376=>549,160=>286,161=>360,162=>572,163=>572,164=>572,165=>572,166=>303,
167=>450,168=>450,169=>900,170=>424,171=>555,172=>754,173=>325,174=>900,175=>450,176=>450,
177=>754,178=>360,179=>360,180=>450,181=>572,182=>572,183=>286,184=>450,185=>360,186=>424,
187=>555,188=>872,189=>872,190=>872,191=>478,192=>615,193=>615,194=>615,195=>615,196=>615,
197=>615,198=>876,199=>628,200=>568,201=>568,202=>568,203=>568,204=>265,205=>265,206=>265,
207=>265,208=>697,209=>673,210=>708,211=>708,212=>708,213=>708,214=>708,215=>754,216=>708,
217=>659,218=>659,219=>659,220=>659,221=>549,222=>547,223=>567,224=>551,225=>551,226=>551,
227=>551,228=>551,229=>551,230=>896,231=>495,232=>554,233=>554,234=>554,235=>554,236=>250,
237=>250,238=>250,239=>250,240=>550,241=>570,242=>550,243=>550,244=>550,245=>550,246=>550,
247=>754,248=>550,249=>570,250=>570,251=>570,252=>570,253=>532,254=>571,255=>532,256=>615,
257=>551,258=>615,259=>551,260=>615,261=>551,262=>628,263=>495,264=>628,265=>495,266=>628,
267=>495,268=>628,269=>495,270=>693,271=>571,272=>697,273=>571,274=>568,275=>554,276=>568,
277=>554,278=>568,279=>554,280=>568,281=>554,282=>568,283=>554,284=>697,285=>571,286=>697,
287=>571,288=>697,289=>571,290=>697,291=>571,292=>677,293=>570,294=>824,295=>625,296=>265,
297=>250,298=>265,299=>250,300=>265,301=>250,302=>265,303=>250,304=>265,305=>250,306=>531,
307=>500,308=>265,309=>250,310=>590,311=>521,312=>521,313=>501,314=>250,315=>501,316=>250,
317=>501,318=>250,319=>501,320=>250,321=>505,322=>258,323=>673,324=>570,325=>673,326=>570,
327=>673,328=>570,329=>732,330=>673,331=>570,332=>708,333=>550,334=>708,335=>550,336=>708,
337=>550,340=>625,341=>370,342=>625,343=>370,344=>625,345=>370,346=>571,347=>469,348=>571,
349=>469,350=>571,351=>469,354=>549,355=>353,356=>549,357=>353,358=>549,359=>353,360=>659,
361=>570,362=>659,363=>570,364=>659,365=>570,366=>659,367=>570,368=>659,369=>570,370=>659,
371=>570,372=>890,373=>736,374=>549,375=>532,377=>616,378=>472,379=>616,380=>472,383=>316,
384=>571,385=>661,386=>617,387=>571,388=>617,389=>571,390=>633,391=>628,392=>495,393=>697,
394=>737,395=>617,396=>571,397=>550,398=>568,399=>708,400=>553,401=>518,403=>697,404=>618,
405=>885,406=>318,407=>265,408=>671,409=>521,410=>250,411=>532,412=>876,413=>673,414=>570,
415=>708,416=>822,417=>550,418=>844,419=>663,420=>586,421=>571,422=>625,423=>571,424=>469,
425=>568,426=>302,427=>353,428=>549,429=>353,430=>549,431=>754,432=>570,433=>688,434=>648,
435=>669,436=>657,437=>616,438=>472,439=>599,440=>599,441=>520,442=>472,443=>572,444=>599,
445=>520,446=>459,447=>571,448=>265,449=>443,450=>413,451=>266,452=>1310,453=>1165,454=>1043,
455=>767,456=>751,457=>500,458=>938,459=>923,460=>820,461=>615,462=>551,463=>265,464=>250,
465=>708,466=>550,467=>659,468=>570,469=>659,470=>570,471=>659,472=>570,473=>659,474=>570,
475=>659,476=>570,477=>554,478=>615,479=>551,480=>615,481=>551,482=>876,483=>896,484=>697,
485=>571,486=>697,487=>571,488=>590,489=>521,490=>708,491=>550,492=>708,493=>550,494=>599,
495=>472,496=>250,497=>1310,498=>1165,499=>1043,500=>697,501=>571,502=>1001,503=>614,504=>673,
505=>570,506=>615,507=>551,508=>876,509=>896,510=>708,511=>550,512=>615,513=>551,514=>615,
515=>551,516=>568,517=>554,518=>568,519=>554,520=>265,521=>250,522=>265,523=>250,524=>708,
525=>550,526=>708,527=>550,528=>625,529=>370,530=>625,531=>370,532=>659,533=>570,534=>659,
535=>570,536=>571,537=>469,538=>549,539=>353,540=>564,541=>469,542=>677,543=>570,544=>662,
545=>754,546=>628,547=>549,548=>616,549=>472,550=>615,551=>551,552=>568,553=>554,554=>708,
555=>550,556=>708,557=>550,558=>708,559=>550,560=>708,561=>550,562=>549,563=>532,564=>427,
565=>758,566=>429,567=>250,568=>898,569=>898,570=>615,571=>628,572=>495,573=>501,574=>549,
575=>469,576=>472,577=>542,578=>431,579=>617,580=>659,581=>615,582=>568,583=>554,584=>265,
585=>250,586=>703,587=>571,588=>625,589=>370,590=>549,591=>532,592=>551,593=>571,594=>571,
595=>571,596=>495,597=>495,598=>571,599=>654,600=>554,601=>554,602=>759,603=>490,604=>490,
605=>698,606=>598,607=>293,608=>626,609=>571,610=>566,611=>536,612=>536,613=>570,614=>570,
615=>570,616=>334,617=>348,618=>334,619=>356,620=>438,621=>250,622=>635,623=>876,624=>876,
625=>876,626=>581,627=>578,628=>570,629=>550,630=>772,631=>655,632=>593,633=>422,634=>422,
635=>422,636=>422,637=>422,638=>477,639=>477,640=>541,641=>541,642=>469,643=>302,644=>302,
645=>415,646=>302,647=>353,648=>353,649=>570,650=>556,651=>538,652=>532,653=>736,654=>532,
655=>549,656=>472,657=>472,658=>520,659=>520,660=>459,661=>459,662=>459,663=>459,664=>708,
665=>521,666=>598,667=>637,668=>588,669=>263,670=>600,671=>456,672=>654,673=>459,674=>459,
675=>913,676=>952,677=>911,678=>742,679=>549,680=>700,681=>763,682=>576,683=>589,684=>463,
685=>463,686=>513,687=>597,688=>359,689=>359,690=>157,691=>233,692=>266,693=>266,694=>341,
695=>463,696=>335,697=>250,698=>414,699=>286,700=>286,701=>286,702=>276,703=>276,704=>333,
705=>333,706=>450,707=>450,708=>450,709=>450,711=>450,712=>247,713=>450,714=>450,715=>450,
716=>247,717=>450,718=>450,719=>450,720=>303,721=>303,722=>276,723=>276,724=>450,725=>450,
726=>351,727=>286,728=>450,729=>450,730=>450,731=>450,733=>450,734=>284,735=>450,736=>383,
737=>149,738=>335,739=>399,740=>333,741=>444,742=>444,743=>444,744=>444,745=>444,748=>450,
749=>450,750=>466,755=>450,759=>450,768=>0,769=>0,770=>0,771=>0,772=>0,773=>0,
774=>0,775=>0,776=>0,777=>0,778=>0,779=>0,780=>0,781=>0,782=>0,783=>0,
784=>0,785=>0,786=>0,787=>0,788=>0,789=>0,790=>0,791=>0,792=>0,793=>0,
794=>0,795=>0,796=>0,797=>0,798=>0,799=>0,800=>0,801=>0,802=>0,803=>0,
804=>0,805=>0,806=>0,807=>0,808=>0,809=>0,810=>0,811=>0,812=>0,813=>0,
814=>0,815=>0,816=>0,817=>0,818=>0,819=>0,820=>0,821=>0,822=>0,823=>0,
824=>0,825=>0,826=>0,827=>0,828=>0,829=>0,830=>0,831=>0,832=>0,833=>0,
834=>0,835=>0,836=>0,837=>0,838=>0,839=>0,840=>0,841=>0,842=>0,843=>0,
844=>0,845=>0,846=>0,847=>0,849=>0,850=>0,851=>0,855=>0,856=>0,858=>0,
860=>0,861=>0,862=>0,863=>0,864=>0,865=>0,866=>0,880=>589,881=>511,882=>775,
883=>583,884=>250,885=>250,886=>673,887=>584,890=>450,891=>494,892=>495,893=>494,894=>303,
900=>450,901=>450,902=>615,903=>286,904=>690,905=>813,906=>391,908=>755,910=>773,911=>814,
912=>304,913=>615,914=>617,915=>501,916=>615,917=>568,918=>616,919=>677,920=>708,921=>265,
922=>590,923=>615,924=>776,925=>673,926=>568,927=>708,928=>677,929=>542,931=>568,932=>549,
933=>549,934=>708,935=>616,936=>708,937=>688,938=>265,939=>549,940=>593,941=>486,942=>570,
943=>304,944=>521,945=>593,946=>574,947=>532,948=>550,949=>486,950=>489,951=>570,952=>550,
953=>304,954=>530,955=>532,956=>572,957=>502,958=>501,959=>550,960=>542,961=>571,962=>528,
963=>570,964=>542,965=>521,966=>593,967=>532,968=>593,969=>753,970=>304,971=>521,972=>550,
973=>521,974=>753,975=>590,976=>553,977=>557,978=>628,979=>758,980=>628,981=>593,982=>753,
983=>597,984=>708,985=>550,986=>583,987=>528,988=>518,989=>413,990=>593,991=>593,992=>778,
993=>564,994=>840,995=>753,996=>682,997=>593,998=>712,999=>553,1000=>618,1001=>546,1002=>690,
1003=>563,1004=>629,1005=>550,1006=>549,1007=>482,1008=>597,1009=>571,1010=>495,1011=>250,1012=>708,
1013=>554,1014=>554,1015=>547,1016=>571,1017=>628,1018=>776,1019=>585,1020=>571,1021=>633,1022=>628,
1023=>633,1024=>568,1025=>568,1026=>708,1027=>501,1028=>628,1029=>571,1030=>265,1031=>265,1032=>265,
1033=>984,1034=>940,1035=>708,1036=>639,1037=>673,1038=>548,1039=>677,1040=>615,1041=>617,1042=>617,
1043=>501,1044=>703,1045=>568,1046=>969,1047=>577,1048=>673,1049=>673,1050=>639,1051=>677,1052=>776,
1053=>677,1054=>708,1055=>677,1056=>542,1057=>628,1058=>549,1059=>548,1060=>774,1061=>616,1062=>699,
1063=>617,1064=>962,1065=>984,1066=>749,1067=>736,1068=>617,1069=>628,1070=>971,1071=>625,1072=>551,
1073=>555,1074=>530,1075=>473,1076=>622,1077=>554,1078=>811,1079=>479,1080=>584,1081=>584,1082=>543,
1083=>575,1084=>679,1085=>588,1086=>550,1087=>588,1088=>571,1089=>495,1090=>524,1091=>532,1092=>769,
1093=>532,1094=>612,1095=>532,1096=>823,1097=>848,1098=>636,1099=>710,1100=>530,1101=>494,1102=>757,
1103=>541,1104=>554,1105=>554,1106=>563,1107=>473,1108=>494,1109=>469,1110=>250,1111=>250,1112=>250,
1113=>812,1114=>809,1115=>586,1116=>543,1117=>584,1118=>532,1119=>588,1120=>840,1121=>753,1122=>693,
1123=>604,1124=>848,1125=>674,1126=>791,1127=>705,1128=>1043,1129=>901,1130=>708,1131=>550,1132=>924,
1133=>742,1134=>572,1135=>486,1136=>771,1137=>789,1138=>708,1139=>550,1140=>703,1141=>598,1142=>703,
1143=>598,1144=>893,1145=>813,1146=>857,1147=>682,1148=>1062,1149=>925,1150=>840,1151=>753,1152=>628,
1153=>495,1154=>452,1155=>0,1156=>0,1157=>0,1158=>0,1159=>0,1160=>376,1161=>376,1162=>673,
1163=>591,1164=>617,1165=>530,1166=>542,1167=>571,1168=>549,1169=>473,1170=>607,1171=>500,1172=>501,
1173=>441,1174=>969,1175=>811,1176=>577,1177=>479,1178=>639,1179=>543,1180=>639,1181=>543,1182=>639,
1183=>543,1184=>771,1185=>748,1186=>677,1187=>594,1188=>913,1189=>789,1190=>1002,1191=>855,1192=>801,
1193=>636,1194=>628,1195=>495,1196=>549,1197=>476,1198=>549,1199=>532,1200=>549,1201=>532,1202=>616,
1203=>532,1204=>840,1205=>726,1206=>617,1207=>532,1208=>617,1209=>532,1210=>617,1211=>570,1212=>836,
1213=>658,1214=>836,1215=>658,1216=>265,1217=>969,1218=>811,1219=>589,1220=>543,1221=>677,1222=>575,
1223=>677,1224=>594,1225=>677,1226=>594,1227=>617,1228=>532,1229=>776,1230=>679,1231=>250,1232=>615,
1233=>551,1234=>615,1235=>551,1236=>876,1237=>896,1238=>568,1239=>554,1240=>708,1241=>554,1242=>708,
1243=>554,1244=>969,1245=>811,1246=>577,1247=>479,1248=>599,1249=>520,1250=>673,1251=>584,1252=>673,
1253=>584,1254=>708,1255=>550,1256=>708,1257=>550,1258=>708,1259=>550,1260=>628,1261=>494,1262=>548,
1263=>532,1264=>548,1265=>532,1266=>548,1267=>532,1268=>617,1269=>532,1270=>501,1271=>442,1272=>736,
1273=>710,1274=>607,1275=>500,1276=>616,1277=>532,1278=>616,1279=>532,1280=>617,1281=>530,1282=>905,
1283=>807,1284=>877,1285=>782,1286=>611,1287=>529,1288=>964,1289=>861,1290=>1001,1291=>870,1292=>697,
1293=>593,1294=>695,1295=>640,1296=>553,1297=>486,1298=>677,1299=>575,1300=>1076,1301=>896,1302=>810,
1303=>780,1304=>927,1305=>890,1306=>708,1307=>571,1308=>890,1309=>736,1312=>1002,1313=>848,1314=>1002,
1315=>854,1316=>713,1317=>614,1329=>780,1330=>659,1331=>794,1332=>794,1333=>659,1334=>579,1335=>613,
1336=>659,1337=>765,1338=>794,1339=>659,1340=>501,1341=>741,1342=>888,1343=>659,1344=>636,1345=>579,
1346=>794,1347=>699,1348=>794,1349=>659,1350=>756,1351=>659,1352=>659,1353=>659,1354=>711,1355=>579,
1356=>794,1357=>659,1358=>794,1359=>571,1360=>659,1361=>659,1362=>719,1363=>774,1364=>711,1365=>708,
1366=>571,1369=>276,1370=>286,1371=>450,1372=>450,1373=>352,1374=>474,1375=>450,1377=>876,1378=>570,
1379=>686,1380=>690,1381=>570,1382=>627,1383=>479,1384=>570,1385=>630,1386=>627,1387=>570,1388=>363,
1389=>804,1390=>576,1391=>570,1392=>570,1393=>571,1394=>631,1395=>570,1396=>593,1397=>250,1398=>684,
1399=>464,1400=>570,1401=>407,1402=>876,1403=>464,1404=>691,1405=>570,1406=>626,1407=>876,1408=>570,
1409=>571,1410=>451,1411=>876,1412=>583,1413=>550,1414=>566,1415=>686,1417=>303,1418=>390,1456=>0,
1457=>0,1458=>0,1459=>0,1460=>0,1461=>0,1462=>0,1463=>0,1464=>0,1465=>0,1466=>0,
1467=>0,1468=>0,1469=>0,1470=>325,1471=>0,1472=>265,1473=>0,1474=>0,1475=>265,1478=>410,
1479=>0,1488=>566,1489=>547,1490=>403,1491=>534,1492=>576,1493=>245,1494=>336,1495=>576,1496=>583,
1497=>245,1498=>532,1499=>500,1500=>539,1501=>576,1502=>593,1503=>245,1504=>397,1505=>629,1506=>506,
1507=>576,1508=>543,1509=>468,1510=>523,1511=>596,1512=>532,1513=>727,1514=>591,1520=>423,1521=>409,
1522=>423,1523=>374,1524=>580,3647=>586,3713=>603,3714=>615,3716=>619,3719=>434,3720=>565,3722=>615,
3725=>619,3732=>577,3733=>577,3734=>605,3735=>589,3737=>576,3738=>533,3739=>533,3740=>670,3741=>690,
3742=>618,3743=>618,3745=>631,3746=>619,3747=>615,3749=>584,3751=>569,3754=>633,3755=>737,3757=>569,
3758=>615,3759=>708,3760=>569,3761=>0,3762=>485,3763=>485,3764=>0,3765=>0,3766=>0,3767=>0,
3768=>0,3769=>0,3771=>0,3772=>0,3773=>597,3776=>324,3777=>611,3778=>414,3779=>492,3780=>442,
3782=>606,3784=>0,3785=>0,3786=>0,3787=>0,3788=>0,3789=>0,3792=>572,3793=>576,3794=>576,
3795=>603,3796=>563,3797=>563,3798=>633,3799=>603,3800=>606,3801=>609,3804=>925,3805=>925,4256=>756,
4257=>621,4258=>577,4259=>683,4260=>532,4261=>617,4262=>710,4263=>729,4264=>420,4265=>508,4266=>710,
4267=>713,4268=>526,4269=>753,4270=>675,4271=>620,4272=>729,4273=>526,4274=>526,4275=>753,4276=>753,
4277=>581,4278=>543,4279=>526,4280=>536,4281=>526,4282=>649,4283=>715,4284=>526,4285=>510,4286=>526,
4287=>602,4288=>719,4289=>488,4290=>598,4291=>488,4292=>508,4293=>606,4304=>457,4305=>457,4306=>479,
4307=>706,4308=>470,4309=>465,4310=>457,4311=>717,4312=>457,4313=>466,4314=>952,4315=>470,4316=>470,
4317=>704,4318=>466,4319=>470,4320=>713,4321=>470,4322=>590,4323=>471,4324=>709,4325=>470,4326=>704,
4327=>470,4328=>470,4329=>470,4330=>510,4331=>470,4332=>470,4333=>439,4334=>470,4335=>448,4336=>465,
4337=>504,4338=>457,4339=>457,4340=>457,4341=>507,4342=>741,4343=>536,4344=>470,4345=>498,4346=>498,
4347=>527,4348=>273,5121=>615,5122=>615,5123=>615,5124=>615,5125=>692,5126=>692,5127=>692,5129=>692,
5130=>692,5131=>692,5132=>751,5133=>751,5134=>751,5135=>751,5136=>751,5137=>751,5138=>870,5139=>906,
5140=>870,5141=>906,5142=>692,5143=>870,5144=>906,5145=>870,5146=>906,5147=>692,5149=>230,5150=>488,
5151=>381,5152=>381,5153=>350,5154=>350,5155=>354,5156=>350,5157=>419,5158=>347,5159=>230,5160=>350,
5161=>350,5162=>350,5163=>980,5164=>817,5165=>857,5166=>1005,5167=>615,5168=>615,5169=>615,5170=>615,
5171=>656,5172=>656,5173=>656,5175=>656,5176=>656,5177=>656,5178=>751,5179=>615,5180=>751,5181=>751,
5182=>751,5183=>751,5184=>870,5185=>906,5186=>870,5187=>906,5188=>870,5189=>906,5190=>870,5191=>906,
5192=>656,5193=>457,5194=>172,5196=>659,5197=>659,5198=>659,5199=>659,5200=>657,5201=>657,5202=>657,
5204=>657,5205=>657,5206=>657,5207=>829,5208=>800,5209=>829,5210=>800,5211=>829,5212=>800,5213=>835,
5214=>810,5215=>835,5216=>810,5217=>853,5218=>810,5219=>853,5220=>810,5221=>853,5222=>391,5223=>790,
5224=>790,5225=>779,5226=>801,5227=>565,5228=>565,5229=>565,5230=>565,5231=>565,5232=>565,5233=>565,
5234=>565,5235=>565,5236=>773,5237=>693,5238=>733,5239=>734,5240=>733,5241=>734,5242=>773,5243=>693,
5244=>773,5245=>693,5246=>733,5247=>734,5248=>733,5249=>734,5250=>733,5251=>366,5252=>366,5253=>675,
5254=>697,5255=>675,5256=>697,5257=>565,5258=>565,5259=>565,5260=>565,5261=>565,5262=>565,5263=>565,
5264=>565,5265=>565,5266=>773,5267=>693,5268=>733,5269=>734,5270=>733,5271=>734,5272=>773,5273=>693,
5274=>773,5275=>693,5276=>733,5277=>734,5278=>733,5279=>734,5280=>733,5281=>391,5282=>391,5283=>549,
5284=>501,5285=>501,5286=>501,5287=>549,5288=>549,5289=>549,5290=>501,5291=>501,5292=>674,5293=>691,
5294=>671,5295=>687,5296=>671,5297=>687,5298=>674,5299=>691,5300=>674,5301=>691,5302=>671,5303=>687,
5304=>671,5305=>687,5306=>671,5307=>347,5308=>457,5309=>347,5312=>766,5313=>766,5314=>766,5315=>766,
5316=>766,5317=>766,5318=>766,5319=>766,5320=>766,5321=>962,5322=>931,5323=>953,5324=>766,5325=>953,
5326=>766,5327=>766,5328=>540,5329=>407,5330=>540,5331=>766,5332=>766,5333=>766,5334=>766,5335=>766,
5336=>766,5337=>766,5338=>766,5339=>766,5340=>962,5341=>931,5342=>953,5343=>927,5344=>953,5345=>927,
5346=>962,5347=>931,5348=>962,5349=>931,5350=>975,5351=>927,5352=>975,5353=>927,5354=>540,5356=>656,
5357=>542,5358=>542,5359=>542,5360=>542,5361=>542,5362=>542,5363=>542,5364=>542,5365=>542,5366=>751,
5367=>678,5368=>712,5369=>694,5370=>712,5371=>694,5372=>751,5373=>678,5374=>751,5375=>678,5376=>712,
5377=>694,5378=>712,5379=>694,5380=>712,5381=>376,5382=>378,5383=>376,5392=>641,5393=>641,5394=>641,
5395=>802,5396=>802,5397=>802,5398=>802,5399=>818,5400=>785,5401=>818,5402=>785,5403=>818,5404=>785,
5405=>1026,5406=>989,5407=>1026,5408=>989,5409=>1026,5410=>989,5411=>1026,5412=>989,5413=>576,5414=>564,
5415=>564,5416=>564,5417=>564,5418=>564,5419=>564,5420=>564,5421=>564,5422=>564,5423=>760,5424=>703,
5425=>734,5426=>736,5427=>734,5428=>736,5429=>760,5430=>703,5431=>760,5432=>703,5433=>734,5434=>736,
5435=>734,5436=>736,5437=>734,5438=>376,5440=>350,5441=>436,5442=>824,5443=>824,5444=>776,5445=>824,
5446=>776,5447=>776,5448=>542,5449=>542,5450=>542,5451=>542,5452=>542,5453=>542,5454=>751,5455=>678,
5456=>376,5458=>656,5459=>615,5460=>615,5461=>615,5462=>615,5463=>653,5464=>653,5465=>653,5466=>653,
5467=>831,5468=>906,5469=>457,5470=>659,5471=>659,5472=>659,5473=>659,5474=>659,5475=>659,5476=>657,
5477=>657,5478=>657,5479=>657,5480=>853,5481=>810,5482=>457,5492=>747,5493=>747,5494=>747,5495=>747,
5496=>747,5497=>747,5498=>747,5499=>507,5500=>677,5501=>436,5502=>942,5503=>942,5504=>942,5505=>942,
5506=>942,5507=>942,5508=>942,5509=>743,5514=>747,5515=>747,5516=>747,5517=>747,5518=>1133,5519=>1133,
5520=>1133,5521=>901,5522=>901,5523=>1133,5524=>1133,5525=>629,5526=>965,5536=>766,5537=>766,5538=>719,
5539=>719,5540=>719,5541=>719,5542=>540,5543=>579,5544=>579,5545=>579,5546=>579,5547=>579,5548=>579,
5549=>579,5550=>376,5551=>565,5598=>693,5601=>693,5702=>421,5703=>421,5742=>399,5743=>942,5744=>1178,
5745=>1469,5746=>1469,5747=>1237,5748=>1237,5749=>1469,5750=>1469,7424=>532,7425=>646,7426=>883,7427=>527,
7428=>495,7429=>544,7430=>544,7431=>441,7432=>486,7433=>250,7434=>355,7435=>521,7436=>524,7437=>679,
7438=>584,7439=>550,7440=>495,7441=>615,7442=>615,7443=>615,7444=>920,7446=>550,7447=>550,7448=>472,
7449=>541,7450=>541,7451=>524,7452=>517,7453=>663,7454=>853,7455=>574,7456=>532,7457=>736,7458=>472,
7459=>473,7462=>524,7463=>532,7464=>507,7465=>472,7466=>531,7467=>575,7468=>387,7469=>552,7470=>389,
7472=>436,7473=>358,7474=>358,7475=>439,7476=>426,7477=>167,7478=>167,7479=>372,7480=>315,7481=>489,
7482=>424,7483=>424,7484=>446,7485=>396,7486=>342,7487=>394,7488=>346,7489=>415,7490=>560,7491=>352,
7492=>352,7493=>365,7494=>583,7495=>385,7496=>365,7497=>375,7498=>375,7499=>324,7500=>323,7501=>365,
7502=>161,7503=>383,7504=>561,7505=>368,7506=>372,7507=>333,7508=>372,7509=>372,7510=>385,7511=>265,
7512=>364,7513=>422,7514=>561,7515=>375,7517=>361,7518=>335,7519=>347,7520=>374,7521=>327,7522=>161,
7523=>233,7524=>364,7525=>375,7526=>361,7527=>335,7528=>370,7529=>374,7530=>327,7543=>571,7544=>426,
7547=>334,7557=>250,7579=>365,7580=>333,7581=>333,7582=>372,7583=>324,7584=>267,7585=>209,7586=>365,
7587=>364,7588=>235,7589=>224,7590=>234,7591=>235,7592=>211,7593=>224,7594=>211,7595=>338,7596=>561,
7597=>561,7598=>369,7599=>431,7600=>368,7601=>372,7602=>372,7603=>324,7604=>258,7605=>265,7606=>457,
7607=>376,7608=>325,7609=>365,7610=>375,7611=>330,7612=>393,7613=>330,7614=>353,7615=>372,7620=>0,
7621=>0,7622=>0,7623=>0,7624=>0,7625=>0,7680=>615,7681=>551,7682=>617,7683=>571,7684=>617,
7685=>571,7686=>617,7687=>571,7688=>628,7689=>495,7690=>693,7691=>571,7692=>693,7693=>571,7694=>693,
7695=>571,7696=>693,7697=>571,7698=>693,7699=>571,7700=>568,7701=>554,7702=>568,7703=>554,7704=>568,
7705=>554,7706=>568,7707=>554,7708=>568,7709=>554,7710=>518,7711=>316,7712=>697,7713=>571,7714=>677,
7715=>570,7716=>677,7717=>570,7718=>677,7719=>570,7720=>677,7721=>570,7722=>677,7723=>570,7724=>265,
7725=>250,7726=>265,7727=>250,7728=>590,7729=>521,7730=>590,7731=>521,7732=>590,7733=>521,7734=>501,
7735=>250,7736=>501,7737=>250,7738=>501,7739=>250,7740=>501,7741=>250,7742=>776,7743=>876,7744=>776,
7745=>876,7746=>776,7747=>876,7748=>673,7749=>570,7750=>673,7751=>570,7752=>673,7753=>570,7754=>673,
7755=>570,7756=>708,7757=>550,7758=>708,7759=>550,7760=>708,7761=>550,7762=>708,7763=>550,7764=>542,
7765=>571,7766=>542,7767=>571,7768=>625,7769=>370,7770=>625,7771=>370,7772=>625,7773=>370,7774=>625,
7775=>370,7776=>571,7777=>469,7778=>571,7779=>469,7780=>571,7781=>469,7782=>571,7783=>469,7784=>571,
7785=>469,7786=>549,7787=>353,7788=>549,7789=>353,7790=>549,7791=>353,7792=>549,7793=>353,7794=>659,
7795=>570,7796=>659,7797=>570,7798=>659,7799=>570,7800=>659,7801=>570,7802=>659,7803=>570,7804=>615,
7805=>532,7806=>615,7807=>532,7808=>890,7809=>736,7810=>890,7811=>736,7812=>890,7813=>736,7814=>890,
7815=>736,7816=>890,7817=>736,7818=>616,7819=>532,7820=>616,7821=>532,7822=>549,7823=>532,7824=>616,
7825=>472,7826=>616,7827=>472,7828=>616,7829=>472,7830=>570,7831=>353,7832=>736,7833=>532,7834=>551,
7835=>316,7838=>691,7839=>550,7840=>615,7841=>551,7842=>615,7843=>551,7844=>615,7845=>551,7846=>615,
7847=>551,7848=>615,7849=>551,7850=>615,7851=>551,7852=>615,7853=>551,7854=>615,7855=>551,7856=>615,
7857=>551,7858=>615,7859=>551,7860=>615,7861=>551,7862=>615,7863=>551,7864=>568,7865=>554,7866=>568,
7867=>554,7868=>568,7869=>554,7870=>568,7871=>554,7872=>568,7873=>554,7874=>568,7875=>554,7876=>568,
7877=>554,7878=>568,7879=>554,7880=>265,7881=>250,7882=>265,7883=>250,7884=>708,7885=>550,7886=>708,
7887=>550,7888=>708,7889=>550,7890=>708,7891=>550,7892=>708,7893=>550,7894=>708,7895=>550,7896=>708,
7897=>550,7898=>822,7899=>550,7900=>822,7901=>550,7902=>822,7903=>550,7904=>822,7905=>550,7906=>822,
7907=>550,7908=>659,7909=>570,7910=>659,7911=>570,7912=>754,7913=>570,7914=>754,7915=>570,7916=>754,
7917=>570,7918=>754,7919=>570,7920=>754,7921=>570,7922=>549,7923=>532,7924=>549,7925=>532,7926=>549,
7927=>532,7928=>549,7929=>532,7936=>593,7937=>593,7938=>593,7939=>593,7940=>593,7941=>593,7942=>593,
7943=>593,7944=>615,7945=>615,7946=>790,7947=>790,7948=>692,7949=>721,7950=>637,7951=>668,7952=>486,
7953=>486,7954=>486,7955=>486,7956=>486,7957=>486,7960=>640,7961=>640,7962=>869,7963=>877,7964=>809,
7965=>835,7968=>570,7969=>570,7970=>570,7971=>570,7972=>570,7973=>570,7974=>570,7975=>570,7976=>753,
7977=>751,7978=>977,7979=>980,7980=>924,7981=>945,7982=>840,7983=>852,7984=>304,7985=>304,7986=>304,
7987=>304,7988=>304,7989=>304,7990=>304,7991=>304,7992=>342,7993=>336,7994=>571,7995=>571,7996=>513,
7997=>540,7998=>440,7999=>443,8000=>550,8001=>550,8002=>550,8003=>550,8004=>550,8005=>550,8008=>724,
8009=>763,8010=>985,8011=>989,8012=>844,8013=>873,8016=>521,8017=>521,8018=>521,8019=>521,8020=>521,
8021=>521,8022=>521,8023=>521,8025=>705,8027=>897,8029=>911,8031=>808,8032=>753,8033=>753,8034=>753,
8035=>753,8036=>753,8037=>753,8038=>753,8039=>753,8040=>722,8041=>759,8042=>980,8043=>985,8044=>851,
8045=>875,8046=>829,8047=>857,8048=>593,8049=>593,8050=>486,8051=>493,8052=>570,8053=>589,8054=>304,
8055=>304,8056=>550,8057=>550,8058=>521,8059=>521,8060=>753,8061=>753,8064=>593,8065=>593,8066=>593,
8067=>593,8068=>593,8069=>593,8070=>593,8071=>593,8072=>615,8073=>615,8074=>790,8075=>790,8076=>692,
8077=>721,8078=>637,8079=>668,8080=>570,8081=>570,8082=>570,8083=>570,8084=>570,8085=>570,8086=>570,
8087=>570,8088=>753,8089=>751,8090=>977,8091=>980,8092=>924,8093=>945,8094=>840,8095=>852,8096=>753,
8097=>753,8098=>753,8099=>753,8100=>753,8101=>753,8102=>753,8103=>753,8104=>722,8105=>759,8106=>980,
8107=>985,8108=>851,8109=>875,8110=>829,8111=>857,8112=>593,8113=>593,8114=>593,8115=>593,8116=>593,
8118=>593,8119=>593,8120=>615,8121=>615,8122=>645,8123=>623,8124=>615,8125=>450,8126=>450,8127=>450,
8128=>450,8129=>450,8130=>570,8131=>570,8132=>589,8134=>570,8135=>570,8136=>724,8137=>671,8138=>837,
8139=>784,8140=>677,8141=>450,8142=>450,8143=>450,8144=>304,8145=>304,8146=>304,8147=>304,8150=>304,
8151=>304,8152=>265,8153=>265,8154=>427,8155=>367,8157=>450,8158=>450,8159=>450,8160=>521,8161=>521,
8162=>521,8163=>521,8164=>571,8165=>571,8166=>521,8167=>521,8168=>549,8169=>549,8170=>760,8171=>742,
8172=>616,8173=>450,8174=>450,8175=>450,8178=>753,8179=>753,8180=>753,8182=>753,8183=>753,8184=>847,
8185=>731,8186=>830,8187=>743,8188=>688,8189=>450,8190=>450,8192=>450,8193=>900,8194=>450,8195=>900,
8196=>296,8197=>225,8198=>150,8199=>572,8200=>286,8201=>180,8202=>89,8203=>0,8204=>0,8205=>0,
8206=>0,8207=>0,8208=>325,8209=>325,8210=>572,8213=>900,8214=>450,8215=>450,8219=>286,8223=>466,
8227=>531,8228=>299,8229=>600,8231=>286,8234=>0,8235=>0,8236=>0,8237=>0,8238=>0,8239=>180,
8241=>1521,8242=>204,8243=>336,8244=>468,8245=>204,8246=>336,8247=>468,8248=>305,8251=>754,8252=>437,
8253=>478,8254=>450,8255=>723,8256=>723,8257=>225,8258=>900,8259=>450,8260=>150,8261=>351,8262=>351,
8263=>830,8264=>659,8265=>659,8266=>447,8267=>572,8268=>450,8269=>450,8270=>450,8271=>303,8272=>723,
8273=>450,8274=>404,8275=>900,8276=>723,8277=>754,8278=>527,8279=>597,8280=>754,8281=>754,8282=>286,
8283=>717,8284=>754,8285=>286,8286=>286,8287=>200,8288=>0,8289=>0,8290=>0,8291=>0,8292=>0,
8298=>0,8299=>0,8300=>0,8301=>0,8302=>0,8303=>0,8304=>360,8305=>161,8308=>360,8309=>360,
8310=>360,8311=>360,8312=>360,8313=>360,8314=>475,8315=>475,8316=>475,8317=>221,8318=>221,8319=>359,
8320=>360,8321=>360,8322=>360,8323=>360,8324=>360,8325=>360,8326=>360,8327=>360,8328=>360,8329=>360,
8330=>475,8331=>475,8332=>475,8333=>221,8334=>221,8336=>352,8337=>375,8338=>372,8339=>399,8340=>375,
8352=>789,8353=>572,8354=>572,8355=>572,8356=>572,8357=>876,8358=>673,8359=>1143,8360=>966,8361=>890,
8362=>754,8363=>572,8365=>590,8366=>549,8367=>1145,8368=>572,8369=>572,8370=>572,8371=>572,8372=>696,
8373=>577,8400=>0,8401=>0,8406=>0,8407=>0,8411=>0,8412=>0,8417=>0,8448=>873,8449=>873,
8450=>628,8451=>1011,8452=>807,8453=>872,8454=>929,8455=>553,8456=>628,8457=>856,8459=>889,8460=>679,
8461=>765,8462=>570,8463=>570,8464=>422,8465=>627,8466=>648,8467=>372,8468=>736,8469=>721,8470=>936,
8471=>900,8472=>627,8473=>631,8474=>708,8475=>718,8476=>732,8477=>712,8478=>807,8479=>615,8480=>917,
8481=>912,8483=>615,8484=>670,8485=>520,8486=>688,8487=>688,8488=>554,8489=>304,8490=>590,8491=>615,
8492=>708,8493=>633,8494=>769,8495=>532,8496=>545,8497=>708,8498=>518,8499=>962,8500=>416,8501=>670,
8502=>606,8503=>419,8504=>580,8505=>342,8506=>833,8507=>1041,8508=>632,8509=>655,8510=>589,8511=>764,
8512=>729,8513=>697,8514=>501,8515=>501,8516=>549,8517=>737,8518=>637,8519=>554,8520=>316,8521=>316,
8523=>702,8526=>474,8531=>872,8532=>872,8533=>872,8534=>872,8535=>872,8536=>872,8537=>872,8538=>872,
8539=>872,8540=>872,8541=>872,8542=>872,8543=>511,8544=>265,8545=>443,8546=>620,8547=>831,8548=>615,
8549=>830,8550=>1007,8551=>1185,8552=>826,8553=>616,8554=>839,8555=>1018,8556=>501,8557=>628,8558=>693,
8559=>776,8560=>250,8561=>412,8562=>573,8563=>730,8564=>532,8565=>729,8566=>892,8567=>1053,8568=>737,
8569=>532,8570=>740,8571=>901,8572=>250,8573=>495,8574=>571,8575=>876,8576=>1121,8577=>693,8578=>1121,
8579=>633,8580=>494,8592=>754,8593=>754,8594=>754,8595=>754,8596=>754,8597=>754,8598=>754,8599=>754,
8600=>754,8601=>754,8602=>754,8603=>754,8604=>754,8605=>754,8606=>754,8607=>754,8608=>754,8609=>754,
8610=>754,8611=>754,8612=>754,8613=>754,8614=>754,8615=>754,8616=>754,8617=>754,8618=>754,8619=>754,
8620=>754,8621=>754,8622=>754,8623=>754,8624=>754,8625=>754,8626=>754,8627=>754,8628=>754,8629=>754,
8630=>754,8631=>754,8632=>754,8633=>754,8634=>754,8635=>754,8636=>754,8637=>754,8638=>754,8639=>754,
8640=>754,8641=>754,8642=>754,8643=>754,8644=>754,8645=>754,8646=>754,8647=>754,8648=>754,8649=>754,
8650=>754,8651=>754,8652=>754,8653=>754,8654=>754,8655=>754,8656=>754,8657=>754,8658=>754,8659=>754,
8660=>754,8661=>754,8662=>754,8663=>754,8664=>754,8665=>754,8666=>754,8667=>754,8668=>754,8669=>754,
8670=>754,8671=>754,8672=>754,8673=>754,8674=>754,8675=>754,8676=>754,8677=>754,8678=>754,8679=>754,
8680=>754,8681=>754,8682=>754,8683=>754,8684=>754,8685=>754,8686=>754,8687=>754,8688=>754,8689=>754,
8690=>754,8691=>754,8692=>754,8693=>754,8694=>754,8695=>754,8696=>754,8697=>754,8698=>754,8699=>754,
8700=>754,8701=>754,8702=>754,8703=>754,8704=>615,8705=>572,8706=>465,8707=>568,8708=>568,8709=>784,
8710=>602,8711=>602,8712=>784,8713=>784,8714=>646,8715=>784,8716=>784,8717=>646,8718=>572,8719=>681,
8720=>681,8721=>606,8722=>754,8723=>754,8724=>754,8725=>303,8726=>573,8727=>754,8728=>563,8729=>563,
8730=>573,8731=>573,8732=>573,8733=>643,8734=>750,8735=>754,8736=>807,8737=>807,8738=>754,8739=>450,
8740=>450,8741=>450,8742=>450,8743=>659,8744=>659,8745=>659,8746=>659,8747=>469,8748=>710,8749=>951,
8750=>469,8751=>710,8752=>951,8753=>469,8754=>469,8755=>469,8756=>572,8757=>572,8758=>234,8759=>572,
8760=>754,8761=>754,8762=>754,8763=>754,8764=>754,8765=>754,8766=>754,8767=>754,8768=>337,8769=>754,
8770=>754,8771=>754,8772=>754,8773=>754,8774=>754,8775=>754,8776=>754,8777=>754,8778=>754,8779=>754,
8780=>754,8781=>754,8782=>754,8783=>754,8784=>754,8785=>754,8786=>754,8787=>754,8788=>900,8789=>900,
8790=>754,8791=>754,8792=>754,8793=>754,8794=>754,8795=>754,8796=>754,8797=>754,8798=>754,8799=>754,
8800=>754,8801=>754,8802=>754,8803=>754,8804=>754,8805=>754,8806=>754,8807=>754,8808=>754,8809=>754,
8810=>942,8811=>942,8812=>417,8813=>754,8814=>754,8815=>754,8816=>754,8817=>754,8818=>754,8819=>754,
8820=>754,8821=>754,8822=>754,8823=>754,8824=>754,8825=>754,8826=>754,8827=>754,8828=>754,8829=>754,
8830=>754,8831=>754,8832=>754,8833=>754,8834=>754,8835=>754,8836=>754,8837=>754,8838=>754,8839=>754,
8840=>754,8841=>754,8842=>754,8843=>754,8844=>659,8845=>659,8846=>659,8847=>754,8848=>754,8849=>754,
8850=>754,8851=>702,8852=>702,8853=>754,8854=>754,8855=>754,8856=>754,8857=>754,8858=>754,8859=>754,
8860=>754,8861=>754,8862=>754,8863=>754,8864=>754,8865=>754,8866=>784,8867=>784,8868=>784,8869=>784,
8870=>468,8871=>468,8872=>784,8873=>784,8874=>784,8875=>784,8876=>784,8877=>784,8878=>784,8879=>784,
8880=>754,8881=>754,8882=>754,8883=>754,8884=>754,8885=>754,8886=>900,8887=>900,8888=>754,8889=>754,
8890=>468,8891=>659,8892=>659,8893=>659,8894=>754,8895=>754,8896=>738,8897=>738,8898=>738,8899=>738,
8900=>444,8901=>286,8902=>563,8903=>754,8904=>900,8905=>900,8906=>900,8907=>900,8908=>900,8909=>754,
8910=>659,8911=>659,8912=>754,8913=>754,8914=>754,8915=>754,8916=>754,8917=>754,8918=>754,8919=>754,
8920=>1280,8921=>1280,8922=>754,8923=>754,8924=>754,8925=>754,8926=>754,8927=>754,8928=>754,8929=>754,
8930=>754,8931=>754,8932=>754,8933=>754,8934=>754,8935=>754,8936=>754,8937=>754,8938=>754,8939=>754,
8940=>754,8941=>754,8942=>900,8943=>900,8944=>900,8945=>900,8946=>900,8947=>784,8948=>646,8949=>784,
8950=>784,8951=>646,8952=>784,8953=>784,8954=>900,8955=>784,8956=>646,8957=>784,8958=>646,8959=>784,
8960=>542,8961=>542,8962=>571,8963=>754,8964=>754,8965=>754,8966=>754,8967=>439,8968=>351,8969=>351,
8970=>351,8971=>351,8972=>728,8973=>728,8974=>728,8975=>728,8976=>754,8977=>461,8984=>900,8985=>754,
8988=>422,8989=>422,8990=>422,8991=>422,8992=>469,8993=>469,8996=>1037,8997=>1037,8998=>1272,8999=>1037,
9000=>1299,9003=>1272,9004=>786,9075=>304,9076=>571,9077=>753,9082=>593,9085=>681,9095=>1037,9108=>786,
9115=>450,9116=>450,9117=>450,9118=>450,9119=>450,9120=>450,9121=>450,9122=>450,9123=>450,9124=>450,
9125=>450,9126=>450,9127=>675,9128=>675,9129=>675,9130=>675,9131=>675,9132=>675,9133=>675,9134=>469,
9166=>754,9167=>850,9187=>786,9189=>692,9250=>571,9251=>571,9312=>807,9313=>807,9314=>807,9315=>807,
9316=>807,9317=>807,9318=>807,9319=>807,9320=>807,9321=>807,9472=>542,9473=>542,9474=>542,9475=>542,
9476=>542,9477=>542,9478=>542,9479=>542,9480=>542,9481=>542,9482=>542,9483=>542,9484=>542,9485=>542,
9486=>542,9487=>542,9488=>542,9489=>542,9490=>542,9491=>542,9492=>542,9493=>542,9494=>542,9495=>542,
9496=>542,9497=>542,9498=>542,9499=>542,9500=>542,9501=>542,9502=>542,9503=>542,9504=>542,9505=>542,
9506=>542,9507=>542,9508=>542,9509=>542,9510=>542,9511=>542,9512=>542,9513=>542,9514=>542,9515=>542,
9516=>542,9517=>542,9518=>542,9519=>542,9520=>542,9521=>542,9522=>542,9523=>542,9524=>542,9525=>542,
9526=>542,9527=>542,9528=>542,9529=>542,9530=>542,9531=>542,9532=>542,9533=>542,9534=>542,9535=>542,
9536=>542,9537=>542,9538=>542,9539=>542,9540=>542,9541=>542,9542=>542,9543=>542,9544=>542,9545=>542,
9546=>542,9547=>542,9548=>542,9549=>542,9550=>542,9551=>542,9552=>542,9553=>542,9554=>542,9555=>542,
9556=>542,9557=>542,9558=>542,9559=>542,9560=>542,9561=>542,9562=>542,9563=>542,9564=>542,9565=>542,
9566=>542,9567=>542,9568=>542,9569=>542,9570=>542,9571=>542,9572=>542,9573=>542,9574=>542,9575=>542,
9576=>542,9577=>542,9578=>542,9579=>542,9580=>542,9581=>542,9582=>542,9583=>542,9584=>542,9585=>542,
9586=>542,9587=>542,9588=>542,9589=>542,9590=>542,9591=>542,9592=>542,9593=>542,9594=>542,9595=>542,
9596=>542,9597=>542,9598=>542,9599=>542,9600=>692,9601=>692,9602=>692,9603=>692,9604=>692,9605=>692,
9606=>692,9607=>692,9608=>692,9609=>692,9610=>692,9611=>692,9612=>692,9613=>692,9614=>692,9615=>692,
9616=>692,9617=>692,9618=>692,9619=>692,9620=>692,9621=>692,9622=>692,9623=>692,9624=>692,9625=>692,
9626=>692,9627=>692,9628=>692,9629=>692,9630=>692,9631=>692,9632=>850,9633=>850,9634=>850,9635=>850,
9636=>850,9637=>850,9638=>850,9639=>850,9640=>850,9641=>850,9642=>610,9643=>610,9644=>850,9645=>850,
9646=>495,9647=>495,9648=>692,9649=>692,9650=>692,9651=>692,9652=>452,9653=>452,9654=>692,9655=>692,
9656=>452,9657=>452,9658=>692,9659=>692,9660=>692,9661=>692,9662=>452,9663=>452,9664=>692,9665=>692,
9666=>452,9667=>452,9668=>692,9669=>692,9670=>692,9671=>692,9672=>692,9673=>785,9674=>444,9675=>785,
9676=>785,9677=>785,9678=>785,9679=>785,9680=>785,9681=>785,9682=>785,9683=>785,9684=>785,9685=>785,
9686=>474,9687=>474,9688=>712,9689=>873,9690=>873,9691=>873,9692=>348,9693=>348,9694=>348,9695=>348,
9696=>692,9697=>692,9698=>692,9699=>692,9700=>692,9701=>692,9702=>531,9703=>850,9704=>850,9705=>850,
9706=>850,9707=>850,9708=>692,9709=>692,9710=>692,9711=>1007,9712=>850,9713=>850,9714=>850,9715=>850,
9716=>785,9717=>785,9718=>785,9719=>785,9720=>692,9721=>692,9722=>692,9723=>747,9724=>747,9725=>659,
9726=>659,9727=>692,9728=>807,9729=>900,9730=>807,9731=>807,9732=>807,9733=>807,9734=>807,9735=>515,
9736=>806,9737=>807,9738=>799,9739=>799,9740=>604,9741=>911,9742=>1121,9743=>1125,9744=>807,9745=>807,
9746=>807,9747=>479,9748=>807,9749=>807,9750=>807,9751=>807,9752=>807,9753=>807,9754=>807,9755=>807,
9756=>807,9757=>548,9758=>807,9759=>548,9760=>807,9761=>807,9762=>807,9763=>807,9764=>602,9765=>671,
9766=>584,9767=>705,9768=>490,9769=>807,9770=>807,9771=>807,9772=>639,9773=>807,9774=>807,9775=>807,
9776=>800,9777=>800,9778=>800,9779=>800,9780=>800,9781=>800,9782=>800,9783=>800,9784=>807,9785=>807,
9786=>807,9787=>807,9788=>807,9789=>807,9790=>807,9791=>552,9792=>658,9793=>658,9794=>807,9795=>807,
9796=>807,9797=>807,9798=>807,9799=>807,9800=>807,9801=>807,9802=>807,9803=>807,9804=>807,9805=>807,
9806=>807,9807=>807,9808=>807,9809=>807,9810=>807,9811=>807,9812=>807,9813=>807,9814=>807,9815=>807,
9816=>807,9817=>807,9818=>807,9819=>807,9820=>807,9821=>807,9822=>807,9823=>807,9824=>807,9825=>807,
9826=>807,9827=>807,9828=>807,9829=>807,9830=>807,9831=>807,9832=>807,9833=>424,9834=>574,9835=>807,
9836=>807,9837=>424,9838=>321,9839=>435,9840=>673,9841=>689,9842=>807,9843=>807,9844=>807,9845=>807,
9846=>807,9847=>807,9848=>807,9849=>807,9850=>807,9851=>807,9852=>807,9853=>807,9854=>807,9855=>807,
9856=>782,9857=>782,9858=>782,9859=>782,9860=>782,9861=>782,9862=>800,9863=>800,9864=>800,9865=>800,
9866=>800,9867=>800,9868=>800,9869=>800,9870=>800,9871=>800,9872=>675,9873=>675,9874=>800,9875=>734,
9876=>644,9877=>483,9878=>766,9879=>800,9880=>615,9881=>800,9882=>637,9883=>800,9884=>800,9888=>800,
9889=>632,9890=>903,9891=>977,9892=>1028,9893=>811,9894=>754,9895=>754,9896=>754,9897=>754,9898=>754,
9899=>754,9900=>754,9901=>754,9902=>754,9903=>754,9904=>759,9905=>754,9906=>658,9907=>659,9908=>659,
9909=>659,9910=>765,9911=>659,9912=>659,9985=>754,9986=>754,9987=>754,9988=>754,9990=>754,9991=>754,
9992=>754,9993=>754,9996=>754,9997=>754,9998=>754,9999=>754,10000=>754,10001=>754,10002=>754,10003=>754,
10004=>754,10005=>754,10006=>754,10007=>754,10008=>754,10009=>754,10010=>754,10011=>754,10012=>754,10013=>754,
10014=>754,10015=>754,10016=>754,10017=>754,10018=>754,10019=>754,10020=>754,10021=>754,10022=>754,10023=>754,
10025=>754,10026=>754,10027=>754,10028=>754,10029=>754,10030=>754,10031=>754,10032=>754,10033=>754,10034=>754,
10035=>754,10036=>754,10037=>754,10038=>754,10039=>754,10040=>754,10041=>754,10042=>754,10043=>754,10044=>754,
10045=>754,10046=>754,10047=>754,10048=>754,10049=>754,10050=>754,10051=>754,10052=>754,10053=>754,10054=>754,
10055=>754,10056=>754,10057=>754,10058=>754,10059=>754,10061=>807,10063=>807,10064=>807,10065=>807,10066=>807,
10070=>807,10072=>754,10073=>754,10074=>754,10075=>290,10076=>290,10077=>484,10078=>484,10081=>754,10082=>754,
10083=>754,10084=>754,10085=>754,10086=>754,10087=>754,10088=>754,10089=>754,10090=>754,10091=>754,10092=>754,
10093=>754,10094=>754,10095=>754,10096=>754,10097=>754,10098=>754,10099=>754,10100=>754,10101=>754,10102=>807,
10103=>807,10104=>807,10105=>807,10106=>807,10107=>807,10108=>807,10109=>807,10110=>807,10111=>807,10112=>754,
10113=>754,10114=>754,10115=>754,10116=>754,10117=>754,10118=>754,10119=>754,10120=>754,10121=>754,10122=>754,
10123=>754,10124=>754,10125=>754,10126=>754,10127=>754,10128=>754,10129=>754,10130=>754,10131=>754,10132=>754,
10136=>754,10137=>754,10138=>754,10139=>754,10140=>754,10141=>754,10142=>754,10143=>754,10144=>754,10145=>754,
10146=>754,10147=>754,10148=>754,10149=>754,10150=>754,10151=>754,10152=>754,10153=>754,10154=>754,10155=>754,
10156=>754,10157=>754,10158=>754,10159=>754,10161=>754,10162=>754,10163=>754,10164=>754,10165=>754,10166=>754,
10167=>754,10168=>754,10169=>754,10170=>754,10171=>754,10172=>754,10173=>754,10174=>754,10181=>351,10182=>351,
10208=>444,10214=>445,10215=>445,10216=>351,10217=>351,10218=>500,10219=>500,10224=>754,10225=>754,10226=>754,
10227=>754,10228=>1042,10229=>1290,10230=>1290,10231=>1290,10232=>1290,10233=>1290,10234=>1290,10235=>1290,10236=>1290,
10237=>1290,10238=>1290,10239=>1290,10240=>659,10241=>659,10242=>659,10243=>659,10244=>659,10245=>659,10246=>659,
10247=>659,10248=>659,10249=>659,10250=>659,10251=>659,10252=>659,10253=>659,10254=>659,10255=>659,10256=>659,
10257=>659,10258=>659,10259=>659,10260=>659,10261=>659,10262=>659,10263=>659,10264=>659,10265=>659,10266=>659,
10267=>659,10268=>659,10269=>659,10270=>659,10271=>659,10272=>659,10273=>659,10274=>659,10275=>659,10276=>659,
10277=>659,10278=>659,10279=>659,10280=>659,10281=>659,10282=>659,10283=>659,10284=>659,10285=>659,10286=>659,
10287=>659,10288=>659,10289=>659,10290=>659,10291=>659,10292=>659,10293=>659,10294=>659,10295=>659,10296=>659,
10297=>659,10298=>659,10299=>659,10300=>659,10301=>659,10302=>659,10303=>659,10304=>659,10305=>659,10306=>659,
10307=>659,10308=>659,10309=>659,10310=>659,10311=>659,10312=>659,10313=>659,10314=>659,10315=>659,10316=>659,
10317=>659,10318=>659,10319=>659,10320=>659,10321=>659,10322=>659,10323=>659,10324=>659,10325=>659,10326=>659,
10327=>659,10328=>659,10329=>659,10330=>659,10331=>659,10332=>659,10333=>659,10334=>659,10335=>659,10336=>659,
10337=>659,10338=>659,10339=>659,10340=>659,10341=>659,10342=>659,10343=>659,10344=>659,10345=>659,10346=>659,
10347=>659,10348=>659,10349=>659,10350=>659,10351=>659,10352=>659,10353=>659,10354=>659,10355=>659,10356=>659,
10357=>659,10358=>659,10359=>659,10360=>659,10361=>659,10362=>659,10363=>659,10364=>659,10365=>659,10366=>659,
10367=>659,10368=>659,10369=>659,10370=>659,10371=>659,10372=>659,10373=>659,10374=>659,10375=>659,10376=>659,
10377=>659,10378=>659,10379=>659,10380=>659,10381=>659,10382=>659,10383=>659,10384=>659,10385=>659,10386=>659,
10387=>659,10388=>659,10389=>659,10390=>659,10391=>659,10392=>659,10393=>659,10394=>659,10395=>659,10396=>659,
10397=>659,10398=>659,10399=>659,10400=>659,10401=>659,10402=>659,10403=>659,10404=>659,10405=>659,10406=>659,
10407=>659,10408=>659,10409=>659,10410=>659,10411=>659,10412=>659,10413=>659,10414=>659,10415=>659,10416=>659,
10417=>659,10418=>659,10419=>659,10420=>659,10421=>659,10422=>659,10423=>659,10424=>659,10425=>659,10426=>659,
10427=>659,10428=>659,10429=>659,10430=>659,10431=>659,10432=>659,10433=>659,10434=>659,10435=>659,10436=>659,
10437=>659,10438=>659,10439=>659,10440=>659,10441=>659,10442=>659,10443=>659,10444=>659,10445=>659,10446=>659,
10447=>659,10448=>659,10449=>659,10450=>659,10451=>659,10452=>659,10453=>659,10454=>659,10455=>659,10456=>659,
10457=>659,10458=>659,10459=>659,10460=>659,10461=>659,10462=>659,10463=>659,10464=>659,10465=>659,10466=>659,
10467=>659,10468=>659,10469=>659,10470=>659,10471=>659,10472=>659,10473=>659,10474=>659,10475=>659,10476=>659,
10477=>659,10478=>659,10479=>659,10480=>659,10481=>659,10482=>659,10483=>659,10484=>659,10485=>659,10486=>659,
10487=>659,10488=>659,10489=>659,10490=>659,10491=>659,10492=>659,10493=>659,10494=>659,10495=>659,10502=>754,
10503=>754,10506=>754,10507=>754,10560=>615,10561=>615,10627=>660,10628=>660,10702=>754,10703=>900,10704=>900,
10705=>900,10706=>900,10707=>900,10708=>900,10709=>900,10731=>444,10746=>754,10747=>754,10752=>900,10753=>900,
10754=>900,10764=>1192,10765=>469,10766=>469,10767=>469,10768=>469,10769=>469,10770=>469,10771=>469,10772=>469,
10773=>469,10774=>469,10775=>469,10776=>469,10777=>469,10778=>469,10779=>469,10780=>469,10799=>754,10877=>754,
10878=>754,10879=>754,10880=>754,10881=>754,10882=>754,10883=>754,10884=>754,10885=>754,10886=>754,10887=>754,
10888=>754,10889=>754,10890=>754,10891=>754,10892=>754,10893=>754,10894=>754,10895=>754,10896=>754,10897=>754,
10898=>754,10899=>754,10900=>754,10901=>754,10902=>754,10903=>754,10904=>754,10905=>754,10906=>754,10907=>754,
10908=>754,10909=>754,10910=>754,10911=>754,10912=>754,10926=>754,10927=>754,10928=>754,10929=>754,10930=>754,
10931=>754,10932=>754,10933=>754,10934=>754,10935=>754,10936=>754,10937=>754,10938=>754,11001=>754,11002=>754,
11008=>754,11009=>754,11010=>754,11011=>754,11012=>754,11013=>754,11014=>754,11015=>754,11016=>754,11017=>754,
11018=>754,11019=>754,11020=>754,11021=>754,11022=>752,11023=>752,11024=>752,11025=>752,11026=>850,11027=>850,
11028=>850,11029=>850,11030=>692,11031=>692,11032=>692,11033=>692,11034=>850,11039=>782,11040=>782,11041=>786,
11042=>786,11043=>786,11044=>1007,11091=>782,11092=>782,11360=>501,11361=>250,11362=>501,11363=>542,11364=>625,
11365=>551,11366=>353,11367=>677,11368=>570,11369=>590,11370=>521,11371=>616,11372=>472,11373=>703,11374=>776,
11375=>615,11377=>661,11378=>1015,11379=>865,11380=>532,11381=>589,11382=>511,11383=>593,11385=>373,11386=>550,
11387=>441,11388=>157,11389=>387,11800=>478,11810=>351,11811=>351,11812=>351,11813=>351,11822=>478,19904=>807,
19905=>807,19906=>807,19907=>807,19908=>807,19909=>807,19910=>807,19911=>807,19912=>807,19913=>807,19914=>807,
19915=>807,19916=>807,19917=>807,19918=>807,19919=>807,19920=>807,19921=>807,19922=>807,19923=>807,19924=>807,
19925=>807,19926=>807,19927=>807,19928=>807,19929=>807,19930=>807,19931=>807,19932=>807,19933=>807,19934=>807,
19935=>807,19936=>807,19937=>807,19938=>807,19939=>807,19940=>807,19941=>807,19942=>807,19943=>807,19944=>807,
19945=>807,19946=>807,19947=>807,19948=>807,19949=>807,19950=>807,19951=>807,19952=>807,19953=>807,19954=>807,
19955=>807,19956=>807,19957=>807,19958=>807,19959=>807,19960=>807,19961=>807,19962=>807,19963=>807,19964=>807,
19965=>807,19966=>807,19967=>807,42564=>571,42565=>469,42566=>318,42567=>304,42572=>1062,42573=>925,42576=>926,
42577=>815,42580=>971,42581=>757,42582=>886,42583=>762,42594=>922,42595=>833,42596=>912,42597=>810,42598=>776,
42599=>907,42600=>708,42601=>550,42602=>770,42603=>641,42604=>1222,42605=>917,42606=>791,42634=>725,42635=>649,
42636=>549,42637=>524,42644=>617,42645=>570,42760=>444,42761=>444,42762=>444,42763=>444,42764=>444,42765=>444,
42766=>444,42767=>444,42768=>444,42769=>444,42770=>444,42771=>444,42772=>444,42773=>444,42774=>444,42779=>332,
42780=>332,42781=>227,42782=>227,42783=>227,42790=>677,42791=>570,42792=>790,42793=>638,42794=>553,42795=>486,
42800=>441,42801=>469,42802=>1125,42803=>886,42804=>1097,42805=>900,42806=>1039,42807=>896,42808=>874,42809=>736,
42810=>874,42811=>736,42812=>863,42813=>736,42814=>628,42815=>494,42822=>612,42823=>353,42824=>523,42825=>384,
42826=>726,42827=>633,42830=>1222,42831=>917,42880=>501,42881=>250,42882=>662,42883=>570,42889=>303,42890=>338,
42891=>360,42892=>247,43003=>518,43004=>542,43005=>776,43006=>265,43007=>1079,63173=>550,64256=>649,64257=>581,
64258=>581,64259=>899,64260=>899,64261=>617,64262=>774,64275=>1081,64276=>1081,64277=>1076,64278=>1067,64279=>1376,
64285=>245,64286=>0,64287=>423,64288=>572,64289=>770,64290=>696,64291=>815,64292=>694,64293=>759,64294=>769,
64295=>726,64296=>788,64297=>754,64298=>727,64299=>727,64300=>727,64301=>727,64302=>566,64303=>566,64304=>566,
64305=>547,64306=>403,64307=>534,64308=>576,64309=>245,64310=>336,64311=>900,64312=>583,64313=>302,64314=>532,
64315=>500,64316=>539,64318=>593,64320=>397,64321=>629,64323=>576,64324=>543,64326=>523,64327=>596,64328=>532,
64329=>727,64330=>591,64331=>245,64332=>547,64333=>500,64334=>543,64335=>566,65024=>0,65025=>0,65026=>0,
65027=>0,65028=>0,65029=>0,65030=>0,65031=>0,65032=>0,65033=>0,65034=>0,65035=>0,65036=>0,
65037=>0,65038=>0,65039=>0,65056=>0,65057=>0,65058=>0,65059=>0,65529=>0,65530=>0,65531=>0,
65532=>0,65533=>923);
$enc='';
$diff='';
$file='dejavusanscondensedi.z';
$ctg='dejavusanscondensedi.ctg.z';
$originalsize=488440;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/dejavusanscondensedi.php | PHP | asf20 | 46,054 |
<?php
$type='TrueTypeUnicode';
$name='DejaVuSerif-Bold';
$desc=array('Ascent'=>939,'Descent'=>-236,'CapHeight'=>5,'Flags'=>32,'FontBBox'=>'[-836 -389 1796 1235]','ItalicAngle'=>0,'StemV'=>120,'MissingWidth'=>600);
$up=-63;
$ut=44;
$dw=600;
$cw=array(
0=>600,32=>348,33=>439,34=>521,35=>838,36=>696,37=>950,38=>903,39=>306,40=>473,
41=>473,42=>523,43=>838,44=>348,45=>415,46=>348,47=>365,48=>696,49=>696,50=>696,
51=>696,52=>696,53=>696,54=>696,55=>696,56=>696,57=>696,58=>369,59=>369,60=>838,
61=>838,62=>838,63=>586,64=>1000,65=>776,66=>845,67=>796,68=>867,69=>762,70=>710,
71=>854,72=>945,73=>468,74=>473,75=>869,76=>703,77=>1107,78=>914,79=>871,80=>752,
81=>871,82=>831,83=>722,84=>744,85=>872,86=>776,87=>1123,88=>776,89=>714,90=>730,
91=>473,92=>365,93=>473,94=>838,95=>500,96=>500,97=>648,98=>699,99=>609,100=>699,
101=>636,102=>430,103=>699,104=>727,105=>380,106=>362,107=>693,108=>380,109=>1058,110=>727,
111=>667,112=>699,113=>699,114=>527,115=>563,116=>462,117=>727,118=>581,119=>861,120=>596,
121=>581,122=>568,123=>643,124=>364,125=>643,126=>838,8364=>696,8218=>348,402=>430,8222=>575,
8230=>1000,8224=>523,8225=>523,710=>500,8240=>1385,352=>722,8249=>400,338=>1180,381=>730,8216=>348,
8217=>348,8220=>575,8221=>575,8226=>639,8211=>500,8212=>1000,732=>500,8482=>1000,353=>563,8250=>400,
339=>1028,382=>568,376=>714,160=>348,161=>439,162=>696,163=>696,164=>636,165=>696,166=>364,
167=>523,168=>500,169=>1000,170=>487,171=>625,172=>838,173=>415,174=>1000,175=>500,176=>500,
177=>838,178=>438,179=>438,180=>500,181=>732,182=>636,183=>348,184=>500,185=>438,186=>500,
187=>625,188=>1043,189=>1043,190=>1043,191=>586,192=>776,193=>776,194=>776,195=>776,196=>776,
197=>776,198=>1034,199=>796,200=>762,201=>762,202=>762,203=>762,204=>468,205=>468,206=>468,
207=>468,208=>874,209=>914,210=>871,211=>871,212=>871,213=>871,214=>871,215=>838,216=>871,
217=>872,218=>872,219=>872,220=>872,221=>714,222=>757,223=>760,224=>648,225=>648,226=>648,
227=>648,228=>648,229=>648,230=>975,231=>609,232=>636,233=>636,234=>636,235=>636,236=>380,
237=>380,238=>380,239=>380,240=>667,241=>727,242=>667,243=>667,244=>667,245=>667,246=>667,
247=>838,248=>667,249=>727,250=>727,251=>727,252=>727,253=>581,254=>699,255=>581,256=>776,
257=>648,258=>776,259=>648,260=>776,261=>648,262=>796,263=>609,264=>796,265=>609,266=>796,
267=>609,268=>796,269=>609,270=>867,271=>699,272=>874,273=>699,274=>762,275=>636,276=>762,
277=>636,278=>762,279=>636,280=>762,281=>636,282=>762,283=>636,284=>854,285=>699,286=>854,
287=>699,288=>854,289=>699,290=>854,291=>699,292=>945,293=>727,294=>945,295=>727,296=>468,
297=>380,298=>468,299=>380,300=>468,301=>380,302=>468,303=>380,304=>468,305=>380,306=>942,
307=>751,308=>473,309=>362,310=>869,311=>693,312=>693,313=>703,314=>380,315=>703,316=>380,
317=>703,318=>380,319=>703,320=>380,321=>710,322=>385,323=>914,324=>727,325=>914,326=>727,
327=>914,328=>727,329=>1008,330=>872,331=>727,332=>871,333=>667,334=>871,335=>667,336=>871,
337=>667,340=>831,341=>527,342=>831,343=>527,344=>831,345=>527,346=>722,347=>563,348=>722,
349=>563,350=>722,351=>563,354=>744,355=>462,356=>744,357=>462,358=>744,359=>462,360=>872,
361=>727,362=>872,363=>727,364=>872,365=>727,366=>872,367=>727,368=>872,369=>727,370=>872,
371=>727,372=>1123,373=>861,374=>714,375=>581,377=>730,378=>568,379=>730,380=>568,383=>430,
384=>699,385=>845,386=>854,387=>699,388=>854,389=>699,390=>796,391=>796,392=>609,393=>874,
394=>867,395=>854,396=>699,397=>667,398=>762,399=>871,400=>721,401=>710,403=>854,404=>771,
405=>1043,406=>468,407=>468,408=>869,409=>693,410=>380,411=>701,412=>1058,413=>914,414=>727,
415=>871,416=>871,417=>667,418=>1200,419=>943,420=>752,421=>699,422=>831,423=>722,424=>563,
425=>707,426=>331,427=>462,428=>744,429=>462,430=>744,431=>872,432=>727,433=>890,434=>890,
435=>714,436=>708,437=>730,438=>568,439=>657,440=>657,441=>657,443=>696,444=>754,445=>568,
446=>536,448=>295,449=>492,450=>459,451=>295,452=>1597,453=>1435,454=>1267,455=>1176,456=>1065,
457=>742,458=>1387,459=>1276,460=>1089,461=>776,462=>648,463=>468,464=>380,465=>871,466=>667,
467=>872,468=>727,469=>872,470=>727,471=>872,472=>727,473=>872,474=>727,475=>872,476=>727,
477=>636,478=>776,479=>648,480=>776,481=>648,482=>1034,483=>975,484=>896,485=>699,486=>854,
487=>699,488=>869,489=>693,490=>871,491=>667,492=>871,493=>667,494=>657,495=>568,496=>380,
497=>1597,498=>1435,499=>1267,500=>854,501=>699,502=>1221,504=>914,505=>727,506=>776,507=>648,
508=>1034,509=>975,510=>871,511=>667,512=>776,513=>648,514=>776,515=>648,516=>762,517=>636,
518=>762,519=>636,520=>468,521=>380,522=>468,523=>380,524=>871,525=>667,526=>871,527=>667,
528=>831,529=>527,530=>831,531=>527,532=>872,533=>727,534=>872,535=>727,536=>722,537=>563,
538=>744,539=>462,540=>690,541=>607,542=>945,543=>727,544=>872,545=>791,548=>730,549=>568,
550=>776,551=>648,552=>762,553=>636,554=>871,555=>667,556=>871,557=>667,558=>871,559=>667,
560=>871,561=>667,562=>714,563=>581,564=>573,565=>922,566=>564,567=>362,568=>1031,569=>1031,
570=>776,571=>796,572=>609,573=>703,574=>744,575=>563,576=>568,577=>660,578=>547,581=>776,
592=>648,593=>699,594=>699,595=>699,596=>609,597=>609,598=>699,599=>730,600=>636,601=>636,
602=>907,603=>608,604=>562,605=>907,606=>720,607=>387,608=>699,609=>699,610=>626,611=>712,
612=>627,613=>727,614=>727,615=>727,616=>380,617=>380,618=>380,619=>409,620=>514,621=>380,
622=>795,623=>1058,624=>1058,625=>1058,626=>727,627=>727,628=>712,629=>667,630=>1061,631=>749,
632=>667,633=>571,634=>571,635=>571,636=>527,637=>527,638=>452,639=>487,640=>801,641=>801,
642=>563,643=>331,644=>430,645=>540,646=>331,647=>492,648=>462,649=>727,650=>679,651=>694,
652=>641,653=>907,654=>635,655=>727,656=>568,657=>568,658=>568,659=>568,660=>536,661=>536,
662=>536,663=>545,664=>871,665=>695,666=>720,667=>626,668=>732,669=>384,670=>740,671=>646,
672=>699,673=>536,674=>536,675=>1117,676=>1179,677=>1117,678=>911,679=>715,680=>909,681=>1039,
682=>790,683=>795,684=>662,685=>443,686=>613,687=>717,688=>521,689=>519,690=>313,691=>414,
692=>414,693=>480,694=>527,695=>662,696=>485,697=>302,699=>348,700=>348,701=>348,702=>366,
703=>366,704=>313,705=>313,711=>500,712=>282,713=>500,716=>282,720=>369,721=>369,722=>366,
723=>366,726=>392,728=>500,729=>500,730=>500,731=>500,733=>500,734=>417,736=>458,737=>292,
738=>395,739=>475,740=>313,741=>500,742=>500,743=>500,744=>500,745=>500,750=>553,768=>0,
769=>0,770=>0,771=>0,772=>0,773=>0,774=>0,775=>0,776=>0,777=>0,778=>0,
779=>0,780=>0,781=>0,782=>0,783=>0,784=>0,785=>0,786=>0,787=>0,788=>0,
789=>0,790=>0,791=>0,792=>0,793=>0,794=>0,795=>0,796=>0,797=>0,798=>0,
799=>0,800=>0,801=>0,802=>0,803=>0,804=>0,805=>0,806=>0,807=>0,808=>0,
809=>0,810=>0,811=>0,812=>0,813=>0,814=>0,815=>0,816=>0,817=>0,818=>0,
819=>0,820=>0,821=>0,822=>0,823=>0,824=>0,825=>0,826=>0,827=>0,828=>0,
829=>0,830=>0,831=>0,835=>0,847=>0,856=>0,865=>0,880=>779,881=>576,884=>302,
885=>302,890=>500,891=>609,892=>609,893=>609,894=>369,900=>500,901=>500,902=>776,903=>348,
904=>947,905=>1118,906=>662,908=>887,910=>953,911=>911,912=>484,913=>776,914=>845,915=>710,
916=>776,917=>762,918=>730,919=>945,920=>871,921=>468,922=>869,923=>776,924=>1107,925=>914,
926=>704,927=>871,928=>944,929=>752,931=>707,932=>744,933=>714,934=>871,935=>776,936=>913,
937=>890,938=>468,939=>714,940=>770,941=>608,942=>727,943=>484,944=>694,945=>770,946=>664,
947=>660,948=>667,949=>608,950=>592,951=>727,952=>667,953=>484,954=>750,955=>701,956=>732,
957=>694,958=>592,959=>667,960=>732,961=>665,962=>609,963=>737,964=>673,965=>694,966=>905,
967=>658,968=>941,969=>952,970=>484,971=>694,972=>667,973=>694,974=>952,976=>667,977=>849,
978=>764,979=>969,980=>764,981=>941,982=>952,983=>655,984=>871,985=>667,986=>796,987=>609,
988=>710,989=>527,990=>590,991=>660,992=>796,993=>667,1008=>655,1009=>665,1010=>609,1011=>362,
1012=>871,1013=>609,1014=>609,1015=>757,1016=>699,1017=>796,1018=>1107,1019=>860,1020=>692,1021=>796,
1022=>796,1023=>796,1024=>762,1025=>762,1026=>901,1027=>690,1028=>795,1029=>722,1030=>468,1031=>468,
1032=>473,1033=>1202,1034=>1262,1035=>963,1036=>910,1037=>945,1038=>812,1039=>945,1040=>814,1041=>854,
1042=>845,1043=>690,1044=>889,1045=>762,1046=>1312,1047=>721,1048=>945,1049=>945,1050=>910,1051=>884,
1052=>1107,1053=>945,1054=>871,1055=>944,1056=>752,1057=>796,1058=>744,1059=>812,1060=>949,1061=>776,
1062=>966,1063=>913,1064=>1268,1065=>1293,1066=>957,1067=>1202,1068=>825,1069=>795,1070=>1287,1071=>882,
1072=>648,1073=>667,1074=>695,1075=>613,1076=>667,1077=>636,1078=>1010,1079=>638,1080=>742,1081=>742,
1082=>722,1083=>705,1084=>869,1085=>732,1086=>667,1087=>732,1088=>699,1089=>609,1090=>620,1091=>640,
1092=>902,1093=>596,1094=>739,1095=>732,1096=>1075,1097=>1082,1098=>767,1099=>1002,1100=>679,1101=>609,
1102=>1025,1103=>739,1104=>636,1105=>636,1106=>719,1107=>613,1108=>609,1109=>563,1110=>380,1111=>380,
1112=>362,1113=>988,1114=>1015,1115=>727,1116=>722,1117=>742,1118=>640,1119=>732,1122=>880,1123=>703,
1124=>1195,1125=>963,1130=>1312,1131=>1010,1136=>1096,1137=>1105,1138=>871,1139=>652,1140=>916,1141=>749,
1164=>846,1165=>673,1168=>700,1169=>618,1170=>690,1171=>613,1172=>868,1173=>716,1174=>1312,1175=>1010,
1176=>721,1177=>638,1178=>947,1179=>744,1182=>910,1183=>722,1184=>1041,1185=>827,1186=>966,1187=>739,
1188=>1167,1189=>956,1190=>1345,1191=>1059,1194=>796,1195=>609,1196=>744,1197=>620,1198=>714,1199=>581,
1200=>714,1201=>581,1202=>866,1203=>649,1204=>1022,1205=>807,1206=>928,1207=>739,1210=>910,1211=>727,
1216=>468,1217=>1312,1218=>1010,1219=>869,1220=>693,1223=>945,1224=>732,1227=>913,1228=>732,1231=>380,
1232=>814,1233=>648,1234=>814,1235=>648,1236=>1034,1237=>975,1238=>762,1239=>636,1240=>871,1241=>636,
1242=>871,1243=>636,1244=>1312,1245=>1010,1246=>721,1247=>638,1248=>657,1249=>568,1250=>945,1251=>742,
1252=>945,1253=>742,1254=>871,1255=>667,1256=>871,1257=>667,1258=>871,1259=>667,1260=>795,1261=>609,
1262=>812,1263=>640,1264=>812,1265=>640,1266=>812,1267=>640,1268=>913,1269=>732,1270=>690,1271=>613,
1272=>1202,1273=>1002,1296=>721,1297=>638,1298=>884,1299=>705,1300=>1248,1301=>945,1306=>820,1307=>640,
1308=>1028,1309=>856,4256=>755,4257=>936,4258=>866,4259=>874,4260=>781,4261=>1078,4262=>1014,4263=>1213,
4264=>643,4265=>818,4266=>1051,4267=>1051,4268=>796,4269=>1135,4270=>969,4271=>902,4272=>1109,4273=>792,
4274=>756,4275=>1076,4276=>976,4277=>1066,4278=>811,4279=>833,4280=>821,4281=>833,4282=>908,4283=>1077,
4284=>769,4285=>822,4286=>813,4287=>1111,4288=>1123,4289=>802,4290=>892,4291=>802,4292=>880,4293=>1063,
4304=>594,4305=>625,4306=>643,4307=>887,4308=>615,4309=>611,4310=>667,4311=>915,4312=>613,4313=>600,
4314=>1120,4315=>640,4316=>640,4317=>879,4318=>624,4319=>634,4320=>877,4321=>666,4322=>780,4323=>751,
4324=>869,4325=>639,4326=>912,4327=>622,4328=>647,4329=>640,4330=>729,4331=>641,4332=>630,4333=>629,
4334=>670,4335=>753,4336=>625,4337=>657,4338=>625,4339=>625,4340=>624,4341=>670,4342=>940,4343=>680,
4344=>636,4345=>672,4346=>625,4347=>588,4348=>354,7426=>940,7432=>509,7433=>320,7444=>989,7446=>667,
7447=>667,7453=>737,7454=>948,7455=>948,7468=>489,7469=>651,7470=>532,7472=>546,7473=>480,7474=>480,
7475=>538,7476=>595,7477=>294,7478=>298,7479=>547,7480=>443,7481=>697,7482=>576,7483=>576,7484=>548,
7486=>474,7487=>523,7488=>455,7489=>469,7490=>549,7491=>466,7492=>466,7493=>498,7494=>657,7495=>499,
7496=>498,7497=>444,7498=>444,7499=>412,7500=>412,7501=>498,7502=>300,7503=>523,7504=>729,7505=>473,
7506=>467,7507=>427,7508=>467,7509=>467,7510=>499,7511=>371,7512=>520,7513=>434,7514=>729,7515=>491,
7522=>239,7523=>414,7524=>520,7525=>491,7543=>640,7544=>595,7547=>380,7557=>380,7579=>498,7580=>427,
7581=>427,7582=>467,7583=>412,7584=>383,7585=>373,7586=>498,7587=>522,7588=>300,7589=>307,7590=>300,
7591=>300,7592=>370,7593=>368,7594=>321,7595=>430,7596=>682,7597=>729,7598=>588,7599=>587,7600=>472,
7601=>467,7602=>522,7603=>400,7604=>387,7605=>371,7606=>520,7607=>475,7609=>489,7610=>491,7611=>412,
7612=>527,7613=>412,7614=>452,7615=>467,7620=>0,7621=>0,7622=>0,7623=>0,7624=>0,7625=>0,
7680=>776,7681=>648,7682=>845,7683=>699,7684=>845,7685=>699,7686=>845,7687=>699,7688=>796,7689=>609,
7690=>867,7691=>699,7692=>867,7693=>699,7694=>867,7695=>699,7696=>867,7697=>699,7698=>867,7699=>699,
7700=>762,7701=>636,7702=>762,7703=>636,7704=>762,7705=>636,7706=>762,7707=>636,7708=>762,7709=>636,
7710=>710,7711=>430,7712=>854,7713=>699,7714=>945,7715=>727,7716=>945,7717=>727,7718=>945,7719=>727,
7720=>945,7721=>727,7722=>945,7723=>727,7724=>468,7725=>380,7728=>869,7729=>693,7730=>869,7731=>693,
7732=>869,7733=>693,7734=>703,7735=>380,7736=>703,7737=>380,7738=>703,7739=>380,7740=>703,7741=>380,
7742=>1107,7743=>1058,7744=>1107,7745=>1058,7746=>1107,7747=>1058,7748=>914,7749=>727,7750=>914,7751=>727,
7752=>914,7753=>727,7754=>914,7755=>727,7756=>871,7757=>667,7760=>871,7761=>667,7762=>871,7763=>667,
7764=>752,7765=>699,7766=>752,7767=>699,7768=>831,7769=>527,7770=>831,7771=>527,7772=>831,7773=>527,
7774=>831,7775=>527,7776=>722,7777=>563,7778=>722,7779=>563,7784=>722,7785=>563,7786=>744,7787=>462,
7788=>744,7789=>462,7790=>744,7791=>462,7792=>744,7793=>462,7794=>872,7795=>727,7796=>872,7797=>727,
7798=>872,7799=>727,7800=>872,7801=>727,7802=>872,7803=>727,7804=>776,7805=>581,7806=>776,7807=>581,
7808=>1123,7809=>861,7810=>1123,7811=>861,7812=>1123,7813=>861,7814=>1123,7815=>861,7816=>1123,7817=>861,
7818=>776,7819=>596,7820=>776,7821=>596,7822=>714,7823=>581,7824=>730,7825=>568,7826=>730,7827=>568,
7828=>730,7829=>568,7830=>727,7831=>462,7832=>861,7833=>581,7834=>1014,7835=>430,7838=>947,7839=>667,
7840=>776,7841=>648,7842=>776,7843=>648,7852=>776,7853=>648,7854=>776,7855=>648,7856=>776,7857=>648,
7858=>776,7859=>648,7860=>776,7861=>648,7862=>776,7863=>648,7864=>762,7865=>636,7866=>762,7867=>636,
7868=>762,7869=>636,7878=>762,7879=>636,7880=>468,7881=>380,7882=>468,7883=>380,7884=>871,7885=>667,
7886=>871,7887=>667,7896=>871,7897=>667,7908=>872,7909=>727,7910=>872,7911=>727,7922=>714,7923=>581,
7924=>714,7925=>581,7926=>714,7927=>581,7928=>714,7929=>581,7936=>770,7937=>770,7938=>770,7939=>770,
7940=>770,7941=>770,7942=>770,7943=>770,7944=>776,7945=>776,7946=>978,7947=>978,7948=>832,7949=>849,
7950=>776,7951=>776,7952=>608,7953=>608,7954=>608,7955=>608,7956=>608,7957=>608,7960=>917,7961=>909,
7962=>1169,7963=>1169,7964=>1093,7965=>1120,7968=>727,7969=>727,7970=>727,7971=>727,7972=>727,7973=>727,
7974=>727,7975=>727,7976=>1100,7977=>1094,7978=>1358,7979=>1361,7980=>1279,7981=>1308,7982=>1197,7983=>1194,
7984=>484,7985=>484,7986=>484,7987=>484,7988=>484,7989=>484,7990=>484,7991=>484,7992=>629,7993=>617,
7994=>878,7995=>881,7996=>799,7997=>831,7998=>723,7999=>714,8000=>667,8001=>667,8002=>667,8003=>667,
8004=>667,8005=>667,8008=>900,8009=>935,8010=>1240,8011=>1237,8012=>1035,8013=>1066,8016=>694,8017=>694,
8018=>694,8019=>694,8020=>694,8021=>694,8022=>694,8023=>694,8025=>922,8027=>1186,8029=>1133,8031=>1019,
8032=>952,8033=>952,8034=>952,8035=>952,8036=>952,8037=>952,8038=>952,8039=>952,8040=>931,8041=>963,
8042=>1268,8043=>1274,8044=>1054,8045=>1088,8046=>1023,8047=>1060,8048=>770,8049=>770,8050=>608,8051=>608,
8052=>727,8053=>727,8054=>484,8055=>484,8056=>667,8057=>667,8058=>694,8059=>694,8060=>952,8061=>952,
8064=>770,8065=>770,8066=>770,8067=>770,8068=>770,8069=>770,8070=>770,8071=>770,8072=>776,8073=>776,
8074=>978,8075=>978,8076=>832,8077=>849,8078=>776,8079=>776,8080=>727,8081=>727,8082=>727,8083=>727,
8084=>727,8085=>727,8086=>727,8087=>727,8088=>1100,8089=>1094,8090=>1358,8091=>1361,8092=>1279,8093=>1308,
8094=>1197,8095=>1194,8096=>952,8097=>952,8098=>952,8099=>952,8100=>952,8101=>952,8102=>952,8103=>952,
8104=>931,8105=>963,8106=>1268,8107=>1274,8108=>1054,8109=>1088,8110=>1023,8111=>1060,8112=>770,8113=>770,
8114=>770,8115=>770,8116=>770,8118=>770,8119=>770,8120=>776,8121=>776,8122=>811,8123=>776,8124=>776,
8125=>500,8126=>500,8127=>500,8128=>500,8129=>500,8130=>727,8131=>727,8132=>727,8134=>727,8135=>727,
8136=>1000,8137=>947,8138=>1191,8139=>1118,8140=>945,8141=>500,8142=>500,8143=>500,8144=>484,8145=>484,
8146=>484,8147=>484,8150=>484,8151=>484,8152=>468,8153=>468,8154=>714,8155=>662,8157=>500,8158=>500,
8159=>500,8160=>694,8161=>694,8162=>694,8163=>694,8164=>665,8165=>665,8166=>694,8167=>694,8168=>714,
8169=>714,8170=>1019,8171=>953,8172=>910,8173=>500,8174=>500,8175=>500,8178=>952,8179=>952,8180=>952,
8182=>952,8183=>952,8184=>1069,8185=>887,8186=>1101,8187=>911,8188=>890,8189=>500,8190=>500,8192=>500,
8193=>1000,8194=>500,8195=>1000,8196=>330,8197=>250,8198=>167,8199=>696,8200=>348,8201=>200,8202=>100,
8203=>0,8204=>0,8205=>0,8206=>0,8207=>0,8208=>415,8209=>415,8210=>696,8213=>1000,8214=>500,
8215=>500,8219=>348,8223=>575,8227=>639,8228=>348,8229=>674,8234=>0,8235=>0,8236=>0,8237=>0,
8238=>0,8239=>200,8241=>1820,8242=>264,8243=>447,8244=>630,8245=>264,8246=>447,8247=>630,8248=>733,
8252=>629,8253=>586,8254=>500,8258=>1023,8260=>167,8261=>473,8262=>473,8263=>1082,8264=>856,8265=>856,
8267=>636,8268=>500,8269=>500,8270=>523,8271=>369,8273=>523,8274=>556,8275=>1000,8279=>813,8287=>222,
8288=>0,8289=>0,8290=>0,8291=>0,8292=>0,8298=>0,8299=>0,8300=>0,8301=>0,8302=>0,
8303=>0,8304=>438,8305=>239,8308=>438,8309=>438,8310=>438,8311=>438,8312=>438,8313=>438,8314=>528,
8315=>528,8316=>528,8317=>298,8318=>298,8319=>519,8320=>438,8321=>438,8322=>438,8323=>438,8324=>438,
8325=>438,8326=>438,8327=>438,8328=>438,8329=>438,8330=>528,8331=>528,8332=>528,8333=>298,8334=>298,
8336=>466,8337=>444,8338=>467,8339=>475,8340=>444,8358=>696,8367=>1155,8369=>790,8372=>876,8373=>696,
8451=>1198,8457=>1112,8462=>727,8463=>727,8470=>1087,8486=>890,8487=>890,8490=>869,8491=>776,8513=>775,
8514=>557,8515=>637,8516=>760,8523=>903,8531=>1035,8532=>1035,8533=>1035,8534=>1035,8535=>1035,8536=>1035,
8537=>1035,8538=>1035,8539=>1035,8540=>1035,8541=>1035,8542=>1035,8543=>615,8544=>468,8545=>736,8546=>1005,
8547=>1093,8548=>776,8549=>1127,8550=>1396,8551=>1664,8552=>1069,8553=>776,8554=>1078,8555=>1347,8556=>703,
8557=>796,8558=>867,8559=>1107,8560=>380,8561=>760,8562=>1140,8563=>961,8564=>581,8565=>961,8566=>1341,
8567=>1721,8568=>976,8569=>596,8570=>976,8571=>1356,8572=>380,8573=>609,8574=>699,8575=>1058,8576=>1255,
8577=>867,8578=>1268,8579=>796,8580=>609,8592=>838,8593=>838,8594=>838,8595=>838,8596=>838,8597=>838,
8598=>838,8599=>838,8600=>838,8601=>838,8602=>838,8603=>838,8604=>838,8605=>838,8606=>838,8607=>838,
8608=>838,8609=>838,8610=>838,8611=>838,8612=>838,8613=>838,8614=>838,8615=>838,8616=>838,8617=>838,
8618=>838,8619=>838,8620=>838,8621=>838,8622=>838,8623=>850,8624=>838,8625=>838,8626=>838,8627=>838,
8628=>838,8629=>838,8630=>838,8631=>838,8632=>838,8633=>838,8634=>838,8635=>838,8636=>838,8637=>838,
8638=>838,8639=>838,8640=>838,8641=>838,8642=>838,8643=>838,8644=>838,8645=>838,8646=>838,8647=>838,
8648=>838,8649=>838,8650=>838,8651=>838,8652=>838,8653=>838,8654=>838,8655=>838,8656=>838,8657=>838,
8658=>838,8659=>838,8660=>838,8661=>838,8662=>838,8663=>838,8664=>838,8665=>838,8666=>838,8667=>838,
8668=>838,8669=>838,8670=>838,8671=>838,8672=>838,8673=>838,8674=>838,8675=>838,8676=>838,8677=>838,
8678=>838,8679=>838,8680=>838,8681=>838,8682=>838,8683=>838,8684=>838,8685=>838,8686=>838,8687=>838,
8688=>838,8689=>838,8690=>838,8691=>838,8692=>838,8693=>838,8694=>838,8695=>838,8696=>838,8697=>838,
8698=>838,8699=>838,8700=>838,8701=>838,8702=>838,8703=>838,8704=>641,8706=>534,8707=>620,8708=>620,
8710=>753,8711=>753,8712=>740,8713=>740,8715=>740,8716=>740,8719=>842,8720=>842,8721=>753,8722=>838,
8723=>838,8724=>838,8725=>365,8727=>691,8728=>519,8729=>519,8730=>657,8731=>657,8732=>657,8733=>672,
8734=>833,8735=>838,8736=>838,8739=>324,8740=>607,8741=>529,8742=>773,8743=>812,8744=>812,8745=>838,
8746=>838,8747=>579,8748=>1000,8749=>1391,8760=>838,8761=>838,8762=>838,8763=>838,8764=>838,8765=>838,
8770=>838,8771=>838,8776=>838,8784=>838,8785=>838,8786=>838,8787=>838,8788=>1082,8789=>1082,8800=>838,
8801=>838,8804=>838,8805=>838,8834=>838,8835=>838,8836=>838,8837=>838,8838=>838,8839=>838,8844=>838,
8845=>838,8846=>838,8847=>838,8848=>838,8849=>838,8850=>838,8851=>838,8852=>838,8853=>838,8854=>838,
8855=>838,8856=>838,8857=>838,8858=>838,8859=>838,8860=>838,8861=>838,8862=>838,8863=>838,8864=>838,
8865=>838,8866=>884,8867=>884,8868=>960,8869=>960,8870=>616,8871=>616,8872=>884,8873=>884,8874=>884,
8875=>1080,8876=>884,8877=>884,8878=>884,8879=>1080,8901=>398,8962=>834,8968=>473,8969=>473,8970=>473,
8971=>473,8976=>838,8977=>539,8984=>928,8985=>838,8992=>579,8993=>579,8997=>1000,9000=>1443,9085=>1008,
9134=>579,9167=>945,9251=>834,9600=>769,9601=>769,9602=>769,9603=>769,9604=>769,9605=>769,9606=>769,
9607=>769,9608=>769,9609=>769,9610=>769,9611=>769,9612=>769,9613=>769,9614=>769,9615=>769,9616=>769,
9617=>769,9618=>769,9619=>769,9620=>769,9621=>769,9622=>769,9623=>769,9624=>769,9625=>769,9626=>769,
9627=>769,9628=>769,9629=>769,9630=>769,9631=>769,9632=>945,9633=>945,9634=>945,9635=>945,9636=>945,
9637=>945,9638=>945,9639=>945,9640=>945,9641=>945,9642=>678,9643=>678,9644=>945,9645=>945,9646=>550,
9647=>550,9648=>769,9649=>769,9650=>769,9651=>769,9652=>502,9653=>502,9654=>769,9655=>769,9656=>502,
9657=>502,9658=>769,9659=>769,9660=>769,9661=>769,9662=>502,9663=>502,9664=>769,9665=>769,9666=>502,
9667=>502,9668=>769,9669=>769,9670=>769,9671=>769,9672=>769,9673=>873,9674=>494,9675=>873,9676=>873,
9677=>873,9678=>873,9679=>873,9680=>873,9681=>873,9682=>873,9683=>873,9684=>873,9685=>873,9686=>527,
9687=>527,9688=>791,9689=>970,9690=>970,9691=>970,9692=>387,9693=>387,9694=>387,9695=>387,9696=>873,
9697=>873,9698=>769,9699=>769,9700=>769,9701=>769,9702=>590,9703=>945,9704=>945,9705=>945,9706=>945,
9707=>945,9708=>769,9709=>769,9710=>769,9711=>1119,9712=>945,9713=>945,9714=>945,9715=>945,9716=>873,
9717=>873,9718=>873,9719=>873,9720=>769,9721=>769,9722=>769,9723=>830,9724=>830,9725=>732,9726=>732,
9727=>769,9728=>896,9784=>896,9785=>896,9786=>896,9787=>896,9788=>896,9791=>614,9792=>731,9793=>731,
9794=>896,9795=>896,9796=>896,9797=>896,9798=>896,9799=>896,9824=>896,9825=>896,9826=>896,9827=>896,
9828=>896,9829=>896,9830=>896,9831=>896,9833=>472,9834=>638,9835=>896,9836=>896,9837=>472,9838=>357,
9839=>484,10145=>838,10181=>457,10182=>457,10208=>494,10216=>457,10217=>457,10224=>838,10225=>838,10226=>838,
10227=>838,10228=>1033,10229=>1434,10230=>1434,10231=>1434,10232=>1434,10233=>1434,10234=>1434,10235=>1434,10236=>1434,
10237=>1434,10238=>1434,10239=>1434,10240=>781,10241=>781,10242=>781,10243=>781,10244=>781,10245=>781,10246=>781,
10247=>781,10248=>781,10249=>781,10250=>781,10251=>781,10252=>781,10253=>781,10254=>781,10255=>781,10256=>781,
10257=>781,10258=>781,10259=>781,10260=>781,10261=>781,10262=>781,10263=>781,10264=>781,10265=>781,10266=>781,
10267=>781,10268=>781,10269=>781,10270=>781,10271=>781,10272=>781,10273=>781,10274=>781,10275=>781,10276=>781,
10277=>781,10278=>781,10279=>781,10280=>781,10281=>781,10282=>781,10283=>781,10284=>781,10285=>781,10286=>781,
10287=>781,10288=>781,10289=>781,10290=>781,10291=>781,10292=>781,10293=>781,10294=>781,10295=>781,10296=>781,
10297=>781,10298=>781,10299=>781,10300=>781,10301=>781,10302=>781,10303=>781,10304=>781,10305=>781,10306=>781,
10307=>781,10308=>781,10309=>781,10310=>781,10311=>781,10312=>781,10313=>781,10314=>781,10315=>781,10316=>781,
10317=>781,10318=>781,10319=>781,10320=>781,10321=>781,10322=>781,10323=>781,10324=>781,10325=>781,10326=>781,
10327=>781,10328=>781,10329=>781,10330=>781,10331=>781,10332=>781,10333=>781,10334=>781,10335=>781,10336=>781,
10337=>781,10338=>781,10339=>781,10340=>781,10341=>781,10342=>781,10343=>781,10344=>781,10345=>781,10346=>781,
10347=>781,10348=>781,10349=>781,10350=>781,10351=>781,10352=>781,10353=>781,10354=>781,10355=>781,10356=>781,
10357=>781,10358=>781,10359=>781,10360=>781,10361=>781,10362=>781,10363=>781,10364=>781,10365=>781,10366=>781,
10367=>781,10368=>781,10369=>781,10370=>781,10371=>781,10372=>781,10373=>781,10374=>781,10375=>781,10376=>781,
10377=>781,10378=>781,10379=>781,10380=>781,10381=>781,10382=>781,10383=>781,10384=>781,10385=>781,10386=>781,
10387=>781,10388=>781,10389=>781,10390=>781,10391=>781,10392=>781,10393=>781,10394=>781,10395=>781,10396=>781,
10397=>781,10398=>781,10399=>781,10400=>781,10401=>781,10402=>781,10403=>781,10404=>781,10405=>781,10406=>781,
10407=>781,10408=>781,10409=>781,10410=>781,10411=>781,10412=>781,10413=>781,10414=>781,10415=>781,10416=>781,
10417=>781,10418=>781,10419=>781,10420=>781,10421=>781,10422=>781,10423=>781,10424=>781,10425=>781,10426=>781,
10427=>781,10428=>781,10429=>781,10430=>781,10431=>781,10432=>781,10433=>781,10434=>781,10435=>781,10436=>781,
10437=>781,10438=>781,10439=>781,10440=>781,10441=>781,10442=>781,10443=>781,10444=>781,10445=>781,10446=>781,
10447=>781,10448=>781,10449=>781,10450=>781,10451=>781,10452=>781,10453=>781,10454=>781,10455=>781,10456=>781,
10457=>781,10458=>781,10459=>781,10460=>781,10461=>781,10462=>781,10463=>781,10464=>781,10465=>781,10466=>781,
10467=>781,10468=>781,10469=>781,10470=>781,10471=>781,10472=>781,10473=>781,10474=>781,10475=>781,10476=>781,
10477=>781,10478=>781,10479=>781,10480=>781,10481=>781,10482=>781,10483=>781,10484=>781,10485=>781,10486=>781,
10487=>781,10488=>781,10489=>781,10490=>781,10491=>781,10492=>781,10493=>781,10494=>781,10495=>781,10496=>838,
10497=>838,10498=>838,10499=>838,10500=>838,10501=>838,10502=>838,10503=>838,10504=>838,10505=>838,10506=>838,
10507=>838,10508=>838,10509=>838,10510=>838,10511=>838,10512=>838,10513=>838,10514=>838,10515=>838,10516=>838,
10517=>838,10518=>838,10519=>838,10520=>838,10521=>838,10522=>838,10523=>838,10524=>838,10525=>838,10526=>838,
10527=>838,10528=>838,10529=>838,10530=>838,10531=>838,10532=>838,10533=>838,10534=>838,10535=>838,10536=>838,
10537=>838,10538=>838,10539=>838,10540=>838,10541=>838,10542=>838,10543=>838,10544=>838,10545=>838,10546=>838,
10547=>838,10548=>838,10549=>838,10550=>838,10551=>838,10552=>838,10553=>838,10554=>838,10555=>838,10556=>838,
10557=>838,10558=>838,10559=>838,10560=>838,10561=>838,10562=>838,10563=>838,10564=>838,10565=>838,10566=>838,
10567=>838,10568=>838,10569=>838,10570=>838,10571=>838,10572=>838,10573=>838,10574=>838,10575=>838,10576=>838,
10577=>838,10578=>838,10579=>838,10580=>838,10581=>838,10582=>838,10583=>838,10584=>838,10585=>838,10586=>838,
10587=>838,10588=>838,10589=>838,10590=>838,10591=>838,10592=>838,10593=>838,10594=>838,10595=>838,10596=>838,
10597=>838,10598=>838,10599=>838,10600=>838,10601=>838,10602=>838,10603=>838,10604=>838,10605=>838,10606=>838,
10607=>838,10608=>838,10609=>838,10610=>838,10611=>838,10612=>838,10613=>838,10614=>838,10615=>1032,10616=>838,
10617=>838,10618=>960,10619=>838,10620=>838,10621=>838,10622=>838,10623=>838,10731=>494,10764=>1782,10765=>610,
10766=>610,10799=>838,11008=>838,11009=>838,11010=>838,11011=>838,11012=>838,11013=>838,11014=>838,11015=>838,
11016=>838,11017=>838,11018=>838,11019=>838,11020=>838,11021=>838,11022=>838,11023=>838,11024=>838,11025=>838,
11026=>945,11027=>945,11028=>945,11029=>945,11030=>769,11031=>769,11032=>769,11033=>769,11034=>945,11364=>831,
11367=>945,11368=>727,11369=>869,11370=>693,11371=>730,11372=>568,11374=>1107,11375=>776,11381=>779,11382=>601,
11383=>905,11385=>571,11386=>667,11388=>313,11389=>489,11520=>773,11521=>635,11522=>804,11523=>658,11524=>788,
11525=>962,11526=>756,11527=>960,11528=>617,11529=>646,11530=>962,11531=>631,11532=>646,11533=>962,11534=>846,
11535=>866,11536=>961,11537=>645,11538=>645,11539=>959,11540=>945,11541=>863,11542=>644,11543=>646,11544=>645,
11545=>649,11546=>688,11547=>936,11548=>982,11549=>681,11550=>676,11551=>852,11552=>1113,11553=>632,11554=>645,
11555=>646,11556=>749,11557=>914,11800=>586,11810=>473,11811=>473,11812=>473,11813=>473,11822=>586,42564=>722,
42565=>563,42566=>468,42567=>380,42576=>1333,42577=>1092,42580=>1287,42581=>1025,42582=>1287,42583=>1039,42760=>500,
42761=>500,42762=>500,42763=>500,42764=>500,42765=>500,42766=>500,42767=>500,42768=>500,42769=>500,42770=>500,
42771=>500,42772=>500,42773=>500,42774=>500,42779=>384,42780=>384,42781=>276,42782=>276,42783=>276,42891=>439,
42892=>306,62464=>705,62465=>716,62466=>765,62467=>999,62468=>716,62469=>710,62470=>776,62471=>1038,62472=>716,
62473=>716,62474=>1309,62475=>734,62476=>733,62477=>1004,62478=>716,62479=>733,62480=>1050,62481=>797,62482=>850,
62483=>799,62484=>996,62485=>732,62486=>987,62487=>731,62488=>739,62489=>733,62490=>780,62491=>733,62492=>739,
62493=>717,62494=>780,62495=>936,62496=>716,62497=>826,62498=>717,62499=>716,62500=>716,62501=>773,62502=>1013,
62504=>904,63173=>667,63185=>500,63188=>500,64256=>821,64257=>727,64258=>727,64259=>1120,64260=>1117,64261=>871,
64262=>971,65024=>0,65025=>0,65026=>0,65027=>0,65028=>0,65029=>0,65030=>0,65031=>0,65032=>0,
65033=>0,65034=>0,65035=>0,65036=>0,65037=>0,65038=>0,65039=>0,65529=>0,65530=>0,65531=>0,
65532=>0,65533=>1113);
$enc='';
$diff='';
$file='dejavuserifb.z';
$ctg='dejavuserifb.ctg.z';
$originalsize=306532;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/dejavuserifb.php | PHP | asf20 | 28,779 |
<?php
$type='TrueTypeUnicode';
$name='DejaVuSansCondensed';
$desc=array('Ascent'=>928,'Descent'=>-236,'CapHeight'=>26,'Flags'=>96,'FontBBox'=>'[-918 -350 1513 1167]','ItalicAngle'=>-18.9,'StemV'=>70,'MissingWidth'=>540);
$up=-63;
$ut=44;
$dw=540;
$cw=array(
0=>540,32=>286,33=>360,34=>414,35=>754,36=>572,37=>855,38=>702,39=>247,40=>351,
41=>351,42=>450,43=>754,44=>286,45=>325,46=>286,47=>303,48=>572,49=>572,50=>572,
51=>572,52=>572,53=>572,54=>572,55=>572,56=>572,57=>572,58=>303,59=>303,60=>754,
61=>754,62=>754,63=>478,64=>900,65=>615,66=>617,67=>628,68=>693,69=>568,70=>518,
71=>697,72=>677,73=>265,74=>265,75=>590,76=>501,77=>776,78=>673,79=>708,80=>542,
81=>708,82=>625,83=>571,84=>549,85=>659,86=>615,87=>890,88=>616,89=>549,90=>616,
91=>351,92=>303,93=>351,94=>754,95=>450,96=>450,97=>551,98=>571,99=>495,100=>571,
101=>554,102=>316,103=>571,104=>570,105=>250,106=>250,107=>521,108=>250,109=>876,110=>570,
111=>550,112=>571,113=>571,114=>370,115=>469,116=>353,117=>570,118=>532,119=>736,120=>532,
121=>532,122=>472,123=>572,124=>303,125=>572,126=>754,8364=>572,8218=>286,402=>316,8222=>466,
8230=>900,8224=>450,8225=>450,710=>450,8240=>1208,352=>571,8249=>360,338=>962,381=>616,8216=>286,
8217=>286,8220=>466,8221=>466,8226=>531,8211=>450,8212=>900,732=>450,8482=>900,353=>469,8250=>360,
339=>920,382=>472,376=>549,160=>286,161=>360,162=>572,163=>572,164=>572,165=>572,166=>303,
167=>450,168=>450,169=>900,170=>424,171=>550,172=>754,173=>325,174=>900,175=>450,176=>450,
177=>754,178=>360,179=>360,180=>450,181=>572,182=>572,183=>286,184=>450,185=>360,186=>424,
187=>550,188=>872,189=>872,190=>872,191=>478,192=>615,193=>615,194=>615,195=>615,196=>615,
197=>615,198=>876,199=>628,200=>568,201=>568,202=>568,203=>568,204=>265,205=>265,206=>265,
207=>265,208=>697,209=>673,210=>708,211=>708,212=>708,213=>708,214=>708,215=>754,216=>708,
217=>659,218=>659,219=>659,220=>659,221=>549,222=>544,223=>567,224=>551,225=>551,226=>551,
227=>551,228=>551,229=>551,230=>883,231=>495,232=>554,233=>554,234=>554,235=>554,236=>250,
237=>250,238=>250,239=>250,240=>550,241=>570,242=>550,243=>550,244=>550,245=>550,246=>550,
247=>754,248=>550,249=>570,250=>570,251=>570,252=>570,253=>532,254=>571,255=>532,256=>615,
257=>551,258=>615,259=>551,260=>615,261=>551,262=>628,263=>495,264=>628,265=>495,266=>628,
267=>495,268=>628,269=>495,270=>693,271=>571,272=>697,273=>571,274=>568,275=>554,276=>568,
277=>554,278=>568,279=>554,280=>568,281=>554,282=>568,283=>554,284=>697,285=>571,286=>697,
287=>571,288=>697,289=>571,290=>697,291=>571,292=>677,293=>570,294=>824,295=>625,296=>265,
297=>250,298=>265,299=>250,300=>265,301=>250,302=>265,303=>250,304=>265,305=>250,306=>531,
307=>500,308=>265,309=>250,310=>590,311=>521,312=>521,313=>501,314=>250,315=>501,316=>250,
317=>501,318=>337,319=>501,320=>308,321=>505,322=>255,323=>673,324=>570,325=>673,326=>570,
327=>673,328=>570,329=>732,330=>673,331=>570,332=>708,333=>550,334=>708,335=>550,336=>708,
337=>550,340=>625,341=>370,342=>625,343=>370,344=>625,345=>370,346=>571,347=>469,348=>571,
349=>469,350=>571,351=>469,354=>549,355=>353,356=>549,357=>353,358=>549,359=>353,360=>659,
361=>570,362=>659,363=>570,364=>659,365=>570,366=>659,367=>570,368=>659,369=>570,370=>659,
371=>570,372=>890,373=>736,374=>549,375=>532,377=>616,378=>472,379=>616,380=>472,383=>316,
384=>571,385=>661,386=>617,387=>571,388=>617,389=>571,390=>633,391=>628,392=>495,393=>697,
394=>737,395=>617,396=>571,397=>550,398=>568,399=>708,400=>553,401=>518,403=>697,404=>618,
405=>885,406=>318,407=>265,408=>671,409=>521,410=>250,411=>532,412=>876,413=>673,414=>570,
415=>708,416=>822,417=>550,418=>854,419=>683,420=>586,421=>571,422=>625,423=>571,424=>469,
425=>568,426=>302,427=>353,428=>549,429=>353,430=>549,431=>772,432=>570,433=>688,434=>648,
435=>669,436=>657,437=>616,438=>472,439=>599,440=>599,441=>520,442=>472,443=>572,444=>599,
445=>520,446=>459,447=>571,448=>265,449=>443,450=>413,451=>266,452=>1279,453=>1169,454=>1039,
455=>751,456=>708,457=>411,458=>838,459=>831,460=>717,461=>615,462=>551,463=>265,464=>250,
465=>708,466=>550,467=>659,468=>570,469=>659,470=>570,471=>659,472=>570,473=>659,474=>570,
475=>659,476=>570,477=>554,478=>615,479=>551,480=>615,481=>551,482=>876,483=>883,484=>697,
485=>571,486=>697,487=>571,488=>590,489=>521,490=>708,491=>550,492=>708,493=>550,494=>599,
495=>520,496=>250,497=>1279,498=>1169,499=>1039,500=>697,501=>571,502=>1001,503=>614,504=>673,
505=>570,506=>615,507=>551,508=>876,509=>883,510=>708,511=>550,512=>615,513=>551,514=>615,
515=>551,516=>568,517=>554,518=>568,519=>554,520=>265,521=>250,522=>265,523=>250,524=>708,
525=>550,526=>708,527=>550,528=>625,529=>370,530=>625,531=>370,532=>659,533=>570,534=>659,
535=>570,536=>571,537=>469,538=>549,539=>353,540=>564,541=>469,542=>677,543=>570,544=>662,
545=>754,546=>628,547=>549,548=>616,549=>472,550=>615,551=>551,552=>568,553=>554,554=>708,
555=>550,556=>708,557=>550,558=>708,559=>550,560=>708,561=>550,562=>549,563=>532,564=>427,
565=>758,566=>429,567=>250,568=>898,569=>898,570=>615,571=>628,572=>495,573=>501,574=>549,
575=>469,576=>472,577=>542,578=>431,579=>617,580=>659,581=>615,582=>568,583=>554,584=>265,
585=>250,586=>703,587=>571,588=>625,589=>370,590=>549,591=>532,592=>540,593=>571,594=>571,
595=>571,596=>494,597=>495,598=>571,599=>626,600=>554,601=>554,602=>737,603=>486,604=>479,
605=>698,606=>598,607=>250,608=>626,609=>571,610=>566,611=>536,612=>536,613=>570,614=>570,
615=>570,616=>250,617=>304,618=>334,619=>356,620=>438,621=>250,622=>635,623=>876,624=>876,
625=>876,626=>581,627=>578,628=>570,629=>550,630=>772,631=>655,632=>593,633=>373,634=>373,
635=>372,636=>370,637=>369,638=>477,639=>477,640=>543,641=>543,642=>469,643=>302,644=>302,
645=>415,646=>302,647=>353,648=>353,649=>570,650=>556,651=>538,652=>532,653=>736,654=>532,
655=>549,656=>472,657=>472,658=>520,659=>520,660=>459,661=>459,662=>459,663=>459,664=>708,
665=>521,666=>598,667=>637,668=>588,669=>263,670=>600,671=>456,672=>654,673=>459,674=>459,
675=>913,676=>952,677=>911,678=>742,679=>549,680=>700,681=>763,682=>576,683=>589,684=>463,
685=>463,686=>595,687=>597,688=>364,689=>359,690=>157,691=>233,692=>266,693=>266,694=>341,
695=>463,696=>335,697=>250,698=>414,699=>286,700=>286,701=>286,702=>276,703=>276,704=>333,
705=>333,706=>450,707=>450,708=>450,709=>450,711=>450,712=>247,713=>450,714=>450,715=>450,
716=>247,717=>450,718=>450,719=>450,720=>303,721=>303,722=>276,723=>276,724=>450,725=>450,
726=>351,727=>286,728=>450,729=>450,730=>450,731=>450,733=>450,734=>284,735=>450,736=>383,
737=>149,738=>335,739=>399,740=>333,741=>444,742=>444,743=>444,744=>444,745=>444,748=>450,
749=>450,750=>466,755=>450,759=>450,768=>0,769=>0,770=>0,771=>0,772=>0,773=>0,
774=>0,775=>0,776=>0,777=>0,778=>0,779=>0,780=>0,781=>0,782=>0,783=>0,
784=>0,785=>0,786=>0,787=>0,788=>0,789=>0,790=>0,791=>0,792=>0,793=>0,
794=>0,795=>0,796=>0,797=>0,798=>0,799=>0,800=>0,801=>0,802=>0,803=>0,
804=>0,805=>0,806=>0,807=>0,808=>0,809=>0,810=>0,811=>0,812=>0,813=>0,
814=>0,815=>0,816=>0,817=>0,818=>0,819=>0,820=>0,821=>0,822=>0,823=>0,
824=>0,825=>0,826=>0,827=>0,828=>0,829=>0,830=>0,831=>0,832=>0,833=>0,
834=>0,835=>0,836=>0,837=>0,838=>0,839=>0,840=>0,841=>0,842=>0,843=>0,
844=>0,845=>0,846=>0,847=>0,849=>0,850=>0,851=>0,855=>0,856=>0,858=>0,
860=>0,861=>0,862=>0,863=>0,864=>0,865=>0,866=>0,880=>589,881=>511,882=>775,
883=>583,884=>250,885=>250,886=>673,887=>584,890=>450,891=>494,892=>495,893=>494,894=>303,
900=>450,901=>450,902=>623,903=>286,904=>671,905=>784,906=>367,908=>731,910=>742,911=>743,
912=>304,913=>615,914=>617,915=>501,916=>615,917=>568,918=>616,919=>677,920=>708,921=>265,
922=>590,923=>615,924=>776,925=>673,926=>568,927=>708,928=>677,929=>542,931=>568,932=>549,
933=>549,934=>708,935=>616,936=>708,937=>688,938=>265,939=>549,940=>593,941=>486,942=>570,
943=>304,944=>521,945=>593,946=>574,947=>532,948=>550,949=>486,950=>489,951=>570,952=>550,
953=>304,954=>530,955=>532,956=>572,957=>502,958=>501,959=>550,960=>542,961=>571,962=>528,
963=>570,964=>542,965=>521,966=>593,967=>520,968=>593,969=>753,970=>304,971=>521,972=>550,
973=>521,974=>753,975=>590,976=>553,977=>557,978=>628,979=>758,980=>628,981=>593,982=>753,
983=>597,984=>708,985=>550,986=>583,987=>528,988=>518,989=>413,990=>593,991=>593,992=>778,
993=>564,994=>840,995=>753,996=>682,997=>593,998=>712,999=>553,1000=>618,1001=>546,1002=>690,
1003=>563,1004=>629,1005=>550,1006=>549,1007=>482,1008=>597,1009=>571,1010=>495,1011=>250,1012=>708,
1013=>554,1014=>554,1015=>544,1016=>571,1017=>628,1018=>776,1019=>585,1020=>571,1021=>633,1022=>628,
1023=>633,1024=>568,1025=>568,1026=>708,1027=>549,1028=>628,1029=>571,1030=>265,1031=>265,1032=>265,
1033=>984,1034=>940,1035=>708,1036=>639,1037=>673,1038=>548,1039=>677,1040=>615,1041=>617,1042=>617,
1043=>549,1044=>703,1045=>568,1046=>969,1047=>577,1048=>673,1049=>673,1050=>639,1051=>677,1052=>776,
1053=>677,1054=>708,1055=>677,1056=>542,1057=>628,1058=>549,1059=>548,1060=>774,1061=>616,1062=>699,
1063=>617,1064=>962,1065=>984,1066=>749,1067=>794,1068=>617,1069=>628,1070=>971,1071=>625,1072=>551,
1073=>555,1074=>530,1075=>473,1076=>622,1077=>554,1078=>811,1079=>479,1080=>584,1081=>584,1082=>543,
1083=>575,1084=>679,1085=>588,1086=>550,1087=>588,1088=>571,1089=>495,1090=>524,1091=>532,1092=>769,
1093=>532,1094=>612,1095=>532,1096=>823,1097=>848,1098=>636,1099=>710,1100=>530,1101=>494,1102=>757,
1103=>541,1104=>554,1105=>554,1106=>563,1107=>473,1108=>494,1109=>469,1110=>250,1111=>250,1112=>250,
1113=>812,1114=>809,1115=>586,1116=>543,1117=>584,1118=>532,1119=>588,1120=>840,1121=>753,1122=>693,
1123=>604,1124=>848,1125=>674,1126=>791,1127=>705,1128=>1043,1129=>901,1130=>708,1131=>550,1132=>924,
1133=>742,1134=>572,1135=>486,1136=>771,1137=>789,1138=>708,1139=>550,1140=>703,1141=>598,1142=>703,
1143=>598,1144=>893,1145=>813,1146=>857,1147=>682,1148=>1062,1149=>925,1150=>840,1151=>753,1152=>628,
1153=>495,1154=>452,1155=>0,1156=>0,1157=>0,1158=>0,1159=>0,1160=>376,1161=>376,1162=>695,
1163=>609,1164=>617,1165=>530,1166=>542,1167=>571,1168=>549,1169=>473,1170=>607,1171=>531,1172=>562,
1173=>477,1174=>969,1175=>811,1176=>577,1177=>479,1178=>639,1179=>543,1180=>639,1181=>543,1182=>639,
1183=>543,1184=>771,1185=>748,1186=>677,1187=>594,1188=>913,1189=>789,1190=>973,1191=>824,1192=>790,
1193=>624,1194=>628,1195=>495,1196=>549,1197=>524,1198=>549,1199=>532,1200=>549,1201=>532,1202=>616,
1203=>532,1204=>840,1205=>726,1206=>617,1207=>532,1208=>617,1209=>532,1210=>617,1211=>570,1212=>847,
1213=>655,1214=>847,1215=>655,1216=>265,1217=>969,1218=>811,1219=>590,1220=>543,1221=>698,1222=>603,
1223=>677,1224=>594,1225=>699,1226=>612,1227=>617,1228=>532,1229=>799,1230=>697,1231=>250,1232=>615,
1233=>551,1234=>615,1235=>551,1236=>876,1237=>883,1238=>568,1239=>554,1240=>708,1241=>554,1242=>708,
1243=>554,1244=>969,1245=>811,1246=>577,1247=>479,1248=>599,1249=>520,1250=>673,1251=>584,1252=>673,
1253=>584,1254=>708,1255=>550,1256=>708,1257=>550,1258=>708,1259=>550,1260=>628,1261=>494,1262=>548,
1263=>532,1264=>548,1265=>532,1266=>548,1267=>532,1268=>617,1269=>532,1270=>549,1271=>473,1272=>794,
1273=>710,1274=>607,1275=>531,1276=>616,1277=>532,1278=>616,1279=>532,1280=>617,1281=>530,1282=>905,
1283=>807,1284=>877,1285=>782,1286=>611,1287=>529,1288=>964,1289=>861,1290=>1001,1291=>870,1292=>697,
1293=>593,1294=>695,1295=>640,1296=>553,1297=>486,1298=>677,1299=>575,1300=>1052,1301=>894,1302=>804,
1303=>778,1304=>928,1305=>887,1306=>708,1307=>571,1308=>890,1309=>736,1312=>972,1313=>814,1314=>973,
1315=>821,1316=>713,1317=>614,1329=>780,1330=>659,1331=>794,1332=>794,1333=>659,1334=>579,1335=>613,
1336=>659,1337=>765,1338=>794,1339=>659,1340=>501,1341=>741,1342=>888,1343=>659,1344=>636,1345=>579,
1346=>794,1347=>699,1348=>794,1349=>659,1350=>756,1351=>659,1352=>659,1353=>659,1354=>711,1355=>579,
1356=>794,1357=>659,1358=>794,1359=>571,1360=>659,1361=>659,1362=>719,1363=>708,1364=>711,1365=>708,
1366=>571,1369=>276,1370=>286,1371=>450,1372=>450,1373=>352,1374=>474,1375=>450,1377=>876,1378=>570,
1379=>686,1380=>690,1381=>570,1382=>627,1383=>479,1384=>570,1385=>630,1386=>627,1387=>570,1388=>363,
1389=>804,1390=>576,1391=>570,1392=>570,1393=>571,1394=>631,1395=>570,1396=>593,1397=>250,1398=>684,
1399=>464,1400=>570,1401=>407,1402=>876,1403=>464,1404=>691,1405=>570,1406=>626,1407=>876,1408=>570,
1409=>571,1410=>451,1411=>876,1412=>583,1413=>550,1414=>566,1415=>686,1417=>303,1418=>390,1456=>0,
1457=>0,1458=>0,1459=>0,1460=>0,1461=>0,1462=>0,1463=>0,1464=>0,1465=>0,1466=>0,
1467=>0,1468=>0,1469=>0,1470=>325,1471=>0,1472=>265,1473=>0,1474=>0,1475=>265,1478=>397,
1479=>0,1488=>566,1489=>547,1490=>403,1491=>534,1492=>576,1493=>245,1494=>336,1495=>576,1496=>583,
1497=>245,1498=>532,1499=>500,1500=>539,1501=>576,1502=>593,1503=>245,1504=>397,1505=>629,1506=>506,
1507=>576,1508=>543,1509=>468,1510=>523,1511=>596,1512=>532,1513=>727,1514=>591,1520=>423,1521=>409,
1522=>423,1523=>374,1524=>580,1542=>573,1543=>573,1545=>681,1546=>879,1548=>290,1557=>0,1563=>286,
1567=>478,1569=>423,1570=>250,1571=>250,1572=>435,1573=>250,1574=>704,1575=>250,1576=>847,1577=>471,
1578=>847,1579=>847,1580=>581,1581=>581,1582=>581,1583=>400,1584=>400,1585=>435,1586=>435,1587=>1099,
1588=>1099,1589=>1088,1590=>1088,1591=>832,1592=>832,1593=>537,1594=>537,1600=>264,1601=>933,1602=>698,
1603=>742,1604=>654,1605=>557,1606=>661,1607=>471,1608=>435,1609=>704,1610=>704,1611=>0,1612=>0,
1613=>0,1614=>0,1615=>0,1616=>0,1617=>0,1618=>0,1619=>0,1620=>0,1621=>0,1626=>450,
1632=>483,1633=>483,1634=>483,1635=>483,1636=>483,1637=>483,1638=>483,1639=>483,1640=>483,1641=>483,
1642=>483,1643=>292,1644=>286,1645=>490,1646=>847,1647=>698,1652=>263,1657=>847,1658=>847,1659=>847,
1660=>847,1661=>847,1662=>847,1663=>847,1664=>847,1665=>581,1666=>581,1667=>581,1668=>581,1669=>581,
1670=>581,1671=>581,1681=>435,1682=>435,1685=>549,1688=>435,1697=>933,1700=>933,1702=>933,1705=>805,
1711=>805,1717=>654,1722=>661,1727=>581,1734=>435,1740=>704,1742=>704,1749=>471,1776=>483,1777=>483,
1778=>483,1779=>483,1780=>483,1781=>483,1782=>483,1783=>483,1784=>483,1785=>483,1984=>572,1985=>572,
1986=>572,1987=>572,1988=>572,1989=>572,1990=>572,1991=>572,1992=>572,1993=>572,1994=>250,1995=>514,
1996=>381,1997=>532,1998=>588,1999=>588,2000=>534,2001=>588,2002=>746,2003=>394,2004=>394,2005=>502,
2006=>550,2007=>315,2008=>863,2009=>425,2010=>705,2011=>588,2012=>563,2013=>660,2014=>477,2015=>651,
2016=>425,2017=>563,2018=>534,2019=>477,2020=>477,2021=>470,2022=>534,2023=>534,2027=>0,2028=>0,
2029=>0,2030=>0,2031=>0,2032=>0,2033=>0,2034=>0,2035=>0,2036=>282,2037=>282,2040=>504,
2041=>504,2042=>325,3647=>586,3713=>603,3714=>615,3716=>619,3719=>434,3720=>565,3722=>615,3725=>619,
3732=>602,3733=>577,3734=>580,3735=>589,3737=>593,3738=>563,3739=>563,3740=>670,3741=>690,3742=>618,
3743=>618,3745=>631,3746=>619,3747=>615,3749=>584,3751=>569,3754=>633,3755=>737,3757=>569,3758=>615,
3759=>708,3760=>569,3761=>0,3762=>485,3763=>485,3764=>0,3765=>0,3766=>0,3767=>0,3768=>0,
3769=>0,3771=>0,3772=>0,3773=>597,3776=>337,3777=>591,3778=>414,3779=>492,3780=>442,3782=>606,
3784=>0,3785=>0,3786=>0,3787=>0,3788=>0,3789=>0,3792=>572,3793=>576,3794=>576,3795=>603,
3796=>563,3797=>563,3798=>633,3799=>603,3800=>606,3801=>609,3804=>925,3805=>925,4256=>756,4257=>621,
4258=>577,4259=>683,4260=>532,4261=>617,4262=>710,4263=>729,4264=>420,4265=>508,4266=>710,4267=>713,
4268=>526,4269=>753,4270=>675,4271=>620,4272=>729,4273=>526,4274=>526,4275=>753,4276=>753,4277=>581,
4278=>543,4279=>526,4280=>536,4281=>526,4282=>649,4283=>715,4284=>526,4285=>510,4286=>526,4287=>602,
4288=>719,4289=>488,4290=>598,4291=>488,4292=>508,4293=>606,4304=>457,4305=>457,4306=>479,4307=>706,
4308=>470,4309=>465,4310=>457,4311=>717,4312=>457,4313=>466,4314=>952,4315=>470,4316=>470,4317=>704,
4318=>466,4319=>470,4320=>713,4321=>470,4322=>590,4323=>471,4324=>709,4325=>470,4326=>704,4327=>470,
4328=>470,4329=>470,4330=>510,4331=>470,4332=>470,4333=>439,4334=>470,4335=>448,4336=>465,4337=>504,
4338=>457,4339=>457,4340=>457,4341=>507,4342=>741,4343=>536,4344=>470,4345=>498,4346=>498,4347=>527,
4348=>273,5121=>615,5122=>615,5123=>615,5124=>615,5125=>692,5126=>692,5127=>692,5129=>692,5130=>692,
5131=>692,5132=>751,5133=>751,5134=>751,5135=>751,5136=>751,5137=>751,5138=>870,5139=>906,5140=>870,
5141=>906,5142=>692,5143=>870,5144=>906,5145=>870,5146=>906,5147=>692,5149=>230,5150=>488,5151=>381,
5152=>381,5153=>350,5154=>350,5155=>354,5156=>350,5157=>419,5158=>347,5159=>230,5160=>350,5161=>350,
5162=>350,5163=>980,5164=>817,5165=>857,5166=>1005,5167=>615,5168=>615,5169=>615,5170=>615,5171=>656,
5172=>656,5173=>656,5175=>656,5176=>656,5177=>656,5178=>751,5179=>615,5180=>751,5181=>751,5182=>751,
5183=>751,5184=>870,5185=>906,5186=>870,5187=>906,5188=>870,5189=>906,5190=>870,5191=>906,5192=>656,
5193=>457,5194=>172,5196=>659,5197=>659,5198=>659,5199=>659,5200=>657,5201=>657,5202=>657,5204=>657,
5205=>657,5206=>657,5207=>829,5208=>800,5209=>829,5210=>800,5211=>829,5212=>800,5213=>835,5214=>810,
5215=>835,5216=>810,5217=>853,5218=>810,5219=>853,5220=>810,5221=>853,5222=>391,5223=>790,5224=>790,
5225=>779,5226=>801,5227=>565,5228=>565,5229=>565,5230=>565,5231=>565,5232=>565,5233=>565,5234=>565,
5235=>565,5236=>773,5237=>693,5238=>733,5239=>734,5240=>733,5241=>734,5242=>773,5243=>693,5244=>773,
5245=>693,5246=>733,5247=>734,5248=>733,5249=>734,5250=>733,5251=>366,5252=>366,5253=>675,5254=>697,
5255=>675,5256=>697,5257=>565,5258=>565,5259=>565,5260=>565,5261=>565,5262=>565,5263=>565,5264=>565,
5265=>565,5266=>773,5267=>693,5268=>733,5269=>734,5270=>733,5271=>734,5272=>773,5273=>693,5274=>773,
5275=>693,5276=>733,5277=>734,5278=>733,5279=>734,5280=>733,5281=>391,5282=>391,5283=>549,5284=>501,
5285=>501,5286=>501,5287=>549,5288=>549,5289=>549,5290=>501,5291=>501,5292=>674,5293=>691,5294=>671,
5295=>687,5296=>671,5297=>687,5298=>674,5299=>691,5300=>674,5301=>691,5302=>671,5303=>687,5304=>671,
5305=>687,5306=>671,5307=>347,5308=>457,5309=>347,5312=>766,5313=>766,5314=>766,5315=>766,5316=>766,
5317=>766,5318=>766,5319=>766,5320=>766,5321=>962,5322=>931,5323=>953,5324=>766,5325=>953,5326=>766,
5327=>766,5328=>540,5329=>407,5330=>540,5331=>766,5332=>766,5333=>766,5334=>766,5335=>766,5336=>766,
5337=>766,5338=>766,5339=>766,5340=>962,5341=>931,5342=>953,5343=>927,5344=>953,5345=>927,5346=>962,
5347=>931,5348=>962,5349=>931,5350=>975,5351=>927,5352=>975,5353=>927,5354=>540,5356=>656,5357=>542,
5358=>542,5359=>542,5360=>542,5361=>542,5362=>542,5363=>542,5364=>542,5365=>542,5366=>751,5367=>678,
5368=>712,5369=>694,5370=>712,5371=>694,5372=>751,5373=>678,5374=>751,5375=>678,5376=>712,5377=>694,
5378=>712,5379=>694,5380=>712,5381=>376,5382=>378,5383=>376,5392=>641,5393=>641,5394=>641,5395=>802,
5396=>802,5397=>802,5398=>802,5399=>818,5400=>785,5401=>818,5402=>785,5403=>818,5404=>785,5405=>1026,
5406=>989,5407=>1026,5408=>989,5409=>1026,5410=>989,5411=>1026,5412=>989,5413=>576,5414=>564,5415=>564,
5416=>564,5417=>564,5418=>564,5419=>564,5420=>564,5421=>564,5422=>564,5423=>760,5424=>703,5425=>734,
5426=>736,5427=>734,5428=>736,5429=>760,5430=>703,5431=>760,5432=>703,5433=>734,5434=>736,5435=>734,
5436=>736,5437=>734,5438=>376,5440=>350,5441=>436,5442=>824,5443=>824,5444=>824,5445=>824,5446=>824,
5447=>824,5448=>542,5449=>542,5450=>542,5451=>542,5452=>542,5453=>542,5454=>751,5455=>678,5456=>376,
5458=>656,5459=>615,5460=>615,5461=>615,5462=>615,5463=>653,5464=>653,5465=>653,5466=>653,5467=>831,
5468=>906,5469=>457,5470=>659,5471=>659,5472=>659,5473=>659,5474=>659,5475=>659,5476=>657,5477=>657,
5478=>657,5479=>657,5480=>853,5481=>810,5482=>457,5492=>747,5493=>747,5494=>747,5495=>747,5496=>747,
5497=>747,5498=>747,5499=>507,5500=>677,5501=>436,5502=>942,5503=>942,5504=>942,5505=>942,5506=>942,
5507=>942,5508=>942,5509=>743,5514=>747,5515=>747,5516=>747,5517=>747,5518=>1133,5519=>1133,5520=>1133,
5521=>901,5522=>901,5523=>1133,5524=>1133,5525=>629,5526=>965,5536=>766,5537=>766,5538=>766,5539=>766,
5540=>766,5541=>766,5542=>540,5543=>579,5544=>579,5545=>579,5546=>579,5547=>579,5548=>579,5549=>579,
5550=>376,5551=>565,5598=>693,5601=>690,5702=>421,5703=>421,5742=>399,5743=>942,5744=>1178,5745=>1469,
5746=>1469,5747=>1237,5748=>1237,5749=>1469,5750=>1469,5760=>429,5761=>443,5762=>641,5763=>838,5764=>1035,
5765=>1232,5766=>443,5767=>641,5768=>838,5769=>1035,5770=>1232,5771=>448,5772=>646,5773=>844,5774=>1042,
5775=>1241,5776=>443,5777=>641,5778=>836,5779=>1034,5780=>1232,5781=>448,5782=>677,5783=>709,5784=>1084,
5785=>1035,5786=>615,5787=>457,5788=>456,7424=>532,7425=>646,7426=>883,7427=>527,7428=>495,7429=>544,
7430=>544,7431=>441,7432=>486,7433=>250,7434=>355,7435=>521,7436=>524,7437=>679,7438=>584,7439=>550,
7440=>495,7441=>615,7442=>615,7443=>615,7444=>920,7446=>550,7447=>550,7448=>472,7449=>541,7450=>541,
7451=>524,7452=>517,7453=>663,7454=>853,7455=>574,7456=>532,7457=>736,7458=>472,7459=>473,7462=>524,
7463=>532,7464=>507,7465=>472,7466=>531,7467=>575,7468=>387,7469=>552,7470=>389,7472=>436,7473=>358,
7474=>358,7475=>439,7476=>426,7477=>167,7478=>167,7479=>372,7480=>315,7481=>489,7482=>424,7483=>424,
7484=>446,7485=>396,7486=>342,7487=>394,7488=>346,7489=>415,7490=>560,7491=>352,7492=>352,7493=>365,
7494=>583,7495=>385,7496=>365,7497=>375,7498=>375,7499=>324,7500=>323,7501=>365,7502=>161,7503=>383,
7504=>561,7505=>368,7506=>372,7507=>333,7508=>372,7509=>372,7510=>385,7511=>265,7512=>364,7513=>422,
7514=>561,7515=>375,7517=>361,7518=>335,7519=>347,7520=>374,7521=>327,7522=>161,7523=>233,7524=>364,
7525=>375,7526=>361,7527=>335,7528=>370,7529=>374,7530=>327,7543=>571,7544=>426,7547=>334,7557=>250,
7579=>365,7580=>333,7581=>333,7582=>372,7583=>324,7584=>267,7585=>209,7586=>365,7587=>364,7588=>235,
7589=>224,7590=>234,7591=>235,7592=>211,7593=>224,7594=>211,7595=>338,7596=>561,7597=>561,7598=>369,
7599=>431,7600=>368,7601=>372,7602=>372,7603=>324,7604=>258,7605=>265,7606=>457,7607=>376,7608=>325,
7609=>365,7610=>375,7611=>330,7612=>393,7613=>330,7614=>353,7615=>372,7620=>0,7621=>0,7622=>0,
7623=>0,7624=>0,7625=>0,7680=>615,7681=>551,7682=>617,7683=>571,7684=>617,7685=>571,7686=>617,
7687=>571,7688=>628,7689=>495,7690=>693,7691=>571,7692=>693,7693=>571,7694=>693,7695=>571,7696=>693,
7697=>571,7698=>693,7699=>571,7700=>568,7701=>554,7702=>568,7703=>554,7704=>568,7705=>554,7706=>568,
7707=>554,7708=>568,7709=>554,7710=>518,7711=>316,7712=>697,7713=>571,7714=>677,7715=>570,7716=>677,
7717=>570,7718=>677,7719=>570,7720=>677,7721=>570,7722=>677,7723=>570,7724=>265,7725=>250,7726=>265,
7727=>250,7728=>590,7729=>521,7730=>590,7731=>521,7732=>590,7733=>521,7734=>501,7735=>259,7736=>501,
7737=>259,7738=>501,7739=>250,7740=>501,7741=>250,7742=>776,7743=>876,7744=>776,7745=>876,7746=>776,
7747=>876,7748=>673,7749=>570,7750=>673,7751=>570,7752=>673,7753=>570,7754=>673,7755=>570,7756=>708,
7757=>550,7758=>708,7759=>550,7760=>708,7761=>550,7762=>708,7763=>550,7764=>542,7765=>571,7766=>542,
7767=>571,7768=>625,7769=>370,7770=>625,7771=>370,7772=>625,7773=>370,7774=>625,7775=>370,7776=>571,
7777=>469,7778=>571,7779=>469,7780=>571,7781=>469,7782=>571,7783=>469,7784=>571,7785=>469,7786=>549,
7787=>353,7788=>549,7789=>353,7790=>549,7791=>353,7792=>549,7793=>353,7794=>659,7795=>570,7796=>659,
7797=>570,7798=>659,7799=>570,7800=>659,7801=>570,7802=>659,7803=>570,7804=>615,7805=>532,7806=>615,
7807=>532,7808=>890,7809=>736,7810=>890,7811=>736,7812=>890,7813=>736,7814=>890,7815=>736,7816=>890,
7817=>736,7818=>616,7819=>532,7820=>616,7821=>532,7822=>549,7823=>532,7824=>616,7825=>472,7826=>616,
7827=>472,7828=>616,7829=>472,7830=>570,7831=>353,7832=>736,7833=>532,7834=>551,7835=>316,7838=>691,
7839=>550,7840=>615,7841=>551,7842=>615,7843=>551,7844=>615,7845=>551,7846=>615,7847=>551,7848=>615,
7849=>551,7850=>615,7851=>551,7852=>615,7853=>551,7854=>615,7855=>551,7856=>615,7857=>551,7858=>615,
7859=>551,7860=>615,7861=>551,7862=>615,7863=>551,7864=>568,7865=>554,7866=>568,7867=>554,7868=>568,
7869=>554,7870=>568,7871=>554,7872=>568,7873=>554,7874=>568,7875=>554,7876=>568,7877=>554,7878=>568,
7879=>554,7880=>265,7881=>250,7882=>265,7883=>250,7884=>708,7885=>550,7886=>708,7887=>550,7888=>708,
7889=>550,7890=>708,7891=>550,7892=>708,7893=>550,7894=>708,7895=>550,7896=>708,7897=>550,7898=>822,
7899=>550,7900=>822,7901=>550,7902=>822,7903=>550,7904=>822,7905=>550,7906=>822,7907=>550,7908=>659,
7909=>570,7910=>659,7911=>570,7912=>772,7913=>570,7914=>772,7915=>570,7916=>772,7917=>570,7918=>772,
7919=>570,7920=>772,7921=>570,7922=>549,7923=>532,7924=>549,7925=>532,7926=>549,7927=>532,7928=>549,
7929=>532,7936=>593,7937=>593,7938=>593,7939=>593,7940=>593,7941=>593,7942=>593,7943=>593,7944=>615,
7945=>615,7946=>790,7947=>790,7948=>692,7949=>721,7950=>637,7951=>668,7952=>486,7953=>486,7954=>486,
7955=>486,7956=>486,7957=>486,7960=>640,7961=>640,7962=>869,7963=>877,7964=>809,7965=>835,7968=>570,
7969=>570,7970=>570,7971=>570,7972=>570,7973=>570,7974=>570,7975=>570,7976=>753,7977=>751,7978=>977,
7979=>980,7980=>924,7981=>945,7982=>840,7983=>852,7984=>304,7985=>304,7986=>304,7987=>304,7988=>304,
7989=>304,7990=>304,7991=>304,7992=>342,7993=>336,7994=>571,7995=>571,7996=>513,7997=>540,7998=>440,
7999=>443,8000=>550,8001=>550,8002=>550,8003=>550,8004=>550,8005=>550,8008=>724,8009=>763,8010=>985,
8011=>989,8012=>844,8013=>873,8016=>521,8017=>521,8018=>521,8019=>521,8020=>521,8021=>521,8022=>521,
8023=>521,8025=>705,8027=>897,8029=>911,8031=>808,8032=>753,8033=>753,8034=>753,8035=>753,8036=>753,
8037=>753,8038=>753,8039=>753,8040=>722,8041=>759,8042=>980,8043=>985,8044=>851,8045=>875,8046=>829,
8047=>857,8048=>593,8049=>593,8050=>486,8051=>493,8052=>570,8053=>589,8054=>304,8055=>304,8056=>550,
8057=>550,8058=>521,8059=>521,8060=>753,8061=>753,8064=>593,8065=>593,8066=>593,8067=>593,8068=>593,
8069=>593,8070=>593,8071=>593,8072=>615,8073=>615,8074=>790,8075=>790,8076=>692,8077=>721,8078=>637,
8079=>668,8080=>570,8081=>570,8082=>570,8083=>570,8084=>570,8085=>570,8086=>570,8087=>570,8088=>753,
8089=>751,8090=>977,8091=>980,8092=>924,8093=>945,8094=>840,8095=>852,8096=>753,8097=>753,8098=>753,
8099=>753,8100=>753,8101=>753,8102=>753,8103=>753,8104=>722,8105=>759,8106=>980,8107=>985,8108=>851,
8109=>875,8110=>829,8111=>857,8112=>593,8113=>593,8114=>593,8115=>593,8116=>593,8118=>593,8119=>593,
8120=>615,8121=>615,8122=>645,8123=>623,8124=>615,8125=>450,8126=>450,8127=>450,8128=>450,8129=>450,
8130=>570,8131=>570,8132=>589,8134=>570,8135=>570,8136=>724,8137=>671,8138=>837,8139=>784,8140=>677,
8141=>450,8142=>450,8143=>450,8144=>304,8145=>304,8146=>304,8147=>304,8150=>304,8151=>304,8152=>265,
8153=>265,8154=>427,8155=>367,8157=>450,8158=>450,8159=>450,8160=>521,8161=>521,8162=>521,8163=>521,
8164=>571,8165=>571,8166=>521,8167=>521,8168=>549,8169=>549,8170=>760,8171=>742,8172=>616,8173=>450,
8174=>450,8175=>450,8178=>753,8179=>753,8180=>753,8182=>753,8183=>753,8184=>847,8185=>731,8186=>830,
8187=>743,8188=>688,8189=>450,8190=>450,8192=>450,8193=>900,8194=>450,8195=>900,8196=>296,8197=>225,
8198=>150,8199=>572,8200=>286,8201=>180,8202=>89,8203=>0,8204=>0,8205=>0,8206=>0,8207=>0,
8208=>325,8209=>325,8210=>572,8213=>900,8214=>450,8215=>450,8219=>286,8223=>466,8227=>531,8228=>301,
8229=>601,8231=>286,8234=>0,8235=>0,8236=>0,8237=>0,8238=>0,8239=>180,8241=>1562,8242=>204,
8243=>336,8244=>468,8245=>204,8246=>336,8247=>468,8248=>305,8251=>754,8252=>437,8253=>478,8254=>450,
8255=>723,8256=>723,8257=>225,8258=>900,8259=>450,8260=>150,8261=>351,8262=>351,8263=>830,8264=>659,
8265=>659,8266=>447,8267=>572,8268=>450,8269=>450,8270=>450,8271=>303,8272=>723,8273=>450,8274=>404,
8275=>900,8276=>723,8277=>754,8278=>527,8279=>597,8280=>754,8281=>754,8282=>286,8283=>717,8284=>754,
8285=>286,8286=>286,8287=>200,8288=>0,8289=>0,8290=>0,8291=>0,8292=>0,8298=>0,8299=>0,
8300=>0,8301=>0,8302=>0,8303=>0,8304=>360,8305=>161,8308=>360,8309=>360,8310=>360,8311=>360,
8312=>360,8313=>360,8314=>475,8315=>475,8316=>475,8317=>221,8318=>221,8319=>358,8320=>360,8321=>360,
8322=>360,8323=>360,8324=>360,8325=>360,8326=>360,8327=>360,8328=>360,8329=>360,8330=>475,8331=>475,
8332=>475,8333=>221,8334=>221,8336=>352,8337=>375,8338=>372,8339=>399,8340=>375,8352=>789,8353=>572,
8354=>572,8355=>572,8356=>572,8357=>876,8358=>673,8359=>1145,8360=>966,8361=>890,8362=>706,8363=>571,
8365=>572,8366=>572,8367=>1145,8368=>572,8369=>572,8370=>572,8371=>572,8372=>696,8373=>577,8400=>0,
8401=>0,8406=>0,8407=>0,8411=>0,8412=>0,8417=>0,8448=>917,8449=>917,8450=>628,8451=>1011,
8452=>578,8453=>917,8454=>960,8455=>553,8456=>628,8457=>856,8459=>889,8460=>679,8461=>765,8462=>570,
8463=>570,8464=>422,8465=>627,8466=>648,8467=>372,8468=>736,8469=>721,8470=>936,8471=>900,8472=>627,
8473=>631,8474=>708,8475=>718,8476=>732,8477=>712,8478=>807,8479=>615,8480=>917,8481=>967,8483=>615,
8484=>670,8485=>520,8486=>688,8487=>688,8488=>554,8489=>304,8490=>590,8491=>615,8492=>708,8493=>633,
8494=>769,8495=>532,8496=>545,8497=>708,8498=>518,8499=>962,8500=>416,8501=>670,8502=>606,8503=>419,
8504=>580,8505=>342,8506=>833,8507=>1074,8508=>632,8509=>655,8510=>589,8511=>764,8512=>729,8513=>697,
8514=>501,8515=>501,8516=>549,8517=>737,8518=>637,8519=>554,8520=>316,8521=>316,8523=>702,8526=>474,
8531=>872,8532=>872,8533=>872,8534=>872,8535=>872,8536=>872,8537=>872,8538=>872,8539=>872,8540=>872,
8541=>872,8542=>872,8543=>511,8544=>265,8545=>443,8546=>620,8547=>831,8548=>615,8549=>830,8550=>1007,
8551=>1185,8552=>826,8553=>616,8554=>839,8555=>1018,8556=>501,8557=>628,8558=>693,8559=>776,8560=>250,
8561=>412,8562=>573,8563=>730,8564=>532,8565=>729,8566=>892,8567=>1053,8568=>737,8569=>532,8570=>740,
8571=>901,8572=>250,8573=>495,8574=>571,8575=>876,8576=>1121,8577=>693,8578=>1121,8579=>633,8580=>494,
8592=>754,8593=>754,8594=>754,8595=>754,8596=>754,8597=>754,8598=>754,8599=>754,8600=>754,8601=>754,
8602=>754,8603=>754,8604=>754,8605=>754,8606=>754,8607=>754,8608=>754,8609=>754,8610=>754,8611=>754,
8612=>754,8613=>754,8614=>754,8615=>754,8616=>754,8617=>754,8618=>754,8619=>754,8620=>754,8621=>754,
8622=>754,8623=>754,8624=>754,8625=>754,8626=>754,8627=>754,8628=>754,8629=>754,8630=>754,8631=>754,
8632=>754,8633=>754,8634=>754,8635=>754,8636=>754,8637=>754,8638=>754,8639=>754,8640=>754,8641=>754,
8642=>754,8643=>754,8644=>754,8645=>754,8646=>754,8647=>754,8648=>754,8649=>754,8650=>754,8651=>754,
8652=>754,8653=>754,8654=>754,8655=>754,8656=>754,8657=>754,8658=>754,8659=>754,8660=>754,8661=>754,
8662=>754,8663=>754,8664=>754,8665=>754,8666=>754,8667=>754,8668=>754,8669=>754,8670=>754,8671=>754,
8672=>754,8673=>754,8674=>754,8675=>754,8676=>754,8677=>754,8678=>754,8679=>754,8680=>754,8681=>754,
8682=>754,8683=>754,8684=>754,8685=>754,8686=>754,8687=>754,8688=>754,8689=>754,8690=>754,8691=>754,
8692=>754,8693=>754,8694=>754,8695=>754,8696=>754,8697=>754,8698=>754,8699=>754,8700=>754,8701=>754,
8702=>754,8703=>754,8704=>615,8705=>572,8706=>465,8707=>568,8708=>568,8709=>784,8710=>602,8711=>602,
8712=>784,8713=>784,8714=>646,8715=>784,8716=>784,8717=>646,8718=>572,8719=>681,8720=>681,8721=>606,
8722=>754,8723=>754,8724=>754,8725=>303,8726=>573,8727=>754,8728=>563,8729=>563,8730=>573,8731=>573,
8732=>573,8733=>643,8734=>750,8735=>754,8736=>807,8737=>807,8738=>754,8739=>450,8740=>450,8741=>450,
8742=>450,8743=>659,8744=>659,8745=>659,8746=>659,8747=>469,8748=>710,8749=>951,8750=>469,8751=>710,
8752=>951,8753=>469,8754=>469,8755=>469,8756=>572,8757=>572,8758=>234,8759=>572,8760=>754,8761=>754,
8762=>754,8763=>754,8764=>754,8765=>754,8766=>754,8767=>754,8768=>337,8769=>754,8770=>754,8771=>754,
8772=>754,8773=>754,8774=>754,8775=>754,8776=>754,8777=>754,8778=>754,8779=>754,8780=>754,8781=>754,
8782=>754,8783=>754,8784=>754,8785=>754,8786=>755,8787=>755,8788=>900,8789=>900,8790=>754,8791=>754,
8792=>754,8793=>754,8794=>754,8795=>754,8796=>754,8797=>754,8798=>754,8799=>754,8800=>754,8801=>754,
8802=>754,8803=>754,8804=>754,8805=>754,8806=>754,8807=>754,8808=>754,8809=>754,8810=>942,8811=>942,
8812=>417,8813=>754,8814=>754,8815=>754,8816=>754,8817=>754,8818=>754,8819=>754,8820=>754,8821=>754,
8822=>754,8823=>754,8824=>754,8825=>754,8826=>754,8827=>754,8828=>754,8829=>754,8830=>754,8831=>754,
8832=>754,8833=>754,8834=>754,8835=>754,8836=>754,8837=>754,8838=>754,8839=>754,8840=>754,8841=>754,
8842=>754,8843=>754,8844=>659,8845=>659,8846=>659,8847=>754,8848=>754,8849=>754,8850=>754,8851=>702,
8852=>702,8853=>754,8854=>754,8855=>754,8856=>754,8857=>754,8858=>754,8859=>754,8860=>754,8861=>754,
8862=>754,8863=>754,8864=>754,8865=>754,8866=>784,8867=>784,8868=>784,8869=>784,8870=>468,8871=>468,
8872=>784,8873=>784,8874=>784,8875=>784,8876=>784,8877=>784,8878=>784,8879=>784,8880=>754,8881=>754,
8882=>754,8883=>754,8884=>754,8885=>754,8886=>900,8887=>900,8888=>754,8889=>754,8890=>468,8891=>659,
8892=>659,8893=>659,8894=>754,8895=>754,8896=>738,8897=>738,8898=>738,8899=>738,8900=>444,8901=>286,
8902=>563,8903=>754,8904=>900,8905=>900,8906=>900,8907=>900,8908=>900,8909=>754,8910=>659,8911=>659,
8912=>754,8913=>754,8914=>754,8915=>754,8916=>754,8917=>754,8918=>754,8919=>754,8920=>1280,8921=>1280,
8922=>754,8923=>754,8924=>754,8925=>754,8926=>754,8927=>754,8928=>754,8929=>754,8930=>754,8931=>754,
8932=>754,8933=>754,8934=>754,8935=>754,8936=>754,8937=>754,8938=>754,8939=>754,8940=>754,8941=>754,
8942=>900,8943=>900,8944=>900,8945=>900,8946=>900,8947=>784,8948=>646,8949=>784,8950=>784,8951=>646,
8952=>784,8953=>784,8954=>900,8955=>784,8956=>646,8957=>784,8958=>646,8959=>784,8960=>542,8961=>542,
8962=>571,8963=>754,8964=>754,8965=>754,8966=>754,8967=>439,8968=>351,8969=>351,8970=>351,8971=>351,
8972=>728,8973=>728,8974=>728,8975=>728,8976=>754,8977=>461,8984=>900,8985=>754,8988=>422,8989=>422,
8990=>422,8991=>422,8992=>469,8993=>469,8996=>1037,8997=>1037,8998=>1272,8999=>1037,9000=>1299,9003=>1272,
9004=>786,9075=>304,9076=>571,9077=>753,9082=>593,9085=>681,9095=>1037,9108=>786,9115=>450,9116=>450,
9117=>450,9118=>450,9119=>450,9120=>450,9121=>450,9122=>450,9123=>450,9124=>450,9125=>450,9126=>450,
9127=>675,9128=>675,9129=>675,9130=>675,9131=>675,9132=>675,9133=>675,9134=>469,9166=>754,9167=>850,
9187=>786,9189=>692,9250=>571,9251=>571,9312=>807,9313=>807,9314=>807,9315=>807,9316=>807,9317=>807,
9318=>807,9319=>807,9320=>807,9321=>807,9472=>542,9473=>542,9474=>542,9475=>542,9476=>542,9477=>542,
9478=>542,9479=>542,9480=>542,9481=>542,9482=>542,9483=>542,9484=>542,9485=>542,9486=>542,9487=>542,
9488=>542,9489=>542,9490=>542,9491=>542,9492=>542,9493=>542,9494=>542,9495=>542,9496=>542,9497=>542,
9498=>542,9499=>542,9500=>542,9501=>542,9502=>542,9503=>542,9504=>542,9505=>542,9506=>542,9507=>542,
9508=>542,9509=>542,9510=>542,9511=>542,9512=>542,9513=>542,9514=>542,9515=>542,9516=>542,9517=>542,
9518=>542,9519=>542,9520=>542,9521=>542,9522=>542,9523=>542,9524=>542,9525=>542,9526=>542,9527=>542,
9528=>542,9529=>542,9530=>542,9531=>542,9532=>542,9533=>542,9534=>542,9535=>542,9536=>542,9537=>542,
9538=>542,9539=>542,9540=>542,9541=>542,9542=>542,9543=>542,9544=>542,9545=>542,9546=>542,9547=>542,
9548=>542,9549=>542,9550=>542,9551=>542,9552=>542,9553=>542,9554=>542,9555=>542,9556=>542,9557=>542,
9558=>542,9559=>542,9560=>542,9561=>542,9562=>542,9563=>542,9564=>542,9565=>542,9566=>542,9567=>542,
9568=>542,9569=>542,9570=>542,9571=>542,9572=>542,9573=>542,9574=>542,9575=>542,9576=>542,9577=>542,
9578=>542,9579=>542,9580=>542,9581=>542,9582=>542,9583=>542,9584=>542,9585=>542,9586=>542,9587=>542,
9588=>542,9589=>542,9590=>542,9591=>542,9592=>542,9593=>542,9594=>542,9595=>542,9596=>542,9597=>542,
9598=>542,9599=>542,9600=>692,9601=>692,9602=>692,9603=>692,9604=>692,9605=>692,9606=>692,9607=>692,
9608=>692,9609=>692,9610=>692,9611=>692,9612=>692,9613=>692,9614=>692,9615=>692,9616=>692,9617=>692,
9618=>692,9619=>692,9620=>692,9621=>692,9622=>692,9623=>692,9624=>692,9625=>692,9626=>692,9627=>692,
9628=>692,9629=>692,9630=>692,9631=>692,9632=>850,9633=>850,9634=>850,9635=>850,9636=>850,9637=>850,
9638=>850,9639=>850,9640=>850,9641=>850,9642=>610,9643=>610,9644=>850,9645=>850,9646=>495,9647=>495,
9648=>692,9649=>692,9650=>692,9651=>692,9652=>452,9653=>452,9654=>692,9655=>692,9656=>452,9657=>452,
9658=>692,9659=>692,9660=>692,9661=>692,9662=>452,9663=>452,9664=>692,9665=>692,9666=>452,9667=>452,
9668=>692,9669=>692,9670=>692,9671=>692,9672=>692,9673=>785,9674=>444,9675=>785,9676=>785,9677=>785,
9678=>785,9679=>785,9680=>785,9681=>785,9682=>785,9683=>785,9684=>785,9685=>785,9686=>474,9687=>474,
9688=>712,9689=>873,9690=>873,9691=>873,9692=>348,9693=>348,9694=>348,9695=>348,9696=>785,9697=>785,
9698=>692,9699=>692,9700=>692,9701=>692,9702=>531,9703=>850,9704=>850,9705=>850,9706=>850,9707=>850,
9708=>692,9709=>692,9710=>692,9711=>1007,9712=>850,9713=>850,9714=>850,9715=>850,9716=>785,9717=>785,
9718=>785,9719=>785,9720=>692,9721=>692,9722=>692,9723=>747,9724=>747,9725=>659,9726=>659,9727=>692,
9728=>807,9729=>900,9730=>807,9731=>807,9732=>807,9733=>807,9734=>807,9735=>515,9736=>806,9737=>807,
9738=>799,9739=>799,9740=>604,9741=>911,9742=>1121,9743=>1125,9744=>807,9745=>807,9746=>807,9747=>479,
9748=>807,9749=>807,9750=>807,9751=>807,9752=>807,9753=>807,9754=>807,9755=>807,9756=>807,9757=>548,
9758=>807,9759=>548,9760=>807,9761=>807,9762=>807,9763=>807,9764=>602,9765=>671,9766=>584,9767=>705,
9768=>490,9769=>807,9770=>807,9771=>807,9772=>639,9773=>807,9774=>807,9775=>807,9776=>807,9777=>807,
9778=>807,9779=>807,9780=>807,9781=>807,9782=>807,9783=>807,9784=>807,9785=>807,9786=>807,9787=>807,
9788=>807,9789=>807,9790=>807,9791=>552,9792=>658,9793=>658,9794=>807,9795=>807,9796=>807,9797=>807,
9798=>807,9799=>807,9800=>807,9801=>807,9802=>807,9803=>807,9804=>807,9805=>807,9806=>807,9807=>807,
9808=>807,9809=>807,9810=>807,9811=>807,9812=>807,9813=>807,9814=>807,9815=>807,9816=>807,9817=>807,
9818=>807,9819=>807,9820=>807,9821=>807,9822=>807,9823=>807,9824=>807,9825=>807,9826=>807,9827=>807,
9828=>807,9829=>807,9830=>807,9831=>807,9832=>807,9833=>424,9834=>574,9835=>807,9836=>807,9837=>424,
9838=>321,9839=>435,9840=>673,9841=>689,9842=>807,9843=>807,9844=>807,9845=>807,9846=>807,9847=>807,
9848=>807,9849=>807,9850=>807,9851=>807,9852=>807,9853=>807,9854=>807,9855=>807,9856=>782,9857=>782,
9858=>782,9859=>782,9860=>782,9861=>782,9862=>807,9863=>807,9864=>807,9865=>807,9866=>807,9867=>807,
9868=>807,9869=>807,9870=>807,9871=>807,9872=>807,9873=>807,9874=>807,9875=>807,9876=>807,9877=>487,
9878=>807,9879=>807,9880=>807,9881=>807,9882=>807,9883=>807,9884=>807,9888=>807,9889=>632,9890=>903,
9891=>977,9892=>1028,9893=>811,9894=>754,9895=>754,9896=>754,9897=>754,9898=>754,9899=>754,9900=>754,
9901=>754,9902=>754,9903=>754,9904=>759,9905=>754,9906=>658,9907=>659,9908=>659,9909=>659,9910=>765,
9911=>659,9912=>659,9985=>754,9986=>754,9987=>754,9988=>754,9990=>754,9991=>754,9992=>754,9993=>754,
9996=>754,9997=>754,9998=>754,9999=>754,10000=>754,10001=>754,10002=>754,10003=>754,10004=>754,10005=>754,
10006=>754,10007=>754,10008=>754,10009=>754,10010=>754,10011=>754,10012=>754,10013=>754,10014=>754,10015=>754,
10016=>754,10017=>754,10018=>754,10019=>754,10020=>754,10021=>754,10022=>754,10023=>754,10025=>754,10026=>754,
10027=>754,10028=>754,10029=>754,10030=>754,10031=>754,10032=>754,10033=>754,10034=>754,10035=>754,10036=>754,
10037=>754,10038=>754,10039=>754,10040=>754,10041=>754,10042=>754,10043=>754,10044=>754,10045=>754,10046=>754,
10047=>754,10048=>754,10049=>754,10050=>754,10051=>754,10052=>754,10053=>754,10054=>754,10055=>754,10056=>754,
10057=>754,10058=>754,10059=>754,10061=>807,10063=>807,10064=>807,10065=>807,10066=>807,10070=>807,10072=>754,
10073=>754,10074=>754,10075=>290,10076=>290,10077=>484,10078=>484,10081=>754,10082=>754,10083=>754,10084=>754,
10085=>754,10086=>754,10087=>754,10088=>754,10089=>754,10090=>754,10091=>754,10092=>754,10093=>754,10094=>754,
10095=>754,10096=>754,10097=>754,10098=>754,10099=>754,10100=>754,10101=>754,10102=>807,10103=>807,10104=>807,
10105=>807,10106=>807,10107=>807,10108=>807,10109=>807,10110=>807,10111=>807,10112=>754,10113=>754,10114=>754,
10115=>754,10116=>754,10117=>754,10118=>754,10119=>754,10120=>754,10121=>754,10122=>754,10123=>754,10124=>754,
10125=>754,10126=>754,10127=>754,10128=>754,10129=>754,10130=>754,10131=>754,10132=>754,10136=>754,10137=>754,
10138=>754,10139=>754,10140=>754,10141=>754,10142=>754,10143=>754,10144=>754,10145=>754,10146=>754,10147=>754,
10148=>754,10149=>754,10150=>754,10151=>754,10152=>754,10153=>754,10154=>754,10155=>754,10156=>754,10157=>754,
10158=>754,10159=>754,10161=>754,10162=>754,10163=>754,10164=>754,10165=>754,10166=>754,10167=>754,10168=>754,
10169=>754,10170=>754,10171=>754,10172=>754,10173=>754,10174=>754,10181=>351,10182=>351,10208=>444,10214=>445,
10215=>445,10216=>351,10217=>351,10218=>500,10219=>500,10224=>754,10225=>754,10226=>754,10227=>754,10228=>1042,
10229=>1290,10230=>1290,10231=>1290,10232=>1290,10233=>1290,10234=>1290,10235=>1290,10236=>1290,10237=>1290,10238=>1290,
10239=>1290,10240=>659,10241=>659,10242=>659,10243=>659,10244=>659,10245=>659,10246=>659,10247=>659,10248=>659,
10249=>659,10250=>659,10251=>659,10252=>659,10253=>659,10254=>659,10255=>659,10256=>659,10257=>659,10258=>659,
10259=>659,10260=>659,10261=>659,10262=>659,10263=>659,10264=>659,10265=>659,10266=>659,10267=>659,10268=>659,
10269=>659,10270=>659,10271=>659,10272=>659,10273=>659,10274=>659,10275=>659,10276=>659,10277=>659,10278=>659,
10279=>659,10280=>659,10281=>659,10282=>659,10283=>659,10284=>659,10285=>659,10286=>659,10287=>659,10288=>659,
10289=>659,10290=>659,10291=>659,10292=>659,10293=>659,10294=>659,10295=>659,10296=>659,10297=>659,10298=>659,
10299=>659,10300=>659,10301=>659,10302=>659,10303=>659,10304=>659,10305=>659,10306=>659,10307=>659,10308=>659,
10309=>659,10310=>659,10311=>659,10312=>659,10313=>659,10314=>659,10315=>659,10316=>659,10317=>659,10318=>659,
10319=>659,10320=>659,10321=>659,10322=>659,10323=>659,10324=>659,10325=>659,10326=>659,10327=>659,10328=>659,
10329=>659,10330=>659,10331=>659,10332=>659,10333=>659,10334=>659,10335=>659,10336=>659,10337=>659,10338=>659,
10339=>659,10340=>659,10341=>659,10342=>659,10343=>659,10344=>659,10345=>659,10346=>659,10347=>659,10348=>659,
10349=>659,10350=>659,10351=>659,10352=>659,10353=>659,10354=>659,10355=>659,10356=>659,10357=>659,10358=>659,
10359=>659,10360=>659,10361=>659,10362=>659,10363=>659,10364=>659,10365=>659,10366=>659,10367=>659,10368=>659,
10369=>659,10370=>659,10371=>659,10372=>659,10373=>659,10374=>659,10375=>659,10376=>659,10377=>659,10378=>659,
10379=>659,10380=>659,10381=>659,10382=>659,10383=>659,10384=>659,10385=>659,10386=>659,10387=>659,10388=>659,
10389=>659,10390=>659,10391=>659,10392=>659,10393=>659,10394=>659,10395=>659,10396=>659,10397=>659,10398=>659,
10399=>659,10400=>659,10401=>659,10402=>659,10403=>659,10404=>659,10405=>659,10406=>659,10407=>659,10408=>659,
10409=>659,10410=>659,10411=>659,10412=>659,10413=>659,10414=>659,10415=>659,10416=>659,10417=>659,10418=>659,
10419=>659,10420=>659,10421=>659,10422=>659,10423=>659,10424=>659,10425=>659,10426=>659,10427=>659,10428=>659,
10429=>659,10430=>659,10431=>659,10432=>659,10433=>659,10434=>659,10435=>659,10436=>659,10437=>659,10438=>659,
10439=>659,10440=>659,10441=>659,10442=>659,10443=>659,10444=>659,10445=>659,10446=>659,10447=>659,10448=>659,
10449=>659,10450=>659,10451=>659,10452=>659,10453=>659,10454=>659,10455=>659,10456=>659,10457=>659,10458=>659,
10459=>659,10460=>659,10461=>659,10462=>659,10463=>659,10464=>659,10465=>659,10466=>659,10467=>659,10468=>659,
10469=>659,10470=>659,10471=>659,10472=>659,10473=>659,10474=>659,10475=>659,10476=>659,10477=>659,10478=>659,
10479=>659,10480=>659,10481=>659,10482=>659,10483=>659,10484=>659,10485=>659,10486=>659,10487=>659,10488=>659,
10489=>659,10490=>659,10491=>659,10492=>659,10493=>659,10494=>659,10495=>659,10502=>754,10503=>754,10506=>754,
10507=>754,10560=>615,10561=>615,10627=>660,10628=>660,10702=>754,10703=>900,10704=>900,10705=>900,10706=>900,
10707=>900,10708=>900,10709=>900,10731=>444,10746=>754,10747=>754,10752=>900,10753=>900,10754=>900,10764=>1192,
10765=>469,10766=>469,10767=>469,10768=>469,10769=>469,10770=>469,10771=>469,10772=>469,10773=>469,10774=>469,
10775=>469,10776=>469,10777=>469,10778=>469,10779=>469,10780=>469,10799=>754,10877=>754,10878=>754,10879=>754,
10880=>754,10881=>754,10882=>754,10883=>754,10884=>754,10885=>754,10886=>754,10887=>754,10888=>754,10889=>754,
10890=>754,10891=>754,10892=>754,10893=>754,10894=>754,10895=>754,10896=>754,10897=>754,10898=>754,10899=>754,
10900=>754,10901=>754,10902=>754,10903=>754,10904=>754,10905=>754,10906=>754,10907=>754,10908=>754,10909=>754,
10910=>754,10911=>754,10912=>754,10926=>754,10927=>754,10928=>754,10929=>754,10930=>754,10931=>754,10932=>754,
10933=>754,10934=>754,10935=>754,10936=>754,10937=>754,10938=>754,11001=>754,11002=>754,11008=>754,11009=>754,
11010=>754,11011=>754,11012=>754,11013=>754,11014=>754,11015=>754,11016=>754,11017=>754,11018=>754,11019=>754,
11020=>754,11021=>754,11022=>752,11023=>752,11024=>752,11025=>752,11026=>850,11027=>850,11028=>850,11029=>850,
11030=>692,11031=>692,11032=>692,11033=>692,11034=>850,11039=>782,11040=>782,11041=>786,11042=>786,11043=>786,
11044=>1007,11091=>782,11092=>782,11360=>501,11361=>250,11362=>501,11363=>542,11364=>625,11365=>551,11366=>353,
11367=>677,11368=>570,11369=>590,11370=>521,11371=>616,11372=>472,11373=>703,11374=>776,11375=>615,11377=>661,
11378=>1015,11379=>865,11380=>532,11381=>589,11382=>511,11383=>593,11385=>373,11386=>550,11387=>441,11388=>157,
11389=>387,11568=>582,11569=>799,11570=>799,11571=>614,11572=>615,11573=>571,11574=>505,11575=>615,11576=>615,
11577=>568,11578=>568,11579=>614,11580=>787,11581=>616,11582=>441,11583=>616,11584=>799,11585=>799,11586=>270,
11587=>564,11588=>677,11589=>590,11590=>475,11591=>616,11592=>580,11593=>568,11594=>452,11595=>857,11596=>700,
11597=>673,11598=>558,11599=>265,11600=>700,11601=>265,11602=>677,11603=>569,11604=>799,11605=>799,11606=>677,
11607=>288,11608=>674,11609=>799,11610=>799,11611=>628,11612=>690,11613=>616,11614=>628,11615=>560,11616=>615,
11617=>677,11618=>568,11619=>709,11620=>510,11621=>709,11631=>463,11800=>478,11810=>351,11811=>351,11812=>351,
11813=>351,11822=>478,19904=>807,19905=>807,19906=>807,19907=>807,19908=>807,19909=>807,19910=>807,19911=>807,
19912=>807,19913=>807,19914=>807,19915=>807,19916=>807,19917=>807,19918=>807,19919=>807,19920=>807,19921=>807,
19922=>807,19923=>807,19924=>807,19925=>807,19926=>807,19927=>807,19928=>807,19929=>807,19930=>807,19931=>807,
19932=>807,19933=>807,19934=>807,19935=>807,19936=>807,19937=>807,19938=>807,19939=>807,19940=>807,19941=>807,
19942=>807,19943=>807,19944=>807,19945=>807,19946=>807,19947=>807,19948=>807,19949=>807,19950=>807,19951=>807,
19952=>807,19953=>807,19954=>807,19955=>807,19956=>807,19957=>807,19958=>807,19959=>807,19960=>807,19961=>807,
19962=>807,19963=>807,19964=>807,19965=>807,19966=>807,19967=>807,42564=>571,42565=>469,42566=>318,42567=>304,
42572=>1062,42573=>925,42576=>926,42577=>815,42580=>971,42581=>757,42582=>879,42583=>758,42594=>956,42595=>820,
42596=>959,42597=>811,42598=>1060,42599=>907,42600=>708,42601=>550,42602=>770,42603=>641,42604=>1222,42605=>917,
42606=>791,42634=>704,42635=>616,42636=>549,42637=>524,42644=>617,42645=>570,42760=>444,42761=>444,42762=>444,
42763=>444,42764=>444,42765=>444,42766=>444,42767=>444,42768=>444,42769=>444,42770=>444,42771=>444,42772=>444,
42773=>444,42774=>444,42779=>332,42780=>332,42781=>227,42782=>227,42783=>227,42790=>677,42791=>570,42792=>790,
42793=>638,42794=>553,42795=>486,42800=>441,42801=>469,42802=>1125,42803=>886,42804=>1083,42805=>891,42806=>1028,
42807=>883,42808=>874,42809=>736,42810=>874,42811=>736,42812=>863,42813=>736,42814=>633,42815=>494,42822=>612,
42823=>353,42824=>523,42825=>384,42826=>726,42827=>633,42830=>1222,42831=>917,42880=>501,42881=>250,42882=>662,
42883=>570,42889=>303,42890=>338,42891=>360,42892=>247,43003=>518,43004=>542,43005=>776,43006=>265,43007=>1079,
61440=>879,61441=>879,63173=>550,64256=>620,64257=>567,64258=>567,64259=>870,64260=>870,64261=>617,64262=>774,
64275=>1081,64276=>1081,64277=>1076,64278=>1067,64279=>1376,64285=>245,64286=>0,64287=>423,64288=>572,64289=>770,
64290=>696,64291=>815,64292=>694,64293=>759,64294=>769,64295=>726,64296=>788,64297=>754,64298=>727,64299=>727,
64300=>727,64301=>727,64302=>566,64303=>566,64304=>566,64305=>547,64306=>403,64307=>534,64308=>576,64309=>245,
64310=>336,64312=>583,64313=>302,64314=>532,64315=>500,64316=>539,64318=>593,64320=>397,64321=>629,64323=>576,
64324=>543,64326=>523,64327=>596,64328=>532,64329=>727,64330=>591,64331=>245,64332=>547,64333=>500,64334=>543,
64335=>566,64338=>847,64339=>883,64340=>250,64341=>271,64342=>847,64343=>883,64344=>250,64345=>271,64346=>847,
64347=>883,64348=>250,64349=>271,64350=>847,64351=>883,64352=>250,64353=>271,64354=>847,64355=>883,64356=>250,
64357=>271,64358=>847,64359=>883,64360=>250,64361=>271,64362=>933,64363=>932,64364=>430,64365=>455,64366=>933,
64367=>932,64368=>430,64369=>455,64370=>581,64371=>581,64372=>556,64373=>581,64374=>581,64375=>581,64376=>556,
64377=>581,64378=>581,64379=>581,64380=>556,64381=>581,64382=>581,64383=>581,64384=>556,64385=>581,64394=>435,
64395=>497,64396=>435,64397=>497,64398=>805,64399=>805,64400=>428,64401=>497,64402=>805,64403=>805,64404=>428,
64405=>497,64414=>661,64415=>685,64473=>435,64474=>465,64488=>250,64489=>271,64508=>704,64509=>750,64510=>250,
64511=>271,65024=>0,65025=>0,65026=>0,65027=>0,65028=>0,65029=>0,65030=>0,65031=>0,65032=>0,
65033=>0,65034=>0,65035=>0,65036=>0,65037=>0,65038=>0,65039=>0,65056=>0,65057=>0,65058=>0,
65059=>0,65136=>264,65137=>264,65138=>264,65139=>235,65140=>264,65142=>264,65143=>264,65144=>264,65145=>264,
65146=>264,65147=>264,65148=>264,65149=>264,65150=>264,65151=>264,65152=>423,65153=>250,65154=>274,65155=>250,
65156=>274,65157=>435,65158=>465,65159=>250,65160=>274,65161=>704,65162=>750,65163=>250,65164=>271,65165=>250,
65166=>274,65167=>847,65168=>883,65169=>250,65170=>271,65171=>471,65172=>482,65173=>847,65174=>883,65175=>250,
65176=>271,65177=>847,65178=>883,65179=>250,65180=>271,65181=>581,65182=>581,65183=>556,65184=>581,65185=>581,
65186=>581,65187=>556,65188=>581,65189=>581,65190=>581,65191=>556,65192=>581,65193=>400,65194=>472,65195=>400,
65196=>472,65197=>435,65198=>497,65199=>435,65200=>497,65201=>1099,65202=>1147,65203=>754,65204=>803,65205=>1099,
65206=>1147,65207=>754,65208=>803,65209=>1088,65210=>1103,65211=>764,65212=>780,65213=>1088,65214=>1103,65215=>764,
65216=>780,65217=>832,65218=>854,65219=>716,65220=>738,65221=>832,65222=>854,65223=>716,65224=>738,65225=>537,
65226=>479,65227=>537,65228=>434,65229=>537,65230=>479,65231=>470,65232=>434,65233=>933,65234=>932,65235=>430,
65236=>455,65237=>698,65238=>750,65239=>430,65240=>455,65241=>742,65242=>758,65243=>428,65244=>497,65245=>654,
65246=>681,65247=>274,65248=>298,65249=>557,65250=>599,65251=>482,65252=>520,65253=>661,65254=>685,65255=>250,
65256=>271,65257=>471,65258=>482,65259=>475,65260=>415,65261=>435,65262=>465,65263=>704,65264=>750,65265=>704,
65266=>750,65267=>250,65268=>271,65269=>513,65270=>537,65271=>513,65272=>537,65273=>513,65274=>537,65275=>513,
65276=>537,65279=>0,65529=>0,65530=>0,65531=>0,65532=>0,65533=>923);
$enc='';
$diff='';
$file='dejavusanscondensed.z';
$ctg='dejavusanscondensed.ctg.z';
$originalsize=544636;
// --- EOF ---
| zysms | trunk/zysms/customer/PHPExcel/Shared/PDF/fonts/dejavusanscondensed.php | PHP | asf20 | 50,984 |