@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * THeader3 class file |
|
| 4 | - * |
|
| 5 | - * @author Brad Anderson <[email protected]> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @package System.Web.UI.WebControls |
|
| 10 | - */ |
|
| 3 | + * THeader3 class file |
|
| 4 | + * |
|
| 5 | + * @author Brad Anderson <[email protected]> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + * @package System.Web.UI.WebControls |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * THeader3 class |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TPlaceHolder class file |
|
| 4 | - * |
|
| 5 | - * @author Qiang Xue <[email protected]> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @package System.Web.UI.WebControls |
|
| 10 | - */ |
|
| 3 | + * TPlaceHolder class file |
|
| 4 | + * |
|
| 5 | + * @author Qiang Xue <[email protected]> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + * @package System.Web.UI.WebControls |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * TPlaceHolder class |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TRequiredFieldValidator class file |
|
| 4 | - * |
|
| 5 | - * @author Qiang Xue <[email protected]> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @package System.Web.UI.WebControls |
|
| 10 | - */ |
|
| 3 | + * TRequiredFieldValidator class file |
|
| 4 | + * |
|
| 5 | + * @author Qiang Xue <[email protected]> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + * @package System.Web.UI.WebControls |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Using TBaseValidator class |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TAutoComplete class file. |
|
| 4 | - * |
|
| 5 | - * @author Wei Zhuo <weizhuo[at]gamil[dot]com> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @package System.Web.UI.ActiveControls |
|
| 10 | - */ |
|
| 3 | + * TAutoComplete class file. |
|
| 4 | + * |
|
| 5 | + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + * @package System.Web.UI.ActiveControls |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Load active text box. |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TInPlaceTextBox class file. |
|
| 4 | - * |
|
| 5 | - * @author Wei Zhuo <weizhuo[at]gamil[dot]com> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @package System.Web.UI.ActiveControls |
|
| 10 | - */ |
|
| 3 | + * TInPlaceTextBox class file. |
|
| 4 | + * |
|
| 5 | + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + * @package System.Web.UI.ActiveControls |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | Prado::using('System.Web.UI.ActiveControls.TActiveTextBox'); |
| 13 | 13 | |
@@ -1,28 +1,28 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TActiveHiddenField class file. |
|
| 4 | - * |
|
| 5 | - * @author Carl G. Mathisen <[email protected]> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @version $Id$ |
|
| 10 | - * @package System.Web.UI.ActiveControls |
|
| 11 | - */ |
|
| 3 | + * TActiveHiddenField class file. |
|
| 4 | + * |
|
| 5 | + * @author Carl G. Mathisen <[email protected]> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + * @version $Id$ |
|
| 10 | + * @package System.Web.UI.ActiveControls |
|
| 11 | + */ |
|
| 12 | 12 | Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter'); |
| 13 | 13 | /** |
| 14 | - * TActiveHiddenField class |
|
| 15 | - * |
|
| 16 | - * TActiveHiddenField displays a hidden input field on a Web page. |
|
| 17 | - * The value of the input field can be accessed via {@link getValue Value} property. |
|
| 18 | - * |
|
| 19 | - * @author Carl G. Mathisen <[email protected]> |
|
| 20 | - * @package System.Web.UI.ActiveControls |
|
| 21 | - * @since 3.1 |
|
| 22 | - */ |
|
| 14 | + * TActiveHiddenField class |
|
| 15 | + * |
|
| 16 | + * TActiveHiddenField displays a hidden input field on a Web page. |
|
| 17 | + * The value of the input field can be accessed via {@link getValue Value} property. |
|
| 18 | + * |
|
| 19 | + * @author Carl G. Mathisen <[email protected]> |
|
| 20 | + * @package System.Web.UI.ActiveControls |
|
| 21 | + * @since 3.1 |
|
| 22 | + */ |
|
| 23 | 23 | class TActiveHiddenField extends THiddenField implements ICallbackEventHandler, IActiveControl |
| 24 | 24 | { |
| 25 | - /** |
|
| 25 | + /** |
|
| 26 | 26 | * Creates a new callback control, sets the adapter to |
| 27 | 27 | * TActiveControlAdapter. If you override this class, be sure to set the |
| 28 | 28 | * adapter appropriately by, for example, by calling this constructor. |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TActiveImage class file. |
|
| 4 | - * |
|
| 5 | - * @author Wei Zhuo <weizhuo[at]gamil[dot]com> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @package System.Web.UI.ActiveControls |
|
| 10 | - */ |
|
| 3 | + * TActiveImage class file. |
|
| 4 | + * |
|
| 5 | + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + * @package System.Web.UI.ActiveControls |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * TActiveImage class. |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * THttpResponseAdatper class |
|
| 4 | - * |
|
| 5 | - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - * @version $Id$ |
|
| 10 | - * @package System.Web |
|
| 11 | - */ |
|
| 3 | + * THttpResponseAdatper class |
|
| 4 | + * |
|
| 5 | + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2005-2016 The PRADO Group |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + * @version $Id$ |
|
| 10 | + * @package System.Web |
|
| 11 | + */ |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * THttpResponseAdapter class. |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TTarFileExtractor class file |
|
| 4 | - * |
|
| 5 | - * @author Vincent Blavet <[email protected]> |
|
| 6 | - * @copyright Copyright © 1997-2003 The PHP Group |
|
| 7 | - * @package System.IO |
|
| 8 | - */ |
|
| 3 | + * TTarFileExtractor class file |
|
| 4 | + * |
|
| 5 | + * @author Vincent Blavet <[email protected]> |
|
| 6 | + * @copyright Copyright © 1997-2003 The PHP Group |
|
| 7 | + * @package System.IO |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /* vim: set ts=4 sw=4: */ |
| 11 | 11 | // +----------------------------------------------------------------------+ |
@@ -35,537 +35,537 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | class TTarFileExtractor |
| 37 | 37 | { |
| 38 | - /** |
|
| 39 | - * @var string Name of the Tar |
|
| 40 | - */ |
|
| 41 | - private $_tarname=''; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var file descriptor |
|
| 45 | - */ |
|
| 46 | - private $_file=0; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var string Local Tar name of a remote Tar (http:// or ftp://) |
|
| 50 | - */ |
|
| 51 | - private $_temp_tarname=''; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Archive_Tar Class constructor. This flavour of the constructor only |
|
| 55 | - * declare a new Archive_Tar object, identifying it by the name of the |
|
| 56 | - * tar file. |
|
| 57 | - * |
|
| 58 | - * @param string $p_tarname The name of the tar archive to create |
|
| 59 | - * @access public |
|
| 60 | - */ |
|
| 61 | - public function __construct($p_tarname) |
|
| 62 | - { |
|
| 63 | - $this->_tarname = $p_tarname; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public function __destruct() |
|
| 67 | - { |
|
| 68 | - $this->_close(); |
|
| 69 | - // ----- Look for a local copy to delete |
|
| 70 | - if ($this->_temp_tarname != '') |
|
| 71 | - @unlink($this->_temp_tarname); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - public function extract($p_path='') |
|
| 75 | - { |
|
| 76 | - return $this->extractModify($p_path, ''); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * This method extract all the content of the archive in the directory |
|
| 81 | - * indicated by $p_path. When relevant the memorized path of the |
|
| 82 | - * files/dir can be modified by removing the $p_remove_path path at the |
|
| 83 | - * beginning of the file/dir path. |
|
| 84 | - * While extracting a file, if the directory path does not exists it is |
|
| 85 | - * created. |
|
| 86 | - * While extracting a file, if the file already exists it is replaced |
|
| 87 | - * without looking for last modification date. |
|
| 88 | - * While extracting a file, if the file already exists and is write |
|
| 89 | - * protected, the extraction is aborted. |
|
| 90 | - * While extracting a file, if a directory with the same name already |
|
| 91 | - * exists, the extraction is aborted. |
|
| 92 | - * While extracting a directory, if a file with the same name already |
|
| 93 | - * exists, the extraction is aborted. |
|
| 94 | - * While extracting a file/directory if the destination directory exist |
|
| 95 | - * and is write protected, or does not exist but can not be created, |
|
| 96 | - * the extraction is aborted. |
|
| 97 | - * If after extraction an extracted file does not show the correct |
|
| 98 | - * stored file size, the extraction is aborted. |
|
| 99 | - * When the extraction is aborted, a PEAR error text is set and false |
|
| 100 | - * is returned. However the result can be a partial extraction that may |
|
| 101 | - * need to be manually cleaned. |
|
| 102 | - * |
|
| 103 | - * @param string $p_path The path of the directory where the |
|
| 104 | - * files/dir need to by extracted. |
|
| 105 | - * @param string $p_remove_path Part of the memorized path that can be |
|
| 106 | - * removed if present at the beginning of |
|
| 107 | - * the file/dir path. |
|
| 108 | - * @return boolean true on success, false on error. |
|
| 109 | - * @access public |
|
| 110 | - */ |
|
| 111 | - protected function extractModify($p_path, $p_remove_path) |
|
| 112 | - { |
|
| 113 | - $v_result = true; |
|
| 114 | - $v_list_detail = array(); |
|
| 115 | - |
|
| 116 | - if ($v_result = $this->_openRead()) { |
|
| 117 | - $v_result = $this->_extractList($p_path, $v_list_detail, |
|
| 118 | - "complete", 0, $p_remove_path); |
|
| 119 | - $this->_close(); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - return $v_result; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - protected function _error($p_message) |
|
| 126 | - { |
|
| 38 | + /** |
|
| 39 | + * @var string Name of the Tar |
|
| 40 | + */ |
|
| 41 | + private $_tarname=''; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var file descriptor |
|
| 45 | + */ |
|
| 46 | + private $_file=0; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var string Local Tar name of a remote Tar (http:// or ftp://) |
|
| 50 | + */ |
|
| 51 | + private $_temp_tarname=''; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Archive_Tar Class constructor. This flavour of the constructor only |
|
| 55 | + * declare a new Archive_Tar object, identifying it by the name of the |
|
| 56 | + * tar file. |
|
| 57 | + * |
|
| 58 | + * @param string $p_tarname The name of the tar archive to create |
|
| 59 | + * @access public |
|
| 60 | + */ |
|
| 61 | + public function __construct($p_tarname) |
|
| 62 | + { |
|
| 63 | + $this->_tarname = $p_tarname; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public function __destruct() |
|
| 67 | + { |
|
| 68 | + $this->_close(); |
|
| 69 | + // ----- Look for a local copy to delete |
|
| 70 | + if ($this->_temp_tarname != '') |
|
| 71 | + @unlink($this->_temp_tarname); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + public function extract($p_path='') |
|
| 75 | + { |
|
| 76 | + return $this->extractModify($p_path, ''); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * This method extract all the content of the archive in the directory |
|
| 81 | + * indicated by $p_path. When relevant the memorized path of the |
|
| 82 | + * files/dir can be modified by removing the $p_remove_path path at the |
|
| 83 | + * beginning of the file/dir path. |
|
| 84 | + * While extracting a file, if the directory path does not exists it is |
|
| 85 | + * created. |
|
| 86 | + * While extracting a file, if the file already exists it is replaced |
|
| 87 | + * without looking for last modification date. |
|
| 88 | + * While extracting a file, if the file already exists and is write |
|
| 89 | + * protected, the extraction is aborted. |
|
| 90 | + * While extracting a file, if a directory with the same name already |
|
| 91 | + * exists, the extraction is aborted. |
|
| 92 | + * While extracting a directory, if a file with the same name already |
|
| 93 | + * exists, the extraction is aborted. |
|
| 94 | + * While extracting a file/directory if the destination directory exist |
|
| 95 | + * and is write protected, or does not exist but can not be created, |
|
| 96 | + * the extraction is aborted. |
|
| 97 | + * If after extraction an extracted file does not show the correct |
|
| 98 | + * stored file size, the extraction is aborted. |
|
| 99 | + * When the extraction is aborted, a PEAR error text is set and false |
|
| 100 | + * is returned. However the result can be a partial extraction that may |
|
| 101 | + * need to be manually cleaned. |
|
| 102 | + * |
|
| 103 | + * @param string $p_path The path of the directory where the |
|
| 104 | + * files/dir need to by extracted. |
|
| 105 | + * @param string $p_remove_path Part of the memorized path that can be |
|
| 106 | + * removed if present at the beginning of |
|
| 107 | + * the file/dir path. |
|
| 108 | + * @return boolean true on success, false on error. |
|
| 109 | + * @access public |
|
| 110 | + */ |
|
| 111 | + protected function extractModify($p_path, $p_remove_path) |
|
| 112 | + { |
|
| 113 | + $v_result = true; |
|
| 114 | + $v_list_detail = array(); |
|
| 115 | + |
|
| 116 | + if ($v_result = $this->_openRead()) { |
|
| 117 | + $v_result = $this->_extractList($p_path, $v_list_detail, |
|
| 118 | + "complete", 0, $p_remove_path); |
|
| 119 | + $this->_close(); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + return $v_result; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + protected function _error($p_message) |
|
| 126 | + { |
|
| 127 | 127 | throw new Exception($p_message); |
| 128 | - } |
|
| 129 | - |
|
| 130 | - private function _isArchive($p_filename=null) |
|
| 131 | - { |
|
| 132 | - if ($p_filename == null) { |
|
| 133 | - $p_filename = $this->_tarname; |
|
| 134 | - } |
|
| 135 | - clearstatcache(); |
|
| 136 | - return @is_file($p_filename); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - private function _openRead() |
|
| 140 | - { |
|
| 141 | - if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') { |
|
| 142 | - |
|
| 143 | - // ----- Look if a local copy need to be done |
|
| 144 | - if ($this->_temp_tarname == '') { |
|
| 145 | - $this->_temp_tarname = uniqid('tar').'.tmp'; |
|
| 146 | - if (!$v_file_from = @fopen($this->_tarname, 'rb')) { |
|
| 147 | - $this->_error('Unable to open in read mode \'' |
|
| 148 | - .$this->_tarname.'\''); |
|
| 149 | - $this->_temp_tarname = ''; |
|
| 150 | - return false; |
|
| 151 | - } |
|
| 152 | - if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { |
|
| 153 | - $this->_error('Unable to open in write mode \'' |
|
| 154 | - .$this->_temp_tarname.'\''); |
|
| 155 | - $this->_temp_tarname = ''; |
|
| 156 | - return false; |
|
| 157 | - } |
|
| 158 | - while ($v_data = @fread($v_file_from, 1024)) |
|
| 159 | - @fwrite($v_file_to, $v_data); |
|
| 160 | - @fclose($v_file_from); |
|
| 161 | - @fclose($v_file_to); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - // ----- File to open if the local copy |
|
| 165 | - $v_filename = $this->_temp_tarname; |
|
| 166 | - |
|
| 167 | - } else |
|
| 168 | - // ----- File to open if the normal Tar file |
|
| 169 | - $v_filename = $this->_tarname; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + private function _isArchive($p_filename=null) |
|
| 131 | + { |
|
| 132 | + if ($p_filename == null) { |
|
| 133 | + $p_filename = $this->_tarname; |
|
| 134 | + } |
|
| 135 | + clearstatcache(); |
|
| 136 | + return @is_file($p_filename); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + private function _openRead() |
|
| 140 | + { |
|
| 141 | + if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') { |
|
| 142 | + |
|
| 143 | + // ----- Look if a local copy need to be done |
|
| 144 | + if ($this->_temp_tarname == '') { |
|
| 145 | + $this->_temp_tarname = uniqid('tar').'.tmp'; |
|
| 146 | + if (!$v_file_from = @fopen($this->_tarname, 'rb')) { |
|
| 147 | + $this->_error('Unable to open in read mode \'' |
|
| 148 | + .$this->_tarname.'\''); |
|
| 149 | + $this->_temp_tarname = ''; |
|
| 150 | + return false; |
|
| 151 | + } |
|
| 152 | + if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { |
|
| 153 | + $this->_error('Unable to open in write mode \'' |
|
| 154 | + .$this->_temp_tarname.'\''); |
|
| 155 | + $this->_temp_tarname = ''; |
|
| 156 | + return false; |
|
| 157 | + } |
|
| 158 | + while ($v_data = @fread($v_file_from, 1024)) |
|
| 159 | + @fwrite($v_file_to, $v_data); |
|
| 160 | + @fclose($v_file_from); |
|
| 161 | + @fclose($v_file_to); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + // ----- File to open if the local copy |
|
| 165 | + $v_filename = $this->_temp_tarname; |
|
| 166 | + |
|
| 167 | + } else |
|
| 168 | + // ----- File to open if the normal Tar file |
|
| 169 | + $v_filename = $this->_tarname; |
|
| 170 | 170 | |
| 171 | 171 | $this->_file = @fopen($v_filename, "rb"); |
| 172 | 172 | |
| 173 | - if ($this->_file == 0) { |
|
| 174 | - $this->_error('Unable to open in read mode \''.$v_filename.'\''); |
|
| 175 | - return false; |
|
| 176 | - } |
|
| 173 | + if ($this->_file == 0) { |
|
| 174 | + $this->_error('Unable to open in read mode \''.$v_filename.'\''); |
|
| 175 | + return false; |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - return true; |
|
| 179 | - } |
|
| 178 | + return true; |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - private function _close() |
|
| 182 | - { |
|
| 183 | - //if (isset($this->_file)) { |
|
| 184 | - if (is_resource($this->_file)) |
|
| 181 | + private function _close() |
|
| 182 | + { |
|
| 183 | + //if (isset($this->_file)) { |
|
| 184 | + if (is_resource($this->_file)) |
|
| 185 | 185 | { |
| 186 | - @fclose($this->_file); |
|
| 187 | - $this->_file = 0; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // ----- Look if a local copy need to be erase |
|
| 191 | - // Note that it might be interesting to keep the url for a time : ToDo |
|
| 192 | - if ($this->_temp_tarname != '') { |
|
| 193 | - @unlink($this->_temp_tarname); |
|
| 194 | - $this->_temp_tarname = ''; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - return true; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - private function _cleanFile() |
|
| 201 | - { |
|
| 202 | - $this->_close(); |
|
| 203 | - |
|
| 204 | - // ----- Look for a local copy |
|
| 205 | - if ($this->_temp_tarname != '') { |
|
| 206 | - // ----- Remove the local copy but not the remote tarname |
|
| 207 | - @unlink($this->_temp_tarname); |
|
| 208 | - $this->_temp_tarname = ''; |
|
| 209 | - } else { |
|
| 210 | - // ----- Remove the local tarname file |
|
| 211 | - @unlink($this->_tarname); |
|
| 212 | - } |
|
| 213 | - $this->_tarname = ''; |
|
| 214 | - |
|
| 215 | - return true; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - private function _readBlock() |
|
| 219 | - { |
|
| 220 | - $v_block = null; |
|
| 221 | - if (is_resource($this->_file)) { |
|
| 222 | - $v_block = @fread($this->_file, 512); |
|
| 223 | - } |
|
| 224 | - return $v_block; |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - private function _jumpBlock($p_len=null) |
|
| 228 | - { |
|
| 229 | - if (is_resource($this->_file)) { |
|
| 230 | - if ($p_len === null) |
|
| 231 | - $p_len = 1; |
|
| 232 | - |
|
| 233 | - @fseek($this->_file, @ftell($this->_file)+($p_len*512)); |
|
| 234 | - } |
|
| 235 | - return true; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - private function _readHeader($v_binary_data, &$v_header) |
|
| 239 | - { |
|
| 240 | - if (strlen($v_binary_data)==0) { |
|
| 241 | - $v_header['filename'] = ''; |
|
| 242 | - return true; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - if (strlen($v_binary_data) != 512) { |
|
| 246 | - $v_header['filename'] = ''; |
|
| 247 | - $this->_error('Invalid block size : '.strlen($v_binary_data)); |
|
| 248 | - return false; |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - // ----- Calculate the checksum |
|
| 252 | - $v_checksum = 0; |
|
| 253 | - // ..... First part of the header |
|
| 254 | - for ($i=0; $i<148; $i++) |
|
| 255 | - $v_checksum+=ord(substr($v_binary_data,$i,1)); |
|
| 256 | - // ..... Ignore the checksum value and replace it by ' ' (space) |
|
| 257 | - for ($i=148; $i<156; $i++) |
|
| 258 | - $v_checksum += ord(' '); |
|
| 259 | - // ..... Last part of the header |
|
| 260 | - for ($i=156; $i<512; $i++) |
|
| 261 | - $v_checksum+=ord(substr($v_binary_data,$i,1)); |
|
| 262 | - |
|
| 263 | - $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" |
|
| 264 | - ."a8checksum/a1typeflag/a100link/a6magic/a2version/" |
|
| 186 | + @fclose($this->_file); |
|
| 187 | + $this->_file = 0; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // ----- Look if a local copy need to be erase |
|
| 191 | + // Note that it might be interesting to keep the url for a time : ToDo |
|
| 192 | + if ($this->_temp_tarname != '') { |
|
| 193 | + @unlink($this->_temp_tarname); |
|
| 194 | + $this->_temp_tarname = ''; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + return true; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + private function _cleanFile() |
|
| 201 | + { |
|
| 202 | + $this->_close(); |
|
| 203 | + |
|
| 204 | + // ----- Look for a local copy |
|
| 205 | + if ($this->_temp_tarname != '') { |
|
| 206 | + // ----- Remove the local copy but not the remote tarname |
|
| 207 | + @unlink($this->_temp_tarname); |
|
| 208 | + $this->_temp_tarname = ''; |
|
| 209 | + } else { |
|
| 210 | + // ----- Remove the local tarname file |
|
| 211 | + @unlink($this->_tarname); |
|
| 212 | + } |
|
| 213 | + $this->_tarname = ''; |
|
| 214 | + |
|
| 215 | + return true; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + private function _readBlock() |
|
| 219 | + { |
|
| 220 | + $v_block = null; |
|
| 221 | + if (is_resource($this->_file)) { |
|
| 222 | + $v_block = @fread($this->_file, 512); |
|
| 223 | + } |
|
| 224 | + return $v_block; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + private function _jumpBlock($p_len=null) |
|
| 228 | + { |
|
| 229 | + if (is_resource($this->_file)) { |
|
| 230 | + if ($p_len === null) |
|
| 231 | + $p_len = 1; |
|
| 232 | + |
|
| 233 | + @fseek($this->_file, @ftell($this->_file)+($p_len*512)); |
|
| 234 | + } |
|
| 235 | + return true; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + private function _readHeader($v_binary_data, &$v_header) |
|
| 239 | + { |
|
| 240 | + if (strlen($v_binary_data)==0) { |
|
| 241 | + $v_header['filename'] = ''; |
|
| 242 | + return true; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + if (strlen($v_binary_data) != 512) { |
|
| 246 | + $v_header['filename'] = ''; |
|
| 247 | + $this->_error('Invalid block size : '.strlen($v_binary_data)); |
|
| 248 | + return false; |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + // ----- Calculate the checksum |
|
| 252 | + $v_checksum = 0; |
|
| 253 | + // ..... First part of the header |
|
| 254 | + for ($i=0; $i<148; $i++) |
|
| 255 | + $v_checksum+=ord(substr($v_binary_data,$i,1)); |
|
| 256 | + // ..... Ignore the checksum value and replace it by ' ' (space) |
|
| 257 | + for ($i=148; $i<156; $i++) |
|
| 258 | + $v_checksum += ord(' '); |
|
| 259 | + // ..... Last part of the header |
|
| 260 | + for ($i=156; $i<512; $i++) |
|
| 261 | + $v_checksum+=ord(substr($v_binary_data,$i,1)); |
|
| 262 | + |
|
| 263 | + $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/" |
|
| 264 | + ."a8checksum/a1typeflag/a100link/a6magic/a2version/" |
|
| 265 | 265 | ."a32uname/a32gname/a8devmajor/a8devminor", |
| 266 | 266 | $v_binary_data); |
| 267 | 267 | |
| 268 | - // ----- Extract the checksum |
|
| 269 | - $v_header['checksum'] = OctDec(trim($v_data['checksum'])); |
|
| 270 | - if ($v_header['checksum'] != $v_checksum) { |
|
| 271 | - $v_header['filename'] = ''; |
|
| 268 | + // ----- Extract the checksum |
|
| 269 | + $v_header['checksum'] = OctDec(trim($v_data['checksum'])); |
|
| 270 | + if ($v_header['checksum'] != $v_checksum) { |
|
| 271 | + $v_header['filename'] = ''; |
|
| 272 | 272 | |
| 273 | - // ----- Look for last block (empty block) |
|
| 274 | - if (($v_checksum == 256) && ($v_header['checksum'] == 0)) |
|
| 275 | - return true; |
|
| 273 | + // ----- Look for last block (empty block) |
|
| 274 | + if (($v_checksum == 256) && ($v_header['checksum'] == 0)) |
|
| 275 | + return true; |
|
| 276 | 276 | |
| 277 | - $this->_error('Invalid checksum for file "'.$v_data['filename'] |
|
| 278 | - .'" : '.$v_checksum.' calculated, ' |
|
| 277 | + $this->_error('Invalid checksum for file "'.$v_data['filename'] |
|
| 278 | + .'" : '.$v_checksum.' calculated, ' |
|
| 279 | 279 | .$v_header['checksum'].' expected'); |
| 280 | - return false; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - // ----- Extract the properties |
|
| 284 | - $v_header['filename'] = trim($v_data['filename']); |
|
| 285 | - $v_header['mode'] = OctDec(trim($v_data['mode'])); |
|
| 286 | - $v_header['uid'] = OctDec(trim($v_data['uid'])); |
|
| 287 | - $v_header['gid'] = OctDec(trim($v_data['gid'])); |
|
| 288 | - $v_header['size'] = OctDec(trim($v_data['size'])); |
|
| 289 | - $v_header['mtime'] = OctDec(trim($v_data['mtime'])); |
|
| 290 | - if (($v_header['typeflag'] = $v_data['typeflag']) == "5") { |
|
| 291 | - $v_header['size'] = 0; |
|
| 292 | - } |
|
| 293 | - return true; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - private function _readLongHeader(&$v_header) |
|
| 297 | - { |
|
| 298 | - $v_filename = ''; |
|
| 299 | - $n = floor($v_header['size']/512); |
|
| 300 | - for ($i=0; $i<$n; $i++) { |
|
| 301 | - $v_content = $this->_readBlock(); |
|
| 302 | - $v_filename .= $v_content; |
|
| 303 | - } |
|
| 304 | - if (($v_header['size'] % 512) != 0) { |
|
| 305 | - $v_content = $this->_readBlock(); |
|
| 306 | - $v_filename .= $v_content; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - // ----- Read the next header |
|
| 310 | - $v_binary_data = $this->_readBlock(); |
|
| 311 | - |
|
| 312 | - if (!$this->_readHeader($v_binary_data, $v_header)) |
|
| 313 | - return false; |
|
| 314 | - |
|
| 315 | - $v_header['filename'] = $v_filename; |
|
| 316 | - |
|
| 317 | - return true; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - protected function _extractList($p_path, &$p_list_detail, $p_mode, |
|
| 321 | - $p_file_list, $p_remove_path) |
|
| 322 | - { |
|
| 323 | - $v_result=true; |
|
| 324 | - $v_nb = 0; |
|
| 325 | - $v_extract_all = true; |
|
| 326 | - $v_listing = false; |
|
| 327 | - |
|
| 328 | - $p_path = $this->_translateWinPath($p_path, false); |
|
| 329 | - if ($p_path == '' || (substr($p_path, 0, 1) != '/' |
|
| 330 | - && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { |
|
| 331 | - $p_path = "./".$p_path; |
|
| 332 | - } |
|
| 333 | - $p_remove_path = $this->_translateWinPath($p_remove_path); |
|
| 334 | - |
|
| 335 | - // ----- Look for path to remove format (should end by /) |
|
| 336 | - if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) |
|
| 337 | - $p_remove_path .= '/'; |
|
| 338 | - $p_remove_path_size = strlen($p_remove_path); |
|
| 339 | - |
|
| 340 | - switch ($p_mode) { |
|
| 341 | - case "complete" : |
|
| 342 | - $v_extract_all = true; |
|
| 343 | - $v_listing = false; |
|
| 344 | - break; |
|
| 345 | - case "partial" : |
|
| 346 | - $v_extract_all = false; |
|
| 347 | - $v_listing = false; |
|
| 348 | - break; |
|
| 349 | - case "list" : |
|
| 350 | - $v_extract_all = false; |
|
| 351 | - $v_listing = true; |
|
| 352 | - break; |
|
| 353 | - default : |
|
| 354 | - $this->_error('Invalid extract mode ('.$p_mode.')'); |
|
| 355 | - return false; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - clearstatcache(); |
|
| 359 | - |
|
| 360 | - while (strlen($v_binary_data = $this->_readBlock()) != 0) |
|
| 361 | - { |
|
| 362 | - $v_extract_file = false; |
|
| 363 | - $v_extraction_stopped = 0; |
|
| 364 | - |
|
| 365 | - if (!$this->_readHeader($v_binary_data, $v_header)) |
|
| 366 | - return false; |
|
| 367 | - |
|
| 368 | - if ($v_header['filename'] == '') { |
|
| 369 | - continue; |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - // ----- Look for long filename |
|
| 373 | - if ($v_header['typeflag'] == 'L') { |
|
| 374 | - if (!$this->_readLongHeader($v_header)) |
|
| 375 | - return false; |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - if ((!$v_extract_all) && (is_array($p_file_list))) { |
|
| 379 | - // ----- By default no unzip if the file is not found |
|
| 380 | - $v_extract_file = false; |
|
| 381 | - |
|
| 382 | - for ($i=0; $i<sizeof($p_file_list); $i++) { |
|
| 383 | - // ----- Look if it is a directory |
|
| 384 | - if (substr($p_file_list[$i], -1) == '/') { |
|
| 385 | - // ----- Look if the directory is in the filename path |
|
| 386 | - if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) |
|
| 387 | - && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) |
|
| 388 | - == $p_file_list[$i])) { |
|
| 389 | - $v_extract_file = true; |
|
| 390 | - break; |
|
| 391 | - } |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - // ----- It is a file, so compare the file names |
|
| 395 | - elseif ($p_file_list[$i] == $v_header['filename']) { |
|
| 396 | - $v_extract_file = true; |
|
| 397 | - break; |
|
| 398 | - } |
|
| 399 | - } |
|
| 400 | - } else { |
|
| 401 | - $v_extract_file = true; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - // ----- Look if this file need to be extracted |
|
| 405 | - if (($v_extract_file) && (!$v_listing)) |
|
| 406 | - { |
|
| 407 | - if (($p_remove_path != '') |
|
| 408 | - && (substr($v_header['filename'], 0, $p_remove_path_size) |
|
| 409 | - == $p_remove_path)) |
|
| 410 | - $v_header['filename'] = substr($v_header['filename'], |
|
| 411 | - $p_remove_path_size); |
|
| 412 | - if (($p_path != './') && ($p_path != '/')) { |
|
| 413 | - while (substr($p_path, -1) == '/') |
|
| 414 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 415 | - |
|
| 416 | - if (substr($v_header['filename'], 0, 1) == '/') |
|
| 417 | - $v_header['filename'] = $p_path.$v_header['filename']; |
|
| 418 | - else |
|
| 419 | - $v_header['filename'] = $p_path.'/'.$v_header['filename']; |
|
| 420 | - } |
|
| 421 | - if (file_exists($v_header['filename'])) { |
|
| 422 | - if ( (@is_dir($v_header['filename'])) |
|
| 423 | - && ($v_header['typeflag'] == '')) { |
|
| 424 | - $this->_error('File '.$v_header['filename'] |
|
| 425 | - .' already exists as a directory'); |
|
| 426 | - return false; |
|
| 427 | - } |
|
| 428 | - if ( ($this->_isArchive($v_header['filename'])) |
|
| 429 | - && ($v_header['typeflag'] == "5")) { |
|
| 430 | - $this->_error('Directory '.$v_header['filename'] |
|
| 431 | - .' already exists as a file'); |
|
| 432 | - return false; |
|
| 433 | - } |
|
| 434 | - if (!is_writeable($v_header['filename'])) { |
|
| 435 | - $this->_error('File '.$v_header['filename'] |
|
| 436 | - .' already exists and is write protected'); |
|
| 437 | - return false; |
|
| 438 | - } |
|
| 439 | - if (filemtime($v_header['filename']) > $v_header['mtime']) { |
|
| 440 | - // To be completed : An error or silent no replace ? |
|
| 441 | - } |
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - // ----- Check the directory availability and create it if necessary |
|
| 445 | - elseif (($v_result |
|
| 446 | - = $this->_dirCheck(($v_header['typeflag'] == "5" |
|
| 447 | - ?$v_header['filename'] |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + // ----- Extract the properties |
|
| 284 | + $v_header['filename'] = trim($v_data['filename']); |
|
| 285 | + $v_header['mode'] = OctDec(trim($v_data['mode'])); |
|
| 286 | + $v_header['uid'] = OctDec(trim($v_data['uid'])); |
|
| 287 | + $v_header['gid'] = OctDec(trim($v_data['gid'])); |
|
| 288 | + $v_header['size'] = OctDec(trim($v_data['size'])); |
|
| 289 | + $v_header['mtime'] = OctDec(trim($v_data['mtime'])); |
|
| 290 | + if (($v_header['typeflag'] = $v_data['typeflag']) == "5") { |
|
| 291 | + $v_header['size'] = 0; |
|
| 292 | + } |
|
| 293 | + return true; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + private function _readLongHeader(&$v_header) |
|
| 297 | + { |
|
| 298 | + $v_filename = ''; |
|
| 299 | + $n = floor($v_header['size']/512); |
|
| 300 | + for ($i=0; $i<$n; $i++) { |
|
| 301 | + $v_content = $this->_readBlock(); |
|
| 302 | + $v_filename .= $v_content; |
|
| 303 | + } |
|
| 304 | + if (($v_header['size'] % 512) != 0) { |
|
| 305 | + $v_content = $this->_readBlock(); |
|
| 306 | + $v_filename .= $v_content; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + // ----- Read the next header |
|
| 310 | + $v_binary_data = $this->_readBlock(); |
|
| 311 | + |
|
| 312 | + if (!$this->_readHeader($v_binary_data, $v_header)) |
|
| 313 | + return false; |
|
| 314 | + |
|
| 315 | + $v_header['filename'] = $v_filename; |
|
| 316 | + |
|
| 317 | + return true; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + protected function _extractList($p_path, &$p_list_detail, $p_mode, |
|
| 321 | + $p_file_list, $p_remove_path) |
|
| 322 | + { |
|
| 323 | + $v_result=true; |
|
| 324 | + $v_nb = 0; |
|
| 325 | + $v_extract_all = true; |
|
| 326 | + $v_listing = false; |
|
| 327 | + |
|
| 328 | + $p_path = $this->_translateWinPath($p_path, false); |
|
| 329 | + if ($p_path == '' || (substr($p_path, 0, 1) != '/' |
|
| 330 | + && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { |
|
| 331 | + $p_path = "./".$p_path; |
|
| 332 | + } |
|
| 333 | + $p_remove_path = $this->_translateWinPath($p_remove_path); |
|
| 334 | + |
|
| 335 | + // ----- Look for path to remove format (should end by /) |
|
| 336 | + if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) |
|
| 337 | + $p_remove_path .= '/'; |
|
| 338 | + $p_remove_path_size = strlen($p_remove_path); |
|
| 339 | + |
|
| 340 | + switch ($p_mode) { |
|
| 341 | + case "complete" : |
|
| 342 | + $v_extract_all = true; |
|
| 343 | + $v_listing = false; |
|
| 344 | + break; |
|
| 345 | + case "partial" : |
|
| 346 | + $v_extract_all = false; |
|
| 347 | + $v_listing = false; |
|
| 348 | + break; |
|
| 349 | + case "list" : |
|
| 350 | + $v_extract_all = false; |
|
| 351 | + $v_listing = true; |
|
| 352 | + break; |
|
| 353 | + default : |
|
| 354 | + $this->_error('Invalid extract mode ('.$p_mode.')'); |
|
| 355 | + return false; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + clearstatcache(); |
|
| 359 | + |
|
| 360 | + while (strlen($v_binary_data = $this->_readBlock()) != 0) |
|
| 361 | + { |
|
| 362 | + $v_extract_file = false; |
|
| 363 | + $v_extraction_stopped = 0; |
|
| 364 | + |
|
| 365 | + if (!$this->_readHeader($v_binary_data, $v_header)) |
|
| 366 | + return false; |
|
| 367 | + |
|
| 368 | + if ($v_header['filename'] == '') { |
|
| 369 | + continue; |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + // ----- Look for long filename |
|
| 373 | + if ($v_header['typeflag'] == 'L') { |
|
| 374 | + if (!$this->_readLongHeader($v_header)) |
|
| 375 | + return false; |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + if ((!$v_extract_all) && (is_array($p_file_list))) { |
|
| 379 | + // ----- By default no unzip if the file is not found |
|
| 380 | + $v_extract_file = false; |
|
| 381 | + |
|
| 382 | + for ($i=0; $i<sizeof($p_file_list); $i++) { |
|
| 383 | + // ----- Look if it is a directory |
|
| 384 | + if (substr($p_file_list[$i], -1) == '/') { |
|
| 385 | + // ----- Look if the directory is in the filename path |
|
| 386 | + if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) |
|
| 387 | + && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) |
|
| 388 | + == $p_file_list[$i])) { |
|
| 389 | + $v_extract_file = true; |
|
| 390 | + break; |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + // ----- It is a file, so compare the file names |
|
| 395 | + elseif ($p_file_list[$i] == $v_header['filename']) { |
|
| 396 | + $v_extract_file = true; |
|
| 397 | + break; |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + } else { |
|
| 401 | + $v_extract_file = true; |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + // ----- Look if this file need to be extracted |
|
| 405 | + if (($v_extract_file) && (!$v_listing)) |
|
| 406 | + { |
|
| 407 | + if (($p_remove_path != '') |
|
| 408 | + && (substr($v_header['filename'], 0, $p_remove_path_size) |
|
| 409 | + == $p_remove_path)) |
|
| 410 | + $v_header['filename'] = substr($v_header['filename'], |
|
| 411 | + $p_remove_path_size); |
|
| 412 | + if (($p_path != './') && ($p_path != '/')) { |
|
| 413 | + while (substr($p_path, -1) == '/') |
|
| 414 | + $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 415 | + |
|
| 416 | + if (substr($v_header['filename'], 0, 1) == '/') |
|
| 417 | + $v_header['filename'] = $p_path.$v_header['filename']; |
|
| 418 | + else |
|
| 419 | + $v_header['filename'] = $p_path.'/'.$v_header['filename']; |
|
| 420 | + } |
|
| 421 | + if (file_exists($v_header['filename'])) { |
|
| 422 | + if ( (@is_dir($v_header['filename'])) |
|
| 423 | + && ($v_header['typeflag'] == '')) { |
|
| 424 | + $this->_error('File '.$v_header['filename'] |
|
| 425 | + .' already exists as a directory'); |
|
| 426 | + return false; |
|
| 427 | + } |
|
| 428 | + if ( ($this->_isArchive($v_header['filename'])) |
|
| 429 | + && ($v_header['typeflag'] == "5")) { |
|
| 430 | + $this->_error('Directory '.$v_header['filename'] |
|
| 431 | + .' already exists as a file'); |
|
| 432 | + return false; |
|
| 433 | + } |
|
| 434 | + if (!is_writeable($v_header['filename'])) { |
|
| 435 | + $this->_error('File '.$v_header['filename'] |
|
| 436 | + .' already exists and is write protected'); |
|
| 437 | + return false; |
|
| 438 | + } |
|
| 439 | + if (filemtime($v_header['filename']) > $v_header['mtime']) { |
|
| 440 | + // To be completed : An error or silent no replace ? |
|
| 441 | + } |
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + // ----- Check the directory availability and create it if necessary |
|
| 445 | + elseif (($v_result |
|
| 446 | + = $this->_dirCheck(($v_header['typeflag'] == "5" |
|
| 447 | + ?$v_header['filename'] |
|
| 448 | 448 | :dirname($v_header['filename'])))) != 1) { |
| 449 | - $this->_error('Unable to create path for '.$v_header['filename']); |
|
| 450 | - return false; |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - if ($v_extract_file) { |
|
| 454 | - if ($v_header['typeflag'] == "5") { |
|
| 455 | - if (!@file_exists($v_header['filename'])) { |
|
| 456 | - if (!@mkdir($v_header['filename'], PRADO_CHMOD)) { |
|
| 457 | - $this->_error('Unable to create directory {' |
|
| 458 | - .$v_header['filename'].'}'); |
|
| 459 | - return false; |
|
| 460 | - } |
|
| 461 | - chmod($v_header['filename'], PRADO_CHMOD); |
|
| 462 | - } |
|
| 463 | - } else { |
|
| 464 | - if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { |
|
| 465 | - $this->_error('Error while opening {'.$v_header['filename'] |
|
| 466 | - .'} in write binary mode'); |
|
| 467 | - return false; |
|
| 468 | - } else { |
|
| 469 | - $n = floor($v_header['size']/512); |
|
| 470 | - for ($i=0; $i<$n; $i++) { |
|
| 471 | - $v_content = $this->_readBlock(); |
|
| 472 | - fwrite($v_dest_file, $v_content, 512); |
|
| 473 | - } |
|
| 474 | - if (($v_header['size'] % 512) != 0) { |
|
| 475 | - $v_content = $this->_readBlock(); |
|
| 476 | - fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - @fclose($v_dest_file); |
|
| 480 | - |
|
| 481 | - // ----- Change the file mode, mtime |
|
| 482 | - @touch($v_header['filename'], $v_header['mtime']); |
|
| 483 | - // To be completed |
|
| 484 | - //chmod($v_header[filename], DecOct($v_header[mode])); |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - // ----- Check the file size |
|
| 488 | - clearstatcache(); |
|
| 489 | - if (filesize($v_header['filename']) != $v_header['size']) { |
|
| 490 | - $this->_error('Extracted file '.$v_header['filename'] |
|
| 491 | - .' does not have the correct file size \'' |
|
| 449 | + $this->_error('Unable to create path for '.$v_header['filename']); |
|
| 450 | + return false; |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + if ($v_extract_file) { |
|
| 454 | + if ($v_header['typeflag'] == "5") { |
|
| 455 | + if (!@file_exists($v_header['filename'])) { |
|
| 456 | + if (!@mkdir($v_header['filename'], PRADO_CHMOD)) { |
|
| 457 | + $this->_error('Unable to create directory {' |
|
| 458 | + .$v_header['filename'].'}'); |
|
| 459 | + return false; |
|
| 460 | + } |
|
| 461 | + chmod($v_header['filename'], PRADO_CHMOD); |
|
| 462 | + } |
|
| 463 | + } else { |
|
| 464 | + if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { |
|
| 465 | + $this->_error('Error while opening {'.$v_header['filename'] |
|
| 466 | + .'} in write binary mode'); |
|
| 467 | + return false; |
|
| 468 | + } else { |
|
| 469 | + $n = floor($v_header['size']/512); |
|
| 470 | + for ($i=0; $i<$n; $i++) { |
|
| 471 | + $v_content = $this->_readBlock(); |
|
| 472 | + fwrite($v_dest_file, $v_content, 512); |
|
| 473 | + } |
|
| 474 | + if (($v_header['size'] % 512) != 0) { |
|
| 475 | + $v_content = $this->_readBlock(); |
|
| 476 | + fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + @fclose($v_dest_file); |
|
| 480 | + |
|
| 481 | + // ----- Change the file mode, mtime |
|
| 482 | + @touch($v_header['filename'], $v_header['mtime']); |
|
| 483 | + // To be completed |
|
| 484 | + //chmod($v_header[filename], DecOct($v_header[mode])); |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + // ----- Check the file size |
|
| 488 | + clearstatcache(); |
|
| 489 | + if (filesize($v_header['filename']) != $v_header['size']) { |
|
| 490 | + $this->_error('Extracted file '.$v_header['filename'] |
|
| 491 | + .' does not have the correct file size \'' |
|
| 492 | 492 | .filesize($v_header['filename']) |
| 493 | 493 | .'\' ('.$v_header['size'] |
| 494 | 494 | .' expected). Archive may be corrupted.'); |
| 495 | - return false; |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - } else { |
|
| 499 | - $this->_jumpBlock(ceil(($v_header['size']/512))); |
|
| 500 | - } |
|
| 501 | - } else { |
|
| 502 | - $this->_jumpBlock(ceil(($v_header['size']/512))); |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - /* TBC : Seems to be unused ... |
|
| 495 | + return false; |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + } else { |
|
| 499 | + $this->_jumpBlock(ceil(($v_header['size']/512))); |
|
| 500 | + } |
|
| 501 | + } else { |
|
| 502 | + $this->_jumpBlock(ceil(($v_header['size']/512))); |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + /* TBC : Seems to be unused ... |
|
| 506 | 506 | if ($this->_compress) |
| 507 | 507 | $v_end_of_file = @gzeof($this->_file); |
| 508 | 508 | else |
| 509 | 509 | $v_end_of_file = @feof($this->_file); |
| 510 | 510 | */ |
| 511 | 511 | |
| 512 | - if ($v_listing || $v_extract_file || $v_extraction_stopped) { |
|
| 513 | - // ----- Log extracted files |
|
| 514 | - if (($v_file_dir = dirname($v_header['filename'])) |
|
| 515 | - == $v_header['filename']) |
|
| 516 | - $v_file_dir = ''; |
|
| 517 | - if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) |
|
| 518 | - $v_file_dir = '/'; |
|
| 519 | - |
|
| 520 | - $p_list_detail[$v_nb++] = $v_header; |
|
| 521 | - } |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - return true; |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - /** |
|
| 528 | - * Check if a directory exists and create it (including parent |
|
| 529 | - * dirs) if not. |
|
| 530 | - * |
|
| 531 | - * @param string $p_dir directory to check |
|
| 532 | - * |
|
| 533 | - * @return bool true if the directory exists or was created |
|
| 534 | - */ |
|
| 535 | - protected function _dirCheck($p_dir) |
|
| 536 | - { |
|
| 537 | - if ((@is_dir($p_dir)) || ($p_dir == '')) |
|
| 538 | - return true; |
|
| 539 | - |
|
| 540 | - $p_parent_dir = dirname($p_dir); |
|
| 541 | - |
|
| 542 | - if (($p_parent_dir != $p_dir) && |
|
| 543 | - ($p_parent_dir != '') && |
|
| 544 | - (!$this->_dirCheck($p_parent_dir))) |
|
| 545 | - return false; |
|
| 546 | - |
|
| 547 | - if (!@mkdir($p_dir, PRADO_CHMOD)) { |
|
| 548 | - $this->_error("Unable to create directory '$p_dir'"); |
|
| 549 | - return false; |
|
| 550 | - } |
|
| 551 | - chmod($p_dir,PRADO_CHMOD); |
|
| 552 | - |
|
| 553 | - return true; |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - protected function _translateWinPath($p_path, $p_remove_disk_letter=true) |
|
| 557 | - { |
|
| 558 | - if (substr(PHP_OS, 0, 3) == 'WIN') { |
|
| 559 | - // ----- Look for potential disk letter |
|
| 560 | - if ( ($p_remove_disk_letter) |
|
| 561 | - && (($v_position = strpos($p_path, ':')) != false)) { |
|
| 562 | - $p_path = substr($p_path, $v_position+1); |
|
| 563 | - } |
|
| 564 | - // ----- Change potential windows directory separator |
|
| 565 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { |
|
| 566 | - $p_path = strtr($p_path, '\\', '/'); |
|
| 567 | - } |
|
| 568 | - } |
|
| 569 | - return $p_path; |
|
| 570 | - } |
|
| 512 | + if ($v_listing || $v_extract_file || $v_extraction_stopped) { |
|
| 513 | + // ----- Log extracted files |
|
| 514 | + if (($v_file_dir = dirname($v_header['filename'])) |
|
| 515 | + == $v_header['filename']) |
|
| 516 | + $v_file_dir = ''; |
|
| 517 | + if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) |
|
| 518 | + $v_file_dir = '/'; |
|
| 519 | + |
|
| 520 | + $p_list_detail[$v_nb++] = $v_header; |
|
| 521 | + } |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + return true; |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + /** |
|
| 528 | + * Check if a directory exists and create it (including parent |
|
| 529 | + * dirs) if not. |
|
| 530 | + * |
|
| 531 | + * @param string $p_dir directory to check |
|
| 532 | + * |
|
| 533 | + * @return bool true if the directory exists or was created |
|
| 534 | + */ |
|
| 535 | + protected function _dirCheck($p_dir) |
|
| 536 | + { |
|
| 537 | + if ((@is_dir($p_dir)) || ($p_dir == '')) |
|
| 538 | + return true; |
|
| 539 | + |
|
| 540 | + $p_parent_dir = dirname($p_dir); |
|
| 541 | + |
|
| 542 | + if (($p_parent_dir != $p_dir) && |
|
| 543 | + ($p_parent_dir != '') && |
|
| 544 | + (!$this->_dirCheck($p_parent_dir))) |
|
| 545 | + return false; |
|
| 546 | + |
|
| 547 | + if (!@mkdir($p_dir, PRADO_CHMOD)) { |
|
| 548 | + $this->_error("Unable to create directory '$p_dir'"); |
|
| 549 | + return false; |
|
| 550 | + } |
|
| 551 | + chmod($p_dir,PRADO_CHMOD); |
|
| 552 | + |
|
| 553 | + return true; |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + protected function _translateWinPath($p_path, $p_remove_disk_letter=true) |
|
| 557 | + { |
|
| 558 | + if (substr(PHP_OS, 0, 3) == 'WIN') { |
|
| 559 | + // ----- Look for potential disk letter |
|
| 560 | + if ( ($p_remove_disk_letter) |
|
| 561 | + && (($v_position = strpos($p_path, ':')) != false)) { |
|
| 562 | + $p_path = substr($p_path, $v_position+1); |
|
| 563 | + } |
|
| 564 | + // ----- Change potential windows directory separator |
|
| 565 | + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { |
|
| 566 | + $p_path = strtr($p_path, '\\', '/'); |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | + return $p_path; |
|
| 570 | + } |
|
| 571 | 571 | } |