PSR2 Fixes

This commit is contained in:
Progi1984 2015-05-16 23:09:31 +02:00
parent f827a25af2
commit 082fb1b475
23 changed files with 429 additions and 421 deletions

View File

@ -38,58 +38,155 @@ class PHPExcel_Shared_CodePage
public static function NumberToName($codePage = 1252) public static function NumberToName($codePage = 1252)
{ {
switch ($codePage) { switch ($codePage) {
case 367: return 'ASCII'; break; // ASCII case 367:
case 437: return 'CP437'; break; // OEM US return 'ASCII';
case 720: throw new PHPExcel_Exception('Code page 720 not supported.'); break; // ASCII
break; // OEM Arabic case 437:
case 737: return 'CP737'; break; // OEM Greek return 'CP437';
case 775: return 'CP775'; break; // OEM Baltic break; // OEM US
case 850: return 'CP850'; break; // OEM Latin I case 720:
case 852: return 'CP852'; break; // OEM Latin II (Central European) throw new PHPExcel_Exception('Code page 720 not supported.');
case 855: return 'CP855'; break; // OEM Cyrillic break; // OEM Arabic
case 857: return 'CP857'; break; // OEM Turkish case 737:
case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro return 'CP737';
case 860: return 'CP860'; break; // OEM Portugese break; // OEM Greek
case 861: return 'CP861'; break; // OEM Icelandic case 775:
case 862: return 'CP862'; break; // OEM Hebrew return 'CP775';
case 863: return 'CP863'; break; // OEM Canadian (French) break; // OEM Baltic
case 864: return 'CP864'; break; // OEM Arabic case 850:
case 865: return 'CP865'; break; // OEM Nordic return 'CP850';
case 866: return 'CP866'; break; // OEM Cyrillic (Russian) break; // OEM Latin I
case 869: return 'CP869'; break; // OEM Greek (Modern) case 852:
case 874: return 'CP874'; break; // ANSI Thai return 'CP852';
case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS break; // OEM Latin II (Central European)
case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK case 855:
case 949: return 'CP949'; break; // ANSI Korean (Wansung) return 'CP855';
case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5 break; // OEM Cyrillic
case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8) case 857:
case 1250: return 'CP1250'; break; // ANSI Latin II (Central European) return 'CP857';
case 1251: return 'CP1251'; break; // ANSI Cyrillic break; // OEM Turkish
case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program case 858:
case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7) return 'CP858';
case 1253: return 'CP1253'; break; // ANSI Greek break; // OEM Multilingual Latin I with Euro
case 1254: return 'CP1254'; break; // ANSI Turkish case 860:
case 1255: return 'CP1255'; break; // ANSI Hebrew return 'CP860';
case 1256: return 'CP1256'; break; // ANSI Arabic break; // OEM Portugese
case 1257: return 'CP1257'; break; // ANSI Baltic case 861:
case 1258: return 'CP1258'; break; // ANSI Vietnamese return 'CP861';
case 1361: return 'CP1361'; break; // ANSI Korean (Johab) break; // OEM Icelandic
case 10000: return 'MAC'; break; // Apple Roman case 862:
case 10001: return 'CP932'; break; // Macintosh Japanese return 'CP862';
case 10002: return 'CP950'; break; // Macintosh Chinese Traditional break; // OEM Hebrew
case 10003: return 'CP1361'; break; // Macintosh Korean case 863:
case 10006: return 'MACGREEK'; break; // Macintosh Greek return 'CP863';
case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic break; // OEM Canadian (French)
case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312) case 864:
case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe return 'CP864';
case 10079: return 'MACICELAND'; break; // Macintosh Icelandic break; // OEM Arabic
case 10081: return 'MACTURKISH'; break; // Macintosh Turkish case 865:
case 21010: return 'UTF-16LE'; break; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE return 'CP865';
case 32768: return 'MAC'; break; // Apple Roman break; // OEM Nordic
case 32769: throw new PHPExcel_Exception('Code page 32769 not supported.'); case 866:
break; // ANSI Latin I (BIFF2-BIFF3) return 'CP866';
case 65000: return 'UTF-7'; break; // Unicode (UTF-7) break; // OEM Cyrillic (Russian)
case 65001: return 'UTF-8'; break; // Unicode (UTF-8) case 869:
return 'CP869';
break; // OEM Greek (Modern)
case 874:
return 'CP874';
break; // ANSI Thai
case 932:
return 'CP932';
break; // ANSI Japanese Shift-JIS
case 936:
return 'CP936';
break; // ANSI Chinese Simplified GBK
case 949:
return 'CP949';
break; // ANSI Korean (Wansung)
case 950:
return 'CP950';
break; // ANSI Chinese Traditional BIG5
case 1200:
return 'UTF-16LE';
break; // UTF-16 (BIFF8)
case 1250:
return 'CP1250';
break; // ANSI Latin II (Central European)
case 1251:
return 'CP1251';
break; // ANSI Cyrillic
case 0:
// CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
case 1252:
return 'CP1252';
break; // ANSI Latin I (BIFF4-BIFF7)
case 1253:
return 'CP1253';
break; // ANSI Greek
case 1254:
return 'CP1254';
break; // ANSI Turkish
case 1255:
return 'CP1255';
break; // ANSI Hebrew
case 1256:
return 'CP1256';
break; // ANSI Arabic
case 1257:
return 'CP1257';
break; // ANSI Baltic
case 1258:
return 'CP1258';
break; // ANSI Vietnamese
case 1361:
return 'CP1361';
break; // ANSI Korean (Johab)
case 10000:
return 'MAC';
break; // Apple Roman
case 10001:
return 'CP932';
break; // Macintosh Japanese
case 10002:
return 'CP950';
break; // Macintosh Chinese Traditional
case 10003:
return 'CP1361';
break; // Macintosh Korean
case 10006:
return 'MACGREEK';
break; // Macintosh Greek
case 10007:
return 'MACCYRILLIC';
break; // Macintosh Cyrillic
case 10008:
return 'CP936';
break; // Macintosh - Simplified Chinese (GB 2312)
case 10029:
return 'MACCENTRALEUROPE';
break; // Macintosh Central Europe
case 10079:
return 'MACICELAND';
break; // Macintosh Icelandic
case 10081:
return 'MACTURKISH';
break; // Macintosh Turkish
case 21010:
return 'UTF-16LE';
break; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
case 32768:
return 'MAC';
break; // Apple Roman
case 32769:
throw new PHPExcel_Exception('Code page 32769 not supported.');
break; // ANSI Latin I (BIFF2-BIFF3)
case 65000:
return 'UTF-7';
break; // Unicode (UTF-7)
case 65001:
return 'UTF-8';
break; // Unicode (UTF-8)
} }
throw new PHPExcel_Exception('Unknown codepage: ' . $codePage); throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
} }

View File

@ -184,13 +184,9 @@ class PHPExcel_Shared_Date
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
$retValue = false; $retValue = false;
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) { if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), $retValue = self::FormattedPHPToExcel($dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s'));
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
);
} elseif (is_numeric($dateValue)) { } elseif (is_numeric($dateValue)) {
$retValue = self::FormattedPHPToExcel( date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue), $retValue = self::FormattedPHPToExcel(date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue), date('H', $dateValue), date('i', $dateValue), date('s', $dateValue));
date('H', $dateValue), date('i', $dateValue), date('s', $dateValue)
);
} }
date_default_timezone_set($saveTimeZone); date_default_timezone_set($saveTimeZone);
@ -235,8 +231,8 @@ class PHPExcel_Shared_Date
} }
// Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0) // 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); $century = substr($year, 0, 2);
$decade = substr($year,2,2); $decade = substr($year, 2, 2);
$excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $myexcelBaseDate + $excel1900isLeapYear; $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; $excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
@ -273,7 +269,7 @@ class PHPExcel_Shared_Date
} }
private static $possibleDateFormatCharacters = 'eymdHs'; private static $possibleDateFormatCharacters = 'eymdHs';
/** /**
* Is a given number format code a date/time? * Is a given number format code a date/time?
@ -283,12 +279,15 @@ class PHPExcel_Shared_Date
*/ */
public static function isDateTimeFormatCode($pFormatCode = '') public static function isDateTimeFormatCode($pFormatCode = '')
{ {
if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL)) if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL)) {
// "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check) // "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check)
return false; return false;
if (preg_match('/[0#]E[+-]0/i', $pFormatCode)) }
if (preg_match('/[0#]E[+-]0/i', $pFormatCode)) {
// Scientific format // Scientific format
return false; return false;
}
// Switch on formatcode // Switch on formatcode
switch ($pFormatCode) { switch ($pFormatCode) {
// Explicitly defined date formats // Explicitly defined date formats
@ -352,10 +351,12 @@ class PHPExcel_Shared_Date
*/ */
public static function stringToExcel($dateValue = '') public static function stringToExcel($dateValue = '')
{ {
if (strlen($dateValue) < 2) if (strlen($dateValue) < 2) {
return false; 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)) }
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; return false;
}
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue); $dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);

View File

@ -225,7 +225,7 @@ class PHPExcel_Shared_Drawing
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption // Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
// Calculate the next DWORD-position in the body // Calculate the next DWORD-position in the body
for ($i = 0 ; $i < $body_size ; $i += 3) { for ($i = 0; $i < $body_size; $i += 3) {
// Calculate line-ending and padding // Calculate line-ending and padding
if ($x >= $width) { if ($x >= $width) {
// If padding needed, ignore image-padding // If padding needed, ignore image-padding

View File

@ -79,5 +79,4 @@ class PHPExcel_Shared_Escher_DgContainer
{ {
return $this->_spgrContainer = $spgrContainer; return $this->_spgrContainer = $spgrContainer;
} }
} }

View File

@ -61,5 +61,4 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer
{ {
return $this->_BSECollection; return $this->_BSECollection;
} }
} }

View File

@ -116,5 +116,4 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
{ {
$this->_blipType = $blipType; $this->_blipType = $blipType;
} }
} }

View File

@ -87,5 +87,4 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
{ {
return $this->_parent; return $this->_parent;
} }
} }

