diff options
65 files changed, 7421 insertions, 7421 deletions
diff --git a/PHP_Compat/Compat.php b/PHP_Compat/Compat.php index 9a26269..5d7849c 100644 --- a/PHP_Compat/Compat.php +++ b/PHP_Compat/Compat.php @@ -1,100 +1,100 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: Compat.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Provides missing functionality in the form of constants and functions
- * for older versions of PHP
- *
- * Optionally, you may simply include the file.
- * e.g. require_once 'PHP/Compat/Function/scandir.php';
- *
- * @category PHP
- * @package PHP_Compat
- * @version 1.1.0
- * @author Aidan Lister <aidan@php.net>
- * @static
- */
-class PHP_Compat
-{
-
- /**
- * Load a function, or array of functions
- *
- * @param string|array $function The function or functions to load.
- * @return bool|array true if loaded, false if not
- */
- function loadFunction ($function)
- {
- if (is_array($function)) {
- $res = array ();
- foreach ($function as $singlefunc) {
- $res[] = PHP_Compat::loadFunction($singlefunc);
- }
- return $res;
- }
-
- else {
- if (!function_exists($function)) {
- $file = sprintf('PHP/Compat/Function/%s.php', $function);
-
- if ((@include_once $file) !== false) {
- return true;
- }
- }
-
- return false;
- }
- }
-
-
- /**
- * Load a constant, or array of constants
- *
- * @param string|array $constant The constant or constants to load.
- * @return bool|array true if loaded, false if not
- */
- function loadConstant ($constant)
- {
- if (is_array($constant)) {
- $res = array ();
- foreach ($constant as $singleconst) {
- $res[] = PHP_Compat::loadConstant($singleconst);
- }
- return $res;
- }
-
- else {
- if (!defined($constant)) {
- $file = sprintf('PHP/Compat/Constant/%s.php', $constant);
-
- if ((@include_once $file) !== false) {
- return true;
- }
- }
-
- return false;
- }
- }
-
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: Compat.php,v 1.2 2006/03/22 10:24:32 squareing Exp $ +// + + +/** + * Provides missing functionality in the form of constants and functions + * for older versions of PHP + * + * Optionally, you may simply include the file. + * e.g. require_once 'PHP/Compat/Function/scandir.php'; + * + * @category PHP + * @package PHP_Compat + * @version 1.1.0 + * @author Aidan Lister <aidan@php.net> + * @static + */ +class PHP_Compat +{ + + /** + * Load a function, or array of functions + * + * @param string|array $function The function or functions to load. + * @return bool|array true if loaded, false if not + */ + function loadFunction ($function) + { + if (is_array($function)) { + $res = array (); + foreach ($function as $singlefunc) { + $res[] = PHP_Compat::loadFunction($singlefunc); + } + return $res; + } + + else { + if (!function_exists($function)) { + $file = sprintf('PHP/Compat/Function/%s.php', $function); + + if ((@include_once $file) !== false) { + return true; + } + } + + return false; + } + } + + + /** + * Load a constant, or array of constants + * + * @param string|array $constant The constant or constants to load. + * @return bool|array true if loaded, false if not + */ + function loadConstant ($constant) + { + if (is_array($constant)) { + $res = array (); + foreach ($constant as $singleconst) { + $res[] = PHP_Compat::loadConstant($singleconst); + } + return $res; + } + + else { + if (!defined($constant)) { + $file = sprintf('PHP/Compat/Constant/%s.php', $constant); + + if ((@include_once $file) !== false) { + return true; + } + } + + return false; + } + } + +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Constant/E_STRICT.php b/PHP_Compat/Compat/Constant/E_STRICT.php index 90264c3..77b00fd 100644 --- a/PHP_Compat/Compat/Constant/E_STRICT.php +++ b/PHP_Compat/Compat/Constant/E_STRICT.php @@ -1,37 +1,37 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: E_STRICT.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace constant E_STRICT
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/ref.errorfunc
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- */
-if (!defined('E_STRICT')) {
- define('E_STRICT', 2048);
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: E_STRICT.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace constant E_STRICT + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/ref.errorfunc + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + */ +if (!defined('E_STRICT')) { + define('E_STRICT', 2048); +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Constant/FILE.php b/PHP_Compat/Compat/Constant/FILE.php index c8eeb6b..22d9342 100644 --- a/PHP_Compat/Compat/Constant/FILE.php +++ b/PHP_Compat/Compat/Constant/FILE.php @@ -1,53 +1,53 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: FILE.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace filesystem constants
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/ref.filesystem
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- */
-if (!defined('FILE_USE_INCLUDE_PATH')) {
- define('FILE_USE_INCLUDE_PATH', 1);
-}
-
-if (!defined('FILE_IGNORE_NEW_LINES')) {
- define('FILE_IGNORE_NEW_LINES', 2);
-}
-
-if (!defined('FILE_SKIP_EMPTY_LINES')) {
- define('FILE_SKIP_EMPTY_LINES', 4);
-}
-
-if (!defined('FILE_APPEND')) {
- define('FILE_APPEND', 8);
-}
-
-if (!defined('FILE_NO_DEFAULT_CONTEXT')) {
- define('FILE_NO_DEFAULT_CONTEXT', 16);
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: FILE.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace filesystem constants + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/ref.filesystem + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + */ +if (!defined('FILE_USE_INCLUDE_PATH')) { + define('FILE_USE_INCLUDE_PATH', 1); +} + +if (!defined('FILE_IGNORE_NEW_LINES')) { + define('FILE_IGNORE_NEW_LINES', 2); +} + +if (!defined('FILE_SKIP_EMPTY_LINES')) { + define('FILE_SKIP_EMPTY_LINES', 4); +} + +if (!defined('FILE_APPEND')) { + define('FILE_APPEND', 8); +} + +if (!defined('FILE_NO_DEFAULT_CONTEXT')) { + define('FILE_NO_DEFAULT_CONTEXT', 16); +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Constant/PATH_SEPARATOR.php b/PHP_Compat/Compat/Constant/PATH_SEPARATOR.php index 3e9a18e..bf4ab3c 100644 --- a/PHP_Compat/Compat/Constant/PATH_SEPARATOR.php +++ b/PHP_Compat/Compat/Constant/PATH_SEPARATOR.php @@ -1,39 +1,39 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: PATH_SEPARATOR.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace constant PATH_SEPARATOR
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/ref.dir
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.3.0-RC2
- */
-if (!defined('PATH_SEPARATOR')) { define('PATH_SEPARATOR',
- strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ?
- ';' :
- ':');
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: PATH_SEPARATOR.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace constant PATH_SEPARATOR + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/ref.dir + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.3.0-RC2 + */ +if (!defined('PATH_SEPARATOR')) { define('PATH_SEPARATOR', + strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? + ';' : + ':'); +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Constant/STD.php b/PHP_Compat/Compat/Constant/STD.php index d6703cd..1fce88e 100644 --- a/PHP_Compat/Compat/Constant/STD.php +++ b/PHP_Compat/Compat/Constant/STD.php @@ -1,45 +1,45 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: STD.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace commandline constants
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/features.commandline
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.3.0
- */
-if (!defined('STDIN')) {
- define('STDIN', fopen('php://stdin', 'r'));
-}
-
-if (!defined('STDOUT')) {
- define('STDOUT', fopen('php://stdout', 'w'));
-}
-
-if (!defined('STDERR')) {
- define('STDERR', fopen('php://stderr', 'w'));
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: STD.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace commandline constants + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/features.commandline + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.3.0 + */ +if (!defined('STDIN')) { + define('STDIN', fopen('php://stdin', 'r')); +} + +if (!defined('STDOUT')) { + define('STDOUT', fopen('php://stdout', 'w')); +} + +if (!defined('STDERR')) { + define('STDERR', fopen('php://stderr', 'w')); +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_change_key_case.php b/PHP_Compat/Compat/Function/array_change_key_case.php index 449fd7e..c9c53d6 100644 --- a/PHP_Compat/Compat/Function/array_change_key_case.php +++ b/PHP_Compat/Compat/Function/array_change_key_case.php @@ -1,65 +1,65 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Stephan Schmidt <schst@php.net> |
-// | Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: array_change_key_case.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-if (!defined('CASE_LOWER')) {
- define('CASE_LOWER', 0);
-}
-
-if (!defined('CASE_UPPER')) {
- define('CASE_UPPER', 1);
-}
-
-
-/**
- * Replace array_change_key_case()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.array_change_key_case
- * @author Stephan Schmidt <schst@php.net>
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.2.0
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('array_change_key_case'))
-{
- function array_change_key_case ($input, $case = CASE_LOWER)
- {
- if (!is_array($input)) {
- trigger_error('array_change_key_case(): The argument should be an array', E_USER_WARNING);
- return false;
- }
-
- $output = array ();
- $keys = array_keys($input);
- $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
-
- foreach ($keys as $key) {
- $output[$casefunc($key)] = $input[$key];
- }
-
- return $output;
- }
-}
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Stephan Schmidt <schst@php.net> | +// | Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: array_change_key_case.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +if (!defined('CASE_LOWER')) { + define('CASE_LOWER', 0); +} + +if (!defined('CASE_UPPER')) { + define('CASE_UPPER', 1); +} + + +/** + * Replace array_change_key_case() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.array_change_key_case + * @author Stephan Schmidt <schst@php.net> + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.2.0 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('array_change_key_case')) +{ + function array_change_key_case ($input, $case = CASE_LOWER) + { + if (!is_array($input)) { + trigger_error('array_change_key_case(): The argument should be an array', E_USER_WARNING); + return false; + } + + $output = array (); + $keys = array_keys($input); + $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper'; + + foreach ($keys as $key) { + $output[$casefunc($key)] = $input[$key]; + } + + return $output; + } +} ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_chunk.php b/PHP_Compat/Compat/Function/array_chunk.php index 54d4871..f4a24ce 100644 --- a/PHP_Compat/Compat/Function/array_chunk.php +++ b/PHP_Compat/Compat/Function/array_chunk.php @@ -1,76 +1,76 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: array_chunk.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace array_combine()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.array_chunk
- * @author Aidan Lister <aidan@php.net>
- * @author Thiemo Mättig (http://maettig.com)
- * @version $Revision: 1.1 $
- * @since PHP 4.2.0
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('array_chunk'))
-{
- function array_chunk ($input, $size, $preserve_keys = false)
- {
- if (!is_array($input)) {
- trigger_error('array_chunk() expects parameter 1 to be array, ' . gettype($input) . ' given', E_USER_WARNING);
- return null;
- }
-
- if (!is_numeric($size)) {
- trigger_error('array_chunk() expects parameter 2 to be long, ' . gettype($size) . ' given', E_USER_WARNING);
- return null;
- }
-
- $size = (int)$size;
- if ($size <= 0)
- {
- trigger_error('array_chunk() Size parameter expected to be greater than 0', E_USER_WARNING);
- return null;
- }
-
- $chunks = array();
- $i = 0;
-
- if ($preserve_keys !== false)
- {
- foreach ($input as $key => $value) {
- $chunks[(int)($i++ / $size)][$key] = $value;
- }
- }
- else
- {
- foreach ($input as $value) {
- $chunks[(int)($i++ / $size)][] = $value;
- }
- }
-
- return $chunks;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: array_chunk.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace array_combine() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.array_chunk + * @author Aidan Lister <aidan@php.net> + * @author Thiemo Mättig (http://maettig.com) + * @version $Revision: 1.2 $ + * @since PHP 4.2.0 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('array_chunk')) +{ + function array_chunk ($input, $size, $preserve_keys = false) + { + if (!is_array($input)) { + trigger_error('array_chunk() expects parameter 1 to be array, ' . gettype($input) . ' given', E_USER_WARNING); + return null; + } + + if (!is_numeric($size)) { + trigger_error('array_chunk() expects parameter 2 to be long, ' . gettype($size) . ' given', E_USER_WARNING); + return null; + } + + $size = (int)$size; + if ($size <= 0) + { + trigger_error('array_chunk() Size parameter expected to be greater than 0', E_USER_WARNING); + return null; + } + + $chunks = array(); + $i = 0; + + if ($preserve_keys !== false) + { + foreach ($input as $key => $value) { + $chunks[(int)($i++ / $size)][$key] = $value; + } + } + else + { + foreach ($input as $value) { + $chunks[(int)($i++ / $size)][] = $value; + } + } + + return $chunks; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_combine.php b/PHP_Compat/Compat/Function/array_combine.php index 8a6f963..7bd80e8 100644 --- a/PHP_Compat/Compat/Function/array_combine.php +++ b/PHP_Compat/Compat/Function/array_combine.php @@ -1,71 +1,71 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: array_combine.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace array_combine()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.array_combine
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('array_combine'))
-{
- function array_combine ($keys, $values)
- {
- if (!is_array($keys)) {
- trigger_error('array_combine() expects parameter 1 to be array, ' . gettype($keys) . ' given', E_USER_WARNING);
- return null;
- }
-
- if (!is_array($values)) {
- trigger_error('array_combine() expects parameter 2 to be array, ' . gettype($values) . ' given', E_USER_WARNING);
- return null;
- }
-
- if (count($keys) !== count($values)) {
- trigger_error('array_combine() Both parameters should have equal number of elements', E_USER_WARNING);
- return false;
- }
-
- if (count($keys) === 0 || count($values) === 0) {
- trigger_error('array_combine() Both parameters should have number of elements at least 0', E_USER_WARNING);
- return false;
- }
-
- $keys = array_values($keys);
- $values = array_values($values);
-
- $combined = array ();
-
- for ($i = 0, $cnt = count($values); $i < $cnt; $i++) {
- $combined[$keys[$i]] = $values[$i];
- }
-
- return $combined;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: array_combine.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace array_combine() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.array_combine + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('array_combine')) +{ + function array_combine ($keys, $values) + { + if (!is_array($keys)) { + trigger_error('array_combine() expects parameter 1 to be array, ' . gettype($keys) . ' given', E_USER_WARNING); + return null; + } + + if (!is_array($values)) { + trigger_error('array_combine() expects parameter 2 to be array, ' . gettype($values) . ' given', E_USER_WARNING); + return null; + } + + if (count($keys) !== count($values)) { + trigger_error('array_combine() Both parameters should have equal number of elements', E_USER_WARNING); + return false; + } + + if (count($keys) === 0 || count($values) === 0) { + trigger_error('array_combine() Both parameters should have number of elements at least 0', E_USER_WARNING); + return false; + } + + $keys = array_values($keys); + $values = array_values($values); + + $combined = array (); + + for ($i = 0, $cnt = count($values); $i < $cnt; $i++) { + $combined[$keys[$i]] = $values[$i]; + } + + return $combined; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_diff_assoc.php b/PHP_Compat/Compat/Function/array_diff_assoc.php index e190b3b..c473fe6 100644 --- a/PHP_Compat/Compat/Function/array_diff_assoc.php +++ b/PHP_Compat/Compat/Function/array_diff_assoc.php @@ -1,80 +1,80 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: array_diff_assoc.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace array_diff_assoc()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.array_diff_assoc
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.3.0
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('array_diff_assoc'))
-{
- function array_diff_assoc ()
- {
- // Check we have enough arguments
- $args = func_get_args();
- $count = count($args);
- if (count($args) < 2) {
- trigger_error('Wrong parameter count for array_diff_assoc()', E_USER_WARNING);
- return null;
- }
-
- // Check arrays
- for ($i = 0; $i < $count; $i++)
- {
- if (!is_array($args[$i])) {
- trigger_error('array_diff_assoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING);
- return null;
- }
- }
-
- // Get the comparison array
- $array_comp = array_shift($args);
- --$count;
-
- // Traverse values of the first array
- foreach ($array_comp as $key => $value)
- {
- // Loop through the other arrays
- for ($i = 0; $i < $count; $i++)
- {
- // Loop through this arrays key/value pairs and compare
- foreach ($args[$i] as $comp_key => $comp_value)
- {
- if ((string)$key === (string)$comp_key &&
- (string)$value === (string)$comp_value) {
-
- unset($array_comp[$key]);
- }
- }
- }
- }
-
- return $array_comp;
- }
-}
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: array_diff_assoc.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace array_diff_assoc() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.array_diff_assoc + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.3.0 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('array_diff_assoc')) +{ + function array_diff_assoc () + { + // Check we have enough arguments + $args = func_get_args(); + $count = count($args); + if (count($args) < 2) { + trigger_error('Wrong parameter count for array_diff_assoc()', E_USER_WARNING); + return null; + } + + // Check arrays + for ($i = 0; $i < $count; $i++) + { + if (!is_array($args[$i])) { + trigger_error('array_diff_assoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); + return null; + } + } + + // Get the comparison array + $array_comp = array_shift($args); + --$count; + + // Traverse values of the first array + foreach ($array_comp as $key => $value) + { + // Loop through the other arrays + for ($i = 0; $i < $count; $i++) + { + // Loop through this arrays key/value pairs and compare + foreach ($args[$i] as $comp_key => $comp_value) + { + if ((string)$key === (string)$comp_key && + (string)$value === (string)$comp_value) { + + unset($array_comp[$key]); + } + } + } + } + + return $array_comp; + } +} ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_key_exists.php b/PHP_Compat/Compat/Function/array_key_exists.php index 5b4230b..46e2b21 100644 --- a/PHP_Compat/Compat/Function/array_key_exists.php +++ b/PHP_Compat/Compat/Function/array_key_exists.php @@ -1,56 +1,56 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: array_key_exists.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace array_key_exists()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/array_key_exists
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.1.0
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('array_key_exists'))
-{
- function array_key_exists ($key, $search)
- {
- if (!is_scalar($key)) {
- trigger_error('array_key_exists() The first argument should be either a string or an integer', E_USER_WARNING);
- return false;
- }
-
- if (is_object($search)) {
- $search = get_object_vars($search);
- }
-
- if (!is_array($search)) {
- trigger_error('array_key_exists() The second argument should be either an array or an object', E_USER_WARNING);
- return false;
- }
-
- return in_array($key, array_keys($search));
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: array_key_exists.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace array_key_exists() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/array_key_exists + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.1.0 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('array_key_exists')) +{ + function array_key_exists ($key, $search) + { + if (!is_scalar($key)) { + trigger_error('array_key_exists() The first argument should be either a string or an integer', E_USER_WARNING); + return false; + } + + if (is_object($search)) { + $search = get_object_vars($search); + } + + if (!is_array($search)) { + trigger_error('array_key_exists() The second argument should be either an array or an object', E_USER_WARNING); + return false; + } + + return in_array($key, array_keys($search)); + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_search.php b/PHP_Compat/Compat/Function/array_search.php index 142c4ad..582427b 100644 --- a/PHP_Compat/Compat/Function/array_search.php +++ b/PHP_Compat/Compat/Function/array_search.php @@ -1,54 +1,54 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: array_search.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace array_search()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/array_search
- * @author Aidan Lister <aidan@php.net>
- * @author Thiemo Mättig (http://maettig.com/)
- * @version $Revision: 1.1 $
- * @since PHP 4.0.5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('array_search'))
-{
- function array_search ($needle, $haystack, $strict = false)
- {
- if (!is_array($haystack)) {
- trigger_error("array_search() Wrong datatype for second argument", E_USER_WARNING);
- return false;
- }
-
- foreach ($haystack as $key => $value) {
- if ($strict ? $value === $needle : $value == $needle) {
- return $key;
- }
- }
-
- return false;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: array_search.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace array_search() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/array_search + * @author Aidan Lister <aidan@php.net> + * @author Thiemo Mättig (http://maettig.com/) + * @version $Revision: 1.2 $ + * @since PHP 4.0.5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('array_search')) +{ + function array_search ($needle, $haystack, $strict = false) + { + if (!is_array($haystack)) { + trigger_error("array_search() Wrong datatype for second argument", E_USER_WARNING); + return false; + } + + foreach ($haystack as $key => $value) { + if ($strict ? $value === $needle : $value == $needle) { + return $key; + } + } + + return false; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_udiff.php b/PHP_Compat/Compat/Function/array_udiff.php index 1d1c5d4..4f35dff 100644 --- a/PHP_Compat/Compat/Function/array_udiff.php +++ b/PHP_Compat/Compat/Function/array_udiff.php @@ -1,84 +1,84 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Stephan Schmidt <schst@php.net> |
-// | Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: array_udiff.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace array_udiff()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.array_udiff
- * @author Stephan Schmidt <schst@php.net>
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('array_udiff'))
-{
- function array_udiff ()
- {
- $args = func_get_args();
-
- if (count($args) < 3) {
- trigger_error('Wrong parameter count for array_udiff()', E_USER_WARNING);
- return null;
- }
-
- // Get compare function
- $compare_func = array_pop($args);
- if (!is_callable($compare_func)) {
- if (is_array($compare_func)) {
- $compare_func = $compare_func[0] . '::' . $compare_func[1];
- }
- trigger_error('array_udiff() Not a valid callback ' . $compare_func, E_USER_WARNING);
- return null;
- }
-
- // Check arrays
- $cnt = count($args);
- for ($i = 0; $i < $cnt; $i++) {
- if (!is_array($args[$i])) {
- trigger_error('array_udiff() Argument #' . ($i + 1). ' is not an array', E_USER_WARNING);
- return null;
- }
- }
-
- $diff = array ();
- // Traverse values of the first array
- foreach ($args[0] as $key => $value) {
- // Check all arrays
- for ($i = 1; $i < $cnt; $i++) {
- foreach ($args[$i] as $cmp_value) {
- $result = call_user_func($compare_func, $value, $cmp_value);
- if ($result === 0) {
- continue 3;
- }
- }
- }
- $diff[$key] = $value;
- }
- return $diff;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Stephan Schmidt <schst@php.net> | +// | Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: array_udiff.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace array_udiff() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.array_udiff + * @author Stephan Schmidt <schst@php.net> + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('array_udiff')) +{ + function array_udiff () + { + $args = func_get_args(); + + if (count($args) < 3) { + trigger_error('Wrong parameter count for array_udiff()', E_USER_WARNING); + return null; + } + + // Get compare function + $compare_func = array_pop($args); + if (!is_callable($compare_func)) { + if (is_array($compare_func)) { + $compare_func = $compare_func[0] . '::' . $compare_func[1]; + } + trigger_error('array_udiff() Not a valid callback ' . $compare_func, E_USER_WARNING); + return null; + } + + // Check arrays + $cnt = count($args); + for ($i = 0; $i < $cnt; $i++) { + if (!is_array($args[$i])) { + trigger_error('array_udiff() Argument #' . ($i + 1). ' is not an array', E_USER_WARNING); + return null; + } + } + + $diff = array (); + // Traverse values of the first array + foreach ($args[0] as $key => $value) { + // Check all arrays + for ($i = 1; $i < $cnt; $i++) { + foreach ($args[$i] as $cmp_value) { + $result = call_user_func($compare_func, $value, $cmp_value); + if ($result === 0) { + continue 3; + } + } + } + $diff[$key] = $value; + } + return $diff; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/array_udiff_assoc.php b/PHP_Compat/Compat/Function/array_udiff_assoc.php index 5f62d8e..70e8242 100644 --- a/PHP_Compat/Compat/Function/array_udiff_assoc.php +++ b/PHP_Compat/Compat/Function/array_udiff_assoc.php @@ -1,90 +1,90 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Stephan Schmidt <schst@php.net> |
-// | Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: array_udiff_assoc.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace array_udiff_assoc()
- *
- * @category PHP
- * @package PHP_Compat
- * @author Stephan Schmidt <schst@php.net>
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @link http://php.net/function.array-udiff-assoc
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('array_udiff_assoc'))
-{
- function array_udiff_assoc ()
- {
- $args = func_get_args();
- if (count($args) < 3) {
- trigger_error('Wrong parameter count for array_udiff()', E_USER_WARNING);
- return null;
- }
-
- // Get compare function
- $compare_func = array_pop($args);
- if (!is_callable($compare_func))
- {
- if (is_array($compare_func)) {
- $compare_func = $compare_func[0].'::'.$compare_func[1];
- }
- trigger_error('array_udiff() Not a valid callback ' . $compare_func, E_USER_WARNING);
- return null;
- }
-
- // Check arrays
- $count = count($args);
- for ($i = 0; $i < $count; $i++)
- {
- if (!is_array($args[$i])) {
- trigger_error('array_udiff() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING);
- return null;
- }
- }
-
- $diff = array ();
- // Traverse values of the first array
- foreach ($args[0] as $key => $value)
- {
- // Check all arrays
- for ($i = 1; $i < $count; $i++)
- {
- if (!isset($args[$i][$key])) {
- continue;
- }
- $result = call_user_func($compare_func, $value, $args[$i][$key]);
- if ($result === 0) {
- continue 2;
- }
- }
-
- $diff[$key] = $value;
- }
-
- return $diff;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Stephan Schmidt <schst@php.net> | +// | Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: array_udiff_assoc.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace array_udiff_assoc() + * + * @category PHP + * @package PHP_Compat + * @author Stephan Schmidt <schst@php.net> + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @link http://php.net/function.array-udiff-assoc + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('array_udiff_assoc')) +{ + function array_udiff_assoc () + { + $args = func_get_args(); + if (count($args) < 3) { + trigger_error('Wrong parameter count for array_udiff()', E_USER_WARNING); + return null; + } + + // Get compare function + $compare_func = array_pop($args); + if (!is_callable($compare_func)) + { + if (is_array($compare_func)) { + $compare_func = $compare_func[0].'::'.$compare_func[1]; + } + trigger_error('array_udiff() Not a valid callback ' . $compare_func, E_USER_WARNING); + return null; + } + + // Check arrays + $count = count($args); + for ($i = 0; $i < $count; $i++) + { + if (!is_array($args[$i])) { + trigger_error('array_udiff() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); + return null; + } + } + + $diff = array (); + // Traverse values of the first array + foreach ($args[0] as $key => $value) + { + // Check all arrays + for ($i = 1; $i < $count; $i++) + { + if (!isset($args[$i][$key])) { + continue; + } + $result = call_user_func($compare_func, $value, $args[$i][$key]); + if ($result === 0) { + continue 2; + } + } + + $diff[$key] = $value; + } + + return $diff; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/call_user_func_array.php b/PHP_Compat/Compat/Function/call_user_func_array.php index 9675667..fd8e045 100644 --- a/PHP_Compat/Compat/Function/call_user_func_array.php +++ b/PHP_Compat/Compat/Function/call_user_func_array.php @@ -1,80 +1,80 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: call_user_func_array.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace call_user_func_array()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/call_user_func_array
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.0.4
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('call_user_func_array'))
-{
- function call_user_func_array ($function, $param_arr)
- {
- $param_arr = (array) $param_arr;
-
- // Sanity check
- if (!is_callable($function))
- {
- if (is_array($function) && count($function) > 2) {
- $function = $function[0] . '::' . $function[1];
- }
- $error = sprintf('call_user_func_array() First argument is expected to be a valid callback, \'%s\' was given', $function);
- trigger_error($error, E_USER_WARNING);
- return null;
- }
-
- // Build argument string
- $arg_string = '';
- $comma = '';
- for ($i = 0, $x = count($param_arr); $i < $x; $i++) {
- $arg_string .= $comma . "\$param_arr[$i]";
- $comma = ', ';
- }
-
- // Determine method of calling function
- if (is_array($function))
- {
- $object =& $function[0];
- $method = $function[1];
-
- // Static vs method call
- if (is_string($function[0])) {
- eval("\$retval = $object::\$method($arg_string);");
- } else {
- eval("\$retval = \$object->\$method($arg_string);");
- }
- }
- else {
- eval("\$retval = \$function($arg_string);");
- }
-
- return $retval;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: call_user_func_array.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace call_user_func_array() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/call_user_func_array + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.0.4 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('call_user_func_array')) +{ + function call_user_func_array ($function, $param_arr) + { + $param_arr = (array) $param_arr; + + // Sanity check + if (!is_callable($function)) + { + if (is_array($function) && count($function) > 2) { + $function = $function[0] . '::' . $function[1]; + } + $error = sprintf('call_user_func_array() First argument is expected to be a valid callback, \'%s\' was given', $function); + trigger_error($error, E_USER_WARNING); + return null; + } + + // Build argument string + $arg_string = ''; + $comma = ''; + for ($i = 0, $x = count($param_arr); $i < $x; $i++) { + $arg_string .= $comma . "\$param_arr[$i]"; + $comma = ', '; + } + + // Determine method of calling function + if (is_array($function)) + { + $object =& $function[0]; + $method = $function[1]; + + // Static vs method call + if (is_string($function[0])) { + eval("\$retval = $object::\$method($arg_string);"); + } else { + eval("\$retval = \$object->\$method($arg_string);"); + } + } + else { + eval("\$retval = \$function($arg_string);"); + } + + return $retval; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/constant.php b/PHP_Compat/Compat/Function/constant.php index ad99389..91ce1cb 100644 --- a/PHP_Compat/Compat/Function/constant.php +++ b/PHP_Compat/Compat/Function/constant.php @@ -1,50 +1,50 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: constant.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace constant()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/constant
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.0.4
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('constant'))
-{
- function constant ($constant)
- {
- if (!defined($constant)) {
- $error = sprintf('constant() Couldn\'t find constant %s', $constant);
- trigger_error($error, E_USER_WARNING);
- return false;
- }
-
- eval("\$value=$constant;");
-
- return $value;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: constant.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace constant() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/constant + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.0.4 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('constant')) +{ + function constant ($constant) + { + if (!defined($constant)) { + $error = sprintf('constant() Couldn\'t find constant %s', $constant); + trigger_error($error, E_USER_WARNING); + return false; + } + + eval("\$value=$constant;"); + + return $value; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/file_get_contents.php b/PHP_Compat/Compat/Function/file_get_contents.php index 6edb194..a10649d 100644 --- a/PHP_Compat/Compat/Function/file_get_contents.php +++ b/PHP_Compat/Compat/Function/file_get_contents.php @@ -1,61 +1,61 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: file_get_contents.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace file_get_contents()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.file_get_contents
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @internal resource_context is not supported
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('file_get_contents'))
-{
- function file_get_contents ($filename, $incpath = false, $resource_context = null)
- {
- if (false === $fh = fopen($filename, 'rb', $incpath)) {
- trigger_error('file_get_contents() failed to open stream: No such file or directory', E_USER_WARNING);
- return false;
- }
-
- clearstatcache();
- if ($fsize = filesize($filename)) {
- $data = fread($fh, $fsize);
- }
-
- else {
- while (!feof($fh)) {
- $data .= fread($fh, 8192);
- }
- }
-
- fclose($fh);
-
- return $data;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: file_get_contents.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace file_get_contents() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.file_get_contents + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @internal resource_context is not supported + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('file_get_contents')) +{ + function file_get_contents ($filename, $incpath = false, $resource_context = null) + { + if (false === $fh = fopen($filename, 'rb', $incpath)) { + trigger_error('file_get_contents() failed to open stream: No such file or directory', E_USER_WARNING); + return false; + } + + clearstatcache(); + if ($fsize = filesize($filename)) { + $data = fread($fh, $fsize); + } + + else { + while (!feof($fh)) { + $data .= fread($fh, 8192); + } + } + + fclose($fh); + + return $data; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/file_put_contents.php b/PHP_Compat/Compat/Function/file_put_contents.php index da26ae4..c82b484 100644 --- a/PHP_Compat/Compat/Function/file_put_contents.php +++ b/PHP_Compat/Compat/Function/file_put_contents.php @@ -1,105 +1,105 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: file_put_contents.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-if (!defined('FILE_USE_INCLUDE_PATH')) {
- define('FILE_USE_INCLUDE_PATH', 1);
-}
-
-if (!defined('FILE_APPEND')) {
- define('FILE_APPEND', 8);
-}
-
-
-/**
- * Replace file_put_contents()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.file_put_contents
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @internal $resource_context is not supported
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('file_put_contents'))
-{
- function file_put_contents ($filename, $content, $flags = null, $resource_context = null)
- {
- // If $content is an array, convert it to a string
- if (is_array($content)) {
- $content = implode('', $content);
- }
-
- // If we don't have a string, throw an error
- if (!is_string($content)) {
- trigger_error('file_put_contents() The 2nd parameter should be either a string or an array', E_USER_WARNING);
- return false;
- }
-
- // Get the length of date to write
- $length = strlen($content);
-
- // Check what mode we are using
- $mode = ($flags & FILE_APPEND) ?
- $mode = 'a' :
- $mode = 'w';
-
- // Check if we're using the include path
- $use_inc_path = ($flags & FILE_USE_INCLUDE_PATH) ?
- true :
- false;
-
- // Open the file for writing
- if (($fh = @fopen($filename, $mode, $use_inc_path)) === false) {
- trigger_error('file_put_contents() failed to open stream: Permission denied', E_USER_WARNING);
- return false;
- }
-
- // Write to the file
- $bytes = 0;
- if (($bytes = @fwrite($fh, $content)) === false) {
- $errormsg = sprintf('file_put_contents() Failed to write %d bytes to %s',
- $length,
- $filename);
- trigger_error($errormsg, E_USER_WARNING);
- return false;
- }
-
- // Close the handle
- @fclose($fh);
-
- // Check all the data was written
- if ($bytes != $length) {
- $errormsg = sprintf('file_put_contents() Only %d of %d bytes written, possibly out of free disk space.',
- $bytes,
- $length);
- trigger_error($errormsg, E_USER_WARNING);
- return false;
- }
-
- // Return length
- return $bytes;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: file_put_contents.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +if (!defined('FILE_USE_INCLUDE_PATH')) { + define('FILE_USE_INCLUDE_PATH', 1); +} + +if (!defined('FILE_APPEND')) { + define('FILE_APPEND', 8); +} + + +/** + * Replace file_put_contents() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.file_put_contents + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @internal $resource_context is not supported + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('file_put_contents')) +{ + function file_put_contents ($filename, $content, $flags = null, $resource_context = null) + { + // If $content is an array, convert it to a string + if (is_array($content)) { + $content = implode('', $content); + } + + // If we don't have a string, throw an error + if (!is_string($content)) { + trigger_error('file_put_contents() The 2nd parameter should be either a string or an array', E_USER_WARNING); + return false; + } + + // Get the length of date to write + $length = strlen($content); + + // Check what mode we are using + $mode = ($flags & FILE_APPEND) ? + $mode = 'a' : + $mode = 'w'; + + // Check if we're using the include path + $use_inc_path = ($flags & FILE_USE_INCLUDE_PATH) ? + true : + false; + + // Open the file for writing + if (($fh = @fopen($filename, $mode, $use_inc_path)) === false) { + trigger_error('file_put_contents() failed to open stream: Permission denied', E_USER_WARNING); + return false; + } + + // Write to the file + $bytes = 0; + if (($bytes = @fwrite($fh, $content)) === false) { + $errormsg = sprintf('file_put_contents() Failed to write %d bytes to %s', + $length, + $filename); + trigger_error($errormsg, E_USER_WARNING); + return false; + } + + // Close the handle + @fclose($fh); + + // Check all the data was written + if ($bytes != $length) { + $errormsg = sprintf('file_put_contents() Only %d of %d bytes written, possibly out of free disk space.', + $bytes, + $length); + trigger_error($errormsg, E_USER_WARNING); + return false; + } + + // Return length + return $bytes; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/fprintf.php b/PHP_Compat/Compat/Function/fprintf.php index 877f0bd..ff194da 100644 --- a/PHP_Compat/Compat/Function/fprintf.php +++ b/PHP_Compat/Compat/Function/fprintf.php @@ -1,56 +1,56 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: fprintf.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace fprintf()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.fprintf
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('fprintf'))
-{
- function fprintf () {
- $args = func_get_args();
-
- if (count($args) < 2) {
- trigger_error ('Wrong parameter count for fprintf()', E_USER_WARNING);
- return null;
- }
-
- $resource_handle = array_shift($args);
- $format = array_shift($args);
-
- if (!is_resource($resource_handle)) {
- trigger_error ('fprintf(): supplied argument is not a valid stream resource', E_USER_WARNING);
- return false;
- }
-
- return fwrite($resource_handle, vsprintf($format, $args));
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: fprintf.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace fprintf() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.fprintf + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('fprintf')) +{ + function fprintf () { + $args = func_get_args(); + + if (count($args) < 2) { + trigger_error ('Wrong parameter count for fprintf()', E_USER_WARNING); + return null; + } + + $resource_handle = array_shift($args); + $format = array_shift($args); + + if (!is_resource($resource_handle)) { + trigger_error ('fprintf(): supplied argument is not a valid stream resource', E_USER_WARNING); + return false; + } + + return fwrite($resource_handle, vsprintf($format, $args)); + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/html_entity_decode.php b/PHP_Compat/Compat/Function/html_entity_decode.php index fbeb195..73315fe 100644 --- a/PHP_Compat/Compat/Function/html_entity_decode.php +++ b/PHP_Compat/Compat/Function/html_entity_decode.php @@ -1,74 +1,74 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: David Irvine <dave@codexweb.co.za> |
-// | Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: html_entity_decode.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-if (!defined('ENT_NOQUOTES')) {
- define('ENT_NOQUOTES', 0);
-}
-
-if (!defined('ENT_COMPAT')) {
- define('ENT_COMPAT', 2);
-}
-
-if (!defined('ENT_QUOTES')) {
- define('ENT_QUOTES', 3);
-}
-
-
-/**
- * Replace html_entity_decode()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.html_entity_decode
- * @author David Irvine <dave@codexweb.co.za>
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.3.0
- * @internal Setting the charset will not do anything
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('html_entity_decode'))
-{
- function html_entity_decode ($string, $quote_style = ENT_COMPAT, $charset = null)
- {
- if (!is_int($quote_style)) {
- trigger_error('html_entity_decode() expects parameter 2 to be long, ' . gettype($quote_style) . ' given', E_USER_WARNING);
- return null;
- }
-
- $trans_tbl = get_html_translation_table(HTML_ENTITIES);
- $trans_tbl = array_flip($trans_tbl);
-
- // Add single quote to translation table;
- $trans_tbl['''] = '\'';
-
- // Not translating double quotes
- if ($quote_style & ENT_NOQUOTES) {
- // Remove double quote from translation table
- unset($trans_tbl['"']);
- }
-
- return strtr($string, $trans_tbl);
- }
-}
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: David Irvine <dave@codexweb.co.za> | +// | Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: html_entity_decode.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +if (!defined('ENT_NOQUOTES')) { + define('ENT_NOQUOTES', 0); +} + +if (!defined('ENT_COMPAT')) { + define('ENT_COMPAT', 2); +} + +if (!defined('ENT_QUOTES')) { + define('ENT_QUOTES', 3); +} + + +/** + * Replace html_entity_decode() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.html_entity_decode + * @author David Irvine <dave@codexweb.co.za> + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.3.0 + * @internal Setting the charset will not do anything + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('html_entity_decode')) +{ + function html_entity_decode ($string, $quote_style = ENT_COMPAT, $charset = null) + { + if (!is_int($quote_style)) { + trigger_error('html_entity_decode() expects parameter 2 to be long, ' . gettype($quote_style) . ' given', E_USER_WARNING); + return null; + } + + $trans_tbl = get_html_translation_table(HTML_ENTITIES); + $trans_tbl = array_flip($trans_tbl); + + // Add single quote to translation table; + $trans_tbl['''] = '\''; + + // Not translating double quotes + if ($quote_style & ENT_NOQUOTES) { + // Remove double quote from translation table + unset($trans_tbl['"']); + } + + return strtr($string, $trans_tbl); + } +} ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/http_build_query.php b/PHP_Compat/Compat/Function/http_build_query.php index 97f0323..e73f623 100644 --- a/PHP_Compat/Compat/Function/http_build_query.php +++ b/PHP_Compat/Compat/Function/http_build_query.php @@ -1,101 +1,101 @@ -<?PHP
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Stephan Schmidt <schst@php.net> |
-// | Aidan Lister <aidan@php.net>
-// +----------------------------------------------------------------------+
-//
-// $Id: http_build_query.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace function http_build_query()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.http-build-query
- * @author Stephan Schmidt <schst@php.net>
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('http_build_query'))
-{
- function http_build_query ($formdata, $numeric_prefix = null)
- {
- // If $formdata is an object, convert it to an array
- if (is_object($formdata)) {
- $formdata = get_object_vars($formdata);
- }
-
- // Check we have an array to work with
- if (!is_array($formdata)) {
- trigger_error('http_build_query() Parameter 1 expected to be Array or Object. Incorrect value given.', E_USER_WARNING);
- return false;
- }
-
- // If the array is empty, return null
- if (empty($formdata)) {
- return null;
- }
-
- // Start building the query
- $tmp = array ();
- foreach ($formdata as $key => $val)
- {
- if (is_integer($key) && $numeric_prefix != null) {
- $key = $numeric_prefix . $key;
- }
-
- if (is_scalar($val)) {
- array_push($tmp, urlencode($key).'='.urlencode($val));
- continue;
- }
-
- // If the value is an array, recursively parse it
- if (is_array($val)) {
- array_push($tmp, __http_build_query($val, urlencode($key)));
- continue;
- }
- }
-
- return implode('&', $tmp);
- }
-
- // Helper function
- function __http_build_query ($array, $name)
- {
- $tmp = array ();
- foreach ($array as $key => $value)
- {
- if (is_array($value)) {
- array_push($tmp, __http_build_query($value, sprintf('%s[%s]', $name, $key)));
- }
-
- elseif (is_scalar($value)) {
- array_push($tmp, sprintf('%s[%s]=%s', $name, urlencode($key), urlencode($value)));
- }
-
- elseif (is_object($value)) {
- array_push($tmp, __http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key)));
- }
- }
-
- return implode('&', $tmp);
- }
-}
+<?PHP +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Stephan Schmidt <schst@php.net> | +// | Aidan Lister <aidan@php.net> +// +----------------------------------------------------------------------+ +// +// $Id: http_build_query.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace function http_build_query() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.http-build-query + * @author Stephan Schmidt <schst@php.net> + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('http_build_query')) +{ + function http_build_query ($formdata, $numeric_prefix = null) + { + // If $formdata is an object, convert it to an array + if (is_object($formdata)) { + $formdata = get_object_vars($formdata); + } + + // Check we have an array to work with + if (!is_array($formdata)) { + trigger_error('http_build_query() Parameter 1 expected to be Array or Object. Incorrect value given.', E_USER_WARNING); + return false; + } + + // If the array is empty, return null + if (empty($formdata)) { + return null; + } + + // Start building the query + $tmp = array (); + foreach ($formdata as $key => $val) + { + if (is_integer($key) && $numeric_prefix != null) { + $key = $numeric_prefix . $key; + } + + if (is_scalar($val)) { + array_push($tmp, urlencode($key).'='.urlencode($val)); + continue; + } + + // If the value is an array, recursively parse it + if (is_array($val)) { + array_push($tmp, __http_build_query($val, urlencode($key))); + continue; + } + } + + return implode('&', $tmp); + } + + // Helper function + function __http_build_query ($array, $name) + { + $tmp = array (); + foreach ($array as $key => $value) + { + if (is_array($value)) { + array_push($tmp, __http_build_query($value, sprintf('%s[%s]', $name, $key))); + } + + elseif (is_scalar($value)) { + array_push($tmp, sprintf('%s[%s]=%s', $name, urlencode($key), urlencode($value))); + } + + elseif (is_object($value)) { + array_push($tmp, __http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key))); + } + } + + return implode('&', $tmp); + } +} ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/image_type_to_mime_type.php b/PHP_Compat/Compat/Function/image_type_to_mime_type.php index b038cb0..17c8848 100644 --- a/PHP_Compat/Compat/Function/image_type_to_mime_type.php +++ b/PHP_Compat/Compat/Function/image_type_to_mime_type.php @@ -1,128 +1,128 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: image_type_to_mime_type.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-if (!defined('IMAGETYPE_GIF')) {
- define('IMAGETYPE_GIF', 0);
-}
-
-if (!defined('IMAGETYPE_JPEG')) {
- define('IMAGETYPE_JPEG', 1);
-}
-
-if (!defined('IMAGETYPE_PNG')) {
- define('IMAGETYPE_PNG', 2);
-}
-
-if (!defined('IMAGETYPE_SWF')) {
- define('IMAGETYPE_SWF', 3);
-}
-
-if (!defined('IMAGETYPE_PSD')) {
- define('IMAGETYPE_PSD', 4);
-}
-
-if (!defined('IMAGETYPE_BMP')) {
- define('IMAGETYPE_BMP', 5);
-}
-
-if (!defined('IMAGETYPE_TIFF_II')) {
- define('IMAGETYPE_TIFF_II', 6);
-}
-
-if (!defined('IMAGETYPE_TIFF_MM')) {
- define('IMAGETYPE_TIFF_MM', 7);
-}
-
-if (!defined('IMAGETYPE_JPC')) {
- define('IMAGETYPE_JPC', 8);
-}
-
-if (!defined('IMAGETYPE_JP2')) {
- define('IMAGETYPE_JP2', 9);
-}
-
-if (!defined('IMAGETYPE_JPX')) {
- define('IMAGETYPE_JPX', 10);
-}
-
-if (!defined('IMAGETYPE_JB2')) {
- define('IMAGETYPE_JB2', 11);
-}
-
-if (!defined('IMAGETYPE_SWC')) {
- define('IMAGETYPE_SWC', 12);
-}
-
-if (!defined('IMAGETYPE_IFF')) {
- define('IMAGETYPE_IFF', 13);
-}
-
-if (!defined('IMAGETYPE_WBMP')) {
- define('IMAGETYPE_WBMP', 14);
-}
-
-if (!defined('IMAGETYPE_XBM')) {
- define('IMAGETYPE_XBM', 15);
-}
-
-
-/**
- * Replace image_type_to_mime_type()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.image_type_to_mime_type
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.3.0
- * @require PHP 3
- */
-if (!function_exists('image_type_to_mime_type'))
-{
- function image_type_to_mime_type ($imagetype)
- {
- static $image_type_to_mime_type = array (
- IMAGETYPE_GIF => 'image/gif',
- IMAGETYPE_JPEG => 'image/jpeg',
- IMAGETYPE_PNG => 'image/png',
- IMAGETYPE_SWF => 'application/x-shockwave-flash',
- IMAGETYPE_PSD => 'image/psd',
- IMAGETYPE_BMP => 'image/bmp',
- IMAGETYPE_TIFF_II => 'image/tiff',
- IMAGETYPE_TIFF_MM => 'image/tiff',
- IMAGETYPE_JPC => 'application/octet-stream',
- IMAGETYPE_JP2 => 'image/jp2',
- IMAGETYPE_JPX => 'application/octet-stream',
- IMAGETYPE_JB2 => 'application/octet-stream',
- IMAGETYPE_SWC => 'application/x-shockwave-flash',
- IMAGETYPE_IFF => 'image/iff',
- IMAGETYPE_WBMP => 'image/vnd.wap.wbmp',
- IMAGETYPE_XBM => 'image/xbm',
- );
-
- return (isset($image_type_to_mime_type[$imagetype]) ?
- $image_type_to_mime_type[$imagetype] :
- $image_type_to_mime_type[IMAGETYPE_JPC]);
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: image_type_to_mime_type.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +if (!defined('IMAGETYPE_GIF')) { + define('IMAGETYPE_GIF', 0); +} + +if (!defined('IMAGETYPE_JPEG')) { + define('IMAGETYPE_JPEG', 1); +} + +if (!defined('IMAGETYPE_PNG')) { + define('IMAGETYPE_PNG', 2); +} + +if (!defined('IMAGETYPE_SWF')) { + define('IMAGETYPE_SWF', 3); +} + +if (!defined('IMAGETYPE_PSD')) { + define('IMAGETYPE_PSD', 4); +} + +if (!defined('IMAGETYPE_BMP')) { + define('IMAGETYPE_BMP', 5); +} + +if (!defined('IMAGETYPE_TIFF_II')) { + define('IMAGETYPE_TIFF_II', 6); +} + +if (!defined('IMAGETYPE_TIFF_MM')) { + define('IMAGETYPE_TIFF_MM', 7); +} + +if (!defined('IMAGETYPE_JPC')) { + define('IMAGETYPE_JPC', 8); +} + +if (!defined('IMAGETYPE_JP2')) { + define('IMAGETYPE_JP2', 9); +} + +if (!defined('IMAGETYPE_JPX')) { + define('IMAGETYPE_JPX', 10); +} + +if (!defined('IMAGETYPE_JB2')) { + define('IMAGETYPE_JB2', 11); +} + +if (!defined('IMAGETYPE_SWC')) { + define('IMAGETYPE_SWC', 12); +} + +if (!defined('IMAGETYPE_IFF')) { + define('IMAGETYPE_IFF', 13); +} + +if (!defined('IMAGETYPE_WBMP')) { + define('IMAGETYPE_WBMP', 14); +} + +if (!defined('IMAGETYPE_XBM')) { + define('IMAGETYPE_XBM', 15); +} + + +/** + * Replace image_type_to_mime_type() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.image_type_to_mime_type + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.3.0 + * @require PHP 3 + */ +if (!function_exists('image_type_to_mime_type')) +{ + function image_type_to_mime_type ($imagetype) + { + static $image_type_to_mime_type = array ( + IMAGETYPE_GIF => 'image/gif', + IMAGETYPE_JPEG => 'image/jpeg', + IMAGETYPE_PNG => 'image/png', + IMAGETYPE_SWF => 'application/x-shockwave-flash', + IMAGETYPE_PSD => 'image/psd', + IMAGETYPE_BMP => 'image/bmp', + IMAGETYPE_TIFF_II => 'image/tiff', + IMAGETYPE_TIFF_MM => 'image/tiff', + IMAGETYPE_JPC => 'application/octet-stream', + IMAGETYPE_JP2 => 'image/jp2', + IMAGETYPE_JPX => 'application/octet-stream', + IMAGETYPE_JB2 => 'application/octet-stream', + IMAGETYPE_SWC => 'application/x-shockwave-flash', + IMAGETYPE_IFF => 'image/iff', + IMAGETYPE_WBMP => 'image/vnd.wap.wbmp', + IMAGETYPE_XBM => 'image/xbm', + ); + + return (isset($image_type_to_mime_type[$imagetype]) ? + $image_type_to_mime_type[$imagetype] : + $image_type_to_mime_type[IMAGETYPE_JPC]); + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/is_a.php b/PHP_Compat/Compat/Function/is_a.php index be010e0..121e56c 100644 --- a/PHP_Compat/Compat/Function/is_a.php +++ b/PHP_Compat/Compat/Function/is_a.php @@ -1,48 +1,48 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: is_a.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace function is_a()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.is_a
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.2.0
- * @require PHP 4.0.0 (is_subclass_of)
- */
-if (!function_exists('is_a'))
-{
- function is_a ($object, $class)
- {
- if (get_class($object) == strtolower($class)) {
- return true;
- }
-
- else {
- return is_subclass_of($object, $class);
- }
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: is_a.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace function is_a() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.is_a + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.2.0 + * @require PHP 4.0.0 (is_subclass_of) + */ +if (!function_exists('is_a')) +{ + function is_a ($object, $class) + { + if (get_class($object) == strtolower($class)) { + return true; + } + + else { + return is_subclass_of($object, $class); + } + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/ob_clean.php b/PHP_Compat/Compat/Function/ob_clean.php index 8495ed2..703973c 100644 --- a/PHP_Compat/Compat/Function/ob_clean.php +++ b/PHP_Compat/Compat/Function/ob_clean.php @@ -1,49 +1,49 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: ob_clean.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace ob_clean()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/ob_clean
- * @author Aidan Lister <aidan@php.net>
- * @author Thiemo Mättig (http://maettig.com/)
- * @version $Revision: 1.1 $
- * @since PHP 4.2.0
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('ob_clean'))
-{
- function ob_clean ()
- {
- if (@ob_end_clean()) {
- return ob_start();
- }
-
- trigger_error("ob_clean() failed to delete buffer. No buffer to delete.", E_USER_NOTICE);
-
- return false;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: ob_clean.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace ob_clean() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/ob_clean + * @author Aidan Lister <aidan@php.net> + * @author Thiemo Mättig (http://maettig.com/) + * @version $Revision: 1.2 $ + * @since PHP 4.2.0 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('ob_clean')) +{ + function ob_clean () + { + if (@ob_end_clean()) { + return ob_start(); + } + + trigger_error("ob_clean() failed to delete buffer. No buffer to delete.", E_USER_NOTICE); + + return false; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/ob_flush.php b/PHP_Compat/Compat/Function/ob_flush.php index c38d1df..a793ad1 100644 --- a/PHP_Compat/Compat/Function/ob_flush.php +++ b/PHP_Compat/Compat/Function/ob_flush.php @@ -1,49 +1,49 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: ob_flush.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace ob_flush()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/ob_flush
- * @author Aidan Lister <aidan@php.net>
- * @author Thiemo Mättig (http://maettig.com/)
- * @version $Revision: 1.1 $
- * @since PHP 4.2.0
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('ob_flush'))
-{
- function ob_flush ()
- {
- if (@ob_end_flush()) {
- return ob_start();
- }
-
- trigger_error("ob_flush() Failed to flush buffer. No buffer to flush.", E_USER_NOTICE);
-
- return false;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: ob_flush.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace ob_flush() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/ob_flush + * @author Aidan Lister <aidan@php.net> + * @author Thiemo Mättig (http://maettig.com/) + * @version $Revision: 1.2 $ + * @since PHP 4.2.0 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('ob_flush')) +{ + function ob_flush () + { + if (@ob_end_flush()) { + return ob_start(); + } + + trigger_error("ob_flush() Failed to flush buffer. No buffer to flush.", E_USER_NOTICE); + + return false; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/ob_get_clean.php b/PHP_Compat/Compat/Function/ob_get_clean.php index dd5bf9c..2be47e7 100644 --- a/PHP_Compat/Compat/Function/ob_get_clean.php +++ b/PHP_Compat/Compat/Function/ob_get_clean.php @@ -1,49 +1,49 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: ob_get_clean.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace ob_get_clean()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/ob_get_clean
- * @author Aidan Lister <aidan@php.net>
- * @author Thiemo Mättig (http://maettig.com/)
- * @version $Revision: 1.1 $
- * @since PHP 4.3.0
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('ob_get_clean'))
-{
- function ob_get_clean ()
- {
- $contents = ob_get_contents();
-
- if ($contents !== false) {
- ob_end_clean();
- }
-
- return $contents;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: ob_get_clean.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace ob_get_clean() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/ob_get_clean + * @author Aidan Lister <aidan@php.net> + * @author Thiemo Mättig (http://maettig.com/) + * @version $Revision: 1.2 $ + * @since PHP 4.3.0 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('ob_get_clean')) +{ + function ob_get_clean () + { + $contents = ob_get_contents(); + + if ($contents !== false) { + ob_end_clean(); + } + + return $contents; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/ob_get_flush.php b/PHP_Compat/Compat/Function/ob_get_flush.php index 72b824a..de2be75 100644 --- a/PHP_Compat/Compat/Function/ob_get_flush.php +++ b/PHP_Compat/Compat/Function/ob_get_flush.php @@ -1,49 +1,49 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: ob_get_flush.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace ob_get_flush()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/ob_get_flush
- * @author Aidan Lister <aidan@php.net>
- * @author Thiemo Mättig (http://maettig.com/)
- * @version $Revision: 1.1 $
- * @since PHP 4.3.0
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('ob_get_flush'))
-{
- function ob_get_flush ()
- {
- $contents = ob_get_contents();
-
- if ($contents !== false) {
- ob_end_flush();
- }
-
- return $contents;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: ob_get_flush.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace ob_get_flush() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/ob_get_flush + * @author Aidan Lister <aidan@php.net> + * @author Thiemo Mättig (http://maettig.com/) + * @version $Revision: 1.2 $ + * @since PHP 4.3.0 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('ob_get_flush')) +{ + function ob_get_flush () + { + $contents = ob_get_contents(); + + if ($contents !== false) { + ob_end_flush(); + } + + return $contents; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/scandir.php b/PHP_Compat/Compat/Function/scandir.php index 54616b7..54ce53b 100644 --- a/PHP_Compat/Compat/Function/scandir.php +++ b/PHP_Compat/Compat/Function/scandir.php @@ -1,70 +1,70 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: scandir.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace scandir()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.scandir
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('scandir'))
-{
- function scandir ($directory, $sorting_order = 0)
- {
- if (!is_string($directory)) {
- trigger_error('scandir() expects parameter 1 to be string, ' . gettype($directory) . ' given', E_USER_WARNING);
- return null;
- }
-
- if (!is_int($sorting_order)) {
- trigger_error('scandir() expects parameter 2 to be long, ' . gettype($sorting_order) . ' given', E_USER_WARNING);
- return null;
- }
-
- if (!is_dir($directory) || (false === $fh = @opendir($directory))) {
- trigger_error('scandir() failed to open dir: Invalid argument', E_USER_WARNING);
- return false;
- }
-
- $files = array ();
- while (false !== ($filename = readdir($fh))) {
- $files[] = $filename;
- }
-
- closedir($fh);
-
- if ($sorting_order == 1) {
- rsort($files);
- } else {
- sort($files);
- }
-
- return $files;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: scandir.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace scandir() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.scandir + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('scandir')) +{ + function scandir ($directory, $sorting_order = 0) + { + if (!is_string($directory)) { + trigger_error('scandir() expects parameter 1 to be string, ' . gettype($directory) . ' given', E_USER_WARNING); + return null; + } + + if (!is_int($sorting_order)) { + trigger_error('scandir() expects parameter 2 to be long, ' . gettype($sorting_order) . ' given', E_USER_WARNING); + return null; + } + + if (!is_dir($directory) || (false === $fh = @opendir($directory))) { + trigger_error('scandir() failed to open dir: Invalid argument', E_USER_WARNING); + return false; + } + + $files = array (); + while (false !== ($filename = readdir($fh))) { + $files[] = $filename; + } + + closedir($fh); + + if ($sorting_order == 1) { + rsort($files); + } else { + sort($files); + } + + return $files; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/str_ireplace.php b/PHP_Compat/Compat/Function/str_ireplace.php index af21a69..d23e7c1 100644 --- a/PHP_Compat/Compat/Function/str_ireplace.php +++ b/PHP_Compat/Compat/Function/str_ireplace.php @@ -1,119 +1,119 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: str_ireplace.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace str_ireplace()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.str_ireplace
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- * @internal count not by returned by reference - not possible in php4
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('str_ireplace'))
-{
- function str_ireplace ($search, $replace, $subject, $count = null)
- {
- if (is_string($search) && is_array($replace)) {
- trigger_error('Array to string conversion', E_USER_NOTICE);
- $replace = (string) $replace;
- }
-
- // If search isn't an array, make it one
- if (!is_array($search)) {
- $search = array ($search);
- }
-
- // If replace isn't an array, make it one, and pad it to the length of search
- if (!is_array($replace))
- {
- $replace_string = $replace;
-
- $replace = array ();
- for ($i = 0, $c = count($search); $i < $c; $i++)
- {
- $replace[$i] = $replace_string;
- }
- }
-
- // Check the replace array is padded to the correct length
- $length_replace = count($replace);
- $length_search = count($search);
- if ($length_replace < $length_search)
- {
- for ($i = $length_replace; $i < $length_search; $i++)
- {
- $replace[$i] = '';
- }
- }
-
- // If subject is not an array, make it one
- $was_array = false;
- if (!is_array($subject)) {
- $was_array = true;
- $subject = array ($subject);
- }
-
- // Loop through each subject
- $count = 0;
- foreach ($subject as $subject_key => $subject_value)
- {
- // Loop through each search
- foreach ($search as $search_key => $search_value)
- {
- // Split the array into segments, in between each part is our search
- $segments = explode(strtolower($search_value), strtolower($subject_value));
-
- // The number of replacements done is the number of segments minus the first
- $count += count($segments) - 1;
- $pos = 0;
-
- // Loop through each segment
- foreach ($segments as $segment_key => $segment_value)
- {
- // Replace the lowercase segments with the upper case versions
- $segments[$segment_key] = substr($subject_value, $pos, strlen($segment_value));
- // Increase the position relative to the initial string
- $pos += strlen($segment_value) + strlen($search_value);
- }
-
- // Put our original string back together
- $subject_value = implode($replace[$search_key], $segments);
- }
-
- $result[$subject_key] = $subject_value;
- }
-
- // Check if subject was initially a string and return it as a string
- if ($was_array === true) {
- return $result[0];
- }
-
- // Otherwise, just return the array
- return $result;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: str_ireplace.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace str_ireplace() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.str_ireplace + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + * @internal count not by returned by reference - not possible in php4 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('str_ireplace')) +{ + function str_ireplace ($search, $replace, $subject, $count = null) + { + if (is_string($search) && is_array($replace)) { + trigger_error('Array to string conversion', E_USER_NOTICE); + $replace = (string) $replace; + } + + // If search isn't an array, make it one + if (!is_array($search)) { + $search = array ($search); + } + + // If replace isn't an array, make it one, and pad it to the length of search + if (!is_array($replace)) + { + $replace_string = $replace; + + $replace = array (); + for ($i = 0, $c = count($search); $i < $c; $i++) + { + $replace[$i] = $replace_string; + } + } + + // Check the replace array is padded to the correct length + $length_replace = count($replace); + $length_search = count($search); + if ($length_replace < $length_search) + { + for ($i = $length_replace; $i < $length_search; $i++) + { + $replace[$i] = ''; + } + } + + // If subject is not an array, make it one + $was_array = false; + if (!is_array($subject)) { + $was_array = true; + $subject = array ($subject); + } + + // Loop through each subject + $count = 0; + foreach ($subject as $subject_key => $subject_value) + { + // Loop through each search + foreach ($search as $search_key => $search_value) + { + // Split the array into segments, in between each part is our search + $segments = explode(strtolower($search_value), strtolower($subject_value)); + + // The number of replacements done is the number of segments minus the first + $count += count($segments) - 1; + $pos = 0; + + // Loop through each segment + foreach ($segments as $segment_key => $segment_value) + { + // Replace the lowercase segments with the upper case versions + $segments[$segment_key] = substr($subject_value, $pos, strlen($segment_value)); + // Increase the position relative to the initial string + $pos += strlen($segment_value) + strlen($search_value); + } + + // Put our original string back together + $subject_value = implode($replace[$search_key], $segments); + } + + $result[$subject_key] = $subject_value; + } + + // Check if subject was initially a string and return it as a string + if ($was_array === true) { + return $result[0]; + } + + // Otherwise, just return the array + return $result; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/str_split.php b/PHP_Compat/Compat/Function/str_split.php index 3b7ef3f..5ab4c43 100644 --- a/PHP_Compat/Compat/Function/str_split.php +++ b/PHP_Compat/Compat/Function/str_split.php @@ -1,53 +1,53 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: str_split.php,v 1.1 2005/06/19 05:21:34 bitweaver Exp $
-//
-
-
-/**
- * Replace str_split()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.str_split
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('str_split'))
-{
- function str_split ($string, $split_length = 1)
- {
- if (!is_numeric($split_length)) {
- trigger_error('str_split() expects parameter 2 to be long, ' . gettype($split_length) . ' given', E_USER_WARNING);
- return false;
- }
-
- if ($split_length < 1) {
- trigger_error('str_split() The the length of each segment must be greater then zero', E_USER_WARNING);
- return false;
- }
-
- preg_match_all('/.{1,' . $split_length . '}/s', $string, $matches);
- return $matches[0];
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: str_split.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace str_split() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.str_split + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('str_split')) +{ + function str_split ($string, $split_length = 1) + { + if (!is_numeric($split_length)) { + trigger_error('str_split() expects parameter 2 to be long, ' . gettype($split_length) . ' given', E_USER_WARNING); + return false; + } + + if ($split_length < 1) { + trigger_error('str_split() The the length of each segment must be greater then zero', E_USER_WARNING); + return false; + } + + preg_match_all('/.{1,' . $split_length . '}/s', $string, $matches); + return $matches[0]; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/stripos.php b/PHP_Compat/Compat/Function/stripos.php index 3991d98..9688a9e 100644 --- a/PHP_Compat/Compat/Function/stripos.php +++ b/PHP_Compat/Compat/Function/stripos.php @@ -1,71 +1,71 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: stripos.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace stripos()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.stripos
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('stripos'))
-{
- function stripos ($haystack, $needle, $offset = null)
- {
- if (!is_scalar($haystack)) {
- trigger_error('stripos() expects parameter 1 to be string, ' . gettype($haystack) . ' given', E_USER_WARNING);
- return false;
- }
-
- if (!is_scalar($needle)) {
- trigger_error('stripos() needle is not a string or an integer.', E_USER_WARNING);
- return false;
- }
-
- if (!is_null($offset) && !is_numeric($offset)) {
- trigger_error('stripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING);
- return false;
- }
-
- // Manipulate the string if there is an offset
- $fix = 0;
- if (!is_null($offset))
- {
- if ($offset > 0)
- {
- $haystack = substr($haystack, $offset, strlen($haystack) - $offset);
- $fix = $offset;
- }
- }
-
- $segments = explode (strtolower($needle), strtolower($haystack), 2);
- $position = strlen($segments[0]) + $fix;
-
- return $position;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: stripos.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace stripos() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.stripos + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('stripos')) +{ + function stripos ($haystack, $needle, $offset = null) + { + if (!is_scalar($haystack)) { + trigger_error('stripos() expects parameter 1 to be string, ' . gettype($haystack) . ' given', E_USER_WARNING); + return false; + } + + if (!is_scalar($needle)) { + trigger_error('stripos() needle is not a string or an integer.', E_USER_WARNING); + return false; + } + + if (!is_null($offset) && !is_numeric($offset)) { + trigger_error('stripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING); + return false; + } + + // Manipulate the string if there is an offset + $fix = 0; + if (!is_null($offset)) + { + if ($offset > 0) + { + $haystack = substr($haystack, $offset, strlen($haystack) - $offset); + $fix = $offset; + } + } + + $segments = explode (strtolower($needle), strtolower($haystack), 2); + $position = strlen($segments[0]) + $fix; + + return $position; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/strripos.php b/PHP_Compat/Compat/Function/strripos.php index a76019e..6d34b9d 100644 --- a/PHP_Compat/Compat/Function/strripos.php +++ b/PHP_Compat/Compat/Function/strripos.php @@ -1,83 +1,83 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// | Stephan Schmidt <schst@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: strripos.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace strripos()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.strripos
- * @author Aidan Lister <aidan@php.net>
- * @author Stephan Schmidt <schst@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 5
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('strripos'))
-{
- function strripos ($haystack, $needle, $offset = null)
- {
- if (!is_scalar($haystack)) {
- trigger_error('strripos() expects parameter 1 to be scalar, ' . gettype($haystack) . ' given', E_USER_WARNING);
- return false;
- }
-
- if (!is_scalar($needle)) {
- trigger_error('strripos() expects parameter 2 to be scalar, ' . gettype($needle) . ' given', E_USER_WARNING);
- return false;
- }
-
- if (!is_null($offset) && !is_numeric($offset)) {
- trigger_error('strripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING);
- return false;
- }
-
- // Manipulate the string if there is an offset
- $fix = 0;
- if (!is_null($offset))
- {
- // If the offset is larger than the haystack, return
- if (abs($offset) >= strlen($haystack)) {
- return false;
- }
-
- // Check whether offset is negative or positive
- if ($offset > 0) {
- $haystack = substr($haystack, $offset, strlen($haystack) - $offset);
- // We need to add this to the position of the needle
- $fix = $offset;
- }
- else {
- $haystack = substr($haystack, 0, strlen($haystack) + $offset);
- }
- }
-
- $segments = explode(strtolower($needle), strtolower($haystack));
-
- $last_seg = count($segments) - 1;
- $position = strlen($haystack) + $fix - strlen($segments[$last_seg]) - strlen($needle);
-
- return $position;
- }
-}
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// | Stephan Schmidt <schst@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: strripos.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace strripos() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.strripos + * @author Aidan Lister <aidan@php.net> + * @author Stephan Schmidt <schst@php.net> + * @version $Revision: 1.2 $ + * @since PHP 5 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('strripos')) +{ + function strripos ($haystack, $needle, $offset = null) + { + if (!is_scalar($haystack)) { + trigger_error('strripos() expects parameter 1 to be scalar, ' . gettype($haystack) . ' given', E_USER_WARNING); + return false; + } + + if (!is_scalar($needle)) { + trigger_error('strripos() expects parameter 2 to be scalar, ' . gettype($needle) . ' given', E_USER_WARNING); + return false; + } + + if (!is_null($offset) && !is_numeric($offset)) { + trigger_error('strripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING); + return false; + } + + // Manipulate the string if there is an offset + $fix = 0; + if (!is_null($offset)) + { + // If the offset is larger than the haystack, return + if (abs($offset) >= strlen($haystack)) { + return false; + } + + // Check whether offset is negative or positive + if ($offset > 0) { + $haystack = substr($haystack, $offset, strlen($haystack) - $offset); + // We need to add this to the position of the needle + $fix = $offset; + } + else { + $haystack = substr($haystack, 0, strlen($haystack) + $offset); + } + } + + $segments = explode(strtolower($needle), strtolower($haystack)); + + $last_seg = count($segments) - 1; + $position = strlen($haystack) + $fix - strlen($segments[$last_seg]) - strlen($needle); + + return $position; + } +} ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/var_export.php b/PHP_Compat/Compat/Function/var_export.php index d3e3196..fae8f68 100644 --- a/PHP_Compat/Compat/Function/var_export.php +++ b/PHP_Compat/Compat/Function/var_export.php @@ -1,103 +1,103 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: var_export.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace var_export()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.var_export
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.2.0
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('var_export'))
-{
- function var_export ($array, $return = false)
- {
- // Common output variables
- $indent = ' ';
- $doublearrow = ' => ';
- $lineend = ",\n";
- $stringdelim = '\'';
- $newline = "\n";
-
- // Check the export isn't a simple string / int
- if (is_string($array)) {
- $out = $stringdelim . $array . $stringdelim;
- }
- elseif (is_int($array)) {
- $out = (string)$array;
- }
-
- // Begin the array export
- else
- {
- // Start the string
- $out = "array (\n";
-
- // Loop through each value in array
- foreach ($array as $key => $value)
- {
- // If the key is a string, delimit it
- if (is_string($key)) {
- $key = $stringdelim . addslashes($key) . $stringdelim;
- }
-
- // If the value is a string, delimit it
- if (is_string($value)) {
- $value = $stringdelim . addslashes($value) . $stringdelim;
- }
-
- // We have an array, so do some recursion
- elseif (is_array($value))
- {
- // Do some basic recursion while increasing the indent
- $recur_array = explode($newline, var_export($value, true));
- $recur_newarr = array ();
- foreach ($recur_array as $recur_line) {
- $recur_newarr[] = $indent . $recur_line;
- }
- $recur_array = implode($newline, $recur_newarr);
- $value = $newline . $recur_array;
- }
-
- // Piece together the line
- $out .= $indent . $key . $doublearrow . $value . $lineend;
- }
-
- // End our string
- $out .= ")";
- }
-
-
- // Decide method of output
- if ($return === true) {
- return $out;
- } else {
- echo $out;
- return null;
- }
- }
-}
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: var_export.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace var_export() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.var_export + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.2.0 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('var_export')) +{ + function var_export ($array, $return = false) + { + // Common output variables + $indent = ' '; + $doublearrow = ' => '; + $lineend = ",\n"; + $stringdelim = '\''; + $newline = "\n"; + + // Check the export isn't a simple string / int + if (is_string($array)) { + $out = $stringdelim . $array . $stringdelim; + } + elseif (is_int($array)) { + $out = (string)$array; + } + + // Begin the array export + else + { + // Start the string + $out = "array (\n"; + + // Loop through each value in array + foreach ($array as $key => $value) + { + // If the key is a string, delimit it + if (is_string($key)) { + $key = $stringdelim . addslashes($key) . $stringdelim; + } + + // If the value is a string, delimit it + if (is_string($value)) { + $value = $stringdelim . addslashes($value) . $stringdelim; + } + + // We have an array, so do some recursion + elseif (is_array($value)) + { + // Do some basic recursion while increasing the indent + $recur_array = explode($newline, var_export($value, true)); + $recur_newarr = array (); + foreach ($recur_array as $recur_line) { + $recur_newarr[] = $indent . $recur_line; + } + $recur_array = implode($newline, $recur_newarr); + $value = $newline . $recur_array; + } + + // Piece together the line + $out .= $indent . $key . $doublearrow . $value . $lineend; + } + + // End our string + $out .= ")"; + } + + + // Decide method of output + if ($return === true) { + return $out; + } else { + echo $out; + return null; + } + } +} ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/version_compare.php b/PHP_Compat/Compat/Function/version_compare.php index 17df1ff..7dcdd0c 100644 --- a/PHP_Compat/Compat/Function/version_compare.php +++ b/PHP_Compat/Compat/Function/version_compare.php @@ -1,170 +1,170 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Philippe Jausions <Philippe.Jausions@11abacus.com> |
-// | Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: version_compare.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace version_compare()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/version_compare
- * @author Philippe Jausions <Philippe.Jausions@11abacus.com>
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.1.0
- * @require PHP 4.0.1 (trigger_error)
- */
-if (!function_exists('version_compare')) {
-
- function version_compare ($version1, $version2, $operator = '<')
- {
- // Check input
- if (!is_scalar($version1)) {
- trigger_error('version_compare() expects parameter 1 to be string, ' . gettype($version1) . ' given', E_USER_WARNING);
- return null;
- }
-
- if (!is_scalar($version2)) {
- trigger_error('version_compare() expects parameter 2 to be string, ' . gettype($version2) . ' given', E_USER_WARNING);
- return null;
- }
-
- if (!is_scalar($operator)) {
- trigger_error('version_compare() expects parameter 3 to be string, ' . gettype($operator) . ' given', E_USER_WARNING);
- return null;
- }
-
- // Standardise versions
- $v1 = explode('.',
- str_replace('..', '.',
- preg_replace('/([^0-9\.]+)/', '.$1.',
- str_replace(array('-', '_', '+'), '.',
- trim($version1)))));
-
- $v2 = explode('.',
- str_replace('..', '.',
- preg_replace('/([^0-9\.]+)/', '.$1.',
- str_replace(array('-', '_', '+'), '.',
- trim($version2)))));
-
- // Replace empty entries at the start of the array
- while (empty($v1[0]) && array_shift($v1)) {}
- while (empty($v2[0]) && array_shift($v2)) {}
-
- // Describe our release states
- $versions = array(
- 'dev' => 0,
- 'alpha' => 1,
- 'a' => 1,
- 'beta' => 2,
- 'b' => 2,
- 'RC' => 3,
- 'pl' => 4);
-
- // Loop through each segment in the version string
- $compare = 0;
- for ($i = 0, $x = min(count($v1), count($v2)); $i < $x; $i++)
- {
- if ($v1[$i] == $v2[$i]) {
- continue;
- }
- if (is_numeric($v1[$i]) && is_numeric($v2[$i])) {
- $compare = ($v1[$i] < $v2[$i]) ? -1 : 1;
- }
- elseif (is_numeric($v1[$i])) {
- $compare = 1;
- }
- elseif (is_numeric($v2[$i])) {
- $compare = -1;
- }
- elseif (isset($versions[$v1[$i]]) && isset($versions[$v2[$i]])) {
- $compare = ($versions[$v1[$i]] < $versions[$v2[$i]]) ? -1 : 1;
- }
- else {
- $compare = strcmp($v2[$i], $v1[$i]);
- }
-
- break;
- }
-
- // If previous loop didn't find anything, compare the "extra" segments
- if ($compare == 0) {
- if (count($v2) > count($v1))
- {
- if (isset($versions[$v2[$i]])) {
- $compare = ($versions[$v2[$i]] < 4) ? 1 : -1;
- } else {
- $compare = -1;
- }
- }
- elseif (count($v2) < count($v1))
- {
- if (isset($versions[$v1[$i]])) {
- $compare = ($versions[$v1[$i]] < 4) ? -1 : 1;
- } else {
- $compare = 1;
- }
- }
- }
-
- // Compare the versions
- if (func_num_args() > 2)
- {
- switch ($operator)
- {
- case '>':
- case 'gt':
- return (bool) ($compare > 0);
- break;
- case '>=':
- case 'ge':
- return (bool) ($compare >= 0);
- break;
- case '<=':
- case 'le':
- return (bool) ($compare <= 0);
- break;
- case '==':
- case '=':
- case 'eq':
- return (bool) ($compare == 0);
- break;
- case '<>':
- case '!=':
- case 'ne':
- return (bool) ($compare != 0);
- break;
- case '':
- case '<':
- case 'lt':
- return (bool) ($compare < 0);
- break;
- default:
- return null;
- }
- }
-
- return $compare;
- }
-}
-
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Philippe Jausions <Philippe.Jausions@11abacus.com> | +// | Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: version_compare.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace version_compare() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/version_compare + * @author Philippe Jausions <Philippe.Jausions@11abacus.com> + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.1.0 + * @require PHP 4.0.1 (trigger_error) + */ +if (!function_exists('version_compare')) { + + function version_compare ($version1, $version2, $operator = '<') + { + // Check input + if (!is_scalar($version1)) { + trigger_error('version_compare() expects parameter 1 to be string, ' . gettype($version1) . ' given', E_USER_WARNING); + return null; + } + + if (!is_scalar($version2)) { + trigger_error('version_compare() expects parameter 2 to be string, ' . gettype($version2) . ' given', E_USER_WARNING); + return null; + } + + if (!is_scalar($operator)) { + trigger_error('version_compare() expects parameter 3 to be string, ' . gettype($operator) . ' given', E_USER_WARNING); + return null; + } + + // Standardise versions + $v1 = explode('.', + str_replace('..', '.', + preg_replace('/([^0-9\.]+)/', '.$1.', + str_replace(array('-', '_', '+'), '.', + trim($version1))))); + + $v2 = explode('.', + str_replace('..', '.', + preg_replace('/([^0-9\.]+)/', '.$1.', + str_replace(array('-', '_', '+'), '.', + trim($version2))))); + + // Replace empty entries at the start of the array + while (empty($v1[0]) && array_shift($v1)) {} + while (empty($v2[0]) && array_shift($v2)) {} + + // Describe our release states + $versions = array( + 'dev' => 0, + 'alpha' => 1, + 'a' => 1, + 'beta' => 2, + 'b' => 2, + 'RC' => 3, + 'pl' => 4); + + // Loop through each segment in the version string + $compare = 0; + for ($i = 0, $x = min(count($v1), count($v2)); $i < $x; $i++) + { + if ($v1[$i] == $v2[$i]) { + continue; + } + if (is_numeric($v1[$i]) && is_numeric($v2[$i])) { + $compare = ($v1[$i] < $v2[$i]) ? -1 : 1; + } + elseif (is_numeric($v1[$i])) { + $compare = 1; + } + elseif (is_numeric($v2[$i])) { + $compare = -1; + } + elseif (isset($versions[$v1[$i]]) && isset($versions[$v2[$i]])) { + $compare = ($versions[$v1[$i]] < $versions[$v2[$i]]) ? -1 : 1; + } + else { + $compare = strcmp($v2[$i], $v1[$i]); + } + + break; + } + + // If previous loop didn't find anything, compare the "extra" segments + if ($compare == 0) { + if (count($v2) > count($v1)) + { + if (isset($versions[$v2[$i]])) { + $compare = ($versions[$v2[$i]] < 4) ? 1 : -1; + } else { + $compare = -1; + } + } + elseif (count($v2) < count($v1)) + { + if (isset($versions[$v1[$i]])) { + $compare = ($versions[$v1[$i]] < 4) ? -1 : 1; + } else { + $compare = 1; + } + } + } + + // Compare the versions + if (func_num_args() > 2) + { + switch ($operator) + { + case '>': + case 'gt': + return (bool) ($compare > 0); + break; + case '>=': + case 'ge': + return (bool) ($compare >= 0); + break; + case '<=': + case 'le': + return (bool) ($compare <= 0); + break; + case '==': + case '=': + case 'eq': + return (bool) ($compare == 0); + break; + case '<>': + case '!=': + case 'ne': + return (bool) ($compare != 0); + break; + case '': + case '<': + case 'lt': + return (bool) ($compare < 0); + break; + default: + return null; + } + } + + return $compare; + } +} + ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/vprintf.php b/PHP_Compat/Compat/Function/vprintf.php index 5d67c9f..6a4ce07 100644 --- a/PHP_Compat/Compat/Function/vprintf.php +++ b/PHP_Compat/Compat/Function/vprintf.php @@ -1,47 +1,47 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: vprintf.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace vprintf()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.vprintf
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.1.0
- * @require PHP 4.0.4 (call_user_func_array)
- */
-if (!function_exists('vprintf'))
-{
- function vprintf ($format, $args)
- {
- if (count($args) < 2) {
- trigger_error('vprintf() Too few arguments', E_USER_WARNING);
- return null;
- }
-
- array_unshift($args, $format);
- return call_user_func_array('printf', $args);
- }
-}
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: vprintf.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace vprintf() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.vprintf + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.1.0 + * @require PHP 4.0.4 (call_user_func_array) + */ +if (!function_exists('vprintf')) +{ + function vprintf ($format, $args) + { + if (count($args) < 2) { + trigger_error('vprintf() Too few arguments', E_USER_WARNING); + return null; + } + + array_unshift($args, $format); + return call_user_func_array('printf', $args); + } +} ?>
\ No newline at end of file diff --git a/PHP_Compat/Compat/Function/vsprintf.php b/PHP_Compat/Compat/Function/vsprintf.php index 0af4a70..7358f22 100644 --- a/PHP_Compat/Compat/Function/vsprintf.php +++ b/PHP_Compat/Compat/Function/vsprintf.php @@ -1,47 +1,47 @@ -<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> |
-// +----------------------------------------------------------------------+
-//
-// $Id: vsprintf.php,v 1.1 2005/06/19 05:21:33 bitweaver Exp $
-//
-
-
-/**
- * Replace vsprintf()
- *
- * @category PHP
- * @package PHP_Compat
- * @link http://php.net/function.vsprintf
- * @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.1 $
- * @since PHP 4.1.0
- * @require PHP 4.0.4 (call_user_func_array)
- */
-if (!function_exists('vsprintf'))
-{
- function vsprintf ($format, $args)
- {
- if (count($args) < 2) {
- trigger_error('vsprintf() Too few arguments', E_USER_WARNING);
- return null;
- }
-
- array_unshift($args, $format);
- return call_user_func_array('sprintf', $args);
- }
-}
+<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.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/3_0.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: Aidan Lister <aidan@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: vsprintf.php,v 1.2 2006/03/22 10:24:33 squareing Exp $ +// + + +/** + * Replace vsprintf() + * + * @category PHP + * @package PHP_Compat + * @link http://php.net/function.vsprintf + * @author Aidan Lister <aidan@php.net> + * @version $Revision: 1.2 $ + * @since PHP 4.1.0 + * @require PHP 4.0.4 (call_user_func_array) + */ +if (!function_exists('vsprintf')) +{ + function vsprintf ($format, $args) + { + if (count($args) < 2) { + trigger_error('vsprintf() Too few arguments', E_USER_WARNING); + return null; + } + + array_unshift($args, $format); + return call_user_func_array('sprintf', $args); + } +} ?>
\ No newline at end of file diff --git a/javascript/fixes/ie7/README.txt b/javascript/fixes/ie7/README.txt index e546ce4..647c8ea 100644 --- a/javascript/fixes/ie7/README.txt +++ b/javascript/fixes/ie7/README.txt @@ -1,34 +1,34 @@ -Installation
-------------
-
-Follow these simple instructions to get IE7 working immediately on your server:
-
- * download the latest IE7 ZIP file (https://sourceforge.net/project/showfiles.php?group_id=109983&package_id=119707)
-
- * extract the contents to a directory on your server (keep the folder names used in the ZIP)
-
- * you will now have an IE7 directory on your server
-
- * include the IE7 JavaScript library in the page you wish to test
-
- <!-- compliance patch for microsoft browsers -->
- <!--[if lt IE 7]><script src="/ie7/ie7-standard-p.js" type="text/javascript"></script><![endif]-->
-
- * make sure this also points to the same directory
-
- * open the page in your web browser
-
- * the page should now be IE7 enabled.
-
- * if you are using the PNG solution then be aware that it operates on files
- names "something-trans.png"
-
- * see this page for more configuration and usage options:
- http://dean.edwards.name/IE7/usage/
-
-You may extract the contents of the ZIP file to your hard disk if you do not have access to a web server.
-
-
-Enjoy ;-)
-
-Dean Edwards, 23rd May 2005
+Installation +------------ + +Follow these simple instructions to get IE7 working immediately on your server: + + * download the latest IE7 ZIP file (https://sourceforge.net/project/showfiles.php?group_id=109983&package_id=119707) + + * extract the contents to a directory on your server (keep the folder names used in the ZIP) + + * you will now have an IE7 directory on your server + + * include the IE7 JavaScript library in the page you wish to test + + <!-- compliance patch for microsoft browsers --> + <!--[if lt IE 7]><script src="/ie7/ie7-standard-p.js" type="text/javascript"></script><![endif]--> + + * make sure this also points to the same directory + + * open the page in your web browser + + * the page should now be IE7 enabled. + + * if you are using the PNG solution then be aware that it operates on files + names "something-trans.png" + + * see this page for more configuration and usage options: + http://dean.edwards.name/IE7/usage/ + +You may extract the contents of the ZIP file to your hard disk if you do not have access to a web server. + + +Enjoy ;-) + +Dean Edwards, 23rd May 2005 diff --git a/javascript/fixes/ie7/ie7-base64.php b/javascript/fixes/ie7/ie7-base64.php index 530392d..099b312 100644 --- a/javascript/fixes/ie7/ie7-base64.php +++ b/javascript/fixes/ie7/ie7-base64.php @@ -1,7 +1,7 @@ -<?php
-$data = split(";", $_SERVER["REDIRECT_QUERY_STRING"]);
-$type = $data[0];
-$data = split(",", $data[1]);
-header("Content-type: ".$type);
-echo base64_decode($data[1]);
+<?php +$data = split(";", $_SERVER["REDIRECT_QUERY_STRING"]); +$type = $data[0]; +$data = split(",", $data[1]); +header("Content-type: ".$type); +echo base64_decode($data[1]); ?>
\ No newline at end of file diff --git a/javascript/fixes/ie7/ie7-content.htc b/javascript/fixes/ie7/ie7-content.htc index cc480cb..bc56f79 100644 --- a/javascript/fixes/ie7/ie7-content.htc +++ b/javascript/fixes/ie7/ie7-content.htc @@ -1,14 +1,14 @@ -<html>
-<!--
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
--->
-<head>
-<object id="dummy" width="0" height="0"></object>
-<base id="base">
-<style type="text/css">html,body,img{margin:0;}img{vertical-align:top}#dummy{display:inline}</style>
-<script type="text/javascript">public_description=new function(){var l=false;this.ie7_anon=true;this.load=function(o,c,u){if(l)return;l=true;base.href=o.document.URL;dummy.style.cssText=c;var _0=o.parentElement;var _1=Boolean(dummy.currentStyle.display=="inline");function r(){o.runtimeStyle.width=(_1)?image.offsetWidth:"100%";o.runtimeStyle.height=body.offsetHeight};image.onreadystatechange=function(){if(this.readyState=="complete")_2()};image.src=u;function _2(){function copy(p){try{body.style[p]=_0.currentStyle[p]}catch(i){}};for(var j in body.currentStyle)copy(j);body.style.width="";body.style.height="";body.style.border="none";body.style.padding="0";body.style.margin="0";body.style.textIndent="";body.style.position="static";while(_0&&_0.currentStyle.backgroundColor=="transparent"){_0=_0.parentElement}if(_0)document.body.style.backgroundColor=_0.currentStyle.backgroundColor;body.runtimeStyle.cssText=c;body.runtimeStyle.margin="0";if(_1)body.runtimeStyle.width="";r()}}};</script>
-</head>
-<body><span id="body"><img id="image"></span></body>
-</html>
+<html> +<!-- + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +--> +<head> +<object id="dummy" width="0" height="0"></object> +<base id="base"> +<style type="text/css">html,body,img{margin:0;}img{vertical-align:top}#dummy{display:inline}</style> +<script type="text/javascript">public_description=new function(){var l=false;this.ie7_anon=true;this.load=function(o,c,u){if(l)return;l=true;base.href=o.document.URL;dummy.style.cssText=c;var _0=o.parentElement;var _1=Boolean(dummy.currentStyle.display=="inline");function r(){o.runtimeStyle.width=(_1)?image.offsetWidth:"100%";o.runtimeStyle.height=body.offsetHeight};image.onreadystatechange=function(){if(this.readyState=="complete")_2()};image.src=u;function _2(){function copy(p){try{body.style[p]=_0.currentStyle[p]}catch(i){}};for(var j in body.currentStyle)copy(j);body.style.width="";body.style.height="";body.style.border="none";body.style.padding="0";body.style.margin="0";body.style.textIndent="";body.style.position="static";while(_0&&_0.currentStyle.backgroundColor=="transparent"){_0=_0.parentElement}if(_0)document.body.style.backgroundColor=_0.currentStyle.backgroundColor;body.runtimeStyle.cssText=c;body.runtimeStyle.margin="0";if(_1)body.runtimeStyle.width="";r()}}};</script> +</head> +<body><span id="body"><img id="image"></span></body> +</html> diff --git a/javascript/fixes/ie7/ie7-core.js b/javascript/fixes/ie7/ie7-core.js index c3dbcef..bb0b5ab 100644 --- a/javascript/fixes/ie7/ie7-core.js +++ b/javascript/fixes/ie7/ie7-core.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('x(!1M.1j)z 6(){1l{1M.1j=8;4 1W=8.2m=z 26;8.O=6(){7"1j 2q 0.9 (5G)"};4 36=/36/.B(42.41.40);4 1G=(36)?6(m){1M.1G(1j+"\\n\\n"+m)}:1W;4 2t=5F.2t.1g(/5E (\\d\\.\\d)/)[1];4 2z=K.5D!="5C";x(/5B/.B(42.41.40)||2t<5||!/^5A/.B(K.1J.2A))7;4 1H=K.39=="1H";4 1t,5z;4 1J=K.1J,2s,3X,17=K.17;4 5y="!";4 22={};4 1u=1C;1j.2m=6(n,s){x(!22[n]){x(1u)1k("s="+2o(s));22[n]=z s()}};4 R=/^[\\w\\.]+[^:]*$/;6 1I(h,p){x(R.B(h))h=(p||"")+h;7 h};6 2e(h,p){h=1I(h,p);7 h.1d(0,h.3n("/")+1)};4 s=K.3Z[K.3Z.y-1];1l{1k(s.3z)}1i(i){}4 1R=2e(s.5x);4 1F;1l{4 l=(5w()>=5)?"5v":"5u";1F=z 5t(l+".5s")}1i(i){}4 2w={};6 2y(h,p){1l{h=1I(h,p);x(!2w[h]){1F.5r("5q",h,1C);1F.5p();x(1F.3Y==0||1F.3Y==5o){2w[h]=1F.5n}}}1i(i){1G("2x [1]: 30 5m 5l "+h)}37{7 2w[h]||""}};4 5k=1I("5j.5i",1R);6 1E(V){x(V!=1L){V.2v=13.16.2v;V.12=13.16.12}7 V};1E.12=6(p,c){x(!p)p={};x(!c)c=p.J;x(c=={}.J)c=z 26("8.2v()");c.Y=z 26("7 8");c.Y.16=z 8.Y;c.Y.16.12(p);c.16=z c.Y;c.Y.16.J=c.16.J=c;c.1r=8;c.12=F.32;c.2u=8.2u;7 c};1E.Y=z 26("7 8");1E.Y.16={J:1E,2v:6(){7 F.32.5h.1r.2k(8,F)},12:6(V){x(8==8.J.16&&8.J.12){7 8.J.Y.16.12(V)}D(4 i 5g V){2K(i){1o"J":1o"O":1o"Y":2X}x(2V V[i]=="6"&&V[i]!=8[i]){V[i].1r=8[i]}8[i]=V[i]}x(V.O!=8.O&&V.O!={}.O){V.O.1r=8.O;8.O=V.O}7 8}};6 13(){};8.13=1E.12({J:13,O:6(){7"[5f "+(8.J.2Z||"5e")+"]"},5d:6(1h){7 8.J==1h||1h.2u(8.J)}});13.2Z="13";13.1r=1L;13.2u=6(1h){1f(1h&&1h.1r!=8)1h=1h.1r;7 3J(1h)};13.Y.1r=1E;2a 8.13;4 3A=13.12({J:6(){8.5c=[];8.1p=[]},1s:1W});x(2t<5.5)1k(2y("Z-5b.3a",1R));4 35=1C;1j.1s=6(){1l{x(35)7;35=1H=1c;2s=K.2s;3X=(2z)?2s:1J;x(1K&&1t)1t.2k();15.2k();1n();1G("1u 5a")}1i(e){1G("2x [2]: "+e.38)}};4 1p=[];6 2C(r){1p.11(r)};6 1n(){H.3P();x(1K&&1t)1t.1n();15.1n();D(4 i=0;i<1p.y;i++)1p[i]()};6 23(){4 E=0,R=1,L=2;4 G=/\\(/g,S=/\\$\\d/,I=/^\\$\\d+$/,T=/([\'"])\\1\\+(.*)\\+\\1\\1$/,3Q=/\\\\./g,Q=/\'/,3W=/\\25[^\\25]*\\25/g;4 1X=8;8.18=6(e,r){x(!r)r="";4 l=(34(2o(e)).1g(G)||"").y+1;x(S.B(r)){x(I.B(r)){r=3e(r.1d(1))-1}1b{4 i=l;4 q=Q.B(34(r))?\'"\':"\'";1f(i)r=r.2S("$"+i--).2p(q+"+a[o+"+i+"]+"+q);r=z 26("a,o","7"+q+r.19(T,"$1")+q)}}3V(e||"/^$/",r,l)};8.1U=6(s){24.y=0;7 3R(3S(s,8.2r).19(z 1Z(1D,8.33?"2I":"g"),3T),8.2r).19(3W,"")};8.59=6(){1D.y=0};4 24=[];4 1D=[];4 3U=6(){7"("+2o(8[E]).1d(1,-1)+")"};1D.O=6(){7 8.2p("|")};6 3V(){F.O=3U;1D[1D.y]=F}6 3T(){x(!F[0])7"";4 i=1,j=0,p;1f(p=1D[j++]){x(F[i]){4 r=p[R];2K(2V r){1o"6":7 r(F,i);1o"58":7 F[r+i]}4 d=(F[i].57(1X.2r)==-1)?"":"\\25"+F[i]+"\\25";7 d+r}1b i+=p[L]}};6 3S(s,e){7 e?s.19(z 1Z("\\\\"+e+"(.)","g"),6(m,c){24[24.y]=c;7 e}):s};6 3R(s,e){4 i=0;7 e?s.19(z 1Z("\\\\"+e,"g"),6(){7 e+(24[i++]||"")}):s};6 34(s){7 s.19(3Q,"")}};23.16={J:23,33:1C,2r:""};13.12(23.16);4 1V=23.12({33:1c});4 H=6(){4 2q="2.0.2";4 C=/\\s*,\\s*/;4 H=6(s,14){1l{4 m=[];4 u=F.32.2Q&&!14;4 b=(14)?(14.J==3G)?14:[14]:[K];4 31=3D(s).2S(C),i;D(i=0;i<31.y;i++){s=2R(31[i]);x(3K&&s.1d(0,3).2p("")==" *#"){s=s.1d(2);14=3H([],b,s[1])}1b 14=b;4 j=0,t,f,a,c="";1f(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";x(s[j]=="("){1f(s[j++]!=")"&&j<s.y){a+=s[j]}a=a.1d(0,-1);c+="("+a+")"}14=(u&&1P[c])?1P[c]:3F(14,t,f,a);x(u)1P[c]=14}m=m.3t(14)}2a H.30;7 m}1i(e){H.30=e;7[]}};H.O=6(){7"6 H() {\\n [2q "+2q+"]\\n}"};4 1P={};H.2Q=1C;H.3P=6(s){x(s){s=2R(s).2p("");2a 1P[s]}1b 1P={}};4 22={};4 1u=1C;H.2m=6(n,s){x(1u)1k("s="+2o(s));22[n]=z s()};H.Y=6(c){7 c?1k(c):8};4 1B={};4 2n={};4 56={1g:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};4 55=[];1B[" "]=6(r,f,t,n){4 e,i,j;D(i=0;i<f.y;i++){4 s=2l(f[i],t,n);D(j=0;(e=s[j]);j++){x(1q(e)&&2T(e,n))r.11(e)}}};1B["#"]=6(r,f,i){4 e,j;D(j=0;(e=f[j]);j++)x(e.1a==i)r.11(e)};1B["."]=6(r,f,c){c=z 1Z("(^|\\\\s)"+c+"(\\\\s|$)");4 e,i;D(i=0;(e=f[i]);i++)x(c.B(e.2Z))r.11(e)};1B[":"]=6(r,f,p,a){4 t=2n[p],e,i;x(t)D(i=0;(e=f[i]);i++)x(t(e,a))r.11(e)};2n["21"]=6(e){4 d=2U(e);x(d.2Y)D(4 i=0;i<d.2Y.y;i++){x(d.2Y[i]==e)7 1c}};2n["2N"]=6(e){};4 1q=6(e){7(e&&e.3B==1&&e.2P!="!")?e:1L};4 3N=6(e){1f(e&&(e=e.54)&&!1q(e))2X;7 e};4 2W=6(e){1f(e&&(e=e.53)&&!1q(e))2X;7 e};4 3L=6(e){7 1q(e.3O)||2W(e.3O)};4 52=6(e){7 1q(e.3M)||3N(e.3M)};4 51=6(e){4 c=[];e=3L(e);1f(e){c.11(e);e=2W(e)}7 c};4 3K=1c;4 2O=6(e){4 d=2U(e);7(2V d.3I=="50")?/\\.4Z$/i.B(d.4Y):3J(d.3I=="4X 4W")};4 2U=6(e){7 e.4V||e.K};4 2l=6(e,t){7(t=="*"&&e.1A)?e.1A:e.2l(t)};4 4U=6(e,t,n){x(t=="*")7 1q(e);x(!2T(e,n))7 1C;x(!2O(e))t=t.4T();7 e.2P==t};4 2T=6(e,n){7!n||(n=="*")||(e.4S==n)};4 4R=6(e){7 e.4Q};6 3H(r,f,1a){4 m,i,j;D(i=0;i<f.y;i++){x(m=f[i].1A.4P(1a)){x(m.1a==1a)r.11(m);1b x(m.y!=1L){D(j=0;j<m.y;j++){x(m[j].1a==1a)r.11(m[j])}}}}7 r};x(![].11)3G.16.11=6(){D(4 i=0;i<F.y;i++){8[8.y]=F[i]}7 8.y};4 N=/\\|/;6 3F(14,t,f,a){x(N.B(f)){f=f.2S(N);a=f[0];f=f[1]}4 r=[];x(1B[t]){1B[t](r,14,f,a)}7 r};4 S=/^[^\\s>+~]/;4 3E=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 2R(s){x(S.B(s))s=" "+s;7 s.1g(3E)||[]};4 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;4 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;4 3D=6(s){7 s.19(W,"$1").19(I,"$1*$2")};4 1y={O:6(){7"\'"},1g:/^(\'[^\']*\')|("[^"]*")$/,B:6(s){7 8.1g.B(s)},18:6(s){7 8.B(s)?s:8+s+8},3C:6(s){7 8.B(s)?s.1d(1,-1):s}};4 1N=6(t){7 1y.3C(t)};4 E=/([\\/()[\\]?{}|*+-])/g;6 4O(s){7 s.19(E,"\\\\$1")};1u=1c;7 H}();H.2Q=1c;H.2m("Z",6(){1q=6(e){7(e&&e.3B==1&&e.2P!="!"&&!e.3d)?e:1L}});H.Y("1N=F[1]",3k);4 1K=!H.Y("2O(F[1])",1J);4 2h=":21{Z-21:21}:2N{Z-21:2N}"+(1K?"":"*{4N:0}");4 15=z(3A.12({2F:z 1V,1O:"",1w:"",2L:[],1s:6(){8.2M();8.2g()},2g:6(){15.1Y.X=2h+8.1O+8.1w},3y:6(){4 20=K.2l("1e"),s;D(4 i=20.y-1;(s=20[i]);i--){x(!s.2H&&!s.Z){8.2L.11(s.3z)}}},2k:6(){8.3y();8.2g();z 28("1O");8.3u()},3w:6(e,r){8.2F.18(e,r)},1n:6(){4 R=/3v\\d+/g;4 s=2h.1g(/[{,]/g).y;4 20=s+(8.1O.X.1g(/\\{/g)||"").y;4 3x=8.1Y.4M,r;4 2j,c,2i,e,i,j,k,1a;D(i=s;i<20;i++){r=3x[i];x(r&&(2j=r.1e.X.1g(R))){2i=H(r.4L);x(2i.y)D(j=0;j<2j.y;j++){1a=2j[j];c=15.1p[1a.1d(10)][2];D(k=0;(e=2i[k]);k++){x(e.1v[1a])c(e)}}}}},2C:6(p,t,h,r){t=z 1Z("([{;\\\\s])"+p+"\\\\s*:\\\\s*"+t+"[^;}]*");4 i=8.1p.y;x(r)r=p+":"+r;8.3w(t,6(m,o){7(r?m[o+1]+r:m[o])+";Z-"+m[o].1d(1)+";3v"+i+":1"});8.1p.11(F);7 i},1N:6(s){7 s.X||""},2M:6(){x(1H||!1K)K.2M();1b K.4K("<1e Z=1c></1e>");8.1Y=17[17.y-1];8.1Y.Z=1c;8.1Y.X=2h},3u:6(){D(4 i=0;i<17.y;i++){x(!17[i].Z&&17[i].X){17[i].X=""}}}}));6 28(m){8.1z=m;8.1S();15[m]=8;15.2g()};13.12({J:28,O:6(){7"@1z "+8.1z+"{"+8.X+"}"},1n:1W,1S:6(){8.X="";8.1N();8.3m();8.X=3j(8.X);f={}},1N:6(){4 3r=[].3t(15.2L);4 M=/@1z\\s+([^{]*)\\{([^@]+\\})\\s*\\}/2I;4 A=/\\4J\\b|^$/i,S=/\\4I\\b/i,P=/\\4H\\b/i;6 3q(c,m){2f.v=m;7 c.19(M,2f)};6 2f(4G,m,c){m=2J(m);2K(m){1o"1O":1o"1w":x(m!=2f.v)7"";1o"1A":7 c}7""};6 2J(m){x(A.B(m))7"1A";1b x(S.B(m))7(P.B(m))?"1A":"1O";1b x(P.B(m))7"1w"};4 1X=8;6 2G(s,p,m,l){4 c="";x(!l){m=2J(s.1z);l=0}x(m=="1A"||m==1X.1z){x(l<3){D(4 i=0;i<s.3s.y;i++){c+=2G(s.3s[i],2e(s.2d,p),m,l+1)}}c+=3l(s.2d?3p(s,p):3r.3h()||"");c=3q(c,1X.1z)}7 c};4 f={};6 3p(s,p){4 u=1I(s.2d,p);x(f[u])7"";f[u]=(s.2H)?"":3o(15.1N(s,p),2e(s.2d,p));7 f[u]};4 U=/(4F\\s*\\(\\s*[\'"]?)([\\w\\.]+[^:\\)]*[\'"]?\\))/2I;6 3o(c,p){7 c.19(U,"$1"+p.1d(0,p.3n("/")+1)+"$2")};D(4 i=0;i<17.y;i++){x(!17[i].2H&&!17[i].Z){8.X+=2G(17[i])}}},3m:6(){8.X=15.2F.1U(8.X)},1n:1W});4 1y=H.Y("1y");4 2b=[];6 3l(c){7 1x.1U(2c.1U(c))};6 2E(m,o){7 1y+(2b.11(m[o])-1)+1y};6 3k(v){7 1y.B(v)?1k(2b[1k(v)]):v};4 1x=z 1V;1x.18(/\\/\\*[^*]*\\*+([^\\/][^*]*\\*+)*\\//);1x.18(/\'[^\']*\'/,2E);1x.18(/"[^"]*"/,2E);1x.18(/\\s+/," ");1x.18(/@(4E|4D)[^;\\n]+[;\\n]|<!\\-\\-|\\-\\->/);4 2c=z 1V;2c.18(/\\\\\'/,"\\\\4C");2c.18(/\\\\"/,"\\\\4B");4 2D=z 1V;2D.18(/\'(\\d+)\'/,3i);6 3j(c){7 2D.1U(c)};6 3i(m,o){7 2b[m[o+1]]};4 2B=[];6 4A(h){2C(h);1Q(1M,"4z",h)};6 1Q(e,t,h){e.4y(t,h);2B.11(F)};6 3g(e,t,h){1l{e.4x(t,h)}1i(i){}};1Q(1M,"4w",6(){4 h;1f(h=2B.3h()){3g(h[0],h[1],h[2])}});6 4v(h,e,c){x(!h.29)h.29={};x(c)h.29[e.2A]=e;1b 2a h.29[e.2A];7 c};1Q(1M,"4u",6(){x(!15.1w)z 28("1w");15.1w.1n()});4 3f=/^\\d+(4t)?$/i;4 4s=/^\\d+%$/;4 4r=6(e,v){x(3f.B(v))7 3e(v);4 s=e.1e.1m;4 r=e.1T.1m;e.1T.1m=e.1v.1m;e.1e.1m=v||0;v=e.1e.4q;e.1e.1m=s;e.1T.1m=r;7 v};6 4p(t){4 e=K.4o(t||"4n");e.1e.X="3c:4m;4l:0;4k:4j;4i:4h;4g:4f(0 0 0 0);1m:-4e";e.3d=1c;7 e};4 27="Z-";6 4d(e){7 e.1v["Z-3c"]=="4c"};6 4b(e,p){7 e.1v[27+p]||e.1v[p]};6 4a(e,p,v){x(e.1v[27+p]==1L){e.1T[27+p]=e.1v[p]}e.1T[p]=v};6 49(o,c,u){4 t=48(6(){1l{x(!o.1S)7;o.1S(o,c,u);3b(t)}1i(i){3b(t)}},10)};1u=1c;x(2z)1k(2y("Z-47.3a",1R));15.1s();x(1K&&1t)1t.1s();x(1H)1j.1s();1b{1J.46(1I("Z-1S.45",1R));1Q(K,"44",6(){x(K.39=="1H")43(1j.1s,0)})}}1i(e){1G("2x [0]: "+e.38)}37{}};',62,353,'||||var||function|return|this|||||||||||||||||||||||||if|length|new||test||for||arguments||cssQuery||constructor|document||||toString|||||||that||cssText|valueOf|ie7||push|specialize|Common|fr|ie7CSS|prototype|styleSheets|add|replace|id|else|true|slice|style|while|match|klass|catch|IE7|eval|try|left|recalc|case|recalcs|thisElement|ancestor|init|ie7HTML|loaded|currentStyle|print|encoder|Quote|media|all|selectors|false|_0|ICommon|httpRequest|alert|complete|makePath|documentElement|isHTML|null|window|getText|screen|cache|addEventHandler|path|load|runtimeStyle|exec|Parser|DUMMY|self|styleSheet|RegExp|st|link|modules|ParseMaster|_1|x01|Function|_2|StyleSheet|elements|delete|_3|safeString|href|getPath|_4|refresh|HEADER|el|ca|apply|getElementsByTagName|addModule|pseudoClasses|String|join|version|escapeChar|body|appVersion|ancestorOf|inherit|_5|Error|loadFile|quirksMode|uniqueID|_6|addRecalc|decoder|_7|parser|_8|disabled|gi|_9|switch|styles|createStyleSheet|visited|isXML|tagName|caching|_10|split|compareNamespace|getDocument|typeof|nextElementSibling|continue|links|className|error|se|callee|ignoreCase|_11|_12|ie7_debug|finally|description|readyState|js|clearInterval|position|ie7_anon|parseInt|PIXEL|removeEventHandler|pop|_13|decode|getString|_14|parse|lastIndexOf|_15|_16|_17|_18|imports|concat|trash|ie7_recalc|addFix|ru|getInlineStyles|innerHTML|Fix|nodeType|remove|parseSelector|ST|select|Array|_19|mimeType|Boolean|isMSIE|firstElementChild|lastChild|previousElementSibling|firstChild|clearCache|ES|_20|_21|_22|_23|_24|DE|viewport|status|scripts|search|location|top|setTimeout|onreadystatechange|htc|addBehavior|quirks|setInterval|addTimer|setOverrideStyle|getDefinedStyle|fixed|isFixed|9999|rect|clip|none|border|block|display|padding|absolute|object|createElement|createTempElement|pixelLeft|getPixelValue|PERCENT|px|onbeforeprint|register|onunload|detachEvent|attachEvent|onresize|addResize|x22|x27|import|namespace|url|ma|bprint|bscreen|ball|write|selectorText|rules|margin|regEscape|item|innerText|getTextContent|scopeName|toUpperCase|compareTagName|ownerDocument|Document|XML|URL|xml|unknown|childElements|lastElementChild|nextSibling|previousSibling|attributeSelectors|AttributeSelector|indexOf|number|reset|successfully|ie5|fixes|instanceOf|Object|common|in|caller|gif|blank|BLANK_GIF|file|loading|responseText|200|send|GET|open|XMLHTTP|ActiveXObject|Microsoft|Msxml2|ScriptEngineMajorVersion|src|ANON|ie7Layout|ms_|ie7_off|CSS1Compat|compatMode|MSIE|navigator|alpha'.split('|'),0,{}))
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('x(!1M.1j)z 6(){1l{1M.1j=8;4 1W=8.2m=z 26;8.O=6(){7"1j 2q 0.9 (5G)"};4 36=/36/.B(42.41.40);4 1G=(36)?6(m){1M.1G(1j+"\\n\\n"+m)}:1W;4 2t=5F.2t.1g(/5E (\\d\\.\\d)/)[1];4 2z=K.5D!="5C";x(/5B/.B(42.41.40)||2t<5||!/^5A/.B(K.1J.2A))7;4 1H=K.39=="1H";4 1t,5z;4 1J=K.1J,2s,3X,17=K.17;4 5y="!";4 22={};4 1u=1C;1j.2m=6(n,s){x(!22[n]){x(1u)1k("s="+2o(s));22[n]=z s()}};4 R=/^[\\w\\.]+[^:]*$/;6 1I(h,p){x(R.B(h))h=(p||"")+h;7 h};6 2e(h,p){h=1I(h,p);7 h.1d(0,h.3n("/")+1)};4 s=K.3Z[K.3Z.y-1];1l{1k(s.3z)}1i(i){}4 1R=2e(s.5x);4 1F;1l{4 l=(5w()>=5)?"5v":"5u";1F=z 5t(l+".5s")}1i(i){}4 2w={};6 2y(h,p){1l{h=1I(h,p);x(!2w[h]){1F.5r("5q",h,1C);1F.5p();x(1F.3Y==0||1F.3Y==5o){2w[h]=1F.5n}}}1i(i){1G("2x [1]: 30 5m 5l "+h)}37{7 2w[h]||""}};4 5k=1I("5j.5i",1R);6 1E(V){x(V!=1L){V.2v=13.16.2v;V.12=13.16.12}7 V};1E.12=6(p,c){x(!p)p={};x(!c)c=p.J;x(c=={}.J)c=z 26("8.2v()");c.Y=z 26("7 8");c.Y.16=z 8.Y;c.Y.16.12(p);c.16=z c.Y;c.Y.16.J=c.16.J=c;c.1r=8;c.12=F.32;c.2u=8.2u;7 c};1E.Y=z 26("7 8");1E.Y.16={J:1E,2v:6(){7 F.32.5h.1r.2k(8,F)},12:6(V){x(8==8.J.16&&8.J.12){7 8.J.Y.16.12(V)}D(4 i 5g V){2K(i){1o"J":1o"O":1o"Y":2X}x(2V V[i]=="6"&&V[i]!=8[i]){V[i].1r=8[i]}8[i]=V[i]}x(V.O!=8.O&&V.O!={}.O){V.O.1r=8.O;8.O=V.O}7 8}};6 13(){};8.13=1E.12({J:13,O:6(){7"[5f "+(8.J.2Z||"5e")+"]"},5d:6(1h){7 8.J==1h||1h.2u(8.J)}});13.2Z="13";13.1r=1L;13.2u=6(1h){1f(1h&&1h.1r!=8)1h=1h.1r;7 3J(1h)};13.Y.1r=1E;2a 8.13;4 3A=13.12({J:6(){8.5c=[];8.1p=[]},1s:1W});x(2t<5.5)1k(2y("Z-5b.3a",1R));4 35=1C;1j.1s=6(){1l{x(35)7;35=1H=1c;2s=K.2s;3X=(2z)?2s:1J;x(1K&&1t)1t.2k();15.2k();1n();1G("1u 5a")}1i(e){1G("2x [2]: "+e.38)}};4 1p=[];6 2C(r){1p.11(r)};6 1n(){H.3P();x(1K&&1t)1t.1n();15.1n();D(4 i=0;i<1p.y;i++)1p[i]()};6 23(){4 E=0,R=1,L=2;4 G=/\\(/g,S=/\\$\\d/,I=/^\\$\\d+$/,T=/([\'"])\\1\\+(.*)\\+\\1\\1$/,3Q=/\\\\./g,Q=/\'/,3W=/\\25[^\\25]*\\25/g;4 1X=8;8.18=6(e,r){x(!r)r="";4 l=(34(2o(e)).1g(G)||"").y+1;x(S.B(r)){x(I.B(r)){r=3e(r.1d(1))-1}1b{4 i=l;4 q=Q.B(34(r))?\'"\':"\'";1f(i)r=r.2S("$"+i--).2p(q+"+a[o+"+i+"]+"+q);r=z 26("a,o","7"+q+r.19(T,"$1")+q)}}3V(e||"/^$/",r,l)};8.1U=6(s){24.y=0;7 3R(3S(s,8.2r).19(z 1Z(1D,8.33?"2I":"g"),3T),8.2r).19(3W,"")};8.59=6(){1D.y=0};4 24=[];4 1D=[];4 3U=6(){7"("+2o(8[E]).1d(1,-1)+")"};1D.O=6(){7 8.2p("|")};6 3V(){F.O=3U;1D[1D.y]=F}6 3T(){x(!F[0])7"";4 i=1,j=0,p;1f(p=1D[j++]){x(F[i]){4 r=p[R];2K(2V r){1o"6":7 r(F,i);1o"58":7 F[r+i]}4 d=(F[i].57(1X.2r)==-1)?"":"\\25"+F[i]+"\\25";7 d+r}1b i+=p[L]}};6 3S(s,e){7 e?s.19(z 1Z("\\\\"+e+"(.)","g"),6(m,c){24[24.y]=c;7 e}):s};6 3R(s,e){4 i=0;7 e?s.19(z 1Z("\\\\"+e,"g"),6(){7 e+(24[i++]||"")}):s};6 34(s){7 s.19(3Q,"")}};23.16={J:23,33:1C,2r:""};13.12(23.16);4 1V=23.12({33:1c});4 H=6(){4 2q="2.0.2";4 C=/\\s*,\\s*/;4 H=6(s,14){1l{4 m=[];4 u=F.32.2Q&&!14;4 b=(14)?(14.J==3G)?14:[14]:[K];4 31=3D(s).2S(C),i;D(i=0;i<31.y;i++){s=2R(31[i]);x(3K&&s.1d(0,3).2p("")==" *#"){s=s.1d(2);14=3H([],b,s[1])}1b 14=b;4 j=0,t,f,a,c="";1f(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";x(s[j]=="("){1f(s[j++]!=")"&&j<s.y){a+=s[j]}a=a.1d(0,-1);c+="("+a+")"}14=(u&&1P[c])?1P[c]:3F(14,t,f,a);x(u)1P[c]=14}m=m.3t(14)}2a H.30;7 m}1i(e){H.30=e;7[]}};H.O=6(){7"6 H() {\\n [2q "+2q+"]\\n}"};4 1P={};H.2Q=1C;H.3P=6(s){x(s){s=2R(s).2p("");2a 1P[s]}1b 1P={}};4 22={};4 1u=1C;H.2m=6(n,s){x(1u)1k("s="+2o(s));22[n]=z s()};H.Y=6(c){7 c?1k(c):8};4 1B={};4 2n={};4 56={1g:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};4 55=[];1B[" "]=6(r,f,t,n){4 e,i,j;D(i=0;i<f.y;i++){4 s=2l(f[i],t,n);D(j=0;(e=s[j]);j++){x(1q(e)&&2T(e,n))r.11(e)}}};1B["#"]=6(r,f,i){4 e,j;D(j=0;(e=f[j]);j++)x(e.1a==i)r.11(e)};1B["."]=6(r,f,c){c=z 1Z("(^|\\\\s)"+c+"(\\\\s|$)");4 e,i;D(i=0;(e=f[i]);i++)x(c.B(e.2Z))r.11(e)};1B[":"]=6(r,f,p,a){4 t=2n[p],e,i;x(t)D(i=0;(e=f[i]);i++)x(t(e,a))r.11(e)};2n["21"]=6(e){4 d=2U(e);x(d.2Y)D(4 i=0;i<d.2Y.y;i++){x(d.2Y[i]==e)7 1c}};2n["2N"]=6(e){};4 1q=6(e){7(e&&e.3B==1&&e.2P!="!")?e:1L};4 3N=6(e){1f(e&&(e=e.54)&&!1q(e))2X;7 e};4 2W=6(e){1f(e&&(e=e.53)&&!1q(e))2X;7 e};4 3L=6(e){7 1q(e.3O)||2W(e.3O)};4 52=6(e){7 1q(e.3M)||3N(e.3M)};4 51=6(e){4 c=[];e=3L(e);1f(e){c.11(e);e=2W(e)}7 c};4 3K=1c;4 2O=6(e){4 d=2U(e);7(2V d.3I=="50")?/\\.4Z$/i.B(d.4Y):3J(d.3I=="4X 4W")};4 2U=6(e){7 e.4V||e.K};4 2l=6(e,t){7(t=="*"&&e.1A)?e.1A:e.2l(t)};4 4U=6(e,t,n){x(t=="*")7 1q(e);x(!2T(e,n))7 1C;x(!2O(e))t=t.4T();7 e.2P==t};4 2T=6(e,n){7!n||(n=="*")||(e.4S==n)};4 4R=6(e){7 e.4Q};6 3H(r,f,1a){4 m,i,j;D(i=0;i<f.y;i++){x(m=f[i].1A.4P(1a)){x(m.1a==1a)r.11(m);1b x(m.y!=1L){D(j=0;j<m.y;j++){x(m[j].1a==1a)r.11(m[j])}}}}7 r};x(![].11)3G.16.11=6(){D(4 i=0;i<F.y;i++){8[8.y]=F[i]}7 8.y};4 N=/\\|/;6 3F(14,t,f,a){x(N.B(f)){f=f.2S(N);a=f[0];f=f[1]}4 r=[];x(1B[t]){1B[t](r,14,f,a)}7 r};4 S=/^[^\\s>+~]/;4 3E=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 2R(s){x(S.B(s))s=" "+s;7 s.1g(3E)||[]};4 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;4 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;4 3D=6(s){7 s.19(W,"$1").19(I,"$1*$2")};4 1y={O:6(){7"\'"},1g:/^(\'[^\']*\')|("[^"]*")$/,B:6(s){7 8.1g.B(s)},18:6(s){7 8.B(s)?s:8+s+8},3C:6(s){7 8.B(s)?s.1d(1,-1):s}};4 1N=6(t){7 1y.3C(t)};4 E=/([\\/()[\\]?{}|*+-])/g;6 4O(s){7 s.19(E,"\\\\$1")};1u=1c;7 H}();H.2Q=1c;H.2m("Z",6(){1q=6(e){7(e&&e.3B==1&&e.2P!="!"&&!e.3d)?e:1L}});H.Y("1N=F[1]",3k);4 1K=!H.Y("2O(F[1])",1J);4 2h=":21{Z-21:21}:2N{Z-21:2N}"+(1K?"":"*{4N:0}");4 15=z(3A.12({2F:z 1V,1O:"",1w:"",2L:[],1s:6(){8.2M();8.2g()},2g:6(){15.1Y.X=2h+8.1O+8.1w},3y:6(){4 20=K.2l("1e"),s;D(4 i=20.y-1;(s=20[i]);i--){x(!s.2H&&!s.Z){8.2L.11(s.3z)}}},2k:6(){8.3y();8.2g();z 28("1O");8.3u()},3w:6(e,r){8.2F.18(e,r)},1n:6(){4 R=/3v\\d+/g;4 s=2h.1g(/[{,]/g).y;4 20=s+(8.1O.X.1g(/\\{/g)||"").y;4 3x=8.1Y.4M,r;4 2j,c,2i,e,i,j,k,1a;D(i=s;i<20;i++){r=3x[i];x(r&&(2j=r.1e.X.1g(R))){2i=H(r.4L);x(2i.y)D(j=0;j<2j.y;j++){1a=2j[j];c=15.1p[1a.1d(10)][2];D(k=0;(e=2i[k]);k++){x(e.1v[1a])c(e)}}}}},2C:6(p,t,h,r){t=z 1Z("([{;\\\\s])"+p+"\\\\s*:\\\\s*"+t+"[^;}]*");4 i=8.1p.y;x(r)r=p+":"+r;8.3w(t,6(m,o){7(r?m[o+1]+r:m[o])+";Z-"+m[o].1d(1)+";3v"+i+":1"});8.1p.11(F);7 i},1N:6(s){7 s.X||""},2M:6(){x(1H||!1K)K.2M();1b K.4K("<1e Z=1c></1e>");8.1Y=17[17.y-1];8.1Y.Z=1c;8.1Y.X=2h},3u:6(){D(4 i=0;i<17.y;i++){x(!17[i].Z&&17[i].X){17[i].X=""}}}}));6 28(m){8.1z=m;8.1S();15[m]=8;15.2g()};13.12({J:28,O:6(){7"@1z "+8.1z+"{"+8.X+"}"},1n:1W,1S:6(){8.X="";8.1N();8.3m();8.X=3j(8.X);f={}},1N:6(){4 3r=[].3t(15.2L);4 M=/@1z\\s+([^{]*)\\{([^@]+\\})\\s*\\}/2I;4 A=/\\4J\\b|^$/i,S=/\\4I\\b/i,P=/\\4H\\b/i;6 3q(c,m){2f.v=m;7 c.19(M,2f)};6 2f(4G,m,c){m=2J(m);2K(m){1o"1O":1o"1w":x(m!=2f.v)7"";1o"1A":7 c}7""};6 2J(m){x(A.B(m))7"1A";1b x(S.B(m))7(P.B(m))?"1A":"1O";1b x(P.B(m))7"1w"};4 1X=8;6 2G(s,p,m,l){4 c="";x(!l){m=2J(s.1z);l=0}x(m=="1A"||m==1X.1z){x(l<3){D(4 i=0;i<s.3s.y;i++){c+=2G(s.3s[i],2e(s.2d,p),m,l+1)}}c+=3l(s.2d?3p(s,p):3r.3h()||"");c=3q(c,1X.1z)}7 c};4 f={};6 3p(s,p){4 u=1I(s.2d,p);x(f[u])7"";f[u]=(s.2H)?"":3o(15.1N(s,p),2e(s.2d,p));7 f[u]};4 U=/(4F\\s*\\(\\s*[\'"]?)([\\w\\.]+[^:\\)]*[\'"]?\\))/2I;6 3o(c,p){7 c.19(U,"$1"+p.1d(0,p.3n("/")+1)+"$2")};D(4 i=0;i<17.y;i++){x(!17[i].2H&&!17[i].Z){8.X+=2G(17[i])}}},3m:6(){8.X=15.2F.1U(8.X)},1n:1W});4 1y=H.Y("1y");4 2b=[];6 3l(c){7 1x.1U(2c.1U(c))};6 2E(m,o){7 1y+(2b.11(m[o])-1)+1y};6 3k(v){7 1y.B(v)?1k(2b[1k(v)]):v};4 1x=z 1V;1x.18(/\\/\\*[^*]*\\*+([^\\/][^*]*\\*+)*\\//);1x.18(/\'[^\']*\'/,2E);1x.18(/"[^"]*"/,2E);1x.18(/\\s+/," ");1x.18(/@(4E|4D)[^;\\n]+[;\\n]|<!\\-\\-|\\-\\->/);4 2c=z 1V;2c.18(/\\\\\'/,"\\\\4C");2c.18(/\\\\"/,"\\\\4B");4 2D=z 1V;2D.18(/\'(\\d+)\'/,3i);6 3j(c){7 2D.1U(c)};6 3i(m,o){7 2b[m[o+1]]};4 2B=[];6 4A(h){2C(h);1Q(1M,"4z",h)};6 1Q(e,t,h){e.4y(t,h);2B.11(F)};6 3g(e,t,h){1l{e.4x(t,h)}1i(i){}};1Q(1M,"4w",6(){4 h;1f(h=2B.3h()){3g(h[0],h[1],h[2])}});6 4v(h,e,c){x(!h.29)h.29={};x(c)h.29[e.2A]=e;1b 2a h.29[e.2A];7 c};1Q(1M,"4u",6(){x(!15.1w)z 28("1w");15.1w.1n()});4 3f=/^\\d+(4t)?$/i;4 4s=/^\\d+%$/;4 4r=6(e,v){x(3f.B(v))7 3e(v);4 s=e.1e.1m;4 r=e.1T.1m;e.1T.1m=e.1v.1m;e.1e.1m=v||0;v=e.1e.4q;e.1e.1m=s;e.1T.1m=r;7 v};6 4p(t){4 e=K.4o(t||"4n");e.1e.X="3c:4m;4l:0;4k:4j;4i:4h;4g:4f(0 0 0 0);1m:-4e";e.3d=1c;7 e};4 27="Z-";6 4d(e){7 e.1v["Z-3c"]=="4c"};6 4b(e,p){7 e.1v[27+p]||e.1v[p]};6 4a(e,p,v){x(e.1v[27+p]==1L){e.1T[27+p]=e.1v[p]}e.1T[p]=v};6 49(o,c,u){4 t=48(6(){1l{x(!o.1S)7;o.1S(o,c,u);3b(t)}1i(i){3b(t)}},10)};1u=1c;x(2z)1k(2y("Z-47.3a",1R));15.1s();x(1K&&1t)1t.1s();x(1H)1j.1s();1b{1J.46(1I("Z-1S.45",1R));1Q(K,"44",6(){x(K.39=="1H")43(1j.1s,0)})}}1i(e){1G("2x [0]: "+e.38)}37{}};',62,353,'||||var||function|return|this|||||||||||||||||||||||||if|length|new||test||for||arguments||cssQuery||constructor|document||||toString|||||||that||cssText|valueOf|ie7||push|specialize|Common|fr|ie7CSS|prototype|styleSheets|add|replace|id|else|true|slice|style|while|match|klass|catch|IE7|eval|try|left|recalc|case|recalcs|thisElement|ancestor|init|ie7HTML|loaded|currentStyle|print|encoder|Quote|media|all|selectors|false|_0|ICommon|httpRequest|alert|complete|makePath|documentElement|isHTML|null|window|getText|screen|cache|addEventHandler|path|load|runtimeStyle|exec|Parser|DUMMY|self|styleSheet|RegExp|st|link|modules|ParseMaster|_1|x01|Function|_2|StyleSheet|elements|delete|_3|safeString|href|getPath|_4|refresh|HEADER|el|ca|apply|getElementsByTagName|addModule|pseudoClasses|String|join|version|escapeChar|body|appVersion|ancestorOf|inherit|_5|Error|loadFile|quirksMode|uniqueID|_6|addRecalc|decoder|_7|parser|_8|disabled|gi|_9|switch|styles|createStyleSheet|visited|isXML|tagName|caching|_10|split|compareNamespace|getDocument|typeof|nextElementSibling|continue|links|className|error|se|callee|ignoreCase|_11|_12|ie7_debug|finally|description|readyState|js|clearInterval|position|ie7_anon|parseInt|PIXEL|removeEventHandler|pop|_13|decode|getString|_14|parse|lastIndexOf|_15|_16|_17|_18|imports|concat|trash|ie7_recalc|addFix|ru|getInlineStyles|innerHTML|Fix|nodeType|remove|parseSelector|ST|select|Array|_19|mimeType|Boolean|isMSIE|firstElementChild|lastChild|previousElementSibling|firstChild|clearCache|ES|_20|_21|_22|_23|_24|DE|viewport|status|scripts|search|location|top|setTimeout|onreadystatechange|htc|addBehavior|quirks|setInterval|addTimer|setOverrideStyle|getDefinedStyle|fixed|isFixed|9999|rect|clip|none|border|block|display|padding|absolute|object|createElement|createTempElement|pixelLeft|getPixelValue|PERCENT|px|onbeforeprint|register|onunload|detachEvent|attachEvent|onresize|addResize|x22|x27|import|namespace|url|ma|bprint|bscreen|ball|write|selectorText|rules|margin|regEscape|item|innerText|getTextContent|scopeName|toUpperCase|compareTagName|ownerDocument|Document|XML|URL|xml|unknown|childElements|lastElementChild|nextSibling|previousSibling|attributeSelectors|AttributeSelector|indexOf|number|reset|successfully|ie5|fixes|instanceOf|Object|common|in|caller|gif|blank|BLANK_GIF|file|loading|responseText|200|send|GET|open|XMLHTTP|ActiveXObject|Microsoft|Msxml2|ScriptEngineMajorVersion|src|ANON|ie7Layout|ms_|ie7_off|CSS1Compat|compatMode|MSIE|navigator|alpha'.split('|'),0,{})) diff --git a/javascript/fixes/ie7/ie7-css-strict.js b/javascript/fixes/ie7/ie7-css-strict.js index 0c7e330..cc3c6a9 100644 --- a/javascript/fixes/ie7/ie7-css-strict.js +++ b/javascript/fixes/ie7/ie7-css-strict.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-css-strict",function(){if(!modules["ie7-css2-selectors"])return;StyleSheet.prototype.specialize({parse:function(){this.inherit();var r=[].concat(this.rules);r.sort(ie7CSS.Rule.compare);this.cssText=r.join("\n")},createRule:function(s,c){var m;if(m=s.match(ie7CSS.PseudoElement.MATCH))return new ie7CSS.PseudoElement(m[1],m[2],c);else if(m=s.match(ie7CSS.DynamicRule.MATCH))return new ie7CSS.DynamicRule(s,m[1],m[2],m[3],c);else return new ie7CSS.Rule(s,c)}});ie7CSS.specialize({apply:function(){this.inherit();this.Rule.MATCH=/([^{}]+)(\{[^{}]*\})/g}});ie7CSS.Rule.compare=function(r1,r2){return r1.specificity-r2.specificity};var N=[],I=/#/g,C=/[.:\[]/g,T=/^\w|[\s>+~]\w/g;ie7CSS.Rule.score=function(s){return(s.match(I)||N).length*10000+(s.match(C)||N).length*100+(s.match(T)||N).length};ie7CSS.Rule.simple=function(){return""};ie7CSS.Rule.prototype.specialize({specificity:0,init:function(){this.specificity=ie7CSS.Rule.score(this.selector)}})});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-css-strict",function(){if(!modules["ie7-css2-selectors"])return;StyleSheet.prototype.specialize({parse:function(){this.inherit();var r=[].concat(this.rules);r.sort(ie7CSS.Rule.compare);this.cssText=r.join("\n")},createRule:function(s,c){var m;if(m=s.match(ie7CSS.PseudoElement.MATCH))return new ie7CSS.PseudoElement(m[1],m[2],c);else if(m=s.match(ie7CSS.DynamicRule.MATCH))return new ie7CSS.DynamicRule(s,m[1],m[2],m[3],c);else return new ie7CSS.Rule(s,c)}});ie7CSS.specialize({apply:function(){this.inherit();this.Rule.MATCH=/([^{}]+)(\{[^{}]*\})/g}});ie7CSS.Rule.compare=function(r1,r2){return r1.specificity-r2.specificity};var N=[],I=/#/g,C=/[.:\[]/g,T=/^\w|[\s>+~]\w/g;ie7CSS.Rule.score=function(s){return(s.match(I)||N).length*10000+(s.match(C)||N).length*100+(s.match(T)||N).length};ie7CSS.Rule.simple=function(){return""};ie7CSS.Rule.prototype.specialize({specificity:0,init:function(){this.specificity=ie7CSS.Rule.score(this.selector)}})}); diff --git a/javascript/fixes/ie7/ie7-css2-selectors.js b/javascript/fixes/ie7/ie7-css2-selectors.js index bb08da3..5967068 100644 --- a/javascript/fixes/ie7/ie7-css2-selectors.js +++ b/javascript/fixes/ie7/ie7-css2-selectors.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-css2-selectors",function(){cssQuery.addModule("css-level2",function(){selectors[">"]=function(r,f,t,n){var e,i,j;for(i=0;i<f.length;i++){var s=childElements(f[i]);for(j=0;(e=s[j]);j++)if(compareTagName(e,t,n))r.push(e)}};selectors["+"]=function(r,f,t,n){for(var i=0;i<f.length;i++){var e=nextElementSibling(f[i]);if(e&&compareTagName(e,t,n))r.push(e)}};selectors["@"]=function(r,f,a){var t=attributeSelectors[a].test;var e,i;for(i=0;(e=f[i]);i++)if(t(e))r.push(e)};pseudoClasses["first-child"]=function(e){return!previousElementSibling(e)};pseudoClasses["lang"]=function(e,c){c=new RegExp("^"+c,"i");while(e&&!e.getAttribute("lang"))e=e.parentNode;return e&&c.test(e.getAttribute("lang"))};AttributeSelector.NS_IE=/\\:/g;AttributeSelector.PREFIX="@";AttributeSelector.tests={};AttributeSelector.replace=function(m,a,n,c,v){var k=this.PREFIX+m;if(!attributeSelectors[k]){a=this.create(a,c||"",v||"");attributeSelectors[k]=a;attributeSelectors.push(a)}return attributeSelectors[k].id};AttributeSelector.parse=function(s){s=s.replace(this.NS_IE,"|");var m;while(m=s.match(this.match)){var r=this.replace(m[0],m[1],m[2],m[3],m[4]);s=s.replace(this.match,r)}return s};AttributeSelector.create=function(p,t,v){var a={};a.id=this.PREFIX+attributeSelectors.length;a.name=p;t=this.tests[t];t=t?t(this.getAttribute(p),getText(v)):false;a.test=new Function("e","return "+t);return a};AttributeSelector.getAttribute=function(n){switch(n.toLowerCase()){case"id":return"e.id";case"class":return"e.className";case"for":return"e.htmlFor";case"href":if(isMSIE){return"String((e.outerHTML.match(/href=\\x22?([^\\s\\x22]*)\\x22?/)||[])[1]||'')"}}return"e.getAttribute('"+n.replace(N,":")+"')"};AttributeSelector.tests[""]=function(a){return a};AttributeSelector.tests["="]=function(a,v){return a+"=="+Quote.add(v)};AttributeSelector.tests["~="]=function(a,v){return"/(^| )"+regEscape(v)+"( |$)/.test("+a+")"};AttributeSelector.tests["|="]=function(a,v){return"/^"+regEscape(v)+"(-|$)/.test("+a+")"};var _6=parseSelector;parseSelector=function(s){return _6(AttributeSelector.parse(s))}});var AttributeSelector=cssQuery.valueOf("AttributeSelector");var H=/a(#[\w-]+)?(\.[\w-]+)?:(hover|active)/i;var B1=/\s*\{\s*/,B2=/\s*\}\s*/,C=/\s*\,\s*/;var F=/(.*)(:first-(line|letter))/;StyleSheet.prototype.specialize({parse:function(){this.inherit();var o=ie7CSS.rules.length;var ru=this.cssText.split(B2),r;var se,c,i,j;for(i=0;i<ru.length;i++){r=ru[i].split(B1);se=r[0].split(C);c=r[1];for(j=0;j<se.length;j++){se[j]=c?this.createRule(se[j],c):""}ru[i]=se.join("\n")}this.cssText=ru.join("\n");this.rules=ie7CSS.rules.slice(o)},recalc:function(){var r,i;for(i=0;(r=this.rules[i]);i++)r.recalc()},createRule:function(s,c){if(ie7CSS.UNKNOWN.test(s)){var m;if(m=s.match(PseudoElement.MATCH)){return new PseudoElement(m[1],m[2],c)}else if(m=s.match(DynamicRule.MATCH)){if(!isHTML||!H.test(m)||DynamicRule.COMPLEX.test(m)){return new DynamicRule(s,m[1],m[2],m[3],c)}}else return new Rule(s,c)}return s+" {"+c+"}"}});ie7CSS.specialize({rules:[],pseudoClasses:cssQuery.valueOf("pseudoClasses"),dynamicPseudoClasses:{},cache:cssQuery.valueOf("cache"),Rule:Rule,DynamicRule:DynamicRule,PseudoElement:PseudoElement,DynamicPseudoClass:DynamicPseudoClass,apply:function(){var p=this.pseudoClasses+"|before|after|"+this.dynamicPseudoClasses;p=p.replace(/(link|visited)\|/g,"");this.UNKNOWN=new RegExp("[>+~\[]|([:.])[\\w-()]+\\1|:("+p+")");var c="[^\\s(]+\\s*[+~]|@\\d+|:(";Rule.COMPLEX=new RegExp(c+p+")","g");DynamicRule.COMPLEX=new RegExp(c+this.pseudoClasses+")","g");DynamicRule.MATCH=new RegExp("(.*):("+this.dynamicPseudoClasses+")(.*)");PseudoElement.MATCH=/(.*):(before|after).*/;this.inherit()},recalc:function(){this.screen.recalc();this.inherit()},getText:function(s,p){return httpRequest?(loadFile(s.href,p)||s.cssText):this.inherit(s)},addEventHandler:function(e,t,h){addEventHandler(e,t,h)}});function Rule(s,c){this.id=ie7CSS.rules.length;this.className=Rule.PREFIX+this.id;s=(s).match(F)||s||"*";this.selector=s[1]||s;this.selectorText=Rule.simple(this.selector)+"."+this.className+(s[2]||"");this.cssText=c;this.MATCH=new RegExp("\\s"+this.className+"(\\s|$)","g");ie7CSS.rules.push(this);this.init()};Common.specialize({constructor:Rule,toString:function(){return this.selectorText+" {"+this.cssText+"}"},init:DUMMY,add:function(e){e.className+=" "+this.className},remove:function(e){e.className=e.className.replace(this.MATCH,"$1")},recalc:function(){var m=ie7CSS.cache[" *."+this.className]=cssQuery(this.selector);for(i=0;i<m.length;i++)this.add(m[i])}});Rule.PREFIX="ie7_class";Rule.CHILD=/>/g;Rule.simple=function(s){s=AttributeSelector.parse(s);return s.replace(this.COMPLEX,"").replace(this.CHILD," ")};function DynamicRule(s,a,d,t,c){this.attach=a||"*";this.dynamicPseudoClass=ie7CSS.dynamicPseudoClasses[d];this.target=t;this.inherit(s,c)};Rule.specialize({constructor:DynamicRule,recalc:function(){var m=cssQuery(this.attach);for(var i=0;i<m.length;i++){var t=(this.target)?cssQuery(this.target,m[i]):[m[i]];if(t.length)this.dynamicPseudoClass.apply(m[i],t,this)}}});var A=/^attr/;var U=/^url\s*\(\s*([^)]*)\)$/;var M={before0:"beforeBegin",before1:"afterBegin",after0:"afterEnd",after1:"beforeEnd"};var _5=makePath("ie7-content.htc",path)+"?";HEADER+=".ie7_anon{display:none}";function PseudoElement(s,p,c){this.position=p;var co=c.match(PseudoElement.CONTENT),m,e;if(co){co=co[1];m=co.split(/\s+/);for(var i=0;(e=m[i]);i++){m[i]=A.test(e)?{attr:e.slice(5,-1)}:(e.charAt(0)=="'")?getString(e):decode(e)}co=m}this.content=co;this.inherit(s,decode(c))};Rule.specialize({constructor:PseudoElement,toString:function(){return"."+this.className+"{display:inline}"},init:function(){this.match=cssQuery(this.selector);for(var i=0;i<this.match.length;i++){var r=this.match[i].runtimeStyle;if(!r[this.position])r[this.position]={cssText:""};r[this.position].cssText+=";"+this.cssText;if(this.content!=null)r[this.position].content=this.content}},recalc:function(){if(this.content==null)return;for(var i=0;i<this.match.length;i++){this.create(this.match[i])}},create:function(t){var g=t.runtimeStyle[this.position];if(g){var c=[].concat(g.content||"");for(var j=0;j<c.length;j++){if(typeof c[j]=="object"){c[j]=t.getAttribute(c[j].attr)}}c=c.join("");var u=c.match(U);var h=PseudoElement[u?"OBJECT":"ANON"].replace(/%1/,this.className);var cs=g.cssText.replace(/'/g,'"');var po=M[this.position+Number(t.canHaveChildren)];if(u){var p=document.createElement(h);t.insertAdjacentElement(po,p);p.data=_5;addTimer(p,cs,Quote.remove(u[1]))}else{h=h.replace(/%2/,cs).replace(/%3/,c);t.insertAdjacentHTML(po,h)}t.runtimeStyle[this.position]=null}}});PseudoElement.CONTENT=/content\s*:\s*([^;]*)(;|$)/;PseudoElement.OBJECT="<object class='ie7_anon %1' ie7_anon width=100% height=0 type=text/x-scriptlet>";PseudoElement.ANON="<ie7:! class='ie7_anon %1' ie7_anon style='%2'>%3</ie7:!>";function DynamicPseudoClass(n,a){this.name=n;this.apply=a;this.instances={};ie7CSS.dynamicPseudoClasses[n]=this};Common.specialize({constructor:DynamicPseudoClass,register:function(i){var c=i[2];i.id=c.id+i[0].uniqueID;if(!this.instances[i.id]){var t=i[1],j;for(j=0;j<t.length;j++)c.add(t[j]);this.instances[i.id]=i}},unregister:function(i){if(this.instances[i.id]){var c=i[2];var t=i[1],j;for(j=0;j<t.length;j++)c.remove(t[j]);delete this.instances[i.id]}}});ie7CSS.pseudoClasses.toString=function(){var t=[],p;for(p in this){if(this[p].length>1)p+="\\([^)]*\\)";t.push(p)}return t.join("|")};ie7CSS.pseudoClasses["link"]=function(e){return e.currentStyle["ie7-link"]=="link"};ie7CSS.pseudoClasses["visited"]=function(e){return e.currentStyle["ie7-link"]=="visited"};var _4=(appVersion<5.5)?"onmouseover":"onmouseenter";var _3=(appVersion<5.5)?"onmouseout":"onmouseleave";ie7CSS.dynamicPseudoClasses.toString=ie7CSS.pseudoClasses.toString;var _0=new DynamicPseudoClass("hover",function(e){var i=arguments;ie7CSS.addEventHandler(e,_4,function(){_0.register(i)});ie7CSS.addEventHandler(e,_3,function(){_0.unregister(i)})});var _1=new DynamicPseudoClass("focus",function(e){var i=arguments;ie7CSS.addEventHandler(e,"onfocus",function(){_1.unregister(i);_1.register(i)});ie7CSS.addEventHandler(e,"onblur",function(){_1.unregister(i)});if(e==document.activeElement){_1.register(i)}});var _2=new DynamicPseudoClass("active",function(e){var i=arguments;ie7CSS.addEventHandler(e,"onmousedown",function(){_2.register(i)})});addEventHandler(document,"onmouseup",function(){var i=_2.instances,j;for(j in i)_2.unregister(i[j]);i=_0.instances;for(j in i)if(!i[j][0].contains(event.srcElement))_0.unregister(i[j])});ICommon(AttributeSelector);AttributeSelector.specialize({getAttribute:function(n){switch(n.toLowerCase()){case"class":return"e.className.replace(/\\b\\s*ie7_class\\d+/g,'')";case"src":return"(e.pngSrc||e.src)"}return this.inherit(n)}});encoder.add(/::/,":");safeString.add(/\\([\da-fA-F]{1,4})/,function(m,o){m=m[o+1];return"\\u"+"0000".slice(m.length)+m})});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-css2-selectors",function(){cssQuery.addModule("css-level2",function(){selectors[">"]=function(r,f,t,n){var e,i,j;for(i=0;i<f.length;i++){var s=childElements(f[i]);for(j=0;(e=s[j]);j++)if(compareTagName(e,t,n))r.push(e)}};selectors["+"]=function(r,f,t,n){for(var i=0;i<f.length;i++){var e=nextElementSibling(f[i]);if(e&&compareTagName(e,t,n))r.push(e)}};selectors["@"]=function(r,f,a){var t=attributeSelectors[a].test;var e,i;for(i=0;(e=f[i]);i++)if(t(e))r.push(e)};pseudoClasses["first-child"]=function(e){return!previousElementSibling(e)};pseudoClasses["lang"]=function(e,c){c=new RegExp("^"+c,"i");while(e&&!e.getAttribute("lang"))e=e.parentNode;return e&&c.test(e.getAttribute("lang"))};AttributeSelector.NS_IE=/\\:/g;AttributeSelector.PREFIX="@";AttributeSelector.tests={};AttributeSelector.replace=function(m,a,n,c,v){var k=this.PREFIX+m;if(!attributeSelectors[k]){a=this.create(a,c||"",v||"");attributeSelectors[k]=a;attributeSelectors.push(a)}return attributeSelectors[k].id};AttributeSelector.parse=function(s){s=s.replace(this.NS_IE,"|");var m;while(m=s.match(this.match)){var r=this.replace(m[0],m[1],m[2],m[3],m[4]);s=s.replace(this.match,r)}return s};AttributeSelector.create=function(p,t,v){var a={};a.id=this.PREFIX+attributeSelectors.length;a.name=p;t=this.tests[t];t=t?t(this.getAttribute(p),getText(v)):false;a.test=new Function("e","return "+t);return a};AttributeSelector.getAttribute=function(n){switch(n.toLowerCase()){case"id":return"e.id";case"class":return"e.className";case"for":return"e.htmlFor";case"href":if(isMSIE){return"String((e.outerHTML.match(/href=\\x22?([^\\s\\x22]*)\\x22?/)||[])[1]||'')"}}return"e.getAttribute('"+n.replace(N,":")+"')"};AttributeSelector.tests[""]=function(a){return a};AttributeSelector.tests["="]=function(a,v){return a+"=="+Quote.add(v)};AttributeSelector.tests["~="]=function(a,v){return"/(^| )"+regEscape(v)+"( |$)/.test("+a+")"};AttributeSelector.tests["|="]=function(a,v){return"/^"+regEscape(v)+"(-|$)/.test("+a+")"};var _6=parseSelector;parseSelector=function(s){return _6(AttributeSelector.parse(s))}});var AttributeSelector=cssQuery.valueOf("AttributeSelector");var H=/a(#[\w-]+)?(\.[\w-]+)?:(hover|active)/i;var B1=/\s*\{\s*/,B2=/\s*\}\s*/,C=/\s*\,\s*/;var F=/(.*)(:first-(line|letter))/;StyleSheet.prototype.specialize({parse:function(){this.inherit();var o=ie7CSS.rules.length;var ru=this.cssText.split(B2),r;var se,c,i,j;for(i=0;i<ru.length;i++){r=ru[i].split(B1);se=r[0].split(C);c=r[1];for(j=0;j<se.length;j++){se[j]=c?this.createRule(se[j],c):""}ru[i]=se.join("\n")}this.cssText=ru.join("\n");this.rules=ie7CSS.rules.slice(o)},recalc:function(){var r,i;for(i=0;(r=this.rules[i]);i++)r.recalc()},createRule:function(s,c){if(ie7CSS.UNKNOWN.test(s)){var m;if(m=s.match(PseudoElement.MATCH)){return new PseudoElement(m[1],m[2],c)}else if(m=s.match(DynamicRule.MATCH)){if(!isHTML||!H.test(m)||DynamicRule.COMPLEX.test(m)){return new DynamicRule(s,m[1],m[2],m[3],c)}}else return new Rule(s,c)}return s+" {"+c+"}"}});ie7CSS.specialize({rules:[],pseudoClasses:cssQuery.valueOf("pseudoClasses"),dynamicPseudoClasses:{},cache:cssQuery.valueOf("cache"),Rule:Rule,DynamicRule:DynamicRule,PseudoElement:PseudoElement,DynamicPseudoClass:DynamicPseudoClass,apply:function(){var p=this.pseudoClasses+"|before|after|"+this.dynamicPseudoClasses;p=p.replace(/(link|visited)\|/g,"");this.UNKNOWN=new RegExp("[>+~\[]|([:.])[\\w-()]+\\1|:("+p+")");var c="[^\\s(]+\\s*[+~]|@\\d+|:(";Rule.COMPLEX=new RegExp(c+p+")","g");DynamicRule.COMPLEX=new RegExp(c+this.pseudoClasses+")","g");DynamicRule.MATCH=new RegExp("(.*):("+this.dynamicPseudoClasses+")(.*)");PseudoElement.MATCH=/(.*):(before|after).*/;this.inherit()},recalc:function(){this.screen.recalc();this.inherit()},getText:function(s,p){return httpRequest?(loadFile(s.href,p)||s.cssText):this.inherit(s)},addEventHandler:function(e,t,h){addEventHandler(e,t,h)}});function Rule(s,c){this.id=ie7CSS.rules.length;this.className=Rule.PREFIX+this.id;s=(s).match(F)||s||"*";this.selector=s[1]||s;this.selectorText=Rule.simple(this.selector)+"."+this.className+(s[2]||"");this.cssText=c;this.MATCH=new RegExp("\\s"+this.className+"(\\s|$)","g");ie7CSS.rules.push(this);this.init()};Common.specialize({constructor:Rule,toString:function(){return this.selectorText+" {"+this.cssText+"}"},init:DUMMY,add:function(e){e.className+=" "+this.className},remove:function(e){e.className=e.className.replace(this.MATCH,"$1")},recalc:function(){var m=ie7CSS.cache[" *."+this.className]=cssQuery(this.selector);for(i=0;i<m.length;i++)this.add(m[i])}});Rule.PREFIX="ie7_class";Rule.CHILD=/>/g;Rule.simple=function(s){s=AttributeSelector.parse(s);return s.replace(this.COMPLEX,"").replace(this.CHILD," ")};function DynamicRule(s,a,d,t,c){this.attach=a||"*";this.dynamicPseudoClass=ie7CSS.dynamicPseudoClasses[d];this.target=t;this.inherit(s,c)};Rule.specialize({constructor:DynamicRule,recalc:function(){var m=cssQuery(this.attach);for(var i=0;i<m.length;i++){var t=(this.target)?cssQuery(this.target,m[i]):[m[i]];if(t.length)this.dynamicPseudoClass.apply(m[i],t,this)}}});var A=/^attr/;var U=/^url\s*\(\s*([^)]*)\)$/;var M={before0:"beforeBegin",before1:"afterBegin",after0:"afterEnd",after1:"beforeEnd"};var _5=makePath("ie7-content.htc",path)+"?";HEADER+=".ie7_anon{display:none}";function PseudoElement(s,p,c){this.position=p;var co=c.match(PseudoElement.CONTENT),m,e;if(co){co=co[1];m=co.split(/\s+/);for(var i=0;(e=m[i]);i++){m[i]=A.test(e)?{attr:e.slice(5,-1)}:(e.charAt(0)=="'")?getString(e):decode(e)}co=m}this.content=co;this.inherit(s,decode(c))};Rule.specialize({constructor:PseudoElement,toString:function(){return"."+this.className+"{display:inline}"},init:function(){this.match=cssQuery(this.selector);for(var i=0;i<this.match.length;i++){var r=this.match[i].runtimeStyle;if(!r[this.position])r[this.position]={cssText:""};r[this.position].cssText+=";"+this.cssText;if(this.content!=null)r[this.position].content=this.content}},recalc:function(){if(this.content==null)return;for(var i=0;i<this.match.length;i++){this.create(this.match[i])}},create:function(t){var g=t.runtimeStyle[this.position];if(g){var c=[].concat(g.content||"");for(var j=0;j<c.length;j++){if(typeof c[j]=="object"){c[j]=t.getAttribute(c[j].attr)}}c=c.join("");var u=c.match(U);var h=PseudoElement[u?"OBJECT":"ANON"].replace(/%1/,this.className);var cs=g.cssText.replace(/'/g,'"');var po=M[this.position+Number(t.canHaveChildren)];if(u){var p=document.createElement(h);t.insertAdjacentElement(po,p);p.data=_5;addTimer(p,cs,Quote.remove(u[1]))}else{h=h.replace(/%2/,cs).replace(/%3/,c);t.insertAdjacentHTML(po,h)}t.runtimeStyle[this.position]=null}}});PseudoElement.CONTENT=/content\s*:\s*([^;]*)(;|$)/;PseudoElement.OBJECT="<object class='ie7_anon %1' ie7_anon width=100% height=0 type=text/x-scriptlet>";PseudoElement.ANON="<ie7:! class='ie7_anon %1' ie7_anon style='%2'>%3</ie7:!>";function DynamicPseudoClass(n,a){this.name=n;this.apply=a;this.instances={};ie7CSS.dynamicPseudoClasses[n]=this};Common.specialize({constructor:DynamicPseudoClass,register:function(i){var c=i[2];i.id=c.id+i[0].uniqueID;if(!this.instances[i.id]){var t=i[1],j;for(j=0;j<t.length;j++)c.add(t[j]);this.instances[i.id]=i}},unregister:function(i){if(this.instances[i.id]){var c=i[2];var t=i[1],j;for(j=0;j<t.length;j++)c.remove(t[j]);delete this.instances[i.id]}}});ie7CSS.pseudoClasses.toString=function(){var t=[],p;for(p in this){if(this[p].length>1)p+="\\([^)]*\\)";t.push(p)}return t.join("|")};ie7CSS.pseudoClasses["link"]=function(e){return e.currentStyle["ie7-link"]=="link"};ie7CSS.pseudoClasses["visited"]=function(e){return e.currentStyle["ie7-link"]=="visited"};var _4=(appVersion<5.5)?"onmouseover":"onmouseenter";var _3=(appVersion<5.5)?"onmouseout":"onmouseleave";ie7CSS.dynamicPseudoClasses.toString=ie7CSS.pseudoClasses.toString;var _0=new DynamicPseudoClass("hover",function(e){var i=arguments;ie7CSS.addEventHandler(e,_4,function(){_0.register(i)});ie7CSS.addEventHandler(e,_3,function(){_0.unregister(i)})});var _1=new DynamicPseudoClass("focus",function(e){var i=arguments;ie7CSS.addEventHandler(e,"onfocus",function(){_1.unregister(i);_1.register(i)});ie7CSS.addEventHandler(e,"onblur",function(){_1.unregister(i)});if(e==document.activeElement){_1.register(i)}});var _2=new DynamicPseudoClass("active",function(e){var i=arguments;ie7CSS.addEventHandler(e,"onmousedown",function(){_2.register(i)})});addEventHandler(document,"onmouseup",function(){var i=_2.instances,j;for(j in i)_2.unregister(i[j]);i=_0.instances;for(j in i)if(!i[j][0].contains(event.srcElement))_0.unregister(i[j])});ICommon(AttributeSelector);AttributeSelector.specialize({getAttribute:function(n){switch(n.toLowerCase()){case"class":return"e.className.replace(/\\b\\s*ie7_class\\d+/g,'')";case"src":return"(e.pngSrc||e.src)"}return this.inherit(n)}});encoder.add(/::/,":");safeString.add(/\\([\da-fA-F]{1,4})/,function(m,o){m=m[o+1];return"\\u"+"0000".slice(m.length)+m})}); diff --git a/javascript/fixes/ie7/ie7-css3-selectors.js b/javascript/fixes/ie7/ie7-css3-selectors.js index 7337b82..1a0de78 100644 --- a/javascript/fixes/ie7/ie7-css3-selectors.js +++ b/javascript/fixes/ie7/ie7-css3-selectors.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-css3-selectors",function(){cssQuery.addModule("css-level3",function(){selectors["~"]=function(r,f,t,n){var e,i;for(i=0;(e=f[i]);i++){while(e=nextElementSibling(e)){if(compareTagName(e,t,n))r.push(e)}}};pseudoClasses["contains"]=function(e,t){t=new RegExp(regEscape(getText(t)));return t.test(getTextContent(e))};pseudoClasses["root"]=function(e){return e==getDocument(e).documentElement};pseudoClasses["empty"]=function(e){var n,i;for(i=0;(n=e.childNodes[i]);i++){if(thisElement(n)||n.nodeType==3)return false}return true};pseudoClasses["last-child"]=function(e){return!nextElementSibling(e)};pseudoClasses["only-child"]=function(e){e=e.parentNode;return firstElementChild(e)==lastElementChild(e)};pseudoClasses["not"]=function(e,s){var n=cssQuery(s,getDocument(e));for(var i=0;i<n.length;i++){if(n[i]==e)return false}return true};pseudoClasses["nth-child"]=function(e,a){return nthChild(e,a,previousElementSibling)};pseudoClasses["nth-last-child"]=function(e,a){return nthChild(e,a,nextElementSibling)};pseudoClasses["target"]=function(e){return e.id==location.hash.slice(1)};pseudoClasses["checked"]=function(e){return e.checked};pseudoClasses["enabled"]=function(e){return e.disabled===false};pseudoClasses["disabled"]=function(e){return e.disabled};pseudoClasses["indeterminate"]=function(e){return e.indeterminate};AttributeSelector.tests["^="]=function(a,v){return"/^"+regEscape(v)+"/.test("+a+")"};AttributeSelector.tests["$="]=function(a,v){return"/"+regEscape(v)+"$/.test("+a+")"};AttributeSelector.tests["*="]=function(a,v){return"/"+regEscape(v)+"/.test("+a+")"};function nthChild(e,a,t){switch(a){case"n":return true;case"even":a="2n";break;case"odd":a="2n+1"}var ch=childElements(e.parentNode);function _5(i){var i=(t==nextElementSibling)?ch.length-i:i-1;return ch[i]==e};if(!isNaN(a))return _5(a);a=a.split("n");var m=parseInt(a[0]);var s=parseInt(a[1]);if((isNaN(m)||m==1)&&s==0)return true;if(m==0&&!isNaN(s))return _5(s);if(isNaN(s))s=0;var c=1;while(e=t(e))c++;if(isNaN(m)||m==1)return(t==nextElementSibling)?(c<=s):(s>=c);return(c%m)==s}});var firstElementChild=cssQuery.valueOf("firstElementChild");ie7CSS.pseudoClasses["root"]=function(e){return(e==viewport)||(!isHTML&&e==firstElementChild(body))};var _4=new ie7CSS.DynamicPseudoClass("checked",function(e){if(typeof e.checked!="boolean")return;var i=arguments;ie7CSS.addEventHandler(e,"onpropertychange",function(){if(event.propertyName=="checked"){if(e.checked)_4.register(i);else _4.unregister(i)}});if(e.checked)_4.register(i)});var _3=new ie7CSS.DynamicPseudoClass("enabled",function(e){if(typeof e.disabled!="boolean")return;var i=arguments;ie7CSS.addEventHandler(e,"onpropertychange",function(){if(event.propertyName=="disabled"){if(!e.isDisabled)_3.register(i);else _3.unregister(i)}});if(!e.isDisabled)_3.register(i)});var _2=new ie7CSS.DynamicPseudoClass("disabled",function(e){if(typeof e.disabled!="boolean")return;var i=arguments;ie7CSS.addEventHandler(e,"onpropertychange",function(){if(event.propertyName=="disabled"){if(e.isDisabled)_2.register(i);else _2.unregister(i)}});if(e.isDisabled)_2.register(i)});var _1=new ie7CSS.DynamicPseudoClass("indeterminate",function(e){if(typeof e.indeterminate!="boolean")return;var i=arguments;ie7CSS.addEventHandler(e,"onpropertychange",function(){if(event.propertyName=="indeterminate"){if(e.indeterminate)_1.register(i);else _1.unregister(i)}});ie7CSS.addEventHandler(e,"onclick",function(){_1.unregister(i)})});var _0=new ie7CSS.DynamicPseudoClass("target",function(e){var i=arguments;if(!e.tabIndex)e.tabIndex=0;ie7CSS.addEventHandler(document,"onpropertychange",function(){if(event.propertyName=="activeElement"){if(e.id==location.hash.slice(1))_0.register(i);else _0.unregister(i)}});if(e.id==location.hash.slice(1))_0.register(i)});decoder.add(/\|/,"\\:")});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-css3-selectors",function(){cssQuery.addModule("css-level3",function(){selectors["~"]=function(r,f,t,n){var e,i;for(i=0;(e=f[i]);i++){while(e=nextElementSibling(e)){if(compareTagName(e,t,n))r.push(e)}}};pseudoClasses["contains"]=function(e,t){t=new RegExp(regEscape(getText(t)));return t.test(getTextContent(e))};pseudoClasses["root"]=function(e){return e==getDocument(e).documentElement};pseudoClasses["empty"]=function(e){var n,i;for(i=0;(n=e.childNodes[i]);i++){if(thisElement(n)||n.nodeType==3)return false}return true};pseudoClasses["last-child"]=function(e){return!nextElementSibling(e)};pseudoClasses["only-child"]=function(e){e=e.parentNode;return firstElementChild(e)==lastElementChild(e)};pseudoClasses["not"]=function(e,s){var n=cssQuery(s,getDocument(e));for(var i=0;i<n.length;i++){if(n[i]==e)return false}return true};pseudoClasses["nth-child"]=function(e,a){return nthChild(e,a,previousElementSibling)};pseudoClasses["nth-last-child"]=function(e,a){return nthChild(e,a,nextElementSibling)};pseudoClasses["target"]=function(e){return e.id==location.hash.slice(1)};pseudoClasses["checked"]=function(e){return e.checked};pseudoClasses["enabled"]=function(e){return e.disabled===false};pseudoClasses["disabled"]=function(e){return e.disabled};pseudoClasses["indeterminate"]=function(e){return e.indeterminate};AttributeSelector.tests["^="]=function(a,v){return"/^"+regEscape(v)+"/.test("+a+")"};AttributeSelector.tests["$="]=function(a,v){return"/"+regEscape(v)+"$/.test("+a+")"};AttributeSelector.tests["*="]=function(a,v){return"/"+regEscape(v)+"/.test("+a+")"};function nthChild(e,a,t){switch(a){case"n":return true;case"even":a="2n";break;case"odd":a="2n+1"}var ch=childElements(e.parentNode);function _5(i){var i=(t==nextElementSibling)?ch.length-i:i-1;return ch[i]==e};if(!isNaN(a))return _5(a);a=a.split("n");var m=parseInt(a[0]);var s=parseInt(a[1]);if((isNaN(m)||m==1)&&s==0)return true;if(m==0&&!isNaN(s))return _5(s);if(isNaN(s))s=0;var c=1;while(e=t(e))c++;if(isNaN(m)||m==1)return(t==nextElementSibling)?(c<=s):(s>=c);return(c%m)==s}});var firstElementChild=cssQuery.valueOf("firstElementChild");ie7CSS.pseudoClasses["root"]=function(e){return(e==viewport)||(!isHTML&&e==firstElementChild(body))};var _4=new ie7CSS.DynamicPseudoClass("checked",function(e){if(typeof e.checked!="boolean")return;var i=arguments;ie7CSS.addEventHandler(e,"onpropertychange",function(){if(event.propertyName=="checked"){if(e.checked)_4.register(i);else _4.unregister(i)}});if(e.checked)_4.register(i)});var _3=new ie7CSS.DynamicPseudoClass("enabled",function(e){if(typeof e.disabled!="boolean")return;var i=arguments;ie7CSS.addEventHandler(e,"onpropertychange",function(){if(event.propertyName=="disabled"){if(!e.isDisabled)_3.register(i);else _3.unregister(i)}});if(!e.isDisabled)_3.register(i)});var _2=new ie7CSS.DynamicPseudoClass("disabled",function(e){if(typeof e.disabled!="boolean")return;var i=arguments;ie7CSS.addEventHandler(e,"onpropertychange",function(){if(event.propertyName=="disabled"){if(e.isDisabled)_2.register(i);else _2.unregister(i)}});if(e.isDisabled)_2.register(i)});var _1=new ie7CSS.DynamicPseudoClass("indeterminate",function(e){if(typeof e.indeterminate!="boolean")return;var i=arguments;ie7CSS.addEventHandler(e,"onpropertychange",function(){if(event.propertyName=="indeterminate"){if(e.indeterminate)_1.register(i);else _1.unregister(i)}});ie7CSS.addEventHandler(e,"onclick",function(){_1.unregister(i)})});var _0=new ie7CSS.DynamicPseudoClass("target",function(e){var i=arguments;if(!e.tabIndex)e.tabIndex=0;ie7CSS.addEventHandler(document,"onpropertychange",function(){if(event.propertyName=="activeElement"){if(e.id==location.hash.slice(1))_0.register(i);else _0.unregister(i)}});if(e.id==location.hash.slice(1))_0.register(i)});decoder.add(/\|/,"\\:")}); diff --git a/javascript/fixes/ie7/ie7-dhtml.js b/javascript/fixes/ie7/ie7-dhtml.js index d768063..5849daf 100644 --- a/javascript/fixes/ie7/ie7-dhtml.js +++ b/javascript/fixes/ie7/ie7-dhtml.js @@ -1,57 +1,57 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-dhtml", function() {
-
-/* ---------------------------------------------------------------------
- This module is still in development and should not be used.
---------------------------------------------------------------------- */
-
-ie7CSS.specialize("recalc", function() {
- this.inherit();
- for (var i = 0; i < this.recalcs.length; i++) {
- var $recalc = this.recalcs[i];
- for (var j = 0; i < $recalc[3].length; i++) {
- _addPropertyChangeHandler($recalc[3][j], _getPropertyName($recalc[2]), $recalc[1]);
- }
- }
-});
-
-// constants
-var _PATTERNS = {
- width: "(width|paddingLeft|paddingRight|borderLeftWidth|borderRightWidth|borderLeftStyle|borderRightStyle)",
- height: "(height|paddingTop|paddingBottom|borderTopHeight|borderBottomHeight|borderTopStyle|borderBottomStyle)"
-};
-var _PROPERTY_NAMES = {
- width: "fixedWidth",
- height: "fixedHeight",
- right: "width",
- bottom: "height"
-};
-var _DASH_LETTER = /-(\w)/g;
-var _PROPERTY_NAME = /\w+/;
-
-function _addPropertyChangeHandler($element, $propertyName, $fix) {
- addEventHandler($element, "onpropertychange", function() {
- if (_getPattern($propertyName).test(event.propertyName)) {
- _reset($element, $propertyName);
- $fix($element);
- }
- });
-};
-function _upper($match, $letter) {return $letter.toUpperCase()};
-function _getPropertyName($pattern) {
- return String(String($pattern).toLowerCase().replace(_DASH_LETTER, _upper).match(_PROPERTY_NAME));
-};
-function _getPattern($propertyName) {
- return eval("/^style." + (_PATTERNS[$propertyName] || $propertyName) + "$/");
-};
-function _reset($element, $propertyName) {
- $element.runtimeStyle[$propertyName] = "";
- $propertyName = _PROPERTY_NAMES[$propertyName]
- if ($propertyName) $element.runtimeStyle[$propertyName] = "";
-};
-
-});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-dhtml", function() { + +/* --------------------------------------------------------------------- + This module is still in development and should not be used. +--------------------------------------------------------------------- */ + +ie7CSS.specialize("recalc", function() { + this.inherit(); + for (var i = 0; i < this.recalcs.length; i++) { + var $recalc = this.recalcs[i]; + for (var j = 0; i < $recalc[3].length; i++) { + _addPropertyChangeHandler($recalc[3][j], _getPropertyName($recalc[2]), $recalc[1]); + } + } +}); + +// constants +var _PATTERNS = { + width: "(width|paddingLeft|paddingRight|borderLeftWidth|borderRightWidth|borderLeftStyle|borderRightStyle)", + height: "(height|paddingTop|paddingBottom|borderTopHeight|borderBottomHeight|borderTopStyle|borderBottomStyle)" +}; +var _PROPERTY_NAMES = { + width: "fixedWidth", + height: "fixedHeight", + right: "width", + bottom: "height" +}; +var _DASH_LETTER = /-(\w)/g; +var _PROPERTY_NAME = /\w+/; + +function _addPropertyChangeHandler($element, $propertyName, $fix) { + addEventHandler($element, "onpropertychange", function() { + if (_getPattern($propertyName).test(event.propertyName)) { + _reset($element, $propertyName); + $fix($element); + } + }); +}; +function _upper($match, $letter) {return $letter.toUpperCase()}; +function _getPropertyName($pattern) { + return String(String($pattern).toLowerCase().replace(_DASH_LETTER, _upper).match(_PROPERTY_NAME)); +}; +function _getPattern($propertyName) { + return eval("/^style." + (_PATTERNS[$propertyName] || $propertyName) + "$/"); +}; +function _reset($element, $propertyName) { + $element.runtimeStyle[$propertyName] = ""; + $propertyName = _PROPERTY_NAMES[$propertyName] + if ($propertyName) $element.runtimeStyle[$propertyName] = ""; +}; + +}); diff --git a/javascript/fixes/ie7/ie7-dynamic-attributes.js b/javascript/fixes/ie7/ie7-dynamic-attributes.js index e066911..a4a5f05 100644 --- a/javascript/fixes/ie7/ie7-dynamic-attributes.js +++ b/javascript/fixes/ie7/ie7-dynamic-attributes.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-dynamic-attributes",function(){if(!modules["ie7-css2-selectors"])return;var attributeSelectors=cssQuery.valueOf("attributeSelectors");var parseSelector=cssQuery.valueOf("parseSelector");function DynamicAttribute(s,a,d,t,c){this.attach=a||"*";parseSelector(d);this.dynamicAttribute=attributeSelectors["@"+d];this.target=t;this.inherit(s,c)};ie7CSS.Rule.specialize({constructor:DynamicAttribute,recalc:function(){var m=cssQuery(this.attach);for(var i=0;i<m.length;i++){var t=(this.target)?cssQuery(this.target,m[i]):[m[i]];if(t.length)this.apply(m[i],t)}},apply:function(e,t){var self=this;addEventHandler(e,"onpropertychange",function(){if(event.propertyName==self.dynamicAttribute.name)self.test(e,t)});this.test(e,t)},test:function(e,t){var a=this.dynamicAttribute.test(e)?"add":"remove";for(var i=0;(e=t[i]);i++)this[a](e)}});DynamicAttribute.MATCH=/(.*)(\[[^\]]*\])(.*)/;StyleSheet.prototype.specialize({createRule:function(s,c){var m;if(m=s.match(DynamicAttribute.MATCH)){return new DynamicAttribute(s,m[1],m[2],m[3],c)}else return this.inherit(s,c)}})});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-dynamic-attributes",function(){if(!modules["ie7-css2-selectors"])return;var attributeSelectors=cssQuery.valueOf("attributeSelectors");var parseSelector=cssQuery.valueOf("parseSelector");function DynamicAttribute(s,a,d,t,c){this.attach=a||"*";parseSelector(d);this.dynamicAttribute=attributeSelectors["@"+d];this.target=t;this.inherit(s,c)};ie7CSS.Rule.specialize({constructor:DynamicAttribute,recalc:function(){var m=cssQuery(this.attach);for(var i=0;i<m.length;i++){var t=(this.target)?cssQuery(this.target,m[i]):[m[i]];if(t.length)this.apply(m[i],t)}},apply:function(e,t){var self=this;addEventHandler(e,"onpropertychange",function(){if(event.propertyName==self.dynamicAttribute.name)self.test(e,t)});this.test(e,t)},test:function(e,t){var a=this.dynamicAttribute.test(e)?"add":"remove";for(var i=0;(e=t[i]);i++)this[a](e)}});DynamicAttribute.MATCH=/(.*)(\[[^\]]*\])(.*)/;StyleSheet.prototype.specialize({createRule:function(s,c){var m;if(m=s.match(DynamicAttribute.MATCH)){return new DynamicAttribute(s,m[1],m[2],m[3],c)}else return this.inherit(s,c)}})}); diff --git a/javascript/fixes/ie7/ie7-fixed.js b/javascript/fixes/ie7/ie7-fixed.js index 10d629f..add3f61 100644 --- a/javascript/fixes/ie7/ie7-fixed.js +++ b/javascript/fixes/ie7/ie7-fixed.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ IE7.addModule("ie7-fixed",function(){ie7CSS.addRecalc("position","fixed",_6,"absolute");ie7CSS.addRecalc("background(-attachment)?","[^};]*fixed",_7);var _10=(quirksMode)?"body":"documentElement";var _8=function(){if(body.currentStyle.backgroundAttachment!="fixed"){if(body.currentStyle.backgroundImage=="none"){body.runtimeStyle.backgroundRepeat="no-repeat";body.runtimeStyle.backgroundImage="url("+BLANK_GIF+")"}body.runtimeStyle.backgroundAttachment="fixed"}_8=DUMMY};var _0=createTempElement("img");function _1(f){return _2.exec(String(f))};var _2=new ParseMaster;_2.add(/Left/,"Top");_2.add(/left/,"top");_2.add(/Width/,"Height");_2.add(/width/,"height");_2.add(/right/,"bottom");_2.add(/X/,"Y");function _3(e){return(e)?isFixed(e)||_3(e.parentElement):false};function setExpression(e,p,ex){setTimeout("document.all."+e.uniqueID+".runtimeStyle.setExpression('"+p+"','"+ex+"')",0)};function _7(e){if(register(_7,e,e.currentStyle.backgroundAttachment=="fixed"&&!e.contains(body))){_8();backgroundLeft(e);backgroundTop(e);_9(e)}};function _9(e){_0.src=e.currentStyle.backgroundImage.slice(5,-2);var p=(e.canHaveChildren)?e:e.parentElement;p.appendChild(_0);setOffsetLeft(e);setOffsetTop(e);p.removeChild(_0)};function backgroundLeft(e){e.style.backgroundPositionX=e.currentStyle.backgroundPositionX;if(!_3(e)){var ex="(parseInt(runtimeStyle.offsetLeft)+document."+_10+".scrollLeft)||0";setExpression(e,"backgroundPositionX",ex)}};eval(_1(backgroundLeft));function setOffsetLeft(e){var p=_3(e)?"backgroundPositionX":"offsetLeft";e.runtimeStyle[p]=getOffsetLeft(e,e.style.backgroundPositionX)-e.getBoundingClientRect().left-e.clientLeft+2};eval(_1(setOffsetLeft));function getOffsetLeft(e,p){switch(p){case"left":case"top":return 0;case"right":case"bottom":return viewport.clientWidth-_0.offsetWidth;case"center":return(viewport.clientWidth-_0.offsetWidth)/2;default:if(PERCENT.test(p)){return parseInt((viewport.clientWidth-_0.offsetWidth)*parseFloat(p)/100)}_0.style.left=p;return _0.offsetLeft}};eval(_1(getOffsetLeft));function _6(e){if(register(_6,e,isFixed(e))){setOverrideStyle(e,"position","absolute");setOverrideStyle(e,"left",e.currentStyle.left);setOverrideStyle(e,"top",e.currentStyle.top);_8();if(ie7Layout)ie7Layout.fixRight(e);_5(e)}};function _5(e,r){positionTop(e,r);positionLeft(e,r,true);if(!e.runtimeStyle.autoLeft&&e.currentStyle.marginLeft=="auto"&&e.currentStyle.right!="auto"){var l=viewport.clientWidth-getPixelWidth(e,e.currentStyle.right)-getPixelWidth(e,e.runtimeStyle._12)-e.clientWidth;if(e.currentStyle.marginRight=="auto")l=parseInt(l/2);if(_3(e.offsetParent))e.runtimeStyle.pixelLeft+=l;else e.runtimeStyle.shiftLeft=l}clipWidth(e);clipHeight(e)};function clipWidth(e){if(e.currentStyle.width!="auto"){var r=e.getBoundingClientRect();var w=e.offsetWidth-viewport.clientWidth+r.left-2;if(w>=0){w=Math.max(getPixelValue(e,e.currentStyle.width)-w,0);setOverrideStyle(e,"width",w)}}};eval(_1(clipWidth));function positionLeft(e,r){if(!r&&PERCENT.test(e.currentStyle.width)){e.runtimeStyle.fixWidth=e.currentStyle.width}if(e.runtimeStyle.fixWidth){e.runtimeStyle.width=getPixelWidth(e,e.runtimeStyle.fixWidth)}if(r){if(!e.runtimeStyle.autoLeft)return}else{e.runtimeStyle.shiftLeft=0;e.runtimeStyle._12=e.currentStyle.left;e.runtimeStyle.autoLeft=e.currentStyle.right!="auto"&&e.currentStyle.left=="auto"}e.runtimeStyle.left="";e.runtimeStyle.screenLeft=getScreenLeft(e);e.runtimeStyle.pixelLeft=e.runtimeStyle.screenLeft;if(!r&&!_3(e.offsetParent)){var ex="runtimeStyle.screenLeft+runtimeStyle.shiftLeft+document."+_10+".scrollLeft";setExpression(e,"pixelLeft",ex)}};eval(_1(positionLeft));function getScreenLeft(e){var s=e.offsetLeft,n=1;if(e.runtimeStyle.autoLeft){s=viewport.clientWidth-e.offsetWidth-getPixelWidth(e,e.currentStyle.right)}if(e.currentStyle.marginLeft!="auto"){s-=getPixelWidth(e,e.currentStyle.marginLeft)}while(e=e.offsetParent){if(e.currentStyle.position!="static")n=-1;s+=e.offsetLeft*n}return s};eval(_1(getScreenLeft));function getPixelWidth(e,v){if(PERCENT.test(v))return parseInt(parseFloat(v)/100*viewport.clientWidth);return getPixelValue(e,v)};eval(_1(getPixelWidth));function _11(){var e=_7.elements;for(var i in e)_9(e[i]);e=_6.elements;for(i in e){_5(e[i],true);_5(e[i],true)}_4=0};var _4;addResize(function(){if(!_4)_4=setTimeout(_11,0)})});
\ No newline at end of file diff --git a/javascript/fixes/ie7/ie7-graphics.js b/javascript/fixes/ie7/ie7-graphics.js index 7e63c47..436e126 100644 --- a/javascript/fixes/ie7/ie7-graphics.js +++ b/javascript/fixes/ie7/ie7-graphics.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-graphics",function(){if(appVersion<5.5)return;var A="DXImageTransform.Microsoft.AlphaImageLoader";var F="progid:"+A+"(src='%1',sizingMethod='scale')";var _3=new RegExp((window.IE7_PNG_SUFFIX||"-trans.png")+"$","i");var _0=[];function _2(e){var f=e.filters[A];if(f){f.src=e.src;f.enabled=true}else{e.runtimeStyle.filter=F.replace(/%1/,e.src);_0.push(e)}e.src=BLANK_GIF};function _5(e){e.src=e.pngSrc;e.filters[A].enabled=false};ie7CSS.addFix(/opacity\s*:\s*([\d.]+)/,function(m,o){return"zoom:1;filter:progid:DXImageTransform.Microsoft.Alpha(opacity="+((parseFloat(m[o+1])*100)||1)+")"});var B=/background(-image)?\s*:\s*([^\(};]*)url\(([^\)]+)\)([^;}]*)/;ie7CSS.addFix(B,function(m,o){var u=getString(m[o+3]);return _3.test(u)?"filter:"+F.replace(/scale/,"crop").replace(/%1/,u)+";zoom:1;background"+(m[o+1]||"")+":"+(m[o+2]||"")+"none"+(m[o+4]||""):m[o]});if(ie7HTML){ie7HTML.addRecalc("img,input",function(e){if(e.tagName=="INPUT"&&e.type!="image")return;_4(e);addEventHandler(e,"onpropertychange",function(){if(!_1&&event.propertyName=="src"&&e.src.indexOf(BLANK_GIF)==-1)_4(e)})});var B64=/^data:.*;base64/i;var _7=makePath("ie7-base64.php",path);function _4(e){if(_3.test(e.src)){var i=new Image(e.width,e.height);i.onload=function(){e.width=i.width;e.height=i.height;i=null};i.src=e.src;e.pngSrc=e.src;_2(e)}else if(B64.test(e.src)){e.src=_7+"?"+e.src.slice(5)}};var I=/^image/i;var _6=makePath("ie7-object.htc",path);ie7HTML.addRecalc("object",function(e){if(I.test(e.type)){var o=document.createElement("<object type=text/x-scriptlet>");o.style.width=e.currentStyle.width;o.style.height=e.currentStyle.height;o.data=_6;var u=makePath(e.data,getPath(location.href));e.parentNode.replaceChild(o,e);cssQuery.clearCache("object");addTimer(o,"",u);return o}})}var _1=false;addEventHandler(window,"onbeforeprint",function(){_1=true;for(var i=0;i<_0.length;i++)_5(_0[i])});addEventHandler(window,"onafterprint",function(){for(var i=0;i<_0.length;i++)_2(_0[i]);_1=false})});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-graphics",function(){if(appVersion<5.5)return;var A="DXImageTransform.Microsoft.AlphaImageLoader";var F="progid:"+A+"(src='%1',sizingMethod='scale')";var _3=new RegExp((window.IE7_PNG_SUFFIX||"-trans.png")+"$","i");var _0=[];function _2(e){var f=e.filters[A];if(f){f.src=e.src;f.enabled=true}else{e.runtimeStyle.filter=F.replace(/%1/,e.src);_0.push(e)}e.src=BLANK_GIF};function _5(e){e.src=e.pngSrc;e.filters[A].enabled=false};ie7CSS.addFix(/opacity\s*:\s*([\d.]+)/,function(m,o){return"zoom:1;filter:progid:DXImageTransform.Microsoft.Alpha(opacity="+((parseFloat(m[o+1])*100)||1)+")"});var B=/background(-image)?\s*:\s*([^\(};]*)url\(([^\)]+)\)([^;}]*)/;ie7CSS.addFix(B,function(m,o){var u=getString(m[o+3]);return _3.test(u)?"filter:"+F.replace(/scale/,"crop").replace(/%1/,u)+";zoom:1;background"+(m[o+1]||"")+":"+(m[o+2]||"")+"none"+(m[o+4]||""):m[o]});if(ie7HTML){ie7HTML.addRecalc("img,input",function(e){if(e.tagName=="INPUT"&&e.type!="image")return;_4(e);addEventHandler(e,"onpropertychange",function(){if(!_1&&event.propertyName=="src"&&e.src.indexOf(BLANK_GIF)==-1)_4(e)})});var B64=/^data:.*;base64/i;var _7=makePath("ie7-base64.php",path);function _4(e){if(_3.test(e.src)){var i=new Image(e.width,e.height);i.onload=function(){e.width=i.width;e.height=i.height;i=null};i.src=e.src;e.pngSrc=e.src;_2(e)}else if(B64.test(e.src)){e.src=_7+"?"+e.src.slice(5)}};var I=/^image/i;var _6=makePath("ie7-object.htc",path);ie7HTML.addRecalc("object",function(e){if(I.test(e.type)){var o=document.createElement("<object type=text/x-scriptlet>");o.style.width=e.currentStyle.width;o.style.height=e.currentStyle.height;o.data=_6;var u=makePath(e.data,getPath(location.href));e.parentNode.replaceChild(o,e);cssQuery.clearCache("object");addTimer(o,"",u);return o}})}var _1=false;addEventHandler(window,"onbeforeprint",function(){_1=true;for(var i=0;i<_0.length;i++)_5(_0[i])});addEventHandler(window,"onafterprint",function(){for(var i=0;i<_0.length;i++)_2(_0[i]);_1=false})}); diff --git a/javascript/fixes/ie7/ie7-html4.js b/javascript/fixes/ie7/ie7-html4.js index 3fcd891..239f3b6 100644 --- a/javascript/fixes/ie7/ie7-html4.js +++ b/javascript/fixes/ie7/ie7-html4.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-html4",function(){if(!isHTML)return;HEADER+="h1{font-size:2em}h2{font-size:1.5em;}h3{font-size:1.17em;}"+"h4{font-size:1em}h5{font-size:.83em}h6{font-size:.67em}";var _0={};ie7HTML=new(Fix.specialize({init:DUMMY,addFix:function(){this.fixes.push(arguments)},apply:function(){for(var i=0;i<this.fixes.length;i++){var m=cssQuery(this.fixes[i][0]);var f=this.fixes[i][1]||_1;for(var j=0;j<m.length;j++)f(m[j])}},addRecalc:function(){this.recalcs.push(arguments)},recalc:function(){for(var i=0;i<this.recalcs.length;i++){var m=cssQuery(this.recalcs[i][0]);var r=this.recalcs[i][1],e;var k=Math.pow(2,i);for(var j=0;(e=m[j]);j++){var u=e.uniqueID;if((_0[u]&k)==0){e=r(e)||e;_0[u]|=k}}}}}));ie7HTML.addFix("abbr");ie7HTML.addRecalc("label",function(e){if(!e.htmlFor){var f=cssQuery("input,textarea",e)[0];if(f){addEventHandler(e,"onclick",function(){f.click()})}}});ie7HTML.addRecalc("button,input",function(e){if(e.tagName=="BUTTON"){var m=e.outerHTML.match(/ value="([^"]*)"/i);e.runtimeStyle.value=(m)?m[1]:""}if(e.type=="submit"){addEventHandler(e,"onclick",function(){e.runtimeStyle.clicked=true;setTimeout("document.all."+e.uniqueID+".runtimeStyle.clicked=false",1)})}});var U=/^(submit|reset|button)$/;ie7HTML.addRecalc("form",function(e){addEventHandler(e,"onsubmit",function(){for(var i=0;i<e.length;i++){if(_2(e[i])){e[i].disabled=true;setTimeout("document.all."+e[i].uniqueID+".disabled=false",1)}else if(e[i].tagName=="BUTTON"&&e[i].type=="submit"){setTimeout("document.all."+e[i].uniqueID+".value='"+e[i].value+"'",1);e[i].value=e[i].runtimeStyle.value}}})});function _2(e){return U.test(e.type)&&!e.disabled&&!e.runtimeStyle.clicked};ie7HTML.addRecalc("img",function(e){if(e.alt&&!e.title)e.title=""});var P=(appVersion<5.5)?"HTML:":"";function _1(e){var f=document.createElement("<"+P+e.outerHTML.slice(1));if(e.outerHTML.slice(-2)!="/>"){var en="</"+e.tagName+">",n;while((n=e.nextSibling)&&n.outerHTML!=en){f.appendChild(n)}if(n)n.removeNode()}e.parentNode.replaceChild(f,e)}});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-html4",function(){if(!isHTML)return;HEADER+="h1{font-size:2em}h2{font-size:1.5em;}h3{font-size:1.17em;}"+"h4{font-size:1em}h5{font-size:.83em}h6{font-size:.67em}";var _0={};ie7HTML=new(Fix.specialize({init:DUMMY,addFix:function(){this.fixes.push(arguments)},apply:function(){for(var i=0;i<this.fixes.length;i++){var m=cssQuery(this.fixes[i][0]);var f=this.fixes[i][1]||_1;for(var j=0;j<m.length;j++)f(m[j])}},addRecalc:function(){this.recalcs.push(arguments)},recalc:function(){for(var i=0;i<this.recalcs.length;i++){var m=cssQuery(this.recalcs[i][0]);var r=this.recalcs[i][1],e;var k=Math.pow(2,i);for(var j=0;(e=m[j]);j++){var u=e.uniqueID;if((_0[u]&k)==0){e=r(e)||e;_0[u]|=k}}}}}));ie7HTML.addFix("abbr");ie7HTML.addRecalc("label",function(e){if(!e.htmlFor){var f=cssQuery("input,textarea",e)[0];if(f){addEventHandler(e,"onclick",function(){f.click()})}}});ie7HTML.addRecalc("button,input",function(e){if(e.tagName=="BUTTON"){var m=e.outerHTML.match(/ value="([^"]*)"/i);e.runtimeStyle.value=(m)?m[1]:""}if(e.type=="submit"){addEventHandler(e,"onclick",function(){e.runtimeStyle.clicked=true;setTimeout("document.all."+e.uniqueID+".runtimeStyle.clicked=false",1)})}});var U=/^(submit|reset|button)$/;ie7HTML.addRecalc("form",function(e){addEventHandler(e,"onsubmit",function(){for(var i=0;i<e.length;i++){if(_2(e[i])){e[i].disabled=true;setTimeout("document.all."+e[i].uniqueID+".disabled=false",1)}else if(e[i].tagName=="BUTTON"&&e[i].type=="submit"){setTimeout("document.all."+e[i].uniqueID+".value='"+e[i].value+"'",1);e[i].value=e[i].runtimeStyle.value}}})});function _2(e){return U.test(e.type)&&!e.disabled&&!e.runtimeStyle.clicked};ie7HTML.addRecalc("img",function(e){if(e.alt&&!e.title)e.title=""});var P=(appVersion<5.5)?"HTML:":"";function _1(e){var f=document.createElement("<"+P+e.outerHTML.slice(1));if(e.outerHTML.slice(-2)!="/>"){var en="</"+e.tagName+">",n;while((n=e.nextSibling)&&n.outerHTML!=en){f.appendChild(n)}if(n)n.removeNode()}e.parentNode.replaceChild(f,e)}}); diff --git a/javascript/fixes/ie7/ie7-ie5.js b/javascript/fixes/ie7/ie7-ie5.js index a07fd98..412ec81 100644 --- a/javascript/fixes/ie7/ie7-ie5.js +++ b/javascript/fixes/ie7/ie7-ie5.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-if(appVersion<5.5){ANON="HTML:!";var ap=function(f,o,a){f.apply(o,a)};if(''.replace(/^/,String)){var _0=String.prototype.replace;var _1=function(e,r){var m,n="",s=this;while(s&&(m=e.exec(s))){n+=s.slice(0,m.index)+ap(r,this,m);s=s.slice(m.lastIndex)}return n+s};String.prototype.replace=function(e,r){this.replace=(typeof r=="function")?_1:_0;return this.replace(e,r)}}if(!Function.apply){var APPLY="apply-"+Number(new Date);ap=function(f,o,a){var r;o[APPLY]=f;switch(a.length){case 0:r=o[APPLY]();break;case 1:r=o[APPLY](a[0]);break;case 2:r=o[APPLY](a[0],a[1]);break;case 3:r=o[APPLY](a[0],a[1],a[2]);break;case 4:r=o[APPLY](a[0],a[1],a[2],a[3]);break;default:var aa=[],i=a.length-1;do aa[i]="a["+i+"]";while(i--);eval("r=o[APPLY]("+aa+")")}delete o[APPLY];return r};ICommon.valueOf.prototype.inherit=function(){return ap(arguments.callee.caller.ancestor,this,arguments)}}if(![].push)Array.prototype.push=function(){for(var i=0;i<arguments.length;i++){this[this.length]=arguments[i]}return this.length};if(![].pop)Array.prototype.pop=function(){var i=this[this.length-1];this.length--;return i};if(isHTML){HEADER+="address,blockquote,body,dd,div,dt,fieldset,form,"+"frame,frameset,h1,h2,h3,h4,h5,h6,iframe,noframes,object,p,"+"hr,applet,center,dir,menu,pre,dl,li,ol,ul{display:block}"}}
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +if(appVersion<5.5){ANON="HTML:!";var ap=function(f,o,a){f.apply(o,a)};if(''.replace(/^/,String)){var _0=String.prototype.replace;var _1=function(e,r){var m,n="",s=this;while(s&&(m=e.exec(s))){n+=s.slice(0,m.index)+ap(r,this,m);s=s.slice(m.lastIndex)}return n+s};String.prototype.replace=function(e,r){this.replace=(typeof r=="function")?_1:_0;return this.replace(e,r)}}if(!Function.apply){var APPLY="apply-"+Number(new Date);ap=function(f,o,a){var r;o[APPLY]=f;switch(a.length){case 0:r=o[APPLY]();break;case 1:r=o[APPLY](a[0]);break;case 2:r=o[APPLY](a[0],a[1]);break;case 3:r=o[APPLY](a[0],a[1],a[2]);break;case 4:r=o[APPLY](a[0],a[1],a[2],a[3]);break;default:var aa=[],i=a.length-1;do aa[i]="a["+i+"]";while(i--);eval("r=o[APPLY]("+aa+")")}delete o[APPLY];return r};ICommon.valueOf.prototype.inherit=function(){return ap(arguments.callee.caller.ancestor,this,arguments)}}if(![].push)Array.prototype.push=function(){for(var i=0;i<arguments.length;i++){this[this.length]=arguments[i]}return this.length};if(![].pop)Array.prototype.pop=function(){var i=this[this.length-1];this.length--;return i};if(isHTML){HEADER+="address,blockquote,body,dd,div,dt,fieldset,form,"+"frame,frameset,h1,h2,h3,h4,h5,h6,iframe,noframes,object,p,"+"hr,applet,center,dir,menu,pre,dl,li,ol,ul{display:block}"}} diff --git a/javascript/fixes/ie7/ie7-layout.js b/javascript/fixes/ie7/ie7-layout.js index d1b64eb..009599d 100644 --- a/javascript/fixes/ie7/ie7-layout.js +++ b/javascript/fixes/ie7/ie7-layout.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-layout",function(){ie7Layout=this;HEADER+="*{boxSizing:content-box}";this.hasLayout=(appVersion<5.5)?function(e){return e.clientWidth}:function(e){return e.currentStyle.hasLayout};this.boxSizing=function(e){if(!ie7Layout.hasLayout(e)){e.style.height="0cm";if(e.currentStyle.verticalAlign=="auto")e.runtimeStyle.verticalAlign="top";_1(e)}};function _1(e){if(e!=viewport&&e.currentStyle.position!="absolute"){collapseMarginTop(e);collapseMarginBottom(e)}};var firstElementChild=cssQuery.valueOf("firstElementChild");var lastElementChild=cssQuery.valueOf("lastElementChild");function collapseMarginTop(e){if(!e.runtimeStyle.marginTop){var p=e.parentElement;if(p&&ie7Layout.hasLayout(p)&&e==firstElementChild(p))return;var f=firstElementChild(e);if(f&&f.currentStyle.styleFloat=="none"&&ie7Layout.hasLayout(f)){collapseMarginTop(f);m=_3(e,e.currentStyle.marginTop);c=_3(f,f.currentStyle.marginTop);if(m<0||c<0){e.runtimeStyle.marginTop=m+c}else{e.runtimeStyle.marginTop=Math.max(c,m)}f.runtimeStyle.marginTop="0px"}}};eval(String(collapseMarginTop).replace(/Top/g,"Bottom").replace(/first/g,"last"));function _3(e,v){return(v=="auto")?0:getPixelValue(e,v)};var U=/^[.\d][\w%]*$/,A=/^(auto|0cm)$/,N="[.\\d]";var applyWidth,applyHeight;function borderBox(e){applyWidth(e);applyHeight(e)};function fixWidth(H){applyWidth=function(e){if(!PERCENT.test(e.currentStyle.width))fixWidth(e);_1(e)};function fixWidth(e,v){if(!e.runtimeStyle.fixedWidth){if(!v)v=e.currentStyle.width;e.runtimeStyle.fixedWidth=(U.test(v))?Math.max(0,getFixedWidth(e,v)):v;setOverrideStyle(e,"width",e.runtimeStyle.fixedWidth)}};function layoutWidth(e){if(!isFixed(e)){var l=e.offsetParent;while(l&&!ie7Layout.hasLayout(l))l=l.offsetParent}return(l||viewport).clientWidth};function getPixelWidth(e,v){if(PERCENT.test(v))return parseInt(parseFloat(v)/100*layoutWidth(e));return getPixelValue(e,v)};var getFixedWidth=function(e,v){var b=e.currentStyle["box-sizing"]=="border-box";var a=0;if(quirksMode&&!b)a+=getBorderWidth(e)+getPaddingWidth(e);else if(!quirksMode&&b)a-=getBorderWidth(e)+getPaddingWidth(e);return getPixelWidth(e,v)+a};function getBorderWidth(e){return e.offsetWidth-e.clientWidth};function getPaddingWidth(e){return getPixelWidth(e,e.currentStyle.paddingLeft)+getPixelWidth(e,e.currentStyle.paddingRight)};eval(String(getPaddingWidth).replace(/padding/g,"margin").replace(/Padding/g,"Margin"));HEADER+="*{minWidth:none;maxWidth:none;min-width:none;max-width:none}";function minWidth(e){if(e.currentStyle["min-width"]!=null){e.style.minWidth=e.currentStyle["min-width"]}if(register(minWidth,e,e.currentStyle.minWidth!="none")){ie7Layout.boxSizing(e);fixWidth(e);resizeWidth(e)}};eval(String(minWidth).replace(/min/g,"max"));ie7Layout.minWidth=minWidth;ie7Layout.maxWidth=maxWidth;function resizeWidth(e){var r=e.getBoundingClientRect();var w=r.right-r.left;if(e.currentStyle.minWidth!="none"&&w<=getFixedWidth(e,e.currentStyle.minWidth)){e.runtimeStyle.width=getFixedWidth(e,e.currentStyle.minWidth)}else if(e.currentStyle.maxWidth!="none"&&w>=getFixedWidth(e,e.currentStyle.maxWidth)){e.runtimeStyle.width=getFixedWidth(e,e.currentStyle.maxWidth)}else{e.runtimeStyle.width=e.runtimeStyle.fixedWidth}};function fixRight(e){if(register(fixRight,e,/^(fixed|absolute)$/.test(e.currentStyle.position)&&getDefinedStyle(e,"left")!="auto"&&getDefinedStyle(e,"right")!="auto"&&A.test(getDefinedStyle(e,"width")))){resizeRight(e);ie7Layout.boxSizing(e)}};ie7Layout.fixRight=fixRight;function resizeRight(e){var l=getPixelWidth(e,e.runtimeStyle._4||e.currentStyle.left);var w=layoutWidth(e)-getPixelWidth(e,e.currentStyle.right)-l-getMarginWidth(e);if(parseInt(e.runtimeStyle.width)==w)return;e.runtimeStyle.width="";if(isFixed(e)||H||e.offsetWidth<w){if(!quirksMode)w-=getBorderWidth(e)+getPaddingWidth(e);if(w<0)w=0;e.runtimeStyle.fixedWidth=w;setOverrideStyle(e,"width",w)}};var _2=0;addResize(function(){var i,w=(_2<viewport.clientWidth);_2=viewport.clientWidth;for(i in minWidth.elements){var e=minWidth.elements[i];var f=(parseInt(e.runtimeStyle.width)==getFixedWidth(e,e.currentStyle.minWidth));if(w&&f)e.runtimeStyle.width="";if(w==f)resizeWidth(e)}for(i in maxWidth.elements){var e=maxWidth.elements[i];var f=(parseInt(e.runtimeStyle.width)==getFixedWidth(e,e.currentStyle.maxWidth));if(!w&&f)e.runtimeStyle.width="";if(w!=f)resizeWidth(e)}for(i in fixRight.elements)resizeRight(fixRight.elements[i])});if(window.IE7_BOX_MODEL!==false){ie7CSS.addRecalc("width",N,quirksMode?applyWidth:_1)}ie7CSS.addRecalc("min-width",N,minWidth);ie7CSS.addRecalc("max-width",N,maxWidth);ie7CSS.addRecalc("right",N,fixRight)};ie7CSS.addRecalc("border-spacing",N,function(e){if(e.currentStyle.borderCollapse!="collapse"){e.cellSpacing=getPixelValue(e,e.currentStyle["border-spacing"])}});ie7CSS.addRecalc("box-sizing","content-box",this.boxSizing);ie7CSS.addRecalc("box-sizing","border-box",borderBox);var _0=new ParseMaster;_0.add(/Width/,"Height");_0.add(/width/,"height");_0.add(/Left/,"Top");_0.add(/left/,"top");_0.add(/Right/,"Bottom");_0.add(/right/,"bottom");eval(_0.exec(String(fixWidth)));fixWidth();fixHeight(true)});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-layout",function(){ie7Layout=this;HEADER+="*{boxSizing:content-box}";this.hasLayout=(appVersion<5.5)?function(e){return e.clientWidth}:function(e){return e.currentStyle.hasLayout};this.boxSizing=function(e){if(!ie7Layout.hasLayout(e)){e.style.height="0cm";if(e.currentStyle.verticalAlign=="auto")e.runtimeStyle.verticalAlign="top";_1(e)}};function _1(e){if(e!=viewport&&e.currentStyle.position!="absolute"){collapseMarginTop(e);collapseMarginBottom(e)}};var firstElementChild=cssQuery.valueOf("firstElementChild");var lastElementChild=cssQuery.valueOf("lastElementChild");function collapseMarginTop(e){if(!e.runtimeStyle.marginTop){var p=e.parentElement;if(p&&ie7Layout.hasLayout(p)&&e==firstElementChild(p))return;var f=firstElementChild(e);if(f&&f.currentStyle.styleFloat=="none"&&ie7Layout.hasLayout(f)){collapseMarginTop(f);m=_3(e,e.currentStyle.marginTop);c=_3(f,f.currentStyle.marginTop);if(m<0||c<0){e.runtimeStyle.marginTop=m+c}else{e.runtimeStyle.marginTop=Math.max(c,m)}f.runtimeStyle.marginTop="0px"}}};eval(String(collapseMarginTop).replace(/Top/g,"Bottom").replace(/first/g,"last"));function _3(e,v){return(v=="auto")?0:getPixelValue(e,v)};var U=/^[.\d][\w%]*$/,A=/^(auto|0cm)$/,N="[.\\d]";var applyWidth,applyHeight;function borderBox(e){applyWidth(e);applyHeight(e)};function fixWidth(H){applyWidth=function(e){if(!PERCENT.test(e.currentStyle.width))fixWidth(e);_1(e)};function fixWidth(e,v){if(!e.runtimeStyle.fixedWidth){if(!v)v=e.currentStyle.width;e.runtimeStyle.fixedWidth=(U.test(v))?Math.max(0,getFixedWidth(e,v)):v;setOverrideStyle(e,"width",e.runtimeStyle.fixedWidth)}};function layoutWidth(e){if(!isFixed(e)){var l=e.offsetParent;while(l&&!ie7Layout.hasLayout(l))l=l.offsetParent}return(l||viewport).clientWidth};function getPixelWidth(e,v){if(PERCENT.test(v))return parseInt(parseFloat(v)/100*layoutWidth(e));return getPixelValue(e,v)};var getFixedWidth=function(e,v){var b=e.currentStyle["box-sizing"]=="border-box";var a=0;if(quirksMode&&!b)a+=getBorderWidth(e)+getPaddingWidth(e);else if(!quirksMode&&b)a-=getBorderWidth(e)+getPaddingWidth(e);return getPixelWidth(e,v)+a};function getBorderWidth(e){return e.offsetWidth-e.clientWidth};function getPaddingWidth(e){return getPixelWidth(e,e.currentStyle.paddingLeft)+getPixelWidth(e,e.currentStyle.paddingRight)};eval(String(getPaddingWidth).replace(/padding/g,"margin").replace(/Padding/g,"Margin"));HEADER+="*{minWidth:none;maxWidth:none;min-width:none;max-width:none}";function minWidth(e){if(e.currentStyle["min-width"]!=null){e.style.minWidth=e.currentStyle["min-width"]}if(register(minWidth,e,e.currentStyle.minWidth!="none")){ie7Layout.boxSizing(e);fixWidth(e);resizeWidth(e)}};eval(String(minWidth).replace(/min/g,"max"));ie7Layout.minWidth=minWidth;ie7Layout.maxWidth=maxWidth;function resizeWidth(e){var r=e.getBoundingClientRect();var w=r.right-r.left;if(e.currentStyle.minWidth!="none"&&w<=getFixedWidth(e,e.currentStyle.minWidth)){e.runtimeStyle.width=getFixedWidth(e,e.currentStyle.minWidth)}else if(e.currentStyle.maxWidth!="none"&&w>=getFixedWidth(e,e.currentStyle.maxWidth)){e.runtimeStyle.width=getFixedWidth(e,e.currentStyle.maxWidth)}else{e.runtimeStyle.width=e.runtimeStyle.fixedWidth}};function fixRight(e){if(register(fixRight,e,/^(fixed|absolute)$/.test(e.currentStyle.position)&&getDefinedStyle(e,"left")!="auto"&&getDefinedStyle(e,"right")!="auto"&&A.test(getDefinedStyle(e,"width")))){resizeRight(e);ie7Layout.boxSizing(e)}};ie7Layout.fixRight=fixRight;function resizeRight(e){var l=getPixelWidth(e,e.runtimeStyle._4||e.currentStyle.left);var w=layoutWidth(e)-getPixelWidth(e,e.currentStyle.right)-l-getMarginWidth(e);if(parseInt(e.runtimeStyle.width)==w)return;e.runtimeStyle.width="";if(isFixed(e)||H||e.offsetWidth<w){if(!quirksMode)w-=getBorderWidth(e)+getPaddingWidth(e);if(w<0)w=0;e.runtimeStyle.fixedWidth=w;setOverrideStyle(e,"width",w)}};var _2=0;addResize(function(){var i,w=(_2<viewport.clientWidth);_2=viewport.clientWidth;for(i in minWidth.elements){var e=minWidth.elements[i];var f=(parseInt(e.runtimeStyle.width)==getFixedWidth(e,e.currentStyle.minWidth));if(w&&f)e.runtimeStyle.width="";if(w==f)resizeWidth(e)}for(i in maxWidth.elements){var e=maxWidth.elements[i];var f=(parseInt(e.runtimeStyle.width)==getFixedWidth(e,e.currentStyle.maxWidth));if(!w&&f)e.runtimeStyle.width="";if(w!=f)resizeWidth(e)}for(i in fixRight.elements)resizeRight(fixRight.elements[i])});if(window.IE7_BOX_MODEL!==false){ie7CSS.addRecalc("width",N,quirksMode?applyWidth:_1)}ie7CSS.addRecalc("min-width",N,minWidth);ie7CSS.addRecalc("max-width",N,maxWidth);ie7CSS.addRecalc("right",N,fixRight)};ie7CSS.addRecalc("border-spacing",N,function(e){if(e.currentStyle.borderCollapse!="collapse"){e.cellSpacing=getPixelValue(e,e.currentStyle["border-spacing"])}});ie7CSS.addRecalc("box-sizing","content-box",this.boxSizing);ie7CSS.addRecalc("box-sizing","border-box",borderBox);var _0=new ParseMaster;_0.add(/Width/,"Height");_0.add(/width/,"height");_0.add(/Left/,"Top");_0.add(/left/,"top");_0.add(/Right/,"Bottom");_0.add(/right/,"bottom");eval(_0.exec(String(fixWidth)));fixWidth();fixHeight(true)}); diff --git a/javascript/fixes/ie7/ie7-load.htc b/javascript/fixes/ie7/ie7-load.htc index a6f1e7f..3a0c663 100644 --- a/javascript/fixes/ie7/ie7-load.htc +++ b/javascript/fixes/ie7/ie7-load.htc @@ -1 +1 @@ -<component lightweight="true"><attach event="ondocumentready" onevent="IE7.init()"/></component>
+<component lightweight="true"><attach event="ondocumentready" onevent="IE7.init()"/></component> diff --git a/javascript/fixes/ie7/ie7-object.htc b/javascript/fixes/ie7/ie7-object.htc index 392409e..93e5a5d 100644 --- a/javascript/fixes/ie7/ie7-object.htc +++ b/javascript/fixes/ie7/ie7-object.htc @@ -1,12 +1,12 @@ -<html>
-<!--
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
--->
-<head>
-<style type="text/css">body{margin:0}</style>
-<script type="text/javascript">public_description=new function(){var l=false;this.ie7_anon=true;this.load=function(o,c,u){if(l)return;l=true;function _0(t,p){t.style[p]=o.currentStyle[p]};var p=o;while(p&&p.currentStyle.backgroundColor=="transparent"){p=p.parentElement}if(p)body.style.backgroundColor=p.currentStyle.backgroundColor;_0(body,"backgroundImage");_0(body,"backgroundRepeat");_0(body,"backgroundPositionX");_0(body,"backgroundPositionY");_0(body,"fontFamily");_0(body,"fontSize");_0(wrapper,"paddingTop");_0(wrapper,"paddingRight");_0(wrapper,"paddingBottom");_0(wrapper,"paddingLeft");image.width=o.clientWidth;image.height=o.clientHeight;var B64=/^data:.*;base64/i,P=/.png$/i;if(B64.test(u))u="ie7-base64.php"+"?"+u.slice(5);if(P.test(u)&&!/MSIE 5.0/.test(navigator.userAgent)){image.src="blank.gif";image.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+u+"',sizingMethod='scale')"}else{image.src=u}o.style.width=body.scrollWidth;o.style.height=body.scrollHeight}};</script>
-</head>
-<body id="body"><div id="wrapper"><img id="image"></div></body>
-</html>
+<html> +<!-- + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +--> +<head> +<style type="text/css">body{margin:0}</style> +<script type="text/javascript">public_description=new function(){var l=false;this.ie7_anon=true;this.load=function(o,c,u){if(l)return;l=true;function _0(t,p){t.style[p]=o.currentStyle[p]};var p=o;while(p&&p.currentStyle.backgroundColor=="transparent"){p=p.parentElement}if(p)body.style.backgroundColor=p.currentStyle.backgroundColor;_0(body,"backgroundImage");_0(body,"backgroundRepeat");_0(body,"backgroundPositionX");_0(body,"backgroundPositionY");_0(body,"fontFamily");_0(body,"fontSize");_0(wrapper,"paddingTop");_0(wrapper,"paddingRight");_0(wrapper,"paddingBottom");_0(wrapper,"paddingLeft");image.width=o.clientWidth;image.height=o.clientHeight;var B64=/^data:.*;base64/i,P=/.png$/i;if(B64.test(u))u="ie7-base64.php"+"?"+u.slice(5);if(P.test(u)&&!/MSIE 5.0/.test(navigator.userAgent)){image.src="blank.gif";image.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+u+"',sizingMethod='scale')"}else{image.src=u}o.style.width=body.scrollWidth;o.style.height=body.scrollHeight}};</script> +</head> +<body id="body"><div id="wrapper"><img id="image"></div></body> +</html> diff --git a/javascript/fixes/ie7/ie7-overflow.js b/javascript/fixes/ie7/ie7-overflow.js index ad2e030..18eb832 100644 --- a/javascript/fixes/ie7/ie7-overflow.js +++ b/javascript/fixes/ie7/ie7-overflow.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-overflow",function(){var S={backgroundColor:"transparent",backgroundImage:"none",backgroundPositionX:null,backgroundPositionY:null,backgroundRepeat:null,borderTopWidth:0,borderRightWidth:0,borderBottomWidth:0,borderLeftStyle:"none",borderTopStyle:"none",borderRightStyle:"none",borderBottomStyle:"none",borderLeftWidth:0,height:null,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,width:"100%"};function _3(p,s,t){t.style[p]=s.currentStyle[p];if(S[p]!=null){s.runtimeStyle[p]=S[p]}};ie7CSS.addRecalc("overflow","visible",function(e){if(e.parentNode.ie7_wrapper)return;if(ie7Layout&&e.currentStyle["max-height"]!="auto"){ie7Layout.maxHeight(e)}if(e.currentStyle.marginLeft=="auto")e.style.marginLeft=0;if(e.currentStyle.marginRight=="auto")e.style.marginRight=0;var w=document.createElement(ANON);w.ie7_wrapper=true;for(var p in S)_3(p,e,w);w.style.display="block";w.style.position="relative";e.runtimeStyle.position="absolute";e.parentNode.insertBefore(w,e);w.appendChild(e)});cssQuery.addModule("ie7-overflow",function(){function _0(e){return(e&&e.ie7_wrapper)?e.firstChild:e};var _2=previousElementSibling;previousElementSibling=function(e){return _0(_2(e))};var _1=nextElementSibling;nextElementSibling=function(e){return _0(_1(e))};selectors[" "]=function(r,f,t,n){var e,i,j;for(i=0;i<f.length;i++){var s=getElementsByTagName(f[i],t,n);for(j=0;(e=_0(s[j]));j++){if(thisElement(e)&&(!n||compareNamespace(e,n)))r.push(e)}}};selectors[">"]=function(r,f,t,n){var e,i,j;for(i=0;i<f.length;i++){var s=childElements(f[i]);for(j=0;(e=_0(s[j]));j++){if(compareTagName(e,t,n))r.push(e)}}}})});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-overflow",function(){var S={backgroundColor:"transparent",backgroundImage:"none",backgroundPositionX:null,backgroundPositionY:null,backgroundRepeat:null,borderTopWidth:0,borderRightWidth:0,borderBottomWidth:0,borderLeftStyle:"none",borderTopStyle:"none",borderRightStyle:"none",borderBottomStyle:"none",borderLeftWidth:0,height:null,marginTop:0,marginBottom:0,marginRight:0,marginLeft:0,width:"100%"};function _3(p,s,t){t.style[p]=s.currentStyle[p];if(S[p]!=null){s.runtimeStyle[p]=S[p]}};ie7CSS.addRecalc("overflow","visible",function(e){if(e.parentNode.ie7_wrapper)return;if(ie7Layout&&e.currentStyle["max-height"]!="auto"){ie7Layout.maxHeight(e)}if(e.currentStyle.marginLeft=="auto")e.style.marginLeft=0;if(e.currentStyle.marginRight=="auto")e.style.marginRight=0;var w=document.createElement(ANON);w.ie7_wrapper=true;for(var p in S)_3(p,e,w);w.style.display="block";w.style.position="relative";e.runtimeStyle.position="absolute";e.parentNode.insertBefore(w,e);w.appendChild(e)});cssQuery.addModule("ie7-overflow",function(){function _0(e){return(e&&e.ie7_wrapper)?e.firstChild:e};var _2=previousElementSibling;previousElementSibling=function(e){return _0(_2(e))};var _1=nextElementSibling;nextElementSibling=function(e){return _0(_1(e))};selectors[" "]=function(r,f,t,n){var e,i,j;for(i=0;i<f.length;i++){var s=getElementsByTagName(f[i],t,n);for(j=0;(e=_0(s[j]));j++){if(thisElement(e)&&(!n||compareNamespace(e,n)))r.push(e)}}};selectors[">"]=function(r,f,t,n){var e,i,j;for(i=0;i<f.length;i++){var s=childElements(f[i]);for(j=0;(e=_0(s[j]));j++){if(compareTagName(e,t,n))r.push(e)}}}})}); diff --git a/javascript/fixes/ie7/ie7-quirks.js b/javascript/fixes/ie7/ie7-quirks.js index a1314dd..0ccfc46 100644 --- a/javascript/fixes/ie7/ie7-quirks.js +++ b/javascript/fixes/ie7/ie7-quirks.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-quirks",function(){if(quirksMode){var F="xx-small,x-small,small,medium,large,x-large,xx-large".split(",");for(var i=0;i<F.length;i++){F[F[i]]=F[i-1]||"0.67em"}ie7CSS.addFix(new RegExp("(font(-size)?\\s*:\\s*)([\\w\\-\\.]+)"),function(m,o){return m[o+1]+(F[m[o+3]]||m[o+3])});if(appVersion<6){var N=/^\-/,L=/(em|ex)$/i;var EM=/em$/i,EX=/ex$/i;function _2(e){var s=1;_0.style.fontFamily=e.currentStyle.fontFamily;_0.style.lineHeight=e.currentStyle.lineHeight;while(e!=body){var f=e.currentStyle["ie7-font-size"];if(f){if(EM.test(f))s*=parseFloat(f);else if(PERCENT.test(f))s*=(parseFloat(f)/100);else if(EX.test(f))s*=(parseFloat(f)/2);else{_0.style.fontSize=f;return 1}}e=e.parentElement}return s};var _0=createTempElement();getPixelValue=function(e,v){if(PIXEL.test(v||0))return parseInt(v||0);var scale=N.test(v)?-1:1;if(L.test(v))scale*=_2(e);_0.style.width=(scale<0)?v.slice(1):v;body.appendChild(_0);v=scale*_0.offsetWidth;_0.removeNode();return parseInt(v)};HEADER=HEADER.replace(/(font(-size)?\s*:\s*([^\s;}\/]*))/gi,"ie7-font-size:$3;$1");ie7CSS.addFix(/cursor\s*:\s*pointer/,"cursor:hand");ie7CSS.addFix(/display\s*:\s*list-item/,"display:block")}function getPaddingWidth(e){return getPixelValue(e,e.currentStyle.paddingLeft)+getPixelValue(e,e.currentStyle.paddingRight)};function _1(e){if(appVersion<5.5&&ie7Layout)ie7Layout.boxSizing(e.parentElement);var p=e.parentElement;var m=p.offsetWidth-e.offsetWidth-getPaddingWidth(p);var a=(e.currentStyle["ie7-margin"]&&e.currentStyle.marginRight=="auto")||e.currentStyle["ie7-margin-right"]=="auto";switch(p.currentStyle.textAlign){case"right":m=(a)?parseInt(m/2):0;e.runtimeStyle.marginRight=parseInt(m)+"px";break;case"center":if(a)m=0;default:if(a)m=parseInt(m/2);e.runtimeStyle.marginLeft=parseInt(m)+"px"}};ie7CSS.addRecalc("margin(-left|-right)?","[^};]*auto",function(e){if(register(_1,e,e.parentElement&&e.currentStyle.display=="block"&&e.currentStyle.marginLeft=="auto"&&e.currentStyle.position!="absolute")){_1(e)}});addResize(function(){for(var i in _1.elements){e=_1.elements[i];e.runtimeStyle.marginLeft=e.runtimeStyle.marginRight="";_1(e)}})}});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-quirks",function(){if(quirksMode){var F="xx-small,x-small,small,medium,large,x-large,xx-large".split(",");for(var i=0;i<F.length;i++){F[F[i]]=F[i-1]||"0.67em"}ie7CSS.addFix(new RegExp("(font(-size)?\\s*:\\s*)([\\w\\-\\.]+)"),function(m,o){return m[o+1]+(F[m[o+3]]||m[o+3])});if(appVersion<6){var N=/^\-/,L=/(em|ex)$/i;var EM=/em$/i,EX=/ex$/i;function _2(e){var s=1;_0.style.fontFamily=e.currentStyle.fontFamily;_0.style.lineHeight=e.currentStyle.lineHeight;while(e!=body){var f=e.currentStyle["ie7-font-size"];if(f){if(EM.test(f))s*=parseFloat(f);else if(PERCENT.test(f))s*=(parseFloat(f)/100);else if(EX.test(f))s*=(parseFloat(f)/2);else{_0.style.fontSize=f;return 1}}e=e.parentElement}return s};var _0=createTempElement();getPixelValue=function(e,v){if(PIXEL.test(v||0))return parseInt(v||0);var scale=N.test(v)?-1:1;if(L.test(v))scale*=_2(e);_0.style.width=(scale<0)?v.slice(1):v;body.appendChild(_0);v=scale*_0.offsetWidth;_0.removeNode();return parseInt(v)};HEADER=HEADER.replace(/(font(-size)?\s*:\s*([^\s;}\/]*))/gi,"ie7-font-size:$3;$1");ie7CSS.addFix(/cursor\s*:\s*pointer/,"cursor:hand");ie7CSS.addFix(/display\s*:\s*list-item/,"display:block")}function getPaddingWidth(e){return getPixelValue(e,e.currentStyle.paddingLeft)+getPixelValue(e,e.currentStyle.paddingRight)};function _1(e){if(appVersion<5.5&&ie7Layout)ie7Layout.boxSizing(e.parentElement);var p=e.parentElement;var m=p.offsetWidth-e.offsetWidth-getPaddingWidth(p);var a=(e.currentStyle["ie7-margin"]&&e.currentStyle.marginRight=="auto")||e.currentStyle["ie7-margin-right"]=="auto";switch(p.currentStyle.textAlign){case"right":m=(a)?parseInt(m/2):0;e.runtimeStyle.marginRight=parseInt(m)+"px";break;case"center":if(a)m=0;default:if(a)m=parseInt(m/2);e.runtimeStyle.marginLeft=parseInt(m)+"px"}};ie7CSS.addRecalc("margin(-left|-right)?","[^};]*auto",function(e){if(register(_1,e,e.parentElement&&e.currentStyle.display=="block"&&e.currentStyle.marginLeft=="auto"&&e.currentStyle.position!="absolute")){_1(e)}});addResize(function(){for(var i in _1.elements){e=_1.elements[i];e.runtimeStyle.marginLeft=e.runtimeStyle.marginRight="";_1(e)}})}}); diff --git a/javascript/fixes/ie7/ie7-recalc.js b/javascript/fixes/ie7/ie7-recalc.js index 10cb839..0a8ebfc 100644 --- a/javascript/fixes/ie7/ie7-recalc.js +++ b/javascript/fixes/ie7/ie7-recalc.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-recalc",function(){C=/\sie7_class\d+/g;function _0(e){e.className=e.className.replace(C,"")};function _1(e){e.runtimeStyle.cssText=""};ie7CSS.specialize({elements:{},handlers:[],reset:function(){this.removeEventHandlers();var e=this.elements;for(var i in e)_1(e[i]);this.elements={};if(this.Rule){var e=this.Rule.elements;for(var i in e)_0(e[i]);this.Rule.elements={}}},reload:function(){ie7CSS.rules=[];this.getInlineStyles();this.screen.load();if(this.print)this.print.load();this.refresh();this.trash()},addRecalc:function(p,t,h,r){this.inherit(p,t,function(e){h(e);ie7CSS.elements[e.uniqueID]=e},r)},recalc:function(){this.reset();this.inherit()},addEventHandler:function(e,t,h){e.attachEvent(t,h);this.handlers.push(arguments)},removeEventHandlers:function(){var h;while(h=this.handlers.pop()){removeEventHandler(h[0],h[1],h[2])}},getInlineStyles:function(){var st=document.getElementsByTagName("style"),s;for(var i=st.length-1;(s=st[i]);i--){if(!s.disabled&&!s.ie7){var c=s.c||s.innerHTML;this.styles.push(c);s.c=c}}},trash:function(){var s,i;for(i=0;i<styleSheets.length;i++){s=styleSheets[i];if(!s.ie7&&!s.c){s.c=s.cssText}}this.inherit()},getText:function(s){return s.c||this.inherit(s)}});addEventHandler(window,"onunload",function(){ie7CSS.removeEventHandlers()});if(ie7CSS.Rule){ie7CSS.Rule.elements={};ie7CSS.Rule.prototype.specialize({add:function(e){this.inherit(e);ie7CSS.Rule.elements[e.uniqueID]=e}});ie7CSS.PseudoElement.hash={};ie7CSS.PseudoElement.prototype.specialize({create:function(t){var k=this.selector+":"+t.uniqueID;if(!ie7CSS.PseudoElement.hash[k]){ie7CSS.PseudoElement.hash[k]=true;this.inherit(t)}}})}if(isHTML&&ie7HTML){ie7HTML.specialize({elements:{},addRecalc:function(s,h){this.inherit(s,function(e){if(!ie7HTML.elements[e.uniqueID]){h(e);ie7HTML.elements[e.uniqueID]=e}})}})}document.recalc=function(reload){if(ie7CSS.screen){if(reload)ie7CSS.reload();recalc()}}});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-recalc",function(){C=/\sie7_class\d+/g;function _0(e){e.className=e.className.replace(C,"")};function _1(e){e.runtimeStyle.cssText=""};ie7CSS.specialize({elements:{},handlers:[],reset:function(){this.removeEventHandlers();var e=this.elements;for(var i in e)_1(e[i]);this.elements={};if(this.Rule){var e=this.Rule.elements;for(var i in e)_0(e[i]);this.Rule.elements={}}},reload:function(){ie7CSS.rules=[];this.getInlineStyles();this.screen.load();if(this.print)this.print.load();this.refresh();this.trash()},addRecalc:function(p,t,h,r){this.inherit(p,t,function(e){h(e);ie7CSS.elements[e.uniqueID]=e},r)},recalc:function(){this.reset();this.inherit()},addEventHandler:function(e,t,h){e.attachEvent(t,h);this.handlers.push(arguments)},removeEventHandlers:function(){var h;while(h=this.handlers.pop()){removeEventHandler(h[0],h[1],h[2])}},getInlineStyles:function(){var st=document.getElementsByTagName("style"),s;for(var i=st.length-1;(s=st[i]);i--){if(!s.disabled&&!s.ie7){var c=s.c||s.innerHTML;this.styles.push(c);s.c=c}}},trash:function(){var s,i;for(i=0;i<styleSheets.length;i++){s=styleSheets[i];if(!s.ie7&&!s.c){s.c=s.cssText}}this.inherit()},getText:function(s){return s.c||this.inherit(s)}});addEventHandler(window,"onunload",function(){ie7CSS.removeEventHandlers()});if(ie7CSS.Rule){ie7CSS.Rule.elements={};ie7CSS.Rule.prototype.specialize({add:function(e){this.inherit(e);ie7CSS.Rule.elements[e.uniqueID]=e}});ie7CSS.PseudoElement.hash={};ie7CSS.PseudoElement.prototype.specialize({create:function(t){var k=this.selector+":"+t.uniqueID;if(!ie7CSS.PseudoElement.hash[k]){ie7CSS.PseudoElement.hash[k]=true;this.inherit(t)}}})}if(isHTML&&ie7HTML){ie7HTML.specialize({elements:{},addRecalc:function(s,h){this.inherit(s,function(e){if(!ie7HTML.elements[e.uniqueID]){h(e);ie7HTML.elements[e.uniqueID]=e}})}})}document.recalc=function(reload){if(ie7CSS.screen){if(reload)ie7CSS.reload();recalc()}}}); diff --git a/javascript/fixes/ie7/ie7-server.css b/javascript/fixes/ie7/ie7-server.css index 50ca605..766e204 100644 --- a/javascript/fixes/ie7/ie7-server.css +++ b/javascript/fixes/ie7/ie7-server.css @@ -1,44 +1,44 @@ -body, td, dd {font: 10pt Verdana, Arial, Helvetica, sans-serif; color: black;}
-body {margin: 8px; background: #333;}
-h1 {margin: 0;}
-h1 a:hover {background-color: transparent;}
-h2 {font-size: 1.75em;}
-h3 {font-size: 1.1em;}
-p.footnote {font-family: "Times New Roman", Times, serif; font-style: italic;}
-a:active {color: #ff0000;}
-a:link {color: #0a6cce;}
-a:visited {color: #0a6cce;}
-code, *.code {font-family: monospace; font-size: 100%; font-style: normal; white-space: nowrap;
- padding: 0 1px; background: #f2f3f8; border: #d6d9e9 1px solid;}
-code.box {display: block; padding: 10px; margin: 0.5em 0;}
-ul {list-style-type: square;}
-dd {margin: .2em 0 .5em 1em;}
-dl.library dt {display: list-item; margin-left: 3em; list-style-type: square;}
-dl.library dd {font-style: italic; margin-left: 3em;}
-dt {font-weight: bold;}
-dt.pack {color: brown;}
-a img {border-style: none;}
-hr {height: 1px; color: #000; border-style: solid;}
-hr.short {height: 2px; width: 100px;}
-div.document {background: #eef; padding: 20px 20px 5px 20px; width: 600px; border: 1px solid black;}
-hr {border-bottom-width: 0px;}
-div.header hr {color: #0a6cce; background-color: #0a6cce;}
-div.footer hr {color: #898e79; background-color: #898e79; }
-div.header, div.header a:link, div.header a:visited, h3 a:link, h3 a:visited {text-decoration: none;}
-a:hover {color: #fff; background-color: #0a6cce; text-decoration: none;}
-div.footer a:hover {background-color: transparent; text-decoration: none;}
-div.header .menu {text-align: right;}
-div.content {min-height: 100px;}
-div.footer {font-size: x-small; margin-top: 8px;}
-div.footnote {font-family: "times new roman", times; font-style: italic; margin-top: 10px;}
-#license {margin-top: 5px; font-size: xx-small;}
-table {border-top: 1px solid #000; border-left: 1px solid #000;}
-th {background-color: #fff; text-align: left;}
-th, td {border-right: 1px solid #000; border-bottom: 1px solid #000;}
-th.small {width: 100px;}
-th.medium {width: 200px;}
-th.large {width: 270px;}
-th.x-large {width: 408px;}
-table.fixed {table-layout: fixed;}
-span.comment {color: #666;}
-
+body, td, dd {font: 10pt Verdana, Arial, Helvetica, sans-serif; color: black;} +body {margin: 8px; background: #333;} +h1 {margin: 0;} +h1 a:hover {background-color: transparent;} +h2 {font-size: 1.75em;} +h3 {font-size: 1.1em;} +p.footnote {font-family: "Times New Roman", Times, serif; font-style: italic;} +a:active {color: #ff0000;} +a:link {color: #0a6cce;} +a:visited {color: #0a6cce;} +code, *.code {font-family: monospace; font-size: 100%; font-style: normal; white-space: nowrap; + padding: 0 1px; background: #f2f3f8; border: #d6d9e9 1px solid;} +code.box {display: block; padding: 10px; margin: 0.5em 0;} +ul {list-style-type: square;} +dd {margin: .2em 0 .5em 1em;} +dl.library dt {display: list-item; margin-left: 3em; list-style-type: square;} +dl.library dd {font-style: italic; margin-left: 3em;} +dt {font-weight: bold;} +dt.pack {color: brown;} +a img {border-style: none;} +hr {height: 1px; color: #000; border-style: solid;} +hr.short {height: 2px; width: 100px;} +div.document {background: #eef; padding: 20px 20px 5px 20px; width: 600px; border: 1px solid black;} +hr {border-bottom-width: 0px;} +div.header hr {color: #0a6cce; background-color: #0a6cce;} +div.footer hr {color: #898e79; background-color: #898e79; } +div.header, div.header a:link, div.header a:visited, h3 a:link, h3 a:visited {text-decoration: none;} +a:hover {color: #fff; background-color: #0a6cce; text-decoration: none;} +div.footer a:hover {background-color: transparent; text-decoration: none;} +div.header .menu {text-align: right;} +div.content {min-height: 100px;} +div.footer {font-size: x-small; margin-top: 8px;} +div.footnote {font-family: "times new roman", times; font-style: italic; margin-top: 10px;} +#license {margin-top: 5px; font-size: xx-small;} +table {border-top: 1px solid #000; border-left: 1px solid #000;} +th {background-color: #fff; text-align: left;} +th, td {border-right: 1px solid #000; border-bottom: 1px solid #000;} +th.small {width: 100px;} +th.medium {width: 200px;} +th.large {width: 270px;} +th.x-large {width: 408px;} +table.fixed {table-layout: fixed;} +span.comment {color: #666;} + diff --git a/javascript/fixes/ie7/ie7-squish.js b/javascript/fixes/ie7/ie7-squish.js index e5a1972..0b445b1 100644 --- a/javascript/fixes/ie7/ie7-squish.js +++ b/javascript/fixes/ie7/ie7-squish.js @@ -1,45 +1,45 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-IE7.addModule("ie7-squish", function() {
-
-/* ---------------------------------------------------------------------
-
- Squish some IE bugs!
-
- Some of these bug fixes may have adverse effects so they are
- not included in the standard library. Add your own if you want.
-
- -dean
-
---------------------------------------------------------------------- */
-
-// @NOTE: ie7Layout.boxSizing is the same as the "Holly Hack"
-
-// "doubled margin" bug
-// http://www.positioniseverything.net/explorer/doubled-margin.html
-ie7CSS.addFix(/float\s*:\s*(left|right)/, "display:inline;$1");
-
-if (ie7Layout) {
- // "peekaboo" bug
- // http://www.positioniseverything.net/explorer/peekaboo.html
- if (appVersion >= 6) ie7CSS.addRecalc("float", "left|right", function($element) {
- ie7Layout.boxSizing($element.parentElement);
- // "doubled margin" bug
- $element.runtimeStyle.display = "inline";
- });
-
- // "unscrollable content" bug
- // http://www.positioniseverything.net/explorer/unscrollable.html
- ie7CSS.addRecalc("position", "absolute|fixed", function($element) {
- if ($element.offsetParent && $element.offsetParent.currentStyle.position == "relative")
- ie7Layout.boxSizing($element.offsetParent);
- });
-}
-
-//# // get rid of Microsoft's pesky image toolbar
-//# if (!complete) document.write('<meta http-equiv="imagetoolbar" content="no">');
-
-});
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +IE7.addModule("ie7-squish", function() { + +/* --------------------------------------------------------------------- + + Squish some IE bugs! + + Some of these bug fixes may have adverse effects so they are + not included in the standard library. Add your own if you want. + + -dean + +--------------------------------------------------------------------- */ + +// @NOTE: ie7Layout.boxSizing is the same as the "Holly Hack" + +// "doubled margin" bug +// http://www.positioniseverything.net/explorer/doubled-margin.html +ie7CSS.addFix(/float\s*:\s*(left|right)/, "display:inline;$1"); + +if (ie7Layout) { + // "peekaboo" bug + // http://www.positioniseverything.net/explorer/peekaboo.html + if (appVersion >= 6) ie7CSS.addRecalc("float", "left|right", function($element) { + ie7Layout.boxSizing($element.parentElement); + // "doubled margin" bug + $element.runtimeStyle.display = "inline"; + }); + + // "unscrollable content" bug + // http://www.positioniseverything.net/explorer/unscrollable.html + ie7CSS.addRecalc("position", "absolute|fixed", function($element) { + if ($element.offsetParent && $element.offsetParent.currentStyle.position == "relative") + ie7Layout.boxSizing($element.offsetParent); + }); +} + +//# // get rid of Microsoft's pesky image toolbar +//# if (!complete) document.write('<meta http-equiv="imagetoolbar" content="no">'); + +}); diff --git a/javascript/fixes/ie7/ie7-xml-extras.js b/javascript/fixes/ie7/ie7-xml-extras.js index 97846f6..a1ad72f 100644 --- a/javascript/fixes/ie7/ie7-xml-extras.js +++ b/javascript/fixes/ie7/ie7-xml-extras.js @@ -1,6 +1,6 @@ -/*
- IE7, version 0.9 (alpha) (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-function XMLHttpRequest(){var l=(ScriptEngineMajorVersion()>=5)?"Msxml2":"Microsoft";return new ActiveXObject(l+".XMLHTTP")};function DOMParser(){};DOMParser.prototype={toString:function(){return"[object DOMParser]"},parseFromString:function(s,c){var x=new ActiveXObject("Microsoft.XMLDOM");x.loadXML(s);return x},parseFromStream:new Function,baseURI:""};function XMLSerializer(){};XMLSerializer.prototype={toString:function(){return"[object XMLSerializer]"},serializeToString:function(r){return r.xml||r.outerHTML},serializeToStream:new Function};
+/* + IE7, version 0.9 (alpha) (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +function XMLHttpRequest(){var l=(ScriptEngineMajorVersion()>=5)?"Msxml2":"Microsoft";return new ActiveXObject(l+".XMLHTTP")};function DOMParser(){};DOMParser.prototype={toString:function(){return"[object DOMParser]"},parseFromString:function(s,c){var x=new ActiveXObject("Microsoft.XMLDOM");x.loadXML(s);return x},parseFromStream:new Function,baseURI:""};function XMLSerializer(){};XMLSerializer.prototype={toString:function(){return"[object XMLSerializer]"},serializeToString:function(r){return r.xml||r.outerHTML},serializeToStream:new Function}; diff --git a/javascript/fixes/ie7/test.html b/javascript/fixes/ie7/test.html index ab78f46..89fe385 100644 --- a/javascript/fixes/ie7/test.html +++ b/javascript/fixes/ie7/test.html @@ -1,100 +1,100 @@ <html xmlns:html="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head>
-<title>IE7 Test Page</title>
-<meta name="author" content="Dean Edwards"/>
-<!-- compliance patch for microsoft browsers -->
-<!--[if lt IE 7]>
-<script src="ie7-standard-p.js" type="text/javascript"></script>
-<script src="ie7-css3-selectors.js" type="text/javascript"></script>
-<script src="ie7-css-strict.js" type="text/javascript"></script>
-<![endif]-->
-<style type="text/css">
- body {background-color: #ccc;}
- img {border: none;}
- h1 {font-family: monospace;}
- h2 {background-color: black; color: white; font-style: normal;}
- h3 {margin: 0.1em 0;}
-</style>
-</head>
+<head> +<title>IE7 Test Page</title> +<meta name="author" content="Dean Edwards"/> +<!-- compliance patch for microsoft browsers --> +<!--[if lt IE 7]> +<script src="ie7-standard-p.js" type="text/javascript"></script> +<script src="ie7-css3-selectors.js" type="text/javascript"></script> +<script src="ie7-css-strict.js" type="text/javascript"></script> +<![endif]--> +<style type="text/css"> + body {background-color: #ccc;} + img {border: none;} + h1 {font-family: monospace;} + h2 {background-color: black; color: white; font-style: normal;} + h3 {margin: 0.1em 0;} +</style> +</head> -<body>
-<div class="document">
-<div class="header">
-<h1>IE7 { css2: auto; }</h1>
-<hr />
-</div>
-
-<div class="content">
-
-<h2>Black & White Test</h2>
-
-<h3>Legend</h3>
-<style type="text/css">
- div.legend {height: 20px; font-weight: bold; text-indent: 4px;}
- #fail {background-color: black; color: white;}
- #pass {background-color: white; color: black;}
-</style>
-<div class="legend" id="pass">PASS</div>
-<div class="legend" id="fail">FAIL</div>
-
-<hr />
-
-<h3>ie7-html4.js</h3>
-<style type="text/css">
- #ie7-html4 {background-color: black; height: 20px;}
- #ie7-html4 abbr {display: block; background-color: white; height: 20px;}
-</style>
-<div id="ie7-html4"><abbr> </abbr></div>
-
-<h3>ie7-layout.js</h3>
-<style type="text/css">
- #ie7-layout {background-color: black; height: 20px; overflow: hidden;}
- #ie7-layout div.box {position: relative; top: -40px; background-color: white;
- height: 40px; border-top: 20px black solid;}
-</style>
-<div id="ie7-layout"><div class="box"></div></div>
-
-<h3>ie7-graphics.js</h3>
-<style type="text/css">
- #ie7-graphics {background-color: white; height: 20px;}
- #ie7-graphics div.box {height: 20px; background: url(test-trans.png);}
-</style>
-<div id="ie7-graphics"><div class="box"></div></div>
-
-<h3>ie7-fixed.js</h3>
-<style type="text/css">
- #ie7-fixed {background-color: white; height: 20px;}
- #ie7-fixed div.box {position: fixed; top: -20px; background-color: black; height: 20px;}
-</style>
-<div id="ie7-fixed"><div class="box"></div></div>
-
-<h3>ie7-css2-selectors.js</h3>
-<style type="text/css">
- #ie7-css2-selectors {background-color: black; height: 20px;}
- #ie7-css2-selectors > span {display: block; background-color: white; height: 20px;}
-</style>
-<div id="ie7-css2-selectors"><span> </span></div>
-
-<h3>ie7-css3-selectors.js</h3>
-<style type="text/css">
- #ie7-css3-selectors {background-color: black; height: 20px;}
- #ie7-css3-selectors:empty {background-color: white;}
-</style>
-<div id="ie7-css3-selectors"></div>
-
-<h3>ie7-css-strict.js</h3>
-<style type="text/css">
- #ie7-css-strict {background-color: black; height: 20px;}
- #ie7-css-strict > span.strict {display: block; background-color: white; height: 20px;}
- #ie7-css-strict > span {display: block; background-color: black}
-</style>
-<div id="ie7-css-strict"><span class="strict"></span></div>
-</div>
-
-<div class="footer">
-<hr />
-<a href="http://dean.edwards.name/IE7/"><img src="ie7.gif" width="80" height="15" alt="IE7 Enhanced"/></a>
-</div>
-</div>
+<body> +<div class="document"> +<div class="header"> +<h1>IE7 { css2: auto; }</h1> +<hr /> +</div> + +<div class="content"> + +<h2>Black & White Test</h2> + +<h3>Legend</h3> +<style type="text/css"> + div.legend {height: 20px; font-weight: bold; text-indent: 4px;} + #fail {background-color: black; color: white;} + #pass {background-color: white; color: black;} +</style> +<div class="legend" id="pass">PASS</div> +<div class="legend" id="fail">FAIL</div> + +<hr /> + +<h3>ie7-html4.js</h3> +<style type="text/css"> + #ie7-html4 {background-color: black; height: 20px;} + #ie7-html4 abbr {display: block; background-color: white; height: 20px;} +</style> +<div id="ie7-html4"><abbr> </abbr></div> + +<h3>ie7-layout.js</h3> +<style type="text/css"> + #ie7-layout {background-color: black; height: 20px; overflow: hidden;} + #ie7-layout div.box {position: relative; top: -40px; background-color: white; + height: 40px; border-top: 20px black solid;} +</style> +<div id="ie7-layout"><div class="box"></div></div> + +<h3>ie7-graphics.js</h3> +<style type="text/css"> + #ie7-graphics {background-color: white; height: 20px;} + #ie7-graphics div.box {height: 20px; background: url(test-trans.png);} +</style> +<div id="ie7-graphics"><div class="box"></div></div> + +<h3>ie7-fixed.js</h3> +<style type="text/css"> + #ie7-fixed {background-color: white; height: 20px;} + #ie7-fixed div.box {position: fixed; top: -20px; background-color: black; height: 20px;} +</style> +<div id="ie7-fixed"><div class="box"></div></div> + +<h3>ie7-css2-selectors.js</h3> +<style type="text/css"> + #ie7-css2-selectors {background-color: black; height: 20px;} + #ie7-css2-selectors > span {display: block; background-color: white; height: 20px;} +</style> +<div id="ie7-css2-selectors"><span> </span></div> + +<h3>ie7-css3-selectors.js</h3> +<style type="text/css"> + #ie7-css3-selectors {background-color: black; height: 20px;} + #ie7-css3-selectors:empty {background-color: white;} +</style> +<div id="ie7-css3-selectors"></div> + +<h3>ie7-css-strict.js</h3> +<style type="text/css"> + #ie7-css-strict {background-color: black; height: 20px;} + #ie7-css-strict > span.strict {display: block; background-color: white; height: 20px;} + #ie7-css-strict > span {display: block; background-color: black} +</style> +<div id="ie7-css-strict"><span class="strict"></span></div> +</div> + +<div class="footer"> +<hr /> +<a href="http://dean.edwards.name/IE7/"><img src="ie7.gif" width="80" height="15" alt="IE7 Enhanced"/></a> +</div> +</div> </body> </html> diff --git a/javascript/jscompressor.php b/javascript/jscompressor.php index d01ce39..1b040f4 100644 --- a/javascript/jscompressor.php +++ b/javascript/jscompressor.php @@ -1,36 +1,36 @@ -<?php
-/**
- * $Header: /cvsroot/bitweaver/_bit_util/javascript/jscompressor.php,v 1.2 2006/01/10 21:18:17 squareing Exp $
- * adapted from tinyMCE gzipper
- */
-
-// initial setup
-require_once( "../../bit_setup_inc.php" );
-
-// General options
-$expiresOffset = 3600 * 24 * 10; // 10 days util client cache expires
-$jsfile = ( !empty( $_REQUEST['jsfile'] ) ? UTIL_PKG_PATH."javascript/".$_REQUEST['jsfile'] : ( !empty( $_REQUEST['jspath'] ) ? $_REQUEST['jspath'] : NULL ) );
-
-// Only gzip the contents if clients and server support it
-$encodings = array();
-if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
- $encodings = explode(',', strtolower( $_SERVER['HTTP_ACCEPT_ENCODING'] ) );
-}
-
-// Check for gzip header or norton internet securities
-if( ( in_array( 'gzip', $encodings ) || isset( $_SERVER['---------------'] ) ) && function_exists( 'ob_gzhandler' ) && !ini_get( 'zlib.output_compression' ) ) {
- ob_start( "ob_gzhandler" );
-}
-
-// Output rest of headers
-header( "Content-type: text/javascript; charset: UTF-8" );
-// header("Cache-Control: must-revalidate");
-header( "Vary: Accept-Encoding" ); // Handle proxies
-header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" );
-
-// get the file contents
-if( !empty( $jsfile ) && is_readable( $jsfile ) ) {
- echo file_get_contents( $jsfile );
-}
-while( @ob_end_flush() );
-?>
+<?php +/** + * $Header: /cvsroot/bitweaver/_bit_util/javascript/jscompressor.php,v 1.3 2006/03/22 10:24:38 squareing Exp $ + * adapted from tinyMCE gzipper + */ + +// initial setup +require_once( "../../bit_setup_inc.php" ); + +// General options +$expiresOffset = 3600 * 24 * 10; // 10 days util client cache expires +$jsfile = ( !empty( $_REQUEST['jsfile'] ) ? UTIL_PKG_PATH."javascript/".$_REQUEST['jsfile'] : ( !empty( $_REQUEST['jspath'] ) ? $_REQUEST['jspath'] : NULL ) ); + +// Only gzip the contents if clients and server support it +$encodings = array(); +if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { + $encodings = explode(',', strtolower( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ); +} + +// Check for gzip header or norton internet securities +if( ( in_array( 'gzip', $encodings ) || isset( $_SERVER['---------------'] ) ) && function_exists( 'ob_gzhandler' ) && !ini_get( 'zlib.output_compression' ) ) { + ob_start( "ob_gzhandler" ); +} + +// Output rest of headers +header( "Content-type: text/javascript; charset: UTF-8" ); +// header("Cache-Control: must-revalidate"); +header( "Vary: Accept-Encoding" ); // Handle proxies +header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" ); + +// get the file contents +if( !empty( $jsfile ) && is_readable( $jsfile ) ) { + echo file_get_contents( $jsfile ); +} +while( @ob_end_flush() ); +?> diff --git a/javascript/libs/fat.js b/javascript/libs/fat.js index fafd937..e0e5e84 100644 --- a/javascript/libs/fat.js +++ b/javascript/libs/fat.js @@ -1,2 +1,2 @@ -eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('4 v={G:q(r,g,b){r=r.C(16);8(r.p==1)r=\'0\'+r;g=g.C(16);8(g.p==1)g=\'0\'+g;b=b.C(16);8(b.p==1)b=\'0\'+b;V"#"+r+g+b},1h:q(){4 a=F.1d("*");1e(4 i=0;i<a.p;i++){4 o=a[i];4 r=/Z-?(\\w{3,6})?/.12(o.14);8(r){8(!r[1])r[1]="";8(o.k)v.I(o.k,A,A,"#"+r[1])}}},I:q(k,u,t,j,e){8(!u)u=13;8(!t)t=1a;8(!j||j=="#")j="#18";8(!e)e=D.J(k);4 9=x.17(u*(t/15));4 B=t/ 9; 4 y = B; 4 f = 0; 8 (j.p < 7) j += j.m(1,3); 8 (e.p < 7) e += e.m(1,3); 4 K = l(j.m(1,2),16); 4 O = l(j.m(3,2),16); 4 H = l(j.m(5,2),16); 4 M = l(e.m(1,2),16); 4 N = l(e.m(3,2),16); 4 L = l(e.m(5,2),16); 4 r,g,b,h; R (f < 9) { r = x.E(K * ((9-f)/9)+M*(f/9));g=x.E(O*((9-f)/9)+N*(f/9));b=x.E(H*((9-f)/9)+L*(f/9));h=D.G(r,g,b);P("v.z(\'"+k+"\',\'"+h+"\')",y);f++;y=B*f}P("v.z(\'"+k+"\',\'"+e+"\')",y)},z:q(k,c){4 o=F.S(k);o.10.U=c},J:q(k){4 o=F.S(k);R(o){4 c;8(W.X)c=W.X(o,A).1c("Y-1g");8(o.Q)c=o.Q.U;8((c!=""&&c!="T")||o.1i=="1j"){1k}o=o.1f}8(c==1b||c==""||c=="T")c="#19";4 n=c.11(/n\\s*\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)/);8(n)c=D.G(l(n[1]),l(n[2]),l(n[3]));V c}}',62,83,'||||var||||if|frames|||||to|frame||||from|id|parseInt|substr|rgb||length|function|||duration|fps|Fat||Math|delay|set_bgcolor|null|interval|toString|this|floor|document|make_hex|bf|fade_element|get_bgcolor|rf|bt|rt|gt|gf|setTimeout|currentStyle|while|getElementById|transparent|backgroundColor|return|window|getComputedStyle|background|fade|style|match|exec|30|className|1000||round|FFFF33|FFFFFF|3000|undefined|getPropertyValue|getElementsByTagName|for|parentNode|color|fade_all|tagName|BODY|break'.split('|'),0,{}))
-window.onload = function () { Fat.fade_all(); }
+eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('4 v={G:q(r,g,b){r=r.C(16);8(r.p==1)r=\'0\'+r;g=g.C(16);8(g.p==1)g=\'0\'+g;b=b.C(16);8(b.p==1)b=\'0\'+b;V"#"+r+g+b},1h:q(){4 a=F.1d("*");1e(4 i=0;i<a.p;i++){4 o=a[i];4 r=/Z-?(\\w{3,6})?/.12(o.14);8(r){8(!r[1])r[1]="";8(o.k)v.I(o.k,A,A,"#"+r[1])}}},I:q(k,u,t,j,e){8(!u)u=13;8(!t)t=1a;8(!j||j=="#")j="#18";8(!e)e=D.J(k);4 9=x.17(u*(t/15));4 B=t/ 9; 4 y = B; 4 f = 0; 8 (j.p < 7) j += j.m(1,3); 8 (e.p < 7) e += e.m(1,3); 4 K = l(j.m(1,2),16); 4 O = l(j.m(3,2),16); 4 H = l(j.m(5,2),16); 4 M = l(e.m(1,2),16); 4 N = l(e.m(3,2),16); 4 L = l(e.m(5,2),16); 4 r,g,b,h; R (f < 9) { r = x.E(K * ((9-f)/9)+M*(f/9));g=x.E(O*((9-f)/9)+N*(f/9));b=x.E(H*((9-f)/9)+L*(f/9));h=D.G(r,g,b);P("v.z(\'"+k+"\',\'"+h+"\')",y);f++;y=B*f}P("v.z(\'"+k+"\',\'"+e+"\')",y)},z:q(k,c){4 o=F.S(k);o.10.U=c},J:q(k){4 o=F.S(k);R(o){4 c;8(W.X)c=W.X(o,A).1c("Y-1g");8(o.Q)c=o.Q.U;8((c!=""&&c!="T")||o.1i=="1j"){1k}o=o.1f}8(c==1b||c==""||c=="T")c="#19";4 n=c.11(/n\\s*\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)/);8(n)c=D.G(l(n[1]),l(n[2]),l(n[3]));V c}}',62,83,'||||var||||if|frames|||||to|frame||||from|id|parseInt|substr|rgb||length|function|||duration|fps|Fat||Math|delay|set_bgcolor|null|interval|toString|this|floor|document|make_hex|bf|fade_element|get_bgcolor|rf|bt|rt|gt|gf|setTimeout|currentStyle|while|getElementById|transparent|backgroundColor|return|window|getComputedStyle|background|fade|style|match|exec|30|className|1000||round|FFFF33|FFFFFF|3000|undefined|getPropertyValue|getElementsByTagName|for|parentNode|color|fade_all|tagName|BODY|break'.split('|'),0,{})) +window.onload = function () { Fat.fade_all(); } diff --git a/pclzip_lib.php b/pclzip_lib.php index dfc1059..139877b 100644 --- a/pclzip_lib.php +++ b/pclzip_lib.php @@ -1,4018 +1,4018 @@ -<?php
-// --------------------------------------------------------------------------------
-// PhpConcept Library - Zip Module 2.0
-// --------------------------------------------------------------------------------
-// License GNU/LGPL - Vincent Blavet - September 2003
-// 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.1 2005/06/19 05:21:32 bitweaver Exp $
-// --------------------------------------------------------------------------------
- // ----- Constants
- 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.
- 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
- 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/' );
- define( 'PCLZIP_TEMPORARY_DIR', '' );
-// --------------------------------------------------------------------------------
-// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
-// --------------------------------------------------------------------------------
- // ----- Global variables
- $g_pclzip_version = "2.0";
- // ----- 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_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 );
- // ----- 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 );
- // ----- 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 = '';
- // --------------------------------------------------------------------------------
- // 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");
- // ----- Tests the zlib
- if (!function_exists('gzopen'))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");
- die('Abort '.basename(__FILE__).' : Missing zlib extensions');
- }
- // ----- Set the attributes
- $this->zipname = $p_zipname;
- $this->zip_fd = 0;
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);
- 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_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, $p_add_dir="", $p_remove_dir="")
- function create($p_filelist /*, options */)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");
- $v_result=1;
- // ----- Reset the error handler
- $this->privErrorReset();
- // ----- Set default values
- $v_options = array();
- $v_add_path = "";
- $v_remove_path = "";
- $v_remove_all_path = false;
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
- // ----- Look for variable options arguments
- $v_size = func_num_args();
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
- // ----- 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)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
- // ----- 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' ));
- if ($v_result != 1) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- return 0;
- }
- // ----- Set the arguments
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
- $v_add_path = $v_options[PCLZIP_OPT_ADD_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];
- }
- }
- // ----- Look for 2 args
- // Here we need to support the first historic synopsis of the
- // method.
- else {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
- // ----- Get the first argument
- $v_add_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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return 0;
- }
- }
- }
- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'");
- // ----- Look if the $p_filelist is really an array
- $p_result_list = array();
- if (is_array($p_filelist))
- {
- // ----- Call the create fct
- $v_result = $this->privCreate($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
- }
- // ----- Look if the $p_filelist is a string
- else if (is_string($p_filelist))
- {
- // ----- Create a list with the elements from the string
- $v_list = explode(PCLZIP_SEPARATOR, $p_filelist);
- // ----- Call the create fct
- $v_result = $this->privCreate($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
- }
- // ----- Invalid variable
- else
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
- }
- if ($v_result != 1)
- {
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- return 0;
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
- 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_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, $p_add_dir="", $p_remove_dir="")
- function add($p_filelist /* options */)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");
- $v_result=1;
- // ----- Reset the error handler
- $this->privErrorReset();
- // ----- Set default values
- $v_options = array();
- $v_add_path = "";
- $v_remove_path = "";
- $v_remove_all_path = false;
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
- // ----- Look for variable options arguments
- $v_size = func_num_args();
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
- // ----- 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)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
- // ----- 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' ));
- if ($v_result != 1) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- return 0;
- }
- // ----- Set the arguments
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
- $v_add_path = $v_options[PCLZIP_OPT_ADD_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];
- }
- }
- // ----- Look for 2 args
- // Here we need to support the first historic synopsis of the
- // method.
- else {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
- // ----- Get the first argument
- $v_add_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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return 0;
- }
- }
- }
- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'");
- // ----- Look if the $p_filelist is really an array
- $p_result_list = array();
- if (is_array($p_filelist))
- {
- // ----- Call the create fct
- $v_result = $this->privAdd($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
- }
- // ----- Look if the $p_filelist is a string
- else if (is_string($p_filelist))
- {
- // ----- Create a list with the elements from the string
- $v_list = explode(PCLZIP_SEPARATOR, $p_filelist);
- // ----- Call the create fct
- $v_result = $this->privAdd($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);
- }
- // ----- Invalid variable
- else
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
- }
- if ($v_result != 1)
- {
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- return 0;
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
- 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 exists 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()
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");
- $v_result=1;
- // ----- Reset the error handler
- $this->privErrorReset();
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- return(0);
- }
- // ----- Call the extracting fct
- $p_list = array();
- if (($v_result = $this->privList($p_list)) != 1)
- {
- unset($p_list);
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
- return(0);
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
- 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($p_path="./", $p_remove_path="")
- function extract(/* options */)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
- $v_result=1;
- // ----- Reset the error handler
- $this->privErrorReset();
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- return(0);
- }
- // ----- Set default values
- $v_options = array();
- $v_path = "./";
- $v_remove_path = "";
- $v_remove_all_path = false;
- // ----- Look for variable options arguments
- $v_size = func_num_args();
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
- // ----- 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)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
- // ----- 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' ));
- if ($v_result != 1) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- 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 {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
- return 0;
- }
- }
- }
- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
- // ----- Call the extracting fct
- $p_list = array();
- if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1)
- {
- unset($p_list);
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
- return(0);
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
- 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 */)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");
- $v_result=1;
- // ----- Reset the error handler
- $this->privErrorReset();
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- return(0);
- }
- // ----- Set default values
- $v_options = array();
- $v_path = "./";
- $v_remove_path = "";
- $v_remove_all_path = false;
- // ----- Look for variable options arguments
- $v_size = func_num_args();
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
- // ----- 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)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
- // ----- 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' ));
- if ($v_result != 1) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- 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;
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");
- }
- else {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");
- }
- }
- // ----- Look for 2 args
- // Here we need to support the first historic synopsis of the
- // method.
- else {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return 0;
- }
- }
- }
- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
- // ----- 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) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- return 0;
- }
- $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
- // ----- Call the extracting fct
- if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
- return(0);
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
- return $p_list;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function :
- // delete([$p_option, $p_option_value, ...])
- // Description :
- // Parameters :
- // None
- // Options :
- // PCLZIP_OPT_BY_INDEX :
- // 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(/* options */)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", "");
- $v_result=1;
- // ----- Reset the error handler
- $this->privErrorReset();
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- return(0);
- }
- // ----- Set default values
- $v_options = array();
- // ----- Look for variable options arguments
- $v_size = func_num_args();
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
- // ----- Look for no arguments
- if ($v_size <= 0) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing arguments");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
- return 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) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- return 0;
- }
- // ----- Check that at least one rule is set
- if ( (!isset($v_options[PCLZIP_OPT_BY_NAME]))
- && (!isset($v_options[PCLZIP_OPT_BY_EREG]))
- && (!isset($v_options[PCLZIP_OPT_BY_PREG]))
- && (!isset($v_options[PCLZIP_OPT_BY_INDEX]))) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "At least one filtering rule must be set");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
- return 0;
- }
- // ----- Call the delete fct
- $v_list = array();
- if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1)
- {
- unset($v_list);
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
- return(0);
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);
- return $v_list;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : deleteByIndex()
- // Description :
- // ***** Deprecated *****
- // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
- // --------------------------------------------------------------------------------
- function deleteByIndex($p_index)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");
- $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
- 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()
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");
- // ----- Reset the error handler
- $this->privErrorReset();
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
- if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);
- return 0;
- }
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- 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';
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");
- $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'))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'");
- // ----- 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))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");
- $v_result = 1;
- // ----- Reset the error handler
- $this->privErrorReset();
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
- 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'))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");
- // ----- 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))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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' );
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");
- $v_result = true;
- // ----- 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."'");
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
- 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."'");
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
- return(false);
- }
- // ----- Check the magic code
- // TBC
- // ----- Check the central header
- // TBC
- // ----- Check each file header
- // TBC
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");
- $v_result=1;
- // ----- Read the options
- $i=0;
- while ($i<$p_size) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");
- // ----- Check if the option is requested
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Get the value
- $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
- $i++;
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
- $i++;
- break;
- // ----- Look for options that request an EREG or PREG expression
- case PCLZIP_OPT_BY_EREG :
- case PCLZIP_OPT_BY_PREG :
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
- $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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Get the value
- $v_work_list = array();
- if (is_string($p_options_list[$i+1])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a 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])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an 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])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array");
- $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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extracted index item = [".$v_result_list[$p_options_list[$i]][$j]['start'].",".$v_result_list[$p_options_list[$i]][$j]['end']."]");
- // ----- Look for list sort
- if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ...");
- $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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "List sorting is not yet write ...");
- }
- // ----- 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 :
- $v_result_list[$p_options_list[$i]] = true;
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Get the value
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
- $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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Get the value
- $v_function_name = $p_options_list[$i+1];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'");
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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 optional parameter '".$p_options_list[$i]."'");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Next options
- $i++;
- }
- // ----- Look for mandatory options
- 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') {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
- // ----- Look if present
- if (!isset($v_result_list[$key])) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- }
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privCreate()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privCreate($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
- $v_result=1;
- $v_list_detail = array();
- // ----- Open the file in write mode
- if (($v_result = $this->privOpenFd('wb')) != 1)
- {
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Add the list of files
- $v_result = $this->privAddList($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);
- // ----- Close
- $this->privCloseFd();
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privAdd()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privAdd($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
- $v_result=1;
- $v_list_detail = array();
- // ----- Look if the archive exists or is empty
- if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it.");
- // ----- Do a create
- $v_result = $this->privCreate($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Open the zip file
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
- if (($v_result=$this->privOpenFd('rb')) != 1)
- {
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- $this->privCloseFd();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Go to beginning of File
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
- @rewind($this->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
- // ----- Creates a temporay file
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
- // ----- Open the temporary file in write mode
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
- if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
- {
- $this->privCloseFd();
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
- $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_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)
- {
- fclose($v_zip_temp_fd);
- $this->privCloseFd();
- @unlink($v_zip_temp_name);
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Store the offset of the central dir
- $v_offset = @ftell($this->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
- // ----- 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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
- $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);
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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 = '';
- // ----- 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);
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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);
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privOpenFd()
- // Description :
- // Parameters :
- // --------------------------------------------------------------------------------
- function privOpenFd($p_mode)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Open the zip file
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode');
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privCloseFd()
- // Description :
- // Parameters :
- // --------------------------------------------------------------------------------
- function privCloseFd()
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", "");
- $v_result=1;
- if ($this->zip_fd != 0)
- @fclose($this->zip_fd);
- $this->zip_fd = 0;
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
- $v_result=1;
- // ----- Add the files
- $v_header_list = array();
- if (($v_result = $this->privAddFileList($p_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)
- {
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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 = '';
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privAddFileList()
- // 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
- // run the lib 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 privAddFileList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
- $v_result=1;
- $v_header = array();
- // ----- Recuperate the current number of elt in list
- $v_nb = sizeof($p_result_list);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have $v_nb elements");
- // ----- Loop on the files
- for ($j=0; ($j<count($p_list)) && ($v_result==1); $j++)
- {
- // ----- Recuperate the filename
- $p_filename = PclZipUtilTranslateWinPath($p_list[$j], false);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file [$p_filename]");
- // ----- Skip empty file names
- if ($p_filename == "")
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");
- continue;
- }
- // ----- Check the filename
- if (!file_exists($p_filename))
- {
- // ----- Error log
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '$p_filename' does not exists");
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '$p_filename' does not exists");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- /* This test is done later
- // ----- Check the path length
- if (strlen($p_filename) > 0xFF)
- {
- // ----- Error log
- PclZip::privErrorLog(-5, "File name is too long (max. 255) : '$p_filename'");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- */
- // ----- Look if it is a file or a dir with no all pathnre move
- if ((is_file($p_filename)) || ((is_dir($p_filename)) && !$p_remove_all_dir)) {
- // ----- Add the file
- if (($v_result = $this->privAddFile($p_filename, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)
- {
- // ----- Return status
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Store the file infos
- $p_result_list[$v_nb++] = $v_header;
- }
- // ----- Look for directory
- if (is_dir($p_filename))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "$p_filename is a directory");
- // ----- Look for path
- if ($p_filename != ".")
- $v_path = $p_filename."/";
- else
- $v_path = "";
- // ----- Read the directory for files and sub-directories
- $p_hdir = opendir($p_filename);
- $p_hitem = readdir($p_hdir); // '.' directory
- $p_hitem = readdir($p_hdir); // '..' directory
- while ($p_hitem = readdir($p_hdir))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for $p_hitem in the directory");
- // ----- Look for a file
- if (is_file($v_path.$p_hitem))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the file '".$v_path.$p_hitem."'");
- // ----- Add the file
- if (($v_result = $this->privAddFile($v_path.$p_hitem, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)
- {
- // ----- Return status
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Store the file infos
- $p_result_list[$v_nb++] = $v_header;
- }
- // ----- Recursive call to privAddFileList()
- else
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the directory '".$v_path.$p_hitem."'");
- // ----- Need an array as parameter
- $p_temp_list[0] = $v_path.$p_hitem;
- $v_result = $this->privAddFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);
- // ----- Update the number of elements of the list
- $v_nb = sizeof($p_result_list);
- }
- }
- // ----- Free memory for the recursive loop
- unset($p_temp_list);
- unset($p_hdir);
- unset($p_hitem);
- }
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have $v_nb elements");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privAddFile()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privAddFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='$p_filename', add_dir='$p_add_dir', remove_dir='$p_remove_dir'");
- $v_result=1;
- if ($p_filename == "")
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- 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, $p_filename);
- if ($v_compare > 0)
-// if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)
- {
- if ($v_compare == 2) {
- $v_stored_filename = "";
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");
- }
- else {
- $v_stored_filename = substr($p_filename, strlen($p_remove_dir));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$p_filename' = '$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;
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");
- }
- // ----- Filename (reduce the path of stored name)
- $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Filename (reduced) '$v_stored_filename', strlen ".strlen($v_stored_filename));
- /* filename length moved after call-back in release 1.3
- // ----- Check the path length
- if (strlen($v_stored_filename) > 0xFF)
- {
- // ----- Error log
- PclZip::privErrorLog(-5, "Stored file name is too long (max. 255) : '$v_stored_filename'");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- */
- // ----- Set the file properties
- clearstatcache();
- $p_header['version'] = 20;
- $p_header['version_extracted'] = 10;
- $p_header['flag'] = 0;
- $p_header['compression'] = 0;
- $p_header['mtime'] = filemtime($p_filename);
- $p_header['crc'] = 0;
- $p_header['compressed_size'] = 0;
- $p_header['size'] = filesize($p_filename);
- $p_header['filename_len'] = strlen($p_filename);
- $p_header['extra_len'] = 0;
- $p_header['comment_len'] = 0;
- $p_header['disk'] = 0;
- $p_header['internal'] = 0;
- $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);
- $p_header['offset'] = 0;
- $p_header['filename'] = $p_filename;
- $p_header['stored_filename'] = $v_stored_filename;
- $p_header['extra'] = '';
- $p_header['comment'] = '';
- $p_header['status'] = 'ok';
- $p_header['index'] = -1;
- // ----- Look for pre-add callback
- if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");
- // ----- 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);');
- 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']);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_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 (is_file($p_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");
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
- // ----- Read the file content
- $v_content_compressed = @fread($v_file, $p_header['size']);
- // ----- Calculate the CRC
- $p_header['crc'] = crc32($v_content_compressed);
- }
- else {
- // ----- Read the file content
- $v_content = @fread($v_file, $p_header['size']);
- // ----- Calculate the CRC
- $p_header['crc'] = crc32($v_content);
- // ----- Compress the file
- $v_content_compressed = gzdeflate($v_content);
- }
- // ----- Set header parameters
- $p_header['compressed_size'] = strlen($v_content_compressed);
- $p_header['compression'] = 8;
- // ----- Call the header generation
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
- @fclose($v_file);
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Write the compressed content
- $v_binary_data = pack('a'.$p_header['compressed_size'], $v_content_compressed);
- @fwrite($this->zip_fd, $v_binary_data, $p_header['compressed_size']);
- // ----- Close the file
- @fclose($v_file);
- }
- // ----- Look for a directory
- else
- {
- // ----- Set the file properties
- $p_header['filename'] .= '/';
- $p_header['filename_len']++;
- $p_header['size'] = 0;
- $p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
- // ----- Call the header generation
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- }
- }
- // ----- Look for pre-add callback
- if (isset($p_options[PCLZIP_CB_POST_ADD])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction");
- // ----- 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);');
- if ($v_result == 0) {
- // ----- Ignored
- $v_result = 1;
- }
- // ----- Update the informations
- // Nothing can be modified
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privWriteFileHeader()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privWriteFileHeader(&$p_header)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
- $v_result=1;
- // TBC
- //for(reset($p_header); $key = key($p_header); next($p_header)) {
- // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);
- //}
- // ----- Store the offset position of the file
- $p_header['offset'] = ftell($this->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']);
- // ----- Transform UNIX mtime to DOS format mdate/mtime
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['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'], $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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privWriteCentralFileHeader()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privWriteCentralFileHeader(&$p_header)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
- $v_result=1;
- // TBC
- //for(reset($p_header); $key = key($p_header); next($p_header)) {
- // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);
- //}
- // ----- Transform UNIX mtime to DOS format mdate/mtime
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privWriteCentralHeader()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privList()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privList(&$p_list)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");
- $v_result=1;
- // ----- Open the zip file
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
- if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Go to beginning of Central Dir
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
- @rewind($this->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
- if (@fseek($this->zip_fd, $v_central_dir['offset']))
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
- // ----- Read each entry
- for ($i=0; $i<$v_central_dir['entries']; $i++)
- {
- // ----- Read the file header
- if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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();
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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.
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privConvertHeader2FileInfo($p_header, &$p_info)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'");
- $v_result=1;
- // ----- Get the interesting attributes
- $p_info['filename'] = $p_header['filename'];
- $p_info['stored_filename'] = $p_header['stored_filename'];
- $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'];
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
- $v_result=1;
- // ----- 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) == "/")
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");
- $p_path = substr($p_path, 0, strlen($p_path)-1);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");
- }
- }
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
- if (($v_result = $this->privOpenFd('rb')) != 1)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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++)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'");
- // ----- Read next Central dir entry
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'");
- @rewind($this->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");
- // ----- Read the file header
- $v_header = array();
- if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
- {
- // ----- Close the zip file
- $this->privCloseFd();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
- // ----- Look if the filename is in the list
- for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
- // ----- Look for a directory
- if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
- // ----- 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])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
- $v_extract = true;
- }
- }
- // ----- Look for a filename
- elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
- $v_extract = true;
- }
- }
- }
- // ----- Look for extract by ereg rule
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
- $v_extract = true;
- }
- }
- // ----- Look for extract by preg rule
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
- $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)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
- // ----- Look if the index is in the list
- for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
- if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
- $v_extract = true;
- }
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
- $j_start = $j+1;
- }
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
- break;
- }
- }
- }
- // ----- Look for no rule, which means extract all the archive
- else {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)");
- $v_extract = true;
- }
- // ----- Look for real extraction
- if ($v_extract)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'");
- // ----- Go to the file position
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
- @rewind($this->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
- if (@fseek($this->zip_fd, $v_header['offset']))
- {
- // ----- Close the zip file
- $this->privCloseFd();
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
- // ----- Look for extraction as string
- if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
- // ----- Extracting the file
- if (($v_result = $this->privExtractFileAsString($v_header, $v_string)) != 1)
- {
- // ----- Close the zip file
- $this->privCloseFd();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- 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();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Set the file content
- $p_file_list[$v_nb_extracted]['content'] = $v_string;
- // ----- Next extracted file
- $v_nb_extracted++;
- }
- else {
- // ----- Extracting the file
- if (($v_result = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options)) != 1)
- {
- // ----- Close the zip file
- $this->privCloseFd();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- 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();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- }
- }
- }
- // ----- Close the zip file
- $this->privCloseFd();
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privExtractFile()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
- $v_result=1;
- // ----- Read the file header
- if (($v_result = $this->privReadFileHeader($v_header)) != 1)
- {
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
- // ----- Check that the file header is coherent with $p_entry info
- // TBC
- // ----- Look for all path to remove
- if ($p_remove_all_path == true) {
- // ----- Get the basename of the path
- $p_entry['filename'] = basename($p_entry['filename']);
- }
- // ----- Look for path to remove
- else if ($p_remove_path != "")
- {
- //if (strcmp($p_remove_path, $p_entry['filename'])==0)
- if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'");
- // ----- Change the file status
- $p_entry['status'] = "filtered";
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- $p_remove_path_size = strlen($p_remove_path);
- if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'");
- // ----- Remove the path
- $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'");
- }
- }
- // ----- Add the path
- if ($p_path != '')
- {
- $p_entry['filename'] = $p_path."/".$p_entry['filename'];
- }
- // ----- Look for pre-extract callback
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
- // ----- 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);');
- if ($v_result == 0) {
- // ----- Change the file status
- $p_entry['status'] = "skipped";
- $v_result = 1;
- }
- // ----- Update the informations
- // Only some fields can be modified
- $p_entry['filename'] = $v_local_header['filename'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
- }
- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
- // ----- 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']))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists");
- // ----- Look if file is a directory
- if (is_dir($p_entry['filename']))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory");
- // ----- Change the file status
- $p_entry['status'] = "already_a_directory";
- // ----- Return
- ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- //return $v_result;
- }
- // ----- Look if file is write protected
- else if (!is_writeable($p_entry['filename']))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected");
- // ----- Change the file status
- $p_entry['status'] = "write_protected";
- // ----- Return
- ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- //return $v_result;
- }
- // ----- Look if the extracted file is older
- else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");
- // ----- Change the file status
- $p_entry['status'] = "newer_exist";
- // ----- Return
- ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- //return $v_result;
- }
- }
- // ----- 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) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'");
- // ----- Change the file status
- $p_entry['status'] = "path_creation_fail";
- // ----- Return
- ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- //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['compressed_size'] == $p_entry['size'])
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
- // ----- Opening destination file
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
- // ----- Change the file status
- $p_entry['status'] = "write_error";
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
- // ----- 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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");
- $v_buffer = fread($this->zip_fd, $v_read_size);
- $v_binary_data = pack('a'.$v_read_size, $v_buffer);
- @fwrite($v_dest_file, $v_binary_data, $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
- {
- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");
- // ----- Opening destination file
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
- // ----- Change the file status
- $p_entry['status'] = "write_error";
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes");
- // ----- 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);
- // ----- 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])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");
- // ----- Change the mode of the file
- chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
- }
- }
- // ----- Look for post-extract callback
- if (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
- // ----- 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);');
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privExtractFileAsString()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privExtractFileAsString(&$p_entry, &$p_string)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'");
- $v_result=1;
- // ----- Read the file header
- $v_header = array();
- if (($v_result = $this->privReadFileHeader($v_header)) != 1)
- {
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
- // ----- Check that the file header is coherent with $p_entry info
- // TBC
- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'");
- // ----- 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'])
- {
- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
- // ----- Reading the file
- $p_string = fread($this->zip_fd, $p_entry['compressed_size']);
- }
- else
- {
- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");
- // ----- Reading the file
- $v_data = fread($this->zip_fd, $p_entry['compressed_size']);
- // ----- Decompress the file
- $p_string = gzinflate($v_data);
- }
- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
- }
- else {
- // TBC : error : can not extract a folder in a string
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privReadFileHeader()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privReadFileHeader(&$p_header)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", "");
- $v_result=1;
- // ----- Read the 4 bytes signature
- $v_binary_data = @fread($this->zip_fd, 4);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
- $v_data = unpack('Vid', $v_binary_data);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
- // ----- Check signature
- if ($v_data['id'] != 0x04034b50)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header");
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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";
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Extract the values
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");
- $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
- // ----- Get filename
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']);
- $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');
- // ----- Get extra_fields
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']);
- if ($v_data['extra_len'] != 0) {
- $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
- }
- else {
- $p_header['extra'] = '';
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\'');
- // ----- Extract properties
- $p_header['compression'] = $v_data['compression'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.bin2hex($p_header['compression']).'\'');
- $p_header['size'] = $v_data['size'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');
- $p_header['compressed_size'] = $v_data['compressed_size'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
- $p_header['crc'] = $v_data['crc'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.$p_header['crc'].'\'');
- $p_header['flag'] = $v_data['flag'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');
- // ----- 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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
- }
- else
- {
- $p_header['mtime'] = time();
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
- }
- // ----- Other informations
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compression type : ".$v_data['compression']);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Version : ".$v_data['version']);
- // TBC
- //for(reset($v_data); $key = key($v_data); next($v_data)) {
- // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]);
- //}
- // ----- Set the stored filename
- $p_header['stored_filename'] = $p_header['filename'];
- // ----- Set the status field
- $p_header['status'] = "ok";
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privReadCentralFileHeader()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privReadCentralFileHeader(&$p_header)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", "");
- $v_result=1;
- // ----- Read the 4 bytes signature
- $v_binary_data = @fread($this->zip_fd, 4);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
- $v_data = unpack('Vid', $v_binary_data);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
- // ----- Check signature
- if ($v_data['id'] != 0x02014b50)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature");
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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";
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Extract the values
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'");
- $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
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']);
- if ($p_header['filename_len'] != 0)
- $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
- else
- $p_header['filename'] = '';
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\'');
- // ----- Get extra
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']);
- if ($p_header['extra_len'] != 0)
- $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
- else
- $p_header['extra'] = '';
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\'');
- // ----- Get comment
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']);
- if ($p_header['comment_len'] != 0)
- $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
- else
- $p_header['comment'] = '';
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\'');
- // ----- Extract properties
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.$p_header['crc'].'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\'');
- // ----- Recuperate date in UNIX format
- 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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
- }
- else
- {
- $p_header['mtime'] = time();
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
- }
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')');
- if (substr($p_header['filename'], -1) == '/')
- {
- $p_header['external'] = 0x41FF0010;
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.$p_header['external'].'\'');
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\'');
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privReadEndCentralDir()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privReadEndCentralDir(&$p_central_dir)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", "");
- $v_result=1;
- // ----- Go to the end of the zip file
- $v_size = filesize($this->zipname);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size");
- @fseek($this->zip_fd, $v_size);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\'');
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');
- @fseek($this->zip_fd, $v_size-22);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\'');
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Read for bytes
- $v_binary_data = @fread($this->zip_fd, 4);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
- $v_data = unpack('Vid', $v_binary_data);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
- // ----- Check signature
- if ($v_data['id'] == 0x06054b50) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position.");
- $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) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir');
- $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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');
- // ----- 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);
- // ----- Compare the bytes
- if ($v_bytes == 0x504b0506)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\'');
- $v_pos++;
- break;
- }
- $v_pos++;
- }
- // ----- Look if not found end of central dir
- if ($v_pos == $v_size)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature");
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Extract the values
- ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'");
- ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'");
- $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
- // ----- Check the global size
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);
- if (($v_pos + $v_data['comment_size'] + 18) != $v_size)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Fail to find the right signature");
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Fail to find the right signature");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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'] = '';
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\'');
- $p_central_dir['entries'] = $v_data['entries'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\'');
- $p_central_dir['disk_entries'] = $v_data['disk_entries'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\'');
- $p_central_dir['offset'] = $v_data['offset'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\'');
- $p_central_dir['size'] = $v_data['size'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\'');
- $p_central_dir['disk'] = $v_data['disk'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\'');
- $p_central_dir['disk_start'] = $v_data['disk_start'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\'');
- // TBC
- //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
- // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]);
- //}
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privDeleteByRule()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privDeleteByRule(&$p_result_list, &$p_options)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", "");
- $v_result=1;
- $v_list_detail = array();
- // ----- Open the zip file
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
- if (($v_result=$this->privOpenFd('rb')) != 1)
- {
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- $this->privCloseFd();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Go to beginning of File
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
- @rewind($this->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
- // ----- Scan all the files
- // ----- Start at beginning of Central Dir
- $v_pos_entry = $v_central_dir['offset'];
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
- @rewind($this->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
- // ----- Read each entry
- $v_header_list = array();
- $j_start = 0;
- for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$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();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'");
- // ----- 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)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
- // ----- Look if the filename is in the list
- for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
- // ----- Look for a directory
- if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
- // ----- 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])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
- $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])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory");
- $v_found = true;
- }
- }
- // ----- Look for a filename
- elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
- $v_found = true;
- }
- }
- }
- // ----- Look for extract by ereg rule
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
- $v_found = true;
- }
- }
- // ----- Look for extract by preg rule
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
- $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)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
- // ----- Look if the index is in the list
- for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
- if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
- $v_found = true;
- }
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
- $j_start = $j+1;
- }
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
- break;
- }
- }
- }
- // ----- Look for deletion
- if ($v_found)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted");
- unset($v_header_list[$v_nb_extracted]);
- }
- else
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted");
- $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
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode");
- if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
- $this->privCloseFd();
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Look which file need to be kept
- for ($i=0; $i<sizeof($v_header_list); $i++) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry index '$i' : '".$v_header_list[$i]['filename']."'");
- // ----- Calculate the position of the header
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset='". $v_header_list[$i]['offset']."'");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
- @rewind($this->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
- // ----- Read the file header
- if (($v_result = $this->privReadFileHeader($v_header_list[$i])) != 1) {
- // ----- Close the zip file
- $this->privCloseFd();
- $v_temp_zip->privCloseFd();
- @unlink($v_zip_temp_name);
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'");
- // ----- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- }
- // ----- Store the offset of the central dir
- $v_offset = @ftell($v_temp_zip->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset");
- // ----- Re-Create the Central Dir files header
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory");
- for ($i=0; $i<sizeof($v_header_list); $i++) {
- // ----- Create the file header
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset of file : ".$v_header_list[$i]['offset']);
- if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
- $v_temp_zip->privCloseFd();
- $this->privCloseFd();
- @unlink($v_zip_temp_name);
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Transform the header to a 'usable' info
- $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer");
- // ----- Zip file comment
- $v_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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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);
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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;
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");
- // ----- Remove the final '/'
- if (($p_is_dir) && (substr($p_dir, -1)=='/'))
- {
- $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");
- // ----- Check the directory availability
- if ((is_dir($p_dir)) || ($p_dir == ""))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");
- return 1;
- }
- // ----- Extract parent directory
- $p_parent_dir = dirname($p_dir);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- }
- }
- // ----- Create the directory
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");
- if (!@mkdir($p_dir, 0777))
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- return PclZip::errorCode();
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'");
- $v_result=1;
- // ----- Look if the archive_to_add exists
- if (!is_file($p_archive_to_add->zipname))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge.");
- // ----- Nothing to merge, so merge is a success
- $v_result = 1;
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Look if the archive exists
- if (!is_file($this->zipname))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add.");
- // ----- Do a duplicate
- $v_result = $this->privDuplicate($p_archive_to_add->zipname);
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Open the zip file
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
- if (($v_result=$this->privOpenFd('rb')) != 1)
- {
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- $this->privCloseFd();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Go to beginning of File
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
- @rewind($this->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
- // ----- Open the archive_to_add file
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode");
- if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
- {
- $this->privCloseFd();
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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();
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Go to beginning of File
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
- @rewind($p_archive_to_add->zip_fd);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($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
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
- $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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
- $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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
- // ----- 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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
- $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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
- $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;
- }
- // ----- Zip file comment
- // TBC : I should merge the two comments
- $v_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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : privDuplicate()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privDuplicate($p_archive_filename)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'");
- $v_result=1;
- // ----- Look if the $p_archive_filename exists
- if (!is_file($p_archive_filename))
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");
- // ----- Nothing to duplicate, so duplicate is a success.
- $v_result = 1;
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Open the zip file
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
- if (($v_result=$this->privOpenFd('wb')) != 1)
- {
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- return $v_result;
- }
- // ----- Open the temporary file in write mode
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
- 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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes");
- $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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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 = 1;
- $this->error_string = '';
- }
- }
- // --------------------------------------------------------------------------------
- }
- // End of class
- // --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : PclZipUtilPathReduction()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function PclZipUtilPathReduction($p_dir)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$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
- 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] == "..")
- {
- // ----- Ignore it and ignore the $i-1
- $i--;
- }
- else if (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0))
- {
- // ----- Ignore only the double '//' in path,
- // but not the first and last '/'
- }
- else
- {
- $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
- }
- }
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'");
- $v_result = 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)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");
- // ----- 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] != '')) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different");
- $v_result = 0;
- }
- // ----- Next items
- $i++;
- $j++;
- }
- // ----- Look if everything seems to be the same
- if ($v_result) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break");
- // ----- 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++;
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'");
- 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
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode");
- $v_result = 1;
- if ($p_mode==0)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src)));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest)));
- while ($p_size != 0)
- {
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
- $v_buffer = @fread($p_src, $v_read_size);
- @fwrite($p_dest, $v_buffer, $v_read_size);
- $p_size -= $v_read_size;
- }
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src)));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest)));
- }
- else if ($p_mode==1)
- {
- while ($p_size != 0)
- {
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
- $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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
- $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);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
- $v_buffer = @gzread($p_src, $v_read_size);
- @gzwrite($p_dest, $v_buffer, $v_read_size);
- $p_size -= $v_read_size;
- }
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest");
- $v_result = 1;
- // ----- Try to rename the files
- if (!@rename($p_src, $p_dest)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink");
- // ----- Try to copy & unlink the src
- if (!@copy($p_src, $p_dest)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file");
- $v_result = 0;
- }
- else if (!@unlink($p_src)) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename");
- $v_result = 0;
- }
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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)
- {
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'");
- switch ($p_option) {
- case PCLZIP_OPT_PATH :
- $v_result = 'PCLZIP_OPT_PATH';
- break;
- case PCLZIP_OPT_ADD_PATH :
- $v_result = 'PCLZIP_OPT_ADD_PATH';
- break;
- case PCLZIP_OPT_REMOVE_PATH :
- $v_result = 'PCLZIP_OPT_REMOVE_PATH';
- break;
- case PCLZIP_OPT_REMOVE_ALL_PATH :
- $v_result = 'PCLZIP_OPT_REMOVE_ALL_PATH';
- break;
- case PCLZIP_OPT_EXTRACT_AS_STRING :
- $v_result = 'PCLZIP_OPT_EXTRACT_AS_STRING';
- break;
- case PCLZIP_OPT_SET_CHMOD :
- $v_result = 'PCLZIP_OPT_SET_CHMOD';
- break;
- case PCLZIP_OPT_BY_NAME :
- $v_result = 'PCLZIP_OPT_BY_NAME';
- break;
- case PCLZIP_OPT_BY_INDEX :
- $v_result = 'PCLZIP_OPT_BY_INDEX';
- break;
- case PCLZIP_OPT_BY_EREG :
- $v_result = 'PCLZIP_OPT_BY_EREG';
- break;
- case PCLZIP_OPT_BY_PREG :
- $v_result = 'PCLZIP_OPT_BY_PREG';
- break;
- case PCLZIP_CB_PRE_EXTRACT :
- $v_result = 'PCLZIP_CB_PRE_EXTRACT';
- break;
- case PCLZIP_CB_POST_EXTRACT :
- $v_result = 'PCLZIP_CB_POST_EXTRACT';
- break;
- case PCLZIP_CB_PRE_ADD :
- $v_result = 'PCLZIP_CB_PRE_ADD';
- break;
- case PCLZIP_CB_POST_ADD :
- $v_result = 'PCLZIP_CB_POST_ADD';
- break;
- default :
- $v_result = 'Unknown';
- }
- // ----- Return
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
- 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;
- }
- // --------------------------------------------------------------------------------
+<?php +// -------------------------------------------------------------------------------- +// PhpConcept Library - Zip Module 2.0 +// -------------------------------------------------------------------------------- +// License GNU/LGPL - Vincent Blavet - September 2003 +// 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.2 2006/03/22 10:24:32 squareing Exp $ +// -------------------------------------------------------------------------------- + // ----- Constants + 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. + 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 + 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/' ); + define( 'PCLZIP_TEMPORARY_DIR', '' ); +// -------------------------------------------------------------------------------- +// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED ***** +// -------------------------------------------------------------------------------- + // ----- Global variables + $g_pclzip_version = "2.0"; + // ----- 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_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 ); + // ----- 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 ); + // ----- 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 = ''; + // -------------------------------------------------------------------------------- + // 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname"); + // ----- Tests the zlib + if (!function_exists('gzopen')) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing"); + die('Abort '.basename(__FILE__).' : Missing zlib extensions'); + } + // ----- Set the attributes + $this->zipname = $p_zipname; + $this->zip_fd = 0; + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1); + 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_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, $p_add_dir="", $p_remove_dir="") + function create($p_filelist /*, options */) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ..."); + $v_result=1; + // ----- Reset the error handler + $this->privErrorReset(); + // ----- Set default values + $v_options = array(); + $v_add_path = ""; + $v_remove_path = ""; + $v_remove_all_path = false; + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + // ----- 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)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected"); + // ----- 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' )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + // ----- Set the arguments + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { + $v_add_path = $v_options[PCLZIP_OPT_ADD_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]; + } + } + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + // ----- Get the first argument + $v_add_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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'"); + // ----- Look if the $p_filelist is really an array + $p_result_list = array(); + if (is_array($p_filelist)) + { + // ----- Call the create fct + $v_result = $this->privCreate($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options); + } + // ----- Look if the $p_filelist is a string + else if (is_string($p_filelist)) + { + // ----- Create a list with the elements from the string + $v_list = explode(PCLZIP_SEPARATOR, $p_filelist); + // ----- Call the create fct + $v_result = $this->privCreate($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options); + } + // ----- Invalid variable + else + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); + $v_result = PCLZIP_ERR_INVALID_PARAMETER; + } + if ($v_result != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list); + 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_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, $p_add_dir="", $p_remove_dir="") + function add($p_filelist /* options */) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ..."); + $v_result=1; + // ----- Reset the error handler + $this->privErrorReset(); + // ----- Set default values + $v_options = array(); + $v_add_path = ""; + $v_remove_path = ""; + $v_remove_all_path = false; + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + // ----- 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)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected"); + // ----- 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' )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + // ----- Set the arguments + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { + $v_add_path = $v_options[PCLZIP_OPT_ADD_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]; + } + } + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + // ----- Get the first argument + $v_add_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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'"); + // ----- Look if the $p_filelist is really an array + $p_result_list = array(); + if (is_array($p_filelist)) + { + // ----- Call the create fct + $v_result = $this->privAdd($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options); + } + // ----- Look if the $p_filelist is a string + else if (is_string($p_filelist)) + { + // ----- Create a list with the elements from the string + $v_list = explode(PCLZIP_SEPARATOR, $p_filelist); + // ----- Call the create fct + $v_result = $this->privAdd($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options); + } + // ----- Invalid variable + else + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); + $v_result = PCLZIP_ERR_INVALID_PARAMETER; + } + if ($v_result != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list); + 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 exists 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() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', ""); + $v_result=1; + // ----- Reset the error handler + $this->privErrorReset(); + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + // ----- Call the extracting fct + $p_list = array(); + if (($v_result = $this->privList($p_list)) != 1) + { + unset($p_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + 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($p_path="./", $p_remove_path="") + function extract(/* options */) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", ""); + $v_result=1; + // ----- Reset the error handler + $this->privErrorReset(); + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + // ----- Set default values + $v_options = array(); + $v_path = "./"; + $v_remove_path = ""; + $v_remove_all_path = false; + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + // ----- 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)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options"); + // ----- 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' )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + 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 { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return 0; + } + } + } + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'"); + // ----- Call the extracting fct + $p_list = array(); + if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1) + { + unset($p_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + 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 */) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ..."); + $v_result=1; + // ----- Reset the error handler + $this->privErrorReset(); + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + // ----- Set default values + $v_options = array(); + $v_path = "./"; + $v_remove_path = ""; + $v_remove_all_path = false; + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + // ----- 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)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options"); + // ----- 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' )); + if ($v_result != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + 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; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set."); + } + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set."); + } + } + // ----- Look for 2 args + // Here we need to support the first historic synopsis of the + // method. + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis"); + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return 0; + } + } + } + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'"); + // ----- 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) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; + // ----- Call the extracting fct + if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + return $p_list; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : + // delete([$p_option, $p_option_value, ...]) + // Description : + // Parameters : + // None + // Options : + // PCLZIP_OPT_BY_INDEX : + // 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(/* options */) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", ""); + $v_result=1; + // ----- Reset the error handler + $this->privErrorReset(); + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return(0); + } + // ----- Set default values + $v_options = array(); + // ----- Look for variable options arguments + $v_size = func_num_args(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method"); + // ----- Look for no arguments + if ($v_size <= 0) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing arguments"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return 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) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + return 0; + } + // ----- Check that at least one rule is set + if ( (!isset($v_options[PCLZIP_OPT_BY_NAME])) + && (!isset($v_options[PCLZIP_OPT_BY_EREG])) + && (!isset($v_options[PCLZIP_OPT_BY_PREG])) + && (!isset($v_options[PCLZIP_OPT_BY_INDEX]))) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "At least one filtering rule must be set"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return 0; + } + // ----- Call the delete fct + $v_list = array(); + if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) + { + unset($v_list); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo()); + return(0); + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list); + return $v_list; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : deleteByIndex() + // Description : + // ***** Deprecated ***** + // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered. + // -------------------------------------------------------------------------------- + function deleteByIndex($p_index) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'"); + $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list); + 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() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", ""); + // ----- Reset the error handler + $this->privErrorReset(); + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0); + return 0; + } + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + 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'; + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", ""); + $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')) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'"); + // ----- 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)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", ""); + $v_result = 1; + // ----- Reset the error handler + $this->privErrorReset(); + // ----- Check archive + if (!$this->privCheckFormat()) { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0); + 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')) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object"); + // ----- 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)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename"); + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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' ); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", ""); + $v_result = true; + // ----- 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."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo()); + 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."'"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo()); + return(false); + } + // ----- Check the magic code + // TBC + // ----- Check the central header + // TBC + // ----- Check each file header + // TBC + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", ""); + $v_result=1; + // ----- Read the options + $i=0; + while ($i<$p_size) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'"); + // ----- Check if the option is requested + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Get the value + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $i++; + break; + // ----- Look for options that request an EREG or PREG expression + case PCLZIP_OPT_BY_EREG : + case PCLZIP_OPT_BY_PREG : + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Get the value + $v_work_list = array(); + if (is_string($p_options_list[$i+1])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a 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])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an 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])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array"); + $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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extracted index item = [".$v_result_list[$p_options_list[$i]][$j]['start'].",".$v_result_list[$p_options_list[$i]][$j]['end']."]"); + // ----- Look for list sort + if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ..."); + $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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "List sorting is not yet write ..."); + } + // ----- 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 : + $v_result_list[$p_options_list[$i]] = true; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Get the value + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'"); + $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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Get the value + $v_function_name = $p_options_list[$i+1]; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'"); + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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 optional parameter '".$p_options_list[$i]."'"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Next options + $i++; + } + // ----- Look for mandatory options + 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') { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")"); + // ----- Look if present + if (!isset($v_result_list[$key])) { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + } + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privCreate() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privCreate($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'"); + $v_result=1; + $v_list_detail = array(); + // ----- Open the file in write mode + if (($v_result = $this->privOpenFd('wb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Add the list of files + $v_result = $this->privAddList($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options); + // ----- Close + $this->privCloseFd(); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privAdd() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAdd($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'"); + $v_result=1; + $v_list_detail = array(); + // ----- Look if the archive exists or is empty + if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it."); + // ----- Do a create + $v_result = $this->privCreate($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + // ----- Creates a temporay file + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) + { + $this->privCloseFd(); + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $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_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1) + { + fclose($v_zip_temp_fd); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Store the offset of the central dir + $v_offset = @ftell($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset"); + // ----- 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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $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); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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 = ''; + // ----- 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); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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); + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privOpenFd() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privOpenFd($p_mode) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode'); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privCloseFd() + // Description : + // Parameters : + // -------------------------------------------------------------------------------- + function privCloseFd() + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", ""); + $v_result=1; + if ($this->zip_fd != 0) + @fclose($this->zip_fd); + $this->zip_fd = 0; + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'"); + $v_result=1; + // ----- Add the files + $v_header_list = array(); + if (($v_result = $this->privAddFileList($p_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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 = ''; + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privAddFileList() + // 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 + // run the lib 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 privAddFileList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'"); + $v_result=1; + $v_header = array(); + // ----- Recuperate the current number of elt in list + $v_nb = sizeof($p_result_list); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have $v_nb elements"); + // ----- Loop on the files + for ($j=0; ($j<count($p_list)) && ($v_result==1); $j++) + { + // ----- Recuperate the filename + $p_filename = PclZipUtilTranslateWinPath($p_list[$j], false); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file [$p_filename]"); + // ----- Skip empty file names + if ($p_filename == "") + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename"); + continue; + } + // ----- Check the filename + if (!file_exists($p_filename)) + { + // ----- Error log + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '$p_filename' does not exists"); + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '$p_filename' does not exists"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + /* This test is done later + // ----- Check the path length + if (strlen($p_filename) > 0xFF) + { + // ----- Error log + PclZip::privErrorLog(-5, "File name is too long (max. 255) : '$p_filename'"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + */ + // ----- Look if it is a file or a dir with no all pathnre move + if ((is_file($p_filename)) || ((is_dir($p_filename)) && !$p_remove_all_dir)) { + // ----- Add the file + if (($v_result = $this->privAddFile($p_filename, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1) + { + // ----- Return status + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Store the file infos + $p_result_list[$v_nb++] = $v_header; + } + // ----- Look for directory + if (is_dir($p_filename)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "$p_filename is a directory"); + // ----- Look for path + if ($p_filename != ".") + $v_path = $p_filename."/"; + else + $v_path = ""; + // ----- Read the directory for files and sub-directories + $p_hdir = opendir($p_filename); + $p_hitem = readdir($p_hdir); // '.' directory + $p_hitem = readdir($p_hdir); // '..' directory + while ($p_hitem = readdir($p_hdir)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for $p_hitem in the directory"); + // ----- Look for a file + if (is_file($v_path.$p_hitem)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the file '".$v_path.$p_hitem."'"); + // ----- Add the file + if (($v_result = $this->privAddFile($v_path.$p_hitem, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1) + { + // ----- Return status + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Store the file infos + $p_result_list[$v_nb++] = $v_header; + } + // ----- Recursive call to privAddFileList() + else + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the directory '".$v_path.$p_hitem."'"); + // ----- Need an array as parameter + $p_temp_list[0] = $v_path.$p_hitem; + $v_result = $this->privAddFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options); + // ----- Update the number of elements of the list + $v_nb = sizeof($p_result_list); + } + } + // ----- Free memory for the recursive loop + unset($p_temp_list); + unset($p_hdir); + unset($p_hitem); + } + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have $v_nb elements"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privAddFile() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privAddFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='$p_filename', add_dir='$p_add_dir', remove_dir='$p_remove_dir'"); + $v_result=1; + if ($p_filename == "") + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- 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, $p_filename); + if ($v_compare > 0) +// if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir) + { + if ($v_compare == 2) { + $v_stored_filename = ""; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder"); + } + else { + $v_stored_filename = substr($p_filename, strlen($p_remove_dir)); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$p_filename' = '$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; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'"); + } + // ----- Filename (reduce the path of stored name) + $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Filename (reduced) '$v_stored_filename', strlen ".strlen($v_stored_filename)); + /* filename length moved after call-back in release 1.3 + // ----- Check the path length + if (strlen($v_stored_filename) > 0xFF) + { + // ----- Error log + PclZip::privErrorLog(-5, "Stored file name is too long (max. 255) : '$v_stored_filename'"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + */ + // ----- Set the file properties + clearstatcache(); + $p_header['version'] = 20; + $p_header['version_extracted'] = 10; + $p_header['flag'] = 0; + $p_header['compression'] = 0; + $p_header['mtime'] = filemtime($p_filename); + $p_header['crc'] = 0; + $p_header['compressed_size'] = 0; + $p_header['size'] = filesize($p_filename); + $p_header['filename_len'] = strlen($p_filename); + $p_header['extra_len'] = 0; + $p_header['comment_len'] = 0; + $p_header['disk'] = 0; + $p_header['internal'] = 0; + $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); + $p_header['offset'] = 0; + $p_header['filename'] = $p_filename; + $p_header['stored_filename'] = $v_stored_filename; + $p_header['extra'] = ''; + $p_header['comment'] = ''; + $p_header['status'] = 'ok'; + $p_header['index'] = -1; + // ----- Look for pre-add callback + if (isset($p_options[PCLZIP_CB_PRE_ADD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction"); + // ----- 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);'); + 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']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_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 (is_file($p_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"); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { + // ----- Read the file content + $v_content_compressed = @fread($v_file, $p_header['size']); + // ----- Calculate the CRC + $p_header['crc'] = crc32($v_content_compressed); + } + else { + // ----- Read the file content + $v_content = @fread($v_file, $p_header['size']); + // ----- Calculate the CRC + $p_header['crc'] = crc32($v_content); + // ----- Compress the file + $v_content_compressed = gzdeflate($v_content); + } + // ----- Set header parameters + $p_header['compressed_size'] = strlen($v_content_compressed); + $p_header['compression'] = 8; + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { + @fclose($v_file); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Write the compressed content + $v_binary_data = pack('a'.$p_header['compressed_size'], $v_content_compressed); + @fwrite($this->zip_fd, $v_binary_data, $p_header['compressed_size']); + // ----- Close the file + @fclose($v_file); + } + // ----- Look for a directory + else + { + // ----- Set the file properties + $p_header['filename'] .= '/'; + $p_header['filename_len']++; + $p_header['size'] = 0; + $p_header['external'] = 0x41FF0010; // Value for a folder : to be checked + // ----- Call the header generation + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + } + // ----- Look for pre-add callback + if (isset($p_options[PCLZIP_CB_POST_ADD])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction"); + // ----- 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);'); + if ($v_result == 0) { + // ----- Ignored + $v_result = 1; + } + // ----- Update the informations + // Nothing can be modified + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privWriteFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"'); + $v_result=1; + // TBC + //for(reset($p_header); $key = key($p_header); next($p_header)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]); + //} + // ----- Store the offset position of the file + $p_header['offset'] = ftell($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']); + // ----- Transform UNIX mtime to DOS format mdate/mtime + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['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'], $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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privWriteCentralFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteCentralFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"'); + $v_result=1; + // TBC + //for(reset($p_header); $key = key($p_header); next($p_header)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]); + //} + // ----- Transform UNIX mtime to DOS format mdate/mtime + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privWriteCentralHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privList() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privList(&$p_list) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list"); + $v_result=1; + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Go to beginning of Central Dir + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_central_dir['offset'])) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'"); + // ----- Read each entry + for ($i=0; $i<$v_central_dir['entries']; $i++) + { + // ----- Read the file header + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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(); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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. + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privConvertHeader2FileInfo($p_header, &$p_info) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'"); + $v_result=1; + // ----- Get the interesting attributes + $p_info['filename'] = $p_header['filename']; + $p_info['stored_filename'] = $p_header['stored_filename']; + $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']; + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'"); + $v_result=1; + // ----- 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) == "/") + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'"); + $p_path = substr($p_path, 0, strlen($p_path)-1); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]"); + } + } + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result = $this->privOpenFd('rb')) != 1) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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++) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'"); + // ----- Read next Central dir entry + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'"); + // ----- Read the file header + $v_header = array(); + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'"); + // ----- Look if the filename is in the list + for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'"); + // ----- Look for a directory + if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory"); + // ----- 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])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path"); + $v_extract = true; + } + } + // ----- Look for a filename + elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one."); + $v_extract = true; + } + } + } + // ----- Look for extract by ereg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); + if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_extract = true; + } + } + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'"); + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $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)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); + // ----- Look if the index is in the list + for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]"); + if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range"); + $v_extract = true; + } + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop"); + $j_start = $j+1; + } + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop"); + break; + } + } + } + // ----- Look for no rule, which means extract all the archive + else { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)"); + $v_extract = true; + } + // ----- Look for real extraction + if ($v_extract) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'"); + // ----- Go to the file position + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'"); + if (@fseek($this->zip_fd, $v_header['offset'])) + { + // ----- Close the zip file + $this->privCloseFd(); + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + // ----- Look for extraction as string + if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { + // ----- Extracting the file + if (($v_result = $this->privExtractFileAsString($v_header, $v_string)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- 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(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Set the file content + $p_file_list[$v_nb_extracted]['content'] = $v_string; + // ----- Next extracted file + $v_nb_extracted++; + } + else { + // ----- Extracting the file + if (($v_result = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options)) != 1) + { + // ----- Close the zip file + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- 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(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + } + } + // ----- Close the zip file + $this->privCloseFd(); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privExtractFile() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'"); + $v_result=1; + // ----- Read the file header + if (($v_result = $this->privReadFileHeader($v_header)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + // ----- Check that the file header is coherent with $p_entry info + // TBC + // ----- Look for all path to remove + if ($p_remove_all_path == true) { + // ----- Get the basename of the path + $p_entry['filename'] = basename($p_entry['filename']); + } + // ----- Look for path to remove + else if ($p_remove_path != "") + { + //if (strcmp($p_remove_path, $p_entry['filename'])==0) + if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'"); + // ----- Change the file status + $p_entry['status'] = "filtered"; + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + $p_remove_path_size = strlen($p_remove_path); + if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'"); + // ----- Remove the path + $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'"); + } + } + // ----- Add the path + if ($p_path != '') + { + $p_entry['filename'] = $p_path."/".$p_entry['filename']; + } + // ----- Look for pre-extract callback + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction"); + // ----- 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);'); + if ($v_result == 0) { + // ----- Change the file status + $p_entry['status'] = "skipped"; + $v_result = 1; + } + // ----- Update the informations + // Only some fields can be modified + $p_entry['filename'] = $v_local_header['filename']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'"); + } + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + // ----- 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'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists"); + // ----- Look if file is a directory + if (is_dir($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory"); + // ----- Change the file status + $p_entry['status'] = "already_a_directory"; + // ----- Return + ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + //return $v_result; + } + // ----- Look if file is write protected + else if (!is_writeable($p_entry['filename'])) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected"); + // ----- Change the file status + $p_entry['status'] = "write_protected"; + // ----- Return + ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + //return $v_result; + } + // ----- Look if the extracted file is older + else if (filemtime($p_entry['filename']) > $p_entry['mtime']) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")"); + // ----- Change the file status + $p_entry['status'] = "newer_exist"; + // ----- Return + ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + //return $v_result; + } + } + // ----- 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) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'"); + // ----- Change the file status + $p_entry['status'] = "path_creation_fail"; + // ----- Return + ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + //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['compressed_size'] == $p_entry['size']) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); + // ----- Change the file status + $p_entry['status'] = "write_error"; + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes"); + // ----- 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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes"); + $v_buffer = fread($this->zip_fd, $v_read_size); + $v_binary_data = pack('a'.$v_read_size, $v_buffer); + @fwrite($v_dest_file, $v_binary_data, $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 + { + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file"); + // ----- Opening destination file + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode"); + // ----- Change the file status + $p_entry['status'] = "write_error"; + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes"); + // ----- 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); + // ----- 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])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'"); + // ----- Change the mode of the file + chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + } + // ----- Look for post-extract callback + if (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction"); + // ----- 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);'); + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privExtractFileAsString() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privExtractFileAsString(&$p_entry, &$p_string) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'"); + $v_result=1; + // ----- Read the file header + $v_header = array(); + if (($v_result = $this->privReadFileHeader($v_header)) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'"); + // ----- Check that the file header is coherent with $p_entry info + // TBC + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'"); + // ----- 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']) + { + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes"); + // ----- Reading the file + $p_string = fread($this->zip_fd, $p_entry['compressed_size']); + } + else + { + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file"); + // ----- Reading the file + $v_data = fread($this->zip_fd, $p_entry['compressed_size']); + // ----- Decompress the file + $p_string = gzinflate($v_data); + } + // ----- Trace + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done"); + } + else { + // TBC : error : can not extract a folder in a string + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privReadFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", ""); + $v_result=1; + // ----- Read the 4 bytes signature + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + // ----- Check signature + if ($v_data['id'] != 0x04034b50) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header"); + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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"; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data)); + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Extract the values + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'"); + $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); + // ----- Get filename + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']); + $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\''); + // ----- Get extra_fields + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']); + if ($v_data['extra_len'] != 0) { + $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); + } + else { + $p_header['extra'] = ''; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\''); + // ----- Extract properties + $p_header['compression'] = $v_data['compression']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.bin2hex($p_header['compression']).'\''); + $p_header['size'] = $v_data['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\''); + $p_header['compressed_size'] = $v_data['compressed_size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\''); + $p_header['crc'] = $v_data['crc']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.$p_header['crc'].'\''); + $p_header['flag'] = $v_data['flag']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\''); + // ----- 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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + else + { + $p_header['mtime'] = time(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + // ----- Other informations + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compression type : ".$v_data['compression']); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Version : ".$v_data['version']); + // TBC + //for(reset($v_data); $key = key($v_data); next($v_data)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]); + //} + // ----- Set the stored filename + $p_header['stored_filename'] = $p_header['filename']; + // ----- Set the status field + $p_header['status'] = "ok"; + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privReadCentralFileHeader() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadCentralFileHeader(&$p_header) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", ""); + $v_result=1; + // ----- Read the 4 bytes signature + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + // ----- Check signature + if ($v_data['id'] != 0x02014b50) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature"); + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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"; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data)); + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Extract the values + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'"); + $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 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']); + if ($p_header['filename_len'] != 0) + $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); + else + $p_header['filename'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\''); + // ----- Get extra + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']); + if ($p_header['extra_len'] != 0) + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); + else + $p_header['extra'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\''); + // ----- Get comment + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']); + if ($p_header['comment_len'] != 0) + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); + else + $p_header['comment'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\''); + // ----- Extract properties + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.$p_header['crc'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\''); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\''); + // ----- Recuperate date in UNIX format + 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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + else + { + $p_header['mtime'] = time(); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\''); + } + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')'); + if (substr($p_header['filename'], -1) == '/') + { + $p_header['external'] = 0x41FF0010; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.$p_header['external'].'\''); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\''); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privReadEndCentralDir() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privReadEndCentralDir(&$p_central_dir) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", ""); + $v_result=1; + // ----- Go to the end of the zip file + $v_size = filesize($this->zipname); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size"); + @fseek($this->zip_fd, $v_size); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\''); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment'); + @fseek($this->zip_fd, $v_size-22); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\''); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Read for bytes + $v_binary_data = @fread($this->zip_fd, 4); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'"); + $v_data = unpack('Vid', $v_binary_data); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'"); + // ----- Check signature + if ($v_data['id'] == 0x06054b50) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position."); + $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) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir'); + $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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\''); + // ----- 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); + // ----- Compare the bytes + if ($v_bytes == 0x504b0506) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\''); + $v_pos++; + break; + } + $v_pos++; + } + // ----- Look if not found end of central dir + if ($v_pos == $v_size) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature"); + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Extract the values + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'"); + ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'"); + $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); + // ----- Check the global size + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']); + if (($v_pos + $v_data['comment_size'] + 18) != $v_size) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Fail to find the right signature"); + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Fail to find the right signature"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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'] = ''; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\''); + $p_central_dir['entries'] = $v_data['entries']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\''); + $p_central_dir['disk_entries'] = $v_data['disk_entries']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\''); + $p_central_dir['offset'] = $v_data['offset']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\''); + $p_central_dir['size'] = $v_data['size']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\''); + $p_central_dir['disk'] = $v_data['disk']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\''); + $p_central_dir['disk_start'] = $v_data['disk_start']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\''); + // TBC + //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { + // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]); + //} + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privDeleteByRule() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDeleteByRule(&$p_result_list, &$p_options) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", ""); + $v_result=1; + $v_list_detail = array(); + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'"); + // ----- Scan all the files + // ----- Start at beginning of Central Dir + $v_pos_entry = $v_central_dir['offset']; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + // ----- Read each entry + $v_header_list = array(); + $j_start = 0; + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$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(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'"); + // ----- 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)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'"); + // ----- Look if the filename is in the list + for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'"); + // ----- Look for a directory + if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory"); + // ----- 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])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path"); + $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])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory"); + $v_found = true; + } + } + // ----- Look for a filename + elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one."); + $v_found = true; + } + } + } + // ----- Look for extract by ereg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) + && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'"); + if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $v_found = true; + } + } + // ----- Look for extract by preg rule + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'"); + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression"); + $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)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'"); + // ----- Look if the index is in the list + for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]"); + if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range"); + $v_found = true; + } + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop"); + $j_start = $j+1; + } + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop"); + break; + } + } + } + // ----- Look for deletion + if ($v_found) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted"); + unset($v_header_list[$v_nb_extracted]); + } + else + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted"); + $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 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode"); + if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { + $this->privCloseFd(); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Look which file need to be kept + for ($i=0; $i<sizeof($v_header_list); $i++) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry index '$i' : '".$v_header_list[$i]['filename']."'"); + // ----- Calculate the position of the header + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset='". $v_header_list[$i]['offset']."'"); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'"); + // ----- Read the file header + if (($v_result = $this->privReadFileHeader($v_header_list[$i])) != 1) { + // ----- Close the zip file + $this->privCloseFd(); + $v_temp_zip->privCloseFd(); + @unlink($v_zip_temp_name); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'"); + // ----- 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + // ----- Store the offset of the central dir + $v_offset = @ftell($v_temp_zip->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset"); + // ----- Re-Create the Central Dir files header + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory"); + for ($i=0; $i<sizeof($v_header_list); $i++) { + // ----- Create the file header + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset of file : ".$v_header_list[$i]['offset']); + if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) { + $v_temp_zip->privCloseFd(); + $this->privCloseFd(); + @unlink($v_zip_temp_name); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Transform the header to a 'usable' info + $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer"); + // ----- Zip file comment + $v_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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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); + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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; + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'"); + // ----- Remove the final '/' + if (($p_is_dir) && (substr($p_dir, -1)=='/')) + { + $p_dir = substr($p_dir, 0, strlen($p_dir)-1); + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'"); + // ----- Check the directory availability + if ((is_dir($p_dir)) || ($p_dir == "")) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory"); + return 1; + } + // ----- Extract parent directory + $p_parent_dir = dirname($p_dir); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_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) + { + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + } + } + // ----- Create the directory + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'"); + if (!@mkdir($p_dir, 0777)) + { + // ----- Error log + PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + return PclZip::errorCode(); + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created"); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'"); + $v_result=1; + // ----- Look if the archive_to_add exists + if (!is_file($p_archive_to_add->zipname)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge."); + // ----- Nothing to merge, so merge is a success + $v_result = 1; + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Look if the archive exists + if (!is_file($this->zipname)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add."); + // ----- Do a duplicate + $v_result = $this->privDuplicate($p_archive_to_add->zipname); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('rb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Read the central directory informations + $v_central_dir = array(); + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) + { + $this->privCloseFd(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'"); + @rewind($this->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'"); + // ----- Open the archive_to_add file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode"); + if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) + { + $this->privCloseFd(); + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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(); + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Go to beginning of File + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'"); + @rewind($p_archive_to_add->zip_fd); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($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 + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset"); + // ----- 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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $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; + } + // ----- Zip file comment + // TBC : I should merge the two comments + $v_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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : privDuplicate() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function privDuplicate($p_archive_filename) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'"); + $v_result=1; + // ----- Look if the $p_archive_filename exists + if (!is_file($p_archive_filename)) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate."); + // ----- Nothing to duplicate, so duplicate is a success. + $v_result = 1; + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Open the zip file + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode"); + if (($v_result=$this->privOpenFd('wb')) != 1) + { + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + return $v_result; + } + // ----- Open the temporary file in write mode + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo()); + 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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes"); + $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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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 = 1; + $this->error_string = ''; + } + } + // -------------------------------------------------------------------------------- + } + // End of class + // -------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------- + // Function : PclZipUtilPathReduction() + // Description : + // Parameters : + // Return Values : + // -------------------------------------------------------------------------------- + function PclZipUtilPathReduction($p_dir) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$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 + 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] == "..") + { + // ----- Ignore it and ignore the $i-1 + $i--; + } + else if (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0)) + { + // ----- Ignore only the double '//' in path, + // but not the first and last '/' + } + else + { + $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); + } + } + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'"); + $v_result = 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)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'"); + // ----- 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] != '')) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different"); + $v_result = 0; + } + // ----- Next items + $i++; + $j++; + } + // ----- Look if everything seems to be the same + if ($v_result) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break"); + // ----- 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++; + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'"); + 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 + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode"); + $v_result = 1; + if ($p_mode==0) + { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src))); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest))); + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @fread($p_src, $v_read_size); + @fwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src))); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest))); + } + else if ($p_mode==1) + { + while ($p_size != 0) + { + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $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); + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes"); + $v_buffer = @gzread($p_src, $v_read_size); + @gzwrite($p_dest, $v_buffer, $v_read_size); + $p_size -= $v_read_size; + } + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest"); + $v_result = 1; + // ----- Try to rename the files + if (!@rename($p_src, $p_dest)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink"); + // ----- Try to copy & unlink the src + if (!@copy($p_src, $p_dest)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file"); + $v_result = 0; + } + else if (!@unlink($p_src)) { + //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename"); + $v_result = 0; + } + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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) + { + //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'"); + switch ($p_option) { + case PCLZIP_OPT_PATH : + $v_result = 'PCLZIP_OPT_PATH'; + break; + case PCLZIP_OPT_ADD_PATH : + $v_result = 'PCLZIP_OPT_ADD_PATH'; + break; + case PCLZIP_OPT_REMOVE_PATH : + $v_result = 'PCLZIP_OPT_REMOVE_PATH'; + break; + case PCLZIP_OPT_REMOVE_ALL_PATH : + $v_result = 'PCLZIP_OPT_REMOVE_ALL_PATH'; + break; + case PCLZIP_OPT_EXTRACT_AS_STRING : + $v_result = 'PCLZIP_OPT_EXTRACT_AS_STRING'; + break; + case PCLZIP_OPT_SET_CHMOD : + $v_result = 'PCLZIP_OPT_SET_CHMOD'; + break; + case PCLZIP_OPT_BY_NAME : + $v_result = 'PCLZIP_OPT_BY_NAME'; + break; + case PCLZIP_OPT_BY_INDEX : + $v_result = 'PCLZIP_OPT_BY_INDEX'; + break; + case PCLZIP_OPT_BY_EREG : + $v_result = 'PCLZIP_OPT_BY_EREG'; + break; + case PCLZIP_OPT_BY_PREG : + $v_result = 'PCLZIP_OPT_BY_PREG'; + break; + case PCLZIP_CB_PRE_EXTRACT : + $v_result = 'PCLZIP_CB_PRE_EXTRACT'; + break; + case PCLZIP_CB_POST_EXTRACT : + $v_result = 'PCLZIP_CB_POST_EXTRACT'; + break; + case PCLZIP_CB_PRE_ADD : + $v_result = 'PCLZIP_CB_PRE_ADD'; + break; + case PCLZIP_CB_POST_ADD : + $v_result = 'PCLZIP_CB_POST_ADD'; + break; + default : + $v_result = 'Unknown'; + } + // ----- Return + //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result); + 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; + } + // -------------------------------------------------------------------------------- ?>
\ No newline at end of file diff --git a/s5/index-osf.html b/s5/index-osf.html index 6f33a65..01948bc 100644 --- a/s5/index-osf.html +++ b/s5/index-osf.html @@ -1,201 +1,201 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-
-<head>
-<title>S5: An Introduction</title>
-<!-- metadata -->
-<meta name="generator" content="S5" />
-<meta name="version" content="S5 1.2a1" />
-<meta name="presdate" content="20050128" />
-<meta name="author" content="Eric A. Meyer" />
-<meta name="company" content="Complex Spiral Consulting" />
-<!-- configuration parameters -->
-<meta name="defaultView" content="slideshow" />
-<meta name="controlVis" content="hidden" />
-<!-- style sheet links -->
-<link rel="stylesheet" href="ui/default/slides.css" type="text/css" media="projection" id="slideProj" />
-<link rel="stylesheet" href="ui/default/outline.css" type="text/css" media="screen" id="outlineStyle" />
-<link rel="stylesheet" href="ui/default/print.css" type="text/css" media="print" id="slidePrint" />
-<link rel="stylesheet" href="ui/default/opera.css" type="text/css" media="projection" id="operaFix" />
-<!-- embedded styles -->
-<style type="text/css" media="all">
-.imgcon {width: 525px; margin: 0 auto; padding: 0; text-align: center;}
-#anim {width: 270px; height: 320px; position: relative; margin-top: 0.5em;}
-#anim img {position: absolute; top: 42px; left: 24px;}
-img#me01 {top: 0; left: 0;}
-img#me02 {left: 23px;}
-img#me04 {top: 44px;}
-img#me05 {top: 43px;left: 36px;}
-</style>
-<!-- S5 JS -->
-<script src="ui/default/slides.js" type="text/javascript"></script>
-</head>
-<body>
-
-<div class="layout">
-<div id="controls"><!-- DO NOT EDIT --></div>
-<div id="currentSlide"><!-- DO NOT EDIT --></div>
-<div id="header"></div>
-<div id="footer">
-<h1>S5 Testbed</h1>
-<h2>Your computer • Today's date</h2>
-</div>
-</div>
-
-<div class="presentation">
-
-<div class="slide">
-<h1>S5 Testbed</h1>
-<h3>Eric A. Meyer</h3>
-<h4><a href="http://www.complexspiral.com/" rel="external">Complex Spiral Consulting</a></h4>
-<div class="handout"></div>
-</div>
-
-
-<div class="slide">
-<h1>What Is S5?</h1>
-<ul>
-<li>It's a <strong>S</strong>imple <strong>S</strong>tandards-based <strong>S</strong>lide <strong>S</strong>how <strong>S</strong>ystem</li>
-<li>One XHTML document provides all of the slide show's content</li>
-<li>CSS handles the layout and look of the slides</li>
-<li>JavaScript handles the dynamic aspects of the show</li>
-<li>That's all there is to it! (<a href="#slide9">skip to summary</a>; demonstrates links internal to the slide show)</li>
-</ul>
-
-<div class="notes">
-<ul>
-<li>I have notes here!</li>
-<li>Keen.</li>
-<li>Remember to tell people that notes are a new feature in 1.2</li>
-</ul>
-</div>
-
-</div>
-
-
-<div class="slide">
-<h1>Operatic Origins</h1>
-<ul>
-<li>Opera 4 introduced <a href="http://www.opera.com/support/tutorials/operashow/" rel="external">Opera Show</a>, a projection-mode style sheet technology (link demonstrates external link styling and window spawning)</li>
-<li>Allows a single XHTML document to be turned into a PowerPoint-like slide show</li>
-<li>Adding screen and print style sheets allows for multi-medium views of a single document</li>
-<li>Highly efficient, but highly browser centric...</li>
-</ul>
-
-<div class="notes">
-<ul>
-<li>S5 and OperaShow diverged greatly in S5 1.1</li>
-<li>S5 1.2 should (we hope) bring them into harmony once more</li>
-</ul>
-</div>
-
-</div>
-
-
-<div class="slide">
-<h1>Incremental Display</h1>
-<ul class="incremental show-first">
-<li>Keep hitting/clicking "next" as long as it isn't the control link (»)</li>
-<li>Bullet points are revealed one by one
-<ul class="incremental">
-<li>All based on class name of <code>inc</code></li>
-<li>Lists can be classed to make items appear individually</li>
-<li>Individual items can be classed as well to create "animations"; see <a href="http://boxofchocolates.ca/projects/s5-incremental-graphics/" rel="external">Derek Featherstone's example</a></li>
-</ul>
-</li>
-<li>Let's try it again, but without the first bullet point being pre-highlighted...</li>
-</ul>
-</div>
-
-
-<div class="slide">
-<h1>Incremental Display II</h1>
-<ul class="incremental">
-<li>Keep hitting/clicking "next" as long as it isn't the control link (»)</li>
-<li>Bullet points are revealed one by one
-<ul>
-<li>All based on class name of <code>incremental</code></li>
-<li>Lists can be classed to make items appear individually</li>
-<li>Individual items can be classed as well to create "animations"; see <a href="http://boxofchocolates.ca/projects/s5-incremental-graphics/" rel="external">Derek Featherstone's example</a></li>
-</ul>
-</li>
-<li>Notice how the sub-list was part of the parent bullet point; that was done on purpose</li>
-<li>Now to move on to other test slides!</li>
-</ul>
-</div>
-
-
-<div class="slide">
-<h1>PNG Alpha Tests</h1>
-<div style="width: 400px; height: 150px; text-align: center; background: url(ui/bg-shade.png)">
-<p>DIV with PNG background followed by foreground PNG</p>
-<img src="ui/bg-shade.png" alt="" title="A translucent image" />
-</div>
-<div style="width: 100%; height: 150px; text-align: center; background: url(ui/bg-shade.png)">
-<p>DIV with PNG background followed by foreground PNG</p>
-<img src="ui/bg-shade.png" alt="" title="A translucent image" />
-</div>
-</div>
-
-<div class="slide">
-<h1>S5 Default File Structure</h1>
-<p style="text-align: center;">
-<img src="pix/s5filemap.png" alt="" title="At a Glance" />
-</p>
-</div>
-
-
-<div class="slide">
-<h1>S5 Themes</h1>
-<p class="imgcon">
-<img src="pix/S501.jpg" alt="" title="Default" />
-<img src="pix/S502.jpg" alt="" title="I18N" />
-<img src="pix/S503.jpg" alt="" title="Blue" />
-<img src="pix/S504.jpg" alt="" title="Flower" />
-(one way of presenting multiple graphics)
-</p>
-</div>
-
-
-<div class="slide">
-<h1>Incremental S5 Themes</h1>
-<p class="imgcon">
-<img src="pix/S501.jpg" alt="" title="Default" class="incremental" />
-<img src="pix/S502.jpg" alt="" title="I18N" class="incremental" />
-<img src="pix/S503.jpg" alt="" title="Blue" class="incremental" />
-<img src="pix/S504.jpg" alt="" title="Flower" class="incremental" />
-(one by one!)
-</p>
-</div>
-
-
-<div class="slide">
-<h1>Incremental Animation</h1>
-<ul>
-<li>A demonstration of just one of the many ways to accomplish simple animation-like effects <small>(using a diagram from <a href="http://gmpg.org/xfn/and/" rel="external">"XFN and..."</a>)</small></li>
-</ul>
-<p class="imgcon" id="anim">
-<img src="pix/mememe01.png" id="me01" alt="" />
-<img src="pix/mememe02.png" alt="" id="me02" class="incremental" />
-<img src="pix/mememe03.png" alt="" id="me03" class="incremental" />
-<img src="pix/mememe04.png" alt="" id="me04" class="incremental" />
-<img src="pix/mememe05.png" alt="" id="me05" class="incremental" />
-</p>
-</div>
-
-
-<div class="slide">
-<h1>In Summary</h1>
-<ul>
-<li>With minimal scripting, we have recreated and improved upon a (currently) browser-specific technology, making it cross-browser in the process</li>
-<li>The S5 format is OSF 1.0 compatible</li>
-<li>S5 is a very flexible and lightweight slide show system available for anyone to use</li>
-</ul>
-</div>
-
-</div>
-
-</body>
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> + +<head> +<title>S5: An Introduction</title> +<!-- metadata --> +<meta name="generator" content="S5" /> +<meta name="version" content="S5 1.2a1" /> +<meta name="presdate" content="20050128" /> +<meta name="author" content="Eric A. Meyer" /> +<meta name="company" content="Complex Spiral Consulting" /> +<!-- configuration parameters --> +<meta name="defaultView" content="slideshow" /> +<meta name="controlVis" content="hidden" /> +<!-- style sheet links --> +<link rel="stylesheet" href="ui/default/slides.css" type="text/css" media="projection" id="slideProj" /> +<link rel="stylesheet" href="ui/default/outline.css" type="text/css" media="screen" id="outlineStyle" /> +<link rel="stylesheet" href="ui/default/print.css" type="text/css" media="print" id="slidePrint" /> +<link rel="stylesheet" href="ui/default/opera.css" type="text/css" media="projection" id="operaFix" /> +<!-- embedded styles --> +<style type="text/css" media="all"> +.imgcon {width: 525px; margin: 0 auto; padding: 0; text-align: center;} +#anim {width: 270px; height: 320px; position: relative; margin-top: 0.5em;} +#anim img {position: absolute; top: 42px; left: 24px;} +img#me01 {top: 0; left: 0;} +img#me02 {left: 23px;} +img#me04 {top: 44px;} +img#me05 {top: 43px;left: 36px;} +</style> +<!-- S5 JS --> +<script src="ui/default/slides.js" type="text/javascript"></script> +</head> +<body> + +<div class="layout"> +<div id="controls"><!-- DO NOT EDIT --></div> +<div id="currentSlide"><!-- DO NOT EDIT --></div> +<div id="header"></div> +<div id="footer"> +<h1>S5 Testbed</h1> +<h2>Your computer • Today's date</h2> +</div> +</div> + +<div class="presentation"> + +<div class="slide"> +<h1>S5 Testbed</h1> +<h3>Eric A. Meyer</h3> +<h4><a href="http://www.complexspiral.com/" rel="external">Complex Spiral Consulting</a></h4> +<div class="handout"></div> +</div> + + +<div class="slide"> +<h1>What Is S5?</h1> +<ul> +<li>It's a <strong>S</strong>imple <strong>S</strong>tandards-based <strong>S</strong>lide <strong>S</strong>how <strong>S</strong>ystem</li> +<li>One XHTML document provides all of the slide show's content</li> +<li>CSS handles the layout and look of the slides</li> +<li>JavaScript handles the dynamic aspects of the show</li> +<li>That's all there is to it! (<a href="#slide9">skip to summary</a>; demonstrates links internal to the slide show)</li> +</ul> + +<div class="notes"> +<ul> +<li>I have notes here!</li> +<li>Keen.</li> +<li>Remember to tell people that notes are a new feature in 1.2</li> +</ul> +</div> + +</div> + + +<div class="slide"> +<h1>Operatic Origins</h1> +<ul> +<li>Opera 4 introduced <a href="http://www.opera.com/support/tutorials/operashow/" rel="external">Opera Show</a>, a projection-mode style sheet technology (link demonstrates external link styling and window spawning)</li> +<li>Allows a single XHTML document to be turned into a PowerPoint-like slide show</li> +<li>Adding screen and print style sheets allows for multi-medium views of a single document</li> +<li>Highly efficient, but highly browser centric...</li> +</ul> + +<div class="notes"> +<ul> +<li>S5 and OperaShow diverged greatly in S5 1.1</li> +<li>S5 1.2 should (we hope) bring them into harmony once more</li> +</ul> +</div> + +</div> + + +<div class="slide"> +<h1>Incremental Display</h1> +<ul class="incremental show-first"> +<li>Keep hitting/clicking "next" as long as it isn't the control link (»)</li> +<li>Bullet points are revealed one by one +<ul class="incremental"> +<li>All based on class name of <code>inc</code></li> +<li>Lists can be classed to make items appear individually</li> +<li>Individual items can be classed as well to create "animations"; see <a href="http://boxofchocolates.ca/projects/s5-incremental-graphics/" rel="external">Derek Featherstone's example</a></li> +</ul> +</li> +<li>Let's try it again, but without the first bullet point being pre-highlighted...</li> +</ul> +</div> + + +<div class="slide"> +<h1>Incremental Display II</h1> +<ul class="incremental"> +<li>Keep hitting/clicking "next" as long as it isn't the control link (»)</li> +<li>Bullet points are revealed one by one +<ul> +<li>All based on class name of <code>incremental</code></li> +<li>Lists can be classed to make items appear individually</li> +<li>Individual items can be classed as well to create "animations"; see <a href="http://boxofchocolates.ca/projects/s5-incremental-graphics/" rel="external">Derek Featherstone's example</a></li> +</ul> +</li> +<li>Notice how the sub-list was part of the parent bullet point; that was done on purpose</li> +<li>Now to move on to other test slides!</li> +</ul> +</div> + + +<div class="slide"> +<h1>PNG Alpha Tests</h1> +<div style="width: 400px; height: 150px; text-align: center; background: url(ui/bg-shade.png)"> +<p>DIV with PNG background followed by foreground PNG</p> +<img src="ui/bg-shade.png" alt="" title="A translucent image" /> +</div> +<div style="width: 100%; height: 150px; text-align: center; background: url(ui/bg-shade.png)"> +<p>DIV with PNG background followed by foreground PNG</p> +<img src="ui/bg-shade.png" alt="" title="A translucent image" /> +</div> +</div> + +<div class="slide"> +<h1>S5 Default File Structure</h1> +<p style="text-align: center;"> +<img src="pix/s5filemap.png" alt="" title="At a Glance" /> +</p> +</div> + + +<div class="slide"> +<h1>S5 Themes</h1> +<p class="imgcon"> +<img src="pix/S501.jpg" alt="" title="Default" /> +<img src="pix/S502.jpg" alt="" title="I18N" /> +<img src="pix/S503.jpg" alt="" title="Blue" /> +<img src="pix/S504.jpg" alt="" title="Flower" /> +(one way of presenting multiple graphics) +</p> +</div> + + +<div class="slide"> +<h1>Incremental S5 Themes</h1> +<p class="imgcon"> +<img src="pix/S501.jpg" alt="" title="Default" class="incremental" /> +<img src="pix/S502.jpg" alt="" title="I18N" class="incremental" /> +<img src="pix/S503.jpg" alt="" title="Blue" class="incremental" /> +<img src="pix/S504.jpg" alt="" title="Flower" class="incremental" /> +(one by one!) +</p> +</div> + + +<div class="slide"> +<h1>Incremental Animation</h1> +<ul> +<li>A demonstration of just one of the many ways to accomplish simple animation-like effects <small>(using a diagram from <a href="http://gmpg.org/xfn/and/" rel="external">"XFN and..."</a>)</small></li> +</ul> +<p class="imgcon" id="anim"> +<img src="pix/mememe01.png" id="me01" alt="" /> +<img src="pix/mememe02.png" alt="" id="me02" class="incremental" /> +<img src="pix/mememe03.png" alt="" id="me03" class="incremental" /> +<img src="pix/mememe04.png" alt="" id="me04" class="incremental" /> +<img src="pix/mememe05.png" alt="" id="me05" class="incremental" /> +</p> +</div> + + +<div class="slide"> +<h1>In Summary</h1> +<ul> +<li>With minimal scripting, we have recreated and improved upon a (currently) browser-specific technology, making it cross-browser in the process</li> +<li>The S5 format is OSF 1.0 compatible</li> +<li>S5 is a very flexible and lightweight slide show system available for anyone to use</li> +</ul> +</div> + +</div> + +</body> +</html> diff --git a/s5/index-xoxo.html b/s5/index-xoxo.html index 7904ae2..9415f44 100644 --- a/s5/index-xoxo.html +++ b/s5/index-xoxo.html @@ -1,201 +1,201 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-
-<head>
-<title>S5: An Introduction</title>
-<!-- metadata -->
-<meta name="generator" content="S5" />
-<meta name="version" content="S5 1.2a1" />
-<meta name="author" content="Eric A. Meyer" />
-<meta name="company" content="Complex Spiral Consulting" />
-<!-- configuration parameters -->
-<meta name="defaultView" content="slideshow" />
-<meta name="controlVis" content="hidden" />
-<!-- style sheet links -->
-<link rel="stylesheet" href="ui/default/slides.css" type="text/css" media="projection" id="slideProj" />
-<link rel="stylesheet" href="ui/default/outline.css" type="text/css" media="screen" id="outlineStyle" />
-<link rel="stylesheet" href="ui/default/print.css" type="text/css" media="print" id="slidePrint" />
-<link rel="stylesheet" href="ui/default/opera.css" type="text/css" media="projection" id="operaFix" />
-<!-- embedded styles -->
-<style type="text/css" media="all">
-.imgcon {width: 525px; margin: 0 auto; padding: 0; text-align: center;}
-#anim {width: 270px; height: 320px; position: relative; margin-top: 0.5em;}
-#anim img {position: absolute; top: 42px; left: 24px;}
-img#me01 {top: 0; left: 0;}
-img#me02 {left: 23px;}
-img#me04 {top: 44px;}
-img#me05 {top: 43px;left: 36px;}
-</style>
-<!-- S5 JS -->
-<script src="ui/default/slides.js" type="text/javascript"></script>
-</head>
-<body>
-
-<div class="layout">
-<div id="controls"><!-- DO NOT EDIT --></div>
-<div id="currentSlide"><!-- DO NOT EDIT --></div>
-<div id="header"></div>
-<div id="footer">
-<h1>S5 Testbed</h1>
-<h2>Your computer • Today's date</h2>
-</div>
-</div>
-
-<ol class="xoxo presentation">
-
-<li class="slide">
-<h1>S5 Testbed</h1>
-<h3>Eric A. Meyer</h3>
-<h4><a href="http://www.complexspiral.com/" rel="external">Complex Spiral Consulting</a></h4>
-<div class="handout"></div>
-</li>
-
-
-<li class="slide">
-<h1>What Is S5?</h1>
-<ul>
-<li>It's a <strong>S</strong>imple <strong>S</strong>tandards-based <strong>S</strong>lide <strong>S</strong>how <strong>S</strong>ystem</li>
-<li>One XHTML document provides all of the slide show's content</li>
-<li>CSS handles the layout and look of the slides</li>
-<li>JavaScript handles the dynamic aspects of the show</li>
-<li>That's all there is to it! (<a href="#slide9">skip to summary</a>; demonstrates links internal to the slide show)</li>
-</ul>
-
-<div class="notes">
-<ul>
-<li>I have notes here!</li>
-<li>Keen.</li>
-<li>Remember to tell people that notes are a new feature in 1.2</li>
-</ul>
-</div>
-
-</li>
-
-
-<li class="slide">
-<h1>Operatic Origins</h1>
-<ul>
-<li>Opera 4 introduced <a href="http://www.opera.com/support/tutorials/operashow/" rel="external">Opera Show</a>, a projection-mode style sheet technology (link demonstrates external link styling and window spawning)</li>
-<li>Allows a single XHTML document to be turned into a PowerPoint-like slide show</li>
-<li>Adding screen and print style sheets allows for multi-medium views of a single document</li>
-<li>Highly efficient, but highly browser centric...</li>
-</ul>
-
-<div class="notes">
-<ul>
-<li>S5 and OperaShow diverged greatly in S5 1.1</li>
-<li>S5 1.2 should (we hope) bring them into harmony once more</li>
-</ul>
-</div>
-
-</li>
-
-
-<li class="slide">
-<h1>Incremental Display</h1>
-<ul class="incremental show-first">
-<li>Keep hitting/clicking "next" as long as it isn't the control link (»)</li>
-<li>Bullet points are revealed one by one
-<ul class="incremental">
-<li>All based on class name of <code>inc</code></li>
-<li>Lists can be classed to make items appear individually</li>
-<li>Individual items can be classed as well to create "animations"; see <a href="http://boxofchocolates.ca/projects/s5-incremental-graphics/" rel="external">Derek Featherstone's example</a></li>
-</ul>
-</li>
-<li>Let's try it again, but without the first bullet point being pre-highlighted...</li>
-</ul>
-</li>
-
-
-<li class="slide">
-<h1>Incremental Display II</h1>
-<ul class="incremental">
-<li>Keep hitting/clicking "next" as long as it isn't the control link (»)</li>
-<li>Bullet points are revealed one by one
-<ul>
-<li>All based on class name of <code>incremental</code></li>
-<li>Lists can be classed to make items appear individually</li>
-<li>Individual items can be classed as well to create "animations"; see <a href="http://boxofchocolates.ca/projects/s5-incremental-graphics/" rel="external">Derek Featherstone's example</a></li>
-</ul>
-</li>
-<li>Notice how the sub-list was part of the parent bullet point; that was done on purpose</li>
-<li>Now to move on to other test slides!</li>
-</ul>
-</li>
-
-
-<li class="slide">
-<h1>PNG Alpha Tests</h1>
-<div style="width: 400px; height: 150px; text-align: center; background: url(ui/bg-shade.png)">
-<p>DIV with PNG background followed by foreground PNG</p>
-<img src="ui/bg-shade.png" alt="" title="A translucent image" />
-</div>
-<div style="width: 100%; height: 150px; text-align: center; background: url(ui/bg-shade.png)">
-<p>DIV with PNG background followed by foreground PNG</p>
-<img src="ui/bg-shade.png" alt="" title="A translucent image" />
-</div>
-</li>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -
-<li class="slide">
-<h1>S5 Default File Structure</h1>
-<p style="text-align: center;">
-<img src="pix/s5filemap.png" alt="" title="At a Glance" />
-</p>
-</li>
-
-
-<li class="slide">
-<h1>S5 Themes</h1>
-<p class="imgcon">
-<img src="pix/S501.jpg" alt="" title="Default" />
-<img src="pix/S502.jpg" alt="" title="I18N" />
-<img src="pix/S503.jpg" alt="" title="Blue" />
-<img src="pix/S504.jpg" alt="" title="Flower" />
-(one way of presenting multiple graphics)
-</p>
-</li>
-
-
-<li class="slide">
-<h1>Incremental S5 Themes</h1>
-<p class="imgcon">
-<img src="pix/S501.jpg" alt="" title="Default" class="incremental" />
-<img src="pix/S502.jpg" alt="" title="I18N" class="incremental" />
-<img src="pix/S503.jpg" alt="" title="Blue" class="incremental" />
-<img src="pix/S504.jpg" alt="" title="Flower" class="incremental" />
-(one by one!)
-</p>
-</li>
-
-
-<li class="slide">
-<h1>Incremental Animation</h1>
-<ul>
-<li>A demonstration of just one of the many ways to accomplish simple animation-like effects <small>(using a diagram from <a href="http://gmpg.org/xfn/and/" rel="external">"XFN and..."</a>)</small></li>
-</ul>
-<p class="imgcon" id="anim">
-<img src="pix/mememe01.png" id="me01" alt="" />
-<img src="pix/mememe02.png" alt="" id="me02" class="incremental" />
-<img src="pix/mememe03.png" alt="" id="me03" class="incremental" />
-<img src="pix/mememe04.png" alt="" id="me04" class="incremental" />
-<img src="pix/mememe05.png" alt="" id="me05" class="incremental" />
-</p>
-</li>
-
-
-<li class="slide">
-<h1>In Summary</h1>
-<ul>
-<li>With minimal scripting, we have recreated and improved upon a (currently) browser-specific technology, making it cross-browser in the process</li>
-<li>The S5 format is OSF 1.0 compatible</li>
-<li>S5 is a very flexible and lightweight slide show system available for anyone to use</li>
-</ul>
+<html xmlns="http://www.w3.org/1999/xhtml"> + +<head> +<title>S5: An Introduction</title> +<!-- metadata --> +<meta name="generator" content="S5" /> +<meta name="version" content="S5 1.2a1" /> +<meta name="author" content="Eric A. Meyer" /> +<meta name="company" content="Complex Spiral Consulting" /> +<!-- configuration parameters --> +<meta name="defaultView" content="slideshow" /> +<meta name="controlVis" content="hidden" /> +<!-- style sheet links --> +<link rel="stylesheet" href="ui/default/slides.css" type="text/css" media="projection" id="slideProj" /> +<link rel="stylesheet" href="ui/default/outline.css" type="text/css" media="screen" id="outlineStyle" /> +<link rel="stylesheet" href="ui/default/print.css" type="text/css" media="print" id="slidePrint" /> +<link rel="stylesheet" href="ui/default/opera.css" type="text/css" media="projection" id="operaFix" /> +<!-- embedded styles --> +<style type="text/css" media="all"> +.imgcon {width: 525px; margin: 0 auto; padding: 0; text-align: center;} +#anim {width: 270px; height: 320px; position: relative; margin-top: 0.5em;} +#anim img {position: absolute; top: 42px; left: 24px;} +img#me01 {top: 0; left: 0;} +img#me02 {left: 23px;} +img#me04 {top: 44px;} +img#me05 {top: 43px;left: 36px;} +</style> +<!-- S5 JS --> +<script src="ui/default/slides.js" type="text/javascript"></script> +</head> +<body> + +<div class="layout"> +<div id="controls"><!-- DO NOT EDIT --></div> +<div id="currentSlide"><!-- DO NOT EDIT --></div> +<div id="header"></div> +<div id="footer"> +<h1>S5 Testbed</h1> +<h2>Your computer • Today's date</h2> +</div> +</div> + +<ol class="xoxo presentation"> + +<li class="slide"> +<h1>S5 Testbed</h1> +<h3>Eric A. Meyer</h3> +<h4><a href="http://www.complexspiral.com/" rel="external">Complex Spiral Consulting</a></h4> +<div class="handout"></div> +</li> + + +<li class="slide"> +<h1>What Is S5?</h1> +<ul> +<li>It's a <strong>S</strong>imple <strong>S</strong>tandards-based <strong>S</strong>lide <strong>S</strong>how <strong>S</strong>ystem</li> +<li>One XHTML document provides all of the slide show's content</li> +<li>CSS handles the layout and look of the slides</li> +<li>JavaScript handles the dynamic aspects of the show</li> +<li>That's all there is to it! (<a href="#slide9">skip to summary</a>; demonstrates links internal to the slide show)</li> +</ul> + +<div class="notes"> +<ul> +<li>I have notes here!</li> +<li>Keen.</li> +<li>Remember to tell people that notes are a new feature in 1.2</li> +</ul> +</div> + +</li> + + +<li class="slide"> +<h1>Operatic Origins</h1> +<ul> +<li>Opera 4 introduced <a href="http://www.opera.com/support/tutorials/operashow/" rel="external">Opera Show</a>, a projection-mode style sheet technology (link demonstrates external link styling and window spawning)</li> +<li>Allows a single XHTML document to be turned into a PowerPoint-like slide show</li> +<li>Adding screen and print style sheets allows for multi-medium views of a single document</li> +<li>Highly efficient, but highly browser centric...</li> +</ul> + +<div class="notes"> +<ul> +<li>S5 and OperaShow diverged greatly in S5 1.1</li> +<li>S5 1.2 should (we hope) bring them into harmony once more</li> +</ul> +</div> + +</li> + + +<li class="slide"> +<h1>Incremental Display</h1> +<ul class="incremental show-first"> +<li>Keep hitting/clicking "next" as long as it isn't the control link (»)</li> +<li>Bullet points are revealed one by one +<ul class="incremental"> +<li>All based on class name of <code>inc</code></li> +<li>Lists can be classed to make items appear individually</li> +<li>Individual items can be classed as well to create "animations"; see <a href="http://boxofchocolates.ca/projects/s5-incremental-graphics/" rel="external">Derek Featherstone's example</a></li> +</ul> +</li> +<li>Let's try it again, but without the first bullet point being pre-highlighted...</li> +</ul> +</li> + + +<li class="slide"> +<h1>Incremental Display II</h1> +<ul class="incremental"> +<li>Keep hitting/clicking "next" as long as it isn't the control link (»)</li> +<li>Bullet points are revealed one by one +<ul> +<li>All based on class name of <code>incremental</code></li> +<li>Lists can be classed to make items appear individually</li> +<li>Individual items can be classed as well to create "animations"; see <a href="http://boxofchocolates.ca/projects/s5-incremental-graphics/" rel="external">Derek Featherstone's example</a></li> +</ul> </li> +<li>Notice how the sub-list was part of the parent bullet point; that was done on purpose</li> +<li>Now to move on to other test slides!</li> +</ul> +</li> + + +<li class="slide"> +<h1>PNG Alpha Tests</h1> +<div style="width: 400px; height: 150px; text-align: center; background: url(ui/bg-shade.png)"> +<p>DIV with PNG background followed by foreground PNG</p> +<img src="ui/bg-shade.png" alt="" title="A translucent image" /> +</div> +<div style="width: 100%; height: 150px; text-align: center; background: url(ui/bg-shade.png)"> +<p>DIV with PNG background followed by foreground PNG</p> +<img src="ui/bg-shade.png" alt="" title="A translucent image" /> +</div> +</li> + + +<li class="slide"> +<h1>S5 Default File Structure</h1> +<p style="text-align: center;"> +<img src="pix/s5filemap.png" alt="" title="At a Glance" /> +</p> +</li> + + +<li class="slide"> +<h1>S5 Themes</h1> +<p class="imgcon"> +<img src="pix/S501.jpg" alt="" title="Default" /> +<img src="pix/S502.jpg" alt="" title="I18N" /> +<img src="pix/S503.jpg" alt="" title="Blue" /> +<img src="pix/S504.jpg" alt="" title="Flower" /> +(one way of presenting multiple graphics) +</p> +</li> + + +<li class="slide"> +<h1>Incremental S5 Themes</h1> +<p class="imgcon"> +<img src="pix/S501.jpg" alt="" title="Default" class="incremental" /> +<img src="pix/S502.jpg" alt="" title="I18N" class="incremental" /> +<img src="pix/S503.jpg" alt="" title="Blue" class="incremental" /> +<img src="pix/S504.jpg" alt="" title="Flower" class="incremental" /> +(one by one!) +</p> +</li> + + +<li class="slide"> +<h1>Incremental Animation</h1> +<ul> +<li>A demonstration of just one of the many ways to accomplish simple animation-like effects <small>(using a diagram from <a href="http://gmpg.org/xfn/and/" rel="external">"XFN and..."</a>)</small></li> +</ul> +<p class="imgcon" id="anim"> +<img src="pix/mememe01.png" id="me01" alt="" /> +<img src="pix/mememe02.png" alt="" id="me02" class="incremental" /> +<img src="pix/mememe03.png" alt="" id="me03" class="incremental" /> +<img src="pix/mememe04.png" alt="" id="me04" class="incremental" /> +<img src="pix/mememe05.png" alt="" id="me05" class="incremental" /> +</p> +</li> + + +<li class="slide"> +<h1>In Summary</h1> +<ul> +<li>With minimal scripting, we have recreated and improved upon a (currently) browser-specific technology, making it cross-browser in the process</li> +<li>The S5 format is OSF 1.0 compatible</li> +<li>S5 is a very flexible and lightweight slide show system available for anyone to use</li> +</ul> +</li> + +</ol> -</ol>
-
-</body>
-</html>
+</body> +</html> diff --git a/s5/ui/default/iepngfix.htc b/s5/ui/default/iepngfix.htc index bba2db7..9f3d628 100644 --- a/s5/ui/default/iepngfix.htc +++ b/s5/ui/default/iepngfix.htc @@ -1,42 +1,42 @@ -<public:component>
-<public:attach event="onpropertychange" onevent="doFix()" />
-
-<script>
-
-// IE5.5+ PNG Alpha Fix v1.0 by Angus Turnbull http://www.twinhelix.com
-// Free usage permitted as long as this notice remains intact.
-
-// This must be a path to a blank image. That's all the configuration you need here.
-var blankImg = 'ui/default/blank.gif';
-
-var f = 'DXImageTransform.Microsoft.AlphaImageLoader';
-
-function filt(s, m) {
- if (filters[f]) {
- filters[f].enabled = s ? true : false;
- if (s) with (filters[f]) { src = s; sizingMethod = m }
- } else if (s) style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")';
-}
-
-function doFix() {
- if ((parseFloat(navigator.userAgent.match(/MSIE (\S+)/)[1]) < 5.5) ||
- (event && !/(background|src)/.test(event.propertyName))) return;
-
- if (tagName == 'IMG') {
- if ((/\.png$/i).test(src)) {
- filt(src, 'image'); // was 'scale'
- src = blankImg;
- } else if (src.indexOf(blankImg) < 0) filt();
- } else if (style.backgroundImage) {
- if (style.backgroundImage.match(/^url[("']+(.*\.png)[)"']+$/i)) {
- var s = RegExp.$1;
- style.backgroundImage = '';
- filt(s, 'crop');
- } else filt();
- }
-}
-
-doFix();
-
-</script>
+<public:component> +<public:attach event="onpropertychange" onevent="doFix()" /> + +<script> + +// IE5.5+ PNG Alpha Fix v1.0 by Angus Turnbull http://www.twinhelix.com +// Free usage permitted as long as this notice remains intact. + +// This must be a path to a blank image. That's all the configuration you need here. +var blankImg = 'ui/default/blank.gif'; + +var f = 'DXImageTransform.Microsoft.AlphaImageLoader'; + +function filt(s, m) { + if (filters[f]) { + filters[f].enabled = s ? true : false; + if (s) with (filters[f]) { src = s; sizingMethod = m } + } else if (s) style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")'; +} + +function doFix() { + if ((parseFloat(navigator.userAgent.match(/MSIE (\S+)/)[1]) < 5.5) || + (event && !/(background|src)/.test(event.propertyName))) return; + + if (tagName == 'IMG') { + if ((/\.png$/i).test(src)) { + filt(src, 'image'); // was 'scale' + src = blankImg; + } else if (src.indexOf(blankImg) < 0) filt(); + } else if (style.backgroundImage) { + if (style.backgroundImage.match(/^url[("']+(.*\.png)[)"']+$/i)) { + var s = RegExp.$1; + style.backgroundImage = ''; + filt(s, 'crop'); + } else filt(); + } +} + +doFix(); + +</script> </public:component>
\ No newline at end of file diff --git a/s5/ui/s5-notes.html b/s5/ui/s5-notes.html index 0a94282..a2ba625 100644 --- a/s5/ui/s5-notes.html +++ b/s5/ui/s5-notes.html @@ -1,57 +1,57 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<!-- Do not edit this document! The system will likely break if you do. -->
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title>Notes</title>
-<link rel="stylesheet" href="default/notes.css" type="text/css" />
-</head>
-
-<body onload="opener.s5NotesWindowLoaded=true;" onunload="opener.s5NotesWindowLoaded=false;">
-
-
-<div class="timers" id="elapsed">
-<h1>
-Elapsed Time
-</h1>
-<ul>
-<li>
-<h2>Presentation</h2>
-<span class="clock" id="elapsed-presentation">00:00:00</span>
-</li>
-<li>
-<h2>Current Slide</h2>
-<span class="clock" id="elapsed-slide">00:00:00</span>
-</li>
-</ul>
-<div class="controls">
-<a href="#reset-elapsed" onclick="opener.resetElapsedTime(); return false;" title="Reset Elapsed Time">|←</a>
-</div>
-</div>
-
-<div class="timers" id="remaining">
-<h1>
-Remaining Time
-</h1>
-<p>
-<a href="#subtract-remaining" class="control" id="minus" onclick="opener.alterRemainingTime('-5'); return false;" title="Subtract 5 Minutes">-</a>
-<span class="clock" id="timeLeft">00:00:00</span>
-<a href="#add-remaining" class="control" id="plus" onclick="opener.alterRemainingTime('5'); return false;" title="Add 5 Minutes">+</a>
-</p>
-<div class="controls">
-<form action="#" onsubmit="opener.resetRemainingTime(); return false;">
-<input type="text" class="text" id="startFrom" value="0" size="4" maxlength="4" />
-<a href="#toggle-remaining" onclick="opener.toggleRemainingTime(); return false;" title="Pause/Run Remaining Time">||</a>
-<a href="#reset-remaining" onclick="opener.resetRemainingTime(); return false;" title="Reset Remaining Time">|←</a>
-</form>
-</div>
-</div>
-
-<h2 id="slide">...</h2>
-<div id="notes"></div>
-
-<h2 id="next">...</h2>
-<div id="nextnotes"></div>
-
-</body>
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!-- Do not edit this document! The system will likely break if you do. --> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Notes</title> +<link rel="stylesheet" href="default/notes.css" type="text/css" /> +</head> + +<body onload="opener.s5NotesWindowLoaded=true;" onunload="opener.s5NotesWindowLoaded=false;"> + + +<div class="timers" id="elapsed"> +<h1> +Elapsed Time +</h1> +<ul> +<li> +<h2>Presentation</h2> +<span class="clock" id="elapsed-presentation">00:00:00</span> +</li> +<li> +<h2>Current Slide</h2> +<span class="clock" id="elapsed-slide">00:00:00</span> +</li> +</ul> +<div class="controls"> +<a href="#reset-elapsed" onclick="opener.resetElapsedTime(); return false;" title="Reset Elapsed Time">|←</a> +</div> +</div> + +<div class="timers" id="remaining"> +<h1> +Remaining Time +</h1> +<p> +<a href="#subtract-remaining" class="control" id="minus" onclick="opener.alterRemainingTime('-5'); return false;" title="Subtract 5 Minutes">-</a> +<span class="clock" id="timeLeft">00:00:00</span> +<a href="#add-remaining" class="control" id="plus" onclick="opener.alterRemainingTime('5'); return false;" title="Add 5 Minutes">+</a> +</p> +<div class="controls"> +<form action="#" onsubmit="opener.resetRemainingTime(); return false;"> +<input type="text" class="text" id="startFrom" value="0" size="4" maxlength="4" /> +<a href="#toggle-remaining" onclick="opener.toggleRemainingTime(); return false;" title="Pause/Run Remaining Time">||</a> +<a href="#reset-remaining" onclick="opener.resetRemainingTime(); return false;" title="Reset Remaining Time">|←</a> +</form> +</div> +</div> + +<h2 id="slide">...</h2> +<div id="notes"></div> + +<h2 id="next">...</h2> +<div id="nextnotes"></div> + +</body> +</html> |
