1 | <?php |
---|
2 | |
---|
3 | ### |
---|
4 | # DEV NOTE: |
---|
5 | # |
---|
6 | # index.php is depreciated by the inc/class.xxphpwebhosting.inc.php files. |
---|
7 | # index.php is still used in the 0.9.14 release, but all future changes should be |
---|
8 | # made to the inc/class.xxphpwebhosting.inc.php files (3-tiered). This includes using templates. |
---|
9 | ### |
---|
10 | |
---|
11 | ### |
---|
12 | # Enable this to display some debugging info |
---|
13 | ### |
---|
14 | |
---|
15 | $phpwh_debug = 0; |
---|
16 | |
---|
17 | @reset ($GLOBALS['HTTP_POST_VARS']); |
---|
18 | while (list ($name,) = @each ($GLOBALS['HTTP_POST_VARS'])) |
---|
19 | { |
---|
20 | $$name = $GLOBALS['HTTP_POST_VARS'][$name]; |
---|
21 | } |
---|
22 | |
---|
23 | @reset ($GLOBALS['HTTP_GET_VARS']); |
---|
24 | while (list ($name,) = @each ($GLOBALS['HTTP_GET_VARS'])) |
---|
25 | { |
---|
26 | $$name = $GLOBALS['HTTP_GET_VARS'][$name]; |
---|
27 | } |
---|
28 | |
---|
29 | $to_decode = array |
---|
30 | ( |
---|
31 | /* |
---|
32 | Decode |
---|
33 | 'var' when 'avar' == 'value' |
---|
34 | or |
---|
35 | 'var' when 'var' is set |
---|
36 | */ |
---|
37 | 'op' => array ('op' => ''), |
---|
38 | 'path' => array ('path' => ''), |
---|
39 | 'file' => array ('file' => ''), |
---|
40 | 'sortby' => array ('sortby' => ''), |
---|
41 | 'fileman' => array ('fileman' => ''), |
---|
42 | 'messages' => array ('messages' => ''), |
---|
43 | 'help_name' => array ('help_name' => ''), |
---|
44 | 'renamefiles' => array ('renamefiles' => ''), |
---|
45 | 'comment_files' => array ('comment_files' => ''), |
---|
46 | 'show_upload_boxes' => array ('show_upload_boxes' => '') |
---|
47 | ); |
---|
48 | |
---|
49 | reset ($to_decode); |
---|
50 | while (list ($var, $conditions) = each ($to_decode)) |
---|
51 | { |
---|
52 | while (list ($condvar, $condvalue) = each ($conditions)) |
---|
53 | { |
---|
54 | if (isset ($$condvar) && ($condvar == $var || $$condvar == $condvalue)) |
---|
55 | { |
---|
56 | if (is_array ($$var)) |
---|
57 | { |
---|
58 | $temp = array (); |
---|
59 | //some fixes in this section were supplied by Michael Totschnig |
---|
60 | while (list ($varkey, $varvalue) = each ($$var)) |
---|
61 | { |
---|
62 | if (is_int ($varkey)) |
---|
63 | { |
---|
64 | $temp[$varkey] = stripslashes (base64_decode(urldecode(($varvalue)))); |
---|
65 | } |
---|
66 | else |
---|
67 | { |
---|
68 | $temp[stripslashes (base64_decode(urldecode(($varkey))))] = $varvalue; |
---|
69 | } |
---|
70 | } |
---|
71 | $$var = $temp; |
---|
72 | } |
---|
73 | elseif (isset ($$var)) |
---|
74 | { |
---|
75 | $$var = stripslashes (base64_decode(urldecode ($$var))); |
---|
76 | } |
---|
77 | } |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | if ($noheader || $nofooter || ($download && (count ($fileman) > 0)) || ($op == 'view' && $file) || ($op == 'history' && $file) || ($op == 'help' && $help_name)) |
---|
82 | { |
---|
83 | $noheader = True; |
---|
84 | $nofooter = True; |
---|
85 | } |
---|
86 | |
---|
87 | $GLOBALS['phpgw_info']['flags'] = array |
---|
88 | ( |
---|
89 | 'currentapp' => 'filemanager', |
---|
90 | 'noheader' => $noheader, |
---|
91 | 'nofooter' => $nofooter, |
---|
92 | 'noappheader' => False, |
---|
93 | 'enable_vfs_class' => True, |
---|
94 | 'enable_browser_class' => True |
---|
95 | ); |
---|
96 | |
---|
97 | include ('../header.inc.php'); |
---|
98 | |
---|
99 | if ($execute && $command_line) |
---|
100 | { |
---|
101 | if ($result = $GLOBALS['phpgw']->vfs->command_line (array ('command_line' => stripslashes ($command_line)))) |
---|
102 | { |
---|
103 | $messages = html_text_bold (lang('Command sucessfully run'),1); |
---|
104 | if ($result != 1 && strlen ($result) > 0) |
---|
105 | { |
---|
106 | $messages .= html_break (2, NULL, 1) . $result; |
---|
107 | } |
---|
108 | } |
---|
109 | else |
---|
110 | { |
---|
111 | $messages = $GLOBALS['phpgw']->common->error_list (array (lang('Error running command'))); |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | ### |
---|
116 | # Page to process users |
---|
117 | # Code is fairly hackish at the beginning, but it gets better |
---|
118 | # Highly suggest turning wrapping off due to long SQL queries |
---|
119 | ### |
---|
120 | |
---|
121 | ### |
---|
122 | # Some hacks to set and display directory paths correctly |
---|
123 | ### |
---|
124 | |
---|
125 | if ($go) |
---|
126 | { |
---|
127 | $path = $todir; |
---|
128 | } |
---|
129 | |
---|
130 | if (!$path) |
---|
131 | { |
---|
132 | $path = $GLOBALS['phpgw']->vfs->pwd (); |
---|
133 | |
---|
134 | if (!$path || $GLOBALS['phpgw']->vfs->pwd (array ('full' => False)) == '') |
---|
135 | { |
---|
136 | $path = $GLOBALS['homedir']; |
---|
137 | } |
---|
138 | } |
---|
139 | |
---|
140 | $GLOBALS['phpgw']->vfs->cd (array ('string' => False, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); |
---|
141 | $GLOBALS['phpgw']->vfs->cd (array ('string' => $path, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); |
---|
142 | |
---|
143 | $pwd = $GLOBALS['phpgw']->vfs->pwd (); |
---|
144 | |
---|
145 | if (!$cwd = substr ($path, strlen ($GLOBALS['homedir']) + 1)) |
---|
146 | { |
---|
147 | $cwd = '/'; |
---|
148 | } |
---|
149 | else |
---|
150 | { |
---|
151 | $cwd = substr ($pwd, strrpos ($pwd, '/') + 1); |
---|
152 | } |
---|
153 | |
---|
154 | $disppath = $path; |
---|
155 | |
---|
156 | /* This just prevents // in some cases */ |
---|
157 | if ($path == '/') |
---|
158 | $dispsep = ''; |
---|
159 | else |
---|
160 | $dispsep = '/'; |
---|
161 | |
---|
162 | if (!($lesspath = substr ($path, 0, strrpos ($path, '/')))) |
---|
163 | $lesspath = '/'; |
---|
164 | |
---|
165 | $now = date ('Y-m-d'); |
---|
166 | |
---|
167 | if ($phpwh_debug) |
---|
168 | { |
---|
169 | echo "<b>PHPWebHosting debug:</b><br> |
---|
170 | path: $path<br> |
---|
171 | disppath: $disppath<br> |
---|
172 | cwd: $cwd<br> |
---|
173 | lesspath: $lesspath |
---|
174 | <p> |
---|
175 | <b>phpGW debug:</b><br> |
---|
176 | real getabsolutepath: " . $GLOBALS['phpgw']->vfs->getabsolutepath (array ('target' => False, 'mask' => False, 'fake' => False)) . "<br> |
---|
177 | fake getabsolutepath: " . $GLOBALS['phpgw']->vfs->getabsolutepath (array ('target' => False)) . "<br> |
---|
178 | appsession: " . $GLOBALS['phpgw']->session->appsession ('vfs','') . "<br> |
---|
179 | pwd: " . $GLOBALS['phpgw']->vfs->pwd () . "<br>"; |
---|
180 | } |
---|
181 | |
---|
182 | ### |
---|
183 | # Get their readable groups to be used throughout the script |
---|
184 | ### |
---|
185 | |
---|
186 | $groups = array (); |
---|
187 | |
---|
188 | $groups = $GLOBALS['phpgw']->accounts->get_list ('groups'); |
---|
189 | |
---|
190 | $readable_groups = array (); |
---|
191 | |
---|
192 | while (list ($num, $account) = each ($groups)) |
---|
193 | { |
---|
194 | if ($GLOBALS['phpgw']->vfs->acl_check (array ( |
---|
195 | 'owner_id' => $account['account_id'], |
---|
196 | 'operation' => PHPGW_ACL_READ |
---|
197 | )) |
---|
198 | ) |
---|
199 | { |
---|
200 | $readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); |
---|
201 | } |
---|
202 | } |
---|
203 | |
---|
204 | $groups_applications = array (); |
---|
205 | |
---|
206 | while (list ($num, $group_array) = each ($readable_groups)) |
---|
207 | { |
---|
208 | $group_id = $GLOBALS['phpgw']->accounts->name2id ($group_array['account_name']); |
---|
209 | |
---|
210 | $applications = CreateObject('phpgwapi.applications', $group_id); |
---|
211 | $groups_applications[$group_array['account_name']] = $applications->read_account_specific (); |
---|
212 | } |
---|
213 | |
---|
214 | ### |
---|
215 | # We determine if they're in their home directory or a group's directory, |
---|
216 | # and set the VFS working_id appropriately |
---|
217 | ### |
---|
218 | |
---|
219 | if ((preg_match ('+^'.$GLOBALS['fakebase'].'\/(.*)(\/|$)+U', $path, $matches)) && $matches[1] != $GLOBALS['userinfo']['account_lid']) |
---|
220 | { |
---|
221 | $GLOBALS['phpgw']->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id ($matches[1]); |
---|
222 | } |
---|
223 | else |
---|
224 | { |
---|
225 | $GLOBALS['phpgw']->vfs->working_id = $GLOBALS['userinfo']['username']; |
---|
226 | } |
---|
227 | |
---|
228 | if ($path != $GLOBALS['homedir'] |
---|
229 | && $path != $GLOBALS['fakebase'] |
---|
230 | && $path != '/' |
---|
231 | && !$GLOBALS['phpgw']->vfs->acl_check (array ( |
---|
232 | 'string' => $path, |
---|
233 | 'relatives' => array (RELATIVE_NONE), |
---|
234 | 'operation' => PHPGW_ACL_READ |
---|
235 | )) |
---|
236 | ) |
---|
237 | { |
---|
238 | echo $GLOBALS['phpgw']->common->error_list (array (lang('You do not have access to %1', $path))); |
---|
239 | html_break (2); |
---|
240 | html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], lang('Go to your home directory')); |
---|
241 | html_page_close (); |
---|
242 | } |
---|
243 | |
---|
244 | $GLOBALS['userinfo']['working_id'] = $GLOBALS['phpgw']->vfs->working_id; |
---|
245 | $GLOBALS['userinfo']['working_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['userinfo']['working_id']); |
---|
246 | |
---|
247 | ### |
---|
248 | # If their home directory doesn't exist, we create it |
---|
249 | # Same for group directories |
---|
250 | ### |
---|
251 | |
---|
252 | if (($path == $GLOBALS['homedir']) |
---|
253 | && !$GLOBALS['phpgw']->vfs->file_exists (array ( |
---|
254 | 'string' => $GLOBALS['homedir'], |
---|
255 | 'relatives' => array (RELATIVE_NONE) |
---|
256 | )) |
---|
257 | ) |
---|
258 | { |
---|
259 | $GLOBALS['phpgw']->vfs->override_acl = 1; |
---|
260 | |
---|
261 | if (!$GLOBALS['phpgw']->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) |
---|
262 | { |
---|
263 | $p = $phpgw->vfs->path_parts (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE))); |
---|
264 | echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not create directory %1', $GLOBALS['homedir'] . ' (' . $p->real_full_path . ')'))); |
---|
265 | } |
---|
266 | |
---|
267 | $GLOBALS['phpgw']->vfs->override_acl = 0; |
---|
268 | } |
---|
269 | |
---|
270 | ### |
---|
271 | # Verify path is real |
---|
272 | ### |
---|
273 | |
---|
274 | if ($path != $GLOBALS['homedir'] && $path != '/' && $path != $GLOBALS['fakebase']) |
---|
275 | { |
---|
276 | if (!$GLOBALS['phpgw']->vfs->file_exists (array ('string' => $path, 'relatives' => array (RELATIVE_NONE)))) |
---|
277 | { |
---|
278 | echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 does not exist', $path))); |
---|
279 | html_break (2); |
---|
280 | html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], lang('Go to your home directory')); |
---|
281 | html_break (2); |
---|
282 | html_link_back (); |
---|
283 | html_page_close (); |
---|
284 | } |
---|
285 | } |
---|
286 | |
---|
287 | /* Update if they request it, or one out of 20 page loads */ |
---|
288 | srand ((double) microtime() * 1000000); |
---|
289 | if ($update || rand (0, 19) == 4) |
---|
290 | { |
---|
291 | $GLOBALS['phpgw']->vfs->update_real (array ('string' => $path, 'relatives' => array (RELATIVE_NONE))); |
---|
292 | } |
---|
293 | |
---|
294 | ### |
---|
295 | # Check available permissions for $path, so we can disable unusable operations in user interface |
---|
296 | ### |
---|
297 | |
---|
298 | if ($GLOBALS['phpgw']->vfs->acl_check (array ( |
---|
299 | 'string' => $path, |
---|
300 | 'relatives' => array (RELATIVE_NONE), |
---|
301 | 'operation' => PHPGW_ACL_ADD |
---|
302 | )) |
---|
303 | ) |
---|
304 | { |
---|
305 | $can_add = True; |
---|
306 | } |
---|
307 | |
---|
308 | ### |
---|
309 | # Default is to sort by name |
---|
310 | ### |
---|
311 | |
---|
312 | if (!$sortby) |
---|
313 | { |
---|
314 | $sortby = 'name'; |
---|
315 | } |
---|
316 | |
---|
317 | ### |
---|
318 | # Decide how many upload boxes to show |
---|
319 | ### |
---|
320 | |
---|
321 | if (!$show_upload_boxes || $show_upload_boxes <= 0) |
---|
322 | { |
---|
323 | if (!$show_upload_boxes = $GLOBALS['settings']['show_upload_boxes']) |
---|
324 | { |
---|
325 | $show_upload_boxes = 5; |
---|
326 | } |
---|
327 | } |
---|
328 | |
---|
329 | |
---|
330 | ### |
---|
331 | # Read in file info from database to use in the rest of the script |
---|
332 | # $fakebase is a special directory. In that directory, we list the user's |
---|
333 | # home directory and the directories for the groups they're in |
---|
334 | ### |
---|
335 | |
---|
336 | $numoffiles = 0; |
---|
337 | if ($path == $GLOBALS['fakebase']) |
---|
338 | { |
---|
339 | if (!$GLOBALS['phpgw']->vfs->file_exists (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) |
---|
340 | { |
---|
341 | $GLOBALS['phpgw']->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE))); |
---|
342 | } |
---|
343 | |
---|
344 | $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( |
---|
345 | 'string' => $GLOBALS['homedir'], |
---|
346 | 'relatives' => array (RELATIVE_NONE), |
---|
347 | 'checksubdirs' => False, |
---|
348 | 'nofiles' => True |
---|
349 | ) |
---|
350 | ); |
---|
351 | $files_array[] = $ls_array[0]; |
---|
352 | $numoffiles++; |
---|
353 | // $files_array = $ls_array; |
---|
354 | // $numoffiles = count($ls_array); |
---|
355 | |
---|
356 | reset ($readable_groups); |
---|
357 | while (list ($num, $group_array) = each ($readable_groups)) |
---|
358 | { |
---|
359 | ### |
---|
360 | # If the group doesn't have access to this app, we don't show it |
---|
361 | ### |
---|
362 | |
---|
363 | if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) |
---|
364 | { |
---|
365 | continue; |
---|
366 | } |
---|
367 | |
---|
368 | if (!$GLOBALS['phpgw']->vfs->file_exists (array ( |
---|
369 | 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], |
---|
370 | 'relatives' => array (RELATIVE_NONE) |
---|
371 | )) |
---|
372 | ) |
---|
373 | { |
---|
374 | $GLOBALS['phpgw']->vfs->override_acl = 1; |
---|
375 | $GLOBALS['phpgw']->vfs->mkdir (array ( |
---|
376 | 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], |
---|
377 | 'relatives' => array (RELATIVE_NONE) |
---|
378 | ) |
---|
379 | ); |
---|
380 | $GLOBALS['phpgw']->vfs->override_acl = 0; |
---|
381 | |
---|
382 | $GLOBALS['phpgw']->vfs->set_attributes (array ( |
---|
383 | 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], |
---|
384 | 'relatives' => array (RELATIVE_NONE), |
---|
385 | 'attributes' => array ( |
---|
386 | 'owner_id' => $group_array['account_id'], |
---|
387 | 'createdby_id' => $group_array['account_id'] |
---|
388 | ) |
---|
389 | ) |
---|
390 | ); |
---|
391 | } |
---|
392 | |
---|
393 | $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( |
---|
394 | 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], |
---|
395 | 'relatives' => array (RELATIVE_NONE), |
---|
396 | 'checksubdirs' => False, |
---|
397 | 'nofiles' => True |
---|
398 | ) |
---|
399 | ); |
---|
400 | |
---|
401 | $files_array[] = $ls_array[0]; |
---|
402 | |
---|
403 | $numoffiles++; |
---|
404 | } |
---|
405 | } |
---|
406 | else |
---|
407 | { |
---|
408 | $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( |
---|
409 | 'string' => $path, |
---|
410 | 'relatives' => array (RELATIVE_NONE), |
---|
411 | 'checksubdirs' => False, |
---|
412 | 'nofiles' => False, |
---|
413 | 'orderby' => $sortby |
---|
414 | ) |
---|
415 | ); |
---|
416 | |
---|
417 | if ($phpwh_debug) |
---|
418 | { |
---|
419 | echo '# of files found in "'.$path.'" : '.count($ls_array).'<br>'."\n"; |
---|
420 | } |
---|
421 | |
---|
422 | while (list ($num, $file_array) = each ($ls_array)) |
---|
423 | { |
---|
424 | $numoffiles++; |
---|
425 | $files_array[] = $file_array; |
---|
426 | if ($phpwh_debug) |
---|
427 | { |
---|
428 | echo 'Filename: '.$file_array['name'].'<br>'."\n"; |
---|
429 | } |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | if (!is_array ($files_array)) |
---|
434 | { |
---|
435 | $files_array = array (); |
---|
436 | } |
---|
437 | |
---|
438 | if ($download) |
---|
439 | { |
---|
440 | for ($i = 0; $i != $numoffiles; $i++) |
---|
441 | { |
---|
442 | if (!$fileman[$i]) |
---|
443 | { |
---|
444 | continue; |
---|
445 | } |
---|
446 | |
---|
447 | $download_browser = CreateObject ('phpgwapi.browser'); |
---|
448 | $download_browser->content_header ($fileman[$i]); |
---|
449 | echo $GLOBALS['phpgw']->vfs->read (array ('string' => $fileman[$i])); |
---|
450 | $GLOBALS['phpgw']->common->phpgw_exit (); |
---|
451 | } |
---|
452 | } |
---|
453 | |
---|
454 | if ($op == 'view' && $file) |
---|
455 | { |
---|
456 | $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( |
---|
457 | 'string' => $path.'/'.$file, |
---|
458 | 'relatives' => array (RELATIVE_ALL), |
---|
459 | 'checksubdirs' => False, |
---|
460 | 'nofiles' => True |
---|
461 | ) |
---|
462 | ); |
---|
463 | |
---|
464 | if ($ls_array[0]['mime_type']) |
---|
465 | { |
---|
466 | $mime_type = $ls_array[0]['mime_type']; |
---|
467 | } |
---|
468 | elseif ($GLOBALS['settings']['viewtextplain']) |
---|
469 | { |
---|
470 | $mime_type = 'text/plain'; |
---|
471 | } |
---|
472 | |
---|
473 | header('Content-type: ' . $mime_type); |
---|
474 | echo $GLOBALS['phpgw']->vfs->read (array ( |
---|
475 | 'string' => $path.'/'.$file, |
---|
476 | 'relatives' => array (RELATIVE_NONE) |
---|
477 | ) |
---|
478 | ); |
---|
479 | $GLOBALS['phpgw']->common->phpgw_exit (); |
---|
480 | } |
---|
481 | |
---|
482 | if ($op == 'history' && $file) |
---|
483 | { |
---|
484 | $journal_array = $GLOBALS['phpgw']->vfs->get_journal (array ( |
---|
485 | 'string' => $file, |
---|
486 | 'relatives' => array (RELATIVE_ALL) |
---|
487 | ) |
---|
488 | ); |
---|
489 | |
---|
490 | if (is_array ($journal_array)) |
---|
491 | { |
---|
492 | html_table_begin (); |
---|
493 | html_table_row_begin (); |
---|
494 | html_table_col_begin (); |
---|
495 | html_text_bold (lang('Date')); |
---|
496 | html_table_col_end (); |
---|
497 | html_table_col_begin (); |
---|
498 | html_text_bold (lang('Version')); |
---|
499 | html_table_col_end (); |
---|
500 | html_table_col_begin (); |
---|
501 | html_text_bold (lang('Who')); |
---|
502 | html_table_col_end (); |
---|
503 | html_table_col_begin (); |
---|
504 | html_text_bold (lang('Operation')); |
---|
505 | html_table_col_end (); |
---|
506 | html_table_row_end (); |
---|
507 | |
---|
508 | while (list ($num, $journal_entry) = each ($journal_array)) |
---|
509 | { |
---|
510 | html_table_row_begin (); |
---|
511 | html_table_col_begin (); |
---|
512 | html_text ($journal_entry['created'] . html_nbsp (3, 1)); |
---|
513 | html_table_col_end (); |
---|
514 | html_table_col_begin (); |
---|
515 | html_text ($journal_entry['version'] . html_nbsp (3, 1)); |
---|
516 | html_table_col_end (); |
---|
517 | html_table_col_begin (); |
---|
518 | html_text ($GLOBALS['phpgw']->accounts->id2name ($journal_entry['owner_id']) . html_nbsp (3, 1)); |
---|
519 | html_table_col_end (); |
---|
520 | html_table_col_begin (); |
---|
521 | html_text ($journal_entry['comment']); |
---|
522 | html_table_col_end (); |
---|
523 | } |
---|
524 | |
---|
525 | html_table_end (); |
---|
526 | html_page_close (); |
---|
527 | } |
---|
528 | else |
---|
529 | { |
---|
530 | html_text_bold (lang('No version history for this file/directory')); |
---|
531 | } |
---|
532 | |
---|
533 | } |
---|
534 | |
---|
535 | if ($newfile && $createfile) |
---|
536 | { |
---|
537 | if ($badchar = bad_chars ($createfile, True, True)) |
---|
538 | { |
---|
539 | echo $GLOBALS['phpgw']->common->error_list (array (html_encode (lang('File names cannot contain "%1"',$badchar), 1))); |
---|
540 | html_break (2); |
---|
541 | html_link_back (); |
---|
542 | html_page_close (); |
---|
543 | } |
---|
544 | |
---|
545 | if ($GLOBALS['phpgw']->vfs->file_exists (array ( |
---|
546 | 'string' => $createfile, |
---|
547 | 'relatives' => array (RELATIVE_ALL) |
---|
548 | )) |
---|
549 | ) |
---|
550 | { |
---|
551 | echo $GLOBALS['phpgw']->common->error_list (array (lang('File %1 already exists. Please edit it or delete it first.', $createfile))); |
---|
552 | html_break (2); |
---|
553 | html_link_back (); |
---|
554 | html_page_close (); |
---|
555 | } |
---|
556 | |
---|
557 | if ($GLOBALS['phpgw']->vfs->touch (array ( |
---|
558 | 'string' => $createfile, |
---|
559 | 'relatives' => array (RELATIVE_ALL) |
---|
560 | )) |
---|
561 | ) |
---|
562 | { |
---|
563 | $fileman = array (); |
---|
564 | $fileman[0] = $createfile; |
---|
565 | $edit = 1; |
---|
566 | $numoffiles++; |
---|
567 | } |
---|
568 | else |
---|
569 | { |
---|
570 | echo $GLOBALS['phpgw']->common->error_list (array (lang('File %1 could not be created.', $createfile))); |
---|
571 | } |
---|
572 | } |
---|
573 | |
---|
574 | if ($op == 'help' && $help_name) |
---|
575 | { |
---|
576 | while (list ($num, $help_array) = each ($help_info)) |
---|
577 | { |
---|
578 | if ($help_array[0] != $help_name) |
---|
579 | continue; |
---|
580 | |
---|
581 | $help_array[1] = preg_replace ("/\[(.*)\|(.*)\]/Ue", "html_help_link ('\\1', '\\2', False, True)", $help_array[1]); |
---|
582 | $help_array[1] = preg_replace ("/\[(.*)\]/Ue", "html_help_link ('\\1', '\\1', False, True)", $help_array[1]); |
---|
583 | |
---|
584 | html_font_set ('4'); |
---|
585 | $title = ereg_replace ('_', ' ', $help_array[0]); |
---|
586 | $title = ucwords ($title); |
---|
587 | html_text ($title); |
---|
588 | html_font_end (); |
---|
589 | |
---|
590 | html_break (2); |
---|
591 | |
---|
592 | html_font_set ('2'); |
---|
593 | html_text ($help_array[1]); |
---|
594 | html_font_end (); |
---|
595 | } |
---|
596 | |
---|
597 | $GLOBALS['phpgw']->common->phpgw_exit (); |
---|
598 | } |
---|
599 | |
---|
600 | ### |
---|
601 | # Start Main Page |
---|
602 | ### |
---|
603 | |
---|
604 | html_page_begin (lang('Users').' :: '.$GLOBALS['userinfo']['username']); |
---|
605 | html_page_body_begin (HTML_PAGE_BODY_COLOR); |
---|
606 | |
---|
607 | if ($messages) |
---|
608 | { |
---|
609 | html_text ($messages); |
---|
610 | } |
---|
611 | |
---|
612 | if (!count ($GLOBALS['settings'])) |
---|
613 | { |
---|
614 | $pref = CreateObject ('phpgwapi.preferences', $GLOBALS['userinfo']['username']); |
---|
615 | $pref->read_repository (); |
---|
616 | $GLOBALS['phpgw']->hooks->single ('add_def_pref', $GLOBALS['appname']); |
---|
617 | $pref->save_repository (True); |
---|
618 | $pref_array = $pref->read_repository (); |
---|
619 | $GLOBALS['settings'] = $pref_array[$GLOBALS['appname']]; |
---|
620 | } |
---|
621 | |
---|
622 | ### |
---|
623 | # Start Main Table |
---|
624 | ### |
---|
625 | |
---|
626 | if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$edit && !$comment_files) |
---|
627 | { |
---|
628 | html_table_begin ('100%'); |
---|
629 | html_table_row_begin (); |
---|
630 | html_table_col_begin ('center', NULL, 'top'); |
---|
631 | html_align ('center'); |
---|
632 | html_form_begin ($GLOBALS['appname'].'/index.php?path='.$path); |
---|
633 | if ($numoffiles || $cwd) |
---|
634 | { |
---|
635 | while (list ($num, $name) = each ($GLOBALS['settings'])) |
---|
636 | { |
---|
637 | if ($name) |
---|
638 | { |
---|
639 | $columns++; |
---|
640 | } |
---|
641 | } |
---|
642 | $columns++; |
---|
643 | html_table_begin (); |
---|
644 | html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_HEADER_BG_COLOR); |
---|
645 | html_table_col_begin ('center', NULL, NULL, NULL, $columns); |
---|
646 | html_table_begin ('100%'); |
---|
647 | html_table_row_begin (); |
---|
648 | html_table_col_begin ('left'); |
---|
649 | |
---|
650 | if ($path != '/') |
---|
651 | { |
---|
652 | html_link ($GLOBALS['appname'].'/index.php?path='.$lesspath, html_image ('images/folder-up.png', lang('Up'), 'left', 0, NULL, 1)); |
---|
653 | html_help_link ('up'); |
---|
654 | } |
---|
655 | |
---|
656 | html_table_col_end (); |
---|
657 | html_table_col_begin ('center'); |
---|
658 | |
---|
659 | if ($cwd) |
---|
660 | { |
---|
661 | if ($path == $GLOBALS['homedir']) |
---|
662 | { |
---|
663 | html_image ('images/folder-home.png', lang('Folder'), 'center'); |
---|
664 | } |
---|
665 | else |
---|
666 | { |
---|
667 | html_image ('images/folder.png', lang('Folder'), 'center'); |
---|
668 | } |
---|
669 | } |
---|
670 | else |
---|
671 | { |
---|
672 | html_image ('images/folder-home.png', lang('Home')); |
---|
673 | } |
---|
674 | |
---|
675 | html_font_set (4, HTML_TABLE_FILES_HEADER_TEXT_COLOR); |
---|
676 | html_text_bold ($disppath); |
---|
677 | html_font_end (); |
---|
678 | html_help_link ('directory_name'); |
---|
679 | html_table_col_end (); |
---|
680 | html_table_col_begin ('right'); |
---|
681 | |
---|
682 | if ($path != $GLOBALS['homedir']) |
---|
683 | { |
---|
684 | html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], html_image ('images/folder-home.png', lang('Home'), 'right', 0, NULL, 1)); |
---|
685 | html_help_link ('home'); |
---|
686 | } |
---|
687 | |
---|
688 | html_table_col_end (); |
---|
689 | html_table_row_end (); |
---|
690 | html_table_end (); |
---|
691 | html_table_col_end (); |
---|
692 | html_table_row_end (); |
---|
693 | html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR); |
---|
694 | |
---|
695 | ### |
---|
696 | # Start File Table Column Headers |
---|
697 | # Reads values from $file_attributes array and preferences |
---|
698 | ### |
---|
699 | |
---|
700 | html_table_col_begin (); |
---|
701 | html_text (lang('Sort by:') . html_nbsp (1, 1), NULL, NULL, 0); |
---|
702 | html_help_link ('sort_by'); |
---|
703 | html_table_col_end (); |
---|
704 | |
---|
705 | reset ($file_attributes); |
---|
706 | while (list ($internal, $displayed) = each ($file_attributes)) |
---|
707 | { |
---|
708 | if ($GLOBALS['settings'][$internal]) |
---|
709 | { |
---|
710 | html_table_col_begin (); |
---|
711 | html_link ($GLOBALS['appname'].'/index.php?path='.$path.'&sortby='.$internal, html_text_bold ($displayed, 1, 0)); |
---|
712 | html_help_link (strtolower (ereg_replace (' ', '_', $displayed))); |
---|
713 | html_table_col_end (); |
---|
714 | } |
---|
715 | } |
---|
716 | |
---|
717 | html_table_col_begin (); |
---|
718 | html_table_col_end (); |
---|
719 | html_table_row_end (); |
---|
720 | |
---|
721 | if ($GLOBALS['settings']['dotdot'] && $GLOBALS['settings']['name'] && $path != '/') |
---|
722 | { |
---|
723 | html_table_row_begin (); |
---|
724 | html_table_col_begin (); |
---|
725 | html_table_col_end (); |
---|
726 | |
---|
727 | /* We can assume the next column is the name */ |
---|
728 | html_table_col_begin (); |
---|
729 | html_image ('images/folder.png', lang('Folder')); |
---|
730 | html_link ($GLOBALS['appname'].'/index.php?path='.$lesspath, '..'); |
---|
731 | html_table_col_end (); |
---|
732 | |
---|
733 | if ($GLOBALS['settings']['mime_type']) |
---|
734 | { |
---|
735 | html_table_col_begin (); |
---|
736 | html_text (lang('Directory')); |
---|
737 | html_table_col_end (); |
---|
738 | } |
---|
739 | |
---|
740 | html_table_row_end (); |
---|
741 | } |
---|
742 | |
---|
743 | ### |
---|
744 | # List all of the files, with their attributes |
---|
745 | ### |
---|
746 | |
---|
747 | reset ($files_array); |
---|
748 | for ($i = 0; $i != $numoffiles; $i++) |
---|
749 | { |
---|
750 | $files = $files_array[$i]; |
---|
751 | |
---|
752 | if ($rename || $edit_comments) |
---|
753 | { |
---|
754 | unset ($this_selected); |
---|
755 | unset ($renamethis); |
---|
756 | unset ($edit_this_comment); |
---|
757 | |
---|
758 | for ($j = 0; $j != $numoffiles; $j++) |
---|
759 | { |
---|
760 | if ($fileman[$j] == $files['name']) |
---|
761 | { |
---|
762 | $this_selected = 1; |
---|
763 | break; |
---|
764 | } |
---|
765 | } |
---|
766 | |
---|
767 | if ($rename && $this_selected) |
---|
768 | { |
---|
769 | $renamethis = 1; |
---|
770 | } |
---|
771 | elseif ($edit_comments && $this_selected) |
---|
772 | { |
---|
773 | $edit_this_comment = 1; |
---|
774 | } |
---|
775 | } |
---|
776 | |
---|
777 | if (!$GLOBALS['settings']['dotfiles'] && ereg ("^\.", $files['name'])) |
---|
778 | { |
---|
779 | continue; |
---|
780 | } |
---|
781 | |
---|
782 | html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_BG_COLOR); |
---|
783 | |
---|
784 | ### |
---|
785 | # Checkboxes |
---|
786 | ### |
---|
787 | |
---|
788 | html_table_col_begin ('right'); |
---|
789 | |
---|
790 | if (!$rename && !$edit_comments && $path != $GLOBALS['fakebase'] && $path != '/') |
---|
791 | { |
---|
792 | html_form_input ('checkbox', 'fileman['.$i.']', base64_encode ($files['name'])); |
---|
793 | } |
---|
794 | elseif ($renamethis) |
---|
795 | { |
---|
796 | html_form_input ('hidden', 'fileman[' . base64_encode ($files['name']) . ']', $files['name'], NULL, NULL, 'checked'); |
---|
797 | } |
---|
798 | else |
---|
799 | { |
---|
800 | html_nbsp(); |
---|
801 | } |
---|
802 | |
---|
803 | html_table_col_end (); |
---|
804 | |
---|
805 | ### |
---|
806 | # File name and icon |
---|
807 | ### |
---|
808 | |
---|
809 | if ($GLOBALS['settings']['name']) |
---|
810 | { |
---|
811 | if ($phpwh_debug) |
---|
812 | { |
---|
813 | echo 'Setting file name: '.$files['name'].'<br>'."\n"; |
---|
814 | } |
---|
815 | |
---|
816 | html_table_col_begin (); |
---|
817 | |
---|
818 | if ($renamethis) |
---|
819 | { |
---|
820 | if ($files['mime_type'] == 'Directory') |
---|
821 | { |
---|
822 | html_image ('images/folder.png', lang('Folder')); |
---|
823 | } |
---|
824 | html_form_input ('text', 'renamefiles[' . base64_encode ($files['name']) . ']', $files['name'], 255); |
---|
825 | } |
---|
826 | else |
---|
827 | { |
---|
828 | if ($files['mime_type'] == 'Directory') |
---|
829 | { |
---|
830 | html_image ('images/folder.png', lang('Folder')); |
---|
831 | html_link ($GLOBALS['appname'].'/index.php?path='.$path.$dispsep.$files['name'], $files['name']); |
---|
832 | } |
---|
833 | else |
---|
834 | { |
---|
835 | if ($GLOBALS['settings']['viewonserver'] && isset ($GLOBALS['filesdir']) && !$files['link_directory']) |
---|
836 | { |
---|
837 | $clickview = $GLOBALS['filesdir'].$pwd.'/'.$files['name']; |
---|
838 | |
---|
839 | if ($phpwh_debug) |
---|
840 | { |
---|
841 | echo 'Setting clickview = '.$clickview.'<br>'."\n"; |
---|
842 | } |
---|
843 | } |
---|
844 | else |
---|
845 | { |
---|
846 | $clickview = $GLOBALS['appname'].'/index.php?op=view&file='.$files['name'].'&path='.$path; |
---|
847 | } |
---|
848 | |
---|
849 | if ($GLOBALS['settings']['viewinnewwin']) |
---|
850 | { |
---|
851 | $target = '_new'; |
---|
852 | } |
---|
853 | |
---|
854 | html_link ($clickview, $files['name'], 0, 1, 0, $target); |
---|
855 | } |
---|
856 | } |
---|
857 | |
---|
858 | html_table_col_end (); |
---|
859 | } |
---|
860 | |
---|
861 | ### |
---|
862 | # MIME type |
---|
863 | ### |
---|
864 | |
---|
865 | if ($GLOBALS['settings']['mime_type']) |
---|
866 | { |
---|
867 | html_table_col_begin (); |
---|
868 | html_text ($files['mime_type']); |
---|
869 | html_table_col_end (); |
---|
870 | } |
---|
871 | |
---|
872 | ### |
---|
873 | # File size |
---|
874 | ### |
---|
875 | |
---|
876 | if ($GLOBALS['settings']['size']) |
---|
877 | { |
---|
878 | html_table_col_begin (); |
---|
879 | |
---|
880 | $size = $GLOBALS['phpgw']->vfs->get_size (array ( |
---|
881 | 'string' => $files['directory'] . '/' . $files['name'], |
---|
882 | 'relatives' => array (RELATIVE_NONE) |
---|
883 | ) |
---|
884 | ); |
---|
885 | |
---|
886 | borkb ($size); |
---|
887 | |
---|
888 | html_table_col_end (); |
---|
889 | } |
---|
890 | |
---|
891 | ### |
---|
892 | # Date created |
---|
893 | ### |
---|
894 | if ($GLOBALS['settings']['created']) |
---|
895 | { |
---|
896 | html_table_col_begin (); |
---|
897 | html_text ($files['created']); |
---|
898 | html_table_col_end (); |
---|
899 | } |
---|
900 | |
---|
901 | ### |
---|
902 | # Date modified |
---|
903 | ### |
---|
904 | |
---|
905 | if ($GLOBALS['settings']['modified']) |
---|
906 | { |
---|
907 | html_table_col_begin (); |
---|
908 | if ($files['modified'] != '0000-00-00') |
---|
909 | { |
---|
910 | html_text ($files['modified']); |
---|
911 | } |
---|
912 | html_table_col_end (); |
---|
913 | } |
---|
914 | |
---|
915 | ### |
---|
916 | # Owner name |
---|
917 | ### |
---|
918 | |
---|
919 | if ($GLOBALS['settings']['owner']) |
---|
920 | { |
---|
921 | html_table_col_begin (); |
---|
922 | html_text ($GLOBALS['phpgw']->accounts->id2name ($files['owner_id'])); |
---|
923 | html_table_col_end (); |
---|
924 | } |
---|
925 | |
---|
926 | ### |
---|
927 | # Creator name |
---|
928 | ### |
---|
929 | |
---|
930 | if ($GLOBALS['settings']['createdby_id']) |
---|
931 | { |
---|
932 | html_table_col_begin (); |
---|
933 | if ($files['createdby_id']) |
---|
934 | { |
---|
935 | html_text ($GLOBALS['phpgw']->accounts->id2name ($files['createdby_id'])); |
---|
936 | } |
---|
937 | html_table_col_end (); |
---|
938 | } |
---|
939 | |
---|
940 | ### |
---|
941 | # Modified by name |
---|
942 | ### |
---|
943 | |
---|
944 | if ($GLOBALS['settings']['modifiedby_id']) |
---|
945 | { |
---|
946 | html_table_col_begin (); |
---|
947 | if ($files['modifiedby_id']) |
---|
948 | { |
---|
949 | html_text ($GLOBALS['phpgw']->accounts->id2name ($files['modifiedby_id'])); |
---|
950 | } |
---|
951 | html_table_col_end (); |
---|
952 | } |
---|
953 | |
---|
954 | ### |
---|
955 | # Application |
---|
956 | ### |
---|
957 | |
---|
958 | if ($GLOBALS['settings']['app']) |
---|
959 | { |
---|
960 | html_table_col_begin (); |
---|
961 | html_text ($files['app']); |
---|
962 | html_table_col_end (); |
---|
963 | } |
---|
964 | |
---|
965 | ### |
---|
966 | # Comment |
---|
967 | ### |
---|
968 | |
---|
969 | if ($GLOBALS['settings']['comment']) |
---|
970 | { |
---|
971 | html_table_col_begin (); |
---|
972 | if ($edit_this_comment) |
---|
973 | { |
---|
974 | html_form_input ('text', 'comment_files[' . base64_encode ($files['name']) . ']', html_encode ($files['comment'], 1), 255); |
---|
975 | } |
---|
976 | else |
---|
977 | { |
---|
978 | html_text ($files['comment']); |
---|
979 | } |
---|
980 | html_table_col_end (); |
---|
981 | } |
---|
982 | |
---|
983 | ### |
---|
984 | # Version |
---|
985 | ### |
---|
986 | |
---|
987 | if ($GLOBALS['settings']['version']) |
---|
988 | { |
---|
989 | html_table_col_begin (); |
---|
990 | html_link ($GLOBALS['appname'].'/index.php?op=history&file='.$files['name'].'&path='.$path, $files['version'], NULL, True, NULL, '_new'); |
---|
991 | html_table_col_end (); |
---|
992 | } |
---|
993 | |
---|
994 | ### |
---|
995 | # Deleteable (currently not used) |
---|
996 | ### |
---|
997 | |
---|
998 | if ($GLOBALS['settings']['deleteable']) |
---|
999 | { |
---|
1000 | if ($files['deleteable'] == 'N') |
---|
1001 | { |
---|
1002 | html_table_col_begin (); |
---|
1003 | html_image ('images/locked.png', lang('Locked')); |
---|
1004 | html_table_col_end (); |
---|
1005 | } |
---|
1006 | else |
---|
1007 | { |
---|
1008 | html_table_col_begin (); |
---|
1009 | html_table_col_end (); |
---|
1010 | } |
---|
1011 | } |
---|
1012 | |
---|
1013 | html_table_row_end (); |
---|
1014 | |
---|
1015 | if ($files['mime_type'] == 'Directory') |
---|
1016 | { |
---|
1017 | $usedspace += $fileinfo[0]; |
---|
1018 | } |
---|
1019 | else |
---|
1020 | { |
---|
1021 | $usedspace += $files['size']; |
---|
1022 | } |
---|
1023 | } |
---|
1024 | |
---|
1025 | html_table_end (); |
---|
1026 | html_break (2); |
---|
1027 | |
---|
1028 | if ($path != '/' && $path != $GLOBALS['fakebase']) |
---|
1029 | { |
---|
1030 | if (!$rename && !$edit_comments) |
---|
1031 | { |
---|
1032 | html_form_input ('submit', 'edit', lang('Edit')); |
---|
1033 | html_help_link ('edit'); |
---|
1034 | html_nbsp (3); |
---|
1035 | } |
---|
1036 | |
---|
1037 | if (!$edit_comments) |
---|
1038 | { |
---|
1039 | html_form_input ('submit', 'rename', lang('Rename')); |
---|
1040 | html_help_link ('rename'); |
---|
1041 | html_nbsp (3); |
---|
1042 | } |
---|
1043 | |
---|
1044 | if (!$rename && !$edit_comments) |
---|
1045 | { |
---|
1046 | html_form_input ('submit', 'delete', lang('Delete')); |
---|
1047 | html_help_link ('delete'); |
---|
1048 | html_nbsp (3); |
---|
1049 | } |
---|
1050 | |
---|
1051 | if (!$rename) |
---|
1052 | { |
---|
1053 | html_form_input ('submit', 'edit_comments', lang('Edit comments')); |
---|
1054 | html_help_link ('edit_comments'); |
---|
1055 | } |
---|
1056 | } |
---|
1057 | } |
---|
1058 | |
---|
1059 | ### |
---|
1060 | # Display some inputs and info, but not when renaming or editing comments |
---|
1061 | ### |
---|
1062 | |
---|
1063 | if (!$rename && !$edit_comments) |
---|
1064 | { |
---|
1065 | ### |
---|
1066 | # Begin Copy to/Move to selection |
---|
1067 | ### |
---|
1068 | |
---|
1069 | html_break (1); |
---|
1070 | html_form_input ('submit', 'go', lang('Go to:')); |
---|
1071 | html_help_link ('go_to'); |
---|
1072 | |
---|
1073 | if ($path != '/' && $path != $GLOBALS['fakebase']) |
---|
1074 | { |
---|
1075 | html_form_input ('submit', 'copy', lang('Copy to:')); |
---|
1076 | html_help_link ('copy_to'); |
---|
1077 | html_form_input ('submit', 'move', lang('Move to:')); |
---|
1078 | html_help_link ('move_to'); |
---|
1079 | } |
---|
1080 | |
---|
1081 | html_form_select_begin ('todir'); |
---|
1082 | |
---|
1083 | html_break (1); |
---|
1084 | |
---|
1085 | ### |
---|
1086 | # First we get the directories in their home directory |
---|
1087 | ### |
---|
1088 | |
---|
1089 | $dirs = array (); |
---|
1090 | $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $GLOBALS['userinfo']['account_lid']); |
---|
1091 | |
---|
1092 | $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( |
---|
1093 | 'string' => $GLOBALS['homedir'], |
---|
1094 | 'relatives' => array (RELATIVE_NONE), |
---|
1095 | 'checksubdirs' => True, |
---|
1096 | 'mime_type' => 'Directory' |
---|
1097 | ) |
---|
1098 | ); |
---|
1099 | |
---|
1100 | while (list ($num, $dir) = each ($ls_array)) |
---|
1101 | { |
---|
1102 | $dirs[] = $dir; |
---|
1103 | } |
---|
1104 | |
---|
1105 | |
---|
1106 | ### |
---|
1107 | # Then we get the directories in their readable groups' home directories |
---|
1108 | ### |
---|
1109 | |
---|
1110 | reset ($readable_groups); |
---|
1111 | while (list ($num, $group_array) = each ($readable_groups)) |
---|
1112 | { |
---|
1113 | ### |
---|
1114 | # Don't list directories for groups that don't have access |
---|
1115 | ### |
---|
1116 | |
---|
1117 | if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) |
---|
1118 | { |
---|
1119 | continue; |
---|
1120 | } |
---|
1121 | |
---|
1122 | $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $group_array['account_name']); |
---|
1123 | |
---|
1124 | $ls_array = $phpgw->vfs->ls (array ( |
---|
1125 | 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], |
---|
1126 | 'relatives' => array (RELATIVE_NONE), |
---|
1127 | 'checksubdirs' => True, |
---|
1128 | 'mime_type' => 'Directory' |
---|
1129 | ) |
---|
1130 | ); |
---|
1131 | while (list ($num, $dir) = each ($ls_array)) |
---|
1132 | { |
---|
1133 | $dirs[] = $dir; |
---|
1134 | } |
---|
1135 | } |
---|
1136 | |
---|
1137 | reset ($dirs); |
---|
1138 | while (list ($num, $dir) = each ($dirs)) |
---|
1139 | { |
---|
1140 | if (!$dir['directory']) |
---|
1141 | { |
---|
1142 | continue; |
---|
1143 | } |
---|
1144 | |
---|
1145 | ### |
---|
1146 | # So we don't display // |
---|
1147 | ### |
---|
1148 | |
---|
1149 | if ($dir['directory'] != '/') |
---|
1150 | { |
---|
1151 | $dir['directory'] .= '/'; |
---|
1152 | } |
---|
1153 | |
---|
1154 | ### |
---|
1155 | # No point in displaying the current directory, or a directory that doesn't exist |
---|
1156 | ### |
---|
1157 | |
---|
1158 | if ((($dir['directory'] . $dir['name']) != $path) |
---|
1159 | && $GLOBALS['phpgw']->vfs->file_exists (array ( |
---|
1160 | 'string' => $dir['directory'] . $dir['name'], |
---|
1161 | 'relatives' => array (RELATIVE_NONE) |
---|
1162 | )) |
---|
1163 | ) |
---|
1164 | { |
---|
1165 | html_form_option ($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); |
---|
1166 | } |
---|
1167 | } |
---|
1168 | |
---|
1169 | html_form_select_end (); |
---|
1170 | html_help_link ('directory_list'); |
---|
1171 | |
---|
1172 | if ($path != '/' && $path != $GLOBALS['fakebase']) |
---|
1173 | { |
---|
1174 | html_break (1); |
---|
1175 | |
---|
1176 | html_form_input ('submit', 'download', lang('Download')); |
---|
1177 | html_help_link ('download'); |
---|
1178 | html_nbsp (3); |
---|
1179 | |
---|
1180 | if ($can_add) |
---|
1181 | { |
---|
1182 | html_form_input ('text', 'createdir', NULL, 255, 15); |
---|
1183 | html_form_input ('submit', 'newdir', lang('Create Folder')); |
---|
1184 | html_help_link ('create_folder'); |
---|
1185 | } |
---|
1186 | } |
---|
1187 | |
---|
1188 | html_break (1); |
---|
1189 | html_form_input ('submit', 'update', lang('Update')); |
---|
1190 | html_help_link ('update'); |
---|
1191 | |
---|
1192 | if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) |
---|
1193 | { |
---|
1194 | html_nbsp (3); |
---|
1195 | html_form_input ('text', 'createfile', NULL, 255, 15); |
---|
1196 | html_form_input ('submit', 'newfile', lang('Create File')); |
---|
1197 | html_help_link ('create_file'); |
---|
1198 | } |
---|
1199 | |
---|
1200 | if ($GLOBALS['settings']['show_command_line']) |
---|
1201 | { |
---|
1202 | html_break (2); |
---|
1203 | html_form_input ('text', 'command_line', NULL, NULL, 50); |
---|
1204 | html_help_link ('command_line'); |
---|
1205 | |
---|
1206 | html_break (1); |
---|
1207 | html_form_input ('submit', 'execute', lang('Execute')); |
---|
1208 | html_help_link ('execute'); |
---|
1209 | } |
---|
1210 | |
---|
1211 | html_form_end (); |
---|
1212 | |
---|
1213 | html_help_link ('file_stats'); |
---|
1214 | html_break (1); |
---|
1215 | html_text_bold (lang('Files').': '); |
---|
1216 | html_text ($numoffiles); |
---|
1217 | html_nbsp (3); |
---|
1218 | |
---|
1219 | html_text_bold (lang('Used space').': '); |
---|
1220 | html_text (borkb ($usedspace, NULL, 1)); |
---|
1221 | html_nbsp (3); |
---|
1222 | |
---|
1223 | if ($path == $GLOBALS['homedir'] || $path == $GLOBALS['fakebase']) |
---|
1224 | { |
---|
1225 | html_text_bold (lang('Unused space').': '); |
---|
1226 | html_text (borkb ($GLOBALS['userinfo']['hdspace'] - $usedspace, NULL, 1)); |
---|
1227 | |
---|
1228 | $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( |
---|
1229 | 'string' => $path, |
---|
1230 | 'relatives' => array (RELATIVE_NONE) |
---|
1231 | ) |
---|
1232 | ); |
---|
1233 | |
---|
1234 | $i = count ($ls_array); |
---|
1235 | |
---|
1236 | html_break (2); |
---|
1237 | html_text_bold (lang('Total Files').': '); |
---|
1238 | html_text ($i); |
---|
1239 | } |
---|
1240 | |
---|
1241 | ### |
---|
1242 | # Show file upload boxes. Note the last argument to html (). Repeats $show_upload_boxes times |
---|
1243 | ### |
---|
1244 | |
---|
1245 | if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) |
---|
1246 | { |
---|
1247 | html_break (2); |
---|
1248 | html_form_begin ($GLOBALS['appname'].'/index.php?op=upload&path='.$path, 'post', 'multipart/form-data'); |
---|
1249 | html_table_begin (); |
---|
1250 | html_table_row_begin ('center'); |
---|
1251 | html_table_col_begin (); |
---|
1252 | html_text_bold (lang('File')); |
---|
1253 | html_help_link ('upload_file'); |
---|
1254 | html_table_col_end (); |
---|
1255 | html_table_col_begin (); |
---|
1256 | html_text_bold (lang('Comment')); |
---|
1257 | html_help_link ('upload_comment'); |
---|
1258 | html_table_col_end (); |
---|
1259 | html_table_row_end (); |
---|
1260 | |
---|
1261 | html_table_row_begin (); |
---|
1262 | html_table_col_begin (); |
---|
1263 | html_form_input ('hidden', 'show_upload_boxes', base64_encode ($show_upload_boxes)); |
---|
1264 | html (html_form_input ('file', 'upload_file[]', NULL, 255, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); |
---|
1265 | html_table_col_end (); |
---|
1266 | html_table_col_begin (); |
---|
1267 | html (html_form_input ('text', 'upload_comment[]', NULL, NULL, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); |
---|
1268 | html_table_col_end (); |
---|
1269 | html_table_row_end (); |
---|
1270 | html_table_end (); |
---|
1271 | html_form_input ('submit', 'upload_files', lang('Upload files')); |
---|
1272 | html_help_link ('upload_files'); |
---|
1273 | html_break (2); |
---|
1274 | html_text (lang('Show') . html_nbsp (1, True)); |
---|
1275 | html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=5', '5'); |
---|
1276 | html_nbsp (); |
---|
1277 | html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=10', '10'); |
---|
1278 | html_nbsp (); |
---|
1279 | html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=20', '20'); |
---|
1280 | html_nbsp (); |
---|
1281 | html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=50', '50'); |
---|
1282 | html_nbsp (); |
---|
1283 | html_text (lang('upload fields')); |
---|
1284 | html_nbsp (); |
---|
1285 | html_help_link ('show_upload_fields'); |
---|
1286 | html_form_end (); |
---|
1287 | } |
---|
1288 | } |
---|
1289 | |
---|
1290 | html_table_col_end (); |
---|
1291 | html_table_row_end (); |
---|
1292 | html_table_end (); |
---|
1293 | html_page_close (); |
---|
1294 | } |
---|
1295 | |
---|
1296 | ### |
---|
1297 | # Handle Editing files |
---|
1298 | ### |
---|
1299 | |
---|
1300 | if ($edit) |
---|
1301 | { |
---|
1302 | ### |
---|
1303 | # If $edit is "Edit", we do nothing, and let the for loop take over |
---|
1304 | ### |
---|
1305 | |
---|
1306 | if ($edit_file) |
---|
1307 | { |
---|
1308 | $edit_file_content = stripslashes ($edit_file_content); |
---|
1309 | } |
---|
1310 | |
---|
1311 | if ($edit_preview) |
---|
1312 | { |
---|
1313 | $content = $edit_file_content; |
---|
1314 | |
---|
1315 | html_break (1); |
---|
1316 | html_text_bold (lang('Preview of %1', $path.'/'.$edit_file)); |
---|
1317 | html_break (2); |
---|
1318 | |
---|
1319 | html_table_begin ('90%'); |
---|
1320 | html_table_row_begin (); |
---|
1321 | html_table_col_begin (); |
---|
1322 | html_text (nl2br ($content)); |
---|
1323 | html_table_col_end (); |
---|
1324 | html_table_row_end (); |
---|
1325 | html_table_end (); |
---|
1326 | } |
---|
1327 | elseif ($edit_save) |
---|
1328 | { |
---|
1329 | $content = $edit_file_content; |
---|
1330 | |
---|
1331 | if ($GLOBALS['phpgw']->vfs->write (array ( |
---|
1332 | 'string' => $edit_file, |
---|
1333 | 'relatives' => array (RELATIVE_ALL), |
---|
1334 | 'content' => $content |
---|
1335 | )) |
---|
1336 | ) |
---|
1337 | { |
---|
1338 | html_text_bold (lang('Saved %1', $path.'/'.$edit_file)); |
---|
1339 | html_break (2); |
---|
1340 | html_link_back (); |
---|
1341 | } |
---|
1342 | else |
---|
1343 | { |
---|
1344 | html_text_error (lang('Could not save %1', $path.'/'.$edit_file)); |
---|
1345 | html_break (2); |
---|
1346 | html_link_back (); |
---|
1347 | } |
---|
1348 | } |
---|
1349 | |
---|
1350 | /* This doesn't work just yet |
---|
1351 | elseif ($edit_save_all) |
---|
1352 | { |
---|
1353 | for ($j = 0; $j != $numoffiles; $j++) |
---|
1354 | { |
---|
1355 | $fileman[$j]; |
---|
1356 | |
---|
1357 | $content = $fileman[$j]; |
---|
1358 | echo 'fileman['.$j.']: '.$fileman[$j].'<br><b>'.$content.'</b><br>'; |
---|
1359 | continue; |
---|
1360 | |
---|
1361 | if ($GLOBALS['phpgw']->vfs->write (array ( |
---|
1362 | 'string' => $fileman[$j], |
---|
1363 | 'relatives' => array (RELATIVE_ALL), |
---|
1364 | 'content' => $content |
---|
1365 | )) |
---|
1366 | ) |
---|
1367 | { |
---|
1368 | html_text_bold (lang('Saved %1', $path.'/'.$fileman[$j])); |
---|
1369 | html_break (1); |
---|
1370 | } |
---|
1371 | else |
---|
1372 | { |
---|
1373 | html_text_error (lang('Could not save %1', $path.'/'.$fileman[$j])); |
---|
1374 | html_break (1); |
---|
1375 | } |
---|
1376 | } |
---|
1377 | |
---|
1378 | html_break (1); |
---|
1379 | } |
---|
1380 | */ |
---|
1381 | |
---|
1382 | ### |
---|
1383 | # Now we display the edit boxes and forms |
---|
1384 | ### |
---|
1385 | |
---|
1386 | for ($j = 0; $j != $numoffiles; $j++) |
---|
1387 | { |
---|
1388 | ### |
---|
1389 | # If we're in preview or save mode, we only show the file |
---|
1390 | # being previewed or saved |
---|
1391 | ### |
---|
1392 | |
---|
1393 | if ($edit_file && ($fileman[$j] != $edit_file)) |
---|
1394 | { |
---|
1395 | continue; |
---|
1396 | } |
---|
1397 | |
---|
1398 | if ($fileman[$j] && $GLOBALS['phpgw']->vfs->file_exists (array ( |
---|
1399 | 'string' => $fileman[$j], |
---|
1400 | 'relatives' => array (RELATIVE_ALL) |
---|
1401 | )) |
---|
1402 | ) |
---|
1403 | { |
---|
1404 | if ($edit_file) |
---|
1405 | { |
---|
1406 | $content = stripslashes ($edit_file_content); |
---|
1407 | } |
---|
1408 | else |
---|
1409 | { |
---|
1410 | $content = $GLOBALS['phpgw']->vfs->read (array ('string' => $fileman[$j])); |
---|
1411 | } |
---|
1412 | |
---|
1413 | html_table_begin ('100%'); |
---|
1414 | html_form_begin ($GLOBALS['appname'].'/index.php?path='.$path); |
---|
1415 | html_form_input ('hidden', 'edit', True); |
---|
1416 | html_form_input ('hidden', 'edit_file', $fileman[$j]); |
---|
1417 | |
---|
1418 | ### |
---|
1419 | # We need to include all of the fileman entries for each file's form, |
---|
1420 | # so we loop through again |
---|
1421 | ### |
---|
1422 | |
---|
1423 | for ($i = 0; $i != $numoffiles; $i++) |
---|
1424 | { |
---|
1425 | html_form_input ('hidden', 'fileman['.$i.']', base64_encode ($fileman[$i])); |
---|
1426 | } |
---|
1427 | |
---|
1428 | html_table_row_begin (); |
---|
1429 | html_table_col_begin (); |
---|
1430 | html_form_textarea ('edit_file_content', 35, 75, $content); |
---|
1431 | html_table_col_end (); |
---|
1432 | html_table_col_begin ('center'); |
---|
1433 | html_form_input ('submit', 'edit_preview', lang('Preview %1', html_encode ($fileman[$j], 1))); |
---|
1434 | html_break (1); |
---|
1435 | html_form_input ('submit', 'edit_save', lang('Save %1', html_encode ($fileman[$j], 1))); |
---|
1436 | // html_break (1); |
---|
1437 | // html_form_input ('submit', 'edit_save_all', lang('Save all')); |
---|
1438 | html_table_col_end (); |
---|
1439 | html_table_row_end (); |
---|
1440 | html_break (2); |
---|
1441 | html_form_end (); |
---|
1442 | html_table_end (); |
---|
1443 | } |
---|
1444 | } |
---|
1445 | } |
---|
1446 | |
---|
1447 | ### |
---|
1448 | # Handle File Uploads |
---|
1449 | ### |
---|
1450 | |
---|
1451 | elseif ($op == 'upload' && $path != '/' && $path != $GLOBALS['fakebase']) |
---|
1452 | { |
---|
1453 | for ($i = 0; $i != $show_upload_boxes; $i++) |
---|
1454 | { |
---|
1455 | if ($badchar = bad_chars ($_FILES['upload_file']['name'][$i], True, True)) |
---|
1456 | { |
---|
1457 | echo $GLOBALS['phpgw']->common->error_list (array (html_encode (lang('File names cannot contain "%1"', $badchar), 1))); |
---|
1458 | |
---|
1459 | continue; |
---|
1460 | } |
---|
1461 | |
---|
1462 | ### |
---|
1463 | # Check to see if the file exists in the database, and get its info at the same time |
---|
1464 | ### |
---|
1465 | |
---|
1466 | $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( |
---|
1467 | 'string' => $path . '/' . $_FILES['upload_file']['name'][$i], |
---|
1468 | 'relatives' => array (RELATIVE_NONE), |
---|
1469 | 'checksubdirs' => False, |
---|
1470 | 'nofiles' => True |
---|
1471 | ) |
---|
1472 | ); |
---|
1473 | |
---|
1474 | $fileinfo = $ls_array[0]; |
---|
1475 | |
---|
1476 | if ($fileinfo['name']) |
---|
1477 | { |
---|
1478 | if ($fileinfo['mime_type'] == 'Directory') |
---|
1479 | { |
---|
1480 | echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); |
---|
1481 | continue; |
---|
1482 | } |
---|
1483 | } |
---|
1484 | |
---|
1485 | if ($_FILES['upload_file']['size'][$i] > 0) |
---|
1486 | { |
---|
1487 | if ($fileinfo['name'] && $fileinfo['deleteable'] != 'N') |
---|
1488 | { |
---|
1489 | $GLOBALS['phpgw']->vfs->set_attributes (array ( |
---|
1490 | 'string' => $_FILES['upload_file']['name'][$i], |
---|
1491 | 'relatives' => array (RELATIVE_ALL), |
---|
1492 | 'attributes' => array ( |
---|
1493 | 'owner_id' => $GLOBALS['userinfo']['username'], |
---|
1494 | 'modifiedby_id' => $GLOBALS['userinfo']['username'], |
---|
1495 | 'modified' => $now, |
---|
1496 | 'size' => $_FILES['upload_file']['size'][$i], |
---|
1497 | 'mime_type' => $_FILES['upload_file']['type'][$i], |
---|
1498 | 'deleteable' => 'Y', |
---|
1499 | 'comment' => stripslashes ($upload_comment[$i]) |
---|
1500 | ) |
---|
1501 | ) |
---|
1502 | ); |
---|
1503 | |
---|
1504 | $GLOBALS['phpgw']->vfs->cp(array ( |
---|
1505 | 'from' => $_FILES['upload_file']['tmp_name'][$i], |
---|
1506 | 'to' => $_FILES['upload_file']['name'][$i], |
---|
1507 | 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) |
---|
1508 | ) |
---|
1509 | ); |
---|
1510 | |
---|
1511 | html_text_summary(lang('Replaced %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); |
---|
1512 | } |
---|
1513 | else |
---|
1514 | { |
---|
1515 | $GLOBALS['phpgw']->vfs->cp (array ( |
---|
1516 | 'from' => $_FILES['upload_file']['tmp_name'][$i], |
---|
1517 | 'to' => $_FILES['upload_file']['name'][$i], |
---|
1518 | 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) |
---|
1519 | ) |
---|
1520 | ); |
---|
1521 | |
---|
1522 | $GLOBALS['phpgw']->vfs->set_attributes (array ( |
---|
1523 | 'string' => $_FILES['upload_file']['name'][$i], |
---|
1524 | 'relatives' => array (RELATIVE_ALL), |
---|
1525 | 'attributes' => array ( |
---|
1526 | 'mime_type' => $_FILES['upload_file']['type'][$i], |
---|
1527 | 'comment' => stripslashes ($upload_comment[$i]) |
---|
1528 | ) |
---|
1529 | ) |
---|
1530 | ); |
---|
1531 | |
---|
1532 | html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); |
---|
1533 | } |
---|
1534 | } |
---|
1535 | elseif ($_FILES['upload_file']['name'][$i]) |
---|
1536 | { |
---|
1537 | $GLOBALS['phpgw']->vfs->touch (array ( |
---|
1538 | 'string' => $_FILES['upload_file']['name'][$i], |
---|
1539 | 'relatives' => array (RELATIVE_ALL) |
---|
1540 | ) |
---|
1541 | ); |
---|
1542 | |
---|
1543 | $GLOBALS['phpgw']->vfs->set_attributes (array ( |
---|
1544 | 'string' => $_FILES['upload_file']['name'][$i], |
---|
1545 | 'relatives' => array (RELATIVE_ALL), |
---|
1546 | 'attributes' => array ( |
---|
1547 | 'mime_type' => $_FILES['upload_file']['type'][$i], |
---|
1548 | 'comment' => $upload_comment[$i] |
---|
1549 | ) |
---|
1550 | ) |
---|
1551 | ); |
---|
1552 | |
---|
1553 | html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $file_size[$i]); |
---|
1554 | } |
---|
1555 | } |
---|
1556 | |
---|
1557 | html_break (2); |
---|
1558 | html_link_back (); |
---|
1559 | } |
---|
1560 | |
---|
1561 | ### |
---|
1562 | # Handle Editing comments |
---|
1563 | ### |
---|
1564 | |
---|
1565 | elseif ($comment_files) |
---|
1566 | { |
---|
1567 | while (list ($file) = each ($comment_files)) |
---|
1568 | { |
---|
1569 | if ($badchar = bad_chars ($comment_files[$file], False, True)) |
---|
1570 | { |
---|
1571 | echo $GLOBALS['phpgw']->common->error_list (array (html_text_italic ($file, 1) . html_encode (': ' . lang('Comments cannot contain "%1"', $badchar), 1))); |
---|
1572 | continue; |
---|
1573 | } |
---|
1574 | |
---|
1575 | $GLOBALS['phpgw']->vfs->set_attributes (array ( |
---|
1576 | 'string' => $file, |
---|
1577 | 'relatives' => array (RELATIVE_ALL), |
---|
1578 | 'attributes' => array ( |
---|
1579 | 'comment' => stripslashes ($comment_files[$file]) |
---|
1580 | ) |
---|
1581 | ) |
---|
1582 | ); |
---|
1583 | |
---|
1584 | html_text_summary (lang('Updated comment for %1', $path.'/'.$file)); |
---|
1585 | } |
---|
1586 | |
---|
1587 | html_break (2); |
---|
1588 | html_link_back (); |
---|
1589 | } |
---|
1590 | |
---|
1591 | ### |
---|
1592 | # Handle Renaming Files and Directories |
---|
1593 | ### |
---|
1594 | |
---|
1595 | elseif ($renamefiles) |
---|
1596 | { |
---|
1597 | while (list ($from, $to) = each ($renamefiles)) |
---|
1598 | { |
---|
1599 | if ($badchar = bad_chars ($to, True, True)) |
---|
1600 | { |
---|
1601 | echo $GLOBALS['phpgw']->common->error_list (array (html_encode (lang('File names cannot contain "%1"', $badchar), 1))); |
---|
1602 | continue; |
---|
1603 | } |
---|
1604 | |
---|
1605 | if (ereg ("/", $to) || ereg ("\\\\", $to)) |
---|
1606 | { |
---|
1607 | echo $GLOBALS['phpgw']->common->error_list (array (lang("File names cannot contain \\ or /"))); |
---|
1608 | } |
---|
1609 | elseif (!$GLOBALS['phpgw']->vfs->mv (array ( |
---|
1610 | 'from' => $from, |
---|
1611 | 'to' => $to |
---|
1612 | )) |
---|
1613 | ) |
---|
1614 | { |
---|
1615 | echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not rename %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to))); |
---|
1616 | } |
---|
1617 | else |
---|
1618 | { |
---|
1619 | html_text_summary (lang('Renamed %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to)); |
---|
1620 | } |
---|
1621 | } |
---|
1622 | |
---|
1623 | html_break (2); |
---|
1624 | html_link_back (); |
---|
1625 | } |
---|
1626 | |
---|
1627 | ### |
---|
1628 | # Handle Moving Files and Directories |
---|
1629 | ### |
---|
1630 | |
---|
1631 | elseif ($move) |
---|
1632 | { |
---|
1633 | while (list ($num, $file) = each ($fileman)) |
---|
1634 | { |
---|
1635 | if ($GLOBALS['phpgw']->vfs->mv (array ( |
---|
1636 | 'from' => $file, |
---|
1637 | 'to' => $todir . '/' . $file, |
---|
1638 | 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) |
---|
1639 | )) |
---|
1640 | ) |
---|
1641 | { |
---|
1642 | $moved++; |
---|
1643 | html_text_summary (lang('Moved %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); |
---|
1644 | } |
---|
1645 | else |
---|
1646 | { |
---|
1647 | echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not move %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); |
---|
1648 | } |
---|
1649 | } |
---|
1650 | |
---|
1651 | if ($moved) |
---|
1652 | { |
---|
1653 | html_break (2); |
---|
1654 | html_link ($GLOBALS['appname'].'/index.php?path='.$todir, lang('Go to %1', $todir)); |
---|
1655 | } |
---|
1656 | |
---|
1657 | html_break (2); |
---|
1658 | html_link_back (); |
---|
1659 | } |
---|
1660 | |
---|
1661 | ### |
---|
1662 | # Handle Copying of Files and Directories |
---|
1663 | ### |
---|
1664 | |
---|
1665 | elseif ($copy) |
---|
1666 | { |
---|
1667 | while (list ($num, $file) = each ($fileman)) |
---|
1668 | { |
---|
1669 | if ($GLOBALS['phpgw']->vfs->cp (array ( |
---|
1670 | 'from' => $file, |
---|
1671 | 'to' => $todir . '/' . $file, |
---|
1672 | 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) |
---|
1673 | )) |
---|
1674 | ) |
---|
1675 | { |
---|
1676 | $copied++; |
---|
1677 | html_text_summary (lang('Copied %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); |
---|
1678 | } |
---|
1679 | else |
---|
1680 | { |
---|
1681 | echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not copy %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); |
---|
1682 | } |
---|
1683 | } |
---|
1684 | |
---|
1685 | if ($copied) |
---|
1686 | { |
---|
1687 | html_break (2); |
---|
1688 | html_link ($GLOBALS['appname'].'/index.php?path='.$todir, lang('Go to %1', $todir)); |
---|
1689 | } |
---|
1690 | |
---|
1691 | html_break (2); |
---|
1692 | html_link_back (); |
---|
1693 | } |
---|
1694 | |
---|
1695 | ### |
---|
1696 | # Handle Deleting Files and Directories |
---|
1697 | ### |
---|
1698 | |
---|
1699 | elseif ($delete) |
---|
1700 | { |
---|
1701 | for ($i = 0; $i != $numoffiles; $i++) |
---|
1702 | { |
---|
1703 | if ($fileman[$i]) |
---|
1704 | { |
---|
1705 | if ($GLOBALS['phpgw']->vfs->delete (array ('string' => $fileman[$i]))) |
---|
1706 | { |
---|
1707 | html_text_summary (lang('Deleted %1', $disppath.'/'.$fileman[$i]), $fileinfo['size']); |
---|
1708 | } |
---|
1709 | else |
---|
1710 | { |
---|
1711 | $GLOBALS['phpgw']->common->error_list (array (lang('Could not delete %1', $disppath.'/'.$fileman[$i]))); |
---|
1712 | } |
---|
1713 | } |
---|
1714 | } |
---|
1715 | |
---|
1716 | html_break (2); |
---|
1717 | html_link_back (); |
---|
1718 | } |
---|
1719 | |
---|
1720 | elseif ($newdir && $createdir) |
---|
1721 | { |
---|
1722 | if ($badchar = bad_chars ($createdir, True, True)) |
---|
1723 | { |
---|
1724 | echo $GLOBALS['phpgw']->common->error_list (array (html_encode (lang('Directory names cannot contain "%1"', $badchar), 1))); |
---|
1725 | html_break (2); |
---|
1726 | html_link_back (); |
---|
1727 | html_page_close (); |
---|
1728 | } |
---|
1729 | |
---|
1730 | if ($createdir[strlen($createdir)-1] == ' ' || $createdir[0] == ' ') |
---|
1731 | { |
---|
1732 | echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot create directory because it begins or ends in a space'))); |
---|
1733 | html_break (2); |
---|
1734 | html_link_back (); |
---|
1735 | html_page_close (); |
---|
1736 | } |
---|
1737 | |
---|
1738 | $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( |
---|
1739 | 'string' => $path . '/' . $createdir, |
---|
1740 | 'relatives' => array (RELATIVE_NONE), |
---|
1741 | 'checksubdirs' => False, |
---|
1742 | 'nofiles' => True |
---|
1743 | ) |
---|
1744 | ); |
---|
1745 | |
---|
1746 | $fileinfo = $ls_array[0]; |
---|
1747 | |
---|
1748 | if ($fileinfo['name']) |
---|
1749 | { |
---|
1750 | if ($fileinfo['mime_type'] != 'Directory') |
---|
1751 | { |
---|
1752 | echo $GLOBALS['phpgw']->common->error_list (array (lang('%1 already exists as a file', $fileinfo['name']))); |
---|
1753 | html_break (2); |
---|
1754 | html_link_back (); |
---|
1755 | html_page_close (); |
---|
1756 | } |
---|
1757 | else |
---|
1758 | { |
---|
1759 | echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 already exists', $fileinfo['name']))); |
---|
1760 | html_break (2); |
---|
1761 | html_link_back (); |
---|
1762 | html_page_close (); |
---|
1763 | } |
---|
1764 | } |
---|
1765 | else |
---|
1766 | { |
---|
1767 | if ($GLOBALS['phpgw']->vfs->mkdir (array ('string' => $createdir))) |
---|
1768 | { |
---|
1769 | html_text_summary (lang('Created directory %1', $disppath.'/'.$createdir)); |
---|
1770 | html_break (2); |
---|
1771 | html_link ($GLOBALS['appname'].'/index.php?path='.$disppath.'/'.$createdir, lang('Go to %1', $disppath.'/'.$createdir)); |
---|
1772 | } |
---|
1773 | else |
---|
1774 | { |
---|
1775 | echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not create %1', $disppath.'/'.$createdir))); |
---|
1776 | } |
---|
1777 | } |
---|
1778 | |
---|
1779 | html_break (2); |
---|
1780 | html_link_back (); |
---|
1781 | } |
---|
1782 | |
---|
1783 | html_page_close (); |
---|
1784 | |
---|
1785 | ?> |
---|