@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once __DIR__.'/MyBlocksAdmin.class.php' ; |
|
3 | +require_once __DIR__.'/MyBlocksAdmin.class.php'; |
|
4 | 4 | |
5 | 5 | class MyBlocksAdminForX25 extends MyBlocksAdmin |
6 | 6 | { |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function construct() |
14 | 14 | { |
15 | - parent::construct() ; |
|
15 | + parent::construct(); |
|
16 | 16 | |
17 | - @include_once XOOPS_ROOT_PATH.'/modules/system/language/'.$this->lang.'/admin/blocksadmin.php' ; |
|
17 | + @include_once XOOPS_ROOT_PATH.'/modules/system/language/'.$this->lang.'/admin/blocksadmin.php'; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | //HACK by domifara for php5.3+ |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | static $instance; |
25 | 25 | if (!isset($instance)) { |
26 | 26 | $instance = new MyBlocksAdminForX25(); |
27 | - $instance->construct() ; |
|
27 | + $instance->construct(); |
|
28 | 28 | } |
29 | 29 | return $instance; |
30 | 30 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $sseln = $ssel0 = $ssel1 = $ssel3 = $ssel4 = $ssel5 = $ssel7 = $ssel8 = $ssel9 = ''; |
41 | 41 | $scoln = $scol0 = $scol1 = $scol3 = $scol4 = $scol5 = $scol7 = $scol8 = $scol9 = 'unselected'; |
42 | 42 | $stextbox = 'unselected'; |
43 | - $value4extra_side = '' ; |
|
43 | + $value4extra_side = ''; |
|
44 | 44 | |
45 | 45 | if ($visible != 1) { |
46 | 46 | $sseln = " checked='checked'"; |
@@ -50,39 +50,39 @@ discard block |
||
50 | 50 | case XOOPS_SIDEBLOCK_LEFT : |
51 | 51 | $ssel0 = " checked='checked'"; |
52 | 52 | $scol0 = 'selected'; |
53 | - break ; |
|
53 | + break; |
|
54 | 54 | case XOOPS_SIDEBLOCK_RIGHT : |
55 | 55 | $ssel1 = " checked='checked'"; |
56 | 56 | $scol1 = 'selected'; |
57 | - break ; |
|
57 | + break; |
|
58 | 58 | case XOOPS_CENTERBLOCK_LEFT : |
59 | 59 | $ssel3 = " checked='checked'"; |
60 | 60 | $scol3 = 'selected'; |
61 | - break ; |
|
61 | + break; |
|
62 | 62 | case XOOPS_CENTERBLOCK_RIGHT : |
63 | 63 | $ssel4 = " checked='checked'"; |
64 | 64 | $scol4 = 'selected'; |
65 | - break ; |
|
65 | + break; |
|
66 | 66 | case XOOPS_CENTERBLOCK_CENTER : |
67 | 67 | $ssel5 = " checked='checked'"; |
68 | 68 | $scol5 = 'selected'; |
69 | - break ; |
|
69 | + break; |
|
70 | 70 | case XOOPS_CENTERBLOCK_BOTTOMLEFT : |
71 | 71 | $ssel7 = " checked='checked'"; |
72 | 72 | $scol7 = 'selected'; |
73 | - break ; |
|
73 | + break; |
|
74 | 74 | case XOOPS_CENTERBLOCK_BOTTOMRIGHT : |
75 | 75 | $ssel8 = " checked='checked'"; |
76 | 76 | $scol8 = 'selected'; |
77 | - break ; |
|
77 | + break; |
|
78 | 78 | case XOOPS_CENTERBLOCK_BOTTOM : |
79 | 79 | $ssel9 = " checked='checked'"; |
80 | 80 | $scol9 = 'selected'; |
81 | - break ; |
|
81 | + break; |
|
82 | 82 | default : |
83 | - $value4extra_side = $side ; |
|
83 | + $value4extra_side = $side; |
|
84 | 84 | $stextbox = 'selected'; |
85 | - break ; |
|
85 | + break; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | <div class='blockposition $scoln'> |
144 | 144 | <input type='radio' name='sides[$bid]' value='-1' class='blockposition' $sseln onclick='document.getElementById(\"extra_side_$bid\").value=-1;' /> |
145 | 145 | </div> |
146 | - <div style='float:"._GLOBAL_LEFT.";'>"._NONE . '</div> |
|
146 | + <div style='float:"._GLOBAL_LEFT.";'>"._NONE.'</div> |
|
147 | 147 | </td> |
148 | 148 | </tr> |
149 | 149 | </table> |
@@ -155,53 +155,53 @@ discard block |
||
155 | 155 | $bid = (int)$bid; |
156 | 156 | |
157 | 157 | //HACK by domifara |
158 | - $block = new XoopsBlock($bid) ; |
|
158 | + $block = new XoopsBlock($bid); |
|
159 | 159 | |
160 | - if (! $block->getVar('bid')) { |
|
160 | + if (!$block->getVar('bid')) { |
|
161 | 161 | // new defaults |
162 | - $bid = 0 ; |
|
163 | - $mode = 'new' ; |
|
164 | - $block->setVar('mid', 0) ; |
|
165 | - $block->setVar('block_type', 'C') ; |
|
162 | + $bid = 0; |
|
163 | + $mode = 'new'; |
|
164 | + $block->setVar('mid', 0); |
|
165 | + $block->setVar('block_type', 'C'); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | switch ($mode) { |
169 | 169 | case 'clone' : |
170 | - $form_title = _MD_A_MYBLOCKSADMIN_CLONEFORM ; |
|
171 | - $button_value = _MD_A_MYBLOCKSADMIN_BTN_CLONE ; |
|
172 | - $next_op = 'clone_ok' ; |
|
170 | + $form_title = _MD_A_MYBLOCKSADMIN_CLONEFORM; |
|
171 | + $button_value = _MD_A_MYBLOCKSADMIN_BTN_CLONE; |
|
172 | + $next_op = 'clone_ok'; |
|
173 | 173 | // breadcrumbs |
174 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
175 | - $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_CLONEFORM) ; |
|
176 | - break ; |
|
174 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
175 | + $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_CLONEFORM); |
|
176 | + break; |
|
177 | 177 | case 'new' : |
178 | - $form_title = _MD_A_MYBLOCKSADMIN_NEWFORM ; |
|
179 | - $button_value = _MD_A_MYBLOCKSADMIN_BTN_NEW ; |
|
180 | - $next_op = 'new_ok' ; |
|
178 | + $form_title = _MD_A_MYBLOCKSADMIN_NEWFORM; |
|
179 | + $button_value = _MD_A_MYBLOCKSADMIN_BTN_NEW; |
|
180 | + $next_op = 'new_ok'; |
|
181 | 181 | // breadcrumbs |
182 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
183 | - $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_NEWFORM) ; |
|
184 | - break ; |
|
182 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
183 | + $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_NEWFORM); |
|
184 | + break; |
|
185 | 185 | case 'edit' : |
186 | 186 | default : |
187 | - $form_title = _MD_A_MYBLOCKSADMIN_EDITFORM ; |
|
188 | - $button_value = _MD_A_MYBLOCKSADMIN_BTN_EDIT ; |
|
189 | - $next_op = 'edit_ok' ; |
|
187 | + $form_title = _MD_A_MYBLOCKSADMIN_EDITFORM; |
|
188 | + $button_value = _MD_A_MYBLOCKSADMIN_BTN_EDIT; |
|
189 | + $next_op = 'edit_ok'; |
|
190 | 190 | // breadcrumbs |
191 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
192 | - $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_EDITFORM) ; |
|
193 | - break ; |
|
191 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
192 | + $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_EDITFORM); |
|
193 | + break; |
|
194 | 194 | } |
195 | 195 | |
196 | - $is_custom = in_array($block->getVar('block_type'), array( 'C', 'E' )) ? true : false ; |
|
197 | - $block_template =& $block->getVar('template', 'n') ; |
|
198 | - $block_template_tplset = '' ; |
|
196 | + $is_custom = in_array($block->getVar('block_type'), array('C', 'E')) ? true : false; |
|
197 | + $block_template = & $block->getVar('template', 'n'); |
|
198 | + $block_template_tplset = ''; |
|
199 | 199 | |
200 | - if (! $is_custom && $block_template) { |
|
200 | + if (!$is_custom && $block_template) { |
|
201 | 201 | // find template of the block |
202 | 202 | $tplfile_handler = xoops_gethandler('tplfile'); |
203 | - $found_templates = $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', null, null, $block_template) ; |
|
204 | - $block_template_tplset = count($found_templates) > 0 ? $GLOBALS['xoopsConfig']['template_set'] : 'default' ; |
|
203 | + $found_templates = $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', null, null, $block_template); |
|
204 | + $block_template_tplset = count($found_templates) > 0 ? $GLOBALS['xoopsConfig']['template_set'] : 'default'; |
|
205 | 205 | } |
206 | 206 | //HACK by domifara |
207 | 207 | /* |
@@ -210,41 +210,41 @@ discard block |
||
210 | 210 | } |
211 | 211 | */ |
212 | 212 | $block_data = $this->preview_request + array( |
213 | - 'bid' => $bid , |
|
214 | - 'name' => $block->getVar('name', 'n') , |
|
215 | - 'title' => $block->getVar('title', 'n') , |
|
213 | + 'bid' => $bid, |
|
214 | + 'name' => $block->getVar('name', 'n'), |
|
215 | + 'title' => $block->getVar('title', 'n'), |
|
216 | 216 | 'weight' => (int)$block->getVar('weight'), |
217 | 217 | 'bcachetime' => (int)$block->getVar('bcachetime'), |
218 | 218 | 'side' => (int)$block->getVar('side'), |
219 | 219 | 'visible' => (int)$block->getVar('visible'), |
220 | - 'template' => $block_template , |
|
221 | - 'template_tplset' => $block_template_tplset , |
|
222 | - 'options' => $block->getVar('options') , |
|
223 | - 'content' => $block->getVar('content', 'n') , |
|
224 | - 'is_custom' => $is_custom , |
|
225 | - 'type' => $block->getVar('block_type') , |
|
220 | + 'template' => $block_template, |
|
221 | + 'template_tplset' => $block_template_tplset, |
|
222 | + 'options' => $block->getVar('options'), |
|
223 | + 'content' => $block->getVar('content', 'n'), |
|
224 | + 'is_custom' => $is_custom, |
|
225 | + 'type' => $block->getVar('block_type'), |
|
226 | 226 | 'ctype' => $block->getVar('c_type') |
227 | - ) ; |
|
227 | + ); |
|
228 | 228 | |
229 | 229 | $block4assign = array( |
230 | - 'name_raw' => $block_data['name'] , |
|
231 | - 'title_raw' => $block_data['title'] , |
|
232 | - 'content_raw' => $block_data['content'] , |
|
233 | - 'cell_position' => $this->renderCell4BlockPosition($block_data) , |
|
234 | - 'cell_module_link' => $this->renderCell4BlockModuleLink($block_data) , |
|
235 | - 'cell_group_perm' => $this->renderCell4BlockReadGroupPerm($block_data) , |
|
236 | - 'cell_options' => $this->renderCell4BlockOptions($block_data) , |
|
230 | + 'name_raw' => $block_data['name'], |
|
231 | + 'title_raw' => $block_data['title'], |
|
232 | + 'content_raw' => $block_data['content'], |
|
233 | + 'cell_position' => $this->renderCell4BlockPosition($block_data), |
|
234 | + 'cell_module_link' => $this->renderCell4BlockModuleLink($block_data), |
|
235 | + 'cell_group_perm' => $this->renderCell4BlockReadGroupPerm($block_data), |
|
236 | + 'cell_options' => $this->renderCell4BlockOptions($block_data), |
|
237 | 237 | 'content_preview' => $this->previewContent($block_data) |
238 | - ) + $block_data ; |
|
238 | + ) + $block_data; |
|
239 | 239 | |
240 | 240 | // display |
241 | - require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php' ; |
|
242 | - $tpl = new D3Tpl() ; |
|
241 | + require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php'; |
|
242 | + $tpl = new D3Tpl(); |
|
243 | 243 | //dhtml |
244 | 244 | include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
245 | 245 | |
246 | - if ($block_data['ctype']=='H' || empty($block_data['ctype'])) { |
|
247 | - $editor_configs=array(); |
|
246 | + if ($block_data['ctype'] == 'H' || empty($block_data['ctype'])) { |
|
247 | + $editor_configs = array(); |
|
248 | 248 | $editor_configs['name'] = 'content_block'; |
249 | 249 | $editor_configs['value'] = $block_data['content']; |
250 | 250 | $editor_configs['rows'] = 20; |
@@ -254,12 +254,12 @@ discard block |
||
254 | 254 | $editor_configs['editor'] = xoops_getModuleOption('blocks_editor', 'system'); |
255 | 255 | $form = new XoopsFormEditor('', 'textarea_content', $editor_configs); |
256 | 256 | $rendered = $form->render(); |
257 | - $tpl->assign('altsys_x25_dhtmltextarea', $rendered) ; |
|
257 | + $tpl->assign('altsys_x25_dhtmltextarea', $rendered); |
|
258 | 258 | } else { |
259 | 259 | $form = new XoopsFormDhtmlTextArea('', 'textarea_content', $block_data['content'], 80, 20); |
260 | 260 | $rendered = $form->render(); |
261 | - $rendered = '<div id="textarea_content_bbcode_buttons_pre" style="display:block;">'.str_replace(array( '<textarea', '</textarea><br />' ), array( '</div><textarea', '</textarea><div id="textarea_content_bbcode_buttons_post" style="display:block;">' ), $rendered) . '</div>' ; |
|
262 | - $tpl->assign('altsys_x25_dhtmltextarea', $rendered) ; |
|
261 | + $rendered = '<div id="textarea_content_bbcode_buttons_pre" style="display:block;">'.str_replace(array('<textarea', '</textarea><br />'), array('</div><textarea', '</textarea><div id="textarea_content_bbcode_buttons_post" style="display:block;">'), $rendered).'</div>'; |
|
262 | + $tpl->assign('altsys_x25_dhtmltextarea', $rendered); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | $tpl->assign(array( |
@@ -274,91 +274,91 @@ discard block |
||
274 | 274 | 'submit_button' => $button_value, |
275 | 275 | 'common_fck_installed' => file_exists(XOOPS_ROOT_PATH.'/common/fckeditor/fckeditor.js'), |
276 | 276 | 'gticket_hidden' => $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__, 1800, 'myblocksadmin') |
277 | - )) ; |
|
277 | + )); |
|
278 | 278 | //HACK by domifara |
279 | - $tpl->display('db:altsys_main_myblocksadmin_edit_4x25.html') ; |
|
279 | + $tpl->display('db:altsys_main_myblocksadmin_edit_4x25.html'); |
|
280 | 280 | |
281 | - return ; |
|
281 | + return; |
|
282 | 282 | } |
283 | 283 | public function fetchRequest4Block($bid) |
284 | 284 | { |
285 | 285 | $bid = (int)$bid; |
286 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance() ; |
|
286 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
287 | 287 | |
288 | 288 | if (@$_POST['extra_sides'][$bid] > 0) { |
289 | 289 | $_POST['sides'][$bid] = (int)$_POST['extra_sides'][$bid]; |
290 | 290 | } |
291 | 291 | |
292 | 292 | if (@$_POST['sides'][$bid] < 0) { |
293 | - $visible = 0 ; |
|
294 | - $_POST['sides'][$bid] = -1 ; |
|
293 | + $visible = 0; |
|
294 | + $_POST['sides'][$bid] = -1; |
|
295 | 295 | } else { |
296 | - $visible = 1 ; |
|
296 | + $visible = 1; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | return array( |
300 | - 'bid' => $bid , |
|
300 | + 'bid' => $bid, |
|
301 | 301 | 'side' => (int)(@$_POST['sides'][$bid]), |
302 | 302 | 'weight' => (int)(@$_POST['weights'][$bid]), |
303 | - 'visible' => $visible , |
|
304 | - 'title' => $myts->stripSlashesGPC(@$_POST['titles'][$bid]) , |
|
305 | - 'content' => $myts->stripSlashesGPC(@$_POST['textarea_content']) , |
|
306 | - 'ctype' => preg_replace('/[^A-Z]/', '', @$_POST['ctypes'][$bid]) , |
|
303 | + 'visible' => $visible, |
|
304 | + 'title' => $myts->stripSlashesGPC(@$_POST['titles'][$bid]), |
|
305 | + 'content' => $myts->stripSlashesGPC(@$_POST['textarea_content']), |
|
306 | + 'ctype' => preg_replace('/[^A-Z]/', '', @$_POST['ctypes'][$bid]), |
|
307 | 307 | 'bcachetime' => (int)(@$_POST['bcachetimes'][$bid]), |
308 | - 'bmodule' => is_array(@$_POST['bmodules'][$bid]) ? $_POST['bmodules'][$bid] : array( 0 ) , |
|
309 | - 'bgroup' => is_array(@$_POST['bgroups'][$bid]) ? $_POST['bgroups'][$bid] : array() , |
|
308 | + 'bmodule' => is_array(@$_POST['bmodules'][$bid]) ? $_POST['bmodules'][$bid] : array(0), |
|
309 | + 'bgroup' => is_array(@$_POST['bgroups'][$bid]) ? $_POST['bgroups'][$bid] : array(), |
|
310 | 310 | 'options' => is_array(@$_POST['options'][$bid]) ? $_POST['options'][$bid] : array() |
311 | - ) ; |
|
311 | + ); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | public function previewContent($block_data) |
315 | 315 | { |
316 | 316 | $bid = (int)$block_data['bid']; |
317 | 317 | |
318 | - if (! $block_data['is_custom']) { |
|
319 | - return '' ; |
|
318 | + if (!$block_data['is_custom']) { |
|
319 | + return ''; |
|
320 | 320 | } |
321 | 321 | if (empty($this->preview_request)) { |
322 | - return '' ; |
|
322 | + return ''; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | //HACK by domifara |
326 | 326 | //TODO : need no hook block at this |
327 | - $block = new XoopsBlock($bid) ; |
|
327 | + $block = new XoopsBlock($bid); |
|
328 | 328 | |
329 | 329 | if ($block->getVar('mid')) { |
330 | - return '' ; |
|
330 | + return ''; |
|
331 | 331 | } |
332 | 332 | |
333 | - $block->setVar('title', $block_data['title']) ; |
|
334 | - $block->setVar('content', $block_data['content']) ; |
|
333 | + $block->setVar('title', $block_data['title']); |
|
334 | + $block->setVar('content', $block_data['content']); |
|
335 | 335 | |
336 | - restore_error_handler() ; |
|
337 | - $original_level = error_reporting(E_ALL) ; |
|
336 | + restore_error_handler(); |
|
337 | + $original_level = error_reporting(E_ALL); |
|
338 | 338 | |
339 | 339 | // $ret = $block->getContent( 'S' , $block_data['ctype'] ) ; |
340 | 340 | |
341 | 341 | $c_type = $block_data['ctype']; |
342 | 342 | if ($c_type == 'H') { |
343 | - $ret = str_replace('{X_SITEURL}', XOOPS_URL . '/', $block->getVar('content', 'N')); |
|
343 | + $ret = str_replace('{X_SITEURL}', XOOPS_URL.'/', $block->getVar('content', 'N')); |
|
344 | 344 | } elseif ($c_type == 'P') { |
345 | 345 | ob_start(); |
346 | 346 | echo eval($block->getVar('content', 'N')); |
347 | 347 | $content = ob_get_contents(); |
348 | 348 | ob_end_clean(); |
349 | - $ret = str_replace('{X_SITEURL}', XOOPS_URL . '/', $content); |
|
349 | + $ret = str_replace('{X_SITEURL}', XOOPS_URL.'/', $content); |
|
350 | 350 | } elseif ($c_type == 'S') { |
351 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
352 | - $content = str_replace('{X_SITEURL}', XOOPS_URL . '/', $block->getVar('content', 'N')); |
|
351 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
352 | + $content = str_replace('{X_SITEURL}', XOOPS_URL.'/', $block->getVar('content', 'N')); |
|
353 | 353 | $ret = $myts->displayTarea($content, 1, 1); |
354 | 354 | } else { |
355 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
356 | - $content = str_replace('{X_SITEURL}', XOOPS_URL . '/', $block->getVar('content', 'N')); |
|
355 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
356 | + $content = str_replace('{X_SITEURL}', XOOPS_URL.'/', $block->getVar('content', 'N')); |
|
357 | 357 | $ret = $myts->displayTarea($content, 1, 0); |
358 | 358 | } |
359 | 359 | |
360 | - error_reporting($original_level) ; |
|
360 | + error_reporting($original_level); |
|
361 | 361 | |
362 | - return $ret ; |
|
362 | + return $ret; |
|
363 | 363 | } |
364 | 364 | } |
@@ -5,170 +5,170 @@ discard block |
||
5 | 5 | // GIJOE <http://www.peak.ne.jp/> // |
6 | 6 | // ------------------------------------------------------------------------- // |
7 | 7 | |
8 | -require_once __DIR__.'/class/AltsysBreadcrumbs.class.php' ; |
|
9 | -include_once __DIR__ . '/include/gtickets.php'; |
|
10 | -include_once __DIR__.'/include/altsys_functions.php' ; |
|
11 | -include_once __DIR__.'/include/lang_functions.php' ; |
|
12 | -include_once __DIR__.'/class/D3LanguageManager.class.php' ; |
|
8 | +require_once __DIR__.'/class/AltsysBreadcrumbs.class.php'; |
|
9 | +include_once __DIR__.'/include/gtickets.php'; |
|
10 | +include_once __DIR__.'/include/altsys_functions.php'; |
|
11 | +include_once __DIR__.'/include/lang_functions.php'; |
|
12 | +include_once __DIR__.'/class/D3LanguageManager.class.php'; |
|
13 | 13 | |
14 | 14 | |
15 | 15 | // only groups have 'module_admin' of 'altsys' can do that. |
16 | -$module_handler = xoops_gethandler('module') ; |
|
17 | -$module =& $module_handler->getByDirname('altsys') ; |
|
18 | -if (! is_object($module)) { |
|
19 | - die('install altsys') ; |
|
16 | +$module_handler = xoops_gethandler('module'); |
|
17 | +$module = & $module_handler->getByDirname('altsys'); |
|
18 | +if (!is_object($module)) { |
|
19 | + die('install altsys'); |
|
20 | 20 | } |
21 | -$moduleperm_handler = xoops_gethandler('groupperm') ; |
|
22 | -if (! is_object(@$xoopsUser) || ! $moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), $xoopsUser->getGroups())) { |
|
23 | - die('only admin of altsys can access this area') ; |
|
21 | +$moduleperm_handler = xoops_gethandler('groupperm'); |
|
22 | +if (!is_object(@$xoopsUser) || !$moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), $xoopsUser->getGroups())) { |
|
23 | + die('only admin of altsys can access this area'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
27 | 27 | // initials |
28 | 28 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
29 | -(method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance() ; |
|
30 | -$langman =& D3LanguageManager::getInstance() ; |
|
29 | +(method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
30 | +$langman = & D3LanguageManager::getInstance(); |
|
31 | 31 | |
32 | 32 | // language file of this controller |
33 | -altsys_include_language_file('mylangadmin') ; |
|
33 | +altsys_include_language_file('mylangadmin'); |
|
34 | 34 | |
35 | 35 | // check $xoopsModule |
36 | -if (! is_object($xoopsModule)) { |
|
37 | - redirect_header(XOOPS_URL.'/user.php', 1, _NOPERM) ; |
|
36 | +if (!is_object($xoopsModule)) { |
|
37 | + redirect_header(XOOPS_URL.'/user.php', 1, _NOPERM); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // set target_module if specified by $_GET['dirname'] |
41 | 41 | $module_handler = xoops_gethandler('module'); |
42 | -if (! empty($_GET['dirname'])) { |
|
43 | - $dirname = preg_replace('/[^0-9a-zA-Z_-]/', '', $_GET['dirname']) ; |
|
44 | - $target_module =& $module_handler->getByDirname($dirname) ; |
|
42 | +if (!empty($_GET['dirname'])) { |
|
43 | + $dirname = preg_replace('/[^0-9a-zA-Z_-]/', '', $_GET['dirname']); |
|
44 | + $target_module = & $module_handler->getByDirname($dirname); |
|
45 | 45 | } |
46 | 46 | |
47 | -if (! empty($target_module) && is_object($target_module)) { |
|
47 | +if (!empty($target_module) && is_object($target_module)) { |
|
48 | 48 | // specified by dirname (for langadmin as an independent module) |
49 | - $target_mid = $target_module->getVar('mid') ; |
|
50 | - $target_dirname = $target_module->getVar('dirname') ; |
|
51 | - $target_dirname4sql = addslashes($target_dirname) ; |
|
52 | - $target_mname = $target_module->getVar('name') . ' ' . sprintf('(%2.2f)', $target_module->getVar('version') / 100.0) ; |
|
49 | + $target_mid = $target_module->getVar('mid'); |
|
50 | + $target_dirname = $target_module->getVar('dirname'); |
|
51 | + $target_dirname4sql = addslashes($target_dirname); |
|
52 | + $target_mname = $target_module->getVar('name').' '.sprintf('(%2.2f)', $target_module->getVar('version') / 100.0); |
|
53 | 53 | //$query4redirect = '?dirname='.urlencode(strip_tags($_GET['dirname'])) ; |
54 | 54 | } else { |
55 | 55 | // not specified by dirname (for 3rd party modules as mylangadmin) |
56 | - $target_mid = $xoopsModule->getVar('mid') ; |
|
57 | - $target_dirname = $xoopsModule->getVar('dirname') ; |
|
58 | - $target_dirname4sql = addslashes($target_dirname) ; |
|
59 | - $target_mname = $xoopsModule->getVar('name') ; |
|
56 | + $target_mid = $xoopsModule->getVar('mid'); |
|
57 | + $target_dirname = $xoopsModule->getVar('dirname'); |
|
58 | + $target_dirname4sql = addslashes($target_dirname); |
|
59 | + $target_mname = $xoopsModule->getVar('name'); |
|
60 | 60 | //$query4redirect = '' ; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // basic GET variables |
64 | -$target_lang = preg_replace('/[^0-9a-zA-Z_-]/', '', @$_GET['target_lang']) ; |
|
64 | +$target_lang = preg_replace('/[^0-9a-zA-Z_-]/', '', @$_GET['target_lang']); |
|
65 | 65 | if (empty($target_lang)) { |
66 | - $target_lang = $GLOBALS['xoopsConfig']['language'] ; |
|
66 | + $target_lang = $GLOBALS['xoopsConfig']['language']; |
|
67 | 67 | } |
68 | -$target_lang4sql = addslashes($target_lang) ; |
|
69 | -$target_file = preg_replace('/[^0-9a-zA-Z_.-]/', '', @$_GET['target_file']) ; |
|
68 | +$target_lang4sql = addslashes($target_lang); |
|
69 | +$target_file = preg_replace('/[^0-9a-zA-Z_.-]/', '', @$_GET['target_file']); |
|
70 | 70 | if (empty($target_file)) { |
71 | - $target_file = 'main.php' ; |
|
71 | + $target_file = 'main.php'; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // get $target_trustdirname |
75 | -$mytrustdirname = '' ; |
|
75 | +$mytrustdirname = ''; |
|
76 | 76 | if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$target_dirname.'/mytrustdirname.php')) { |
77 | - require XOOPS_ROOT_PATH.'/modules/'.$target_dirname.'/mytrustdirname.php' ; |
|
77 | + require XOOPS_ROOT_PATH.'/modules/'.$target_dirname.'/mytrustdirname.php'; |
|
78 | 78 | } |
79 | -$target_trustdirname = $mytrustdirname ; |
|
79 | +$target_trustdirname = $mytrustdirname; |
|
80 | 80 | |
81 | 81 | // get base directory |
82 | 82 | if (empty($target_trustdirname)) { |
83 | 83 | // conventinal module |
84 | - $base_dir = XOOPS_ROOT_PATH.'/modules/'.$target_dirname.'/language' ; |
|
84 | + $base_dir = XOOPS_ROOT_PATH.'/modules/'.$target_dirname.'/language'; |
|
85 | 85 | } else { |
86 | 86 | // D3 module |
87 | - $base_dir = XOOPS_TRUST_PATH.'/modules/'.$target_trustdirname.'/language' ; |
|
87 | + $base_dir = XOOPS_TRUST_PATH.'/modules/'.$target_trustdirname.'/language'; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | // make list of language and check $target_lang |
91 | -$languages = array() ; |
|
92 | -$languages4disp = array() ; |
|
93 | -if (! is_dir($base_dir)) { |
|
94 | - altsys_mylangadmin_errordie($target_mname, _MYLANGADMIN_ERR_MODNOLANGUAGE) ; |
|
91 | +$languages = array(); |
|
92 | +$languages4disp = array(); |
|
93 | +if (!is_dir($base_dir)) { |
|
94 | + altsys_mylangadmin_errordie($target_mname, _MYLANGADMIN_ERR_MODNOLANGUAGE); |
|
95 | 95 | } |
96 | -$dh = opendir($base_dir) ; |
|
96 | +$dh = opendir($base_dir); |
|
97 | 97 | if ($dh) { |
98 | 98 | while ($file = readdir($dh)) { |
99 | 99 | if (substr($file, 0, 1) == '.') { |
100 | - continue ; |
|
100 | + continue; |
|
101 | 101 | } |
102 | 102 | if (is_dir("$base_dir/$file")) { |
103 | - list($count) = $db->fetchRow($db->query('SELECT COUNT(*) FROM ' . $db->prefix('altsys_language_constants') . " WHERE mid=$target_mid AND language='" . addslashes($file) . "'")) ; |
|
104 | - $languages[] = $file ; |
|
105 | - $languages4disp[] = $file . " ($count)" ; |
|
103 | + list($count) = $db->fetchRow($db->query('SELECT COUNT(*) FROM '.$db->prefix('altsys_language_constants')." WHERE mid=$target_mid AND language='".addslashes($file)."'")); |
|
104 | + $languages[] = $file; |
|
105 | + $languages4disp[] = $file." ($count)"; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
109 | -closedir($dh) ; |
|
110 | -if (! in_array($target_lang, $languages)) { |
|
111 | - $target_lang = $languages[0] ; |
|
109 | +closedir($dh); |
|
110 | +if (!in_array($target_lang, $languages)) { |
|
111 | + $target_lang = $languages[0]; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | // get base directory seleced language |
115 | -$lang_base_dir = $base_dir.'/'.$target_lang ; |
|
116 | -if (! is_dir($lang_base_dir)) { |
|
117 | - altsys_mylangadmin_errordie($target_mname, _MYLANGADMIN_ERR_MODLANGINCOMPATIBLE) ; |
|
115 | +$lang_base_dir = $base_dir.'/'.$target_lang; |
|
116 | +if (!is_dir($lang_base_dir)) { |
|
117 | + altsys_mylangadmin_errordie($target_mname, _MYLANGADMIN_ERR_MODLANGINCOMPATIBLE); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // make list of files and check $target_file |
121 | -$lang_files = array() ; |
|
122 | -$dh = opendir($lang_base_dir) ; |
|
121 | +$lang_files = array(); |
|
122 | +$dh = opendir($lang_base_dir); |
|
123 | 123 | if ($dh) { |
124 | 124 | while ($file = readdir($dh)) { |
125 | 125 | if (substr($file, 0, 1) == '.') { |
126 | - continue ; |
|
126 | + continue; |
|
127 | 127 | } |
128 | 128 | if ($file == 'index.html') { |
129 | - continue ; |
|
129 | + continue; |
|
130 | 130 | } |
131 | 131 | //if( $file == 'modinfo.php' ) continue ; // TODO(?) |
132 | 132 | //if( $file == 'global.php' ) continue ; // TODO(?) |
133 | 133 | if (is_file("$lang_base_dir/$file")) { |
134 | - $lang_files[] = $file ; |
|
134 | + $lang_files[] = $file; |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | } |
138 | -closedir($dh) ; |
|
138 | +closedir($dh); |
|
139 | 139 | if (empty($lang_files)) { |
140 | - altsys_mylangadmin_errordie($target_mname, _MYLANGADMIN_ERR_MODEMPTYLANGDIR) ; |
|
140 | + altsys_mylangadmin_errordie($target_mname, _MYLANGADMIN_ERR_MODEMPTYLANGDIR); |
|
141 | 141 | } |
142 | -if (! in_array($target_file, $lang_files)) { |
|
143 | - $target_file = $lang_files[0] ; |
|
142 | +if (!in_array($target_file, $lang_files)) { |
|
143 | + $target_file = $lang_files[0]; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | // get unique path of language_file |
147 | -$langfile_unique_path = "$lang_base_dir/$target_file" ; |
|
147 | +$langfile_unique_path = "$lang_base_dir/$target_file"; |
|
148 | 148 | |
149 | 149 | // get constants defined by the target_file |
150 | -list($langfile_names, $constpref, $already_read) = altsys_mylangadmin_get_constant_names($langfile_unique_path, $target_dirname) ; |
|
150 | +list($langfile_names, $constpref, $already_read) = altsys_mylangadmin_get_constant_names($langfile_unique_path, $target_dirname); |
|
151 | 151 | |
152 | 152 | // get user_values should be overridden |
153 | -$langfile_constants = array() ; |
|
153 | +$langfile_constants = array(); |
|
154 | 154 | foreach ($langfile_names as $name) { |
155 | - list($value) = $db->fetchRow($db->query('SELECT value FROM ' . $db->prefix('altsys_language_constants') . " WHERE mid=$target_mid AND language='$target_lang4sql' AND name='" . addslashes($name) . "'")) ; |
|
156 | - $langfile_constants[ $name ] = $value ; |
|
155 | + list($value) = $db->fetchRow($db->query('SELECT value FROM '.$db->prefix('altsys_language_constants')." WHERE mid=$target_mid AND language='$target_lang4sql' AND name='".addslashes($name)."'")); |
|
156 | + $langfile_constants[$name] = $value; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // constants defined in XOOPS_ROOT_PATH/my_language/(dirname)/... |
160 | 160 | if ($langman->my_language) { |
161 | - $mylang_unique_path = $langman->my_language.'/modules/'.$target_dirname.'/'.$target_lang.'/'.$target_file ; |
|
162 | - $mylang_constants = array_map('htmlspecialchars', altsys_mylangadmin_get_constants_by_pcre($mylang_unique_path)) ; |
|
161 | + $mylang_unique_path = $langman->my_language.'/modules/'.$target_dirname.'/'.$target_lang.'/'.$target_file; |
|
162 | + $mylang_constants = array_map('htmlspecialchars', altsys_mylangadmin_get_constants_by_pcre($mylang_unique_path)); |
|
163 | 163 | foreach ($mylang_constants as $key => $val) { |
164 | - if (! in_array($key, array_keys($langfile_constants))) { |
|
165 | - $langfile_constants[ $key ] = null ; |
|
166 | - define($key, _MYLANGADMIN_NOTE_ADDEDBYMYLANG) ; |
|
164 | + if (!in_array($key, array_keys($langfile_constants))) { |
|
165 | + $langfile_constants[$key] = null; |
|
166 | + define($key, _MYLANGADMIN_NOTE_ADDEDBYMYLANG); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } else { |
170 | - $mylang_unique_path = '' ; |
|
171 | - $mylang_constants = array() ; |
|
170 | + $mylang_unique_path = ''; |
|
171 | + $mylang_constants = array(); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -177,57 +177,57 @@ discard block |
||
177 | 177 | // |
178 | 178 | |
179 | 179 | // Update language table and cache file |
180 | -if (! empty($_POST['do_update'])) { |
|
180 | +if (!empty($_POST['do_update'])) { |
|
181 | 181 | // Ticket Check |
182 | - if (! $xoopsGTicket->check(true, 'altsys')) { |
|
182 | + if (!$xoopsGTicket->check(true, 'altsys')) { |
|
183 | 183 | redirect_header(XOOPS_URL.'/', 3, $xoopsGTicket->getErrors()); |
184 | 184 | } |
185 | 185 | |
186 | 186 | // read original file |
187 | - $file_contents = file_get_contents($langfile_unique_path) ; |
|
187 | + $file_contents = file_get_contents($langfile_unique_path); |
|
188 | 188 | |
189 | 189 | // insert fingerprint of langfile_unique_path |
190 | - $langfile_fingerprint = '_MYLANGADMIN_'.md5($langfile_unique_path) ; |
|
191 | - $file_contents = str_replace('<?php', "<?php\nif(!defined('$langfile_fingerprint'))define('$langfile_fingerprint',1);", $file_contents) ; |
|
190 | + $langfile_fingerprint = '_MYLANGADMIN_'.md5($langfile_unique_path); |
|
191 | + $file_contents = str_replace('<?php', "<?php\nif(!defined('$langfile_fingerprint'))define('$langfile_fingerprint',1);", $file_contents); |
|
192 | 192 | |
193 | 193 | // constants loop |
194 | - $overrides_counter = 0 ; |
|
194 | + $overrides_counter = 0; |
|
195 | 195 | foreach (array_reverse($langfile_names) as $name) { |
196 | - $user_value = $myts->stripSlashesGPC(@$_POST[$name]) ; |
|
197 | - $db->query('DELETE FROM ' . $db->prefix('altsys_language_constants') . " WHERE mid=$target_mid AND language='$target_lang4sql' AND name='" . addslashes($name) . "'") ; |
|
196 | + $user_value = $myts->stripSlashesGPC(@$_POST[$name]); |
|
197 | + $db->query('DELETE FROM '.$db->prefix('altsys_language_constants')." WHERE mid=$target_mid AND language='$target_lang4sql' AND name='".addslashes($name)."'"); |
|
198 | 198 | if ($user_value !== '') { |
199 | - $overrides_counter ++ ; |
|
199 | + $overrides_counter++; |
|
200 | 200 | // Update table |
201 | - $db->query('INSERT INTO ' . $db->prefix('altsys_language_constants') . " (mid,language,name,value) VALUES ($target_mid,'$target_lang4sql','" . addslashes($name) . "','" . addslashes($user_value) . "')") ; |
|
201 | + $db->query('INSERT INTO '.$db->prefix('altsys_language_constants')." (mid,language,name,value) VALUES ($target_mid,'$target_lang4sql','".addslashes($name)."','".addslashes($user_value)."')"); |
|
202 | 202 | // rewrite script for cache |
203 | 203 | // comment-out the line of define() |
204 | 204 | if (empty($constpref)) { |
205 | - $from = '/.*define\s?\(\s*(["\'])'.preg_quote($name).'(\\1).*\;.*/' ; |
|
205 | + $from = '/.*define\s?\(\s*(["\'])'.preg_quote($name).'(\\1).*\;.*/'; |
|
206 | 206 | } else { |
207 | - $from = '/.*define\s?\(\s*\$constpref\s*\.\s*(["\'])'.preg_quote(substr($name, strlen($constpref))).'(\\1).*\;.*/' ; |
|
207 | + $from = '/.*define\s?\(\s*\$constpref\s*\.\s*(["\'])'.preg_quote(substr($name, strlen($constpref))).'(\\1).*\;.*/'; |
|
208 | 208 | } |
209 | - $to = '//$0'."\ndefine('".addslashes($name)."','".addslashes($user_value)."');" ; |
|
210 | - $file_contents = preg_replace($from, $to, $file_contents) ; |
|
209 | + $to = '//$0'."\ndefine('".addslashes($name)."','".addslashes($user_value)."');"; |
|
210 | + $file_contents = preg_replace($from, $to, $file_contents); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | 214 | // get the file name for caching |
215 | - $cache_file_name = $langman->getCacheFileName($target_file, $target_dirname, $target_lang) ; |
|
215 | + $cache_file_name = $langman->getCacheFileName($target_file, $target_dirname, $target_lang); |
|
216 | 216 | |
217 | 217 | // Create language cache file |
218 | 218 | if ($overrides_counter > 0) { |
219 | - $fp = fopen($cache_file_name, 'wb') ; |
|
220 | - if (! $fp) { |
|
221 | - die('Invalid Cache Directory. (Set XOOPS_TRUST_PATH/cache writable)') ; |
|
219 | + $fp = fopen($cache_file_name, 'wb'); |
|
220 | + if (!$fp) { |
|
221 | + die('Invalid Cache Directory. (Set XOOPS_TRUST_PATH/cache writable)'); |
|
222 | 222 | } |
223 | - fwrite($fp, $file_contents) ; |
|
224 | - fclose($fp) ; |
|
223 | + fwrite($fp, $file_contents); |
|
224 | + fclose($fp); |
|
225 | 225 | } else { |
226 | - unlink($cache_file_name) ; |
|
226 | + unlink($cache_file_name); |
|
227 | 227 | } |
228 | 228 | |
229 | - redirect_header('?mode=admin&lib=altsys&page=mylangadmin&dirname='.$target_dirname.'&target_lang='.rawurlencode($target_lang).'&target_file='.rawurlencode($target_file), 1, _MYLANGADMIN_CACHEUPDATED) ; |
|
230 | - exit ; |
|
229 | + redirect_header('?mode=admin&lib=altsys&page=mylangadmin&dirname='.$target_dirname.'&target_lang='.rawurlencode($target_lang).'&target_file='.rawurlencode($target_file), 1, _MYLANGADMIN_CACHEUPDATED); |
|
230 | + exit; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | |
@@ -236,22 +236,22 @@ discard block |
||
236 | 236 | // |
237 | 237 | |
238 | 238 | // check cache file |
239 | -$cache_file_name = $langman->getCacheFileName($target_file, $target_dirname, $target_lang) ; |
|
240 | -$cache_file_mtime = file_exists($cache_file_name) ? filemtime($cache_file_name) : 0 ; |
|
239 | +$cache_file_name = $langman->getCacheFileName($target_file, $target_dirname, $target_lang); |
|
240 | +$cache_file_mtime = file_exists($cache_file_name) ? filemtime($cache_file_name) : 0; |
|
241 | 241 | |
242 | 242 | // check core version and generate message to enable D3LanguageManager |
243 | 243 | if (altsys_get_core_type() == ALTSYS_CORE_TYPE_XCL21) { |
244 | 244 | // XoopsCube Legacy without preload |
245 | 245 | if (class_exists('AltsysLangMgr_LanguageManager')) { |
246 | 246 | // the preload enabled |
247 | - $notice4disp = _MYLANGADMIN_MSG_D3LANGMANENABLED ; |
|
247 | + $notice4disp = _MYLANGADMIN_MSG_D3LANGMANENABLED; |
|
248 | 248 | } else { |
249 | 249 | // the preload disabled |
250 | - $notice4disp = sprintf(_MYLANGADMIN_FMT_HOWTOENABLED3LANGMAN4XCL, 'SetupAltsysLangMgr.class.php', 'XOOPS_ROOT_PATH/preload') ; |
|
250 | + $notice4disp = sprintf(_MYLANGADMIN_FMT_HOWTOENABLED3LANGMAN4XCL, 'SetupAltsysLangMgr.class.php', 'XOOPS_ROOT_PATH/preload'); |
|
251 | 251 | } |
252 | 252 | } else { |
253 | 253 | // X2 core etc. |
254 | - $notice4disp = _MYLANGADMIN_MSG_HOWTOENABLED3LANGMAN4X2.'<br />' ; |
|
254 | + $notice4disp = _MYLANGADMIN_MSG_HOWTOENABLED3LANGMAN4X2.'<br />'; |
|
255 | 255 | $notice4disp .= ' |
256 | 256 | <h4>include/common.php</h4> |
257 | 257 | <pre> |
@@ -275,20 +275,20 @@ discard block |
||
275 | 275 | // |
276 | 276 | |
277 | 277 | |
278 | -xoops_cp_header() ; |
|
278 | +xoops_cp_header(); |
|
279 | 279 | |
280 | 280 | // mymenu |
281 | -altsys_include_mymenu() ; |
|
281 | +altsys_include_mymenu(); |
|
282 | 282 | |
283 | 283 | // breadcrumbs |
284 | -$breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
284 | +$breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
285 | 285 | if ($breadcrumbsObj->hasPaths()) { |
286 | - $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=mylangadmin', _MI_ALTSYS_MENU_MYLANGADMIN) ; |
|
287 | - $breadcrumbsObj->appendPath('', $target_mname) ; |
|
286 | + $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=mylangadmin', _MI_ALTSYS_MENU_MYLANGADMIN); |
|
287 | + $breadcrumbsObj->appendPath('', $target_mname); |
|
288 | 288 | } |
289 | 289 | |
290 | -require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php' ; |
|
291 | -$tpl = new D3Tpl() ; |
|
290 | +require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php'; |
|
291 | +$tpl = new D3Tpl(); |
|
292 | 292 | $tpl->assign(array( |
293 | 293 | 'target_dirname' => $target_dirname, |
294 | 294 | 'target_mname' => $target_mname, |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | 'notice' => $notice4disp, |
308 | 308 | 'already_read' => $already_read, |
309 | 309 | 'gticket_hidden' => $xoopsGTicket->getTicketHtml(__LINE__, 1800, 'altsys') |
310 | -)) ; |
|
311 | -$tpl->display('db:altsys_main_mylangadmin.html') ; |
|
310 | +)); |
|
311 | +$tpl->display('db:altsys_main_mylangadmin.html'); |
|
312 | 312 | |
313 | -xoops_cp_footer() ; |
|
314 | -exit ; |
|
313 | +xoops_cp_footer(); |
|
314 | +exit; |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once dirname(__DIR__).'/class/altsysUtils.class.php' ; |
|
2 | +require_once dirname(__DIR__).'/class/altsysUtils.class.php'; |
|
3 | 3 | |
4 | -define('ALTSYS_ADMINMENU_FILE', XOOPS_CACHE_PATH.'/adminmenu.php') ; |
|
5 | -define('ALTSYS_ADMINMENU_HACK_NONE', 0) ; |
|
6 | -define('ALTSYS_ADMINMENU_HACK_2COL', 1) ; |
|
7 | -define('ALTSYS_ADMINMENU_HACK_NOIMG', 2) ; |
|
8 | -define('ALTSYS_ADMINMENU_HACK_XCSTY', 3) ; |
|
4 | +define('ALTSYS_ADMINMENU_FILE', XOOPS_CACHE_PATH.'/adminmenu.php'); |
|
5 | +define('ALTSYS_ADMINMENU_HACK_NONE', 0); |
|
6 | +define('ALTSYS_ADMINMENU_HACK_2COL', 1); |
|
7 | +define('ALTSYS_ADMINMENU_HACK_NOIMG', 2); |
|
8 | +define('ALTSYS_ADMINMENU_HACK_XCSTY', 3); |
|
9 | 9 | |
10 | 10 | |
11 | 11 | // |
@@ -13,73 +13,73 @@ discard block |
||
13 | 13 | // |
14 | 14 | function altsys_adminmenu_insert_mymenu(&$module) |
15 | 15 | { |
16 | - global $altsysModuleConfig ; |
|
16 | + global $altsysModuleConfig; |
|
17 | 17 | |
18 | 18 | if (empty($altsysModuleConfig['adminmenu_insert_mymenu'])) { |
19 | - return ; |
|
19 | + return; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (altsys_get_core_type() < ALTSYS_CORE_TYPE_ORE) { |
23 | - altsys_adminmenu_insert_mymenu_x20($module) ; |
|
23 | + altsys_adminmenu_insert_mymenu_x20($module); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | 27 | function altsys_adminmenu_insert_mymenu_x20(&$module) |
28 | 28 | { |
29 | 29 | // read |
30 | - if (! file_exists(ALTSYS_ADMINMENU_FILE)) { |
|
31 | - redirect_header(XOOPS_URL.'/admin.php', 1, 'Rebuild adminmenu') ; |
|
32 | - exit ; |
|
30 | + if (!file_exists(ALTSYS_ADMINMENU_FILE)) { |
|
31 | + redirect_header(XOOPS_URL.'/admin.php', 1, 'Rebuild adminmenu'); |
|
32 | + exit; |
|
33 | 33 | } |
34 | - $not_inside_cp_functions = true ; |
|
35 | - include ALTSYS_ADMINMENU_FILE ; |
|
34 | + $not_inside_cp_functions = true; |
|
35 | + include ALTSYS_ADMINMENU_FILE; |
|
36 | 36 | |
37 | - $dirname = $module->getVar('dirname') ; |
|
38 | - $mid = $module->getVar('mid') ; |
|
39 | - $anchor = '<!-- ALTSYS ANCHOR '.$dirname.' -->' ; |
|
37 | + $dirname = $module->getVar('dirname'); |
|
38 | + $mid = $module->getVar('mid'); |
|
39 | + $anchor = '<!-- ALTSYS ANCHOR '.$dirname.' -->'; |
|
40 | 40 | |
41 | 41 | // fetch popup_no |
42 | 42 | if (empty($xoops_admin_menu_ft[$mid])) { |
43 | - return ; |
|
43 | + return; |
|
44 | 44 | } |
45 | - if (! preg_match('/popUpL(\d+)/', $xoops_admin_menu_ft[$mid], $regs)) { |
|
46 | - return ; |
|
45 | + if (!preg_match('/popUpL(\d+)/', $xoops_admin_menu_ft[$mid], $regs)) { |
|
46 | + return; |
|
47 | 47 | } |
48 | 48 | $popup_no = (int)$regs[1]; |
49 | 49 | |
50 | 50 | // replace |
51 | - $search = '<img src=\''.XOOPS_URL.'/images/pointer.gif\' width=\'8\' height=\'8\' alt=\'\' /> <a href=\''.XOOPS_URL.'/modules/system/admin.php?fct=preferences&op=showmod&mod='.$mid.'\'' ; |
|
52 | - $replace = $anchor.'<img src=\''.XOOPS_URL.'/images/pointer.gif\' width=\'8\' height=\'8\' alt=\'\' /> <a href=\''.XOOPS_URL.'/modules/'.$dirname.'/admin/index.php?mode=admin&lib=altsys&page=mypreferences\'' ; |
|
51 | + $search = '<img src=\''.XOOPS_URL.'/images/pointer.gif\' width=\'8\' height=\'8\' alt=\'\' /> <a href=\''.XOOPS_URL.'/modules/system/admin.php?fct=preferences&op=showmod&mod='.$mid.'\''; |
|
52 | + $replace = $anchor.'<img src=\''.XOOPS_URL.'/images/pointer.gif\' width=\'8\' height=\'8\' alt=\'\' /> <a href=\''.XOOPS_URL.'/modules/'.$dirname.'/admin/index.php?mode=admin&lib=altsys&page=mypreferences\''; |
|
53 | 53 | |
54 | 54 | // do replacement |
55 | - $new_xoops_admin_menu_dv = preg_replace('#'.preg_quote($search).'#', $replace, $xoops_admin_menu_dv) ; |
|
55 | + $new_xoops_admin_menu_dv = preg_replace('#'.preg_quote($search).'#', $replace, $xoops_admin_menu_dv); |
|
56 | 56 | |
57 | 57 | if ($xoops_admin_menu_dv == $new_xoops_admin_menu_dv) { |
58 | - return ; |
|
58 | + return; |
|
59 | 59 | } |
60 | - $xoops_admin_menu_dv = $new_xoops_admin_menu_dv ; |
|
60 | + $xoops_admin_menu_dv = $new_xoops_admin_menu_dv; |
|
61 | 61 | |
62 | - $insert = '' ; |
|
62 | + $insert = ''; |
|
63 | 63 | |
64 | 64 | // insert blocksadmin |
65 | 65 | if ($dirname != 'altsys') { |
66 | - $blocksadmin_title = defined('_MD_A_MYMENU_MYBLOCKSADMIN') ? _MD_A_MYMENU_MYBLOCKSADMIN : 'blocksadmin' ; |
|
67 | - $insert .= '<img src=\''.XOOPS_URL.'/images/pointer.gif\' width=\'8\' height=\'8\' alt=\'\' /> <a href=\''.XOOPS_URL.'/modules/'.$dirname.'/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin\'>'.$blocksadmin_title.'</a><br />'."\n" ; |
|
66 | + $blocksadmin_title = defined('_MD_A_MYMENU_MYBLOCKSADMIN') ? _MD_A_MYMENU_MYBLOCKSADMIN : 'blocksadmin'; |
|
67 | + $insert .= '<img src=\''.XOOPS_URL.'/images/pointer.gif\' width=\'8\' height=\'8\' alt=\'\' /> <a href=\''.XOOPS_URL.'/modules/'.$dirname.'/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin\'>'.$blocksadmin_title.'</a><br />'."\n"; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // insert tplsadmin |
71 | - $db = XoopsDatabaseFactory::getDatabaseConnection() ; |
|
72 | - list($count) = $db->fetchRow($db->query('SELECT COUNT(*) FROM ' . $db->prefix('tplfile') . " WHERE tpl_module='$dirname'")) ; |
|
71 | + $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
72 | + list($count) = $db->fetchRow($db->query('SELECT COUNT(*) FROM '.$db->prefix('tplfile')." WHERE tpl_module='$dirname'")); |
|
73 | 73 | if ($count > 0) { |
74 | - $tplsadmin_title = defined('_MD_A_MYMENU_MYTPLSADMIN') ? _MD_A_MYMENU_MYTPLSADMIN : 'tplsadmin' ; |
|
75 | - $insert = '<img src=\''.XOOPS_URL.'/images/pointer.gif\' width=\'8\' height=\'8\' alt=\'\' /> <a href=\''.XOOPS_URL.'/modules/'.$dirname.'/admin/index.php?mode=admin&lib=altsys&page=mytplsadmin\'>'.$tplsadmin_title.'</a><br />'."\n".$insert ; |
|
74 | + $tplsadmin_title = defined('_MD_A_MYMENU_MYTPLSADMIN') ? _MD_A_MYMENU_MYTPLSADMIN : 'tplsadmin'; |
|
75 | + $insert = '<img src=\''.XOOPS_URL.'/images/pointer.gif\' width=\'8\' height=\'8\' alt=\'\' /> <a href=\''.XOOPS_URL.'/modules/'.$dirname.'/admin/index.php?mode=admin&lib=altsys&page=mytplsadmin\'>'.$tplsadmin_title.'</a><br />'."\n".$insert; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // do insertion |
79 | - $xoops_admin_menu_dv = preg_replace('#'.preg_quote($anchor).'#', $anchor.$insert, $xoops_admin_menu_dv) ; |
|
79 | + $xoops_admin_menu_dv = preg_replace('#'.preg_quote($anchor).'#', $anchor.$insert, $xoops_admin_menu_dv); |
|
80 | 80 | |
81 | 81 | // write back |
82 | - altsys_adminmenu_save_x20(array( 'xoops_admin_menu_js' => $xoops_admin_menu_js, 'xoops_admin_menu_ml' => $xoops_admin_menu_ml, 'xoops_admin_menu_sd' => $xoops_admin_menu_sd, 'xoops_admin_menu_ft' => $xoops_admin_menu_ft, 'xoops_admin_menu_dv' => $xoops_admin_menu_dv, 'altsys_adminmenu_ft_hacked' => (int)(@$altsys_adminmenu_ft_hacked), 'altsys_adminmenu_dv_updated' => true )) ; |
|
82 | + altsys_adminmenu_save_x20(array('xoops_admin_menu_js' => $xoops_admin_menu_js, 'xoops_admin_menu_ml' => $xoops_admin_menu_ml, 'xoops_admin_menu_sd' => $xoops_admin_menu_sd, 'xoops_admin_menu_ft' => $xoops_admin_menu_ft, 'xoops_admin_menu_dv' => $xoops_admin_menu_dv, 'altsys_adminmenu_ft_hacked' => (int)(@$altsys_adminmenu_ft_hacked), 'altsys_adminmenu_dv_updated' => true)); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | // |
@@ -87,184 +87,184 @@ discard block |
||
87 | 87 | // |
88 | 88 | function altsys_adminmenu_hack_ft() |
89 | 89 | { |
90 | - global $altsysModuleConfig ; |
|
90 | + global $altsysModuleConfig; |
|
91 | 91 | |
92 | 92 | if (altsys_get_core_type() >= ALTSYS_CORE_TYPE_ORE) { |
93 | - return ; |
|
93 | + return; |
|
94 | 94 | } |
95 | 95 | if (empty($altsysModuleConfig['adminmenu_hack_ft'])) { |
96 | - return ; |
|
96 | + return; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | if ($altsysModuleConfig['adminmenu_hack_ft'] == ALTSYS_ADMINMENU_HACK_2COL) { |
100 | - altsys_adminmenu_hack_ft_2col_x20() ; |
|
100 | + altsys_adminmenu_hack_ft_2col_x20(); |
|
101 | 101 | } elseif ($altsysModuleConfig['adminmenu_hack_ft'] == ALTSYS_ADMINMENU_HACK_NOIMG) { |
102 | - altsys_adminmenu_hack_ft_noimg_x20() ; |
|
102 | + altsys_adminmenu_hack_ft_noimg_x20(); |
|
103 | 103 | } elseif ($altsysModuleConfig['adminmenu_hack_ft'] == ALTSYS_ADMINMENU_HACK_XCSTY) { |
104 | - altsys_adminmenu_hack_ft_xcsty_x20() ; |
|
104 | + altsys_adminmenu_hack_ft_xcsty_x20(); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | 108 | function altsys_adminmenu_hack_ft_2col_x20() |
109 | 109 | { |
110 | 110 | // read |
111 | - if (! file_exists(ALTSYS_ADMINMENU_FILE)) { |
|
112 | - redirect_header(XOOPS_URL.'/admin.php', 1, 'Rebuild adminmenu') ; |
|
113 | - exit ; |
|
111 | + if (!file_exists(ALTSYS_ADMINMENU_FILE)) { |
|
112 | + redirect_header(XOOPS_URL.'/admin.php', 1, 'Rebuild adminmenu'); |
|
113 | + exit; |
|
114 | 114 | } |
115 | - $not_inside_cp_functions = true ; |
|
116 | - include ALTSYS_ADMINMENU_FILE ; |
|
115 | + $not_inside_cp_functions = true; |
|
116 | + include ALTSYS_ADMINMENU_FILE; |
|
117 | 117 | |
118 | 118 | // check previous hack |
119 | - if (! empty($altsys_adminmenu_ft_hacked)) { |
|
119 | + if (!empty($altsys_adminmenu_ft_hacked)) { |
|
120 | 120 | if ($altsys_adminmenu_ft_hacked == ALTSYS_ADMINMENU_HACK_2COL) { |
121 | 121 | // skip |
122 | - return ; |
|
122 | + return; |
|
123 | 123 | } else { |
124 | 124 | // rebuild adminmenu |
125 | - require_once XOOPS_ROOT_PATH.'/include/cp_functions.php' ; |
|
126 | - xoops_module_write_admin_menu(xoops_module_get_admin_menu()) ; |
|
125 | + require_once XOOPS_ROOT_PATH.'/include/cp_functions.php'; |
|
126 | + xoops_module_write_admin_menu(xoops_module_get_admin_menu()); |
|
127 | 127 | // backup $xoops_admin_menu_dv |
128 | - $backup_admin_menu_dv = $xoops_admin_menu_dv ; |
|
128 | + $backup_admin_menu_dv = $xoops_admin_menu_dv; |
|
129 | 129 | // include new adminmenu |
130 | - include ALTSYS_ADMINMENU_FILE ; |
|
130 | + include ALTSYS_ADMINMENU_FILE; |
|
131 | 131 | // restore $xoops_admin_menu_dv |
132 | - $xoops_admin_menu_dv = $backup_admin_menu_dv ; |
|
132 | + $xoops_admin_menu_dv = $backup_admin_menu_dv; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | - $search = ' alt=\'\' /></a><br />' ; |
|
137 | - $replace_fmt = ' alt="%s" /></a>' ; |
|
136 | + $search = ' alt=\'\' /></a><br />'; |
|
137 | + $replace_fmt = ' alt="%s" /></a>'; |
|
138 | 138 | |
139 | - $is_left = true ; |
|
140 | - $module_handler = xoops_gethandler('module') ; |
|
141 | - $mids = array_keys($xoops_admin_menu_ft) ; |
|
142 | - $last_mid = $mids[count($mids) - 1 ] ; |
|
139 | + $is_left = true; |
|
140 | + $module_handler = xoops_gethandler('module'); |
|
141 | + $mids = array_keys($xoops_admin_menu_ft); |
|
142 | + $last_mid = $mids[count($mids) - 1]; |
|
143 | 143 | foreach ($mids as $mid) { |
144 | - $module = $module_handler->get($mid) ; |
|
145 | - $new_menu_ft = preg_replace('#'.preg_quote($search).'#', sprintf($replace_fmt, $module->getVar('name')), $xoops_admin_menu_ft[$mid]) ; |
|
144 | + $module = $module_handler->get($mid); |
|
145 | + $new_menu_ft = preg_replace('#'.preg_quote($search).'#', sprintf($replace_fmt, $module->getVar('name')), $xoops_admin_menu_ft[$mid]); |
|
146 | 146 | if ($is_left) { |
147 | 147 | if ($mid == $last_mid) { |
148 | - $xoops_admin_menu_ft[$mid] = $new_menu_ft . '</td><td>' ; |
|
148 | + $xoops_admin_menu_ft[$mid] = $new_menu_ft.'</td><td>'; |
|
149 | 149 | } else { |
150 | - $left_body = $new_menu_ft ; |
|
151 | - $left_key = $mid ; |
|
152 | - $xoops_admin_menu_ml[$mid] = str_replace(',105);', ',85);', $xoops_admin_menu_ml[$mid]) ; |
|
150 | + $left_body = $new_menu_ft; |
|
151 | + $left_key = $mid; |
|
152 | + $xoops_admin_menu_ml[$mid] = str_replace(',105);', ',85);', $xoops_admin_menu_ml[$mid]); |
|
153 | 153 | } |
154 | 154 | } else { |
155 | - $xoops_admin_menu_ft[$mid] = $left_body . '</td><td>' . $new_menu_ft ; |
|
156 | - unset($xoops_admin_menu_ft[$left_key]) ; |
|
157 | - $xoops_admin_menu_ml[$mid] = str_replace(',105);', ',185);', $xoops_admin_menu_ml[$mid]) ; |
|
155 | + $xoops_admin_menu_ft[$mid] = $left_body.'</td><td>'.$new_menu_ft; |
|
156 | + unset($xoops_admin_menu_ft[$left_key]); |
|
157 | + $xoops_admin_menu_ml[$mid] = str_replace(',105);', ',185);', $xoops_admin_menu_ml[$mid]); |
|
158 | 158 | } |
159 | - $is_left = ! $is_left ; |
|
159 | + $is_left = !$is_left; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // write back |
163 | - altsys_adminmenu_save_x20(array( 'xoops_admin_menu_js' => $xoops_admin_menu_js, 'xoops_admin_menu_ml' => $xoops_admin_menu_ml, 'xoops_admin_menu_sd' => $xoops_admin_menu_sd, 'xoops_admin_menu_ft' => $xoops_admin_menu_ft, 'xoops_admin_menu_dv' => $xoops_admin_menu_dv, 'altsys_adminmenu_ft_hacked' => ALTSYS_ADMINMENU_HACK_2COL )) ; |
|
163 | + altsys_adminmenu_save_x20(array('xoops_admin_menu_js' => $xoops_admin_menu_js, 'xoops_admin_menu_ml' => $xoops_admin_menu_ml, 'xoops_admin_menu_sd' => $xoops_admin_menu_sd, 'xoops_admin_menu_ft' => $xoops_admin_menu_ft, 'xoops_admin_menu_dv' => $xoops_admin_menu_dv, 'altsys_adminmenu_ft_hacked' => ALTSYS_ADMINMENU_HACK_2COL)); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
167 | 167 | function altsys_adminmenu_hack_ft_noimg_x20() |
168 | 168 | { |
169 | 169 | // read |
170 | - if (! file_exists(ALTSYS_ADMINMENU_FILE)) { |
|
171 | - redirect_header(XOOPS_URL.'/admin.php', 1, 'Rebuild adminmenu') ; |
|
172 | - exit ; |
|
170 | + if (!file_exists(ALTSYS_ADMINMENU_FILE)) { |
|
171 | + redirect_header(XOOPS_URL.'/admin.php', 1, 'Rebuild adminmenu'); |
|
172 | + exit; |
|
173 | 173 | } |
174 | - $not_inside_cp_functions = true ; |
|
175 | - include ALTSYS_ADMINMENU_FILE ; |
|
174 | + $not_inside_cp_functions = true; |
|
175 | + include ALTSYS_ADMINMENU_FILE; |
|
176 | 176 | |
177 | 177 | // check previous hack |
178 | - if (! empty($altsys_adminmenu_ft_hacked)) { |
|
178 | + if (!empty($altsys_adminmenu_ft_hacked)) { |
|
179 | 179 | if ($altsys_adminmenu_ft_hacked == ALTSYS_ADMINMENU_HACK_NOIMG) { |
180 | 180 | // skip |
181 | - return ; |
|
181 | + return; |
|
182 | 182 | } else { |
183 | 183 | // rebuild adminmenu |
184 | - require_once XOOPS_ROOT_PATH.'/include/cp_functions.php' ; |
|
185 | - xoops_module_write_admin_menu(xoops_module_get_admin_menu()) ; |
|
184 | + require_once XOOPS_ROOT_PATH.'/include/cp_functions.php'; |
|
185 | + xoops_module_write_admin_menu(xoops_module_get_admin_menu()); |
|
186 | 186 | // backup $xoops_admin_menu_dv |
187 | - $backup_admin_menu_dv = $xoops_admin_menu_dv ; |
|
187 | + $backup_admin_menu_dv = $xoops_admin_menu_dv; |
|
188 | 188 | // include new adminmenu |
189 | - include ALTSYS_ADMINMENU_FILE ; |
|
189 | + include ALTSYS_ADMINMENU_FILE; |
|
190 | 190 | // restore $xoops_admin_menu_dv |
191 | - $xoops_admin_menu_dv = $backup_admin_menu_dv ; |
|
191 | + $xoops_admin_menu_dv = $backup_admin_menu_dv; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - $module_handler = xoops_gethandler('module') ; |
|
196 | - $mids = array_keys($xoops_admin_menu_ft) ; |
|
195 | + $module_handler = xoops_gethandler('module'); |
|
196 | + $mids = array_keys($xoops_admin_menu_ft); |
|
197 | 197 | foreach ($mids as $mid) { |
198 | - $module = $module_handler->get($mid) ; |
|
199 | - $xoops_admin_menu_ft[$mid] = preg_replace('/\<img src\=.*$/', $module->getVar('name').'</a>', $xoops_admin_menu_ft[$mid]) ; |
|
200 | - $xoops_admin_menu_ft[$mid] = '<div style="text-align:'._GLOBAL_LEFT.';background-color:#CCC;" title="'.$module->getVar('dirname').'">'.$xoops_admin_menu_ft[$mid].'</div>' ; |
|
201 | - $xoops_admin_menu_ml[$mid] = str_replace(',105);', ',45);', $xoops_admin_menu_ml[$mid]) ; |
|
198 | + $module = $module_handler->get($mid); |
|
199 | + $xoops_admin_menu_ft[$mid] = preg_replace('/\<img src\=.*$/', $module->getVar('name').'</a>', $xoops_admin_menu_ft[$mid]); |
|
200 | + $xoops_admin_menu_ft[$mid] = '<div style="text-align:'._GLOBAL_LEFT.';background-color:#CCC;" title="'.$module->getVar('dirname').'">'.$xoops_admin_menu_ft[$mid].'</div>'; |
|
201 | + $xoops_admin_menu_ml[$mid] = str_replace(',105);', ',45);', $xoops_admin_menu_ml[$mid]); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | // write back |
205 | - altsys_adminmenu_save_x20(array( 'xoops_admin_menu_js' => $xoops_admin_menu_js, 'xoops_admin_menu_ml' => $xoops_admin_menu_ml, 'xoops_admin_menu_sd' => $xoops_admin_menu_sd, 'xoops_admin_menu_ft' => $xoops_admin_menu_ft, 'xoops_admin_menu_dv' => $xoops_admin_menu_dv, 'altsys_adminmenu_ft_hacked' => ALTSYS_ADMINMENU_HACK_NOIMG )) ; |
|
205 | + altsys_adminmenu_save_x20(array('xoops_admin_menu_js' => $xoops_admin_menu_js, 'xoops_admin_menu_ml' => $xoops_admin_menu_ml, 'xoops_admin_menu_sd' => $xoops_admin_menu_sd, 'xoops_admin_menu_ft' => $xoops_admin_menu_ft, 'xoops_admin_menu_dv' => $xoops_admin_menu_dv, 'altsys_adminmenu_ft_hacked' => ALTSYS_ADMINMENU_HACK_NOIMG)); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
209 | 209 | function altsys_adminmenu_hack_ft_xcsty_x20() |
210 | 210 | { |
211 | 211 | // read |
212 | - if (! file_exists(ALTSYS_ADMINMENU_FILE)) { |
|
213 | - redirect_header(XOOPS_URL.'/admin.php', 1, 'Rebuild adminmenu') ; |
|
214 | - exit ; |
|
212 | + if (!file_exists(ALTSYS_ADMINMENU_FILE)) { |
|
213 | + redirect_header(XOOPS_URL.'/admin.php', 1, 'Rebuild adminmenu'); |
|
214 | + exit; |
|
215 | 215 | } |
216 | - $not_inside_cp_functions = true ; |
|
217 | - include ALTSYS_ADMINMENU_FILE ; |
|
216 | + $not_inside_cp_functions = true; |
|
217 | + include ALTSYS_ADMINMENU_FILE; |
|
218 | 218 | |
219 | 219 | // check previous hack |
220 | - if (! empty($altsys_adminmenu_ft_hacked)) { |
|
220 | + if (!empty($altsys_adminmenu_ft_hacked)) { |
|
221 | 221 | if ($altsys_adminmenu_ft_hacked == ALTSYS_ADMINMENU_HACK_XCSTY && empty($altsys_adminmenu_dv_updated)) { |
222 | 222 | // skip |
223 | - return ; |
|
223 | + return; |
|
224 | 224 | } else { |
225 | 225 | // rebuild adminmenu |
226 | - require_once XOOPS_ROOT_PATH.'/include/cp_functions.php' ; |
|
227 | - $fp = fopen(ALTSYS_ADMINMENU_FILE, 'wb') ; |
|
228 | - fwrite($fp, xoops_module_get_admin_menu()) ; |
|
229 | - fclose($fp) ; |
|
226 | + require_once XOOPS_ROOT_PATH.'/include/cp_functions.php'; |
|
227 | + $fp = fopen(ALTSYS_ADMINMENU_FILE, 'wb'); |
|
228 | + fwrite($fp, xoops_module_get_admin_menu()); |
|
229 | + fclose($fp); |
|
230 | 230 | // backup $xoops_admin_menu_dv |
231 | - $backup_admin_menu_dv = $xoops_admin_menu_dv ; |
|
231 | + $backup_admin_menu_dv = $xoops_admin_menu_dv; |
|
232 | 232 | // include new adminmenu |
233 | - include ALTSYS_ADMINMENU_FILE ; |
|
233 | + include ALTSYS_ADMINMENU_FILE; |
|
234 | 234 | // restore $xoops_admin_menu_dv |
235 | - $xoops_admin_menu_dv = $backup_admin_menu_dv ; |
|
235 | + $xoops_admin_menu_dv = $backup_admin_menu_dv; |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | - $module_handler = xoops_gethandler('module') ; |
|
240 | - $mids = array_keys($xoops_admin_menu_ft) ; |
|
239 | + $module_handler = xoops_gethandler('module'); |
|
240 | + $mids = array_keys($xoops_admin_menu_ft); |
|
241 | 241 | foreach ($mids as $mid) { |
242 | - $module = $module_handler->get($mid) ; |
|
243 | - $submenuitems = array() ; |
|
242 | + $module = $module_handler->get($mid); |
|
243 | + $submenuitems = array(); |
|
244 | 244 | if (preg_match('/popUpL\d+/', $xoops_admin_menu_ft[$mid], $regs)) { |
245 | - $popup = $regs[0] ; |
|
246 | - preg_match_all('#\<a href.*'.$popup.'\(\).*\</a>#U', $xoops_admin_menu_dv, $regs) ; |
|
245 | + $popup = $regs[0]; |
|
246 | + preg_match_all('#\<a href.*'.$popup.'\(\).*\</a>#U', $xoops_admin_menu_dv, $regs); |
|
247 | 247 | foreach ($regs[0] as $submenuitem) { |
248 | - $submenuitems[] = str_replace($popup.'();', '', $submenuitem) ; |
|
248 | + $submenuitems[] = str_replace($popup.'();', '', $submenuitem); |
|
249 | 249 | } |
250 | 250 | } else { |
251 | - return ; |
|
251 | + return; |
|
252 | 252 | } |
253 | 253 | // module icon |
254 | 254 | if (preg_match('#\<img .*/\>#U', $xoops_admin_menu_ft[$mid], $regs)) { |
255 | - $icon_img = str_replace("alt=''", 'alt="'.$module->getVar('name').'"', $regs[0]) ; |
|
255 | + $icon_img = str_replace("alt=''", 'alt="'.$module->getVar('name').'"', $regs[0]); |
|
256 | 256 | } else { |
257 | - $icon_img = '' ; |
|
257 | + $icon_img = ''; |
|
258 | 258 | } |
259 | 259 | // version number |
260 | - $icon_img .= '<span class="version" style="">' . sprintf('%.2f', $module->getVar('version') / 100.0) . '</span>' ; |
|
261 | - $newline = preg_replace('/ onmouseover.*$/', '', $xoops_admin_menu_ft[$mid]) ; |
|
262 | - $newline = "\n".'<!-- '.$popup.' --><div id="adminmenu_ft'.$mid.'" style="text-align:'._GLOBAL_LEFT.';background-color:#CCC;" title="'.$module->getVar('dirname').'"><a id="adminmenu_ftpoint'.$mid.'" href="javascript:void(0);" onclick="submenuToggle('.$mid.');">+</a> '.$newline.'>'.$module->getVar('name').'</a></div><div id="adminmenu_ftsub'.$mid.'" style="display:none;"><ul>' ; |
|
260 | + $icon_img .= '<span class="version" style="">'.sprintf('%.2f', $module->getVar('version') / 100.0).'</span>'; |
|
261 | + $newline = preg_replace('/ onmouseover.*$/', '', $xoops_admin_menu_ft[$mid]); |
|
262 | + $newline = "\n".'<!-- '.$popup.' --><div id="adminmenu_ft'.$mid.'" style="text-align:'._GLOBAL_LEFT.';background-color:#CCC;" title="'.$module->getVar('dirname').'"><a id="adminmenu_ftpoint'.$mid.'" href="javascript:void(0);" onclick="submenuToggle('.$mid.');">+</a> '.$newline.'>'.$module->getVar('name').'</a></div><div id="adminmenu_ftsub'.$mid.'" style="display:none;"><ul>'; |
|
263 | 263 | foreach ($submenuitems as $submenuitem) { |
264 | - $newline .= '<li>'.$submenuitem.'</li>' ; |
|
264 | + $newline .= '<li>'.$submenuitem.'</li>'; |
|
265 | 265 | } |
266 | - $newline .= '</ul>'.$icon_img.'</div>' ; |
|
267 | - $xoops_admin_menu_ft[$mid] = $newline ; |
|
266 | + $newline .= '</ul>'.$icon_img.'</div>'; |
|
267 | + $xoops_admin_menu_ft[$mid] = $newline; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | $xoops_admin_menu_js = " |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | }" ; |
281 | 281 | |
282 | 282 | // write back |
283 | - altsys_adminmenu_save_x20(array( 'xoops_admin_menu_js' => $xoops_admin_menu_js, 'xoops_admin_menu_ml' => array(), 'xoops_admin_menu_sd' => array(), 'xoops_admin_menu_ft' => $xoops_admin_menu_ft, 'xoops_admin_menu_dv' => $xoops_admin_menu_dv, 'altsys_adminmenu_ft_hacked' => ALTSYS_ADMINMENU_HACK_XCSTY )) ; |
|
283 | + altsys_adminmenu_save_x20(array('xoops_admin_menu_js' => $xoops_admin_menu_js, 'xoops_admin_menu_ml' => array(), 'xoops_admin_menu_sd' => array(), 'xoops_admin_menu_ft' => $xoops_admin_menu_ft, 'xoops_admin_menu_dv' => $xoops_admin_menu_dv, 'altsys_adminmenu_ft_hacked' => ALTSYS_ADMINMENU_HACK_XCSTY)); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | |
@@ -291,18 +291,18 @@ discard block |
||
291 | 291 | function altsys_adminmenu_save_x20($xoops_admin_vars) |
292 | 292 | { |
293 | 293 | // variable definitions |
294 | - ob_start() ; |
|
295 | - echo "<?php\n// modified by altsys\nif( ! defined('XOOPS_ROOT_PATH') ) exit ;\n" ; |
|
294 | + ob_start(); |
|
295 | + echo "<?php\n// modified by altsys\nif( ! defined('XOOPS_ROOT_PATH') ) exit ;\n"; |
|
296 | 296 | foreach ($xoops_admin_vars as $key => $val) { |
297 | - echo '$' . $key . " = \n" ; |
|
298 | - @var_export($val) ; |
|
299 | - echo " ;\n" ; |
|
297 | + echo '$'.$key." = \n"; |
|
298 | + @var_export($val); |
|
299 | + echo " ;\n"; |
|
300 | 300 | } |
301 | - $output = ob_get_contents() ; |
|
302 | - ob_end_clean() ; |
|
301 | + $output = ob_get_contents(); |
|
302 | + ob_end_clean(); |
|
303 | 303 | |
304 | 304 | // embedding logics |
305 | - if (in_array(@$xoops_admin_vars['altsys_adminmenu_ft_hacked'], array( ALTSYS_ADMINMENU_HACK_NOIMG, ALTSYS_ADMINMENU_HACK_XCSTY ))) { |
|
305 | + if (in_array(@$xoops_admin_vars['altsys_adminmenu_ft_hacked'], array(ALTSYS_ADMINMENU_HACK_NOIMG, ALTSYS_ADMINMENU_HACK_XCSTY))) { |
|
306 | 306 | $output .= ' |
307 | 307 | |
308 | 308 | if( is_object( @$GLOBALS["xoopsModule"] ) && empty( $not_inside_cp_functions ) ) { |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | // termination |
320 | - $output .= "\n\n?>" ; |
|
320 | + $output .= "\n\n?>"; |
|
321 | 321 | |
322 | 322 | // replace into XOOPS_URL |
323 | - $output = str_replace(XOOPS_URL, "'.XOOPS_URL.'", $output) ; |
|
323 | + $output = str_replace(XOOPS_URL, "'.XOOPS_URL.'", $output); |
|
324 | 324 | |
325 | 325 | // output |
326 | - $fp = fopen(ALTSYS_ADMINMENU_FILE, 'wb') ; |
|
327 | - fwrite($fp, $output) ; |
|
328 | - fclose($fp) ; |
|
326 | + $fp = fopen(ALTSYS_ADMINMENU_FILE, 'wb'); |
|
327 | + fwrite($fp, $output); |
|
328 | + fclose($fp); |
|
329 | 329 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! defined('XOOPS_ROOT_PATH')) { |
|
4 | - exit ; |
|
3 | +if (!defined('XOOPS_ROOT_PATH')) { |
|
4 | + exit; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function myDeleteByModule($DB, $gperm_modid, $gperm_name = null, $gperm_itemid = null) |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | $criteria->add(new Criteria('gperm_itemid', (int)$gperm_itemid)); |
14 | 14 | } |
15 | 15 | } |
16 | - $sql = 'DELETE FROM ' . $DB->prefix('group_permission') . ' ' . $criteria->renderWhere(); |
|
16 | + $sql = 'DELETE FROM '.$DB->prefix('group_permission').' '.$criteria->renderWhere(); |
|
17 | 17 | if (!$result = $DB->query($sql)) { |
18 | 18 | return false; |
19 | 19 | } |
@@ -27,27 +27,27 @@ discard block |
||
27 | 27 | |
28 | 28 | if ($modid == 1) { |
29 | 29 | // check by the permission of eather 'altsys' or 'system' |
30 | - $module_handler = xoops_gethandler('module') ; |
|
31 | - $module =& $module_handler->getByDirname('altsys') ; |
|
32 | - if (! is_object($module)) { |
|
33 | - $module =& $module_handler->getByDirname('system') ; |
|
34 | - if (! is_object($module)) { |
|
35 | - die('there is no altsys nor system.') ; |
|
30 | + $module_handler = xoops_gethandler('module'); |
|
31 | + $module = & $module_handler->getByDirname('altsys'); |
|
32 | + if (!is_object($module)) { |
|
33 | + $module = & $module_handler->getByDirname('system'); |
|
34 | + if (!is_object($module)) { |
|
35 | + die('there is no altsys nor system.'); |
|
36 | 36 | } |
37 | 37 | } |
38 | - $moduleperm_handler = xoops_gethandler('groupperm') ; |
|
39 | - if (! is_object(@$GLOBALS['xoopsUser']) || ! $moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), $GLOBALS['xoopsUser']->getGroups())) { |
|
40 | - die('only admin of altsys can access this area') ; |
|
38 | + $moduleperm_handler = xoops_gethandler('groupperm'); |
|
39 | + if (!is_object(@$GLOBALS['xoopsUser']) || !$moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), $GLOBALS['xoopsUser']->getGroups())) { |
|
40 | + die('only admin of altsys can access this area'); |
|
41 | 41 | } |
42 | 42 | } else { |
43 | 43 | // check the permission of 'module_admin' of the module |
44 | 44 | if ($modid <= 0 || !is_object($GLOBALS['xoopsUser']) || !$GLOBALS['xoopsUser']->isAdmin($modid)) { |
45 | - die(_NOPERM) ; |
|
45 | + die(_NOPERM); |
|
46 | 46 | } |
47 | 47 | $module_handler = xoops_gethandler('module'); |
48 | 48 | $module = $module_handler->get($modid); |
49 | 49 | if (!is_object($module) || !$module->getVar('isactive')) { |
50 | - die(_MODULENOEXIST) ; |
|
50 | + die(_MODULENOEXIST); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | if (!empty($_POST['perms']) && is_array($_POST['perms'])) { |
57 | 57 | $gperm_handler = xoops_gethandler('groupperm'); |
58 | 58 | foreach ($_POST['perms'] as $perm_name => $perm_data) { |
59 | - foreach ($perm_data['itemname' ] as $item_id => $item_name) { |
|
59 | + foreach ($perm_data['itemname'] as $item_id => $item_name) { |
|
60 | 60 | // checking code |
61 | 61 | // echo "<pre>" ; |
62 | 62 | // var_dump( $_POST['perms'] ) ; |
63 | 63 | // exit ; |
64 | 64 | if (false != myDeleteByModule($gperm_handler->db, $modid, $perm_name, $item_id)) { |
65 | 65 | if (empty($perm_data['groups'])) { |
66 | - continue ; |
|
66 | + continue; |
|
67 | 67 | } |
68 | 68 | foreach ($perm_data['groups'] as $group_id => $item_ids) { |
69 | 69 | // foreach ($item_ids as $item_id => $selected) { |
70 | - $selected = isset($item_ids[ $item_id ]) ? $item_ids[ $item_id ] : 0 ; |
|
70 | + $selected = isset($item_ids[$item_id]) ? $item_ids[$item_id] : 0; |
|
71 | 71 | if ($selected == 1) { |
72 | 72 | // make sure that all parent ids are selected as well |
73 | 73 | if ($perm_data['parents'][$item_id] != '') { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
83 | - $gperm =& $gperm_handler->create(); |
|
83 | + $gperm = & $gperm_handler->create(); |
|
84 | 84 | $gperm->setVar('gperm_groupid', $group_id); |
85 | 85 | $gperm->setVar('gperm_name', $perm_name); |
86 | 86 | $gperm->setVar('gperm_modid', $modid); |
@@ -27,63 +27,63 @@ discard block |
||
27 | 27 | |
28 | 28 | // require_once 'PEAR.php'; // GIJ |
29 | 29 | |
30 | - // ----- Constants |
|
31 | - define('ARCHIVE_ZIP_READ_BLOCK_SIZE', 2048); |
|
32 | - |
|
33 | - // ----- File list separator |
|
34 | - define('ARCHIVE_ZIP_SEPARATOR', ','); |
|
35 | - |
|
36 | - // ----- Optional static temporary directory |
|
37 | - // By default temporary files are generated in the script current |
|
38 | - // path. |
|
39 | - // If defined : |
|
40 | - // - MUST BE terminated by a '/'. |
|
41 | - // - MUST be a valid, already created directory |
|
42 | - // Samples : |
|
43 | - // define( 'ARCHIVE_ZIP_TEMPORARY_DIR', '/temp/' ); |
|
44 | - // define( 'ARCHIVE_ZIP_TEMPORARY_DIR', 'C:/Temp/' ); |
|
45 | - define('ARCHIVE_ZIP_TEMPORARY_DIR', ''); |
|
46 | - |
|
47 | - // ----- Error codes |
|
48 | - define('ARCHIVE_ZIP_ERR_NO_ERROR', 0); |
|
49 | - define('ARCHIVE_ZIP_ERR_WRITE_OPEN_FAIL', -1); |
|
50 | - define('ARCHIVE_ZIP_ERR_READ_OPEN_FAIL', -2); |
|
51 | - define('ARCHIVE_ZIP_ERR_INVALID_PARAMETER', -3); |
|
52 | - define('ARCHIVE_ZIP_ERR_MISSING_FILE', -4); |
|
53 | - define('ARCHIVE_ZIP_ERR_FILENAME_TOO_LONG', -5); |
|
54 | - define('ARCHIVE_ZIP_ERR_INVALID_ZIP', -6); |
|
55 | - define('ARCHIVE_ZIP_ERR_BAD_EXTRACTED_FILE', -7); |
|
56 | - define('ARCHIVE_ZIP_ERR_DIR_CREATE_FAIL', -8); |
|
57 | - define('ARCHIVE_ZIP_ERR_BAD_EXTENSION', -9); |
|
58 | - define('ARCHIVE_ZIP_ERR_BAD_FORMAT', -10); |
|
59 | - define('ARCHIVE_ZIP_ERR_DELETE_FILE_FAIL', -11); |
|
60 | - define('ARCHIVE_ZIP_ERR_RENAME_FILE_FAIL', -12); |
|
61 | - define('ARCHIVE_ZIP_ERR_BAD_CHECKSUM', -13); |
|
62 | - define('ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP', -14); |
|
63 | - define('ARCHIVE_ZIP_ERR_MISSING_OPTION_VALUE', -15); |
|
64 | - define('ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE', -16); |
|
65 | - |
|
66 | - // ----- Warning codes |
|
67 | - define('ARCHIVE_ZIP_WARN_NO_WARNING', 0); |
|
68 | - define('ARCHIVE_ZIP_WARN_FILE_EXIST', 1); |
|
69 | - |
|
70 | - // ----- Methods parameters |
|
71 | - define('ARCHIVE_ZIP_PARAM_PATH', 'path'); |
|
72 | - define('ARCHIVE_ZIP_PARAM_ADD_PATH', 'add_path'); |
|
73 | - define('ARCHIVE_ZIP_PARAM_REMOVE_PATH', 'remove_path'); |
|
74 | - define('ARCHIVE_ZIP_PARAM_REMOVE_ALL_PATH', 'remove_all_path'); |
|
75 | - define('ARCHIVE_ZIP_PARAM_SET_CHMOD', 'set_chmod'); |
|
76 | - define('ARCHIVE_ZIP_PARAM_EXTRACT_AS_STRING', 'extract_as_string'); |
|
77 | - define('ARCHIVE_ZIP_PARAM_NO_COMPRESSION', 'no_compression'); |
|
78 | - define('ARCHIVE_ZIP_PARAM_BY_NAME', 'by_name'); |
|
79 | - define('ARCHIVE_ZIP_PARAM_BY_INDEX', 'by_index'); |
|
80 | - define('ARCHIVE_ZIP_PARAM_BY_EREG', 'by_ereg'); |
|
81 | - define('ARCHIVE_ZIP_PARAM_BY_PREG', 'by_preg'); |
|
82 | - |
|
83 | - define('ARCHIVE_ZIP_PARAM_PRE_EXTRACT', 'callback_pre_extract'); |
|
84 | - define('ARCHIVE_ZIP_PARAM_POST_EXTRACT', 'callback_post_extract'); |
|
85 | - define('ARCHIVE_ZIP_PARAM_PRE_ADD', 'callback_pre_add'); |
|
86 | - define('ARCHIVE_ZIP_PARAM_POST_ADD', 'callback_post_add'); |
|
30 | + // ----- Constants |
|
31 | + define('ARCHIVE_ZIP_READ_BLOCK_SIZE', 2048); |
|
32 | + |
|
33 | + // ----- File list separator |
|
34 | + define('ARCHIVE_ZIP_SEPARATOR', ','); |
|
35 | + |
|
36 | + // ----- Optional static temporary directory |
|
37 | + // By default temporary files are generated in the script current |
|
38 | + // path. |
|
39 | + // If defined : |
|
40 | + // - MUST BE terminated by a '/'. |
|
41 | + // - MUST be a valid, already created directory |
|
42 | + // Samples : |
|
43 | + // define( 'ARCHIVE_ZIP_TEMPORARY_DIR', '/temp/' ); |
|
44 | + // define( 'ARCHIVE_ZIP_TEMPORARY_DIR', 'C:/Temp/' ); |
|
45 | + define('ARCHIVE_ZIP_TEMPORARY_DIR', ''); |
|
46 | + |
|
47 | + // ----- Error codes |
|
48 | + define('ARCHIVE_ZIP_ERR_NO_ERROR', 0); |
|
49 | + define('ARCHIVE_ZIP_ERR_WRITE_OPEN_FAIL', -1); |
|
50 | + define('ARCHIVE_ZIP_ERR_READ_OPEN_FAIL', -2); |
|
51 | + define('ARCHIVE_ZIP_ERR_INVALID_PARAMETER', -3); |
|
52 | + define('ARCHIVE_ZIP_ERR_MISSING_FILE', -4); |
|
53 | + define('ARCHIVE_ZIP_ERR_FILENAME_TOO_LONG', -5); |
|
54 | + define('ARCHIVE_ZIP_ERR_INVALID_ZIP', -6); |
|
55 | + define('ARCHIVE_ZIP_ERR_BAD_EXTRACTED_FILE', -7); |
|
56 | + define('ARCHIVE_ZIP_ERR_DIR_CREATE_FAIL', -8); |
|
57 | + define('ARCHIVE_ZIP_ERR_BAD_EXTENSION', -9); |
|
58 | + define('ARCHIVE_ZIP_ERR_BAD_FORMAT', -10); |
|
59 | + define('ARCHIVE_ZIP_ERR_DELETE_FILE_FAIL', -11); |
|
60 | + define('ARCHIVE_ZIP_ERR_RENAME_FILE_FAIL', -12); |
|
61 | + define('ARCHIVE_ZIP_ERR_BAD_CHECKSUM', -13); |
|
62 | + define('ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP', -14); |
|
63 | + define('ARCHIVE_ZIP_ERR_MISSING_OPTION_VALUE', -15); |
|
64 | + define('ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE', -16); |
|
65 | + |
|
66 | + // ----- Warning codes |
|
67 | + define('ARCHIVE_ZIP_WARN_NO_WARNING', 0); |
|
68 | + define('ARCHIVE_ZIP_WARN_FILE_EXIST', 1); |
|
69 | + |
|
70 | + // ----- Methods parameters |
|
71 | + define('ARCHIVE_ZIP_PARAM_PATH', 'path'); |
|
72 | + define('ARCHIVE_ZIP_PARAM_ADD_PATH', 'add_path'); |
|
73 | + define('ARCHIVE_ZIP_PARAM_REMOVE_PATH', 'remove_path'); |
|
74 | + define('ARCHIVE_ZIP_PARAM_REMOVE_ALL_PATH', 'remove_all_path'); |
|
75 | + define('ARCHIVE_ZIP_PARAM_SET_CHMOD', 'set_chmod'); |
|
76 | + define('ARCHIVE_ZIP_PARAM_EXTRACT_AS_STRING', 'extract_as_string'); |
|
77 | + define('ARCHIVE_ZIP_PARAM_NO_COMPRESSION', 'no_compression'); |
|
78 | + define('ARCHIVE_ZIP_PARAM_BY_NAME', 'by_name'); |
|
79 | + define('ARCHIVE_ZIP_PARAM_BY_INDEX', 'by_index'); |
|
80 | + define('ARCHIVE_ZIP_PARAM_BY_EREG', 'by_ereg'); |
|
81 | + define('ARCHIVE_ZIP_PARAM_BY_PREG', 'by_preg'); |
|
82 | + |
|
83 | + define('ARCHIVE_ZIP_PARAM_PRE_EXTRACT', 'callback_pre_extract'); |
|
84 | + define('ARCHIVE_ZIP_PARAM_POST_EXTRACT', 'callback_post_extract'); |
|
85 | + define('ARCHIVE_ZIP_PARAM_PRE_ADD', 'callback_pre_add'); |
|
86 | + define('ARCHIVE_ZIP_PARAM_POST_ADD', 'callback_post_add'); |
|
87 | 87 | |
88 | 88 | |
89 | 89 | |
@@ -102,55 +102,55 @@ discard block |
||
102 | 102 | class Archive_Zip |
103 | 103 | { |
104 | 104 | /** |
105 | - * The filename of the zip archive. |
|
106 | - * |
|
107 | - * @var string Name of the Zip file |
|
108 | - */ |
|
105 | + * The filename of the zip archive. |
|
106 | + * |
|
107 | + * @var string Name of the Zip file |
|
108 | + */ |
|
109 | 109 | public $_zipname=''; |
110 | 110 | |
111 | 111 | /** |
112 | - * File descriptor of the opened Zip file. |
|
113 | - * |
|
114 | - * @var int Internal zip file descriptor |
|
115 | - */ |
|
112 | + * File descriptor of the opened Zip file. |
|
113 | + * |
|
114 | + * @var int Internal zip file descriptor |
|
115 | + */ |
|
116 | 116 | public $_zip_fd=0; |
117 | 117 | |
118 | 118 | /** |
119 | - * @var int last error code |
|
120 | - */ |
|
119 | + * @var int last error code |
|
120 | + */ |
|
121 | 121 | public $_error_code=1; |
122 | 122 | |
123 | 123 | /** |
124 | - * @var string Last error description |
|
125 | - */ |
|
124 | + * @var string Last error description |
|
125 | + */ |
|
126 | 126 | public $_error_string=''; |
127 | 127 | |
128 | 128 | // {{{ constructor |
129 | 129 | /** |
130 | - * Archive_Zip Class constructor. This flavour of the constructor only |
|
131 | - * declare a new Archive_Zip object, identifying it by the name of the |
|
132 | - * zip file. |
|
133 | - * |
|
134 | - * @param string $p_zipname The name of the zip archive to create |
|
135 | - * @access public |
|
136 | - */ |
|
130 | + * Archive_Zip Class constructor. This flavour of the constructor only |
|
131 | + * declare a new Archive_Zip object, identifying it by the name of the |
|
132 | + * zip file. |
|
133 | + * |
|
134 | + * @param string $p_zipname The name of the zip archive to create |
|
135 | + * @access public |
|
136 | + */ |
|
137 | 137 | //HACK by domifara |
138 | 138 | // function Archive_Zip($p_zipname) |
139 | 139 | public function __construct($p_zipname) |
140 | 140 | { |
141 | 141 | |
142 | - // ----- Check the zlib |
|
142 | + // ----- Check the zlib |
|
143 | 143 | /* if (!extension_loaded('zlib')) { |
144 | 144 | PEAR::loadExtension('zlib'); |
145 | 145 | }*/ // GIJ |
146 | - if (!extension_loaded('zlib')) { |
|
147 | - die("The extension 'zlib' couldn't be found.\n". 'Please make sure your version of PHP was built ' . |
|
148 | - "with 'zlib' support.\n"); |
|
149 | - return false; |
|
150 | - } |
|
151 | - |
|
152 | - // ----- Set the attributes |
|
153 | - $this->_zipname = $p_zipname; |
|
146 | + if (!extension_loaded('zlib')) { |
|
147 | + die("The extension 'zlib' couldn't be found.\n". 'Please make sure your version of PHP was built ' . |
|
148 | + "with 'zlib' support.\n"); |
|
149 | + return false; |
|
150 | + } |
|
151 | + |
|
152 | + // ----- Set the attributes |
|
153 | + $this->_zipname = $p_zipname; |
|
154 | 154 | $this->_zip_fd = 0; |
155 | 155 | |
156 | 156 | return; |
@@ -159,27 +159,27 @@ discard block |
||
159 | 159 | |
160 | 160 | // {{{ create() |
161 | 161 | /** |
162 | - * This method creates a Zip Archive with the filename set with |
|
163 | - * the constructor. |
|
164 | - * The files and directories indicated in $p_filelist |
|
165 | - * are added in the archive. |
|
166 | - * When a directory is in the list, the directory and its content is added |
|
167 | - * in the archive. |
|
168 | - * The methods takes a variable list of parameters in $p_params. |
|
169 | - * The supported parameters for this method are : |
|
170 | - * 'add_path' : Add a path to the archived files. |
|
171 | - * 'remove_path' : Remove the specified 'root' path of the archived files. |
|
172 | - * 'remove_all_path' : Remove all the path of the archived files. |
|
173 | - * 'no_compression' : The archived files will not be compressed. |
|
174 | - * |
|
175 | - * @access public |
|
176 | - * @param mixed $p_filelist The list of the files or folders to add. |
|
177 | - * It can be a string with filenames separated |
|
178 | - * by a comma, or an array of filenames. |
|
179 | - * @param mixed $p_params An array of variable parameters and values. |
|
180 | - * @return mixed An array of file description on success, |
|
181 | - * an error code on error |
|
182 | - */ |
|
162 | + * This method creates a Zip Archive with the filename set with |
|
163 | + * the constructor. |
|
164 | + * The files and directories indicated in $p_filelist |
|
165 | + * are added in the archive. |
|
166 | + * When a directory is in the list, the directory and its content is added |
|
167 | + * in the archive. |
|
168 | + * The methods takes a variable list of parameters in $p_params. |
|
169 | + * The supported parameters for this method are : |
|
170 | + * 'add_path' : Add a path to the archived files. |
|
171 | + * 'remove_path' : Remove the specified 'root' path of the archived files. |
|
172 | + * 'remove_all_path' : Remove all the path of the archived files. |
|
173 | + * 'no_compression' : The archived files will not be compressed. |
|
174 | + * |
|
175 | + * @access public |
|
176 | + * @param mixed $p_filelist The list of the files or folders to add. |
|
177 | + * It can be a string with filenames separated |
|
178 | + * by a comma, or an array of filenames. |
|
179 | + * @param mixed $p_params An array of variable parameters and values. |
|
180 | + * @return mixed An array of file description on success, |
|
181 | + * an error code on error |
|
182 | + */ |
|
183 | 183 | public function create($p_filelist, $p_params=0) |
184 | 184 | { |
185 | 185 | $this->_errorReset(); |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | $p_params = array(); |
190 | 190 | } |
191 | 191 | if ($this->_check_parameters($p_params, |
192 | - array('no_compression' => false, |
|
193 | - 'add_path' => '', |
|
194 | - 'remove_path' => '', |
|
195 | - 'remove_all_path' => false)) != 1) { |
|
192 | + array('no_compression' => false, |
|
193 | + 'add_path' => '', |
|
194 | + 'remove_path' => '', |
|
195 | + 'remove_all_path' => false)) != 1) { |
|
196 | 196 | return 0; |
197 | 197 | } |
198 | 198 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | // ----- Invalid variable |
214 | 214 | else { |
215 | 215 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
216 | - 'Invalid variable type p_filelist'); |
|
216 | + 'Invalid variable type p_filelist'); |
|
217 | 217 | $v_result = ARCHIVE_ZIP_ERR_INVALID_PARAMETER; |
218 | 218 | } |
219 | 219 | |
@@ -227,30 +227,30 @@ discard block |
||
227 | 227 | |
228 | 228 | // {{{ add() |
229 | 229 | /** |
230 | - * This method add files or directory in an existing Zip Archive. |
|
231 | - * If the Zip Archive does not exist it is created. |
|
232 | - * The files and directories to add are indicated in $p_filelist. |
|
233 | - * When a directory is in the list, the directory and its content is added |
|
234 | - * in the archive. |
|
235 | - * The methods takes a variable list of parameters in $p_params. |
|
236 | - * The supported parameters for this method are : |
|
237 | - * 'add_path' : Add a path to the archived files. |
|
238 | - * 'remove_path' : Remove the specified 'root' path of the archived files. |
|
239 | - * 'remove_all_path' : Remove all the path of the archived files. |
|
240 | - * 'no_compression' : The archived files will not be compressed. |
|
241 | - * 'callback_pre_add' : A callback function that will be called before |
|
242 | - * each entry archiving. |
|
243 | - * 'callback_post_add' : A callback function that will be called after |
|
244 | - * each entry archiving. |
|
245 | - * |
|
246 | - * @access public |
|
247 | - * @param mixed $p_filelist The list of the files or folders to add. |
|
248 | - * It can be a string with filenames separated |
|
249 | - * by a comma, or an array of filenames. |
|
250 | - * @param mixed $p_params An array of variable parameters and values. |
|
251 | - * @return mixed An array of file description on success, |
|
252 | - * 0 on an unrecoverable failure, an error code is logged. |
|
253 | - */ |
|
230 | + * This method add files or directory in an existing Zip Archive. |
|
231 | + * If the Zip Archive does not exist it is created. |
|
232 | + * The files and directories to add are indicated in $p_filelist. |
|
233 | + * When a directory is in the list, the directory and its content is added |
|
234 | + * in the archive. |
|
235 | + * The methods takes a variable list of parameters in $p_params. |
|
236 | + * The supported parameters for this method are : |
|
237 | + * 'add_path' : Add a path to the archived files. |
|
238 | + * 'remove_path' : Remove the specified 'root' path of the archived files. |
|
239 | + * 'remove_all_path' : Remove all the path of the archived files. |
|
240 | + * 'no_compression' : The archived files will not be compressed. |
|
241 | + * 'callback_pre_add' : A callback function that will be called before |
|
242 | + * each entry archiving. |
|
243 | + * 'callback_post_add' : A callback function that will be called after |
|
244 | + * each entry archiving. |
|
245 | + * |
|
246 | + * @access public |
|
247 | + * @param mixed $p_filelist The list of the files or folders to add. |
|
248 | + * It can be a string with filenames separated |
|
249 | + * by a comma, or an array of filenames. |
|
250 | + * @param mixed $p_params An array of variable parameters and values. |
|
251 | + * @return mixed An array of file description on success, |
|
252 | + * 0 on an unrecoverable failure, an error code is logged. |
|
253 | + */ |
|
254 | 254 | public function add($p_filelist, $p_params=0) |
255 | 255 | { |
256 | 256 | $this->_errorReset(); |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | $p_params = array(); |
261 | 261 | } |
262 | 262 | if ($this->_check_parameters($p_params, |
263 | - array('no_compression' => false, |
|
263 | + array('no_compression' => false, |
|
264 | 264 | 'add_path' => '', |
265 | 265 | 'remove_path' => '', |
266 | 266 | 'remove_all_path' => false, |
267 | - 'callback_pre_add' => '', |
|
267 | + 'callback_pre_add' => '', |
|
268 | 268 | 'callback_post_add' => '')) != 1) { |
269 | 269 | return 0; |
270 | 270 | } |
@@ -302,48 +302,48 @@ discard block |
||
302 | 302 | |
303 | 303 | // {{{ listContent() |
304 | 304 | /** |
305 | - * This method gives the names and properties of the files and directories |
|
306 | - * which are present in the zip archive. |
|
307 | - * The properties of each entries in the list are : |
|
308 | - * filename : Name of the file. |
|
309 | - * For create() or add() it's the filename given by the user. |
|
310 | - * For an extract() it's the filename of the extracted file. |
|
311 | - * stored_filename : Name of the file / directory stored in the archive. |
|
312 | - * size : Size of the stored file. |
|
313 | - * compressed_size : Size of the file's data compressed in the archive |
|
314 | - * (without the zip headers overhead) |
|
315 | - * mtime : Last known modification date of the file (UNIX timestamp) |
|
316 | - * comment : Comment associated with the file |
|
317 | - * folder : true | false (indicates if the entry is a folder) |
|
318 | - * index : index of the file in the archive (-1 when not available) |
|
319 | - * status : status of the action on the entry (depending of the action) : |
|
320 | - * Values are : |
|
321 | - * ok : OK ! |
|
322 | - * filtered : the file/dir was not extracted (filtered by user) |
|
323 | - * already_a_directory : the file can't be extracted because a |
|
324 | - * directory with the same name already |
|
325 | - * exists |
|
326 | - * write_protected : the file can't be extracted because a file |
|
327 | - * with the same name already exists and is |
|
328 | - * write protected |
|
329 | - * newer_exist : the file was not extracted because a newer |
|
330 | - * file already exists |
|
331 | - * path_creation_fail : the file is not extracted because the |
|
332 | - * folder does not exists and can't be |
|
333 | - * created |
|
334 | - * write_error : the file was not extracted because there was a |
|
335 | - * error while writing the file |
|
336 | - * read_error : the file was not extracted because there was a |
|
337 | - * error while reading the file |
|
338 | - * invalid_header : the file was not extracted because of an |
|
339 | - * archive format error (bad file header) |
|
340 | - * Note that each time a method can continue operating when there |
|
341 | - * is an error on a single file, the error is only logged in the file status. |
|
342 | - * |
|
343 | - * @access public |
|
344 | - * @return mixed An array of file description on success, |
|
345 | - * 0 on an unrecoverable failure, an error code is logged. |
|
346 | - */ |
|
305 | + * This method gives the names and properties of the files and directories |
|
306 | + * which are present in the zip archive. |
|
307 | + * The properties of each entries in the list are : |
|
308 | + * filename : Name of the file. |
|
309 | + * For create() or add() it's the filename given by the user. |
|
310 | + * For an extract() it's the filename of the extracted file. |
|
311 | + * stored_filename : Name of the file / directory stored in the archive. |
|
312 | + * size : Size of the stored file. |
|
313 | + * compressed_size : Size of the file's data compressed in the archive |
|
314 | + * (without the zip headers overhead) |
|
315 | + * mtime : Last known modification date of the file (UNIX timestamp) |
|
316 | + * comment : Comment associated with the file |
|
317 | + * folder : true | false (indicates if the entry is a folder) |
|
318 | + * index : index of the file in the archive (-1 when not available) |
|
319 | + * status : status of the action on the entry (depending of the action) : |
|
320 | + * Values are : |
|
321 | + * ok : OK ! |
|
322 | + * filtered : the file/dir was not extracted (filtered by user) |
|
323 | + * already_a_directory : the file can't be extracted because a |
|
324 | + * directory with the same name already |
|
325 | + * exists |
|
326 | + * write_protected : the file can't be extracted because a file |
|
327 | + * with the same name already exists and is |
|
328 | + * write protected |
|
329 | + * newer_exist : the file was not extracted because a newer |
|
330 | + * file already exists |
|
331 | + * path_creation_fail : the file is not extracted because the |
|
332 | + * folder does not exists and can't be |
|
333 | + * created |
|
334 | + * write_error : the file was not extracted because there was a |
|
335 | + * error while writing the file |
|
336 | + * read_error : the file was not extracted because there was a |
|
337 | + * error while reading the file |
|
338 | + * invalid_header : the file was not extracted because of an |
|
339 | + * archive format error (bad file header) |
|
340 | + * Note that each time a method can continue operating when there |
|
341 | + * is an error on a single file, the error is only logged in the file status. |
|
342 | + * |
|
343 | + * @access public |
|
344 | + * @return mixed An array of file description on success, |
|
345 | + * 0 on an unrecoverable failure, an error code is logged. |
|
346 | + */ |
|
347 | 347 | public function listContent() |
348 | 348 | { |
349 | 349 | $this->_errorReset(); |
@@ -365,42 +365,42 @@ discard block |
||
365 | 365 | |
366 | 366 | // {{{ extract() |
367 | 367 | /** |
368 | - * This method extract the files and folders which are in the zip archive. |
|
369 | - * It can extract all the archive or a part of the archive by using filter |
|
370 | - * feature (extract by name, by index, by ereg, by preg). The extraction |
|
371 | - * can occur in the current path or an other path. |
|
372 | - * All the advanced features are activated by the use of variable |
|
373 | - * parameters. |
|
374 | - * The return value is an array of entry descriptions which gives |
|
375 | - * information on extracted files (See listContent()). |
|
376 | - * The method may return a success value (an array) even if some files |
|
377 | - * are not correctly extracted (see the file status in listContent()). |
|
378 | - * The supported variable parameters for this method are : |
|
379 | - * 'add_path' : Path where the files and directories are to be extracted |
|
380 | - * 'remove_path' : First part ('root' part) of the memorized path |
|
381 | - * (if similar) to remove while extracting. |
|
382 | - * 'remove_all_path' : Remove all the memorized path while extracting. |
|
383 | - * 'extract_as_string' : |
|
384 | - * 'set_chmod' : After the extraction of the file the indicated mode |
|
385 | - * will be set. |
|
386 | - * 'by_name' : It can be a string with file/dir names separated by ',', |
|
387 | - * or an array of file/dir names to extract from the archive. |
|
388 | - * 'by_index' : A string with range of indexes separated by ',', |
|
389 | - * (sample "1,3-5,12"). |
|
390 | - * 'by_ereg' : A regular expression (ereg) that must match the extracted |
|
391 | - * filename. |
|
392 | - * 'by_preg' : A regular expression (preg) that must match the extracted |
|
393 | - * filename. |
|
394 | - * 'callback_pre_extract' : A callback function that will be called before |
|
395 | - * each entry extraction. |
|
396 | - * 'callback_post_extract' : A callback function that will be called after |
|
397 | - * each entry extraction. |
|
398 | - * |
|
399 | - * @access public |
|
400 | - * @param mixed $p_params An array of variable parameters and values. |
|
401 | - * @return mixed An array of file description on success, |
|
402 | - * 0 on an unrecoverable failure, an error code is logged. |
|
403 | - */ |
|
368 | + * This method extract the files and folders which are in the zip archive. |
|
369 | + * It can extract all the archive or a part of the archive by using filter |
|
370 | + * feature (extract by name, by index, by ereg, by preg). The extraction |
|
371 | + * can occur in the current path or an other path. |
|
372 | + * All the advanced features are activated by the use of variable |
|
373 | + * parameters. |
|
374 | + * The return value is an array of entry descriptions which gives |
|
375 | + * information on extracted files (See listContent()). |
|
376 | + * The method may return a success value (an array) even if some files |
|
377 | + * are not correctly extracted (see the file status in listContent()). |
|
378 | + * The supported variable parameters for this method are : |
|
379 | + * 'add_path' : Path where the files and directories are to be extracted |
|
380 | + * 'remove_path' : First part ('root' part) of the memorized path |
|
381 | + * (if similar) to remove while extracting. |
|
382 | + * 'remove_all_path' : Remove all the memorized path while extracting. |
|
383 | + * 'extract_as_string' : |
|
384 | + * 'set_chmod' : After the extraction of the file the indicated mode |
|
385 | + * will be set. |
|
386 | + * 'by_name' : It can be a string with file/dir names separated by ',', |
|
387 | + * or an array of file/dir names to extract from the archive. |
|
388 | + * 'by_index' : A string with range of indexes separated by ',', |
|
389 | + * (sample "1,3-5,12"). |
|
390 | + * 'by_ereg' : A regular expression (ereg) that must match the extracted |
|
391 | + * filename. |
|
392 | + * 'by_preg' : A regular expression (preg) that must match the extracted |
|
393 | + * filename. |
|
394 | + * 'callback_pre_extract' : A callback function that will be called before |
|
395 | + * each entry extraction. |
|
396 | + * 'callback_post_extract' : A callback function that will be called after |
|
397 | + * each entry extraction. |
|
398 | + * |
|
399 | + * @access public |
|
400 | + * @param mixed $p_params An array of variable parameters and values. |
|
401 | + * @return mixed An array of file description on success, |
|
402 | + * 0 on an unrecoverable failure, an error code is logged. |
|
403 | + */ |
|
404 | 404 | public function extract($p_params=0) |
405 | 405 | { |
406 | 406 | $this->_errorReset(); |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | $p_params = array(); |
416 | 416 | } |
417 | 417 | if ($this->_check_parameters($p_params, |
418 | - array('extract_as_string' => false, |
|
418 | + array('extract_as_string' => false, |
|
419 | 419 | 'add_path' => '', |
420 | 420 | 'remove_path' => '', |
421 | 421 | 'remove_all_path' => false, |
422 | - 'callback_pre_extract' => '', |
|
422 | + 'callback_pre_extract' => '', |
|
423 | 423 | 'callback_post_extract' => '', |
424 | 424 | 'set_chmod' => 0, |
425 | 425 | 'by_name' => '', |
@@ -443,26 +443,26 @@ discard block |
||
443 | 443 | |
444 | 444 | // {{{ delete() |
445 | 445 | /** |
446 | - * This methods delete archive entries in the zip archive. |
|
447 | - * Notice that at least one filtering rule (set by the variable parameter |
|
448 | - * list) must be set. |
|
449 | - * Also notice that if you delete a folder entry, only the folder entry |
|
450 | - * is deleted, not all the files bellonging to this folder. |
|
451 | - * The supported variable parameters for this method are : |
|
452 | - * 'by_name' : It can be a string with file/dir names separated by ',', |
|
453 | - * or an array of file/dir names to delete from the archive. |
|
454 | - * 'by_index' : A string with range of indexes separated by ',', |
|
455 | - * (sample "1,3-5,12"). |
|
456 | - * 'by_ereg' : A regular expression (ereg) that must match the extracted |
|
457 | - * filename. |
|
458 | - * 'by_preg' : A regular expression (preg) that must match the extracted |
|
459 | - * filename. |
|
460 | - * |
|
461 | - * @access public |
|
462 | - * @param mixed $p_params An array of variable parameters and values. |
|
463 | - * @return mixed An array of file description on success, |
|
464 | - * 0 on an unrecoverable failure, an error code is logged. |
|
465 | - */ |
|
446 | + * This methods delete archive entries in the zip archive. |
|
447 | + * Notice that at least one filtering rule (set by the variable parameter |
|
448 | + * list) must be set. |
|
449 | + * Also notice that if you delete a folder entry, only the folder entry |
|
450 | + * is deleted, not all the files bellonging to this folder. |
|
451 | + * The supported variable parameters for this method are : |
|
452 | + * 'by_name' : It can be a string with file/dir names separated by ',', |
|
453 | + * or an array of file/dir names to delete from the archive. |
|
454 | + * 'by_index' : A string with range of indexes separated by ',', |
|
455 | + * (sample "1,3-5,12"). |
|
456 | + * 'by_ereg' : A regular expression (ereg) that must match the extracted |
|
457 | + * filename. |
|
458 | + * 'by_preg' : A regular expression (preg) that must match the extracted |
|
459 | + * filename. |
|
460 | + * |
|
461 | + * @access public |
|
462 | + * @param mixed $p_params An array of variable parameters and values. |
|
463 | + * @return mixed An array of file description on success, |
|
464 | + * 0 on an unrecoverable failure, an error code is logged. |
|
465 | + */ |
|
466 | 466 | public function delete($p_params) |
467 | 467 | { |
468 | 468 | $this->_errorReset(); |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | |
475 | 475 | // ----- Set default values |
476 | 476 | if ($this->_check_parameters($p_params, |
477 | - array('by_name' => '', |
|
477 | + array('by_name' => '', |
|
478 | 478 | 'by_index' => '', |
479 | 479 | 'by_ereg' => '', |
480 | 480 | 'by_preg' => '')) != 1) { |
@@ -487,8 +487,8 @@ discard block |
||
487 | 487 | && ($p_params['by_ereg'] == '') |
488 | 488 | && ($p_params['by_preg'] == '')) { |
489 | 489 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
490 | - 'At least one filtering rule must' |
|
491 | - .' be set as parameter'); |
|
490 | + 'At least one filtering rule must' |
|
491 | + .' be set as parameter'); |
|
492 | 492 | return 0; |
493 | 493 | } |
494 | 494 | |
@@ -505,16 +505,16 @@ discard block |
||
505 | 505 | |
506 | 506 | // {{{ properties() |
507 | 507 | /** |
508 | - * This method gives the global properties of the archive. |
|
509 | - * The properties are : |
|
510 | - * nb : Number of files in the archive |
|
511 | - * comment : Comment associated with the archive file |
|
512 | - * status : not_exist, ok |
|
513 | - * |
|
514 | - * @access public |
|
515 | - * @param mixed $p_params {Description} |
|
516 | - * @return mixed An array with the global properties or 0 on error. |
|
517 | - */ |
|
508 | + * This method gives the global properties of the archive. |
|
509 | + * The properties are : |
|
510 | + * nb : Number of files in the archive |
|
511 | + * comment : Comment associated with the archive file |
|
512 | + * status : not_exist, ok |
|
513 | + * |
|
514 | + * @access public |
|
515 | + * @param mixed $p_params {Description} |
|
516 | + * @return mixed An array with the global properties or 0 on error. |
|
517 | + */ |
|
518 | 518 | public function properties() |
519 | 519 | { |
520 | 520 | $this->_errorReset(); |
@@ -535,8 +535,8 @@ discard block |
||
535 | 535 | // ----- Open the zip file |
536 | 536 | if (($this->_zip_fd = @fopen($this->_zipname, 'rb')) == 0) { |
537 | 537 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
538 | - 'Unable to open archive \''.$this->_zipname |
|
539 | - .'\' in binary read mode'); |
|
538 | + 'Unable to open archive \''.$this->_zipname |
|
539 | + .'\' in binary read mode'); |
|
540 | 540 | return 0; |
541 | 541 | } |
542 | 542 | |
@@ -561,15 +561,15 @@ discard block |
||
561 | 561 | |
562 | 562 | // {{{ duplicate() |
563 | 563 | /** |
564 | - * This method creates an archive by copying the content of an other one. |
|
565 | - * If the archive already exist, it is replaced by the new one without |
|
566 | - * any warning. |
|
567 | - * |
|
568 | - * @access public |
|
569 | - * @param mixed $p_archive It can be a valid Archive_Zip object or |
|
570 | - * the filename of a valid zip archive. |
|
571 | - * @return integer 1 on success, 0 on failure. |
|
572 | - */ |
|
564 | + * This method creates an archive by copying the content of an other one. |
|
565 | + * If the archive already exist, it is replaced by the new one without |
|
566 | + * any warning. |
|
567 | + * |
|
568 | + * @access public |
|
569 | + * @param mixed $p_archive It can be a valid Archive_Zip object or |
|
570 | + * the filename of a valid zip archive. |
|
571 | + * @return integer 1 on success, 0 on failure. |
|
572 | + */ |
|
573 | 573 | public function duplicate($p_archive) |
574 | 574 | { |
575 | 575 | $this->_errorReset(); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | // TBC : Should also check the archive format |
587 | 587 | if (!is_file($p_archive)) { |
588 | 588 | $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, |
589 | - "No file with filename '".$p_archive."'"); |
|
589 | + "No file with filename '".$p_archive."'"); |
|
590 | 590 | $v_result = ARCHIVE_ZIP_ERR_MISSING_FILE; |
591 | 591 | } else { |
592 | 592 | $v_result = $this->_duplicate($p_archive); |
@@ -605,16 +605,16 @@ discard block |
||
605 | 605 | |
606 | 606 | // {{{ merge() |
607 | 607 | /** |
608 | - * This method merge a valid zip archive at the end of the |
|
609 | - * archive identified by the Archive_Zip object. |
|
610 | - * If the archive ($this) does not exist, the merge becomes a duplicate. |
|
611 | - * If the archive to add does not exist, the merge is a success. |
|
612 | - * |
|
613 | - * @access public |
|
614 | - * @param mixed $p_archive_to_add It can be a valid Archive_Zip object or |
|
615 | - * the filename of a valid zip archive. |
|
616 | - * @return integer 1 on success, 0 on failure. |
|
617 | - */ |
|
608 | + * This method merge a valid zip archive at the end of the |
|
609 | + * archive identified by the Archive_Zip object. |
|
610 | + * If the archive ($this) does not exist, the merge becomes a duplicate. |
|
611 | + * If the archive to add does not exist, the merge is a success. |
|
612 | + * |
|
613 | + * @access public |
|
614 | + * @param mixed $p_archive_to_add It can be a valid Archive_Zip object or |
|
615 | + * the filename of a valid zip archive. |
|
616 | + * @return integer 1 on success, 0 on failure. |
|
617 | + */ |
|
618 | 618 | public function merge($p_archive_to_add) |
619 | 619 | { |
620 | 620 | $v_result = 1; |
@@ -652,11 +652,11 @@ discard block |
||
652 | 652 | |
653 | 653 | // {{{ errorCode() |
654 | 654 | /** |
655 | - * Method that gives the lastest error code. |
|
656 | - * |
|
657 | - * @access public |
|
658 | - * @return integer The error code value. |
|
659 | - */ |
|
655 | + * Method that gives the lastest error code. |
|
656 | + * |
|
657 | + * @access public |
|
658 | + * @return integer The error code value. |
|
659 | + */ |
|
660 | 660 | public function errorCode() |
661 | 661 | { |
662 | 662 | return $this->_error_code; |
@@ -665,19 +665,19 @@ discard block |
||
665 | 665 | |
666 | 666 | // {{{ errorName() |
667 | 667 | /** |
668 | - * This method gives the latest error code name. |
|
669 | - * |
|
670 | - * @access public |
|
671 | - * @param boolean $p_with_code If true, gives the name and the int value. |
|
672 | - * @return string The error name. |
|
673 | - */ |
|
668 | + * This method gives the latest error code name. |
|
669 | + * |
|
670 | + * @access public |
|
671 | + * @param boolean $p_with_code If true, gives the name and the int value. |
|
672 | + * @return string The error name. |
|
673 | + */ |
|
674 | 674 | public function errorName($p_with_code=false) |
675 | 675 | { |
676 | 676 | $v_const_list = get_defined_constants(); |
677 | 677 | |
678 | - // ----- Extract error constants from all const. |
|
678 | + // ----- Extract error constants from all const. |
|
679 | 679 | for (reset($v_const_list); |
680 | - list($v_key, $v_value) = each($v_const_list);) { |
|
680 | + list($v_key, $v_value) = each($v_const_list);) { |
|
681 | 681 | if (substr($v_key, 0, strlen('ARCHIVE_ZIP_ERR_')) |
682 | 682 | =='ARCHIVE_ZIP_ERR_') { |
683 | 683 | $v_error_list[$v_key] = $v_value; |
@@ -702,15 +702,15 @@ discard block |
||
702 | 702 | |
703 | 703 | // {{{ errorInfo() |
704 | 704 | /** |
705 | - * This method returns the description associated with the latest error. |
|
706 | - * |
|
707 | - * @access public |
|
708 | - * @param boolean $p_full If set to true gives the description with the |
|
709 | - * error code, the name and the description. |
|
710 | - * If set to false gives only the description |
|
711 | - * and the error code. |
|
712 | - * @return string The error description. |
|
713 | - */ |
|
705 | + * This method returns the description associated with the latest error. |
|
706 | + * |
|
707 | + * @access public |
|
708 | + * @param boolean $p_full If set to true gives the description with the |
|
709 | + * error code, the name and the description. |
|
710 | + * If set to false gives only the description |
|
711 | + * and the error code. |
|
712 | + * @return string The error description. |
|
713 | + */ |
|
714 | 714 | public function errorInfo($p_full=false) |
715 | 715 | { |
716 | 716 | if ($p_full) { |
@@ -728,30 +728,30 @@ discard block |
||
728 | 728 | // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY ***** |
729 | 729 | // ----------------------------------------------------------------------------- |
730 | 730 | |
731 | - // --------------------------------------------------------------------------- |
|
732 | - // Function : _checkFormat() |
|
733 | - // Description : |
|
734 | - // This method check that the archive exists and is a valid zip archive. |
|
735 | - // Several level of check exists. (futur) |
|
736 | - // Parameters : |
|
737 | - // $p_level : Level of check. Default 0. |
|
738 | - // 0 : Check the first bytes (magic codes) (default value)) |
|
739 | - // 1 : 0 + Check the central directory (futur) |
|
740 | - // 2 : 1 + Check each file header (futur) |
|
741 | - // Return Values : |
|
742 | - // true on success, |
|
743 | - // false on error, the error code is set. |
|
744 | - // --------------------------------------------------------------------------- |
|
745 | - /** |
|
746 | - * Archive_Zip::_checkFormat() |
|
747 | - * |
|
748 | - * { Description } |
|
749 | - * |
|
750 | - * @param integer $p_level |
|
751 | - */ |
|
752 | - public function _checkFormat($p_level=0) |
|
753 | - { |
|
754 | - $v_result = true; |
|
731 | + // --------------------------------------------------------------------------- |
|
732 | + // Function : _checkFormat() |
|
733 | + // Description : |
|
734 | + // This method check that the archive exists and is a valid zip archive. |
|
735 | + // Several level of check exists. (futur) |
|
736 | + // Parameters : |
|
737 | + // $p_level : Level of check. Default 0. |
|
738 | + // 0 : Check the first bytes (magic codes) (default value)) |
|
739 | + // 1 : 0 + Check the central directory (futur) |
|
740 | + // 2 : 1 + Check each file header (futur) |
|
741 | + // Return Values : |
|
742 | + // true on success, |
|
743 | + // false on error, the error code is set. |
|
744 | + // --------------------------------------------------------------------------- |
|
745 | + /** |
|
746 | + * Archive_Zip::_checkFormat() |
|
747 | + * |
|
748 | + * { Description } |
|
749 | + * |
|
750 | + * @param integer $p_level |
|
751 | + */ |
|
752 | + public function _checkFormat($p_level=0) |
|
753 | + { |
|
754 | + $v_result = true; |
|
755 | 755 | |
756 | 756 | // ----- Reset the error handler |
757 | 757 | $this->_errorReset(); |
@@ -759,16 +759,16 @@ discard block |
||
759 | 759 | // ----- Look if the file exits |
760 | 760 | if (!is_file($this->_zipname)) { |
761 | 761 | // ----- Error log |
762 | - $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, |
|
763 | - "Missing archive file '".$this->_zipname."'"); |
|
762 | + $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, |
|
763 | + "Missing archive file '".$this->_zipname."'"); |
|
764 | 764 | return false; |
765 | 765 | } |
766 | 766 | |
767 | 767 | // ----- Check that the file is readeable |
768 | 768 | if (!is_readable($this->_zipname)) { |
769 | 769 | // ----- Error log |
770 | - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
|
771 | - "Unable to read archive '".$this->_zipname."'"); |
|
770 | + $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
|
771 | + "Unable to read archive '".$this->_zipname."'"); |
|
772 | 772 | return false; |
773 | 773 | } |
774 | 774 | |
@@ -783,34 +783,34 @@ discard block |
||
783 | 783 | |
784 | 784 | // ----- Return |
785 | 785 | return $v_result; |
786 | - } |
|
787 | - // --------------------------------------------------------------------------- |
|
788 | - |
|
789 | - // --------------------------------------------------------------------------- |
|
790 | - // Function : _create() |
|
791 | - // Description : |
|
792 | - // Parameters : |
|
793 | - // Return Values : |
|
794 | - // --------------------------------------------------------------------------- |
|
795 | - /** |
|
796 | - * Archive_Zip::_create() |
|
797 | - * |
|
798 | - * { Description } |
|
799 | - * |
|
800 | - */ |
|
801 | - public function _create($p_list, &$p_result_list, &$p_params) |
|
802 | - { |
|
803 | - $v_result=1; |
|
804 | - $v_list_detail = array(); |
|
805 | - |
|
806 | - $p_add_dir = $p_params['add_path']; |
|
807 | - $p_remove_dir = $p_params['remove_path']; |
|
808 | - $p_remove_all_dir = $p_params['remove_all_path']; |
|
786 | + } |
|
787 | + // --------------------------------------------------------------------------- |
|
788 | + |
|
789 | + // --------------------------------------------------------------------------- |
|
790 | + // Function : _create() |
|
791 | + // Description : |
|
792 | + // Parameters : |
|
793 | + // Return Values : |
|
794 | + // --------------------------------------------------------------------------- |
|
795 | + /** |
|
796 | + * Archive_Zip::_create() |
|
797 | + * |
|
798 | + * { Description } |
|
799 | + * |
|
800 | + */ |
|
801 | + public function _create($p_list, &$p_result_list, &$p_params) |
|
802 | + { |
|
803 | + $v_result=1; |
|
804 | + $v_list_detail = array(); |
|
805 | + |
|
806 | + $p_add_dir = $p_params['add_path']; |
|
807 | + $p_remove_dir = $p_params['remove_path']; |
|
808 | + $p_remove_all_dir = $p_params['remove_all_path']; |
|
809 | 809 | |
810 | 810 | // ----- Open the file in write mode |
811 | 811 | if (($v_result = $this->_openFd('wb')) != 1) { |
812 | 812 | // ----- Return |
813 | - return $v_result; |
|
813 | + return $v_result; |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | // ----- Add the list of files |
@@ -821,29 +821,29 @@ discard block |
||
821 | 821 | |
822 | 822 | // ----- Return |
823 | 823 | return $v_result; |
824 | - } |
|
825 | - // --------------------------------------------------------------------------- |
|
826 | - |
|
827 | - // --------------------------------------------------------------------------- |
|
828 | - // Function : _add() |
|
829 | - // Description : |
|
830 | - // Parameters : |
|
831 | - // Return Values : |
|
832 | - // --------------------------------------------------------------------------- |
|
833 | - /** |
|
834 | - * Archive_Zip::_add() |
|
835 | - * |
|
836 | - * { Description } |
|
837 | - * |
|
838 | - */ |
|
839 | - public function _add($p_list, &$p_result_list, &$p_params) |
|
840 | - { |
|
841 | - $v_result=1; |
|
842 | - $v_list_detail = array(); |
|
843 | - |
|
844 | - $p_add_dir = $p_params['add_path']; |
|
845 | - $p_remove_dir = $p_params['remove_path']; |
|
846 | - $p_remove_all_dir = $p_params['remove_all_path']; |
|
824 | + } |
|
825 | + // --------------------------------------------------------------------------- |
|
826 | + |
|
827 | + // --------------------------------------------------------------------------- |
|
828 | + // Function : _add() |
|
829 | + // Description : |
|
830 | + // Parameters : |
|
831 | + // Return Values : |
|
832 | + // --------------------------------------------------------------------------- |
|
833 | + /** |
|
834 | + * Archive_Zip::_add() |
|
835 | + * |
|
836 | + * { Description } |
|
837 | + * |
|
838 | + */ |
|
839 | + public function _add($p_list, &$p_result_list, &$p_params) |
|
840 | + { |
|
841 | + $v_result=1; |
|
842 | + $v_list_detail = array(); |
|
843 | + |
|
844 | + $p_add_dir = $p_params['add_path']; |
|
845 | + $p_remove_dir = $p_params['remove_path']; |
|
846 | + $p_remove_all_dir = $p_params['remove_all_path']; |
|
847 | 847 | |
848 | 848 | // ----- Look if the archive exists or is empty and need to be created |
849 | 849 | if ((!is_file($this->_zipname)) || (filesize($this->_zipname) == 0)) { |
@@ -858,10 +858,10 @@ discard block |
||
858 | 858 | |
859 | 859 | // ----- Read the central directory informations |
860 | 860 | $v_central_dir = array(); |
861 | - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
862 | - $this->_closeFd(); |
|
863 | - return $v_result; |
|
864 | - } |
|
861 | + if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
862 | + $this->_closeFd(); |
|
863 | + return $v_result; |
|
864 | + } |
|
865 | 865 | |
866 | 866 | // ----- Go to beginning of File |
867 | 867 | @rewind($this->_zip_fd); |
@@ -874,8 +874,8 @@ discard block |
||
874 | 874 | $this->_closeFd(); |
875 | 875 | |
876 | 876 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
877 | - 'Unable to open temporary file \'' |
|
878 | - .$v_zip_temp_name.'\' in binary write mode'); |
|
877 | + 'Unable to open temporary file \'' |
|
878 | + .$v_zip_temp_name.'\' in binary write mode'); |
|
879 | 879 | return Archive_Zip::errorCode(); |
880 | 880 | } |
881 | 881 | |
@@ -883,64 +883,64 @@ discard block |
||
883 | 883 | // TBC : Here I should better append the file and go back to erase the |
884 | 884 | // central dir |
885 | 885 | $v_size = $v_central_dir['offset']; |
886 | - while ($v_size != 0) { |
|
887 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
886 | + while ($v_size != 0) { |
|
887 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
888 | 888 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
889 | - $v_buffer = fread($this->_zip_fd, $v_read_size); |
|
890 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
891 | - $v_size -= $v_read_size; |
|
892 | - } |
|
889 | + $v_buffer = fread($this->_zip_fd, $v_read_size); |
|
890 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
891 | + $v_size -= $v_read_size; |
|
892 | + } |
|
893 | 893 | |
894 | 894 | // ----- Swap the file descriptor |
895 | 895 | // Here is a trick : I swap the temporary fd with the zip fd, in order to |
896 | 896 | // use the following methods on the temporary fil and not the real archive |
897 | 897 | $v_swap = $this->_zip_fd; |
898 | - $this->_zip_fd = $v_zip_temp_fd; |
|
899 | - $v_zip_temp_fd = $v_swap; |
|
898 | + $this->_zip_fd = $v_zip_temp_fd; |
|
899 | + $v_zip_temp_fd = $v_swap; |
|
900 | 900 | |
901 | 901 | // ----- Add the files |
902 | 902 | $v_header_list = array(); |
903 | - if (($v_result = $this->_addFileList($p_list, $v_header_list, |
|
904 | - $p_add_dir, $p_remove_dir, |
|
905 | - $p_remove_all_dir, $p_params)) != 1) { |
|
906 | - fclose($v_zip_temp_fd); |
|
907 | - $this->_closeFd(); |
|
908 | - @unlink($v_zip_temp_name); |
|
903 | + if (($v_result = $this->_addFileList($p_list, $v_header_list, |
|
904 | + $p_add_dir, $p_remove_dir, |
|
905 | + $p_remove_all_dir, $p_params)) != 1) { |
|
906 | + fclose($v_zip_temp_fd); |
|
907 | + $this->_closeFd(); |
|
908 | + @unlink($v_zip_temp_name); |
|
909 | 909 | |
910 | - // ----- Return |
|
911 | - return $v_result; |
|
912 | - } |
|
910 | + // ----- Return |
|
911 | + return $v_result; |
|
912 | + } |
|
913 | 913 | |
914 | 914 | // ----- Store the offset of the central dir |
915 | 915 | $v_offset = @ftell($this->_zip_fd); |
916 | 916 | |
917 | 917 | // ----- Copy the block of file headers from the old archive |
918 | 918 | $v_size = $v_central_dir['size']; |
919 | - while ($v_size != 0) { |
|
920 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
919 | + while ($v_size != 0) { |
|
920 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
921 | 921 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
922 | - $v_buffer = @fread($v_zip_temp_fd, $v_read_size); |
|
923 | - @fwrite($this->_zip_fd, $v_buffer, $v_read_size); |
|
924 | - $v_size -= $v_read_size; |
|
925 | - } |
|
922 | + $v_buffer = @fread($v_zip_temp_fd, $v_read_size); |
|
923 | + @fwrite($this->_zip_fd, $v_buffer, $v_read_size); |
|
924 | + $v_size -= $v_read_size; |
|
925 | + } |
|
926 | 926 | |
927 | 927 | // ----- Create the Central Dir files header |
928 | 928 | for ($i=0, $v_count=0; $i < count($v_header_list); $i++) { |
929 | 929 | // ----- Create the file header |
930 | - if ($v_header_list[$i]['status'] == 'ok') { |
|
931 | - if (($v_result=$this->_writeCentralFileHeader($v_header_list[$i]))!=1) { |
|
932 | - fclose($v_zip_temp_fd); |
|
933 | - $this->_closeFd(); |
|
934 | - @unlink($v_zip_temp_name); |
|
930 | + if ($v_header_list[$i]['status'] == 'ok') { |
|
931 | + if (($v_result=$this->_writeCentralFileHeader($v_header_list[$i]))!=1) { |
|
932 | + fclose($v_zip_temp_fd); |
|
933 | + $this->_closeFd(); |
|
934 | + @unlink($v_zip_temp_name); |
|
935 | 935 | |
936 | - // ----- Return |
|
937 | - return $v_result; |
|
938 | - } |
|
939 | - $v_count++; |
|
940 | - } |
|
936 | + // ----- Return |
|
937 | + return $v_result; |
|
938 | + } |
|
939 | + $v_count++; |
|
940 | + } |
|
941 | 941 | |
942 | - // ----- Transform the header to a 'usable' info |
|
943 | - $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
942 | + // ----- Transform the header to a 'usable' info |
|
943 | + $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | // ----- Zip file comment |
@@ -955,16 +955,16 @@ discard block |
||
955 | 955 | $v_size, $v_offset, |
956 | 956 | $v_comment)) != 1) { |
957 | 957 | // ----- Reset the file list |
958 | - unset($v_header_list); |
|
958 | + unset($v_header_list); |
|
959 | 959 | |
960 | - // ----- Return |
|
961 | - return $v_result; |
|
960 | + // ----- Return |
|
961 | + return $v_result; |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | // ----- Swap back the file descriptor |
965 | 965 | $v_swap = $this->_zip_fd; |
966 | - $this->_zip_fd = $v_zip_temp_fd; |
|
967 | - $v_zip_temp_fd = $v_swap; |
|
966 | + $this->_zip_fd = $v_zip_temp_fd; |
|
967 | + $v_zip_temp_fd = $v_swap; |
|
968 | 968 | |
969 | 969 | // ----- Close |
970 | 970 | $this->_closeFd(); |
@@ -983,100 +983,100 @@ discard block |
||
983 | 983 | |
984 | 984 | // ----- Return |
985 | 985 | return $v_result; |
986 | - } |
|
987 | - // --------------------------------------------------------------------------- |
|
988 | - |
|
989 | - // --------------------------------------------------------------------------- |
|
990 | - // Function : _openFd() |
|
991 | - // Description : |
|
992 | - // Parameters : |
|
993 | - // --------------------------------------------------------------------------- |
|
994 | - /** |
|
995 | - * Archive_Zip::_openFd() |
|
996 | - * |
|
997 | - * { Description } |
|
998 | - * |
|
999 | - */ |
|
1000 | - public function _openFd($p_mode) |
|
1001 | - { |
|
1002 | - $v_result=1; |
|
986 | + } |
|
987 | + // --------------------------------------------------------------------------- |
|
988 | + |
|
989 | + // --------------------------------------------------------------------------- |
|
990 | + // Function : _openFd() |
|
991 | + // Description : |
|
992 | + // Parameters : |
|
993 | + // --------------------------------------------------------------------------- |
|
994 | + /** |
|
995 | + * Archive_Zip::_openFd() |
|
996 | + * |
|
997 | + * { Description } |
|
998 | + * |
|
999 | + */ |
|
1000 | + public function _openFd($p_mode) |
|
1001 | + { |
|
1002 | + $v_result=1; |
|
1003 | 1003 | |
1004 | 1004 | // ----- Look if already open |
1005 | 1005 | if ($this->_zip_fd != 0) { |
1006 | 1006 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
1007 | - 'Zip file \''.$this->_zipname.'\' already open'); |
|
1007 | + 'Zip file \''.$this->_zipname.'\' already open'); |
|
1008 | 1008 | return Archive_Zip::errorCode(); |
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | // ----- Open the zip file |
1012 | 1012 | if (($this->_zip_fd = @fopen($this->_zipname, $p_mode)) == 0) { |
1013 | 1013 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
1014 | - 'Unable to open archive \''.$this->_zipname |
|
1015 | - .'\' in '.$p_mode.' mode'); |
|
1014 | + 'Unable to open archive \''.$this->_zipname |
|
1015 | + .'\' in '.$p_mode.' mode'); |
|
1016 | 1016 | return Archive_Zip::errorCode(); |
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | // ----- Return |
1020 | 1020 | return $v_result; |
1021 | - } |
|
1022 | - // --------------------------------------------------------------------------- |
|
1023 | - |
|
1024 | - // --------------------------------------------------------------------------- |
|
1025 | - // Function : _closeFd() |
|
1026 | - // Description : |
|
1027 | - // Parameters : |
|
1028 | - // --------------------------------------------------------------------------- |
|
1029 | - /** |
|
1030 | - * Archive_Zip::_closeFd() |
|
1031 | - * |
|
1032 | - * { Description } |
|
1033 | - * |
|
1034 | - */ |
|
1035 | - public function _closeFd() |
|
1036 | - { |
|
1037 | - $v_result=1; |
|
1038 | - |
|
1039 | - if ($this->_zip_fd != 0) { |
|
1040 | - @fclose($this->_zip_fd); |
|
1041 | - } |
|
1042 | - $this->_zip_fd = 0; |
|
1021 | + } |
|
1022 | + // --------------------------------------------------------------------------- |
|
1023 | + |
|
1024 | + // --------------------------------------------------------------------------- |
|
1025 | + // Function : _closeFd() |
|
1026 | + // Description : |
|
1027 | + // Parameters : |
|
1028 | + // --------------------------------------------------------------------------- |
|
1029 | + /** |
|
1030 | + * Archive_Zip::_closeFd() |
|
1031 | + * |
|
1032 | + * { Description } |
|
1033 | + * |
|
1034 | + */ |
|
1035 | + public function _closeFd() |
|
1036 | + { |
|
1037 | + $v_result=1; |
|
1038 | + |
|
1039 | + if ($this->_zip_fd != 0) { |
|
1040 | + @fclose($this->_zip_fd); |
|
1041 | + } |
|
1042 | + $this->_zip_fd = 0; |
|
1043 | 1043 | |
1044 | 1044 | // ----- Return |
1045 | 1045 | return $v_result; |
1046 | - } |
|
1047 | - // --------------------------------------------------------------------------- |
|
1048 | - |
|
1049 | - // --------------------------------------------------------------------------- |
|
1050 | - // Function : _addList() |
|
1051 | - // Description : |
|
1052 | - // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is |
|
1053 | - // different from the real path of the file. This is usefull if you want to have PclTar |
|
1054 | - // running in any directory, and memorize relative path from an other directory. |
|
1055 | - // Parameters : |
|
1056 | - // $p_list : An array containing the file or directory names to add in the tar |
|
1057 | - // $p_result_list : list of added files with their properties (specially the status field) |
|
1058 | - // $p_add_dir : Path to add in the filename path archived |
|
1059 | - // $p_remove_dir : Path to remove in the filename path archived |
|
1060 | - // Return Values : |
|
1061 | - // --------------------------------------------------------------------------- |
|
1062 | - /** |
|
1063 | - * Archive_Zip::_addList() |
|
1064 | - * |
|
1065 | - * { Description } |
|
1066 | - * |
|
1067 | - */ |
|
1068 | - public function _addList($p_list, &$p_result_list, |
|
1046 | + } |
|
1047 | + // --------------------------------------------------------------------------- |
|
1048 | + |
|
1049 | + // --------------------------------------------------------------------------- |
|
1050 | + // Function : _addList() |
|
1051 | + // Description : |
|
1052 | + // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is |
|
1053 | + // different from the real path of the file. This is usefull if you want to have PclTar |
|
1054 | + // running in any directory, and memorize relative path from an other directory. |
|
1055 | + // Parameters : |
|
1056 | + // $p_list : An array containing the file or directory names to add in the tar |
|
1057 | + // $p_result_list : list of added files with their properties (specially the status field) |
|
1058 | + // $p_add_dir : Path to add in the filename path archived |
|
1059 | + // $p_remove_dir : Path to remove in the filename path archived |
|
1060 | + // Return Values : |
|
1061 | + // --------------------------------------------------------------------------- |
|
1062 | + /** |
|
1063 | + * Archive_Zip::_addList() |
|
1064 | + * |
|
1065 | + * { Description } |
|
1066 | + * |
|
1067 | + */ |
|
1068 | + public function _addList($p_list, &$p_result_list, |
|
1069 | 1069 | $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params) |
1070 | - { |
|
1071 | - $v_result=1; |
|
1070 | + { |
|
1071 | + $v_result=1; |
|
1072 | 1072 | |
1073 | 1073 | // ----- Add the files |
1074 | 1074 | $v_header_list = array(); |
1075 | - if (($v_result = $this->_addFileList($p_list, $v_header_list, |
|
1076 | - $p_add_dir, $p_remove_dir, |
|
1077 | - $p_remove_all_dir, $p_params)) != 1) { |
|
1078 | - return $v_result; |
|
1079 | - } |
|
1075 | + if (($v_result = $this->_addFileList($p_list, $v_header_list, |
|
1076 | + $p_add_dir, $p_remove_dir, |
|
1077 | + $p_remove_all_dir, $p_params)) != 1) { |
|
1078 | + return $v_result; |
|
1079 | + } |
|
1080 | 1080 | |
1081 | 1081 | // ----- Store the offset of the central dir |
1082 | 1082 | $v_offset = @ftell($this->_zip_fd); |
@@ -1084,15 +1084,15 @@ discard block |
||
1084 | 1084 | // ----- Create the Central Dir files header |
1085 | 1085 | for ($i=0, $v_count=0; $i < count($v_header_list); $i++) { |
1086 | 1086 | // ----- Create the file header |
1087 | - if ($v_header_list[$i]['status'] == 'ok') { |
|
1088 | - if (($v_result = $this->_writeCentralFileHeader($v_header_list[$i])) != 1) { |
|
1089 | - return $v_result; |
|
1090 | - } |
|
1091 | - $v_count++; |
|
1092 | - } |
|
1087 | + if ($v_header_list[$i]['status'] == 'ok') { |
|
1088 | + if (($v_result = $this->_writeCentralFileHeader($v_header_list[$i])) != 1) { |
|
1089 | + return $v_result; |
|
1090 | + } |
|
1091 | + $v_count++; |
|
1092 | + } |
|
1093 | 1093 | |
1094 | - // ----- Transform the header to a 'usable' info |
|
1095 | - $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
1094 | + // ----- Transform the header to a 'usable' info |
|
1095 | + $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | // ----- Zip file comment |
@@ -1105,42 +1105,42 @@ discard block |
||
1105 | 1105 | if (($v_result = $this->_writeCentralHeader($v_count, $v_size, $v_offset, |
1106 | 1106 | $v_comment)) != 1) { |
1107 | 1107 | // ----- Reset the file list |
1108 | - unset($v_header_list); |
|
1108 | + unset($v_header_list); |
|
1109 | 1109 | |
1110 | - // ----- Return |
|
1111 | - return $v_result; |
|
1110 | + // ----- Return |
|
1111 | + return $v_result; |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | 1114 | // ----- Return |
1115 | 1115 | return $v_result; |
1116 | - } |
|
1117 | - // --------------------------------------------------------------------------- |
|
1118 | - |
|
1119 | - // --------------------------------------------------------------------------- |
|
1120 | - // Function : _addFileList() |
|
1121 | - // Description : |
|
1122 | - // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is |
|
1123 | - // different from the real path of the file. This is usefull if you want to |
|
1124 | - // run the lib in any directory, and memorize relative path from an other directory. |
|
1125 | - // Parameters : |
|
1126 | - // $p_list : An array containing the file or directory names to add in the tar |
|
1127 | - // $p_result_list : list of added files with their properties (specially the status field) |
|
1128 | - // $p_add_dir : Path to add in the filename path archived |
|
1129 | - // $p_remove_dir : Path to remove in the filename path archived |
|
1130 | - // Return Values : |
|
1131 | - // --------------------------------------------------------------------------- |
|
1132 | - /** |
|
1133 | - * Archive_Zip::_addFileList() |
|
1134 | - * |
|
1135 | - * { Description } |
|
1136 | - * |
|
1137 | - */ |
|
1138 | - public function _addFileList($p_list, &$p_result_list, |
|
1116 | + } |
|
1117 | + // --------------------------------------------------------------------------- |
|
1118 | + |
|
1119 | + // --------------------------------------------------------------------------- |
|
1120 | + // Function : _addFileList() |
|
1121 | + // Description : |
|
1122 | + // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is |
|
1123 | + // different from the real path of the file. This is usefull if you want to |
|
1124 | + // run the lib in any directory, and memorize relative path from an other directory. |
|
1125 | + // Parameters : |
|
1126 | + // $p_list : An array containing the file or directory names to add in the tar |
|
1127 | + // $p_result_list : list of added files with their properties (specially the status field) |
|
1128 | + // $p_add_dir : Path to add in the filename path archived |
|
1129 | + // $p_remove_dir : Path to remove in the filename path archived |
|
1130 | + // Return Values : |
|
1131 | + // --------------------------------------------------------------------------- |
|
1132 | + /** |
|
1133 | + * Archive_Zip::_addFileList() |
|
1134 | + * |
|
1135 | + * { Description } |
|
1136 | + * |
|
1137 | + */ |
|
1138 | + public function _addFileList($p_list, &$p_result_list, |
|
1139 | 1139 | $p_add_dir, $p_remove_dir, $p_remove_all_dir, |
1140 | 1140 | &$p_params) |
1141 | - { |
|
1142 | - $v_result=1; |
|
1143 | - $v_header = array(); |
|
1141 | + { |
|
1142 | + $v_result=1; |
|
1143 | + $v_header = array(); |
|
1144 | 1144 | |
1145 | 1145 | // ----- Recuperate the current number of elt in list |
1146 | 1146 | $v_nb = count($p_result_list); |
@@ -1148,34 +1148,34 @@ discard block |
||
1148 | 1148 | // ----- Loop on the files |
1149 | 1149 | for ($j=0; ($j<count($p_list)) && ($v_result==1); $j++) { |
1150 | 1150 | // ----- Recuperate the filename |
1151 | - $p_filename = $this->_tool_TranslateWinPath($p_list[$j], false); |
|
1152 | - |
|
1153 | - // ----- Skip empty file names |
|
1154 | - if ($p_filename == '') { |
|
1155 | - continue; |
|
1156 | - } |
|
1157 | - |
|
1158 | - // ----- Check the filename |
|
1159 | - if (!file_exists($p_filename)) { |
|
1160 | - $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, |
|
1161 | - "File '$p_filename' does not exists"); |
|
1162 | - return Archive_Zip::errorCode(); |
|
1163 | - } |
|
1164 | - |
|
1165 | - // ----- Look if it is a file or a dir with no all pathnre move |
|
1166 | - if (is_file($p_filename) || (is_dir($p_filename) && !$p_remove_all_dir)) { |
|
1167 | - // ----- Add the file |
|
1151 | + $p_filename = $this->_tool_TranslateWinPath($p_list[$j], false); |
|
1152 | + |
|
1153 | + // ----- Skip empty file names |
|
1154 | + if ($p_filename == '') { |
|
1155 | + continue; |
|
1156 | + } |
|
1157 | + |
|
1158 | + // ----- Check the filename |
|
1159 | + if (!file_exists($p_filename)) { |
|
1160 | + $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, |
|
1161 | + "File '$p_filename' does not exists"); |
|
1162 | + return Archive_Zip::errorCode(); |
|
1163 | + } |
|
1164 | + |
|
1165 | + // ----- Look if it is a file or a dir with no all pathnre move |
|
1166 | + if (is_file($p_filename) || (is_dir($p_filename) && !$p_remove_all_dir)) { |
|
1167 | + // ----- Add the file |
|
1168 | 1168 | if (($v_result = $this->_addFile($p_filename, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params)) != 1) { |
1169 | 1169 | // ----- Return status |
1170 | - return $v_result; |
|
1170 | + return $v_result; |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | // ----- Store the file infos |
1174 | 1174 | $p_result_list[$v_nb++] = $v_header; |
1175 | - } |
|
1175 | + } |
|
1176 | 1176 | |
1177 | - // ----- Look for directory |
|
1178 | - if (is_dir($p_filename)) { |
|
1177 | + // ----- Look for directory |
|
1178 | + if (is_dir($p_filename)) { |
|
1179 | 1179 | |
1180 | 1180 | // ----- Look for path |
1181 | 1181 | if ($p_filename != '.') { |
@@ -1186,67 +1186,67 @@ discard block |
||
1186 | 1186 | |
1187 | 1187 | // ----- Read the directory for files and sub-directories |
1188 | 1188 | $p_hdir = opendir($p_filename); |
1189 | - $p_hitem = readdir($p_hdir); // '.' directory |
|
1189 | + $p_hitem = readdir($p_hdir); // '.' directory |
|
1190 | 1190 | $p_hitem = readdir($p_hdir); // '..' directory |
1191 | 1191 | while ($p_hitem = readdir($p_hdir)) { |
1192 | 1192 | |
1193 | - // ----- Look for a file |
|
1194 | - if (is_file($v_path.$p_hitem)) { |
|
1193 | + // ----- Look for a file |
|
1194 | + if (is_file($v_path.$p_hitem)) { |
|
1195 | 1195 | |
1196 | 1196 | // ----- Add the file |
1197 | 1197 | if (($v_result = $this->_addFile($v_path.$p_hitem, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params)) != 1) { |
1198 | 1198 | // ----- Return status |
1199 | - return $v_result; |
|
1199 | + return $v_result; |
|
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | // ----- Store the file infos |
1203 | 1203 | $p_result_list[$v_nb++] = $v_header; |
1204 | - } |
|
1204 | + } |
|
1205 | 1205 | |
1206 | - // ----- Recursive call to _addFileList() |
|
1207 | - else { |
|
1206 | + // ----- Recursive call to _addFileList() |
|
1207 | + else { |
|
1208 | 1208 | |
1209 | 1209 | // ----- Need an array as parameter |
1210 | 1210 | $p_temp_list[0] = $v_path.$p_hitem; |
1211 | - $v_result = $this->_addFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params); |
|
1211 | + $v_result = $this->_addFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params); |
|
1212 | 1212 | |
1213 | 1213 | // ----- Update the number of elements of the list |
1214 | 1214 | $v_nb = count($p_result_list); |
1215 | - } |
|
1215 | + } |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | // ----- Free memory for the recursive loop |
1219 | 1219 | unset($p_temp_list, $p_hdir, $p_hitem); |
1220 | - } |
|
1221 | - } |
|
1222 | - |
|
1223 | - return $v_result; |
|
1224 | - } |
|
1225 | - // --------------------------------------------------------------------------- |
|
1226 | - |
|
1227 | - // --------------------------------------------------------------------------- |
|
1228 | - // Function : _addFile() |
|
1229 | - // Description : |
|
1230 | - // Parameters : |
|
1231 | - // Return Values : |
|
1232 | - // --------------------------------------------------------------------------- |
|
1233 | - /** |
|
1234 | - * Archive_Zip::_addFile() |
|
1235 | - * |
|
1236 | - * { Description } |
|
1237 | - * |
|
1238 | - */ |
|
1239 | - public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params) |
|
1240 | - { |
|
1241 | - $v_result=1; |
|
1242 | - |
|
1243 | - if ($p_filename == '') { |
|
1244 | - // ----- Error log |
|
1245 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, 'Invalid file list parameter (invalid or empty list)'); |
|
1220 | + } |
|
1221 | + } |
|
1246 | 1222 | |
1247 | - // ----- Return |
|
1248 | - return Archive_Zip::errorCode(); |
|
1249 | - } |
|
1223 | + return $v_result; |
|
1224 | + } |
|
1225 | + // --------------------------------------------------------------------------- |
|
1226 | + |
|
1227 | + // --------------------------------------------------------------------------- |
|
1228 | + // Function : _addFile() |
|
1229 | + // Description : |
|
1230 | + // Parameters : |
|
1231 | + // Return Values : |
|
1232 | + // --------------------------------------------------------------------------- |
|
1233 | + /** |
|
1234 | + * Archive_Zip::_addFile() |
|
1235 | + * |
|
1236 | + * { Description } |
|
1237 | + * |
|
1238 | + */ |
|
1239 | + public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params) |
|
1240 | + { |
|
1241 | + $v_result=1; |
|
1242 | + |
|
1243 | + if ($p_filename == '') { |
|
1244 | + // ----- Error log |
|
1245 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, 'Invalid file list parameter (invalid or empty list)'); |
|
1246 | + |
|
1247 | + // ----- Return |
|
1248 | + return Archive_Zip::errorCode(); |
|
1249 | + } |
|
1250 | 1250 | |
1251 | 1251 | // ----- Calculate the stored filename |
1252 | 1252 | $v_stored_filename = $p_filename; |
@@ -1309,51 +1309,51 @@ discard block |
||
1309 | 1309 | |
1310 | 1310 | // ----- Set the file properties |
1311 | 1311 | clearstatcache(); |
1312 | - $p_header['version'] = 20; |
|
1313 | - $p_header['version_extracted'] = 10; |
|
1314 | - $p_header['flag'] = 0; |
|
1315 | - $p_header['compression'] = 0; |
|
1316 | - $p_header['mtime'] = filemtime($p_filename); |
|
1317 | - $p_header['crc'] = 0; |
|
1318 | - $p_header['compressed_size'] = 0; |
|
1319 | - $p_header['size'] = filesize($p_filename); |
|
1320 | - $p_header['filename_len'] = strlen($p_filename); |
|
1321 | - $p_header['extra_len'] = 0; |
|
1322 | - $p_header['comment_len'] = 0; |
|
1323 | - $p_header['disk'] = 0; |
|
1324 | - $p_header['internal'] = 0; |
|
1325 | - $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); |
|
1326 | - $p_header['offset'] = 0; |
|
1327 | - $p_header['filename'] = $p_filename; |
|
1328 | - $p_header['stored_filename'] = $v_stored_filename; |
|
1329 | - $p_header['extra'] = ''; |
|
1330 | - $p_header['comment'] = ''; |
|
1331 | - $p_header['status'] = 'ok'; |
|
1332 | - $p_header['index'] = -1; |
|
1312 | + $p_header['version'] = 20; |
|
1313 | + $p_header['version_extracted'] = 10; |
|
1314 | + $p_header['flag'] = 0; |
|
1315 | + $p_header['compression'] = 0; |
|
1316 | + $p_header['mtime'] = filemtime($p_filename); |
|
1317 | + $p_header['crc'] = 0; |
|
1318 | + $p_header['compressed_size'] = 0; |
|
1319 | + $p_header['size'] = filesize($p_filename); |
|
1320 | + $p_header['filename_len'] = strlen($p_filename); |
|
1321 | + $p_header['extra_len'] = 0; |
|
1322 | + $p_header['comment_len'] = 0; |
|
1323 | + $p_header['disk'] = 0; |
|
1324 | + $p_header['internal'] = 0; |
|
1325 | + $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); |
|
1326 | + $p_header['offset'] = 0; |
|
1327 | + $p_header['filename'] = $p_filename; |
|
1328 | + $p_header['stored_filename'] = $v_stored_filename; |
|
1329 | + $p_header['extra'] = ''; |
|
1330 | + $p_header['comment'] = ''; |
|
1331 | + $p_header['status'] = 'ok'; |
|
1332 | + $p_header['index'] = -1; |
|
1333 | 1333 | |
1334 | 1334 | // ----- Look for pre-add callback |
1335 | 1335 | if (isset($p_params[ARCHIVE_ZIP_PARAM_PRE_ADD]) |
1336 | 1336 | && ($p_params[ARCHIVE_ZIP_PARAM_PRE_ADD] != '')) { |
1337 | 1337 | |
1338 | - // ----- Generate a local information |
|
1339 | - $v_local_header = array(); |
|
1338 | + // ----- Generate a local information |
|
1339 | + $v_local_header = array(); |
|
1340 | 1340 | $this->_convertHeader2FileInfo($p_header, $v_local_header); |
1341 | 1341 | |
1342 | - // ----- Call the callback |
|
1343 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
1344 | - // header. |
|
1345 | - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_ADD].'(ARCHIVE_ZIP_PARAM_PRE_ADD, $v_local_header);'); |
|
1342 | + // ----- Call the callback |
|
1343 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
1344 | + // header. |
|
1345 | + eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_ADD].'(ARCHIVE_ZIP_PARAM_PRE_ADD, $v_local_header);'); |
|
1346 | 1346 | if ($v_result == 0) { |
1347 | 1347 | // ----- Change the file status |
1348 | 1348 | $p_header['status'] = 'skipped'; |
1349 | 1349 | $v_result = 1; |
1350 | 1350 | } |
1351 | 1351 | |
1352 | - // ----- Update the informations |
|
1353 | - // Only some fields can be modified |
|
1354 | - if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { |
|
1355 | - $p_header['stored_filename'] = $this->_tool_PathReduction($v_local_header['stored_filename']); |
|
1356 | - } |
|
1352 | + // ----- Update the informations |
|
1353 | + // Only some fields can be modified |
|
1354 | + if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { |
|
1355 | + $p_header['stored_filename'] = $this->_tool_PathReduction($v_local_header['stored_filename']); |
|
1356 | + } |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | // ----- Look for empty stored filename |
@@ -1369,34 +1369,34 @@ discard block |
||
1369 | 1369 | // ----- Look if no error, or file not skipped |
1370 | 1370 | if ($p_header['status'] == 'ok') { |
1371 | 1371 | |
1372 | - // ----- Look for a file |
|
1373 | - if (is_file($p_filename)) { |
|
1374 | - // ----- Open the source file |
|
1372 | + // ----- Look for a file |
|
1373 | + if (is_file($p_filename)) { |
|
1374 | + // ----- Open the source file |
|
1375 | 1375 | if (($v_file = @fopen($p_filename, 'rb')) == 0) { |
1376 | 1376 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
1377 | 1377 | return Archive_Zip::errorCode(); |
1378 | 1378 | } |
1379 | 1379 | |
1380 | - if ($p_params['no_compression']) { |
|
1381 | - // ----- Read the file content |
|
1382 | - $v_content_compressed = @fread($v_file, $p_header['size']); |
|
1380 | + if ($p_params['no_compression']) { |
|
1381 | + // ----- Read the file content |
|
1382 | + $v_content_compressed = @fread($v_file, $p_header['size']); |
|
1383 | 1383 | |
1384 | - // ----- Calculate the CRC |
|
1385 | - $p_header['crc'] = crc32($v_content_compressed); |
|
1386 | - } else { |
|
1387 | - // ----- Read the file content |
|
1388 | - $v_content = @fread($v_file, $p_header['size']); |
|
1384 | + // ----- Calculate the CRC |
|
1385 | + $p_header['crc'] = crc32($v_content_compressed); |
|
1386 | + } else { |
|
1387 | + // ----- Read the file content |
|
1388 | + $v_content = @fread($v_file, $p_header['size']); |
|
1389 | 1389 | |
1390 | - // ----- Calculate the CRC |
|
1391 | - $p_header['crc'] = crc32($v_content); |
|
1390 | + // ----- Calculate the CRC |
|
1391 | + $p_header['crc'] = crc32($v_content); |
|
1392 | 1392 | |
1393 | - // ----- Compress the file |
|
1394 | - $v_content_compressed = gzdeflate($v_content); |
|
1395 | - } |
|
1393 | + // ----- Compress the file |
|
1394 | + $v_content_compressed = gzdeflate($v_content); |
|
1395 | + } |
|
1396 | 1396 | |
1397 | 1397 | // ----- Set header parameters |
1398 | 1398 | $p_header['compressed_size'] = strlen($v_content_compressed); |
1399 | - $p_header['compression'] = 8; |
|
1399 | + $p_header['compression'] = 8; |
|
1400 | 1400 | |
1401 | 1401 | // ----- Call the header generation |
1402 | 1402 | if (($v_result = $this->_writeFileHeader($p_header)) != 1) { |
@@ -1406,68 +1406,68 @@ discard block |
||
1406 | 1406 | |
1407 | 1407 | // ----- Write the compressed content |
1408 | 1408 | $v_binary_data = pack('a'.$p_header['compressed_size'], $v_content_compressed); |
1409 | - @fwrite($this->_zip_fd, $v_binary_data, $p_header['compressed_size']); |
|
1409 | + @fwrite($this->_zip_fd, $v_binary_data, $p_header['compressed_size']); |
|
1410 | 1410 | |
1411 | 1411 | // ----- Close the file |
1412 | 1412 | @fclose($v_file); |
1413 | - } |
|
1413 | + } |
|
1414 | 1414 | |
1415 | - // ----- Look for a directory |
|
1416 | - else { |
|
1417 | - // ----- Set the file properties |
|
1415 | + // ----- Look for a directory |
|
1416 | + else { |
|
1417 | + // ----- Set the file properties |
|
1418 | 1418 | $p_header['filename'] .= '/'; |
1419 | - $p_header['filename_len']++; |
|
1420 | - $p_header['size'] = 0; |
|
1421 | - $p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
|
1419 | + $p_header['filename_len']++; |
|
1420 | + $p_header['size'] = 0; |
|
1421 | + $p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
|
1422 | 1422 | |
1423 | 1423 | // ----- Call the header generation |
1424 | 1424 | if (($v_result = $this->_writeFileHeader($p_header)) != 1) { |
1425 | 1425 | return $v_result; |
1426 | 1426 | } |
1427 | - } |
|
1427 | + } |
|
1428 | 1428 | } |
1429 | 1429 | |
1430 | 1430 | // ----- Look for pre-add callback |
1431 | 1431 | if (isset($p_params[ARCHIVE_ZIP_PARAM_POST_ADD]) |
1432 | 1432 | && ($p_params[ARCHIVE_ZIP_PARAM_POST_ADD] != '')) { |
1433 | 1433 | |
1434 | - // ----- Generate a local information |
|
1435 | - $v_local_header = array(); |
|
1434 | + // ----- Generate a local information |
|
1435 | + $v_local_header = array(); |
|
1436 | 1436 | $this->_convertHeader2FileInfo($p_header, $v_local_header); |
1437 | 1437 | |
1438 | - // ----- Call the callback |
|
1439 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
1440 | - // header. |
|
1441 | - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_ADD].'(ARCHIVE_ZIP_PARAM_POST_ADD, $v_local_header);'); |
|
1438 | + // ----- Call the callback |
|
1439 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
1440 | + // header. |
|
1441 | + eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_ADD].'(ARCHIVE_ZIP_PARAM_POST_ADD, $v_local_header);'); |
|
1442 | 1442 | if ($v_result == 0) { |
1443 | 1443 | // ----- Ignored |
1444 | 1444 | $v_result = 1; |
1445 | 1445 | } |
1446 | 1446 | |
1447 | - // ----- Update the informations |
|
1448 | - // Nothing can be modified |
|
1447 | + // ----- Update the informations |
|
1448 | + // Nothing can be modified |
|
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | // ----- Return |
1452 | 1452 | return $v_result; |
1453 | - } |
|
1454 | - // --------------------------------------------------------------------------- |
|
1455 | - |
|
1456 | - // --------------------------------------------------------------------------- |
|
1457 | - // Function : _writeFileHeader() |
|
1458 | - // Description : |
|
1459 | - // Parameters : |
|
1460 | - // Return Values : |
|
1461 | - // --------------------------------------------------------------------------- |
|
1462 | - /** |
|
1463 | - * Archive_Zip::_writeFileHeader() |
|
1464 | - * |
|
1465 | - * { Description } |
|
1466 | - * |
|
1467 | - */ |
|
1468 | - public function _writeFileHeader(&$p_header) |
|
1469 | - { |
|
1470 | - $v_result=1; |
|
1453 | + } |
|
1454 | + // --------------------------------------------------------------------------- |
|
1455 | + |
|
1456 | + // --------------------------------------------------------------------------- |
|
1457 | + // Function : _writeFileHeader() |
|
1458 | + // Description : |
|
1459 | + // Parameters : |
|
1460 | + // Return Values : |
|
1461 | + // --------------------------------------------------------------------------- |
|
1462 | + /** |
|
1463 | + * Archive_Zip::_writeFileHeader() |
|
1464 | + * |
|
1465 | + * { Description } |
|
1466 | + * |
|
1467 | + */ |
|
1468 | + public function _writeFileHeader(&$p_header) |
|
1469 | + { |
|
1470 | + $v_result=1; |
|
1471 | 1471 | |
1472 | 1472 | // TBC |
1473 | 1473 | //for(reset($p_header); $key = key($p_header); next($p_header)) { |
@@ -1478,14 +1478,14 @@ discard block |
||
1478 | 1478 | |
1479 | 1479 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
1480 | 1480 | $v_date = getdate($p_header['mtime']); |
1481 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
1482 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
1481 | + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
1482 | + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
1483 | 1483 | |
1484 | 1484 | // ----- Packed data |
1485 | 1485 | $v_binary_data = pack('VvvvvvVVVvv', 0x04034b50, $p_header['version'], $p_header['flag'], |
1486 | - $p_header['compression'], $v_mtime, $v_mdate, |
|
1487 | - $p_header['crc'], $p_header['compressed_size'], $p_header['size'], |
|
1488 | - strlen($p_header['stored_filename']), $p_header['extra_len']); |
|
1486 | + $p_header['compression'], $v_mtime, $v_mdate, |
|
1487 | + $p_header['crc'], $p_header['compressed_size'], $p_header['size'], |
|
1488 | + strlen($p_header['stored_filename']), $p_header['extra_len']); |
|
1489 | 1489 | |
1490 | 1490 | // ----- Write the first 148 bytes of the header in the archive |
1491 | 1491 | fwrite($this->_zip_fd, $v_binary_data, 30); |
@@ -1494,30 +1494,30 @@ discard block |
||
1494 | 1494 | if (strlen($p_header['stored_filename']) != 0) { |
1495 | 1495 | fwrite($this->_zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
1496 | 1496 | } |
1497 | - if ($p_header['extra_len'] != 0) { |
|
1498 | - fwrite($this->_zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
1499 | - } |
|
1497 | + if ($p_header['extra_len'] != 0) { |
|
1498 | + fwrite($this->_zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
1499 | + } |
|
1500 | 1500 | |
1501 | 1501 | // ----- Return |
1502 | 1502 | return $v_result; |
1503 | - } |
|
1504 | - // --------------------------------------------------------------------------- |
|
1505 | - |
|
1506 | - // --------------------------------------------------------------------------- |
|
1507 | - // Function : _writeCentralFileHeader() |
|
1508 | - // Description : |
|
1509 | - // Parameters : |
|
1510 | - // Return Values : |
|
1511 | - // --------------------------------------------------------------------------- |
|
1512 | - /** |
|
1513 | - * Archive_Zip::_writeCentralFileHeader() |
|
1514 | - * |
|
1515 | - * { Description } |
|
1516 | - * |
|
1517 | - */ |
|
1518 | - public function _writeCentralFileHeader(&$p_header) |
|
1519 | - { |
|
1520 | - $v_result=1; |
|
1503 | + } |
|
1504 | + // --------------------------------------------------------------------------- |
|
1505 | + |
|
1506 | + // --------------------------------------------------------------------------- |
|
1507 | + // Function : _writeCentralFileHeader() |
|
1508 | + // Description : |
|
1509 | + // Parameters : |
|
1510 | + // Return Values : |
|
1511 | + // --------------------------------------------------------------------------- |
|
1512 | + /** |
|
1513 | + * Archive_Zip::_writeCentralFileHeader() |
|
1514 | + * |
|
1515 | + * { Description } |
|
1516 | + * |
|
1517 | + */ |
|
1518 | + public function _writeCentralFileHeader(&$p_header) |
|
1519 | + { |
|
1520 | + $v_result=1; |
|
1521 | 1521 | |
1522 | 1522 | // TBC |
1523 | 1523 | //for(reset($p_header); $key = key($p_header); next($p_header)) { |
@@ -1525,15 +1525,15 @@ discard block |
||
1525 | 1525 | |
1526 | 1526 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
1527 | 1527 | $v_date = getdate($p_header['mtime']); |
1528 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
1529 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
1528 | + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
1529 | + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
1530 | 1530 | |
1531 | 1531 | // ----- Packed data |
1532 | 1532 | $v_binary_data = pack('VvvvvvvVVVvvvvvVV', 0x02014b50, $p_header['version'], $p_header['version_extracted'], |
1533 | - $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], |
|
1534 | - $p_header['compressed_size'], $p_header['size'], |
|
1535 | - strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], |
|
1536 | - $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']); |
|
1533 | + $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], |
|
1534 | + $p_header['compressed_size'], $p_header['size'], |
|
1535 | + strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], |
|
1536 | + $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']); |
|
1537 | 1537 | |
1538 | 1538 | // ----- Write the 42 bytes of the header in the zip file |
1539 | 1539 | fwrite($this->_zip_fd, $v_binary_data, 46); |
@@ -1542,33 +1542,33 @@ discard block |
||
1542 | 1542 | if (strlen($p_header['stored_filename']) != 0) { |
1543 | 1543 | fwrite($this->_zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
1544 | 1544 | } |
1545 | - if ($p_header['extra_len'] != 0) { |
|
1546 | - fwrite($this->_zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
1547 | - } |
|
1548 | - if ($p_header['comment_len'] != 0) { |
|
1549 | - fwrite($this->_zip_fd, $p_header['comment'], $p_header['comment_len']); |
|
1550 | - } |
|
1545 | + if ($p_header['extra_len'] != 0) { |
|
1546 | + fwrite($this->_zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
1547 | + } |
|
1548 | + if ($p_header['comment_len'] != 0) { |
|
1549 | + fwrite($this->_zip_fd, $p_header['comment'], $p_header['comment_len']); |
|
1550 | + } |
|
1551 | 1551 | |
1552 | 1552 | // ----- Return |
1553 | 1553 | return $v_result; |
1554 | - } |
|
1555 | - // --------------------------------------------------------------------------- |
|
1556 | - |
|
1557 | - // --------------------------------------------------------------------------- |
|
1558 | - // Function : _writeCentralHeader() |
|
1559 | - // Description : |
|
1560 | - // Parameters : |
|
1561 | - // Return Values : |
|
1562 | - // --------------------------------------------------------------------------- |
|
1563 | - /** |
|
1564 | - * Archive_Zip::_writeCentralHeader() |
|
1565 | - * |
|
1566 | - * { Description } |
|
1567 | - * |
|
1568 | - */ |
|
1569 | - public function _writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
|
1570 | - { |
|
1571 | - $v_result=1; |
|
1554 | + } |
|
1555 | + // --------------------------------------------------------------------------- |
|
1556 | + |
|
1557 | + // --------------------------------------------------------------------------- |
|
1558 | + // Function : _writeCentralHeader() |
|
1559 | + // Description : |
|
1560 | + // Parameters : |
|
1561 | + // Return Values : |
|
1562 | + // --------------------------------------------------------------------------- |
|
1563 | + /** |
|
1564 | + * Archive_Zip::_writeCentralHeader() |
|
1565 | + * |
|
1566 | + * { Description } |
|
1567 | + * |
|
1568 | + */ |
|
1569 | + public function _writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
|
1570 | + { |
|
1571 | + $v_result=1; |
|
1572 | 1572 | |
1573 | 1573 | // ----- Packed data |
1574 | 1574 | $v_binary_data = pack('VvvvvVVv', 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment)); |
@@ -1583,60 +1583,60 @@ discard block |
||
1583 | 1583 | |
1584 | 1584 | // ----- Return |
1585 | 1585 | return $v_result; |
1586 | - } |
|
1587 | - // --------------------------------------------------------------------------- |
|
1588 | - |
|
1589 | - // --------------------------------------------------------------------------- |
|
1590 | - // Function : _list() |
|
1591 | - // Description : |
|
1592 | - // Parameters : |
|
1593 | - // Return Values : |
|
1594 | - // --------------------------------------------------------------------------- |
|
1595 | - /** |
|
1596 | - * Archive_Zip::_list() |
|
1597 | - * |
|
1598 | - * { Description } |
|
1599 | - * |
|
1600 | - */ |
|
1601 | - public function _list(&$p_list) |
|
1602 | - { |
|
1603 | - $v_result=1; |
|
1586 | + } |
|
1587 | + // --------------------------------------------------------------------------- |
|
1588 | + |
|
1589 | + // --------------------------------------------------------------------------- |
|
1590 | + // Function : _list() |
|
1591 | + // Description : |
|
1592 | + // Parameters : |
|
1593 | + // Return Values : |
|
1594 | + // --------------------------------------------------------------------------- |
|
1595 | + /** |
|
1596 | + * Archive_Zip::_list() |
|
1597 | + * |
|
1598 | + * { Description } |
|
1599 | + * |
|
1600 | + */ |
|
1601 | + public function _list(&$p_list) |
|
1602 | + { |
|
1603 | + $v_result=1; |
|
1604 | 1604 | |
1605 | 1605 | // ----- Open the zip file |
1606 | 1606 | if (($this->_zip_fd = @fopen($this->_zipname, 'rb')) == 0) { |
1607 | 1607 | // ----- Error log |
1608 | - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->_zipname.'\' in binary read mode'); |
|
1608 | + $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->_zipname.'\' in binary read mode'); |
|
1609 | 1609 | |
1610 | - // ----- Return |
|
1611 | - return Archive_Zip::errorCode(); |
|
1610 | + // ----- Return |
|
1611 | + return Archive_Zip::errorCode(); |
|
1612 | 1612 | } |
1613 | 1613 | |
1614 | 1614 | // ----- Read the central directory informations |
1615 | 1615 | $v_central_dir = array(); |
1616 | - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
1617 | - return $v_result; |
|
1618 | - } |
|
1616 | + if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
1617 | + return $v_result; |
|
1618 | + } |
|
1619 | 1619 | |
1620 | 1620 | // ----- Go to beginning of Central Dir |
1621 | 1621 | @rewind($this->_zip_fd); |
1622 | - if (@fseek($this->_zip_fd, $v_central_dir['offset'])) { |
|
1623 | - // ----- Error log |
|
1624 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
1622 | + if (@fseek($this->_zip_fd, $v_central_dir['offset'])) { |
|
1623 | + // ----- Error log |
|
1624 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
1625 | 1625 | |
1626 | - // ----- Return |
|
1627 | - return Archive_Zip::errorCode(); |
|
1628 | - } |
|
1626 | + // ----- Return |
|
1627 | + return Archive_Zip::errorCode(); |
|
1628 | + } |
|
1629 | 1629 | |
1630 | 1630 | // ----- Read each entry |
1631 | 1631 | for ($i=0; $i<$v_central_dir['entries']; $i++) { |
1632 | 1632 | // ----- Read the file header |
1633 | - if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) { |
|
1634 | - return $v_result; |
|
1635 | - } |
|
1633 | + if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) { |
|
1634 | + return $v_result; |
|
1635 | + } |
|
1636 | 1636 | $v_header['index'] = $i; |
1637 | 1637 | |
1638 | - // ----- Get the only interesting attributes |
|
1639 | - $this->_convertHeader2FileInfo($v_header, $p_list[$i]); |
|
1638 | + // ----- Get the only interesting attributes |
|
1639 | + $this->_convertHeader2FileInfo($v_header, $p_list[$i]); |
|
1640 | 1640 | unset($v_header); |
1641 | 1641 | } |
1642 | 1642 | |
@@ -1645,82 +1645,82 @@ discard block |
||
1645 | 1645 | |
1646 | 1646 | // ----- Return |
1647 | 1647 | return $v_result; |
1648 | - } |
|
1649 | - // --------------------------------------------------------------------------- |
|
1650 | - |
|
1651 | - // --------------------------------------------------------------------------- |
|
1652 | - // Function : _convertHeader2FileInfo() |
|
1653 | - // Description : |
|
1654 | - // This function takes the file informations from the central directory |
|
1655 | - // entries and extract the interesting parameters that will be given back. |
|
1656 | - // The resulting file infos are set in the array $p_info |
|
1657 | - // $p_info['filename'] : Filename with full path. Given by user (add), |
|
1658 | - // extracted in the filesystem (extract). |
|
1659 | - // $p_info['stored_filename'] : Stored filename in the archive. |
|
1660 | - // $p_info['size'] = Size of the file. |
|
1661 | - // $p_info['compressed_size'] = Compressed size of the file. |
|
1662 | - // $p_info['mtime'] = Last modification date of the file. |
|
1663 | - // $p_info['comment'] = Comment associated with the file. |
|
1664 | - // $p_info['folder'] = true/false : indicates if the entry is a folder or not. |
|
1665 | - // $p_info['status'] = status of the action on the file. |
|
1666 | - // Parameters : |
|
1667 | - // Return Values : |
|
1668 | - // --------------------------------------------------------------------------- |
|
1669 | - /** |
|
1670 | - * Archive_Zip::_convertHeader2FileInfo() |
|
1671 | - * |
|
1672 | - * { Description } |
|
1673 | - * |
|
1674 | - */ |
|
1675 | - public function _convertHeader2FileInfo($p_header, &$p_info) |
|
1676 | - { |
|
1677 | - $v_result=1; |
|
1648 | + } |
|
1649 | + // --------------------------------------------------------------------------- |
|
1650 | + |
|
1651 | + // --------------------------------------------------------------------------- |
|
1652 | + // Function : _convertHeader2FileInfo() |
|
1653 | + // Description : |
|
1654 | + // This function takes the file informations from the central directory |
|
1655 | + // entries and extract the interesting parameters that will be given back. |
|
1656 | + // The resulting file infos are set in the array $p_info |
|
1657 | + // $p_info['filename'] : Filename with full path. Given by user (add), |
|
1658 | + // extracted in the filesystem (extract). |
|
1659 | + // $p_info['stored_filename'] : Stored filename in the archive. |
|
1660 | + // $p_info['size'] = Size of the file. |
|
1661 | + // $p_info['compressed_size'] = Compressed size of the file. |
|
1662 | + // $p_info['mtime'] = Last modification date of the file. |
|
1663 | + // $p_info['comment'] = Comment associated with the file. |
|
1664 | + // $p_info['folder'] = true/false : indicates if the entry is a folder or not. |
|
1665 | + // $p_info['status'] = status of the action on the file. |
|
1666 | + // Parameters : |
|
1667 | + // Return Values : |
|
1668 | + // --------------------------------------------------------------------------- |
|
1669 | + /** |
|
1670 | + * Archive_Zip::_convertHeader2FileInfo() |
|
1671 | + * |
|
1672 | + * { Description } |
|
1673 | + * |
|
1674 | + */ |
|
1675 | + public function _convertHeader2FileInfo($p_header, &$p_info) |
|
1676 | + { |
|
1677 | + $v_result=1; |
|
1678 | 1678 | |
1679 | 1679 | // ----- Get the interesting attributes |
1680 | 1680 | $p_info['filename'] = $p_header['filename']; |
1681 | - $p_info['stored_filename'] = $p_header['stored_filename']; |
|
1682 | - $p_info['size'] = $p_header['size']; |
|
1683 | - $p_info['compressed_size'] = $p_header['compressed_size']; |
|
1684 | - $p_info['mtime'] = $p_header['mtime']; |
|
1685 | - $p_info['comment'] = $p_header['comment']; |
|
1686 | - $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
1687 | - $p_info['index'] = $p_header['index']; |
|
1688 | - $p_info['status'] = $p_header['status']; |
|
1681 | + $p_info['stored_filename'] = $p_header['stored_filename']; |
|
1682 | + $p_info['size'] = $p_header['size']; |
|
1683 | + $p_info['compressed_size'] = $p_header['compressed_size']; |
|
1684 | + $p_info['mtime'] = $p_header['mtime']; |
|
1685 | + $p_info['comment'] = $p_header['comment']; |
|
1686 | + $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
1687 | + $p_info['index'] = $p_header['index']; |
|
1688 | + $p_info['status'] = $p_header['status']; |
|
1689 | 1689 | |
1690 | 1690 | // ----- Return |
1691 | 1691 | return $v_result; |
1692 | - } |
|
1693 | - // --------------------------------------------------------------------------- |
|
1694 | - |
|
1695 | - // --------------------------------------------------------------------------- |
|
1696 | - // Function : _extractByRule() |
|
1697 | - // Description : |
|
1698 | - // Extract a file or directory depending of rules (by index, by name, ...) |
|
1699 | - // Parameters : |
|
1700 | - // $p_file_list : An array where will be placed the properties of each |
|
1701 | - // extracted file |
|
1702 | - // $p_path : Path to add while writing the extracted files |
|
1703 | - // $p_remove_path : Path to remove (from the file memorized path) while writing the |
|
1704 | - // extracted files. If the path does not match the file path, |
|
1705 | - // the file is extracted with its memorized path. |
|
1706 | - // $p_remove_path does not apply to 'list' mode. |
|
1707 | - // $p_path and $p_remove_path are commulative. |
|
1708 | - // Return Values : |
|
1709 | - // 1 on success,0 or less on error (see error code list) |
|
1710 | - // --------------------------------------------------------------------------- |
|
1711 | - /** |
|
1712 | - * Archive_Zip::_extractByRule() |
|
1713 | - * |
|
1714 | - * { Description } |
|
1715 | - * |
|
1716 | - */ |
|
1717 | - public function _extractByRule(&$p_file_list, &$p_params) |
|
1718 | - { |
|
1719 | - $v_result=1; |
|
1720 | - |
|
1721 | - $p_path = $p_params['add_path']; |
|
1722 | - $p_remove_path = $p_params['remove_path']; |
|
1723 | - $p_remove_all_path = $p_params['remove_all_path']; |
|
1692 | + } |
|
1693 | + // --------------------------------------------------------------------------- |
|
1694 | + |
|
1695 | + // --------------------------------------------------------------------------- |
|
1696 | + // Function : _extractByRule() |
|
1697 | + // Description : |
|
1698 | + // Extract a file or directory depending of rules (by index, by name, ...) |
|
1699 | + // Parameters : |
|
1700 | + // $p_file_list : An array where will be placed the properties of each |
|
1701 | + // extracted file |
|
1702 | + // $p_path : Path to add while writing the extracted files |
|
1703 | + // $p_remove_path : Path to remove (from the file memorized path) while writing the |
|
1704 | + // extracted files. If the path does not match the file path, |
|
1705 | + // the file is extracted with its memorized path. |
|
1706 | + // $p_remove_path does not apply to 'list' mode. |
|
1707 | + // $p_path and $p_remove_path are commulative. |
|
1708 | + // Return Values : |
|
1709 | + // 1 on success,0 or less on error (see error code list) |
|
1710 | + // --------------------------------------------------------------------------- |
|
1711 | + /** |
|
1712 | + * Archive_Zip::_extractByRule() |
|
1713 | + * |
|
1714 | + * { Description } |
|
1715 | + * |
|
1716 | + */ |
|
1717 | + public function _extractByRule(&$p_file_list, &$p_params) |
|
1718 | + { |
|
1719 | + $v_result=1; |
|
1720 | + |
|
1721 | + $p_path = $p_params['add_path']; |
|
1722 | + $p_remove_path = $p_params['remove_path']; |
|
1723 | + $p_remove_all_path = $p_params['remove_all_path']; |
|
1724 | 1724 | |
1725 | 1725 | // ----- Check the path |
1726 | 1726 | if (($p_path == '') |
@@ -1732,16 +1732,16 @@ discard block |
||
1732 | 1732 | // ----- Reduce the path last (and duplicated) '/' |
1733 | 1733 | if (($p_path != './') && ($p_path != '/')) { |
1734 | 1734 | // ----- Look for the path end '/' |
1735 | - while (substr($p_path, -1) == '/') { |
|
1736 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
1737 | - } |
|
1735 | + while (substr($p_path, -1) == '/') { |
|
1736 | + $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
1737 | + } |
|
1738 | 1738 | } |
1739 | 1739 | |
1740 | 1740 | // ----- Look for path to remove format (should end by /) |
1741 | 1741 | if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) { |
1742 | 1742 | $p_remove_path .= '/'; |
1743 | 1743 | } |
1744 | - $p_remove_path_size = strlen($p_remove_path); |
|
1744 | + $p_remove_path_size = strlen($p_remove_path); |
|
1745 | 1745 | |
1746 | 1746 | // ----- Open the zip file |
1747 | 1747 | if (($v_result = $this->_openFd('rb')) != 1) { |
@@ -1750,202 +1750,202 @@ discard block |
||
1750 | 1750 | |
1751 | 1751 | // ----- Read the central directory informations |
1752 | 1752 | $v_central_dir = array(); |
1753 | - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
1754 | - // ----- Close the zip file |
|
1755 | - $this->_closeFd(); |
|
1753 | + if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
1754 | + // ----- Close the zip file |
|
1755 | + $this->_closeFd(); |
|
1756 | 1756 | |
1757 | - return $v_result; |
|
1758 | - } |
|
1757 | + return $v_result; |
|
1758 | + } |
|
1759 | 1759 | |
1760 | 1760 | // ----- Start at beginning of Central Dir |
1761 | 1761 | $v_pos_entry = $v_central_dir['offset']; |
1762 | 1762 | |
1763 | 1763 | // ----- Read each entry |
1764 | 1764 | $j_start = 0; |
1765 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { |
|
1766 | - // ----- Read next Central dir entry |
|
1767 | - @rewind($this->_zip_fd); |
|
1768 | - if (@fseek($this->_zip_fd, $v_pos_entry)) { |
|
1769 | - $this->_closeFd(); |
|
1765 | + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { |
|
1766 | + // ----- Read next Central dir entry |
|
1767 | + @rewind($this->_zip_fd); |
|
1768 | + if (@fseek($this->_zip_fd, $v_pos_entry)) { |
|
1769 | + $this->_closeFd(); |
|
1770 | 1770 | |
1771 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, |
|
1772 | - 'Invalid archive size'); |
|
1771 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, |
|
1772 | + 'Invalid archive size'); |
|
1773 | 1773 | |
1774 | - return Archive_Zip::errorCode(); |
|
1775 | - } |
|
1774 | + return Archive_Zip::errorCode(); |
|
1775 | + } |
|
1776 | 1776 | |
1777 | - // ----- Read the file header |
|
1778 | - $v_header = array(); |
|
1779 | - if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) { |
|
1780 | - $this->_closeFd(); |
|
1777 | + // ----- Read the file header |
|
1778 | + $v_header = array(); |
|
1779 | + if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) { |
|
1780 | + $this->_closeFd(); |
|
1781 | 1781 | |
1782 | - return $v_result; |
|
1783 | - } |
|
1782 | + return $v_result; |
|
1783 | + } |
|
1784 | 1784 | |
1785 | - // ----- Store the index |
|
1786 | - $v_header['index'] = $i; |
|
1785 | + // ----- Store the index |
|
1786 | + $v_header['index'] = $i; |
|
1787 | 1787 | |
1788 | - // ----- Store the file position |
|
1789 | - $v_pos_entry = ftell($this->_zip_fd); |
|
1788 | + // ----- Store the file position |
|
1789 | + $v_pos_entry = ftell($this->_zip_fd); |
|
1790 | 1790 | |
1791 | - // ----- Look for the specific extract rules |
|
1792 | - $v_extract = false; |
|
1791 | + // ----- Look for the specific extract rules |
|
1792 | + $v_extract = false; |
|
1793 | 1793 | |
1794 | - // ----- Look for extract by name rule |
|
1795 | - if (isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME]) |
|
1794 | + // ----- Look for extract by name rule |
|
1795 | + if (isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME]) |
|
1796 | 1796 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) { |
1797 | 1797 | |
1798 | - // ----- Look if the filename is in the list |
|
1799 | - for ($j=0; |
|
1800 | - ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
1798 | + // ----- Look if the filename is in the list |
|
1799 | + for ($j=0; |
|
1800 | + ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
1801 | 1801 | && (!$v_extract); |
1802 | - $j++) { |
|
1802 | + $j++) { |
|
1803 | 1803 | |
1804 | - // ----- Look for a directory |
|
1805 | - if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == '/') { |
|
1804 | + // ----- Look for a directory |
|
1805 | + if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == '/') { |
|
1806 | 1806 | |
1807 | - // ----- Look if the directory is in the filename path |
|
1808 | - if ((strlen($v_header['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) |
|
1807 | + // ----- Look if the directory is in the filename path |
|
1808 | + if ((strlen($v_header['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) |
|
1809 | 1809 | && (substr($v_header['stored_filename'], 0, strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { |
1810 | - $v_extract = true; |
|
1811 | - } |
|
1812 | - } |
|
1813 | - // ----- Look for a filename |
|
1814 | - elseif ($v_header['stored_filename'] == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) { |
|
1815 | - $v_extract = true; |
|
1816 | - } |
|
1817 | - } |
|
1818 | - } |
|
1819 | - |
|
1820 | - // ----- Look for extract by ereg rule |
|
1821 | - elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG]) |
|
1810 | + $v_extract = true; |
|
1811 | + } |
|
1812 | + } |
|
1813 | + // ----- Look for a filename |
|
1814 | + elseif ($v_header['stored_filename'] == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) { |
|
1815 | + $v_extract = true; |
|
1816 | + } |
|
1817 | + } |
|
1818 | + } |
|
1819 | + |
|
1820 | + // ----- Look for extract by ereg rule |
|
1821 | + elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG]) |
|
1822 | 1822 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_EREG] != '')) { |
1823 | - if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], $v_header['stored_filename'])) { |
|
1824 | - $v_extract = true; |
|
1825 | - } |
|
1826 | - } |
|
1823 | + if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], $v_header['stored_filename'])) { |
|
1824 | + $v_extract = true; |
|
1825 | + } |
|
1826 | + } |
|
1827 | 1827 | |
1828 | - // ----- Look for extract by preg rule |
|
1829 | - elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG]) |
|
1828 | + // ----- Look for extract by preg rule |
|
1829 | + elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG]) |
|
1830 | 1830 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != '')) { |
1831 | - if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], $v_header['stored_filename'])) { |
|
1832 | - $v_extract = true; |
|
1833 | - } |
|
1834 | - } |
|
1831 | + if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], $v_header['stored_filename'])) { |
|
1832 | + $v_extract = true; |
|
1833 | + } |
|
1834 | + } |
|
1835 | 1835 | |
1836 | - // ----- Look for extract by index rule |
|
1837 | - elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX]) |
|
1836 | + // ----- Look for extract by index rule |
|
1837 | + elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX]) |
|
1838 | 1838 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) { |
1839 | 1839 | |
1840 | - // ----- Look if the index is in the list |
|
1841 | - for ($j=$j_start; ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) && (!$v_extract); $j++) { |
|
1842 | - if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { |
|
1843 | - $v_extract = true; |
|
1844 | - } |
|
1845 | - if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
1846 | - $j_start = $j+1; |
|
1847 | - } |
|
1848 | - |
|
1849 | - if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { |
|
1850 | - break; |
|
1851 | - } |
|
1852 | - } |
|
1853 | - } |
|
1840 | + // ----- Look if the index is in the list |
|
1841 | + for ($j=$j_start; ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) && (!$v_extract); $j++) { |
|
1842 | + if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { |
|
1843 | + $v_extract = true; |
|
1844 | + } |
|
1845 | + if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
1846 | + $j_start = $j+1; |
|
1847 | + } |
|
1848 | + |
|
1849 | + if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { |
|
1850 | + break; |
|
1851 | + } |
|
1852 | + } |
|
1853 | + } |
|
1854 | 1854 | |
1855 | - // ----- Look for no rule, which means extract all the archive |
|
1856 | - else { |
|
1857 | - $v_extract = true; |
|
1858 | - } |
|
1855 | + // ----- Look for no rule, which means extract all the archive |
|
1856 | + else { |
|
1857 | + $v_extract = true; |
|
1858 | + } |
|
1859 | 1859 | |
1860 | 1860 | |
1861 | - // ----- Look for real extraction |
|
1862 | - if ($v_extract) { |
|
1861 | + // ----- Look for real extraction |
|
1862 | + if ($v_extract) { |
|
1863 | 1863 | |
1864 | 1864 | // ----- Go to the file position |
1865 | 1865 | @rewind($this->_zip_fd); |
1866 | - if (@fseek($this->_zip_fd, $v_header['offset'])) { |
|
1867 | - // ----- Close the zip file |
|
1868 | - $this->_closeFd(); |
|
1866 | + if (@fseek($this->_zip_fd, $v_header['offset'])) { |
|
1867 | + // ----- Close the zip file |
|
1868 | + $this->_closeFd(); |
|
1869 | 1869 | |
1870 | - // ----- Error log |
|
1871 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
1870 | + // ----- Error log |
|
1871 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
1872 | 1872 | |
1873 | - // ----- Return |
|
1874 | - return Archive_Zip::errorCode(); |
|
1875 | - } |
|
1873 | + // ----- Return |
|
1874 | + return Archive_Zip::errorCode(); |
|
1875 | + } |
|
1876 | 1876 | |
1877 | 1877 | // ----- Look for extraction as string |
1878 | 1878 | if ($p_params[ARCHIVE_ZIP_PARAM_EXTRACT_AS_STRING]) { |
1879 | 1879 | |
1880 | - // ----- Extracting the file |
|
1881 | - if (($v_result = $this->_extractFileAsString($v_header, $v_string)) != 1) { |
|
1882 | - // ----- Close the zip file |
|
1880 | + // ----- Extracting the file |
|
1881 | + if (($v_result = $this->_extractFileAsString($v_header, $v_string)) != 1) { |
|
1882 | + // ----- Close the zip file |
|
1883 | 1883 | $this->_closeFd(); |
1884 | 1884 | |
1885 | - return $v_result; |
|
1886 | - } |
|
1885 | + return $v_result; |
|
1886 | + } |
|
1887 | 1887 | |
1888 | - // ----- Get the only interesting attributes |
|
1889 | - if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) { |
|
1890 | - // ----- Close the zip file |
|
1888 | + // ----- Get the only interesting attributes |
|
1889 | + if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) { |
|
1890 | + // ----- Close the zip file |
|
1891 | 1891 | $this->_closeFd(); |
1892 | 1892 | |
1893 | - return $v_result; |
|
1894 | - } |
|
1893 | + return $v_result; |
|
1894 | + } |
|
1895 | 1895 | |
1896 | - // ----- Set the file content |
|
1897 | - $p_file_list[$v_nb_extracted]['content'] = $v_string; |
|
1896 | + // ----- Set the file content |
|
1897 | + $p_file_list[$v_nb_extracted]['content'] = $v_string; |
|
1898 | 1898 | |
1899 | - // ----- Next extracted file |
|
1900 | - $v_nb_extracted++; |
|
1899 | + // ----- Next extracted file |
|
1900 | + $v_nb_extracted++; |
|
1901 | 1901 | } else { |
1902 | 1902 | // ----- Extracting the file |
1903 | - if (($v_result = $this->_extractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_params)) != 1) { |
|
1904 | - // ----- Close the zip file |
|
1903 | + if (($v_result = $this->_extractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_params)) != 1) { |
|
1904 | + // ----- Close the zip file |
|
1905 | 1905 | $this->_closeFd(); |
1906 | 1906 | |
1907 | - return $v_result; |
|
1908 | - } |
|
1907 | + return $v_result; |
|
1908 | + } |
|
1909 | 1909 | |
1910 | - // ----- Get the only interesting attributes |
|
1911 | - if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { |
|
1912 | - // ----- Close the zip file |
|
1910 | + // ----- Get the only interesting attributes |
|
1911 | + if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { |
|
1912 | + // ----- Close the zip file |
|
1913 | 1913 | $this->_closeFd(); |
1914 | 1914 | |
1915 | - return $v_result; |
|
1916 | - } |
|
1915 | + return $v_result; |
|
1916 | + } |
|
1917 | + } |
|
1918 | + } |
|
1917 | 1919 | } |
1918 | - } |
|
1919 | - } |
|
1920 | 1920 | |
1921 | 1921 | // ----- Close the zip file |
1922 | 1922 | $this->_closeFd(); |
1923 | 1923 | |
1924 | 1924 | // ----- Return |
1925 | 1925 | return $v_result; |
1926 | - } |
|
1927 | - // --------------------------------------------------------------------------- |
|
1928 | - |
|
1929 | - // --------------------------------------------------------------------------- |
|
1930 | - // Function : _extractFile() |
|
1931 | - // Description : |
|
1932 | - // Parameters : |
|
1933 | - // Return Values : |
|
1934 | - // --------------------------------------------------------------------------- |
|
1935 | - /** |
|
1936 | - * Archive_Zip::_extractFile() |
|
1937 | - * |
|
1938 | - * { Description } |
|
1939 | - * |
|
1940 | - */ |
|
1941 | - public function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params) |
|
1942 | - { |
|
1943 | - $v_result=1; |
|
1926 | + } |
|
1927 | + // --------------------------------------------------------------------------- |
|
1928 | + |
|
1929 | + // --------------------------------------------------------------------------- |
|
1930 | + // Function : _extractFile() |
|
1931 | + // Description : |
|
1932 | + // Parameters : |
|
1933 | + // Return Values : |
|
1934 | + // --------------------------------------------------------------------------- |
|
1935 | + /** |
|
1936 | + * Archive_Zip::_extractFile() |
|
1937 | + * |
|
1938 | + * { Description } |
|
1939 | + * |
|
1940 | + */ |
|
1941 | + public function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params) |
|
1942 | + { |
|
1943 | + $v_result=1; |
|
1944 | 1944 | |
1945 | 1945 | // ----- Read the file header |
1946 | 1946 | if (($v_result = $this->_readFileHeader($v_header)) != 1) { |
1947 | 1947 | // ----- Return |
1948 | - return $v_result; |
|
1948 | + return $v_result; |
|
1949 | 1949 | } |
1950 | 1950 | |
1951 | 1951 | |
@@ -1961,14 +1961,14 @@ discard block |
||
1961 | 1961 | // ----- Look for path to remove |
1962 | 1962 | elseif ($p_remove_path != '') { |
1963 | 1963 | //if (strcmp($p_remove_path, $p_entry['filename'])==0) |
1964 | - if ($this->_tool_PathInclusion($p_remove_path, $p_entry['filename']) == 2) { |
|
1964 | + if ($this->_tool_PathInclusion($p_remove_path, $p_entry['filename']) == 2) { |
|
1965 | 1965 | |
1966 | 1966 | // ----- Change the file status |
1967 | 1967 | $p_entry['status'] = 'filtered'; |
1968 | 1968 | |
1969 | 1969 | // ----- Return |
1970 | 1970 | return $v_result; |
1971 | - } |
|
1971 | + } |
|
1972 | 1972 | |
1973 | 1973 | $p_remove_path_size = strlen($p_remove_path); |
1974 | 1974 | if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) { |
@@ -1987,23 +1987,23 @@ discard block |
||
1987 | 1987 | if (isset($p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT]) |
1988 | 1988 | && ($p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT] != '')) { |
1989 | 1989 | |
1990 | - // ----- Generate a local information |
|
1991 | - $v_local_header = array(); |
|
1990 | + // ----- Generate a local information |
|
1991 | + $v_local_header = array(); |
|
1992 | 1992 | $this->_convertHeader2FileInfo($p_entry, $v_local_header); |
1993 | 1993 | |
1994 | - // ----- Call the callback |
|
1995 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
1996 | - // header. |
|
1997 | - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT].'(ARCHIVE_ZIP_PARAM_PRE_EXTRACT, $v_local_header);'); |
|
1994 | + // ----- Call the callback |
|
1995 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
1996 | + // header. |
|
1997 | + eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT].'(ARCHIVE_ZIP_PARAM_PRE_EXTRACT, $v_local_header);'); |
|
1998 | 1998 | if ($v_result == 0) { |
1999 | 1999 | // ----- Change the file status |
2000 | 2000 | $p_entry['status'] = 'skipped'; |
2001 | 2001 | $v_result = 1; |
2002 | 2002 | } |
2003 | 2003 | |
2004 | - // ----- Update the informations |
|
2005 | - // Only some fields can be modified |
|
2006 | - $p_entry['filename'] = $v_local_header['filename']; |
|
2004 | + // ----- Update the informations |
|
2005 | + // Only some fields can be modified |
|
2006 | + $p_entry['filename'] = $v_local_header['filename']; |
|
2007 | 2007 | } |
2008 | 2008 | |
2009 | 2009 | // ----- Trace |
@@ -2014,34 +2014,34 @@ discard block |
||
2014 | 2014 | // ----- Look for specific actions while the file exist |
2015 | 2015 | if (file_exists($p_entry['filename'])) { |
2016 | 2016 | |
2017 | - // ----- Look if file is a directory |
|
2018 | - if (is_dir($p_entry['filename'])) { |
|
2017 | + // ----- Look if file is a directory |
|
2018 | + if (is_dir($p_entry['filename'])) { |
|
2019 | 2019 | |
2020 | 2020 | // ----- Change the file status |
2021 | 2021 | $p_entry['status'] = 'already_a_directory'; |
2022 | 2022 | |
2023 | 2023 | // ----- Return |
2024 | 2024 | //return $v_result; |
2025 | - } |
|
2026 | - // ----- Look if file is write protected |
|
2027 | - elseif (!is_writable($p_entry['filename'])) { |
|
2025 | + } |
|
2026 | + // ----- Look if file is write protected |
|
2027 | + elseif (!is_writable($p_entry['filename'])) { |
|
2028 | 2028 | |
2029 | 2029 | // ----- Change the file status |
2030 | 2030 | $p_entry['status'] = 'write_protected'; |
2031 | 2031 | |
2032 | 2032 | // ----- Return |
2033 | 2033 | //return $v_result; |
2034 | - } |
|
2034 | + } |
|
2035 | 2035 | |
2036 | - // ----- Look if the extracted file is older |
|
2037 | - elseif (filemtime($p_entry['filename']) > $p_entry['mtime']) { |
|
2036 | + // ----- Look if the extracted file is older |
|
2037 | + elseif (filemtime($p_entry['filename']) > $p_entry['mtime']) { |
|
2038 | 2038 | |
2039 | 2039 | // ----- Change the file status |
2040 | 2040 | $p_entry['status'] = 'newer_exist'; |
2041 | 2041 | |
2042 | 2042 | // ----- Return |
2043 | 2043 | //return $v_result; |
2044 | - } |
|
2044 | + } |
|
2045 | 2045 | } |
2046 | 2046 | |
2047 | 2047 | // ----- Check the directory availability and create it if necessary |
@@ -2069,25 +2069,25 @@ discard block |
||
2069 | 2069 | // ----- Look if extraction should be done |
2070 | 2070 | if ($p_entry['status'] == 'ok') { |
2071 | 2071 | |
2072 | - // ----- Do the extraction (if not a folder) |
|
2073 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
2072 | + // ----- Do the extraction (if not a folder) |
|
2073 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
2074 | 2074 | |
2075 | 2075 | // ----- Look for not compressed file |
2076 | 2076 | if ($p_entry['compressed_size'] == $p_entry['size']) { |
2077 | 2077 | |
2078 | - // ----- Opening destination file |
|
2079 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
2078 | + // ----- Opening destination file |
|
2079 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
2080 | 2080 | |
2081 | 2081 | // ----- Change the file status |
2082 | 2082 | $p_entry['status'] = 'write_error'; |
2083 | 2083 | |
2084 | 2084 | // ----- Return |
2085 | 2085 | return $v_result; |
2086 | - } |
|
2086 | + } |
|
2087 | 2087 | |
2088 | 2088 | |
2089 | - // ----- Read the file by ARCHIVE_ZIP_READ_BLOCK_SIZE octets blocks |
|
2090 | - $v_size = $p_entry['compressed_size']; |
|
2089 | + // ----- Read the file by ARCHIVE_ZIP_READ_BLOCK_SIZE octets blocks |
|
2090 | + $v_size = $p_entry['compressed_size']; |
|
2091 | 2091 | while ($v_size != 0) { |
2092 | 2092 | $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
2093 | 2093 | $v_buffer = fread($this->_zip_fd, $v_read_size); |
@@ -2096,93 +2096,93 @@ discard block |
||
2096 | 2096 | $v_size -= $v_read_size; |
2097 | 2097 | } |
2098 | 2098 | |
2099 | - // ----- Closing the destination file |
|
2100 | - fclose($v_dest_file); |
|
2099 | + // ----- Closing the destination file |
|
2100 | + fclose($v_dest_file); |
|
2101 | 2101 | |
2102 | - // ----- Change the file mtime |
|
2103 | - touch($p_entry['filename'], $p_entry['mtime']); |
|
2102 | + // ----- Change the file mtime |
|
2103 | + touch($p_entry['filename'], $p_entry['mtime']); |
|
2104 | 2104 | } else { |
2105 | 2105 | // ----- Trace |
2106 | 2106 | |
2107 | - // ----- Opening destination file |
|
2108 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
2107 | + // ----- Opening destination file |
|
2108 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
2109 | 2109 | |
2110 | 2110 | // ----- Change the file status |
2111 | 2111 | $p_entry['status'] = 'write_error'; |
2112 | 2112 | |
2113 | - return $v_result; |
|
2114 | - } |
|
2113 | + return $v_result; |
|
2114 | + } |
|
2115 | 2115 | |
2116 | 2116 | |
2117 | - // ----- Read the compressed file in a buffer (one shot) |
|
2118 | - $v_buffer = @fread($this->_zip_fd, $p_entry['compressed_size']); |
|
2117 | + // ----- Read the compressed file in a buffer (one shot) |
|
2118 | + $v_buffer = @fread($this->_zip_fd, $p_entry['compressed_size']); |
|
2119 | 2119 | |
2120 | - // ----- Decompress the file |
|
2121 | - $v_file_content = gzinflate($v_buffer); |
|
2120 | + // ----- Decompress the file |
|
2121 | + $v_file_content = gzinflate($v_buffer); |
|
2122 | 2122 | unset($v_buffer); |
2123 | 2123 | |
2124 | - // ----- Write the uncompressed data |
|
2125 | - @fwrite($v_dest_file, $v_file_content, $p_entry['size']); |
|
2124 | + // ----- Write the uncompressed data |
|
2125 | + @fwrite($v_dest_file, $v_file_content, $p_entry['size']); |
|
2126 | 2126 | unset($v_file_content); |
2127 | 2127 | |
2128 | - // ----- Closing the destination file |
|
2129 | - @fclose($v_dest_file); |
|
2128 | + // ----- Closing the destination file |
|
2129 | + @fclose($v_dest_file); |
|
2130 | 2130 | |
2131 | - // ----- Change the file mtime |
|
2132 | - touch($p_entry['filename'], $p_entry['mtime']); |
|
2131 | + // ----- Change the file mtime |
|
2132 | + touch($p_entry['filename'], $p_entry['mtime']); |
|
2133 | 2133 | } |
2134 | 2134 | |
2135 | 2135 | // ----- Look for chmod option |
2136 | 2136 | if (isset($p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD]) |
2137 | 2137 | && ($p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD] != 0)) { |
2138 | 2138 | |
2139 | - // ----- Change the mode of the file |
|
2140 | - chmod($p_entry['filename'], $p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD]); |
|
2139 | + // ----- Change the mode of the file |
|
2140 | + chmod($p_entry['filename'], $p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD]); |
|
2141 | + } |
|
2141 | 2142 | } |
2142 | - } |
|
2143 | 2143 | } |
2144 | 2144 | |
2145 | 2145 | // ----- Look for post-extract callback |
2146 | 2146 | if (isset($p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT]) |
2147 | 2147 | && ($p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT] != '')) { |
2148 | 2148 | |
2149 | - // ----- Generate a local information |
|
2150 | - $v_local_header = array(); |
|
2149 | + // ----- Generate a local information |
|
2150 | + $v_local_header = array(); |
|
2151 | 2151 | $this->_convertHeader2FileInfo($p_entry, $v_local_header); |
2152 | 2152 | |
2153 | - // ----- Call the callback |
|
2154 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
2155 | - // header. |
|
2156 | - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT].'(ARCHIVE_ZIP_PARAM_POST_EXTRACT, $v_local_header);'); |
|
2153 | + // ----- Call the callback |
|
2154 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
2155 | + // header. |
|
2156 | + eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT].'(ARCHIVE_ZIP_PARAM_POST_EXTRACT, $v_local_header);'); |
|
2157 | 2157 | } |
2158 | 2158 | |
2159 | 2159 | // ----- Return |
2160 | 2160 | return $v_result; |
2161 | - } |
|
2162 | - // --------------------------------------------------------------------------- |
|
2163 | - |
|
2164 | - // --------------------------------------------------------------------------- |
|
2165 | - // Function : _extractFileAsString() |
|
2166 | - // Description : |
|
2167 | - // Parameters : |
|
2168 | - // Return Values : |
|
2169 | - // --------------------------------------------------------------------------- |
|
2170 | - /** |
|
2171 | - * Archive_Zip::_extractFileAsString() |
|
2172 | - * |
|
2173 | - * { Description } |
|
2174 | - * |
|
2175 | - */ |
|
2176 | - public function _extractFileAsString(&$p_entry, &$p_string) |
|
2177 | - { |
|
2178 | - $v_result=1; |
|
2161 | + } |
|
2162 | + // --------------------------------------------------------------------------- |
|
2163 | + |
|
2164 | + // --------------------------------------------------------------------------- |
|
2165 | + // Function : _extractFileAsString() |
|
2166 | + // Description : |
|
2167 | + // Parameters : |
|
2168 | + // Return Values : |
|
2169 | + // --------------------------------------------------------------------------- |
|
2170 | + /** |
|
2171 | + * Archive_Zip::_extractFileAsString() |
|
2172 | + * |
|
2173 | + * { Description } |
|
2174 | + * |
|
2175 | + */ |
|
2176 | + public function _extractFileAsString(&$p_entry, &$p_string) |
|
2177 | + { |
|
2178 | + $v_result=1; |
|
2179 | 2179 | |
2180 | 2180 | // ----- Read the file header |
2181 | 2181 | $v_header = array(); |
2182 | - if (($v_result = $this->_readFileHeader($v_header)) != 1) { |
|
2183 | - // ----- Return |
|
2184 | - return $v_result; |
|
2185 | - } |
|
2182 | + if (($v_result = $this->_readFileHeader($v_header)) != 1) { |
|
2183 | + // ----- Return |
|
2184 | + return $v_result; |
|
2185 | + } |
|
2186 | 2186 | |
2187 | 2187 | |
2188 | 2188 | // ----- Check that the file header is coherent with $p_entry info |
@@ -2193,59 +2193,59 @@ discard block |
||
2193 | 2193 | // ----- Do the extraction (if not a folder) |
2194 | 2194 | if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
2195 | 2195 | // ----- Look for not compressed file |
2196 | - if ($p_entry['compressed_size'] == $p_entry['size']) { |
|
2197 | - // ----- Trace |
|
2196 | + if ($p_entry['compressed_size'] == $p_entry['size']) { |
|
2197 | + // ----- Trace |
|
2198 | 2198 | |
2199 | 2199 | // ----- Reading the file |
2200 | 2200 | $p_string = fread($this->_zip_fd, $p_entry['compressed_size']); |
2201 | - } else { |
|
2202 | - // ----- Trace |
|
2201 | + } else { |
|
2202 | + // ----- Trace |
|
2203 | 2203 | |
2204 | 2204 | // ----- Reading the file |
2205 | 2205 | $v_data = fread($this->_zip_fd, $p_entry['compressed_size']); |
2206 | 2206 | |
2207 | 2207 | // ----- Decompress the file |
2208 | 2208 | $p_string = gzinflate($v_data); |
2209 | - } |
|
2209 | + } |
|
2210 | 2210 | |
2211 | - // ----- Trace |
|
2211 | + // ----- Trace |
|
2212 | 2212 | } else { |
2213 | 2213 | // TBC : error : can not extract a folder in a string |
2214 | 2214 | } |
2215 | 2215 | |
2216 | 2216 | // ----- Return |
2217 | 2217 | return $v_result; |
2218 | - } |
|
2219 | - // --------------------------------------------------------------------------- |
|
2220 | - |
|
2221 | - // --------------------------------------------------------------------------- |
|
2222 | - // Function : _readFileHeader() |
|
2223 | - // Description : |
|
2224 | - // Parameters : |
|
2225 | - // Return Values : |
|
2226 | - // --------------------------------------------------------------------------- |
|
2227 | - /** |
|
2228 | - * Archive_Zip::_readFileHeader() |
|
2229 | - * |
|
2230 | - * { Description } |
|
2231 | - * |
|
2232 | - */ |
|
2233 | - public function _readFileHeader(&$p_header) |
|
2234 | - { |
|
2235 | - $v_result=1; |
|
2218 | + } |
|
2219 | + // --------------------------------------------------------------------------- |
|
2220 | + |
|
2221 | + // --------------------------------------------------------------------------- |
|
2222 | + // Function : _readFileHeader() |
|
2223 | + // Description : |
|
2224 | + // Parameters : |
|
2225 | + // Return Values : |
|
2226 | + // --------------------------------------------------------------------------- |
|
2227 | + /** |
|
2228 | + * Archive_Zip::_readFileHeader() |
|
2229 | + * |
|
2230 | + * { Description } |
|
2231 | + * |
|
2232 | + */ |
|
2233 | + public function _readFileHeader(&$p_header) |
|
2234 | + { |
|
2235 | + $v_result=1; |
|
2236 | 2236 | |
2237 | 2237 | // ----- Read the 4 bytes signature |
2238 | 2238 | $v_binary_data = @fread($this->_zip_fd, 4); |
2239 | - $v_data = unpack('Vid', $v_binary_data); |
|
2239 | + $v_data = unpack('Vid', $v_binary_data); |
|
2240 | 2240 | |
2241 | 2241 | // ----- Check signature |
2242 | 2242 | if ($v_data['id'] != 0x04034b50) { |
2243 | 2243 | |
2244 | - // ----- Error log |
|
2245 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
2244 | + // ----- Error log |
|
2245 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
2246 | 2246 | |
2247 | - // ----- Return |
|
2248 | - return Archive_Zip::errorCode(); |
|
2247 | + // ----- Return |
|
2248 | + return Archive_Zip::errorCode(); |
|
2249 | 2249 | } |
2250 | 2250 | |
2251 | 2251 | // ----- Read the first 42 bytes of the header |
@@ -2256,11 +2256,11 @@ discard block |
||
2256 | 2256 | $p_header['filename'] = ''; |
2257 | 2257 | $p_header['status'] = 'invalid_header'; |
2258 | 2258 | |
2259 | - // ----- Error log |
|
2260 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : ' . strlen($v_binary_data)); |
|
2259 | + // ----- Error log |
|
2260 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : ' . strlen($v_binary_data)); |
|
2261 | 2261 | |
2262 | - // ----- Return |
|
2263 | - return Archive_Zip::errorCode(); |
|
2262 | + // ----- Return |
|
2263 | + return Archive_Zip::errorCode(); |
|
2264 | 2264 | } |
2265 | 2265 | |
2266 | 2266 | // ----- Extract the values |
@@ -2278,30 +2278,30 @@ discard block |
||
2278 | 2278 | |
2279 | 2279 | // ----- Extract properties |
2280 | 2280 | $p_header['compression'] = $v_data['compression']; |
2281 | - $p_header['size'] = $v_data['size']; |
|
2282 | - $p_header['compressed_size'] = $v_data['compressed_size']; |
|
2283 | - $p_header['crc'] = $v_data['crc']; |
|
2284 | - $p_header['flag'] = $v_data['flag']; |
|
2281 | + $p_header['size'] = $v_data['size']; |
|
2282 | + $p_header['compressed_size'] = $v_data['compressed_size']; |
|
2283 | + $p_header['crc'] = $v_data['crc']; |
|
2284 | + $p_header['flag'] = $v_data['flag']; |
|
2285 | 2285 | |
2286 | 2286 | // ----- Recuperate date in UNIX format |
2287 | 2287 | $p_header['mdate'] = $v_data['mdate']; |
2288 | - $p_header['mtime'] = $v_data['mtime']; |
|
2289 | - if ($p_header['mdate'] && $p_header['mtime']) { |
|
2290 | - // ----- Extract time |
|
2291 | - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
2292 | - $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
2293 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
2294 | - |
|
2295 | - // ----- Extract date |
|
2296 | - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
2297 | - $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
2298 | - $v_day = $p_header['mdate'] & 0x001F; |
|
2299 | - |
|
2300 | - // ----- Get UNIX date format |
|
2301 | - $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
2302 | - } else { |
|
2303 | - $p_header['mtime'] = time(); |
|
2304 | - } |
|
2288 | + $p_header['mtime'] = $v_data['mtime']; |
|
2289 | + if ($p_header['mdate'] && $p_header['mtime']) { |
|
2290 | + // ----- Extract time |
|
2291 | + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
2292 | + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
2293 | + $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
2294 | + |
|
2295 | + // ----- Extract date |
|
2296 | + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
2297 | + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
2298 | + $v_day = $p_header['mdate'] & 0x001F; |
|
2299 | + |
|
2300 | + // ----- Get UNIX date format |
|
2301 | + $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
2302 | + } else { |
|
2303 | + $p_header['mtime'] = time(); |
|
2304 | + } |
|
2305 | 2305 | |
2306 | 2306 | // ----- Other informations |
2307 | 2307 | |
@@ -2317,37 +2317,37 @@ discard block |
||
2317 | 2317 | |
2318 | 2318 | // ----- Return |
2319 | 2319 | return $v_result; |
2320 | - } |
|
2321 | - // --------------------------------------------------------------------------- |
|
2322 | - |
|
2323 | - // --------------------------------------------------------------------------- |
|
2324 | - // Function : _readCentralFileHeader() |
|
2325 | - // Description : |
|
2326 | - // Parameters : |
|
2327 | - // Return Values : |
|
2328 | - // --------------------------------------------------------------------------- |
|
2329 | - /** |
|
2330 | - * Archive_Zip::_readCentralFileHeader() |
|
2331 | - * |
|
2332 | - * { Description } |
|
2333 | - * |
|
2334 | - */ |
|
2335 | - public function _readCentralFileHeader(&$p_header) |
|
2336 | - { |
|
2337 | - $v_result=1; |
|
2320 | + } |
|
2321 | + // --------------------------------------------------------------------------- |
|
2322 | + |
|
2323 | + // --------------------------------------------------------------------------- |
|
2324 | + // Function : _readCentralFileHeader() |
|
2325 | + // Description : |
|
2326 | + // Parameters : |
|
2327 | + // Return Values : |
|
2328 | + // --------------------------------------------------------------------------- |
|
2329 | + /** |
|
2330 | + * Archive_Zip::_readCentralFileHeader() |
|
2331 | + * |
|
2332 | + * { Description } |
|
2333 | + * |
|
2334 | + */ |
|
2335 | + public function _readCentralFileHeader(&$p_header) |
|
2336 | + { |
|
2337 | + $v_result=1; |
|
2338 | 2338 | |
2339 | 2339 | // ----- Read the 4 bytes signature |
2340 | 2340 | $v_binary_data = @fread($this->_zip_fd, 4); |
2341 | - $v_data = unpack('Vid', $v_binary_data); |
|
2341 | + $v_data = unpack('Vid', $v_binary_data); |
|
2342 | 2342 | |
2343 | 2343 | // ----- Check signature |
2344 | 2344 | if ($v_data['id'] != 0x02014b50) { |
2345 | 2345 | |
2346 | - // ----- Error log |
|
2347 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
2346 | + // ----- Error log |
|
2347 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
2348 | 2348 | |
2349 | - // ----- Return |
|
2350 | - return Archive_Zip::errorCode(); |
|
2349 | + // ----- Return |
|
2350 | + return Archive_Zip::errorCode(); |
|
2351 | 2351 | } |
2352 | 2352 | |
2353 | 2353 | // ----- Read the first 42 bytes of the header |
@@ -2358,11 +2358,11 @@ discard block |
||
2358 | 2358 | $p_header['filename'] = ''; |
2359 | 2359 | $p_header['status'] = 'invalid_header'; |
2360 | 2360 | |
2361 | - // ----- Error log |
|
2362 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : ' . strlen($v_binary_data)); |
|
2361 | + // ----- Error log |
|
2362 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : ' . strlen($v_binary_data)); |
|
2363 | 2363 | |
2364 | - // ----- Return |
|
2365 | - return Archive_Zip::errorCode(); |
|
2364 | + // ----- Return |
|
2365 | + return Archive_Zip::errorCode(); |
|
2366 | 2366 | } |
2367 | 2367 | |
2368 | 2368 | // ----- Extract the values |
@@ -2394,17 +2394,17 @@ discard block |
||
2394 | 2394 | // ----- Recuperate date in UNIX format |
2395 | 2395 | if ($p_header['mdate'] && $p_header['mtime']) { |
2396 | 2396 | // ----- Extract time |
2397 | - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
2397 | + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
2398 | 2398 | $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
2399 | 2399 | $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
2400 | 2400 | |
2401 | - // ----- Extract date |
|
2402 | - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
2401 | + // ----- Extract date |
|
2402 | + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
2403 | 2403 | $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
2404 | 2404 | $v_day = $p_header['mdate'] & 0x001F; |
2405 | 2405 | |
2406 | - // ----- Get UNIX date format |
|
2407 | - $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
2406 | + // ----- Get UNIX date format |
|
2407 | + $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
2408 | 2408 | } else { |
2409 | 2409 | $p_header['mtime'] = time(); |
2410 | 2410 | } |
@@ -2423,76 +2423,76 @@ discard block |
||
2423 | 2423 | |
2424 | 2424 | // ----- Return |
2425 | 2425 | return $v_result; |
2426 | - } |
|
2427 | - // --------------------------------------------------------------------------- |
|
2428 | - |
|
2429 | - // --------------------------------------------------------------------------- |
|
2430 | - // Function : _readEndCentralDir() |
|
2431 | - // Description : |
|
2432 | - // Parameters : |
|
2433 | - // Return Values : |
|
2434 | - // --------------------------------------------------------------------------- |
|
2435 | - /** |
|
2436 | - * Archive_Zip::_readEndCentralDir() |
|
2437 | - * |
|
2438 | - * { Description } |
|
2439 | - * |
|
2440 | - */ |
|
2441 | - public function _readEndCentralDir(&$p_central_dir) |
|
2442 | - { |
|
2443 | - $v_result=1; |
|
2426 | + } |
|
2427 | + // --------------------------------------------------------------------------- |
|
2428 | + |
|
2429 | + // --------------------------------------------------------------------------- |
|
2430 | + // Function : _readEndCentralDir() |
|
2431 | + // Description : |
|
2432 | + // Parameters : |
|
2433 | + // Return Values : |
|
2434 | + // --------------------------------------------------------------------------- |
|
2435 | + /** |
|
2436 | + * Archive_Zip::_readEndCentralDir() |
|
2437 | + * |
|
2438 | + * { Description } |
|
2439 | + * |
|
2440 | + */ |
|
2441 | + public function _readEndCentralDir(&$p_central_dir) |
|
2442 | + { |
|
2443 | + $v_result=1; |
|
2444 | 2444 | |
2445 | 2445 | // ----- Go to the end of the zip file |
2446 | 2446 | $v_size = filesize($this->_zipname); |
2447 | - @fseek($this->_zip_fd, $v_size); |
|
2448 | - if (@ftell($this->_zip_fd) != $v_size) { |
|
2449 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
|
2450 | - 'Unable to go to the end of the archive \'' |
|
2451 | - .$this->_zipname.'\''); |
|
2452 | - return Archive_Zip::errorCode(); |
|
2453 | - } |
|
2447 | + @fseek($this->_zip_fd, $v_size); |
|
2448 | + if (@ftell($this->_zip_fd) != $v_size) { |
|
2449 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
|
2450 | + 'Unable to go to the end of the archive \'' |
|
2451 | + .$this->_zipname.'\''); |
|
2452 | + return Archive_Zip::errorCode(); |
|
2453 | + } |
|
2454 | 2454 | |
2455 | 2455 | // ----- First try : look if this is an archive with no commentaries |
2456 | 2456 | // (most of the time) |
2457 | 2457 | // in this case the end of central dir is at 22 bytes of the file end |
2458 | 2458 | $v_found = 0; |
2459 | - if ($v_size > 26) { |
|
2460 | - @fseek($this->_zip_fd, $v_size-22); |
|
2461 | - if (($v_pos = @ftell($this->_zip_fd)) != ($v_size-22)) { |
|
2462 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
|
2463 | - 'Unable to seek back to the middle of the archive \'' |
|
2464 | - .$this->_zipname.'\''); |
|
2465 | - return Archive_Zip::errorCode(); |
|
2466 | - } |
|
2467 | - |
|
2468 | - // ----- Read for bytes |
|
2469 | - $v_binary_data = @fread($this->_zip_fd, 4); |
|
2470 | - $v_data = unpack('Vid', $v_binary_data); |
|
2471 | - |
|
2472 | - // ----- Check signature |
|
2473 | - if ($v_data['id'] == 0x06054b50) { |
|
2474 | - $v_found = 1; |
|
2475 | - } |
|
2476 | - |
|
2477 | - $v_pos = ftell($this->_zip_fd); |
|
2478 | - } |
|
2459 | + if ($v_size > 26) { |
|
2460 | + @fseek($this->_zip_fd, $v_size-22); |
|
2461 | + if (($v_pos = @ftell($this->_zip_fd)) != ($v_size-22)) { |
|
2462 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
|
2463 | + 'Unable to seek back to the middle of the archive \'' |
|
2464 | + .$this->_zipname.'\''); |
|
2465 | + return Archive_Zip::errorCode(); |
|
2466 | + } |
|
2467 | + |
|
2468 | + // ----- Read for bytes |
|
2469 | + $v_binary_data = @fread($this->_zip_fd, 4); |
|
2470 | + $v_data = unpack('Vid', $v_binary_data); |
|
2471 | + |
|
2472 | + // ----- Check signature |
|
2473 | + if ($v_data['id'] == 0x06054b50) { |
|
2474 | + $v_found = 1; |
|
2475 | + } |
|
2476 | + |
|
2477 | + $v_pos = ftell($this->_zip_fd); |
|
2478 | + } |
|
2479 | 2479 | |
2480 | 2480 | // ----- Go back to the maximum possible size of the Central Dir End Record |
2481 | 2481 | if (!$v_found) { |
2482 | 2482 | $v_maximum_size = 65557; // 0xFFFF + 22; |
2483 | - if ($v_maximum_size > $v_size) { |
|
2484 | - $v_maximum_size = $v_size; |
|
2485 | - } |
|
2483 | + if ($v_maximum_size > $v_size) { |
|
2484 | + $v_maximum_size = $v_size; |
|
2485 | + } |
|
2486 | 2486 | @fseek($this->_zip_fd, $v_size-$v_maximum_size); |
2487 | 2487 | if (@ftell($this->_zip_fd) != ($v_size-$v_maximum_size)) { |
2488 | 2488 | $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
2489 | - 'Unable to seek back to the middle of the archive \'' |
|
2490 | - .$this->_zipname.'\''); |
|
2489 | + 'Unable to seek back to the middle of the archive \'' |
|
2490 | + .$this->_zipname.'\''); |
|
2491 | 2491 | return Archive_Zip::errorCode(); |
2492 | 2492 | } |
2493 | 2493 | |
2494 | - // ----- Read byte per byte in order to find the signature |
|
2495 | - $v_pos = ftell($this->_zip_fd); |
|
2494 | + // ----- Read byte per byte in order to find the signature |
|
2495 | + $v_pos = ftell($this->_zip_fd); |
|
2496 | 2496 | $v_bytes = 0x00000000; |
2497 | 2497 | while ($v_pos < $v_size) { |
2498 | 2498 | // ----- Read a byte |
@@ -2510,11 +2510,11 @@ discard block |
||
2510 | 2510 | $v_pos++; |
2511 | 2511 | } |
2512 | 2512 | |
2513 | - // ----- Look if not found end of central dir |
|
2514 | - if ($v_pos == $v_size) { |
|
2515 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Unable to find End of Central Dir Record signature'); |
|
2516 | - return Archive_Zip::errorCode(); |
|
2517 | - } |
|
2513 | + // ----- Look if not found end of central dir |
|
2514 | + if ($v_pos == $v_size) { |
|
2515 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Unable to find End of Central Dir Record signature'); |
|
2516 | + return Archive_Zip::errorCode(); |
|
2517 | + } |
|
2518 | 2518 | } |
2519 | 2519 | |
2520 | 2520 | // ----- Read the first 18 bytes of the header |
@@ -2523,8 +2523,8 @@ discard block |
||
2523 | 2523 | // ----- Look for invalid block size |
2524 | 2524 | if (strlen($v_binary_data) != 18) { |
2525 | 2525 | $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
2526 | - 'Invalid End of Central Dir Record size : ' |
|
2527 | - . strlen($v_binary_data)); |
|
2526 | + 'Invalid End of Central Dir Record size : ' |
|
2527 | + . strlen($v_binary_data)); |
|
2528 | 2528 | return Archive_Zip::errorCode(); |
2529 | 2529 | } |
2530 | 2530 | |
@@ -2544,47 +2544,47 @@ discard block |
||
2544 | 2544 | $p_central_dir['comment'] = ''; |
2545 | 2545 | } |
2546 | 2546 | |
2547 | - $p_central_dir['entries'] = $v_data['entries']; |
|
2548 | - $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
|
2549 | - $p_central_dir['offset'] = $v_data['offset']; |
|
2550 | - $p_central_dir['size'] = $v_data['size']; |
|
2551 | - $p_central_dir['disk'] = $v_data['disk']; |
|
2552 | - $p_central_dir['disk_start'] = $v_data['disk_start']; |
|
2547 | + $p_central_dir['entries'] = $v_data['entries']; |
|
2548 | + $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
|
2549 | + $p_central_dir['offset'] = $v_data['offset']; |
|
2550 | + $p_central_dir['size'] = $v_data['size']; |
|
2551 | + $p_central_dir['disk'] = $v_data['disk']; |
|
2552 | + $p_central_dir['disk_start'] = $v_data['disk_start']; |
|
2553 | 2553 | |
2554 | 2554 | // ----- Return |
2555 | 2555 | return $v_result; |
2556 | - } |
|
2557 | - // --------------------------------------------------------------------------- |
|
2558 | - |
|
2559 | - // --------------------------------------------------------------------------- |
|
2560 | - // Function : _deleteByRule() |
|
2561 | - // Description : |
|
2562 | - // Parameters : |
|
2563 | - // Return Values : |
|
2564 | - // --------------------------------------------------------------------------- |
|
2565 | - /** |
|
2566 | - * Archive_Zip::_deleteByRule() |
|
2567 | - * |
|
2568 | - * { Description } |
|
2569 | - * |
|
2570 | - */ |
|
2571 | - public function _deleteByRule(&$p_result_list, &$p_params) |
|
2572 | - { |
|
2573 | - $v_result=1; |
|
2574 | - $v_list_detail = array(); |
|
2556 | + } |
|
2557 | + // --------------------------------------------------------------------------- |
|
2558 | + |
|
2559 | + // --------------------------------------------------------------------------- |
|
2560 | + // Function : _deleteByRule() |
|
2561 | + // Description : |
|
2562 | + // Parameters : |
|
2563 | + // Return Values : |
|
2564 | + // --------------------------------------------------------------------------- |
|
2565 | + /** |
|
2566 | + * Archive_Zip::_deleteByRule() |
|
2567 | + * |
|
2568 | + * { Description } |
|
2569 | + * |
|
2570 | + */ |
|
2571 | + public function _deleteByRule(&$p_result_list, &$p_params) |
|
2572 | + { |
|
2573 | + $v_result=1; |
|
2574 | + $v_list_detail = array(); |
|
2575 | 2575 | |
2576 | 2576 | // ----- Open the zip file |
2577 | 2577 | if (($v_result=$this->_openFd('rb')) != 1) { |
2578 | 2578 | // ----- Return |
2579 | - return $v_result; |
|
2579 | + return $v_result; |
|
2580 | 2580 | } |
2581 | 2581 | |
2582 | 2582 | // ----- Read the central directory informations |
2583 | 2583 | $v_central_dir = array(); |
2584 | - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
2585 | - $this->_closeFd(); |
|
2586 | - return $v_result; |
|
2587 | - } |
|
2584 | + if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
2585 | + $this->_closeFd(); |
|
2586 | + return $v_result; |
|
2587 | + } |
|
2588 | 2588 | |
2589 | 2589 | // ----- Go to beginning of File |
2590 | 2590 | @rewind($this->_zip_fd); |
@@ -2592,123 +2592,123 @@ discard block |
||
2592 | 2592 | // ----- Scan all the files |
2593 | 2593 | // ----- Start at beginning of Central Dir |
2594 | 2594 | $v_pos_entry = $v_central_dir['offset']; |
2595 | - @rewind($this->_zip_fd); |
|
2596 | - if (@fseek($this->_zip_fd, $v_pos_entry)) { |
|
2597 | - // ----- Clean |
|
2598 | - $this->_closeFd(); |
|
2595 | + @rewind($this->_zip_fd); |
|
2596 | + if (@fseek($this->_zip_fd, $v_pos_entry)) { |
|
2597 | + // ----- Clean |
|
2598 | + $this->_closeFd(); |
|
2599 | 2599 | |
2600 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, |
|
2601 | - 'Invalid archive size'); |
|
2602 | - return Archive_Zip::errorCode(); |
|
2603 | - } |
|
2600 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, |
|
2601 | + 'Invalid archive size'); |
|
2602 | + return Archive_Zip::errorCode(); |
|
2603 | + } |
|
2604 | 2604 | |
2605 | 2605 | // ----- Read each entry |
2606 | 2606 | $v_header_list = array(); |
2607 | - $j_start = 0; |
|
2608 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { |
|
2607 | + $j_start = 0; |
|
2608 | + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { |
|
2609 | 2609 | |
2610 | - // ----- Read the file header |
|
2611 | - $v_header_list[$v_nb_extracted] = array(); |
|
2612 | - $v_result |
|
2610 | + // ----- Read the file header |
|
2611 | + $v_header_list[$v_nb_extracted] = array(); |
|
2612 | + $v_result |
|
2613 | 2613 | = $this->_readCentralFileHeader($v_header_list[$v_nb_extracted]); |
2614 | - if ($v_result != 1) { |
|
2615 | - // ----- Clean |
|
2614 | + if ($v_result != 1) { |
|
2615 | + // ----- Clean |
|
2616 | 2616 | $this->_closeFd(); |
2617 | 2617 | |
2618 | - return $v_result; |
|
2619 | - } |
|
2618 | + return $v_result; |
|
2619 | + } |
|
2620 | 2620 | |
2621 | - // ----- Store the index |
|
2622 | - $v_header_list[$v_nb_extracted]['index'] = $i; |
|
2621 | + // ----- Store the index |
|
2622 | + $v_header_list[$v_nb_extracted]['index'] = $i; |
|
2623 | 2623 | |
2624 | - // ----- Look for the specific extract rules |
|
2625 | - $v_found = false; |
|
2624 | + // ----- Look for the specific extract rules |
|
2625 | + $v_found = false; |
|
2626 | 2626 | |
2627 | - // ----- Look for extract by name rule |
|
2628 | - if (isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME]) |
|
2627 | + // ----- Look for extract by name rule |
|
2628 | + if (isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME]) |
|
2629 | 2629 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) { |
2630 | 2630 | |
2631 | - // ----- Look if the filename is in the list |
|
2632 | - for ($j=0; |
|
2633 | - ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
2631 | + // ----- Look if the filename is in the list |
|
2632 | + for ($j=0; |
|
2633 | + ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
2634 | 2634 | && (!$v_found); |
2635 | - $j++) { |
|
2635 | + $j++) { |
|
2636 | 2636 | |
2637 | - // ----- Look for a directory |
|
2638 | - if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == '/') { |
|
2637 | + // ----- Look for a directory |
|
2638 | + if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == '/') { |
|
2639 | 2639 | |
2640 | - // ----- Look if the directory is in the filename path |
|
2641 | - if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) |
|
2640 | + // ----- Look if the directory is in the filename path |
|
2641 | + if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) |
|
2642 | 2642 | && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { |
2643 | - $v_found = true; |
|
2644 | - } elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
2643 | + $v_found = true; |
|
2644 | + } elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
2645 | 2645 | && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { |
2646 | - $v_found = true; |
|
2647 | - } |
|
2648 | - } |
|
2649 | - // ----- Look for a filename |
|
2650 | - elseif ($v_header_list[$v_nb_extracted]['stored_filename'] |
|
2651 | - == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) { |
|
2652 | - $v_found = true; |
|
2653 | - } |
|
2654 | - } |
|
2655 | - } |
|
2656 | - |
|
2657 | - // ----- Look for extract by ereg rule |
|
2658 | - elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG]) |
|
2646 | + $v_found = true; |
|
2647 | + } |
|
2648 | + } |
|
2649 | + // ----- Look for a filename |
|
2650 | + elseif ($v_header_list[$v_nb_extracted]['stored_filename'] |
|
2651 | + == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) { |
|
2652 | + $v_found = true; |
|
2653 | + } |
|
2654 | + } |
|
2655 | + } |
|
2656 | + |
|
2657 | + // ----- Look for extract by ereg rule |
|
2658 | + elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG]) |
|
2659 | 2659 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_EREG] != '')) { |
2660 | - if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], |
|
2661 | - $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
2662 | - $v_found = true; |
|
2663 | - } |
|
2664 | - } |
|
2665 | - |
|
2666 | - // ----- Look for extract by preg rule |
|
2667 | - elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG]) |
|
2660 | + if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], |
|
2661 | + $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
2662 | + $v_found = true; |
|
2663 | + } |
|
2664 | + } |
|
2665 | + |
|
2666 | + // ----- Look for extract by preg rule |
|
2667 | + elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG]) |
|
2668 | 2668 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != '')) { |
2669 | - if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], |
|
2670 | - $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
2671 | - $v_found = true; |
|
2672 | - } |
|
2673 | - } |
|
2674 | - |
|
2675 | - // ----- Look for extract by index rule |
|
2676 | - elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX]) |
|
2669 | + if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], |
|
2670 | + $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
2671 | + $v_found = true; |
|
2672 | + } |
|
2673 | + } |
|
2674 | + |
|
2675 | + // ----- Look for extract by index rule |
|
2676 | + elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX]) |
|
2677 | 2677 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) { |
2678 | 2678 | |
2679 | - // ----- Look if the index is in the list |
|
2680 | - for ($j=$j_start; |
|
2681 | - ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) |
|
2679 | + // ----- Look if the index is in the list |
|
2680 | + for ($j=$j_start; |
|
2681 | + ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) |
|
2682 | 2682 | && (!$v_found); |
2683 | - $j++) { |
|
2684 | - if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) |
|
2683 | + $j++) { |
|
2684 | + if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) |
|
2685 | 2685 | && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { |
2686 | - $v_found = true; |
|
2687 | - } |
|
2688 | - if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
2689 | - $j_start = $j+1; |
|
2690 | - } |
|
2691 | - |
|
2692 | - if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { |
|
2693 | - break; |
|
2694 | - } |
|
2695 | - } |
|
2696 | - } |
|
2697 | - |
|
2698 | - // ----- Look for deletion |
|
2699 | - if ($v_found) { |
|
2700 | - unset($v_header_list[$v_nb_extracted]); |
|
2701 | - } else { |
|
2702 | - $v_nb_extracted++; |
|
2703 | - } |
|
2704 | - } |
|
2686 | + $v_found = true; |
|
2687 | + } |
|
2688 | + if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
2689 | + $j_start = $j+1; |
|
2690 | + } |
|
2691 | + |
|
2692 | + if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { |
|
2693 | + break; |
|
2694 | + } |
|
2695 | + } |
|
2696 | + } |
|
2697 | + |
|
2698 | + // ----- Look for deletion |
|
2699 | + if ($v_found) { |
|
2700 | + unset($v_header_list[$v_nb_extracted]); |
|
2701 | + } else { |
|
2702 | + $v_nb_extracted++; |
|
2703 | + } |
|
2704 | + } |
|
2705 | 2705 | |
2706 | 2706 | // ----- Look if something need to be deleted |
2707 | 2707 | if ($v_nb_extracted > 0) { |
2708 | 2708 | |
2709 | 2709 | // ----- Creates a temporay file |
2710 | 2710 | $v_zip_temp_name = ARCHIVE_ZIP_TEMPORARY_DIR.uniqid('archive_zip-') |
2711 | - .'.tmp'; |
|
2711 | + .'.tmp'; |
|
2712 | 2712 | |
2713 | 2713 | // ----- Creates a temporary zip archive |
2714 | 2714 | $v_temp_zip = new Archive_Zip($v_zip_temp_name); |
@@ -2733,7 +2733,7 @@ discard block |
||
2733 | 2733 | @unlink($v_zip_temp_name); |
2734 | 2734 | |
2735 | 2735 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, |
2736 | - 'Invalid archive size'); |
|
2736 | + 'Invalid archive size'); |
|
2737 | 2737 | return Archive_Zip::errorCode(); |
2738 | 2738 | } |
2739 | 2739 | |
@@ -2760,8 +2760,8 @@ discard block |
||
2760 | 2760 | |
2761 | 2761 | // ----- Read/write the data block |
2762 | 2762 | $v_result = $this->_tool_CopyBlock($this->_zip_fd, |
2763 | - $v_temp_zip->_zip_fd, |
|
2764 | - $v_header_list[$i]['compressed_size']); |
|
2763 | + $v_temp_zip->_zip_fd, |
|
2764 | + $v_header_list[$i]['compressed_size']); |
|
2765 | 2765 | if ($v_result != 1) { |
2766 | 2766 | // ----- Clean |
2767 | 2767 | $this->_closeFd(); |
@@ -2790,7 +2790,7 @@ discard block |
||
2790 | 2790 | |
2791 | 2791 | // ----- Transform the header to a 'usable' info |
2792 | 2792 | $v_temp_zip->_convertHeader2FileInfo($v_header_list[$i], |
2793 | - $p_result_list[$i]); |
|
2793 | + $p_result_list[$i]); |
|
2794 | 2794 | } |
2795 | 2795 | |
2796 | 2796 | |
@@ -2802,8 +2802,8 @@ discard block |
||
2802 | 2802 | |
2803 | 2803 | // ----- Create the central dir footer |
2804 | 2804 | $v_result = $v_temp_zip->_writeCentralHeader(count($v_header_list), |
2805 | - $v_size, $v_offset, |
|
2806 | - $v_comment); |
|
2805 | + $v_size, $v_offset, |
|
2806 | + $v_comment); |
|
2807 | 2807 | if ($v_result != 1) { |
2808 | 2808 | // ----- Clean |
2809 | 2809 | unset($v_header_list); |
@@ -2833,30 +2833,30 @@ discard block |
||
2833 | 2833 | |
2834 | 2834 | // ----- Return |
2835 | 2835 | return $v_result; |
2836 | - } |
|
2837 | - // --------------------------------------------------------------------------- |
|
2838 | - |
|
2839 | - // --------------------------------------------------------------------------- |
|
2840 | - // Function : _dirCheck() |
|
2841 | - // Description : |
|
2842 | - // Check if a directory exists, if not it creates it and all the parents directory |
|
2843 | - // which may be useful. |
|
2844 | - // Parameters : |
|
2845 | - // $p_dir : Directory path to check. |
|
2846 | - // Return Values : |
|
2847 | - // 1 : OK |
|
2848 | - // -1 : Unable to create directory |
|
2849 | - // --------------------------------------------------------------------------- |
|
2850 | - /** |
|
2851 | - * Archive_Zip::_dirCheck() |
|
2852 | - * |
|
2853 | - * { Description } |
|
2854 | - * |
|
2855 | - * @param [type] $p_is_dir |
|
2856 | - */ |
|
2857 | - public function _dirCheck($p_dir, $p_is_dir=false) |
|
2858 | - { |
|
2859 | - $v_result = 1; |
|
2836 | + } |
|
2837 | + // --------------------------------------------------------------------------- |
|
2838 | + |
|
2839 | + // --------------------------------------------------------------------------- |
|
2840 | + // Function : _dirCheck() |
|
2841 | + // Description : |
|
2842 | + // Check if a directory exists, if not it creates it and all the parents directory |
|
2843 | + // which may be useful. |
|
2844 | + // Parameters : |
|
2845 | + // $p_dir : Directory path to check. |
|
2846 | + // Return Values : |
|
2847 | + // 1 : OK |
|
2848 | + // -1 : Unable to create directory |
|
2849 | + // --------------------------------------------------------------------------- |
|
2850 | + /** |
|
2851 | + * Archive_Zip::_dirCheck() |
|
2852 | + * |
|
2853 | + * { Description } |
|
2854 | + * |
|
2855 | + * @param [type] $p_is_dir |
|
2856 | + */ |
|
2857 | + public function _dirCheck($p_dir, $p_is_dir=false) |
|
2858 | + { |
|
2859 | + $v_result = 1; |
|
2860 | 2860 | |
2861 | 2861 | // ----- Remove the final '/' |
2862 | 2862 | if ($p_is_dir && (substr($p_dir, -1) == '/')) { |
@@ -2874,52 +2874,52 @@ discard block |
||
2874 | 2874 | // ----- Just a check |
2875 | 2875 | if ($p_parent_dir != $p_dir) { |
2876 | 2876 | // ----- Look for parent directory |
2877 | - if ($p_parent_dir != '') { |
|
2878 | - if (($v_result = $this->_dirCheck($p_parent_dir)) != 1) { |
|
2879 | - return $v_result; |
|
2880 | - } |
|
2881 | - } |
|
2877 | + if ($p_parent_dir != '') { |
|
2878 | + if (($v_result = $this->_dirCheck($p_parent_dir)) != 1) { |
|
2879 | + return $v_result; |
|
2880 | + } |
|
2881 | + } |
|
2882 | 2882 | } |
2883 | 2883 | |
2884 | 2884 | // ----- Create the directory |
2885 | 2885 | if (!@mkdir($p_dir, 0777)) { |
2886 | 2886 | $this->_errorLog(ARCHIVE_ZIP_ERR_DIR_CREATE_FAIL, |
2887 | - "Unable to create directory '$p_dir'"); |
|
2887 | + "Unable to create directory '$p_dir'"); |
|
2888 | 2888 | return Archive_Zip::errorCode(); |
2889 | 2889 | } |
2890 | 2890 | |
2891 | 2891 | // ----- Return |
2892 | 2892 | return $v_result; |
2893 | - } |
|
2894 | - // --------------------------------------------------------------------------- |
|
2895 | - |
|
2896 | - // --------------------------------------------------------------------------- |
|
2897 | - // Function : _merge() |
|
2898 | - // Description : |
|
2899 | - // If $p_archive_to_add does not exist, the function exit with a success result. |
|
2900 | - // Parameters : |
|
2901 | - // Return Values : |
|
2902 | - // --------------------------------------------------------------------------- |
|
2903 | - /** |
|
2904 | - * Archive_Zip::_merge() |
|
2905 | - * |
|
2906 | - * { Description } |
|
2907 | - * |
|
2908 | - */ |
|
2909 | - public function _merge(&$p_archive_to_add) |
|
2910 | - { |
|
2911 | - $v_result=1; |
|
2893 | + } |
|
2894 | + // --------------------------------------------------------------------------- |
|
2895 | + |
|
2896 | + // --------------------------------------------------------------------------- |
|
2897 | + // Function : _merge() |
|
2898 | + // Description : |
|
2899 | + // If $p_archive_to_add does not exist, the function exit with a success result. |
|
2900 | + // Parameters : |
|
2901 | + // Return Values : |
|
2902 | + // --------------------------------------------------------------------------- |
|
2903 | + /** |
|
2904 | + * Archive_Zip::_merge() |
|
2905 | + * |
|
2906 | + * { Description } |
|
2907 | + * |
|
2908 | + */ |
|
2909 | + public function _merge(&$p_archive_to_add) |
|
2910 | + { |
|
2911 | + $v_result=1; |
|
2912 | 2912 | |
2913 | 2913 | // ----- Look if the archive_to_add exists |
2914 | 2914 | if (!is_file($p_archive_to_add->_zipname)) { |
2915 | 2915 | // ----- Nothing to merge, so merge is a success |
2916 | - return 1; |
|
2916 | + return 1; |
|
2917 | 2917 | } |
2918 | 2918 | |
2919 | 2919 | // ----- Look if the archive exists |
2920 | 2920 | if (!is_file($this->_zipname)) { |
2921 | 2921 | // ----- Do a duplicate |
2922 | - $v_result = $this->_duplicate($p_archive_to_add->_zipname); |
|
2922 | + $v_result = $this->_duplicate($p_archive_to_add->_zipname); |
|
2923 | 2923 | |
2924 | 2924 | return $v_result; |
2925 | 2925 | } |
@@ -2931,10 +2931,10 @@ discard block |
||
2931 | 2931 | |
2932 | 2932 | // ----- Read the central directory informations |
2933 | 2933 | $v_central_dir = array(); |
2934 | - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
2935 | - $this->_closeFd(); |
|
2936 | - return $v_result; |
|
2937 | - } |
|
2934 | + if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
2935 | + $this->_closeFd(); |
|
2936 | + return $v_result; |
|
2937 | + } |
|
2938 | 2938 | |
2939 | 2939 | // ----- Go to beginning of File |
2940 | 2940 | @rewind($this->_zip_fd); |
@@ -2947,12 +2947,12 @@ discard block |
||
2947 | 2947 | |
2948 | 2948 | // ----- Read the central directory informations |
2949 | 2949 | $v_central_dir_to_add = array(); |
2950 | - $v_result = $p_archive_to_add->_readEndCentralDir($v_central_dir_to_add); |
|
2951 | - if ($v_result != 1) { |
|
2952 | - $this->_closeFd(); |
|
2953 | - $p_archive_to_add->_closeFd(); |
|
2954 | - return $v_result; |
|
2955 | - } |
|
2950 | + $v_result = $p_archive_to_add->_readEndCentralDir($v_central_dir_to_add); |
|
2951 | + if ($v_result != 1) { |
|
2952 | + $this->_closeFd(); |
|
2953 | + $p_archive_to_add->_closeFd(); |
|
2954 | + return $v_result; |
|
2955 | + } |
|
2956 | 2956 | |
2957 | 2957 | // ----- Go to beginning of File |
2958 | 2958 | @rewind($p_archive_to_add->_zip_fd); |
@@ -2965,8 +2965,8 @@ discard block |
||
2965 | 2965 | $this->_closeFd(); |
2966 | 2966 | $p_archive_to_add->_closeFd(); |
2967 | 2967 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
2968 | - 'Unable to open temporary file \'' |
|
2969 | - .$v_zip_temp_name.'\' in binary write mode'); |
|
2968 | + 'Unable to open temporary file \'' |
|
2969 | + .$v_zip_temp_name.'\' in binary write mode'); |
|
2970 | 2970 | return Archive_Zip::errorCode(); |
2971 | 2971 | } |
2972 | 2972 | |
@@ -2974,46 +2974,46 @@ discard block |
||
2974 | 2974 | // TBC : Here I should better append the file and go back to erase the |
2975 | 2975 | // central dir |
2976 | 2976 | $v_size = $v_central_dir['offset']; |
2977 | - while ($v_size != 0) { |
|
2978 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
2977 | + while ($v_size != 0) { |
|
2978 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
2979 | 2979 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
2980 | - $v_buffer = fread($this->_zip_fd, $v_read_size); |
|
2981 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
2982 | - $v_size -= $v_read_size; |
|
2983 | - } |
|
2980 | + $v_buffer = fread($this->_zip_fd, $v_read_size); |
|
2981 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
2982 | + $v_size -= $v_read_size; |
|
2983 | + } |
|
2984 | 2984 | |
2985 | 2985 | // ----- Copy the files from the archive_to_add into the temporary file |
2986 | 2986 | $v_size = $v_central_dir_to_add['offset']; |
2987 | - while ($v_size != 0) { |
|
2988 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
2987 | + while ($v_size != 0) { |
|
2988 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
2989 | 2989 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
2990 | - $v_buffer = fread($p_archive_to_add->_zip_fd, $v_read_size); |
|
2991 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
2992 | - $v_size -= $v_read_size; |
|
2993 | - } |
|
2990 | + $v_buffer = fread($p_archive_to_add->_zip_fd, $v_read_size); |
|
2991 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
2992 | + $v_size -= $v_read_size; |
|
2993 | + } |
|
2994 | 2994 | |
2995 | 2995 | // ----- Store the offset of the central dir |
2996 | 2996 | $v_offset = @ftell($v_zip_temp_fd); |
2997 | 2997 | |
2998 | 2998 | // ----- Copy the block of file headers from the old archive |
2999 | 2999 | $v_size = $v_central_dir['size']; |
3000 | - while ($v_size != 0) { |
|
3001 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3000 | + while ($v_size != 0) { |
|
3001 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3002 | 3002 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
3003 | - $v_buffer = @fread($this->_zip_fd, $v_read_size); |
|
3004 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
3005 | - $v_size -= $v_read_size; |
|
3006 | - } |
|
3003 | + $v_buffer = @fread($this->_zip_fd, $v_read_size); |
|
3004 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
3005 | + $v_size -= $v_read_size; |
|
3006 | + } |
|
3007 | 3007 | |
3008 | 3008 | // ----- Copy the block of file headers from the archive_to_add |
3009 | 3009 | $v_size = $v_central_dir_to_add['size']; |
3010 | - while ($v_size != 0) { |
|
3011 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3010 | + while ($v_size != 0) { |
|
3011 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3012 | 3012 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
3013 | - $v_buffer = @fread($p_archive_to_add->_zip_fd, $v_read_size); |
|
3014 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
3015 | - $v_size -= $v_read_size; |
|
3016 | - } |
|
3013 | + $v_buffer = @fread($p_archive_to_add->_zip_fd, $v_read_size); |
|
3014 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
3015 | + $v_size -= $v_read_size; |
|
3016 | + } |
|
3017 | 3017 | |
3018 | 3018 | // ----- Zip file comment |
3019 | 3019 | // TBC : I should merge the two comments |
@@ -3026,8 +3026,8 @@ discard block |
||
3026 | 3026 | // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
3027 | 3027 | // the following methods on the temporary fil and not the real archive fd |
3028 | 3028 | $v_swap = $this->_zip_fd; |
3029 | - $this->_zip_fd = $v_zip_temp_fd; |
|
3030 | - $v_zip_temp_fd = $v_swap; |
|
3029 | + $this->_zip_fd = $v_zip_temp_fd; |
|
3030 | + $v_zip_temp_fd = $v_swap; |
|
3031 | 3031 | |
3032 | 3032 | // ----- Create the central dir footer |
3033 | 3033 | if (($v_result = $this->_writeCentralHeader($v_central_dir['entries'] |
@@ -3039,21 +3039,21 @@ discard block |
||
3039 | 3039 | @fclose($v_zip_temp_fd); |
3040 | 3040 | $this->_zip_fd = null; |
3041 | 3041 | |
3042 | - // ----- Reset the file list |
|
3043 | - unset($v_header_list); |
|
3042 | + // ----- Reset the file list |
|
3043 | + unset($v_header_list); |
|
3044 | 3044 | |
3045 | - // ----- Return |
|
3046 | - return $v_result; |
|
3045 | + // ----- Return |
|
3046 | + return $v_result; |
|
3047 | 3047 | } |
3048 | 3048 | |
3049 | 3049 | // ----- Swap back the file descriptor |
3050 | 3050 | $v_swap = $this->_zip_fd; |
3051 | - $this->_zip_fd = $v_zip_temp_fd; |
|
3052 | - $v_zip_temp_fd = $v_swap; |
|
3051 | + $this->_zip_fd = $v_zip_temp_fd; |
|
3052 | + $v_zip_temp_fd = $v_swap; |
|
3053 | 3053 | |
3054 | 3054 | // ----- Close |
3055 | 3055 | $this->_closeFd(); |
3056 | - $p_archive_to_add->_closeFd(); |
|
3056 | + $p_archive_to_add->_closeFd(); |
|
3057 | 3057 | |
3058 | 3058 | // ----- Close the temporary file |
3059 | 3059 | @fclose($v_zip_temp_fd); |
@@ -3069,47 +3069,47 @@ discard block |
||
3069 | 3069 | |
3070 | 3070 | // ----- Return |
3071 | 3071 | return $v_result; |
3072 | - } |
|
3073 | - // --------------------------------------------------------------------------- |
|
3074 | - |
|
3075 | - // --------------------------------------------------------------------------- |
|
3076 | - // Function : _duplicate() |
|
3077 | - // Description : |
|
3078 | - // Parameters : |
|
3079 | - // Return Values : |
|
3080 | - // --------------------------------------------------------------------------- |
|
3081 | - /** |
|
3082 | - * Archive_Zip::_duplicate() |
|
3083 | - * |
|
3084 | - * { Description } |
|
3085 | - * |
|
3086 | - */ |
|
3087 | - public function _duplicate($p_archive_filename) |
|
3088 | - { |
|
3089 | - $v_result=1; |
|
3072 | + } |
|
3073 | + // --------------------------------------------------------------------------- |
|
3074 | + |
|
3075 | + // --------------------------------------------------------------------------- |
|
3076 | + // Function : _duplicate() |
|
3077 | + // Description : |
|
3078 | + // Parameters : |
|
3079 | + // Return Values : |
|
3080 | + // --------------------------------------------------------------------------- |
|
3081 | + /** |
|
3082 | + * Archive_Zip::_duplicate() |
|
3083 | + * |
|
3084 | + * { Description } |
|
3085 | + * |
|
3086 | + */ |
|
3087 | + public function _duplicate($p_archive_filename) |
|
3088 | + { |
|
3089 | + $v_result=1; |
|
3090 | 3090 | |
3091 | 3091 | // ----- Look if the $p_archive_filename exists |
3092 | 3092 | if (!is_file($p_archive_filename)) { |
3093 | 3093 | |
3094 | - // ----- Nothing to duplicate, so duplicate is a success. |
|
3095 | - $v_result = 1; |
|
3094 | + // ----- Nothing to duplicate, so duplicate is a success. |
|
3095 | + $v_result = 1; |
|
3096 | 3096 | |
3097 | - // ----- Return |
|
3098 | - return $v_result; |
|
3097 | + // ----- Return |
|
3098 | + return $v_result; |
|
3099 | 3099 | } |
3100 | 3100 | |
3101 | 3101 | // ----- Open the zip file |
3102 | 3102 | if (($v_result=$this->_openFd('wb')) != 1) { |
3103 | 3103 | // ----- Return |
3104 | - return $v_result; |
|
3104 | + return $v_result; |
|
3105 | 3105 | } |
3106 | 3106 | |
3107 | 3107 | // ----- Open the temporary file in write mode |
3108 | 3108 | if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) { |
3109 | 3109 | $this->_closeFd(); |
3110 | 3110 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
3111 | - 'Unable to open archive file \'' |
|
3112 | - .$p_archive_filename.'\' in binary write mode'); |
|
3111 | + 'Unable to open archive file \'' |
|
3112 | + .$p_archive_filename.'\' in binary write mode'); |
|
3113 | 3113 | return Archive_Zip::errorCode(); |
3114 | 3114 | } |
3115 | 3115 | |
@@ -3117,13 +3117,13 @@ discard block |
||
3117 | 3117 | // TBC : Here I should better append the file and go back to erase the |
3118 | 3118 | // central dir |
3119 | 3119 | $v_size = filesize($p_archive_filename); |
3120 | - while ($v_size != 0) { |
|
3121 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3120 | + while ($v_size != 0) { |
|
3121 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3122 | 3122 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
3123 | - $v_buffer = fread($v_zip_temp_fd, $v_read_size); |
|
3124 | - @fwrite($this->_zip_fd, $v_buffer, $v_read_size); |
|
3125 | - $v_size -= $v_read_size; |
|
3126 | - } |
|
3123 | + $v_buffer = fread($v_zip_temp_fd, $v_read_size); |
|
3124 | + @fwrite($this->_zip_fd, $v_buffer, $v_read_size); |
|
3125 | + $v_size -= $v_read_size; |
|
3126 | + } |
|
3127 | 3127 | |
3128 | 3128 | // ----- Close |
3129 | 3129 | $this->_closeFd(); |
@@ -3131,25 +3131,25 @@ discard block |
||
3131 | 3131 | // ----- Close the temporary file |
3132 | 3132 | @fclose($v_zip_temp_fd); |
3133 | 3133 | |
3134 | - return $v_result; |
|
3135 | - } |
|
3136 | - // --------------------------------------------------------------------------- |
|
3137 | - |
|
3138 | - /** |
|
3139 | - * Archive_Zip::_check_parameters() |
|
3140 | - * |
|
3141 | - * { Description } |
|
3142 | - * |
|
3143 | - * @param integer $p_error_code |
|
3144 | - * @param string $p_error_string |
|
3145 | - */ |
|
3146 | - public function _check_parameters(&$p_params, $p_default) |
|
3147 | - { |
|
3134 | + return $v_result; |
|
3135 | + } |
|
3136 | + // --------------------------------------------------------------------------- |
|
3137 | + |
|
3138 | + /** |
|
3139 | + * Archive_Zip::_check_parameters() |
|
3140 | + * |
|
3141 | + * { Description } |
|
3142 | + * |
|
3143 | + * @param integer $p_error_code |
|
3144 | + * @param string $p_error_string |
|
3145 | + */ |
|
3146 | + public function _check_parameters(&$p_params, $p_default) |
|
3147 | + { |
|
3148 | 3148 | |
3149 | 3149 | // ----- Check that param is an array |
3150 | 3150 | if (!is_array($p_params)) { |
3151 | 3151 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
3152 | - 'Unsupported parameter, waiting for an array'); |
|
3152 | + 'Unsupported parameter, waiting for an array'); |
|
3153 | 3153 | return Archive_Zip::errorCode(); |
3154 | 3154 | } |
3155 | 3155 | |
@@ -3157,7 +3157,7 @@ discard block |
||
3157 | 3157 | for (reset($p_params); list($v_key, $v_value) = each($p_params);) { |
3158 | 3158 | if (!isset($p_default[$v_key])) { |
3159 | 3159 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
3160 | - 'Unsupported parameter with key \''.$v_key.'\''); |
|
3160 | + 'Unsupported parameter with key \''.$v_key.'\''); |
|
3161 | 3161 | |
3162 | 3162 | return Archive_Zip::errorCode(); |
3163 | 3163 | } |
@@ -3172,170 +3172,170 @@ discard block |
||
3172 | 3172 | |
3173 | 3173 | // ----- Check specific parameters |
3174 | 3174 | $v_callback_list = array('callback_pre_add', 'callback_post_add', |
3175 | - 'callback_pre_extract', 'callback_post_extract'); |
|
3176 | - for ($i=0; $i < count($v_callback_list); $i++) { |
|
3177 | - $v_key=$v_callback_list[$i]; |
|
3178 | - if (isset($p_params[$v_key]) && ($p_params[$v_key] != '')) { |
|
3179 | - if (!function_exists($p_params[$v_key])) { |
|
3180 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE, |
|
3181 | - "Callback '".$p_params[$v_key] |
|
3182 | - ."()' is not an existing function for " |
|
3183 | - ."parameter '".$v_key."'"); |
|
3184 | - return Archive_Zip::errorCode(); |
|
3185 | - } |
|
3186 | - } |
|
3187 | - } |
|
3188 | - |
|
3189 | - return 1; |
|
3190 | - } |
|
3191 | - // --------------------------------------------------------------------------- |
|
3192 | - |
|
3193 | - // --------------------------------------------------------------------------- |
|
3194 | - // Function : _errorLog() |
|
3195 | - // Description : |
|
3196 | - // Parameters : |
|
3197 | - // --------------------------------------------------------------------------- |
|
3198 | - /** |
|
3199 | - * Archive_Zip::_errorLog() |
|
3200 | - * |
|
3201 | - * { Description } |
|
3202 | - * |
|
3203 | - * @param integer $p_error_code |
|
3204 | - * @param string $p_error_string |
|
3205 | - */ |
|
3206 | - public function _errorLog($p_error_code=0, $p_error_string='') |
|
3207 | - { |
|
3208 | - $this->_error_code = $p_error_code; |
|
3209 | - $this->_error_string = $p_error_string; |
|
3210 | - } |
|
3211 | - // --------------------------------------------------------------------------- |
|
3212 | - |
|
3213 | - // --------------------------------------------------------------------------- |
|
3214 | - // Function : _errorReset() |
|
3215 | - // Description : |
|
3216 | - // Parameters : |
|
3217 | - // --------------------------------------------------------------------------- |
|
3218 | - /** |
|
3219 | - * Archive_Zip::_errorReset() |
|
3220 | - * |
|
3221 | - * { Description } |
|
3222 | - * |
|
3223 | - */ |
|
3224 | - public function _errorReset() |
|
3225 | - { |
|
3226 | - $this->_error_code = 1; |
|
3227 | - $this->_error_string = ''; |
|
3228 | - } |
|
3229 | - // --------------------------------------------------------------------------- |
|
3230 | - |
|
3231 | - // --------------------------------------------------------------------------- |
|
3232 | - // Function : $this->_tool_PathReduction() |
|
3233 | - // Description : |
|
3234 | - // Parameters : |
|
3235 | - // Return Values : |
|
3236 | - // --------------------------------------------------------------------------- |
|
3237 | - /** |
|
3238 | - * _tool_PathReduction() |
|
3239 | - * |
|
3240 | - * { Description } |
|
3241 | - * |
|
3242 | - */ |
|
3243 | - public function _tool_PathReduction($p_dir) |
|
3244 | - { |
|
3245 | - $v_result = ''; |
|
3175 | + 'callback_pre_extract', 'callback_post_extract'); |
|
3176 | + for ($i=0; $i < count($v_callback_list); $i++) { |
|
3177 | + $v_key=$v_callback_list[$i]; |
|
3178 | + if (isset($p_params[$v_key]) && ($p_params[$v_key] != '')) { |
|
3179 | + if (!function_exists($p_params[$v_key])) { |
|
3180 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE, |
|
3181 | + "Callback '".$p_params[$v_key] |
|
3182 | + ."()' is not an existing function for " |
|
3183 | + ."parameter '".$v_key."'"); |
|
3184 | + return Archive_Zip::errorCode(); |
|
3185 | + } |
|
3186 | + } |
|
3187 | + } |
|
3188 | + |
|
3189 | + return 1; |
|
3190 | + } |
|
3191 | + // --------------------------------------------------------------------------- |
|
3192 | + |
|
3193 | + // --------------------------------------------------------------------------- |
|
3194 | + // Function : _errorLog() |
|
3195 | + // Description : |
|
3196 | + // Parameters : |
|
3197 | + // --------------------------------------------------------------------------- |
|
3198 | + /** |
|
3199 | + * Archive_Zip::_errorLog() |
|
3200 | + * |
|
3201 | + * { Description } |
|
3202 | + * |
|
3203 | + * @param integer $p_error_code |
|
3204 | + * @param string $p_error_string |
|
3205 | + */ |
|
3206 | + public function _errorLog($p_error_code=0, $p_error_string='') |
|
3207 | + { |
|
3208 | + $this->_error_code = $p_error_code; |
|
3209 | + $this->_error_string = $p_error_string; |
|
3210 | + } |
|
3211 | + // --------------------------------------------------------------------------- |
|
3212 | + |
|
3213 | + // --------------------------------------------------------------------------- |
|
3214 | + // Function : _errorReset() |
|
3215 | + // Description : |
|
3216 | + // Parameters : |
|
3217 | + // --------------------------------------------------------------------------- |
|
3218 | + /** |
|
3219 | + * Archive_Zip::_errorReset() |
|
3220 | + * |
|
3221 | + * { Description } |
|
3222 | + * |
|
3223 | + */ |
|
3224 | + public function _errorReset() |
|
3225 | + { |
|
3226 | + $this->_error_code = 1; |
|
3227 | + $this->_error_string = ''; |
|
3228 | + } |
|
3229 | + // --------------------------------------------------------------------------- |
|
3230 | + |
|
3231 | + // --------------------------------------------------------------------------- |
|
3232 | + // Function : $this->_tool_PathReduction() |
|
3233 | + // Description : |
|
3234 | + // Parameters : |
|
3235 | + // Return Values : |
|
3236 | + // --------------------------------------------------------------------------- |
|
3237 | + /** |
|
3238 | + * _tool_PathReduction() |
|
3239 | + * |
|
3240 | + * { Description } |
|
3241 | + * |
|
3242 | + */ |
|
3243 | + public function _tool_PathReduction($p_dir) |
|
3244 | + { |
|
3245 | + $v_result = ''; |
|
3246 | 3246 | |
3247 | 3247 | // ----- Look for not empty path |
3248 | 3248 | if ($p_dir != '') { |
3249 | 3249 | // ----- Explode path by directory names |
3250 | - $v_list = explode('/', $p_dir); |
|
3250 | + $v_list = explode('/', $p_dir); |
|
3251 | 3251 | |
3252 | - // ----- Study directories from last to first |
|
3253 | - for ($i= count($v_list) - 1; $i >= 0; $i--) { |
|
3254 | - // ----- Look for current path |
|
3252 | + // ----- Study directories from last to first |
|
3253 | + for ($i= count($v_list) - 1; $i >= 0; $i--) { |
|
3254 | + // ----- Look for current path |
|
3255 | 3255 | if ($v_list[$i] == '.') { |
3256 | 3256 | // ----- Ignore this directory |
3257 | - // Should be the first $i=0, but no check is done |
|
3257 | + // Should be the first $i=0, but no check is done |
|
3258 | 3258 | } elseif ($v_list[$i] == '..') { |
3259 | 3259 | // ----- Ignore it and ignore the $i-1 |
3260 | - $i--; |
|
3260 | + $i--; |
|
3261 | 3261 | } elseif (($v_list[$i] == '') && ($i != (count($v_list) - 1)) && ($i != 0)) { |
3262 | 3262 | // ----- Ignore only the double '//' in path, |
3263 | - // but not the first and last '/' |
|
3263 | + // but not the first and last '/' |
|
3264 | 3264 | } else { |
3265 | 3265 | $v_result = $v_list[$i].($i!=(count($v_list) - 1)? '/' . $v_result: ''); |
3266 | 3266 | } |
3267 | - } |
|
3267 | + } |
|
3268 | 3268 | } |
3269 | 3269 | |
3270 | 3270 | // ----- Return |
3271 | 3271 | return $v_result; |
3272 | - } |
|
3273 | - // --------------------------------------------------------------------------- |
|
3274 | - |
|
3275 | - // --------------------------------------------------------------------------- |
|
3276 | - // Function : $this->_tool_PathInclusion() |
|
3277 | - // Description : |
|
3278 | - // This function indicates if the path $p_path is under the $p_dir tree. Or, |
|
3279 | - // said in an other way, if the file or sub-dir $p_path is inside the dir |
|
3280 | - // $p_dir. |
|
3281 | - // The function indicates also if the path is exactly the same as the dir. |
|
3282 | - // This function supports path with duplicated '/' like '//', but does not |
|
3283 | - // support '.' or '..' statements. |
|
3284 | - // Parameters : |
|
3285 | - // Return Values : |
|
3286 | - // 0 if $p_path is not inside directory $p_dir |
|
3287 | - // 1 if $p_path is inside directory $p_dir |
|
3288 | - // 2 if $p_path is exactly the same as $p_dir |
|
3289 | - // --------------------------------------------------------------------------- |
|
3290 | - /** |
|
3291 | - * _tool_PathInclusion() |
|
3292 | - * |
|
3293 | - * { Description } |
|
3294 | - * |
|
3295 | - */ |
|
3296 | - public function _tool_PathInclusion($p_dir, $p_path) |
|
3297 | - { |
|
3298 | - $v_result = 1; |
|
3272 | + } |
|
3273 | + // --------------------------------------------------------------------------- |
|
3274 | + |
|
3275 | + // --------------------------------------------------------------------------- |
|
3276 | + // Function : $this->_tool_PathInclusion() |
|
3277 | + // Description : |
|
3278 | + // This function indicates if the path $p_path is under the $p_dir tree. Or, |
|
3279 | + // said in an other way, if the file or sub-dir $p_path is inside the dir |
|
3280 | + // $p_dir. |
|
3281 | + // The function indicates also if the path is exactly the same as the dir. |
|
3282 | + // This function supports path with duplicated '/' like '//', but does not |
|
3283 | + // support '.' or '..' statements. |
|
3284 | + // Parameters : |
|
3285 | + // Return Values : |
|
3286 | + // 0 if $p_path is not inside directory $p_dir |
|
3287 | + // 1 if $p_path is inside directory $p_dir |
|
3288 | + // 2 if $p_path is exactly the same as $p_dir |
|
3289 | + // --------------------------------------------------------------------------- |
|
3290 | + /** |
|
3291 | + * _tool_PathInclusion() |
|
3292 | + * |
|
3293 | + * { Description } |
|
3294 | + * |
|
3295 | + */ |
|
3296 | + public function _tool_PathInclusion($p_dir, $p_path) |
|
3297 | + { |
|
3298 | + $v_result = 1; |
|
3299 | 3299 | |
3300 | 3300 | // ----- Explode dir and path by directory separator |
3301 | 3301 | $v_list_dir = explode('/', $p_dir); |
3302 | - $v_list_dir_size = count($v_list_dir); |
|
3303 | - $v_list_path = explode('/', $p_path); |
|
3304 | - $v_list_path_size = count($v_list_path); |
|
3302 | + $v_list_dir_size = count($v_list_dir); |
|
3303 | + $v_list_path = explode('/', $p_path); |
|
3304 | + $v_list_path_size = count($v_list_path); |
|
3305 | 3305 | |
3306 | 3306 | // ----- Study directories paths |
3307 | 3307 | $i = 0; |
3308 | - $j = 0; |
|
3309 | - while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && $v_result) { |
|
3310 | - |
|
3311 | - // ----- Look for empty dir (path reduction) |
|
3312 | - if ($v_list_dir[$i] == '') { |
|
3313 | - $i++; |
|
3314 | - continue; |
|
3315 | - } |
|
3316 | - if ($v_list_path[$j] == '') { |
|
3317 | - $j++; |
|
3318 | - continue; |
|
3319 | - } |
|
3320 | - |
|
3321 | - // ----- Compare the items |
|
3322 | - if (($v_list_dir[$i] != $v_list_path[$j]) |
|
3308 | + $j = 0; |
|
3309 | + while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && $v_result) { |
|
3310 | + |
|
3311 | + // ----- Look for empty dir (path reduction) |
|
3312 | + if ($v_list_dir[$i] == '') { |
|
3313 | + $i++; |
|
3314 | + continue; |
|
3315 | + } |
|
3316 | + if ($v_list_path[$j] == '') { |
|
3317 | + $j++; |
|
3318 | + continue; |
|
3319 | + } |
|
3320 | + |
|
3321 | + // ----- Compare the items |
|
3322 | + if (($v_list_dir[$i] != $v_list_path[$j]) |
|
3323 | 3323 | && ($v_list_dir[$i] != '') |
3324 | 3324 | && ($v_list_path[$j] != '')) { |
3325 | - $v_result = 0; |
|
3326 | - } |
|
3325 | + $v_result = 0; |
|
3326 | + } |
|
3327 | 3327 | |
3328 | - // ----- Next items |
|
3329 | - $i++; |
|
3330 | - $j++; |
|
3331 | - } |
|
3328 | + // ----- Next items |
|
3329 | + $i++; |
|
3330 | + $j++; |
|
3331 | + } |
|
3332 | 3332 | |
3333 | 3333 | // ----- Look if everything seems to be the same |
3334 | 3334 | if ($v_result) { |
3335 | 3335 | // ----- Skip all the empty items |
3336 | - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) { |
|
3337 | - $j++; |
|
3338 | - } |
|
3336 | + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) { |
|
3337 | + $j++; |
|
3338 | + } |
|
3339 | 3339 | while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) { |
3340 | 3340 | $i++; |
3341 | 3341 | } |
@@ -3351,142 +3351,142 @@ discard block |
||
3351 | 3351 | |
3352 | 3352 | // ----- Return |
3353 | 3353 | return $v_result; |
3354 | - } |
|
3355 | - // --------------------------------------------------------------------------- |
|
3356 | - |
|
3357 | - // --------------------------------------------------------------------------- |
|
3358 | - // Function : $this->_tool_CopyBlock() |
|
3359 | - // Description : |
|
3360 | - // Parameters : |
|
3361 | - // $p_mode : read/write compression mode |
|
3362 | - // 0 : src & dest normal |
|
3363 | - // 1 : src gzip, dest normal |
|
3364 | - // 2 : src normal, dest gzip |
|
3365 | - // 3 : src & dest gzip |
|
3366 | - // Return Values : |
|
3367 | - // --------------------------------------------------------------------------- |
|
3368 | - /** |
|
3369 | - * _tool_CopyBlock() |
|
3370 | - * |
|
3371 | - * { Description } |
|
3372 | - * |
|
3373 | - * @param integer $p_mode |
|
3374 | - */ |
|
3375 | - public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
|
3376 | - { |
|
3377 | - $v_result = 1; |
|
3378 | - |
|
3379 | - if ($p_mode==0) { |
|
3380 | - while ($p_size != 0) { |
|
3381 | - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3354 | + } |
|
3355 | + // --------------------------------------------------------------------------- |
|
3356 | + |
|
3357 | + // --------------------------------------------------------------------------- |
|
3358 | + // Function : $this->_tool_CopyBlock() |
|
3359 | + // Description : |
|
3360 | + // Parameters : |
|
3361 | + // $p_mode : read/write compression mode |
|
3362 | + // 0 : src & dest normal |
|
3363 | + // 1 : src gzip, dest normal |
|
3364 | + // 2 : src normal, dest gzip |
|
3365 | + // 3 : src & dest gzip |
|
3366 | + // Return Values : |
|
3367 | + // --------------------------------------------------------------------------- |
|
3368 | + /** |
|
3369 | + * _tool_CopyBlock() |
|
3370 | + * |
|
3371 | + * { Description } |
|
3372 | + * |
|
3373 | + * @param integer $p_mode |
|
3374 | + */ |
|
3375 | + public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
|
3376 | + { |
|
3377 | + $v_result = 1; |
|
3378 | + |
|
3379 | + if ($p_mode==0) { |
|
3380 | + while ($p_size != 0) { |
|
3381 | + $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3382 | 3382 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
3383 | - $v_buffer = @fread($p_src, $v_read_size); |
|
3384 | - @fwrite($p_dest, $v_buffer, $v_read_size); |
|
3385 | - $p_size -= $v_read_size; |
|
3386 | - } |
|
3387 | - } elseif ($p_mode==1) { |
|
3388 | - while ($p_size != 0) { |
|
3389 | - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3383 | + $v_buffer = @fread($p_src, $v_read_size); |
|
3384 | + @fwrite($p_dest, $v_buffer, $v_read_size); |
|
3385 | + $p_size -= $v_read_size; |
|
3386 | + } |
|
3387 | + } elseif ($p_mode==1) { |
|
3388 | + while ($p_size != 0) { |
|
3389 | + $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3390 | 3390 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
3391 | - $v_buffer = @gzread($p_src, $v_read_size); |
|
3392 | - @fwrite($p_dest, $v_buffer, $v_read_size); |
|
3393 | - $p_size -= $v_read_size; |
|
3394 | - } |
|
3395 | - } elseif ($p_mode==2) { |
|
3396 | - while ($p_size != 0) { |
|
3397 | - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3391 | + $v_buffer = @gzread($p_src, $v_read_size); |
|
3392 | + @fwrite($p_dest, $v_buffer, $v_read_size); |
|
3393 | + $p_size -= $v_read_size; |
|
3394 | + } |
|
3395 | + } elseif ($p_mode==2) { |
|
3396 | + while ($p_size != 0) { |
|
3397 | + $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3398 | 3398 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
3399 | - $v_buffer = @fread($p_src, $v_read_size); |
|
3400 | - @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
3401 | - $p_size -= $v_read_size; |
|
3402 | - } |
|
3403 | - } elseif ($p_mode==3) { |
|
3404 | - while ($p_size != 0) { |
|
3405 | - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3399 | + $v_buffer = @fread($p_src, $v_read_size); |
|
3400 | + @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
3401 | + $p_size -= $v_read_size; |
|
3402 | + } |
|
3403 | + } elseif ($p_mode==3) { |
|
3404 | + while ($p_size != 0) { |
|
3405 | + $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
3406 | 3406 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
3407 | - $v_buffer = @gzread($p_src, $v_read_size); |
|
3408 | - @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
3409 | - $p_size -= $v_read_size; |
|
3410 | - } |
|
3411 | - } |
|
3407 | + $v_buffer = @gzread($p_src, $v_read_size); |
|
3408 | + @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
3409 | + $p_size -= $v_read_size; |
|
3410 | + } |
|
3411 | + } |
|
3412 | 3412 | |
3413 | 3413 | // ----- Return |
3414 | 3414 | return $v_result; |
3415 | - } |
|
3416 | - // --------------------------------------------------------------------------- |
|
3417 | - |
|
3418 | - // --------------------------------------------------------------------------- |
|
3419 | - // Function : $this->_tool_Rename() |
|
3420 | - // Description : |
|
3421 | - // This function tries to do a simple rename() function. If it fails, it |
|
3422 | - // tries to copy the $p_src file in a new $p_dest file and then unlink the |
|
3423 | - // first one. |
|
3424 | - // Parameters : |
|
3425 | - // $p_src : Old filename |
|
3426 | - // $p_dest : New filename |
|
3427 | - // Return Values : |
|
3428 | - // 1 on success, 0 on failure. |
|
3429 | - // --------------------------------------------------------------------------- |
|
3430 | - /** |
|
3431 | - * _tool_Rename() |
|
3432 | - * |
|
3433 | - * { Description } |
|
3434 | - * |
|
3435 | - */ |
|
3436 | - public function _tool_Rename($p_src, $p_dest) |
|
3437 | - { |
|
3438 | - $v_result = 1; |
|
3415 | + } |
|
3416 | + // --------------------------------------------------------------------------- |
|
3417 | + |
|
3418 | + // --------------------------------------------------------------------------- |
|
3419 | + // Function : $this->_tool_Rename() |
|
3420 | + // Description : |
|
3421 | + // This function tries to do a simple rename() function. If it fails, it |
|
3422 | + // tries to copy the $p_src file in a new $p_dest file and then unlink the |
|
3423 | + // first one. |
|
3424 | + // Parameters : |
|
3425 | + // $p_src : Old filename |
|
3426 | + // $p_dest : New filename |
|
3427 | + // Return Values : |
|
3428 | + // 1 on success, 0 on failure. |
|
3429 | + // --------------------------------------------------------------------------- |
|
3430 | + /** |
|
3431 | + * _tool_Rename() |
|
3432 | + * |
|
3433 | + * { Description } |
|
3434 | + * |
|
3435 | + */ |
|
3436 | + public function _tool_Rename($p_src, $p_dest) |
|
3437 | + { |
|
3438 | + $v_result = 1; |
|
3439 | 3439 | |
3440 | 3440 | // ----- Try to rename the files |
3441 | 3441 | if (!@rename($p_src, $p_dest)) { |
3442 | 3442 | |
3443 | - // ----- Try to copy & unlink the src |
|
3444 | - if (!@copy($p_src, $p_dest)) { |
|
3445 | - $v_result = 0; |
|
3446 | - } elseif (!@unlink($p_src)) { |
|
3447 | - $v_result = 0; |
|
3448 | - } |
|
3443 | + // ----- Try to copy & unlink the src |
|
3444 | + if (!@copy($p_src, $p_dest)) { |
|
3445 | + $v_result = 0; |
|
3446 | + } elseif (!@unlink($p_src)) { |
|
3447 | + $v_result = 0; |
|
3448 | + } |
|
3449 | 3449 | } |
3450 | 3450 | |
3451 | 3451 | // ----- Return |
3452 | 3452 | return $v_result; |
3453 | - } |
|
3454 | - // --------------------------------------------------------------------------- |
|
3455 | - |
|
3456 | - // --------------------------------------------------------------------------- |
|
3457 | - // Function : $this->_tool_TranslateWinPath() |
|
3458 | - // Description : |
|
3459 | - // Translate windows path by replacing '\' by '/' and optionally removing |
|
3460 | - // drive letter. |
|
3461 | - // Parameters : |
|
3462 | - // $p_path : path to translate. |
|
3463 | - // $p_remove_disk_letter : true | false |
|
3464 | - // Return Values : |
|
3465 | - // The path translated. |
|
3466 | - // --------------------------------------------------------------------------- |
|
3467 | - /** |
|
3468 | - * _tool_TranslateWinPath() |
|
3469 | - * |
|
3470 | - * { Description } |
|
3471 | - * |
|
3472 | - * @param [type] $p_remove_disk_letter |
|
3473 | - */ |
|
3474 | - public function _tool_TranslateWinPath($p_path, $p_remove_disk_letter=true) |
|
3475 | - { |
|
3476 | - if (stristr(php_uname(), 'windows')) { |
|
3477 | - // ----- Look for potential disk letter |
|
3478 | - if ($p_remove_disk_letter |
|
3453 | + } |
|
3454 | + // --------------------------------------------------------------------------- |
|
3455 | + |
|
3456 | + // --------------------------------------------------------------------------- |
|
3457 | + // Function : $this->_tool_TranslateWinPath() |
|
3458 | + // Description : |
|
3459 | + // Translate windows path by replacing '\' by '/' and optionally removing |
|
3460 | + // drive letter. |
|
3461 | + // Parameters : |
|
3462 | + // $p_path : path to translate. |
|
3463 | + // $p_remove_disk_letter : true | false |
|
3464 | + // Return Values : |
|
3465 | + // The path translated. |
|
3466 | + // --------------------------------------------------------------------------- |
|
3467 | + /** |
|
3468 | + * _tool_TranslateWinPath() |
|
3469 | + * |
|
3470 | + * { Description } |
|
3471 | + * |
|
3472 | + * @param [type] $p_remove_disk_letter |
|
3473 | + */ |
|
3474 | + public function _tool_TranslateWinPath($p_path, $p_remove_disk_letter=true) |
|
3475 | + { |
|
3476 | + if (stristr(php_uname(), 'windows')) { |
|
3477 | + // ----- Look for potential disk letter |
|
3478 | + if ($p_remove_disk_letter |
|
3479 | 3479 | && (($v_position = strpos($p_path, ':')) != false)) { |
3480 | - $p_path = substr($p_path, $v_position+1); |
|
3481 | - } |
|
3482 | - // ----- Change potential windows directory separator |
|
3483 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { |
|
3484 | - $p_path = strtr($p_path, '\\', '/'); |
|
3485 | - } |
|
3486 | - } |
|
3487 | - return $p_path; |
|
3488 | - } |
|
3489 | - // --------------------------------------------------------------------------- |
|
3480 | + $p_path = substr($p_path, $v_position+1); |
|
3481 | + } |
|
3482 | + // ----- Change potential windows directory separator |
|
3483 | + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { |
|
3484 | + $p_path = strtr($p_path, '\\', '/'); |
|
3485 | + } |
|
3486 | + } |
|
3487 | + return $p_path; |
|
3488 | + } |
|
3489 | + // --------------------------------------------------------------------------- |
|
3490 | 3490 | } |
3491 | - // End of class |
|
3491 | + // End of class |
|
3492 | 3492 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * Parent |
46 | 46 | */ |
47 | -include_once XOOPS_ROOT_PATH . '/class/xoopsform/formcheckbox.php'; |
|
47 | +include_once XOOPS_ROOT_PATH.'/class/xoopsform/formcheckbox.php'; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * A checkbox field with a choice of available groups |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param bool $include_anon Include group "anonymous"? |
66 | 66 | * @param mixed $value Pre-selected value (or array of them). |
67 | 67 | */ |
68 | - public function __construct($caption, $name, $include_anon=false, $value=null) |
|
68 | + public function __construct($caption, $name, $include_anon = false, $value = null) |
|
69 | 69 | { |
70 | 70 | parent::__construct($caption, $name, $value); |
71 | 71 | $member_handler = xoops_gethandler('member'); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $options = $member_handler->getGroupList(); |
76 | 76 | } |
77 | 77 | foreach ($options as $k => $v) { |
78 | - $options[$k] = $v . '<br />'; |
|
78 | + $options[$k] = $v.'<br />'; |
|
79 | 79 | } |
80 | 80 | $this->addOptionArray($options); |
81 | 81 | } |
@@ -1,51 +1,51 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! defined('XOOPS_MODULE_PATH')) { |
|
4 | - define('XOOPS_MODULE_PATH', XOOPS_ROOT_PATH . '/modules'); |
|
3 | +if (!defined('XOOPS_MODULE_PATH')) { |
|
4 | + define('XOOPS_MODULE_PATH', XOOPS_ROOT_PATH.'/modules'); |
|
5 | 5 | } |
6 | -if (! defined('XOOPS_MODULE_URL')) { |
|
7 | - define('XOOPS_MODULE_URL', XOOPS_URL . '/modules'); |
|
6 | +if (!defined('XOOPS_MODULE_URL')) { |
|
7 | + define('XOOPS_MODULE_URL', XOOPS_URL.'/modules'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
11 | -require_once __DIR__.'/class/AltsysBreadcrumbs.class.php' ; |
|
12 | -require_once __DIR__.'/include/altsys_functions.php' ; |
|
11 | +require_once __DIR__.'/class/AltsysBreadcrumbs.class.php'; |
|
12 | +require_once __DIR__.'/include/altsys_functions.php'; |
|
13 | 13 | |
14 | 14 | |
15 | 15 | if (empty($xoopsModule)) { |
16 | - $moduleperm_handler = xoops_gethandler('module') ; |
|
17 | - $xoopsModule =& $moduleperm_handler->getByDirname('altsys') ; |
|
16 | + $moduleperm_handler = xoops_gethandler('module'); |
|
17 | + $xoopsModule = & $moduleperm_handler->getByDirname('altsys'); |
|
18 | 18 | } |
19 | 19 | |
20 | -require XOOPS_ROOT_PATH.'/include/cp_functions.php' ; |
|
20 | +require XOOPS_ROOT_PATH.'/include/cp_functions.php'; |
|
21 | 21 | |
22 | 22 | // breadcrumbs |
23 | -$breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
24 | -$breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php', $GLOBALS['xoopsModule']->getVar('name')) ; |
|
23 | +$breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
24 | +$breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php', $GLOBALS['xoopsModule']->getVar('name')); |
|
25 | 25 | |
26 | 26 | // get page |
27 | -$page = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_GET['page']) ; |
|
28 | -require __DIR__.'/controllers.php' ; |
|
29 | -if (! in_array($page, $controllers)) { |
|
30 | - $_GET['page'] = $page = 'myblocksadmin' ; |
|
31 | - $_SERVER['REQUEST_URI'] = '/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin' ; |
|
27 | +$page = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_GET['page']); |
|
28 | +require __DIR__.'/controllers.php'; |
|
29 | +if (!in_array($page, $controllers)) { |
|
30 | + $_GET['page'] = $page = 'myblocksadmin'; |
|
31 | + $_SERVER['REQUEST_URI'] = '/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | // half measure ... (TODO) |
36 | 36 | if (empty($_GET['dirname'])) { |
37 | - $module_handler = xoops_gethandler('module') ; |
|
38 | - list($top_module) = $module_handler->getObjects(new Criteria('isactive', 1)) ; |
|
39 | - $_GET['dirname'] = $top_module->getVar('dirname') ; |
|
37 | + $module_handler = xoops_gethandler('module'); |
|
38 | + list($top_module) = $module_handler->getObjects(new Criteria('isactive', 1)); |
|
39 | + $_GET['dirname'] = $top_module->getVar('dirname'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // language file |
43 | -altsys_include_language_file($page) ; |
|
43 | +altsys_include_language_file($page); |
|
44 | 44 | |
45 | 45 | // branch to each pages |
46 | -$mytrustdirpath = __DIR__ ; |
|
46 | +$mytrustdirpath = __DIR__; |
|
47 | 47 | if (file_exists(XOOPS_TRUST_PATH.'/libs/altsys/'.$page.'.php')) { |
48 | - include XOOPS_TRUST_PATH.'/libs/altsys/'.$page.'.php' ; |
|
48 | + include XOOPS_TRUST_PATH.'/libs/altsys/'.$page.'.php'; |
|
49 | 49 | } else { |
50 | - die('wrong request') ; |
|
50 | + die('wrong request'); |
|
51 | 51 | } |
@@ -76,83 +76,83 @@ |
||
76 | 76 | $title4tray = (!defined($config[$i]->getVar('conf_desc')) || constant($config[$i]->getVar('conf_desc')) == '') ? (constant($config[$i]->getVar('conf_title')).$title_icon) : (constant($config[$i]->getVar('conf_title')).$title_icon.'<br /><br /><span style="font-weight:normal;">'.constant($config[$i]->getVar('conf_desc')).'</span>'); // GIJ |
77 | 77 | $title = '' ; // GIJ |
78 | 78 | switch ($config[$i]->getVar('conf_formtype')) { |
79 | - case 'textarea': |
|
80 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
81 | - if ($config[$i]->getVar('conf_valuetype') == 'array') { |
|
82 | - // this is exceptional.. only when value type is arrayneed a smarter way for this |
|
83 | - $ele = ($config[$i]->getVar('conf_value') != '') ? new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars(implode('|', $config[$i]->getConfValueForOutput())), 5, 50) : new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), '', 5, 50); |
|
84 | - } else { |
|
85 | - $ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()), 5, 50); |
|
86 | - } |
|
87 | - break; |
|
88 | - case 'select': |
|
89 | - case 'radio': |
|
90 | - if ($config[$i]->getVar('conf_formtype') === 'select') { |
|
91 | - $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|
92 | - $addBr = ''; |
|
93 | - } else { |
|
94 | - $ele = new XoopsFormRadio($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|
95 | - $addBr = '<br />'; |
|
96 | - } |
|
97 | - $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
|
98 | - $opcount = count($options); |
|
99 | - for ($j = 0; $j < $opcount; $j++) { |
|
100 | - $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
|
101 | - $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
|
102 | - $ele->addOption($optval, $optkey.$addBr); |
|
103 | - } |
|
104 | - break; |
|
105 | - case 'select_multi': |
|
106 | - case 'checkbox': |
|
107 | - if ($config[$i]->getVar('conf_formtype') === 'select_multi') { |
|
108 | - $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); |
|
109 | - $addBr = ''; |
|
110 | - } else { |
|
111 | - $ele = new XoopsFormCheckBox($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|
112 | - $addBr = '<br />'; |
|
113 | - } |
|
114 | - $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
|
115 | - $opcount = count($options); |
|
116 | - for ($j = 0; $j < $opcount; $j++) { |
|
117 | - $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
|
118 | - $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
|
79 | + case 'textarea': |
|
80 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
81 | + if ($config[$i]->getVar('conf_valuetype') == 'array') { |
|
82 | + // this is exceptional.. only when value type is arrayneed a smarter way for this |
|
83 | + $ele = ($config[$i]->getVar('conf_value') != '') ? new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars(implode('|', $config[$i]->getConfValueForOutput())), 5, 50) : new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), '', 5, 50); |
|
84 | + } else { |
|
85 | + $ele = new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars($config[$i]->getConfValueForOutput()), 5, 50); |
|
86 | + } |
|
87 | + break; |
|
88 | + case 'select': |
|
89 | + case 'radio': |
|
90 | + if ($config[$i]->getVar('conf_formtype') === 'select') { |
|
91 | + $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|
92 | + $addBr = ''; |
|
93 | + } else { |
|
94 | + $ele = new XoopsFormRadio($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|
95 | + $addBr = '<br />'; |
|
96 | + } |
|
97 | + $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
|
98 | + $opcount = count($options); |
|
99 | + for ($j = 0; $j < $opcount; $j++) { |
|
100 | + $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
|
101 | + $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
|
102 | + $ele->addOption($optval, $optkey.$addBr); |
|
103 | + } |
|
104 | + break; |
|
105 | + case 'select_multi': |
|
106 | + case 'checkbox': |
|
107 | + if ($config[$i]->getVar('conf_formtype') === 'select_multi') { |
|
108 | + $ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true); |
|
109 | + $addBr = ''; |
|
110 | + } else { |
|
111 | + $ele = new XoopsFormCheckBox($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); |
|
112 | + $addBr = '<br />'; |
|
113 | + } |
|
114 | + $options = $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id'))); |
|
115 | + $opcount = count($options); |
|
116 | + for ($j = 0; $j < $opcount; $j++) { |
|
117 | + $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value'); |
|
118 | + $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name'); |
|
119 | 119 | |
120 | - $ele->addOption($optval, $optkey.$addBr); |
|
121 | - } |
|
122 | - break; |
|
123 | - case 'yesno': |
|
124 | - $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO); |
|
125 | - break; |
|
126 | - case 'group': |
|
127 | - include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
128 | - $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
|
129 | - break; |
|
130 | - case 'group_multi': |
|
131 | - include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
132 | - $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
|
133 | - break; |
|
134 | - case 'group_checkbox': |
|
135 | - include_once __DIR__.'/include/formcheckboxgroup.php'; |
|
136 | - $ele = new AltsysFormCheckboxGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput()); |
|
137 | - break; |
|
138 | - // RMV-NOTIFY: added 'user' and 'user_multi' |
|
139 | - case 'user': |
|
140 | - include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
141 | - $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
|
142 | - break; |
|
143 | - case 'user_multi': |
|
144 | - include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
145 | - $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
|
146 | - break; |
|
147 | - case 'password': |
|
148 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
149 | - $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput())); |
|
150 | - break; |
|
151 | - case 'textbox': |
|
152 | - default: |
|
153 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
154 | - $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput())); |
|
155 | - break; |
|
120 | + $ele->addOption($optval, $optkey.$addBr); |
|
121 | + } |
|
122 | + break; |
|
123 | + case 'yesno': |
|
124 | + $ele = new XoopsFormRadioYN($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), _YES, _NO); |
|
125 | + break; |
|
126 | + case 'group': |
|
127 | + include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
128 | + $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
|
129 | + break; |
|
130 | + case 'group_multi': |
|
131 | + include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
132 | + $ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
|
133 | + break; |
|
134 | + case 'group_checkbox': |
|
135 | + include_once __DIR__.'/include/formcheckboxgroup.php'; |
|
136 | + $ele = new AltsysFormCheckboxGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput()); |
|
137 | + break; |
|
138 | + // RMV-NOTIFY: added 'user' and 'user_multi' |
|
139 | + case 'user': |
|
140 | + include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
141 | + $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 1, false); |
|
142 | + break; |
|
143 | + case 'user_multi': |
|
144 | + include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
145 | + $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
|
146 | + break; |
|
147 | + case 'password': |
|
148 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
149 | + $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput())); |
|
150 | + break; |
|
151 | + case 'textbox': |
|
152 | + default: |
|
153 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
154 | + $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput())); |
|
155 | + break; |
|
156 | 156 | } |
157 | 157 | $hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id')); |
158 | 158 | $ele_tray = new XoopsFormElementTray($title4tray, '') ; |
@@ -5,33 +5,33 @@ discard block |
||
5 | 5 | // GIJOE <http://www.peak.ne.jp/> // |
6 | 6 | // ------------------------------------------------------------------------- // |
7 | 7 | |
8 | -require_once __DIR__.'/class/AltsysBreadcrumbs.class.php' ; |
|
9 | -include_once __DIR__.'/include/gtickets.php' ; |
|
10 | -include_once __DIR__.'/include/altsys_functions.php' ; |
|
8 | +require_once __DIR__.'/class/AltsysBreadcrumbs.class.php'; |
|
9 | +include_once __DIR__.'/include/gtickets.php'; |
|
10 | +include_once __DIR__.'/include/altsys_functions.php'; |
|
11 | 11 | |
12 | 12 | // check access right (needs module_admin of this module) |
13 | -if (! is_object($xoopsUser) || ! is_object($xoopsModule) || ! $xoopsUser->isAdmin($xoopsModule->mid())) { |
|
14 | - die('Access Denied') ; |
|
13 | +if (!is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid())) { |
|
14 | + die('Access Denied'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | |
18 | 18 | // initials |
19 | 19 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
20 | -(method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance() ; |
|
20 | +(method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
21 | 21 | |
22 | 22 | // language file |
23 | -altsys_include_language_file('mypreferences') ; |
|
23 | +altsys_include_language_file('mypreferences'); |
|
24 | 24 | |
25 | 25 | |
26 | -$op = empty($_GET['op']) ? 'showmod' : preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['op']) ; |
|
26 | +$op = empty($_GET['op']) ? 'showmod' : preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['op']); |
|
27 | 27 | |
28 | 28 | if ($op == 'showmod') { |
29 | 29 | $config_handler = xoops_gethandler('config'); |
30 | - $mod = $xoopsModule->mid() ; |
|
30 | + $mod = $xoopsModule->mid(); |
|
31 | 31 | $config = $config_handler->getConfigs(new Criteria('conf_modid', $mod)); |
32 | 32 | $count = count($config); |
33 | 33 | if ($count < 1) { |
34 | - die('no configs') ; |
|
34 | + die('no configs'); |
|
35 | 35 | } |
36 | 36 | include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
37 | 37 | $form = new XoopsThemeForm(_MD_A_MYPREFERENCES_FORMTITLE, 'pref_form', 'index.php?mode=admin&lib=altsys&page=mypreferences&op=save'); |
@@ -39,30 +39,30 @@ discard block |
||
39 | 39 | $module = $module_handler->get($mod); |
40 | 40 | |
41 | 41 | // language |
42 | - $language = empty($xoopsConfig['language']) ? 'english' : $xoopsConfig['language'] ; |
|
42 | + $language = empty($xoopsConfig['language']) ? 'english' : $xoopsConfig['language']; |
|
43 | 43 | |
44 | 44 | // load modinfo.php if necessary (judged by a specific constant is defined) |
45 | - if (! defined('_MYMENU_CONSTANT_IN_MODINFO') || ! defined(_MYMENU_CONSTANT_IN_MODINFO)) { |
|
45 | + if (!defined('_MYMENU_CONSTANT_IN_MODINFO') || !defined(_MYMENU_CONSTANT_IN_MODINFO)) { |
|
46 | 46 | if (file_exists("$mydirpath/language/$language/modinfo.php")) { |
47 | 47 | // user customized language file |
48 | - include_once "$mydirpath/language/$language/modinfo.php" ; |
|
48 | + include_once "$mydirpath/language/$language/modinfo.php"; |
|
49 | 49 | } elseif (file_exists("$mytrustdirpath/language/$language/modinfo.php")) { |
50 | 50 | // default language file |
51 | - include_once "$mytrustdirpath/language/$language/modinfo.php" ; |
|
51 | + include_once "$mytrustdirpath/language/$language/modinfo.php"; |
|
52 | 52 | } else { |
53 | 53 | // fallback english |
54 | - include_once "$mytrustdirpath/language/english/modinfo.php" ; |
|
54 | + include_once "$mytrustdirpath/language/english/modinfo.php"; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // if has comments feature, need comment lang file |
59 | - if ($module->getVar('hascomments') == 1 && ! defined('_CM_TITLE')) { |
|
59 | + if ($module->getVar('hascomments') == 1 && !defined('_CM_TITLE')) { |
|
60 | 60 | include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/comment.php'; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // RMV-NOTIFY |
64 | 64 | // if has notification feature, need notification lang file |
65 | - if ($module->getVar('hasnotification') == 1 && ! defined('_NOT_NOTIFICATIONOPTIONS')) { |
|
65 | + if ($module->getVar('hasnotification') == 1 && !defined('_NOT_NOTIFICATIONOPTIONS')) { |
|
66 | 66 | include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/notification.php'; |
67 | 67 | } |
68 | 68 | |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | // $form->addElement(new XoopsFormHidden('redirect', XOOPS_URL.'/modules/'.$module->getVar('dirname').'/'.$module->getInfo('adminindex'))); |
73 | 73 | // } |
74 | 74 | for ($i = 0; $i < $count; $i++) { |
75 | - $title_icon = ($config[$i]->getVar('conf_valuetype') === 'encrypt')? '<img src="'.XOOPS_MODULE_URL.'/legacy/admin/theme/icons/textfield_key.png" alt="Encrypted">' : ''; // support XCL 2.2.3 'encrypt' of 'conf_valuetype' |
|
75 | + $title_icon = ($config[$i]->getVar('conf_valuetype') === 'encrypt') ? '<img src="'.XOOPS_MODULE_URL.'/legacy/admin/theme/icons/textfield_key.png" alt="Encrypted">' : ''; // support XCL 2.2.3 'encrypt' of 'conf_valuetype' |
|
76 | 76 | $title4tray = (!defined($config[$i]->getVar('conf_desc')) || constant($config[$i]->getVar('conf_desc')) == '') ? (constant($config[$i]->getVar('conf_title')).$title_icon) : (constant($config[$i]->getVar('conf_title')).$title_icon.'<br /><br /><span style="font-weight:normal;">'.constant($config[$i]->getVar('conf_desc')).'</span>'); // GIJ |
77 | - $title = '' ; // GIJ |
|
77 | + $title = ''; // GIJ |
|
78 | 78 | switch ($config[$i]->getVar('conf_formtype')) { |
79 | 79 | case 'textarea': |
80 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
80 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
81 | 81 | if ($config[$i]->getVar('conf_valuetype') == 'array') { |
82 | 82 | // this is exceptional.. only when value type is arrayneed a smarter way for this |
83 | 83 | $ele = ($config[$i]->getVar('conf_value') != '') ? new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), $myts->htmlspecialchars(implode('|', $config[$i]->getConfValueForOutput())), 5, 50) : new XoopsFormTextArea($title, $config[$i]->getVar('conf_name'), '', 5, 50); |
@@ -145,35 +145,35 @@ discard block |
||
145 | 145 | $ele = new XoopsFormSelectUser($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true); |
146 | 146 | break; |
147 | 147 | case 'password': |
148 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
148 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
149 | 149 | $ele = new XoopsFormPassword($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput())); |
150 | 150 | break; |
151 | 151 | case 'textbox': |
152 | 152 | default: |
153 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
153 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
154 | 154 | $ele = new XoopsFormText($title, $config[$i]->getVar('conf_name'), 50, 255, $myts->htmlspecialchars($config[$i]->getConfValueForOutput())); |
155 | 155 | break; |
156 | 156 | } |
157 | 157 | $hidden = new XoopsFormHidden('conf_ids[]', $config[$i]->getVar('conf_id')); |
158 | - $ele_tray = new XoopsFormElementTray($title4tray, '') ; |
|
158 | + $ele_tray = new XoopsFormElementTray($title4tray, ''); |
|
159 | 159 | $ele_tray->addElement($ele); |
160 | 160 | $ele_tray->addElement($hidden); |
161 | - $form->addElement($ele_tray) ; |
|
161 | + $form->addElement($ele_tray); |
|
162 | 162 | unset($ele_tray, $ele, $hidden); |
163 | 163 | } |
164 | 164 | // $button_tray->addElement(new XoopsFormHidden('op', 'save')); |
165 | - $xoopsGTicket->addTicketXoopsFormElement($button_tray, __LINE__, 1800, 'mypreferences') ; |
|
165 | + $xoopsGTicket->addTicketXoopsFormElement($button_tray, __LINE__, 1800, 'mypreferences'); |
|
166 | 166 | $button_tray->addElement(new XoopsFormButton('', 'button', _GO, 'submit')); |
167 | - $form->addElement($button_tray) ; |
|
167 | + $form->addElement($button_tray); |
|
168 | 168 | xoops_cp_header(); |
169 | 169 | |
170 | 170 | // GIJ patch start |
171 | - altsys_include_mymenu() ; |
|
172 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
171 | + altsys_include_mymenu(); |
|
172 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
173 | 173 | if ($breadcrumbsObj->hasPaths()) { |
174 | - $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=mypreferences', _PREFERENCES) ; |
|
174 | + $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=mypreferences', _PREFERENCES); |
|
175 | 175 | } |
176 | - echo "<h3 style='text-align:"._GLOBAL_LEFT.";'>".$module->getvar('name').' '._PREFERENCES."</h3>\n" ; |
|
176 | + echo "<h3 style='text-align:"._GLOBAL_LEFT.";'>".$module->getvar('name').' '._PREFERENCES."</h3>\n"; |
|
177 | 177 | // GIJ patch end |
178 | 178 | |
179 | 179 | $form->display(); |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
186 | 186 | // exit('Invalid referer'); |
187 | 187 | //} |
188 | - if (! $xoopsGTicket->check(true, 'mypreferences')) { |
|
188 | + if (!$xoopsGTicket->check(true, 'mypreferences')) { |
|
189 | 189 | redirect_header(XOOPS_URL.'/', 3, $xoopsGTicket->getErrors()); |
190 | 190 | } |
191 | - require_once XOOPS_ROOT_PATH.'/class/template.php' ; |
|
191 | + require_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
192 | 192 | $xoopsTpl = new XoopsTpl(); |
193 | 193 | //HACK by domifara for new XOOPS and XCL etc. |
194 | 194 | //old xoops |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | if ($count > 0) { |
210 | 210 | for ($i = 0; $i < $count; $i++) { |
211 | 211 | $config = $config_handler->getConfig($conf_ids[$i]); |
212 | - $new_value =& $_POST[$config->getVar('conf_name')]; |
|
212 | + $new_value = & $_POST[$config->getVar('conf_name')]; |
|
213 | 213 | if (is_array($new_value) || $new_value != $config->getVar('conf_value')) { |
214 | 214 | // if language has been changed |
215 | 215 | if (!$lang_updated && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'language') { |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | // generate compiled files for the new theme |
239 | 239 | // block files only for now.. |
240 | 240 | $tplfile_handler = xoops_gethandler('tplfile'); |
241 | - $dtemplates =& $tplfile_handler->find('default', 'block'); |
|
241 | + $dtemplates = & $tplfile_handler->find('default', 'block'); |
|
242 | 242 | $dcount = count($dtemplates); |
243 | 243 | |
244 | 244 | // need to do this to pass to xoops_template_touch function |
245 | 245 | $GLOBALS['xoopsConfig']['template_set'] = $newtplset; |
246 | 246 | |
247 | - altsys_clear_templates_c() ; |
|
247 | + altsys_clear_templates_c(); |
|
248 | 248 | |
249 | 249 | /* for ($i = 0; $i < $dcount; $i++) { |
250 | 250 | $found =& $tplfile_handler->find($newtplset, 'block', $dtemplates[$i]->getVar('tpl_refid'), null); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | // generate image cache files from image binary data, save them under cache/ |
261 | 261 | $image_handler = xoops_gethandler('imagesetimg'); |
262 | - $imagefiles =& $image_handler->getObjects(new Criteria('tplset_name', $newtplset), true); |
|
262 | + $imagefiles = & $image_handler->getObjects(new Criteria('tplset_name', $newtplset), true); |
|
263 | 263 | foreach (array_keys($imagefiles) as $i) { |
264 | 264 | if (!$fp = fopen(XOOPS_CACHE_PATH.'/'.$newtplset.'_'.$imagefiles[$i]->getVar('imgsetimg_file'), 'wb')) { |
265 | 265 | } else { |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | // add read permission for the start module to all groups |
275 | - if (!$startmod_updated && $new_value != '--' && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'startpage') { |
|
275 | + if (!$startmod_updated && $new_value != '--' && $config->getVar('conf_catid') == XOOPS_CONF && $config->getVar('conf_name') == 'startpage') { |
|
276 | 276 | $member_handler = xoops_gethandler('member'); |
277 | - $groups =& $member_handler->getGroupList(); |
|
277 | + $groups = & $member_handler->getGroupList(); |
|
278 | 278 | $moduleperm_handler = xoops_gethandler('groupperm'); |
279 | 279 | $module_handler = xoops_gethandler('module'); |
280 | - $module =& $module_handler->getByDirname($new_value); |
|
280 | + $module = & $module_handler->getByDirname($new_value); |
|
281 | 281 | foreach ($groups as $groupid => $groupname) { |
282 | 282 | if (!$moduleperm_handler->checkRight('module_read', $module->getVar('mid'), $groupid)) { |
283 | 283 | $moduleperm_handler->addRight('module_read', $module->getVar('mid'), $groupid); |
@@ -293,5 +293,5 @@ discard block |
||
293 | 293 | } |
294 | 294 | } |
295 | 295 | |
296 | - redirect_header('index.php?mode=admin&lib=altsys&page=mypreferences', 2, _MD_A_MYPREFERENCES_UPDATED) ; |
|
296 | + redirect_header('index.php?mode=admin&lib=altsys&page=mypreferences', 2, _MD_A_MYPREFERENCES_UPDATED); |
|
297 | 297 | } |
@@ -1,147 +1,147 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once dirname(__DIR__).'/include/altsys_functions.php' ; |
|
3 | +require_once dirname(__DIR__).'/include/altsys_functions.php'; |
|
4 | 4 | |
5 | 5 | function b_altsys_admin_menu_show($options) |
6 | 6 | { |
7 | - global $xoopsUser ; |
|
7 | + global $xoopsUser; |
|
8 | 8 | |
9 | - $mydirname = empty($options[0]) ? 'altsys' : $options[0] ; |
|
10 | - $this_template = empty($options[1]) ? 'db:'.$mydirname.'_block_admin_menu.html' : trim($options[1]) ; |
|
9 | + $mydirname = empty($options[0]) ? 'altsys' : $options[0]; |
|
10 | + $this_template = empty($options[1]) ? 'db:'.$mydirname.'_block_admin_menu.html' : trim($options[1]); |
|
11 | 11 | |
12 | 12 | if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { |
13 | - die('Invalid mydirname') ; |
|
13 | + die('Invalid mydirname'); |
|
14 | 14 | } |
15 | - if (! is_object(@$xoopsUser)) { |
|
16 | - return array() ; |
|
15 | + if (!is_object(@$xoopsUser)) { |
|
16 | + return array(); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | // coretype |
20 | - $coretype = altsys_get_core_type() ; |
|
20 | + $coretype = altsys_get_core_type(); |
|
21 | 21 | |
22 | 22 | // mid_selected |
23 | 23 | if (is_object(@$GLOBALS['xoopsModule'])) { |
24 | - $mid_selected = $GLOBALS['xoopsModule']->getVar('mid') ; |
|
24 | + $mid_selected = $GLOBALS['xoopsModule']->getVar('mid'); |
|
25 | 25 | // for system->preferences |
26 | - if ($mid_selected == 1 && @$_GET['fct'] == 'preferences' && @$_GET['op'] == 'showmod' && ! empty($_GET['mod'])) { |
|
26 | + if ($mid_selected == 1 && @$_GET['fct'] == 'preferences' && @$_GET['op'] == 'showmod' && !empty($_GET['mod'])) { |
|
27 | 27 | $mid_selected = (int)$_GET['mod']; |
28 | 28 | } |
29 | 29 | } else { |
30 | - $mid_selected = 0 ; |
|
30 | + $mid_selected = 0; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
34 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
34 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance(); |
|
35 | 35 | |
36 | 36 | $module_handler = xoops_gethandler('module'); |
37 | - $current_module =& $module_handler->getByDirname($mydirname); |
|
37 | + $current_module = & $module_handler->getByDirname($mydirname); |
|
38 | 38 | $config_handler = xoops_gethandler('config'); |
39 | - $current_configs = $config_handler->getConfigList($current_module->mid()) ; |
|
39 | + $current_configs = $config_handler->getConfigList($current_module->mid()); |
|
40 | 40 | $moduleperm_handler = xoops_gethandler('groupperm'); |
41 | 41 | $admin_mids = $moduleperm_handler->getItemIds('module_admin', $xoopsUser->getGroups()); |
42 | - $modules = $module_handler->getObjects(new Criteria('mid', '('.implode(',', $admin_mids) . ')', 'IN'), true) ; |
|
42 | + $modules = $module_handler->getObjects(new Criteria('mid', '('.implode(',', $admin_mids).')', 'IN'), true); |
|
43 | 43 | |
44 | 44 | $block = array( |
45 | - 'mydirname' => $mydirname , |
|
46 | - 'mod_url' => XOOPS_URL.'/modules/'.$mydirname , |
|
47 | - 'mod_imageurl' => XOOPS_URL.'/modules/'.$mydirname.'/'.$current_configs['images_dir'] , |
|
45 | + 'mydirname' => $mydirname, |
|
46 | + 'mod_url' => XOOPS_URL.'/modules/'.$mydirname, |
|
47 | + 'mod_imageurl' => XOOPS_URL.'/modules/'.$mydirname.'/'.$current_configs['images_dir'], |
|
48 | 48 | 'mod_config' => $current_configs |
49 | - ) ; |
|
49 | + ); |
|
50 | 50 | |
51 | 51 | foreach ($modules as $mod) { |
52 | 52 | $mid = (int)$mod->getVar('mid'); |
53 | - $dirname = $mod->getVar('dirname') ; |
|
54 | - $modinfo = $mod->getInfo() ; |
|
55 | - $submenus4assign = array() ; |
|
56 | - $adminmenu = array() ; |
|
57 | - $adminmenu4altsys = array() ; |
|
58 | - unset($adminmenu_use_altsys) ; |
|
59 | - @include XOOPS_ROOT_PATH.'/modules/'.$dirname.'/'.@$modinfo['adminmenu'] ; |
|
53 | + $dirname = $mod->getVar('dirname'); |
|
54 | + $modinfo = $mod->getInfo(); |
|
55 | + $submenus4assign = array(); |
|
56 | + $adminmenu = array(); |
|
57 | + $adminmenu4altsys = array(); |
|
58 | + unset($adminmenu_use_altsys); |
|
59 | + @include XOOPS_ROOT_PATH.'/modules/'.$dirname.'/'.@$modinfo['adminmenu']; |
|
60 | 60 | // from admin_menu.php etc. |
61 | - $adminmenu = array_merge($adminmenu, $adminmenu4altsys) ; |
|
61 | + $adminmenu = array_merge($adminmenu, $adminmenu4altsys); |
|
62 | 62 | foreach ($adminmenu as $sub) { |
63 | - $link = empty($sub['altsys_link']) ? $sub['link'] : $sub['altsys_link'] ; |
|
63 | + $link = empty($sub['altsys_link']) ? $sub['link'] : $sub['altsys_link']; |
|
64 | 64 | if (isset($sub['show']) && $sub['show'] === false) { |
65 | - continue ; |
|
65 | + continue; |
|
66 | 66 | } |
67 | 67 | $submenus4assign[] = array( |
68 | - 'title' => $myts->makeTboxData4Show($sub['title']) , |
|
68 | + 'title' => $myts->makeTboxData4Show($sub['title']), |
|
69 | 69 | 'url' => XOOPS_URL.'/modules/'.$dirname.'/'.htmlspecialchars($link, ENT_QUOTES) |
70 | - ) ; |
|
70 | + ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // for modules overriding Module.class.php (eg. Analyzer for XC) |
74 | - if (empty($submenus4assign) && defined('XOOPS_CUBE_LEGACY') && ! empty($modinfo['cube_style'])) { |
|
74 | + if (empty($submenus4assign) && defined('XOOPS_CUBE_LEGACY') && !empty($modinfo['cube_style'])) { |
|
75 | 75 | $module_handler = xoops_gethandler('module'); |
76 | 76 | $module = $module_handler->get($mid); |
77 | - $moduleObj =& Legacy_Utils::createModule($module); |
|
78 | - $modinfo['adminindex'] = $moduleObj->getAdminIndex() ; |
|
79 | - $modinfo['adminindex_absolute'] = true ; |
|
77 | + $moduleObj = & Legacy_Utils::createModule($module); |
|
78 | + $modinfo['adminindex'] = $moduleObj->getAdminIndex(); |
|
79 | + $modinfo['adminindex_absolute'] = true; |
|
80 | 80 | foreach ($moduleObj->getAdminMenu() as $sub) { |
81 | 81 | if (@$sub['show'] === false) { |
82 | - continue ; |
|
82 | + continue; |
|
83 | 83 | } |
84 | 84 | $submenus4assign[] = array( |
85 | - 'title' => $myts->makeTboxData4Show($sub['title']) , |
|
85 | + 'title' => $myts->makeTboxData4Show($sub['title']), |
|
86 | 86 | 'url' => strncmp($sub['link'], 'http', 4) === 0 ? htmlspecialchars($sub['link'], ENT_QUOTES) : XOOPS_URL.'/modules/'.$dirname.'/'.htmlspecialchars($sub['link'], ENT_QUOTES) |
87 | - ) ; |
|
87 | + ); |
|
88 | 88 | } |
89 | 89 | } elseif (empty($adminmenu4altsys)) { |
90 | 90 | |
91 | 91 | // add preferences |
92 | - if ($mod->getVar('hasconfig') && ! in_array($mod->getVar('dirname'), array( 'system', 'legacy' ))) { |
|
92 | + if ($mod->getVar('hasconfig') && !in_array($mod->getVar('dirname'), array('system', 'legacy'))) { |
|
93 | 93 | $submenus4assign[] = array( |
94 | - 'title' => _PREFERENCES , |
|
94 | + 'title' => _PREFERENCES, |
|
95 | 95 | 'url' => htmlspecialchars(altsys_get_link2modpreferences($mid, $coretype), ENT_QUOTES) |
96 | - ) ; |
|
96 | + ); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // add help |
100 | - if (defined('XOOPS_CUBE_LEGACY') && ! empty($modinfo['help'])) { |
|
100 | + if (defined('XOOPS_CUBE_LEGACY') && !empty($modinfo['help'])) { |
|
101 | 101 | $submenus4assign[] = array( |
102 | - 'title' => _HELP , |
|
102 | + 'title' => _HELP, |
|
103 | 103 | 'url' => XOOPS_URL.'/modules/legacy/admin/index.php?action=Help&dirname='.$dirname |
104 | - ) ; |
|
104 | + ); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | 108 | $module4assign = array( |
109 | - 'mid' => $mid , |
|
110 | - 'dirname' => $dirname , |
|
111 | - 'name' => $mod->getVar('name') , |
|
112 | - 'version_in_db' => sprintf('%.2f', $mod->getVar('version') / 100.0) , |
|
113 | - 'version_in_file' => sprintf('%.2f', $modinfo['version']) , |
|
114 | - 'description' => htmlspecialchars(@$modinfo['description'], ENT_QUOTES) , |
|
115 | - 'image' => htmlspecialchars($modinfo['image'], ENT_QUOTES) , |
|
116 | - 'isactive' => $mod->getVar('isactive') , |
|
117 | - 'hasmain' => $mod->getVar('hasmain') , |
|
118 | - 'hasadmin' => $mod->getVar('hasadmin') , |
|
119 | - 'hasconfig' => $mod->getVar('hasconfig') , |
|
120 | - 'weight' => $mod->getVar('weight') , |
|
121 | - 'adminindex' => htmlspecialchars(@$modinfo['adminindex'], ENT_QUOTES) , |
|
122 | - 'adminindex_absolute' => @$modinfo['adminindex_absolute'] , |
|
123 | - 'submenu' => $submenus4assign , |
|
124 | - 'selected' => $mid == $mid_selected ? true : false , |
|
109 | + 'mid' => $mid, |
|
110 | + 'dirname' => $dirname, |
|
111 | + 'name' => $mod->getVar('name'), |
|
112 | + 'version_in_db' => sprintf('%.2f', $mod->getVar('version') / 100.0), |
|
113 | + 'version_in_file' => sprintf('%.2f', $modinfo['version']), |
|
114 | + 'description' => htmlspecialchars(@$modinfo['description'], ENT_QUOTES), |
|
115 | + 'image' => htmlspecialchars($modinfo['image'], ENT_QUOTES), |
|
116 | + 'isactive' => $mod->getVar('isactive'), |
|
117 | + 'hasmain' => $mod->getVar('hasmain'), |
|
118 | + 'hasadmin' => $mod->getVar('hasadmin'), |
|
119 | + 'hasconfig' => $mod->getVar('hasconfig'), |
|
120 | + 'weight' => $mod->getVar('weight'), |
|
121 | + 'adminindex' => htmlspecialchars(@$modinfo['adminindex'], ENT_QUOTES), |
|
122 | + 'adminindex_absolute' => @$modinfo['adminindex_absolute'], |
|
123 | + 'submenu' => $submenus4assign, |
|
124 | + 'selected' => $mid == $mid_selected ? true : false, |
|
125 | 125 | 'dot_suffix' => $mid == $mid_selected ? 'selected_opened' : 'closed' |
126 | - ) ; |
|
127 | - $block['modules'][] = $module4assign ; |
|
126 | + ); |
|
127 | + $block['modules'][] = $module4assign; |
|
128 | 128 | } |
129 | 129 | |
130 | - require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php' ; |
|
131 | - $tpl = new D3Tpl() ; |
|
132 | - $tpl->assign('block', $block) ; |
|
133 | - $ret['content'] = $tpl->fetch($this_template) ; |
|
134 | - return $ret ; |
|
130 | + require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php'; |
|
131 | + $tpl = new D3Tpl(); |
|
132 | + $tpl->assign('block', $block); |
|
133 | + $ret['content'] = $tpl->fetch($this_template); |
|
134 | + return $ret; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
138 | 138 | function b_altsys_admin_menu_edit($options) |
139 | 139 | { |
140 | - $mydirname = empty($options[0]) ? 'd3forum' : $options[0] ; |
|
141 | - $this_template = empty($options[1]) ? 'db:'.$mydirname.'_block_admin_menu.html' : trim($options[1]) ; |
|
140 | + $mydirname = empty($options[0]) ? 'd3forum' : $options[0]; |
|
141 | + $this_template = empty($options[1]) ? 'db:'.$mydirname.'_block_admin_menu.html' : trim($options[1]); |
|
142 | 142 | |
143 | 143 | if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { |
144 | - die('Invalid mydirname') ; |
|
144 | + die('Invalid mydirname'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | $form = " |