View File

@ -51,22 +51,17 @@ class PHPExcel_Shared_Excel5
$columnDimensions = $sheet->getColumnDimensions(); $columnDimensions = $sheet->getColumnDimensions();
// first find the true column width in pixels (uncollapsed and unhidden) // first find the true column width in pixels (uncollapsed and unhidden)
if ( isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1 ) { if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) {
// then we have column dimension with explicit width // then we have column dimension with explicit width
$columnDimension = $columnDimensions[$col]; $columnDimension = $columnDimensions[$col];
$width = $columnDimension->getWidth(); $width = $columnDimension->getWidth();
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font); $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
} else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) { } else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
// then we have default column dimension with explicit width // then we have default column dimension with explicit width
$defaultColumnDimension = $sheet->getDefaultColumnDimension(); $defaultColumnDimension = $sheet->getDefaultColumnDimension();
$width = $defaultColumnDimension->getWidth(); $width = $defaultColumnDimension->getWidth();
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font); $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
} else { } else {
// we don't even have any default column dimension. Width depends on default font // we don't even have any default column dimension. Width depends on default font
$pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true); $pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true);
} }
@ -98,30 +93,24 @@ class PHPExcel_Shared_Excel5
$rowDimensions = $sheet->getRowDimensions(); $rowDimensions = $sheet->getRowDimensions();
// first find the true row height in pixels (uncollapsed and unhidden) // first find the true row height in pixels (uncollapsed and unhidden)
if ( isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) { if (isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) {
// then we have a row dimension // then we have a row dimension
$rowDimension = $rowDimensions[$row]; $rowDimension = $rowDimensions[$row];
$rowHeight = $rowDimension->getRowHeight(); $rowHeight = $rowDimension->getRowHeight();
$pixelRowHeight = (int) ceil(4 * $rowHeight / 3); // here we assume Arial 10 $pixelRowHeight = (int) ceil(4 * $rowHeight / 3); // here we assume Arial 10
} else if ($sheet->getDefaultRowDimension()->getRowHeight() != -1) { } else if ($sheet->getDefaultRowDimension()->getRowHeight() != -1) {
// then we have a default row dimension with explicit height // then we have a default row dimension with explicit height
$defaultRowDimension = $sheet->getDefaultRowDimension(); $defaultRowDimension = $sheet->getDefaultRowDimension();
$rowHeight = $defaultRowDimension->getRowHeight(); $rowHeight = $defaultRowDimension->getRowHeight();
$pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight); $pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight);
} else { } else {
// we don't even have any default row dimension. Height depends on default font // we don't even have any default row dimension. Height depends on default font
$pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font); $pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font);
$pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight); $pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight);
} }
// now find the effective row height in pixels // now find the effective row height in pixels
if ( isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible() ) { if (isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible()) {
$effectivePixelRowHeight = 0; $effectivePixelRowHeight = 0;
} else { } else {
$effectivePixelRowHeight = $pixelRowHeight; $effectivePixelRowHeight = $pixelRowHeight;
@ -313,5 +302,4 @@ class PHPExcel_Shared_Excel5
return $twoAnchor; return $twoAnchor;
} }
} }

View File

