@@ -22,7 +22,7 @@ |
||
22 | 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. |
@@ -60,8 +60,8 @@ |
||
60 | 60 | * @param THtmlWriter the writer used for the rendering purpose |
61 | 61 | */ |
62 | 62 | protected function addAttributesToRender($writer) { |
63 | - $writer->addAttribute('id',$this->getClientID()); |
|
64 | - parent::addAttributesToRender($writer); |
|
63 | + $writer->addAttribute('id',$this->getClientID()); |
|
64 | + parent::addAttributesToRender($writer); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -116,7 +116,7 @@ |
||
116 | 116 | && $this->getPage()->getClientSupportsJavaScript()) |
117 | 117 | { |
118 | 118 | $this->getActiveControl()->registerCallbackClientScript( |
119 | - $this->getClientClassName(), $this->getPostBackOptions()); |
|
119 | + $this->getClientClassName(), $this->getPostBackOptions()); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 |
@@ -238,90 +238,90 @@ |
||
238 | 238 | parent::initRecursive($namingContainer); |
239 | 239 | } |
240 | 240 | |
241 | - /** |
|
242 | - * Function to update view controls with data in a given AR object. |
|
243 | - * View controls and AR object need to have the same name in IDs and Attrs respectively. |
|
244 | - * @param TActiveRecord $arObj |
|
245 | - * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
246 | - * @author Daniel Sampedro <[email protected]> |
|
247 | - */ |
|
248 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
249 | - { |
|
250 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
251 | - foreach (array_keys($objAttrs) as $key) |
|
252 | - { |
|
253 | - try |
|
254 | - { |
|
255 | - if ($key != "RELATIONS") |
|
256 | - { |
|
257 | - $control = $this->{$key}; |
|
258 | - if ($control instanceof TTextBox) |
|
259 | - $control->Text = $arObj->{$key}; |
|
260 | - elseif ($control instanceof TCheckBox) |
|
261 | - $control->Checked = (boolean) $arObj->{$key}; |
|
262 | - elseif ($control instanceof TDatePicker) |
|
263 | - $control->Date = $arObj->{$key}; |
|
264 | - } |
|
265 | - else |
|
266 | - { |
|
267 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
268 | - { |
|
269 | - $relControl = $this->{$relKey}; |
|
270 | - switch ($relValues[0]) |
|
271 | - { |
|
272 | - case TActiveRecord::BELONGS_TO: |
|
273 | - case TActiveRecord::HAS_ONE: |
|
274 | - $relControl->Text = $arObj->{$relKey}; |
|
275 | - break; |
|
276 | - case TActiveRecord::HAS_MANY: |
|
277 | - if ($relControl instanceof TListControl) |
|
278 | - { |
|
279 | - $relControl->DataSource = $arObj->{$relKey}; |
|
280 | - $relControl->dataBind(); |
|
281 | - } |
|
282 | - break; |
|
283 | - } |
|
284 | - } |
|
285 | - break; |
|
286 | - } |
|
287 | - } |
|
288 | - catch (Exception $ex) |
|
289 | - { |
|
290 | - if ($throwExceptions) |
|
291 | - throw $ex; |
|
292 | - } |
|
293 | - } |
|
294 | - } |
|
241 | + /** |
|
242 | + * Function to update view controls with data in a given AR object. |
|
243 | + * View controls and AR object need to have the same name in IDs and Attrs respectively. |
|
244 | + * @param TActiveRecord $arObj |
|
245 | + * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
246 | + * @author Daniel Sampedro <[email protected]> |
|
247 | + */ |
|
248 | + public function tryToUpdateView($arObj, $throwExceptions = false) |
|
249 | + { |
|
250 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
251 | + foreach (array_keys($objAttrs) as $key) |
|
252 | + { |
|
253 | + try |
|
254 | + { |
|
255 | + if ($key != "RELATIONS") |
|
256 | + { |
|
257 | + $control = $this->{$key}; |
|
258 | + if ($control instanceof TTextBox) |
|
259 | + $control->Text = $arObj->{$key}; |
|
260 | + elseif ($control instanceof TCheckBox) |
|
261 | + $control->Checked = (boolean) $arObj->{$key}; |
|
262 | + elseif ($control instanceof TDatePicker) |
|
263 | + $control->Date = $arObj->{$key}; |
|
264 | + } |
|
265 | + else |
|
266 | + { |
|
267 | + foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
268 | + { |
|
269 | + $relControl = $this->{$relKey}; |
|
270 | + switch ($relValues[0]) |
|
271 | + { |
|
272 | + case TActiveRecord::BELONGS_TO: |
|
273 | + case TActiveRecord::HAS_ONE: |
|
274 | + $relControl->Text = $arObj->{$relKey}; |
|
275 | + break; |
|
276 | + case TActiveRecord::HAS_MANY: |
|
277 | + if ($relControl instanceof TListControl) |
|
278 | + { |
|
279 | + $relControl->DataSource = $arObj->{$relKey}; |
|
280 | + $relControl->dataBind(); |
|
281 | + } |
|
282 | + break; |
|
283 | + } |
|
284 | + } |
|
285 | + break; |
|
286 | + } |
|
287 | + } |
|
288 | + catch (Exception $ex) |
|
289 | + { |
|
290 | + if ($throwExceptions) |
|
291 | + throw $ex; |
|
292 | + } |
|
293 | + } |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
297 | - * Function to try to update an AR object with data in view controls. |
|
298 | - * @param TActiveRecord $arObj |
|
299 | - * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
300 | - * @author Daniel Sampedro <[email protected]> |
|
301 | - */ |
|
302 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
303 | - { |
|
304 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
305 | - foreach (array_keys($objAttrs) as $key) |
|
306 | - { |
|
307 | - try |
|
308 | - { |
|
309 | - if ($key == "RELATIONS") |
|
310 | - break; |
|
311 | - $control = $this->{$key}; |
|
312 | - if ($control instanceof TTextBox) |
|
313 | - $arObj->{$key} = $control->Text; |
|
314 | - elseif ($control instanceof TCheckBox) |
|
315 | - $arObj->{$key} = $control->Checked; |
|
316 | - elseif ($control instanceof TDatePicker) |
|
317 | - $arObj->{$key} = $control->Date; |
|
318 | - } |
|
319 | - catch (Exception $ex) |
|
320 | - { |
|
321 | - if ($throwExceptions) |
|
322 | - throw $ex; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
296 | + /** |
|
297 | + * Function to try to update an AR object with data in view controls. |
|
298 | + * @param TActiveRecord $arObj |
|
299 | + * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
300 | + * @author Daniel Sampedro <[email protected]> |
|
301 | + */ |
|
302 | + public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
303 | + { |
|
304 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
305 | + foreach (array_keys($objAttrs) as $key) |
|
306 | + { |
|
307 | + try |
|
308 | + { |
|
309 | + if ($key == "RELATIONS") |
|
310 | + break; |
|
311 | + $control = $this->{$key}; |
|
312 | + if ($control instanceof TTextBox) |
|
313 | + $arObj->{$key} = $control->Text; |
|
314 | + elseif ($control instanceof TCheckBox) |
|
315 | + $arObj->{$key} = $control->Checked; |
|
316 | + elseif ($control instanceof TDatePicker) |
|
317 | + $arObj->{$key} = $control->Date; |
|
318 | + } |
|
319 | + catch (Exception $ex) |
|
320 | + { |
|
321 | + if ($throwExceptions) |
|
322 | + throw $ex; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | 326 | } |
327 | 327 |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * It reads the CacheModule property. |
51 | 51 | * @param TXmlElement module configuration |
52 | 52 | */ |
53 | - public function init($config) |
|
54 | - { |
|
53 | + public function init($config) |
|
54 | + { |
|
55 | 55 | if($this->_cacheModuleID==='') |
56 | 56 | throw new TConfigurationException('cachesession_cachemoduleid_required'); |
57 | 57 | else if(($cache=$this->getApplication()->getModule($this->_cacheModuleID))===null) |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | throw new TConfigurationException('cachesession_cachemodule_invalid',$this->_cacheModuleID); |
63 | 63 | $this->setUseCustomStorage(true); |
64 | 64 | parent::init($config); |
65 | - } |
|
65 | + } |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @return string the ID of the cache module. |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function _read($id) |
97 | 97 | { |
98 | - return $this->_cache->get($this->calculateKey($id)); |
|
98 | + return $this->_cache->get($this->calculateKey($id)); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function _destroy($id) |
119 | 119 | { |
120 | - return $this->_cache->delete($this->calculateKey($id)); |
|
120 | + return $this->_cache->delete($this->calculateKey($id)); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,15 +125,15 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getKeyPrefix() |
127 | 127 | { |
128 | - return $this->_prefix; |
|
128 | + return $this->_prefix; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | - * @param string prefix of session variable name to avoid conflict with other cache data |
|
133 | - */ |
|
132 | + * @param string prefix of session variable name to avoid conflict with other cache data |
|
133 | + */ |
|
134 | 134 | public function setKeyPrefix($value) |
135 | 135 | { |
136 | - $this->_prefix=$value; |
|
136 | + $this->_prefix=$value; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | protected function calculateKey($id) |
144 | 144 | { |
145 | - return $this->_prefix.':'.$id; |
|
145 | + return $this->_prefix.':'.$id; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 |
@@ -306,10 +306,10 @@ |
||
306 | 306 | { |
307 | 307 | $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
308 | 308 | if($value===THttpSessionCookieMode::None) |
309 | - { |
|
309 | + { |
|
310 | 310 | ini_set('session.use_cookies','0'); |
311 | 311 | ini_set('session.use_only_cookies','0'); |
312 | - } |
|
312 | + } |
|
313 | 313 | else if($value===THttpSessionCookieMode::Allow) |
314 | 314 | { |
315 | 315 | ini_set('session.use_cookies','1'); |
@@ -35,537 +35,537 @@ |
||
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 | } |
@@ -602,7 +602,7 @@ |
||
602 | 602 | |
603 | 603 | /** |
604 | 604 | * @param string the application configuration type. 'xml' and 'php' are valid values |
605 | - */ |
|
605 | + */ |
|
606 | 606 | public function setConfigurationType($value) |
607 | 607 | { |
608 | 608 | $this->_configType = $value; |
@@ -90,10 +90,10 @@ |
||
90 | 90 | private $_association_columns=array(); |
91 | 91 | |
92 | 92 | /** |
93 | - * Get the foreign key index values from the results and make calls to the |
|
94 | - * database to find the corresponding foreign objects using association table. |
|
95 | - * @param array original results. |
|
96 | - */ |
|
93 | + * Get the foreign key index values from the results and make calls to the |
|
94 | + * database to find the corresponding foreign objects using association table. |
|
95 | + * @param array original results. |
|
96 | + */ |
|
97 | 97 | protected function collectForeignObjects(&$results) |
98 | 98 | { |
99 | 99 | list($sourceKeys, $foreignKeys) = $this->getRelationForeignKeys(); |