@ -152,18 +152,18 @@ class PHPExcel_Shared_File
// sys_get_temp_dir is only available since PHP 5.2.1 // sys_get_temp_dir is only available since PHP 5.2.1
// http://php.net/manual/en/function.sys-get-temp-dir.php#94119 // http://php.net/manual/en/function.sys-get-temp-dir.php#94119
if ( !function_exists('sys_get_temp_dir')) { if (!function_exists('sys_get_temp_dir')) {
if ($temp = getenv('TMP') ) { if ($temp = getenv('TMP')) {
if ((!empty($temp)) && (file_exists($temp))) { if ((!empty($temp)) && (file_exists($temp))) {
return realpath($temp); return realpath($temp);
} }
} }
if ($temp = getenv('TEMP') ) { if ($temp = getenv('TEMP')) {
if ((!empty($temp)) && (file_exists($temp))) { if ((!empty($temp)) && (file_exists($temp))) {
return realpath($temp); return realpath($temp);
} }
} }
if ($temp = getenv('TMPDIR') ) { if ($temp = getenv('TMPDIR')) {
if ((!empty($temp)) && (file_exists($temp))) { if ((!empty($temp)) && (file_exists($temp))) {
return realpath($temp); return realpath($temp);
} }

View File

@ -37,7 +37,7 @@ class PHPExcel_Shared_Font
{ {
/* Methods for resolving autosize value */ /* Methods for resolving autosize value */
const AUTOSIZE_METHOD_APPROX = 'approx'; const AUTOSIZE_METHOD_APPROX = 'approx';
const AUTOSIZE_METHOD_EXACT = 'exact'; const AUTOSIZE_METHOD_EXACT = 'exact';
private static $_autoSizeMethods = array( private static $_autoSizeMethods = array(
self::AUTOSIZE_METHOD_APPROX, self::AUTOSIZE_METHOD_APPROX,
@ -48,84 +48,84 @@ class PHPExcel_Shared_Font
const CHARSET_ANSI_LATIN = 0x00; const CHARSET_ANSI_LATIN = 0x00;
const CHARSET_SYSTEM_DEFAULT = 0x01; const CHARSET_SYSTEM_DEFAULT = 0x01;
const CHARSET_SYMBOL = 0x02; const CHARSET_SYMBOL = 0x02;
const CHARSET_APPLE_ROMAN = 0x4D; const CHARSET_APPLE_ROMAN = 0x4D;
const CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80; const CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80;
const CHARSET_ANSI_KOREAN_HANGUL = 0x81; const CHARSET_ANSI_KOREAN_HANGUL = 0x81;
const CHARSET_ANSI_KOREAN_JOHAB = 0x82; const CHARSET_ANSI_KOREAN_JOHAB = 0x82;
const CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86; // gb2312 const CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86; // gb2312
const CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88; // big5 const CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88; // big5
const CHARSET_ANSI_GREEK = 0xA1; const CHARSET_ANSI_GREEK = 0xA1;
const CHARSET_ANSI_TURKISH = 0xA2; const CHARSET_ANSI_TURKISH = 0xA2;
const CHARSET_ANSI_VIETNAMESE = 0xA3; const CHARSET_ANSI_VIETNAMESE = 0xA3;
const CHARSET_ANSI_HEBREW = 0xB1; const CHARSET_ANSI_HEBREW = 0xB1;
const CHARSET_ANSI_ARABIC = 0xB2; const CHARSET_ANSI_ARABIC = 0xB2;
const CHARSET_ANSI_BALTIC = 0xBA; const CHARSET_ANSI_BALTIC = 0xBA;
const CHARSET_ANSI_CYRILLIC = 0xCC; const CHARSET_ANSI_CYRILLIC = 0xCC;
const CHARSET_ANSI_THAI = 0xDD; const CHARSET_ANSI_THAI = 0xDD;
const CHARSET_ANSI_LATIN_II = 0xEE; const CHARSET_ANSI_LATIN_II = 0xEE;
const CHARSET_OEM_LATIN_I = 0xFF; const CHARSET_OEM_LATIN_I = 0xFF;
// XXX: Constants created! // XXX: Constants created!
/** Font filenames */ /** Font filenames */
const ARIAL = 'arial.ttf'; const ARIAL = 'arial.ttf';
const ARIAL_BOLD = 'arialbd.ttf'; const ARIAL_BOLD = 'arialbd.ttf';
const ARIAL_ITALIC = 'ariali.ttf'; const ARIAL_ITALIC = 'ariali.ttf';
const ARIAL_BOLD_ITALIC = 'arialbi.ttf'; const ARIAL_BOLD_ITALIC = 'arialbi.ttf';
const CALIBRI = 'CALIBRI.TTF'; const CALIBRI = 'CALIBRI.TTF';
const CALIBRI_BOLD = 'CALIBRIB.TTF'; const CALIBRI_BOLD = 'CALIBRIB.TTF';
const CALIBRI_ITALIC = 'CALIBRII.TTF'; const CALIBRI_ITALIC = 'CALIBRII.TTF';
const CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF'; const CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF';
const COMIC_SANS_MS = 'comic.ttf'; const COMIC_SANS_MS = 'comic.ttf';
const COMIC_SANS_MS_BOLD = 'comicbd.ttf'; const COMIC_SANS_MS_BOLD = 'comicbd.ttf';
const COURIER_NEW = 'cour.ttf'; const COURIER_NEW = 'cour.ttf';
const COURIER_NEW_BOLD = 'courbd.ttf'; const COURIER_NEW_BOLD = 'courbd.ttf';
const COURIER_NEW_ITALIC = 'couri.ttf'; const COURIER_NEW_ITALIC = 'couri.ttf';
const COURIER_NEW_BOLD_ITALIC = 'courbi.ttf'; const COURIER_NEW_BOLD_ITALIC = 'courbi.ttf';
const GEORGIA = 'georgia.ttf'; const GEORGIA = 'georgia.ttf';
const GEORGIA_BOLD = 'georgiab.ttf'; const GEORGIA_BOLD = 'georgiab.ttf';
const GEORGIA_ITALIC = 'georgiai.ttf'; const GEORGIA_ITALIC = 'georgiai.ttf';
const GEORGIA_BOLD_ITALIC = 'georgiaz.ttf'; const GEORGIA_BOLD_ITALIC = 'georgiaz.ttf';
const IMPACT = 'impact.ttf'; const IMPACT = 'impact.ttf';
const LIBERATION_SANS = 'LiberationSans-Regular.ttf'; const LIBERATION_SANS = 'LiberationSans-Regular.ttf';
const LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf'; const LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf';
const LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf'; const LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf';
const LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf'; const LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf';
const LUCIDA_CONSOLE = 'lucon.ttf'; const LUCIDA_CONSOLE = 'lucon.ttf';
const LUCIDA_SANS_UNICODE = 'l_10646.ttf'; const LUCIDA_SANS_UNICODE = 'l_10646.ttf';
const MICROSOFT_SANS_SERIF = 'micross.ttf'; const MICROSOFT_SANS_SERIF = 'micross.ttf';
const PALATINO_LINOTYPE = 'pala.ttf'; const PALATINO_LINOTYPE = 'pala.ttf';
const PALATINO_LINOTYPE_BOLD = 'palab.ttf'; const PALATINO_LINOTYPE_BOLD = 'palab.ttf';
const PALATINO_LINOTYPE_ITALIC = 'palai.ttf'; const PALATINO_LINOTYPE_ITALIC = 'palai.ttf';
const PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf'; const PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf';
const SYMBOL = 'symbol.ttf'; const SYMBOL = 'symbol.ttf';
const TAHOMA = 'tahoma.ttf'; const TAHOMA = 'tahoma.ttf';
const TAHOMA_BOLD = 'tahomabd.ttf'; const TAHOMA_BOLD = 'tahomabd.ttf';
const TIMES_NEW_ROMAN = 'times.ttf'; const TIMES_NEW_ROMAN = 'times.ttf';
const TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf'; const TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf';
const TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf'; const TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf';
const TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf'; const TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf';
const TREBUCHET_MS = 'trebuc.ttf'; const TREBUCHET_MS = 'trebuc.ttf';
const TREBUCHET_MS_BOLD = 'trebucbd.ttf'; const TREBUCHET_MS_BOLD = 'trebucbd.ttf';
const TREBUCHET_MS_ITALIC = 'trebucit.ttf'; const TREBUCHET_MS_ITALIC = 'trebucit.ttf';
const TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf'; const TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf';
const VERDANA = 'verdana.ttf'; const VERDANA = 'verdana.ttf';
const VERDANA_BOLD = 'verdanab.ttf'; const VERDANA_BOLD = 'verdanab.ttf';
const VERDANA_ITALIC = 'verdanai.ttf'; const VERDANA_ITALIC = 'verdanai.ttf';
const VERDANA_BOLD_ITALIC = 'verdanaz.ttf'; const VERDANA_BOLD_ITALIC = 'verdanaz.ttf';
/** /**
* AutoSize method * AutoSize method
@ -196,12 +196,12 @@ class PHPExcel_Shared_Font
*/ */
public static function setAutoSizeMethod($pValue = self::AUTOSIZE_METHOD_APPROX) public static function setAutoSizeMethod($pValue = self::AUTOSIZE_METHOD_APPROX)
{ {
if (!in_array($pValue,self::$_autoSizeMethods)) { if (!in_array($pValue, self::$_autoSizeMethods)) {
return FALSE; return false;
} }
self::$autoSizeMethod = $pValue; self::$autoSizeMethod = $pValue;
return TRUE; return true;
} }
/** /**
@ -249,7 +249,8 @@ class PHPExcel_Shared_Font
* @param PHPExcel_Style_Font|NULL $defaultFont Font object * @param PHPExcel_Style_Font|NULL $defaultFont Font object
* @return integer Column width * @return integer Column width
*/ */
public static function calculateColumnWidth(PHPExcel_Style_Font $font, $cellText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) { 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 it is rich text, use plain text
if ($cellText instanceof PHPExcel_RichText) { if ($cellText instanceof PHPExcel_RichText) {
$cellText = $cellText->getPlainText(); $cellText = $cellText->getPlainText();
@ -301,7 +302,8 @@ class PHPExcel_Shared_Font
* @return int * @return int
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0) { public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0)
{
if (!function_exists('imagettfbbox')) { if (!function_exists('imagettfbbox')) {
throw new PHPExcel_Exception('GD library needs to be enabled'); throw new PHPExcel_Exception('GD library needs to be enabled');
} }
@ -391,7 +393,8 @@ class PHPExcel_Shared_Font
* @param int $fontSizeInPoints Font size (in points) * @param int $fontSizeInPoints Font size (in points)
* @return int Font size (in pixels) * @return int Font size (in pixels)
*/ */
public static function fontSizeToPixels($fontSizeInPoints = 11) { public static function fontSizeToPixels($fontSizeInPoints = 11)
{
return (int) ((4 / 3) * $fontSizeInPoints); return (int) ((4 / 3) * $fontSizeInPoints);
} }
@ -401,7 +404,8 @@ class PHPExcel_Shared_Font
* @param int $sizeInInch Font size (in inch) * @param int $sizeInInch Font size (in inch)
* @return int Size (in pixels) * @return int Size (in pixels)
*/ */
public static function inchSizeToPixels($sizeInInch = 1) { public static function inchSizeToPixels($sizeInInch = 1)
{
return ($sizeInInch * 96); return ($sizeInInch * 96);
} }
@ -411,7 +415,8 @@ class PHPExcel_Shared_Font
* @param int $sizeInCm Font size (in centimeters) * @param int $sizeInCm Font size (in centimeters)
* @return int Size (in pixels) * @return int Size (in pixels)
*/ */
public static function centimeterSizeToPixels($sizeInCm = 1) { public static function centimeterSizeToPixels($sizeInCm = 1)
{
return ($sizeInCm * 37.795275591); return ($sizeInCm * 37.795275591);
} }
@ -421,14 +426,15 @@ class PHPExcel_Shared_Font
* @param PHPExcel_Style_Font * @param PHPExcel_Style_Font
* @return string Path to TrueType font file * @return string Path to TrueType font file
*/ */
public static function getTrueTypeFontFileFromFont($font) { public static function getTrueTypeFontFileFromFont($font)
{
if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) { if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) {
throw new PHPExcel_Exception('Valid directory to TrueType Font files not specified'); throw new PHPExcel_Exception('Valid directory to TrueType Font files not specified');
} }
$name = $font->getName(); $name = $font->getName();
$bold = $font->getBold(); $bold = $font->getBold();
$italic = $font->getItalic(); $italic = $font->getItalic();
// Check if we can map font to true type font file // Check if we can map font to true type font file
switch ($name) { switch ($name) {
@ -438,95 +444,79 @@ class PHPExcel_Shared_Font
: ($italic ? self::ARIAL_ITALIC : self::ARIAL) : ($italic ? self::ARIAL_ITALIC : self::ARIAL)
); );
break; break;
case 'Calibri': case 'Calibri':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD) $bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
: ($italic ? self::CALIBRI_ITALIC : self::CALIBRI) : ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
); );
break; break;
case 'Courier New': case 'Courier New':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD) $bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
: ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW) : ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
); );
break; break;
case 'Comic Sans MS': case 'Comic Sans MS':
$fontFile = ( $fontFile = (
$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS $bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
); );
break; break;
case 'Georgia': case 'Georgia':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD) $bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
: ($italic ? self::GEORGIA_ITALIC : self::GEORGIA) : ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
); );
break; break;
case 'Impact': case 'Impact':
$fontFile = self::IMPACT; $fontFile = self::IMPACT;
break; break;
case 'Liberation Sans': case 'Liberation Sans':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD) $bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
: ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS) : ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
); );
break; break;
case 'Lucida Console': case 'Lucida Console':
$fontFile = self::LUCIDA_CONSOLE; $fontFile = self::LUCIDA_CONSOLE;
break; break;
case 'Lucida Sans Unicode': case 'Lucida Sans Unicode':
$fontFile = self::LUCIDA_SANS_UNICODE; $fontFile = self::LUCIDA_SANS_UNICODE;
break; break;
case 'Microsoft Sans Serif': case 'Microsoft Sans Serif':
$fontFile = self::MICROSOFT_SANS_SERIF; $fontFile = self::MICROSOFT_SANS_SERIF;
break; break;
case 'Palatino Linotype': case 'Palatino Linotype':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD) $bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
: ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE) : ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
); );
break; break;
case 'Symbol': case 'Symbol':
$fontFile = self::SYMBOL; $fontFile = self::SYMBOL;
break; break;
case 'Tahoma': case 'Tahoma':
$fontFile = ( $fontFile = (
$bold ? self::TAHOMA_BOLD : self::TAHOMA $bold ? self::TAHOMA_BOLD : self::TAHOMA
); );
break; break;
case 'Times New Roman': case 'Times New Roman':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD) $bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
: ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN) : ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
); );
break; break;
case 'Trebuchet MS': case 'Trebuchet MS':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD) $bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
: ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS) : ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
); );
break; break;
case 'Verdana': case 'Verdana':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD) $bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
: ($italic ? self::VERDANA_ITALIC : self::VERDANA) : ($italic ? self::VERDANA_ITALIC : self::VERDANA)
); );
break; break;
default: default:
throw new PHPExcel_Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file'); throw new PHPExcel_Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file');
break; break;
@ -536,7 +526,7 @@ class PHPExcel_Shared_Font
// Check if file actually exists // Check if file actually exists
if (!file_exists($fontFile)) { if (!file_exists($fontFile)) {
throw New PHPExcel_Exception('TrueType Font file not found'); throw new PHPExcel_Exception('TrueType Font file not found');
} }
return $fontFile; return $fontFile;
@ -552,11 +542,16 @@ class PHPExcel_Shared_Font
{ {
switch ($name) { switch ($name) {
// Add more cases. Check FONT records in real Excel files. // Add more cases. Check FONT records in real Excel files.
case 'EucrosiaUPC': return self::CHARSET_ANSI_THAI; case 'EucrosiaUPC':
case 'Wingdings': return self::CHARSET_SYMBOL; return self::CHARSET_ANSI_THAI;
case 'Wingdings 2': return self::CHARSET_SYMBOL; case 'Wingdings':
case 'Wingdings 3': return self::CHARSET_SYMBOL; return self::CHARSET_SYMBOL;
default: return self::CHARSET_ANSI_LATIN; case 'Wingdings 2':
return self::CHARSET_SYMBOL;
case 'Wingdings 3':
return self::CHARSET_SYMBOL;
default:
return self::CHARSET_ANSI_LATIN;
} }
} }
@ -609,44 +604,36 @@ class PHPExcel_Shared_Font
// inspection of Arial 10 workbook says 12.75pt ~17px // inspection of Arial 10 workbook says 12.75pt ~17px
$rowHeight = 12.75; $rowHeight = 12.75;
break; break;
case 9: case 9:
// inspection of Arial 9 workbook says 12.00pt ~16px // inspection of Arial 9 workbook says 12.00pt ~16px
$rowHeight = 12; $rowHeight = 12;
break; break;
case 8: case 8:
// inspection of Arial 8 workbook says 11.25pt ~15px // inspection of Arial 8 workbook says 11.25pt ~15px
$rowHeight = 11.25; $rowHeight = 11.25;
break; break;
case 7: case 7:
// inspection of Arial 7 workbook says 9.00pt ~12px // inspection of Arial 7 workbook says 9.00pt ~12px
$rowHeight = 9; $rowHeight = 9;
break; break;
case 6: case 6:
case 5: case 5:
// inspection of Arial 5,6 workbook says 8.25pt ~11px // inspection of Arial 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25; $rowHeight = 8.25;
break; break;
case 4: case 4:
// inspection of Arial 4 workbook says 6.75pt ~9px // inspection of Arial 4 workbook says 6.75pt ~9px
$rowHeight = 6.75; $rowHeight = 6.75;
break; break;
case 3: case 3:
// inspection of Arial 3 workbook says 6.00pt ~8px // inspection of Arial 3 workbook says 6.00pt ~8px
$rowHeight = 6; $rowHeight = 6;
break; break;
case 2: case 2:
case 1: case 1:
// inspection of Arial 1,2 workbook says 5.25pt ~7px // inspection of Arial 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25; $rowHeight = 5.25;
break; break;
default: default:
// use Arial 10 workbook as an approximation, extrapolation // use Arial 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10; $rowHeight = 12.75 * $font->getSize() / 10;
@ -660,49 +647,40 @@ class PHPExcel_Shared_Font
// inspection of Calibri 11 workbook says 15.00pt ~20px // inspection of Calibri 11 workbook says 15.00pt ~20px
$rowHeight = 15; $rowHeight = 15;
break; break;
case 10: case 10:
// inspection of Calibri 10 workbook says 12.75pt ~17px // inspection of Calibri 10 workbook says 12.75pt ~17px
$rowHeight = 12.75; $rowHeight = 12.75;
break; break;
case 9: case 9:
// inspection of Calibri 9 workbook says 12.00pt ~16px // inspection of Calibri 9 workbook says 12.00pt ~16px
$rowHeight = 12; $rowHeight = 12;
break; break;
case 8: case 8:
// inspection of Calibri 8 workbook says 11.25pt ~15px // inspection of Calibri 8 workbook says 11.25pt ~15px
$rowHeight = 11.25; $rowHeight = 11.25;
break; break;
case 7: case 7:
// inspection of Calibri 7 workbook says 9.00pt ~12px // inspection of Calibri 7 workbook says 9.00pt ~12px
$rowHeight = 9; $rowHeight = 9;
break; break;
case 6: case 6:
case 5: case 5:
// inspection of Calibri 5,6 workbook says 8.25pt ~11px // inspection of Calibri 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25; $rowHeight = 8.25;
break; break;
case 4: case 4:
// inspection of Calibri 4 workbook says 6.75pt ~9px // inspection of Calibri 4 workbook says 6.75pt ~9px
$rowHeight = 6.75; $rowHeight = 6.75;
break; break;
case 3: case 3:
// inspection of Calibri 3 workbook says 6.00pt ~8px // inspection of Calibri 3 workbook says 6.00pt ~8px
$rowHeight = 6.00; $rowHeight = 6.00;
break; break;
case 2: case 2:
case 1: case 1:
// inspection of Calibri 1,2 workbook says 5.25pt ~7px // inspection of Calibri 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25; $rowHeight = 5.25;
break; break;
default: default:
// use Calibri 11 workbook as an approximation, extrapolation // use Calibri 11 workbook as an approximation, extrapolation
$rowHeight = 15 * $font->getSize() / 11; $rowHeight = 15 * $font->getSize() / 11;
@ -716,51 +694,42 @@ class PHPExcel_Shared_Font
// inspection of Verdana 10 workbook says 12.75pt ~17px // inspection of Verdana 10 workbook says 12.75pt ~17px
$rowHeight = 12.75; $rowHeight = 12.75;
break; break;
case 9: case 9:
// inspection of Verdana 9 workbook says 11.25pt ~15px // inspection of Verdana 9 workbook says 11.25pt ~15px
$rowHeight = 11.25; $rowHeight = 11.25;
break; break;
case 8: case 8:
// inspection of Verdana 8 workbook says 10.50pt ~14px // inspection of Verdana 8 workbook says 10.50pt ~14px
$rowHeight = 10.50; $rowHeight = 10.50;
break; break;
case 7: case 7:
// inspection of Verdana 7 workbook says 9.00pt ~12px // inspection of Verdana 7 workbook says 9.00pt ~12px
$rowHeight = 9.00; $rowHeight = 9.00;
break; break;
case 6: case 6:
case 5: case 5:
// inspection of Verdana 5,6 workbook says 8.25pt ~11px // inspection of Verdana 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25; $rowHeight = 8.25;
break; break;
case 4: case 4:
// inspection of Verdana 4 workbook says 6.75pt ~9px // inspection of Verdana 4 workbook says 6.75pt ~9px
$rowHeight = 6.75; $rowHeight = 6.75;
break; break;
case 3: case 3:
// inspection of Verdana 3 workbook says 6.00pt ~8px // inspection of Verdana 3 workbook says 6.00pt ~8px
$rowHeight = 6; $rowHeight = 6;
break; break;
case 2: case 2:
case 1: case 1:
// inspection of Verdana 1,2 workbook says 5.25pt ~7px // inspection of Verdana 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25; $rowHeight = 5.25;
break; break;
default: default:
// use Verdana 10 workbook as an approximation, extrapolation // use Verdana 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10; $rowHeight = 12.75 * $font->getSize() / 10;
break; break;
} }
break; break;
default: default:
// just use Calibri as an approximation // just use Calibri as an approximation
$rowHeight = 15 * $font->getSize() / 11; $rowHeight = 15 * $font->getSize() / 11;
@ -769,5 +738,4 @@ class PHPExcel_Shared_Font
return $rowHeight; return $rowHeight;
} }
} }

View File

@ -83,10 +83,7 @@ class PHPExcel_Shared_OLE_ChainedBlockStream
// 25 is length of "ole-chainedblockstream://" // 25 is length of "ole-chainedblockstream://"
parse_str(substr($path, 25), $this->params); parse_str(substr($path, 25), $this->params);
if (!isset($this->params['oleInstanceId'], if (!isset($this->params['oleInstanceId'], $this->params['blockId'], $GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']])) {
$this->params['blockId'],
$GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']])) {
if ($options & STREAM_REPORT_ERRORS) { if ($options & STREAM_REPORT_ERRORS) {
trigger_error('OLE stream not found', E_USER_WARNING); trigger_error('OLE stream not found', E_USER_WARNING);
} }
@ -96,10 +93,7 @@ class PHPExcel_Shared_OLE_ChainedBlockStream
$blockId = $this->params['blockId']; $blockId = $this->params['blockId'];
$this->data = ''; $this->data = '';
if (isset($this->params['size']) && if (isset($this->params['size']) && $this->params['size'] < $this->ole->bigBlockThreshold && $blockId != $this->ole->root->_StartBlock) {
$this->params['size'] < $this->ole->bigBlockThreshold &&
$blockId != $this->ole->root->_StartBlock) {
// Block id refers to small blocks // Block id refers to small blocks
$rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock); $rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock);
while ($blockId != -2) { while ($blockId != -2) {

View File

@ -169,7 +169,7 @@ class PHPExcel_Shared_OLE_PPS
*/ */
public function _getPpsWk() public function _getPpsWk()
{ {
$ret = str_pad($this->Name,64,"\x00"); $ret = str_pad($this->Name, 64, "\x00");
$ret .= pack("v", strlen($this->Name) + 2) // 66 $ret .= pack("v", strlen($this->Name) + 2) // 66
. pack("c", $this->Type) // 67 . pack("c", $this->Type) // 67
@ -202,9 +202,9 @@ class PHPExcel_Shared_OLE_PPS
*/ */
public static function _savePpsSetPnt(&$raList, $to_save, $depth = 0) public static function _savePpsSetPnt(&$raList, $to_save, $depth = 0)
{ {
if ( !is_array($to_save) || (empty($to_save)) ) { if (!is_array($to_save) || (empty($to_save))) {
return 0xFFFFFFFF; return 0xFFFFFFFF;
} elseif ( count($to_save) == 1 ) { } elseif (count($to_save) == 1) {
$cnt = count($raList); $cnt = count($raList);
// If the first entry, it's the root... Don't clone it! // If the first entry, it's the root... Don't clone it!
$raList[$cnt] = ( $depth == 0 ) ? $to_save[0] : clone $to_save[0]; $raList[$cnt] = ( $depth == 0 ) ? $to_save[0] : clone $to_save[0];

View File

@ -28,7 +28,7 @@
* @package PHPExcel_Shared_OLE * @package PHPExcel_Shared_OLE
*/ */
class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
{ {
/** /**
* The constructor * The constructor
* *
@ -38,17 +38,7 @@ class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
*/ */
public function __construct($name) public function __construct($name)
{ {
parent::__construct( parent::__construct(null, $name, PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE, null, null, null, null, null, '', array());
null,
$name,
PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE,
null,
null,
null,
null,
null,
'',
array());
} }
/** /**

View File

@ -28,13 +28,13 @@
* @package PHPExcel_Shared_OLE * @package PHPExcel_Shared_OLE
*/ */
class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
{ {
/** /**
* Directory for temporary files * Directory for temporary files
* @var string * @var string
*/ */
protected $_tmp_dir = NULL; protected $_tmp_dir = null;
/** /**
* @param integer $time_1st A timestamp * @param integer $time_1st A timestamp
@ -44,17 +44,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
{ {
$this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir(); $this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
parent::__construct( 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);
null,
PHPExcel_Shared_OLE::Asc2Ucs('Root Entry'),
PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT,
null,
null,
null,
$time_1st,
$time_2nd,
null,
$raChild);
} }
/** /**
@ -78,13 +68,13 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
if (is_resource($filename)) { if (is_resource($filename)) {
$this->_FILEH_ = $filename; $this->_FILEH_ = $filename;
} else if ($filename == '-' || $filename == '') { } else if ($filename == '-' || $filename == '') {
if ($this->_tmp_dir === NULL) if ($this->_tmp_dir === null)
$this->_tmp_dir = PHPExcel_Shared_File::sys_get_temp_dir(); $this->_tmp_dir = PHPExcel_Shared_File::sys_get_temp_dir();
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root"); $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
$this->_FILEH_ = fopen($this->_tmp_filename,"w+b"); $this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
if ($this->_FILEH_ == false) { if ($this->_FILEH_ == false) {
throw new PHPExcel_Writer_Exception("Can't create temporary file."); throw new PHPExcel_Writer_Exception("Can't create temporary file.");
} }
} else { } else {
$this->_FILEH_ = fopen($filename, "wb"); $this->_FILEH_ = fopen($filename, "wb");
@ -94,7 +84,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
} }
// Make an array of PPS's (for Save) // Make an array of PPS's (for Save)
$aList = array(); $aList = array();
PHPExcel_Shared_OLE_PPS::_savePpsSetPnt($aList, array($this)); PHPExcel_Shared_OLE_PPS::_savePpsSetPnt($aList, array($this));
// calculate values for header // calculate values for header
list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo); list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo);
// Save Header // Save Header
@ -447,7 +437,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
if ($iBdCnt > $i1stBdL) { if ($iBdCnt > $i1stBdL) {
$iN=0; $iN=0;
$iNb=0; $iNb=0;
for ($i = $i1stBdL;$i < $iBdCnt; $i++, ++$iN) { for ($i = $i1stBdL; $i < $iBdCnt; $i++, ++$iN) {
if ($iN >= ($iBbCnt - 1)) { if ($iN >= ($iBbCnt - 1)) {
$iN = 0; $iN = 0;
++$iNb; ++$iNb;

View File

@ -32,39 +32,39 @@ class PHPExcel_Shared_OLERead {
private $data = ''; private $data = '';
// OLE identifier // OLE identifier
const IDENTIFIER_OLE = IDENTIFIER_OLE; const IDENTIFIER_OLE = IDENTIFIER_OLE;
// Size of a sector = 512 bytes // Size of a sector = 512 bytes
const BIG_BLOCK_SIZE = 0x200; const BIG_BLOCK_SIZE = 0x200;
// Size of a short sector = 64 bytes // Size of a short sector = 64 bytes
const SMALL_BLOCK_SIZE = 0x40; const SMALL_BLOCK_SIZE = 0x40;
// Size of a directory entry always = 128 bytes // Size of a directory entry always = 128 bytes
const PROPERTY_STORAGE_BLOCK_SIZE = 0x80; const PROPERTY_STORAGE_BLOCK_SIZE = 0x80;
// Minimum size of a standard stream = 4096 bytes, streams smaller than this are stored as short streams // Minimum size of a standard stream = 4096 bytes, streams smaller than this are stored as short streams
const SMALL_BLOCK_THRESHOLD = 0x1000; const SMALL_BLOCK_THRESHOLD = 0x1000;
// header offsets // header offsets
const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2c; const NUM_BIG_BLOCK_DEPOT_BLOCKS_POS = 0x2c;
const ROOT_START_BLOCK_POS = 0x30; const ROOT_START_BLOCK_POS = 0x30;
const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3c; const SMALL_BLOCK_DEPOT_BLOCK_POS = 0x3c;
const EXTENSION_BLOCK_POS = 0x44; const EXTENSION_BLOCK_POS = 0x44;
const NUM_EXTENSION_BLOCK_POS = 0x48; const NUM_EXTENSION_BLOCK_POS = 0x48;
const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4c; const BIG_BLOCK_DEPOT_BLOCKS_POS = 0x4c;
// property storage offsets (directory offsets) // property storage offsets (directory offsets)
const SIZE_OF_NAME_POS = 0x40; const SIZE_OF_NAME_POS = 0x40;
const TYPE_POS = 0x42; const TYPE_POS = 0x42;
const START_BLOCK_POS = 0x74; const START_BLOCK_POS = 0x74;
const SIZE_POS = 0x78; const SIZE_POS = 0x78;
public $wrkbook = null; public $wrkbook = null;
public $summaryInformation = null; public $summaryInformation = null;
public $documentSummaryInformation = null; public $documentSummaryInformation = null;
/** /**
@ -82,7 +82,7 @@ class PHPExcel_Shared_OLERead {
// Get the file identifier // Get the file identifier
// Don't bother reading the whole file until we know it's a valid OLE file // Don't bother reading the whole file until we know it's a valid OLE file
$this->data = file_get_contents($sFileName, FALSE, NULL, 0, 8); $this->data = file_get_contents($sFileName, false, null, 0, 8);
// Check OLE identifier // Check OLE identifier
if ($this->data != self::IDENTIFIER_OLE) { if ($this->data != self::IDENTIFIER_OLE) {
@ -172,7 +172,7 @@ class PHPExcel_Shared_OLERead {
*/ */
public function getStream($stream) public function getStream($stream)
{ {
if ($stream === NULL) { if ($stream === null) {
return null; return null;
} }
@ -197,7 +197,9 @@ class PHPExcel_Shared_OLERead {
++$numBlocks; ++$numBlocks;
} }
if ($numBlocks == 0) return ''; if ($numBlocks == 0) {
return '';
}
$block = $this->props[$stream]['startBlock']; $block = $this->props[$stream]['startBlock'];
@ -222,18 +224,19 @@ class PHPExcel_Shared_OLERead {
$block = $bl; $block = $bl;
$data = ''; $data = '';
while ($block != -2) { while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE; $pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); $data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
$block = self::_GetInt4d($this->bigBlockChain, $block*4); $block = self::_GetInt4d($this->bigBlockChain, $block*4);
} }
return $data; return $data;
} }
/** /**
* Read entries in the directory stream. * Read entries in the directory stream.
*/ */
private function _readPropertySets() { private function _readPropertySets()
{
$offset = 0; $offset = 0;
// loop through entires, each entry is 128 bytes // loop through entires, each entry is 128 bytes
@ -254,14 +257,14 @@ class PHPExcel_Shared_OLERead {
$size = self::_GetInt4d($d, self::SIZE_POS); $size = self::_GetInt4d($d, self::SIZE_POS);
$name = str_replace("\x00", "", substr($d,0, $nameSize)); $name = str_replace("\x00", "", substr($d, 0, $nameSize));
$this->props[] = array(
$this->props[] = array (
'name' => $name, 'name' => $name,
'type' => $type, 'type' => $type,
'startBlock' => $startBlock, 'startBlock' => $startBlock,
'size' => $size); 'size' => $size
);
// tmp helper to simplify checks // tmp helper to simplify checks
$upName = strtoupper($name); $upName = strtoupper($name);
@ -269,8 +272,7 @@ class PHPExcel_Shared_OLERead {
// Workbook directory entry (BIFF5 uses Book, BIFF8 uses Workbook) // Workbook directory entry (BIFF5 uses Book, BIFF8 uses Workbook)
if (($upName === 'WORKBOOK') || ($upName === 'BOOK')) { if (($upName === 'WORKBOOK') || ($upName === 'BOOK')) {
$this->wrkbook = count($this->props) - 1; $this->wrkbook = count($this->props) - 1;
} } else if ($upName === 'ROOT ENTRY' || $upName === 'R') {
else if ( $upName === 'ROOT ENTRY' || $upName === 'R') {
// Root entry // Root entry
$this->rootentry = count($this->props) - 1; $this->rootentry = count($this->props) - 1;
} }
@ -289,7 +291,6 @@ class PHPExcel_Shared_OLERead {
$offset += self::PROPERTY_STORAGE_BLOCK_SIZE; $offset += self::PROPERTY_STORAGE_BLOCK_SIZE;
} }
} }
/** /**
@ -313,5 +314,4 @@ class PHPExcel_Shared_OLERead {
} }
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $_ord_24; return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $_ord_24;
} }
} }

View File

@ -27,7 +27,7 @@
// ----- Constants // ----- Constants
if (!defined('PCLZIP_READ_BLOCK_SIZE')) { if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); define('PCLZIP_READ_BLOCK_SIZE', 2048);
} }
// ----- File list separator // ----- File list separator
@ -38,10 +38,10 @@ if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
// However notice that changing this value, may have impact on existing // However notice that changing this value, may have impact on existing
// scripts, using space separated filenames. // scripts, using space separated filenames.
// Recommanded values for compatibility with older versions : // Recommanded values for compatibility with older versions :
//define( 'PCLZIP_SEPARATOR', ' ' ); //define('PCLZIP_SEPARATOR', ' ');
// Recommanded values for smart separation of filenames. // Recommanded values for smart separation of filenames.
if (!defined('PCLZIP_SEPARATOR')) { if (!defined('PCLZIP_SEPARATOR')) {
define( 'PCLZIP_SEPARATOR', ',' ); define('PCLZIP_SEPARATOR', ',');
} }
// ----- Error configuration // ----- Error configuration
@ -50,7 +50,7 @@ if (!defined('PCLZIP_SEPARATOR')) {
// you must ensure that you have included PclError library. // you must ensure that you have included PclError library.
// [2,...] : reserved for futur use // [2,...] : reserved for futur use
if (!defined('PCLZIP_ERROR_EXTERNAL')) { if (!defined('PCLZIP_ERROR_EXTERNAL')) {
define( 'PCLZIP_ERROR_EXTERNAL', 0 ); define('PCLZIP_ERROR_EXTERNAL', 0);
} }
// ----- Optional static temporary directory // ----- Optional static temporary directory
@ -60,10 +60,10 @@ if (!defined('PCLZIP_ERROR_EXTERNAL')) {
// - MUST BE terminated by a '/'. // - MUST BE terminated by a '/'.
// - MUST be a valid, already created directory // - MUST be a valid, already created directory
// Samples : // Samples :
// define( 'PCLZIP_TEMPORARY_DIR', '/temp/' ); // define('PCLZIP_TEMPORARY_DIR', '/temp/');
// define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' ); // define('PCLZIP_TEMPORARY_DIR', 'C:/Temp/');
if (!defined('PCLZIP_TEMPORARY_DIR')) { if (!defined('PCLZIP_TEMPORARY_DIR')) {
define( 'PCLZIP_TEMPORARY_DIR', '' ); define('PCLZIP_TEMPORARY_DIR', '');
} }
// ----- Optional threshold ratio for use of temporary files // ----- Optional threshold ratio for use of temporary files
@ -73,9 +73,9 @@ if (!defined('PCLZIP_TEMPORARY_DIR')) {
// threshold = memory_limit * ratio. // threshold = memory_limit * ratio.
// Recommended values are under 0.5. Default 0.47. // Recommended values are under 0.5. Default 0.47.
// Samples : // Samples :
// define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 ); // define('PCLZIP_TEMPORARY_FILE_RATIO', 0.5);
if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) { if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 ); define('PCLZIP_TEMPORARY_FILE_RATIO', 0.47);
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
@ -100,77 +100,77 @@ $g_pclzip_version = "2.8.2";
// -12 : Unable to rename file (rename) // -12 : Unable to rename file (rename)
// -13 : Invalid header checksum // -13 : Invalid header checksum
// -14 : Invalid archive size // -14 : Invalid archive size
define( 'PCLZIP_ERR_USER_ABORTED', 2 ); define('PCLZIP_ERR_USER_ABORTED', 2);
define( 'PCLZIP_ERR_NO_ERROR', 0 ); define('PCLZIP_ERR_NO_ERROR', 0);
define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 ); define('PCLZIP_ERR_WRITE_OPEN_FAIL', -1);
define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 ); define('PCLZIP_ERR_READ_OPEN_FAIL', -2);
define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 ); define('PCLZIP_ERR_INVALID_PARAMETER', -3);
define( 'PCLZIP_ERR_MISSING_FILE', -4 ); define('PCLZIP_ERR_MISSING_FILE', -4);
define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 ); define('PCLZIP_ERR_FILENAME_TOO_LONG', -5);
define( 'PCLZIP_ERR_INVALID_ZIP', -6 ); define('PCLZIP_ERR_INVALID_ZIP', -6);
define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 ); define('PCLZIP_ERR_BAD_EXTRACTED_FILE', -7);
define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 ); define('PCLZIP_ERR_DIR_CREATE_FAIL', -8);
define( 'PCLZIP_ERR_BAD_EXTENSION', -9 ); define('PCLZIP_ERR_BAD_EXTENSION', -9);
define( 'PCLZIP_ERR_BAD_FORMAT', -10 ); define('PCLZIP_ERR_BAD_FORMAT', -10);
define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 ); define('PCLZIP_ERR_DELETE_FILE_FAIL', -11);
define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 ); define('PCLZIP_ERR_RENAME_FILE_FAIL', -12);
define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 ); define('PCLZIP_ERR_BAD_CHECKSUM', -13);
define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 ); define('PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14);
define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 ); define('PCLZIP_ERR_MISSING_OPTION_VALUE', -15);
define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 ); define('PCLZIP_ERR_INVALID_OPTION_VALUE', -16);
define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 ); define('PCLZIP_ERR_ALREADY_A_DIRECTORY', -17);
define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 ); define('PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18);
define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 ); define('PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19);
define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 ); define('PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20);
define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 ); define('PCLZIP_ERR_DIRECTORY_RESTRICTION', -21);
// ----- Options values // ----- Options values
define( 'PCLZIP_OPT_PATH', 77001 ); define('PCLZIP_OPT_PATH', 77001);
define( 'PCLZIP_OPT_ADD_PATH', 77002 ); define('PCLZIP_OPT_ADD_PATH', 77002);
define( 'PCLZIP_OPT_REMOVE_PATH', 77003 ); define('PCLZIP_OPT_REMOVE_PATH', 77003);
define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 ); define('PCLZIP_OPT_REMOVE_ALL_PATH', 77004);
define( 'PCLZIP_OPT_SET_CHMOD', 77005 ); define('PCLZIP_OPT_SET_CHMOD', 77005);
define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 ); define('PCLZIP_OPT_EXTRACT_AS_STRING', 77006);
define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 ); define('PCLZIP_OPT_NO_COMPRESSION', 77007);
define( 'PCLZIP_OPT_BY_NAME', 77008 ); define('PCLZIP_OPT_BY_NAME', 77008);
define( 'PCLZIP_OPT_BY_INDEX', 77009 ); define('PCLZIP_OPT_BY_INDEX', 77009);
define( 'PCLZIP_OPT_BY_EREG', 77010 ); define('PCLZIP_OPT_BY_EREG', 77010);
define( 'PCLZIP_OPT_BY_PREG', 77011 ); define('PCLZIP_OPT_BY_PREG', 77011);
define( 'PCLZIP_OPT_COMMENT', 77012 ); define('PCLZIP_OPT_COMMENT', 77012);
define( 'PCLZIP_OPT_ADD_COMMENT', 77013 ); define('PCLZIP_OPT_ADD_COMMENT', 77013);
define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 ); define('PCLZIP_OPT_PREPEND_COMMENT', 77014);
define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 ); define('PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015);
define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 ); define('PCLZIP_OPT_REPLACE_NEWER', 77016);
define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 ); define('PCLZIP_OPT_STOP_ON_ERROR', 77017);
// Having big trouble with crypt. Need to multiply 2 long int // Having big trouble with crypt. Need to multiply 2 long int
// which is not correctly supported by PHP ... // which is not correctly supported by PHP ...
//define( 'PCLZIP_OPT_CRYPT', 77018 ); //define('PCLZIP_OPT_CRYPT', 77018);
define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 ); define('PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019);
define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 ); define('PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020);
define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias define('PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020); // alias
define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 ); define('PCLZIP_OPT_TEMP_FILE_ON', 77021);
define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias define('PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021); // alias
define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 ); define('PCLZIP_OPT_TEMP_FILE_OFF', 77022);
define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias define('PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022); // alias
// ----- File description attributes // ----- File description attributes
define( 'PCLZIP_ATT_FILE_NAME', 79001 ); define('PCLZIP_ATT_FILE_NAME', 79001);
define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); define('PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002);
define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 ); define('PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003);
define( 'PCLZIP_ATT_FILE_MTIME', 79004 ); define('PCLZIP_ATT_FILE_MTIME', 79004);
define( 'PCLZIP_ATT_FILE_CONTENT', 79005 ); define('PCLZIP_ATT_FILE_CONTENT', 79005);
define( 'PCLZIP_ATT_FILE_COMMENT', 79006 ); define('PCLZIP_ATT_FILE_COMMENT', 79006);
// ----- Call backs values // ----- Call backs values
define( 'PCLZIP_CB_PRE_EXTRACT', 78001 ); define('PCLZIP_CB_PRE_EXTRACT', 78001);
define( 'PCLZIP_CB_POST_EXTRACT', 78002 ); define('PCLZIP_CB_POST_EXTRACT', 78002);
define( 'PCLZIP_CB_PRE_ADD', 78003 ); define('PCLZIP_CB_PRE_ADD', 78003);
define( 'PCLZIP_CB_POST_ADD', 78004 ); define('PCLZIP_CB_POST_ADD', 78004);
/* For futur use /* For futur use
define( 'PCLZIP_CB_PRE_LIST', 78005 ); define('PCLZIP_CB_PRE_LIST', 78005);
define( 'PCLZIP_CB_POST_LIST', 78006 ); define('PCLZIP_CB_POST_LIST', 78006);
define( 'PCLZIP_CB_PRE_DELETE', 78007 ); define('PCLZIP_CB_PRE_DELETE', 78007);
define( 'PCLZIP_CB_POST_DELETE', 78008 ); define('PCLZIP_CB_POST_DELETE', 78008);
*/ */
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
@ -276,7 +276,7 @@ class PclZip
// ----- Set default values // ----- Set default values
$v_options = array(); $v_options = array();
$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; $v_options[PCLZIP_OPT_NO_COMPRESSION] = false;
// ----- Look for variable options arguments // ----- Look for variable options arguments
$v_size = func_num_args(); $v_size = func_num_args();
@ -320,8 +320,7 @@ class PclZip
if ($v_size == 2) { if ($v_size == 2) {
$v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
} else if ($v_size > 2) { } else if ($v_size > 2) {
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
"Invalid number / type of arguments");
return 0; return 0;
} }
} }
@ -443,7 +442,7 @@ class PclZip
// ----- Set default values // ----- Set default values
$v_options = array(); $v_options = array();
$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; $v_options[PCLZIP_OPT_NO_COMPRESSION] = false;
// ----- Look for variable options arguments // ----- Look for variable options arguments
$v_size = func_num_args(); $v_size = func_num_args();
@ -687,7 +686,7 @@ class PclZip
$v_size = func_num_args(); $v_size = func_num_args();
// ----- Default values for option // ----- Default values for option
$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = false;
// ----- Look for arguments // ----- Look for arguments
if ($v_size > 0) { if ($v_size > 0) {
@ -838,7 +837,7 @@ class PclZip
$v_size = func_num_args(); $v_size = func_num_args();
// ----- Default values for option // ----- Default values for option
$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = false;
// ----- Look for arguments // ----- Look for arguments
if ($v_size > 1) { if ($v_size > 1) {
@ -890,7 +889,7 @@ class PclZip
$v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
} }
if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = false;
} else { } else {
} }
} else { } else {
@ -921,7 +920,7 @@ class PclZip
// with privParseOptions() // with privParseOptions()
$v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
$v_options_trick = array(); $v_options_trick = array();
$v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, array (PCLZIP_OPT_BY_INDEX => 'optional' )); $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, array (PCLZIP_OPT_BY_INDEX => 'optional'));
if ($v_result != 1) { if ($v_result != 1) {
return 0; return 0;
} }
@ -1121,7 +1120,6 @@ class PclZip
// ----- Look if the $p_archive is a PclZip object // ----- Look if the $p_archive is a PclZip object
if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) { if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) {
// ----- Duplicate the archive // ----- Duplicate the archive
$v_result = $this->privDuplicate($p_archive->zipname); $v_result = $this->privDuplicate($p_archive->zipname);
} else if (is_string($p_archive)) { } else if (is_string($p_archive)) {
@ -1219,9 +1217,9 @@ class PclZip
// Description : // Description :
// Parameters : // Parameters :
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
function errorName($p_with_code=false) function errorName($p_with_code = false)
{ {
$v_name = array ( $v_name = array(
PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
@ -1264,7 +1262,7 @@ class PclZip
// Description : // Description :
// Parameters : // Parameters :
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
function errorInfo($p_full=false) function errorInfo($p_full = false)
{ {
if (PCLZIP_ERROR_EXTERNAL == 1) { if (PCLZIP_ERROR_EXTERNAL == 1) {
return(PclErrorString()); return(PclErrorString());
@ -1301,7 +1299,7 @@ class PclZip
// true on success, // true on success,
// false on error, the error code is set. // false on error, the error code is set.
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
function privCheckFormat($p_level=0) function privCheckFormat($p_level = 0)
{ {
$v_result = true; $v_result = true;
@ -1354,7 +1352,7 @@ class PclZip
// 1 on success. // 1 on success.
// 0 on failure. // 0 on failure.
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options = false)
{ {
$v_result=1; $v_result=1;
@ -1386,7 +1384,7 @@ class PclZip
} }
// ----- Get the value // ----- Get the value
$v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);
$i++; $i++;
break; break;
@ -1439,7 +1437,7 @@ class PclZip
$v_result_list[$p_options_list[$i]] = true; $v_result_list[$p_options_list[$i]] = true;
break; break;
case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION:
// ----- Check the number of parameters // ----- Check the number of parameters
if (($i+1) >= $p_size) { if (($i+1) >= $p_size) {
// ----- Error log // ----- Error log
@ -1450,14 +1448,13 @@ class PclZip
// ----- Get the value // ----- Get the value
if (is_string($p_options_list[$i+1]) && ($p_options_list[$i+1] != '')) { 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); $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);
$i++; $i++;
} else { } else {
} }
break; break;
// ----- Look for options that request an array of string for value // ----- Look for options that request an array of string for value
case PCLZIP_OPT_BY_NAME : case PCLZIP_OPT_BY_NAME:
// ----- Check the number of parameters // ----- Check the number of parameters
if (($i+1) >= $p_size) { if (($i+1) >= $p_size) {
// ----- Error log // ----- Error log
@ -1480,11 +1477,11 @@ class PclZip
$i++; $i++;
break; break;
// ----- Look for options that request an EREG or PREG expression // ----- Look for options that request an EREG or PREG expression
case PCLZIP_OPT_BY_EREG : case PCLZIP_OPT_BY_EREG:
// ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
// to PCLZIP_OPT_BY_PREG // to PCLZIP_OPT_BY_PREG
$p_options_list[$i] = PCLZIP_OPT_BY_PREG; $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
case PCLZIP_OPT_BY_PREG : case PCLZIP_OPT_BY_PREG:
//case PCLZIP_OPT_CRYPT : //case PCLZIP_OPT_CRYPT :
// ----- Check the number of parameters // ----- Check the number of parameters
if (($i+1) >= $p_size) { if (($i+1) >= $p_size) {
@ -1507,9 +1504,9 @@ class PclZip
break; break;
// ----- Look for options that takes a string // ----- Look for options that takes a string
case PCLZIP_OPT_COMMENT : case PCLZIP_OPT_COMMENT:
case PCLZIP_OPT_ADD_COMMENT : case PCLZIP_OPT_ADD_COMMENT:
case PCLZIP_OPT_PREPEND_COMMENT : case PCLZIP_OPT_PREPEND_COMMENT:
// ----- Check the number of parameters // ----- Check the number of parameters
if (($i+1) >= $p_size) { if (($i+1) >= $p_size) {
// ----- Error log // ----- Error log
@ -1533,7 +1530,7 @@ class PclZip
break; break;
// ----- Look for options that request an array of index // ----- Look for options that request an array of index
case PCLZIP_OPT_BY_INDEX : case PCLZIP_OPT_BY_INDEX:
// ----- Check the number of parameters // ----- Check the number of parameters
if (($i+1) >= $p_size) { if (($i+1) >= $p_size) {
// ----- Error log // ----- Error log
@ -1673,7 +1670,7 @@ class PclZip
$v_result_list[$p_options_list[$i]] = $v_function_name; $v_result_list[$p_options_list[$i]] = $v_function_name;
$i++; $i++;
break; break;
default : default:
// ----- Error log // ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown parameter '" .$p_options_list[$i]."'"); PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown parameter '" .$p_options_list[$i]."'");
@ -1762,7 +1759,7 @@ class PclZip
// 1 on success. // 1 on success.
// 0 on failure. // 0 on failure.
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options = false)
{ {
$v_result=1; $v_result=1;
@ -1836,7 +1833,7 @@ class PclZip
case PCLZIP_ATT_FILE_CONTENT: case PCLZIP_ATT_FILE_CONTENT:
$p_filedescr['content'] = $v_value; $p_filedescr['content'] = $v_value;
break; break;
default : default:
// ----- Error log // ----- Error log
PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown parameter '".$v_key."'"); PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown parameter '".$v_key."'");
@ -2030,7 +2027,6 @@ class PclZip
// ----- Look if the archive exists or is empty // ----- Look if the archive exists or is empty
if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) { if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) {
// ----- Do a create // ----- Do a create
$v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
@ -2341,8 +2337,8 @@ class PclZip
// ----- Look if it is a file or a dir with no all path remove option // ----- Look if it is a file or a dir with no all path remove option
// or a dir with all its path removed // or a dir with all its path removed
// if ( (is_file($p_filedescr_list[$j]['filename'])) // if ( (is_file($p_filedescr_list[$j]['filename']))
// || ( is_dir($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]))) { 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 // ----- Add the file
$v_result = $this->privAddFile($p_filedescr_list[$j], $v_header, $p_options); $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header, $p_options);
@ -2484,7 +2480,7 @@ class PclZip
// ----- Look for a file // ----- Look for a file
if ($p_filedescr['type'] == 'file') { if ($p_filedescr['type'] == 'file') {
// ----- Look for using temporary file to zip // ----- 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'])) ) ) { 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); $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
if ($v_result < PCLZIP_ERR_NO_ERROR) { if ($v_result < PCLZIP_ERR_NO_ERROR) {
return $v_result; return $v_result;
@ -2964,8 +2960,7 @@ class PclZip
// ----- Read each entry // ----- Read each entry
for ($i=0; $i<$v_central_dir['entries']; $i++) { for ($i=0; $i<$v_central_dir['entries']; $i++) {
// ----- Read the file header // ----- Read the file header
if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) {
{
$this->privSwapBackMagicQuotes(); $this->privSwapBackMagicQuotes();
return $v_result; return $v_result;
} }
@ -3053,7 +3048,7 @@ class PclZip
$this->privDisableMagicQuotes(); $this->privDisableMagicQuotes();
// ----- Check the path // ----- Check the path
if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../") && (substr($p_path,1,2)!=":/"))) { if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../") && (substr($p_path, 1, 2)!=":/"))) {
$p_path = "./".$p_path; $p_path = "./".$p_path;
} }
@ -3141,19 +3136,7 @@ class PclZip
$v_extract = true; $v_extract = true;
} }
} }
} }else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
// ----- 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;
}
}
*/
else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
// ----- Look for extract by preg rule // ----- Look for extract by preg rule
if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
$v_extract = true; $v_extract = true;
@ -3533,7 +3516,7 @@ class PclZip
} }
// ----- Look for using temporary file to unzip // ----- 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'])) ) ) { 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); $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
if ($v_result < PCLZIP_ERR_NO_ERROR) { if ($v_result < PCLZIP_ERR_NO_ERROR) {
return $v_result; return $v_result;
@ -3546,7 +3529,7 @@ class PclZip
// ----- Decompress the file // ----- Decompress the file
$v_file_content = @gzinflate($v_buffer); $v_file_content = @gzinflate($v_buffer);
unset($v_buffer); unset($v_buffer);
if ($v_file_content === FALSE) { if ($v_file_content === false) {
// ----- Change the file status // ----- Change the file status
// TBC // TBC
@ -3856,7 +3839,7 @@ class PclZip
$v_data = @fread($this->zip_fd, $p_entry['compressed_size']); $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
// ----- Decompress the file // ----- Decompress the file
if (($p_string = @gzinflate($v_data)) === FALSE) { if (($p_string = @gzinflate($v_data)) === false) {
// TBC // TBC
} }
} }
@ -4210,7 +4193,7 @@ class PclZip
//$v_bytes = ($v_bytes << 8) | Ord($v_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 // 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. // 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); $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
// ----- Compare the bytes // ----- Compare the bytes
if ($v_bytes == 0x504b0506) if ($v_bytes == 0x504b0506)
@ -4369,7 +4352,7 @@ class PclZip
// ----- Look for extract by ereg rule // ----- Look for extract by ereg rule
// ereg() is deprecated with PHP 5.3 // ereg() is deprecated with PHP 5.3
/* /*
else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
&& ($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'])) { if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
@ -4571,11 +4554,10 @@ class PclZip
// 1 : OK // 1 : OK
// -1 : Unable to create directory // -1 : Unable to create directory
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
function privDirCheck($p_dir, $p_is_dir=false) function privDirCheck($p_dir, $p_is_dir = false)
{ {
$v_result = 1; $v_result = 1;
// ----- Remove the final '/' // ----- Remove the final '/'
if (($p_is_dir) && (substr($p_dir, -1)=='/')) { if (($p_is_dir) && (substr($p_dir, -1)=='/')) {
$p_dir = substr($p_dir, 0, strlen($p_dir)-1); $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
@ -4849,7 +4831,7 @@ class PclZip
// Description : // Description :
// Parameters : // Parameters :
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
function privErrorLog($p_error_code=0, $p_error_string='') function privErrorLog($p_error_code = 0, $p_error_string = '')
{ {
if (PCLZIP_ERROR_EXTERNAL == 1) { if (PCLZIP_ERROR_EXTERNAL == 1) {
PclError($p_error_code, $p_error_string); PclError($p_error_code, $p_error_string);
@ -5030,10 +5012,10 @@ function PclZipUtilPathInclusion($p_dir, $p_path)
// ----- Look for path beginning by ./ // ----- Look for path beginning by ./
if (($p_dir == '.') || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { if (($p_dir == '.') || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
$p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); $p_dir = PclZipUtilTranslateWinPath(getcwd(), false).'/'.substr($p_dir, 1);
} }
if (($p_path == '.') || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { if (($p_path == '.') || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
$p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); $p_path = PclZipUtilTranslateWinPath(getcwd(), false).'/'.substr($p_path, 1);
} }
// ----- Explode dir and path by directory separator // ----- Explode dir and path by directory separator
@ -5057,7 +5039,7 @@ function PclZipUtilPathInclusion($p_dir, $p_path)
} }
// ----- Compare the items // ----- Compare the items
if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ($v_list_path[$j] != '')) {
$v_result = 0; $v_result = 0;
} }
@ -5097,7 +5079,7 @@ function PclZipUtilPathInclusion($p_dir, $p_path)
// 3 : src & dest gzip // 3 : src & dest gzip
// Return Values : // Return Values :
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode = 0)
{ {
$v_result = 1; $v_result = 1;
@ -5204,7 +5186,7 @@ function PclZipUtilOptionText($p_option)
// Return Values : // Return Values :
// The path translated. // The path translated.
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true)
{ {
if (stristr(php_uname(), 'windows')) { if (stristr(php_uname(), 'windows')) {
// ----- Look for potential disk letter // ----- Look for potential disk letter

View File

@ -526,21 +526,22 @@ class PHPExcel_Shared_String
* @author Rasmus Andersson {@link http://rasmusandersson.se/} * @author Rasmus Andersson {@link http://rasmusandersson.se/}
* @author vadik56 * @author vadik56
*/ */
public static function utf16_decode($str, $bom_be = TRUE) { public static function utf16_decode($str, $bom_be = true)
{
if (strlen($str) < 2) { if (strlen($str) < 2) {
return $str; return $str;
} }
$c0 = ord($str{0}); $c0 = ord($str{0});
$c1 = ord($str{1}); $c1 = ord($str{1});
if ($c0 == 0xfe && $c1 == 0xff) { if ($c0 == 0xfe && $c1 == 0xff) {
$str = substr($str,2); $str = substr($str, 2);
} elseif ($c0 == 0xff && $c1 == 0xfe) { } elseif ($c0 == 0xff && $c1 == 0xfe) {
$str = substr($str,2); $str = substr($str, 2);
$bom_be = false; $bom_be = false;
} }
$len = strlen($str); $len = strlen($str);
$newstr = ''; $newstr = '';
for($i=0;$i<$len;$i+=2) { for ($i=0; $i<$len; $i+=2) {
if ($bom_be) { if ($bom_be) {
$val = ord($str{$i}) << 4; $val = ord($str{$i}) << 4;
$val += ord($str{$i+1}); $val += ord($str{$i+1});

View File

@ -59,7 +59,8 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter
* @param int $pTemporaryStorage Temporary storage location * @param int $pTemporaryStorage Temporary storage location
* @param string $pTemporaryStorageFolder Temporary storage folder * @param string $pTemporaryStorageFolder Temporary storage folder
*/ */
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = null) { public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = null)
{
// Open temporary storage // Open temporary storage
if ($pTemporaryStorage == self::STORAGE_MEMORY) { if ($pTemporaryStorage == self::STORAGE_MEMORY) {
$this->openMemory(); $this->openMemory();

View File

@ -39,7 +39,7 @@ class PHPExcel_Best_Fit
* *
* @var boolean * @var boolean
**/ **/
protected $_error = False; protected $_error = false;
/** /**
* Algorithm type to use for best-fit * Algorithm type to use for best-fit
@ -163,7 +163,7 @@ class PHPExcel_Best_Fit
*/ */
public function getEquation($dp = 0) public function getEquation($dp = 0)
{ {
return False; return false;
} // function getEquation() } // function getEquation()
/** /**
@ -200,7 +200,7 @@ class PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
*/ */
public function getIntersect($dp=0) public function getIntersect($dp = 0)
{ {
if ($dp != 0) { if ($dp != 0) {
return round($this->_intersect, $dp); return round($this->_intersect, $dp);
@ -347,7 +347,7 @@ class PHPExcel_Best_Fit
$this->_SSRegression = $this->_goodnessOfFit * $SStot; $this->_SSRegression = $this->_goodnessOfFit * $SStot;
$this->_covariance = $SScov / $this->_valueCount; $this->_covariance = $SScov / $this->_valueCount;
$this->_correlation = ($this->_valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->_valueCount * $sumX2 - pow($sumX,2)) * ($this->_valueCount * $sumY2 - pow($sumY,2))); $this->_correlation = ($this->_valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->_valueCount * $sumX2 - pow($sumX, 2)) * ($this->_valueCount * $sumY2 - pow($sumY, 2)));
$this->_slopeSE = $this->_stdevOfResiduals / sqrt($SSsex); $this->_slopeSE = $this->_stdevOfResiduals / sqrt($SSsex);
$this->_intersectSE = $this->_stdevOfResiduals * sqrt(1 / ($this->_valueCount - ($sumX * $sumX) / $sumX2)); $this->_intersectSE = $this->_stdevOfResiduals * sqrt(1 / ($this->_valueCount - ($sumX * $sumX) / $sumX2));
if ($this->_SSResiduals != 0.0) { if ($this->_SSResiduals != 0.0) {
@ -373,7 +373,7 @@ class PHPExcel_Best_Fit
$meanX = $x_sum / $this->_valueCount; $meanX = $x_sum / $this->_valueCount;
$meanY = $y_sum / $this->_valueCount; $meanY = $y_sum / $this->_valueCount;
$mBase = $mDivisor = $xx_sum = $xy_sum = $yy_sum = 0.0; $mBase = $mDivisor = $xx_sum = $xy_sum = $yy_sum = 0.0;
for($i = 0; $i < $this->_valueCount; ++$i) { for ($i = 0; $i < $this->_valueCount; ++$i) {
$xy_sum += $xValues[$i] * $yValues[$i]; $xy_sum += $xValues[$i] * $yValues[$i];
$xx_sum += $xValues[$i] * $xValues[$i]; $xx_sum += $xValues[$i] * $xValues[$i];
$yy_sum += $yValues[$i] * $yValues[$i]; $yy_sum += $yValues[$i] * $yValues[$i];
@ -409,7 +409,7 @@ class PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
function __construct($yValues, $xValues = array(), $const = true) public function __construct($yValues, $xValues = array(), $const = true)
{ {
// Calculate number of points // Calculate number of points
$nY = count($yValues); $nY = count($yValues);

View File

@ -54,7 +54,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
**/ **/
public function getValueOfYForX($xValue) public function getValueOfYForX($xValue)
{ {
return $this->getIntersect() * pow($this->getSlope(),($xValue - $this->_Xoffset)); return $this->getIntersect() * pow($this->getSlope(), ($xValue - $this->_Xoffset));
} // function getValueOfYForX() } // function getValueOfYForX()
/** /**
@ -144,4 +144,4 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
$this->_exponential_regression($yValues, $xValues, $const); $this->_exponential_regression($yValues, $xValues, $const);
} }
} // function __construct() } // function __construct()
} }

View File

@ -106,4 +106,4 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
$this->_linear_regression($yValues, $xValues, $const); $this->_linear_regression($yValues, $xValues, $const);
} }
} // function __construct() } // function __construct()
} }

View File

@ -114,4 +114,4 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
$this->_logarithmic_regression($yValues, $xValues, $const); $this->_logarithmic_regression($yValues, $xValues, $const);
} }
} // function __construct() } // function __construct()
} }

View File

@ -161,7 +161,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
$x_sum = array_sum($xValues); $x_sum = array_sum($xValues);
$y_sum = array_sum($yValues); $y_sum = array_sum($yValues);
$xx_sum = $xy_sum = 0; $xx_sum = $xy_sum = 0;
for($i = 0; $i < $this->_valueCount; ++$i) { for ($i = 0; $i < $this->_valueCount; ++$i) {
$xy_sum += $xValues[$i] * $yValues[$i]; $xy_sum += $xValues[$i] * $yValues[$i];
$xx_sum += $xValues[$i] * $xValues[$i]; $xx_sum += $xValues[$i] * $xValues[$i];
$yy_sum += $yValues[$i] * $yValues[$i]; $yy_sum += $yValues[$i] * $yValues[$i];
@ -187,7 +187,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
$C = $matrixA->solve($matrixB); $C = $matrixA->solve($matrixB);
$coefficients = array(); $coefficients = array();
for($i = 0; $i < $C->m; ++$i) { for ($i = 0; $i < $C->m; ++$i) {
$r = $C->get($i, 0); $r = $C->get($i, 0);
if (abs($r) <= pow(10, -9)) { if (abs($r) <= pow(10, -9)) {
$r = 0; $r = 0;
@ -221,11 +221,11 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
$this->_order = $order; $this->_order = $order;
$this->_polynomial_regression($order, $yValues, $xValues, $const); $this->_polynomial_regression($order, $yValues, $xValues, $const);
if (($this->getGoodnessOfFit() < 0.0) || ($this->getGoodnessOfFit() > 1.0)) { if (($this->getGoodnessOfFit() < 0.0) || ($this->getGoodnessOfFit() > 1.0)) {
$this->_error = True; $this->_error = true;
} }
} else { } else {
$this->_error = True; $this->_error = true;
} }
} }
} // function __construct() } // function __construct()
} }