· 6 years ago · Sep 29, 2019, 07:24 PM
1<?php
2/*
3 * webadmin.php - a simple Web-based file manager
4 * Copyright (C) 2004 Daniel Wacker <daniel.wacker@web.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * -------------------------------------------------------------------------
21 * While using this script, do NOT navigate with your browser's back and
22 * forward buttons! Always open files in a new browser tab!
23 * -------------------------------------------------------------------------
24 *
25 * This is Version 0.9, revision 5
26 * =========================================================================
27 *
28 * Changes of revision 5
29 * <daniel.wacker@web.de>
30 * added language auto select
31 * fixed symlinks in directory listing
32 * removed word-wrap in edit textarea
33 *
34 * Changes of revision 4
35 * <daloan@guideo.fr>
36 * added French translation
37 * <anders@wiik.cc>
38 * added Swedish translation
39 *
40 * Changes of revision 3
41 * <nzunta@gabriele-erba.it>
42 * improved Italian translation
43 *
44 * Changes of revision 2
45 * <daniel.wacker@web.de>
46 * got images work in some old browsers
47 * fixed creation of directories
48 * fixed files deletion
49 * improved path handling
50 * added missing word 'not_created'
51 * <till@tuxen.de>
52 * improved human readability of file sizes
53 * <nzunta@gabriele-erba.it>
54 * added Italian translation
55 *
56 * Changes of revision 1
57 * <daniel.wacker@web.de>
58 * webadmin.php completely rewritten:
59 * - clean XHTML/CSS output
60 * - several files selectable
61 * - support for windows servers
62 * - no more treeview, because
63 * - webadmin.php is a >simple< file manager
64 * - performance problems (too much additional code)
65 * - I don't like: frames, java-script, to reload after every treeview-click
66 * - execution of shell scripts
67 * - introduced revision numbers
68 *
69/* ------------------------------------------------------------------------- */
70
71/* Your language:
72 * 'en' - English
73 * 'de' - German
74 * 'fr' - French
75 * 'it' - Italian
76 * 'se' - Swedish
77 * 'auto' - autoselect
78 */
79$lang = 'auto';
80
81/* Charset of your filenames:
82 */
83$charset = 'ISO-8859-1';
84
85/* Homedir:
86 * For example: './' - the script's directory
87 */
88$homedir = './';
89
90/* Size of the edit textarea
91 */
92$editcols = 80;
93$editrows = 25;
94
95/* -------------------------------------------
96 * Optional configuration (remove # to enable)
97 */
98
99/* Permission of created directories:
100 * For example: 0705 would be 'drwx---r-x'.
101 */
102# $dirpermission = 0705;
103
104/* Permission of created files:
105 * For example: 0604 would be '-rw----r--'.
106 */
107# $filepermission = 0604;
108
109/* Filenames related to the apache web server:
110 */
111$htaccess = '.htaccess';
112$htpasswd = '.htpasswd';
113
114/* ------------------------------------------------------------------------- */
115
116if (get_magic_quotes_gpc()) {
117 array_walk($_GET, 'strip');
118 array_walk($_POST, 'strip');
119 array_walk($_REQUEST, 'strip');
120}
121
122if (array_key_exists('image', $_GET)) {
123 header('Content-Type: image/gif');
124 die(getimage($_GET['image']));
125}
126
127$delim = DIRECTORY_SEPARATOR;
128
129if (function_exists('php_uname')) {
130 $win = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false;
131} else {
132 $win = ($delim == '\\') ? true : false;
133}
134
135if (!empty($_SERVER['PATH_TRANSLATED'])) {
136 $scriptdir = dirname($_SERVER['PATH_TRANSLATED']);
137} elseif (!empty($_SERVER['SCRIPT_FILENAME'])) {
138 $scriptdir = dirname($_SERVER['SCRIPT_FILENAME']);
139} elseif (function_exists('getcwd')) {
140 $scriptdir = getcwd();
141} else {
142 $scriptdir = '.';
143}
144$homedir = relative2absolute($homedir, $scriptdir);
145
146$dir = (array_key_exists('dir', $_REQUEST)) ? $_REQUEST['dir'] : $homedir;
147
148if (array_key_exists('olddir', $_POST) && !path_is_relative($_POST['olddir'])) {
149 $dir = relative2absolute($dir, $_POST['olddir']);
150}
151
152$directory = simplify_path(addslash($dir));
153
154$files = array();
155$action = '';
156if (!empty($_POST['submit_all'])) {
157 $action = $_POST['action_all'];
158 for ($i = 0; $i < $_POST['num']; $i++) {
159 if (array_key_exists("checked$i", $_POST) && $_POST["checked$i"] == 'true') {
160 $files[] = $_POST["file$i"];
161 }
162 }
163} elseif (!empty($_REQUEST['action'])) {
164 $action = $_REQUEST['action'];
165 $files[] = relative2absolute($_REQUEST['file'], $directory);
166} elseif (!empty($_POST['submit_upload']) && !empty($_FILES['upload']['name'])) {
167 $files[] = $_FILES['upload'];
168 $action = 'upload';
169} elseif (array_key_exists('num', $_POST)) {
170 for ($i = 0; $i < $_POST['num']; $i++) {
171 if (array_key_exists("submit$i", $_POST)) break;
172 }
173 if ($i < $_POST['num']) {
174 $action = $_POST["action$i"];
175 $files[] = $_POST["file$i"];
176 }
177}
178if (empty($action) && (!empty($_POST['submit_create']) || (array_key_exists('focus', $_POST) && $_POST['focus'] == 'create')) && !empty($_POST['create_name'])) {
179 $files[] = relative2absolute($_POST['create_name'], $directory);
180 switch ($_POST['create_type']) {
181 case 'directory':
182 $action = 'create_directory';
183 break;
184 case 'file':
185 $action = 'create_file';
186 }
187}
188if (sizeof($files) == 0) $action = ''; else $file = reset($files);
189
190if ($lang == 'auto') {
191 if (array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) {
192 $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
193 } else {
194 $lang = 'en';
195 }
196}
197
198$words = getwords($lang);
199
200$cols = ($win) ? 4 : 7;
201
202if (!isset($dirpermission)) {
203 $dirpermission = (function_exists('umask')) ? (0777 & ~umask()) : 0755;
204}
205if (!isset($filepermission)) {
206 $filepermission = (function_exists('umask')) ? (0666 & ~umask()) : 0644;
207}
208
209if (!empty($_SERVER['SCRIPT_NAME'])) {
210 $self = html(basename($_SERVER['SCRIPT_NAME']));
211} elseif (!empty($_SERVER['PHP_SELF'])) {
212 $self = html(basename($_SERVER['PHP_SELF']));
213} else {
214 $self = '';
215}
216
217if (!empty($_SERVER['SERVER_SOFTWARE'])) {
218 if (strtolower(substr($_SERVER['SERVER_SOFTWARE'], 0, 6)) == 'apache') {
219 $apache = true;
220 } else {
221 $apache = false;
222 }
223} else {
224 $apache = true;
225}
226
227switch ($action) {
228
229case 'view':
230
231 if (is_script($file)) {
232
233 /* highlight_file is a mess! */
234 ob_start();
235 highlight_file($file);
236 $src = ereg_replace('<font color="([^"]*)">', '<span style="color: \1">', ob_get_contents());
237 $src = str_replace(array('</font>', "\r", "\n"), array('</span>', '', ''), $src);
238 ob_end_clean();
239
240 html_header();
241 echo '<h2 style="text-align: left; margin-bottom: 0">' . html($file) . '</h2>
242
243<hr />
244
245<table>
246<tr>
247<td style="text-align: right; vertical-align: top; color: gray; padding-right: 3pt; border-right: 1px solid gray">
248<pre style="margin-top: 0"><code>';
249
250 for ($i = 1; $i <= sizeof(file($file)); $i++) echo "$i\n";
251
252 echo '</code></pre>
253</td>
254<td style="text-align: left; vertical-align: top; padding-left: 3pt">
255<pre style="margin-top: 0">' . $src . '</pre>
256</td>
257</tr>
258</table>
259
260';
261
262 html_footer();
263
264 } else {
265
266 header('Content-Type: ' . getmimetype($file));
267 header('Content-Disposition: filename=' . basename($file));
268
269 readfile($file);
270
271 }
272
273 break;
274
275case 'download':
276
277 header('Pragma: public');
278 header('Expires: 0');
279 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
280 header('Content-Type: ' . getmimetype($file));
281 header('Content-Disposition: attachment; filename=' . basename($file) . ';');
282 header('Content-Length: ' . filesize($file));
283
284 readfile($file);
285
286 break;
287
288case 'upload':
289
290 $dest = relative2absolute($file['name'], $directory);
291
292 if (@file_exists($dest)) {
293 listing_page(error('already_exists', $dest));
294 } elseif (@move_uploaded_file($file['tmp_name'], $dest)) {
295 listing_page(notice('uploaded', $file['name']));
296 } else {
297 listing_page(error('not_uploaded', $file['name']));
298 }
299
300 break;
301
302case 'create_directory':
303
304 if (@file_exists($file)) {
305 listing_page(error('already_exists', $file));
306 } else {
307 $old = @umask(0777 & ~$dirpermission);
308 if (@mkdir($file, $dirpermission)) {
309 listing_page(notice('created', $file));
310 } else {
311 listing_page(error('not_created', $file));
312 }
313 @umask($old);
314 }
315
316 break;
317
318case 'create_file':
319
320 if (@file_exists($file)) {
321 listing_page(error('already_exists', $file));
322 } else {
323 $old = @umask(0777 & ~$filepermission);
324 if (@touch($file)) {
325 edit($file);
326 } else {
327 listing_page(error('not_created', $file));
328 }
329 @umask($old);
330 }
331
332 break;
333
334case 'execute':
335
336 chdir(dirname($file));
337
338 $output = array();
339 $retval = 0;
340 exec('echo "./' . basename($file) . '" | /bin/sh', $output, $retval);
341
342 $error = ($retval == 0) ? false : true;
343
344 if (sizeof($output) == 0) $output = array('<' . $words['no_output'] . '>');
345
346 if ($error) {
347 listing_page(error('not_executed', $file, implode("\n", $output)));
348 } else {
349 listing_page(notice('executed', $file, implode("\n", $output)));
350 }
351
352 break;
353
354case 'delete':
355
356 if (!empty($_POST['no'])) {
357 listing_page();
358 } elseif (!empty($_POST['yes'])) {
359
360 $failure = array();
361 $success = array();
362
363 foreach ($files as $file) {
364 if (del($file)) {
365 $success[] = $file;
366 } else {
367 $failure[] = $file;
368 }
369 }
370
371 $message = '';
372 if (sizeof($failure) > 0) {
373 $message = error('not_deleted', implode("\n", $failure));
374 }
375 if (sizeof($success) > 0) {
376 $message .= notice('deleted', implode("\n", $success));
377 }
378
379 listing_page($message);
380
381 } else {
382
383 html_header();
384
385 echo '<form action="' . $self . '" method="post">
386<table class="dialog">
387<tr>
388<td class="dialog">
389';
390
391 request_dump();
392
393 echo "\t<b>" . word('really_delete') . '</b>
394 <p>
395';
396
397 foreach ($files as $file) {
398 echo "\t" . html($file) . "<br />\n";
399 }
400
401 echo ' </p>
402 <hr />
403 <input type="submit" name="no" value="' . word('no') . '" id="red_button" />
404 <input type="submit" name="yes" value="' . word('yes') . '" id="green_button" style="margin-left: 50px" />
405</td>
406</tr>
407</table>
408</form>
409
410';
411
412 html_footer();
413
414 }
415
416 break;
417
418case 'rename':
419
420 if (!empty($_POST['destination'])) {
421
422 $dest = relative2absolute($_POST['destination'], $directory);
423
424 if (!@file_exists($dest) && @rename($file, $dest)) {
425 listing_page(notice('renamed', $file, $dest));
426 } else {
427 listing_page(error('not_renamed', $file, $dest));
428 }
429
430 } else {
431
432 html_header();
433
434 echo '<form action="' . $self . '" method="post">
435
436<table class="dialog">
437<tr>
438<td class="dialog">
439 <input type="hidden" name="action" value="rename" />
440 <input type="hidden" name="file" value="' . html($file) . '" />
441 <input type="hidden" name="dir" value="' . html($directory) . '" />
442 <b>' . word('rename_file') . '</b>
443 <p>' . html($file) . '</p>
444 <hr />
445 ' . word('destination') . ':
446 <input type="text" name="destination" size="' . textfieldsize($file) . '" value="' . html($file) . '" />
447 <input type="submit" value="' . word('rename') . '" />
448</td>
449</tr>
450</table>
451
452<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
453
454</form>
455
456';
457
458 html_footer();
459
460 }
461
462 break;
463
464case 'move':
465
466 if (!empty($_POST['destination'])) {
467
468 $dest = relative2absolute($_POST['destination'], $directory);
469
470 $failure = array();
471 $success = array();
472
473 foreach ($files as $file) {
474 $filename = substr($file, strlen($directory));
475 $d = $dest . $filename;
476 if (!@file_exists($d) && @rename($file, $d)) {
477 $success[] = $file;
478 } else {
479 $failure[] = $file;
480 }
481 }
482
483 $message = '';
484 if (sizeof($failure) > 0) {
485 $message = error('not_moved', implode("\n", $failure), $dest);
486 }
487 if (sizeof($success) > 0) {
488 $message .= notice('moved', implode("\n", $success), $dest);
489 }
490
491 listing_page($message);
492
493 } else {
494
495 html_header();
496
497 echo '<form action="' . $self . '" method="post">
498
499<table class="dialog">
500<tr>
501<td class="dialog">
502';
503
504 request_dump();
505
506 echo "\t<b>" . word('move_files') . '</b>
507 <p>
508';
509
510 foreach ($files as $file) {
511 echo "\t" . html($file) . "<br />\n";
512 }
513
514 echo ' </p>
515 <hr />
516 ' . word('destination') . ':
517 <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
518 <input type="submit" value="' . word('move') . '" />
519</td>
520</tr>
521</table>
522
523<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
524
525</form>
526
527';
528
529 html_footer();
530
531 }
532
533 break;
534
535case 'copy':
536
537 if (!empty($_POST['destination'])) {
538
539 $dest = relative2absolute($_POST['destination'], $directory);
540
541 if (@is_dir($dest)) {
542
543 $failure = array();
544 $success = array();
545
546 foreach ($files as $file) {
547 $filename = substr($file, strlen($directory));
548 $d = addslash($dest) . $filename;
549 if (!@is_dir($file) && !@file_exists($d) && @copy($file, $d)) {
550 $success[] = $file;
551 } else {
552 $failure[] = $file;
553 }
554 }
555
556 $message = '';
557 if (sizeof($failure) > 0) {
558 $message = error('not_copied', implode("\n", $failure), $dest);
559 }
560 if (sizeof($success) > 0) {
561 $message .= notice('copied', implode("\n", $success), $dest);
562 }
563
564 listing_page($message);
565
566 } else {
567
568 if (!@file_exists($dest) && @copy($file, $dest)) {
569 listing_page(notice('copied', $file, $dest));
570 } else {
571 listing_page(error('not_copied', $file, $dest));
572 }
573
574 }
575
576 } else {
577
578 html_header();
579
580 echo '<form action="' . $self . '" method="post">
581
582<table class="dialog">
583<tr>
584<td class="dialog">
585';
586
587 request_dump();
588
589 echo "\n<b>" . word('copy_files') . '</b>
590 <p>
591';
592
593 foreach ($files as $file) {
594 echo "\t" . html($file) . "<br />\n";
595 }
596
597 echo ' </p>
598 <hr />
599 ' . word('destination') . ':
600 <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
601 <input type="submit" value="' . word('copy') . '" />
602</td>
603</tr>
604</table>
605
606<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
607
608</form>
609
610';
611
612 html_footer();
613
614 }
615
616 break;
617
618case 'create_symlink':
619
620 if (!empty($_POST['destination'])) {
621
622 $dest = relative2absolute($_POST['destination'], $directory);
623
624 if (substr($dest, -1, 1) == $delim) $dest .= basename($file);
625
626 if (!empty($_POST['relative'])) $file = absolute2relative(addslash(dirname($dest)), $file);
627
628 if (!@file_exists($dest) && @symlink($file, $dest)) {
629 listing_page(notice('symlinked', $file, $dest));
630 } else {
631 listing_page(error('not_symlinked', $file, $dest));
632 }
633
634 } else {
635
636 html_header();
637
638 echo '<form action="' . $self . '" method="post">
639
640<table class="dialog" id="symlink">
641<tr>
642 <td style="vertical-align: top">' . word('destination') . ': </td>
643 <td>
644 <b>' . html($file) . '</b><br />
645 <input type="checkbox" name="relative" value="yes" id="checkbox_relative" checked="checked" style="margin-top: 1ex" />
646 <label for="checkbox_relative">' . word('relative') . '</label>
647 <input type="hidden" name="action" value="create_symlink" />
648 <input type="hidden" name="file" value="' . html($file) . '" />
649 <input type="hidden" name="dir" value="' . html($directory) . '" />
650 </td>
651</tr>
652<tr>
653 <td>' . word('symlink') . ': </td>
654 <td>
655 <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
656 <input type="submit" value="' . word('create_symlink') . '" />
657 </td>
658</tr>
659</table>
660
661<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
662
663</form>
664
665';
666
667 html_footer();
668
669 }
670
671 break;
672
673case 'edit':
674
675 if (!empty($_POST['save'])) {
676
677 $content = str_replace("\r\n", "\n", $_POST['content']);
678
679 if (($f = @fopen($file, 'w')) && @fwrite($f, $content) !== false && @fclose($f)) {
680 listing_page(notice('saved', $file));
681 } else {
682 listing_page(error('not_saved', $file));
683 }
684
685 } else {
686
687 if (@is_readable($file) && @is_writable($file)) {
688 edit($file);
689 } else {
690 listing_page(error('not_edited', $file));
691 }
692
693 }
694
695 break;
696
697case 'permission':
698
699 if (!empty($_POST['set'])) {
700
701 $mode = 0;
702 if (!empty($_POST['ur'])) $mode |= 0400; if (!empty($_POST['uw'])) $mode |= 0200; if (!empty($_POST['ux'])) $mode |= 0100;
703 if (!empty($_POST['gr'])) $mode |= 0040; if (!empty($_POST['gw'])) $mode |= 0020; if (!empty($_POST['gx'])) $mode |= 0010;
704 if (!empty($_POST['or'])) $mode |= 0004; if (!empty($_POST['ow'])) $mode |= 0002; if (!empty($_POST['ox'])) $mode |= 0001;
705
706 if (@chmod($file, $mode)) {
707 listing_page(notice('permission_set', $file, decoct($mode)));
708 } else {
709 listing_page(error('permission_not_set', $file, decoct($mode)));
710 }
711
712 } else {
713
714 html_header();
715
716 $mode = fileperms($file);
717
718 echo '<form action="' . $self . '" method="post">
719
720<table class="dialog">
721<tr>
722<td class="dialog">
723
724 <p style="margin: 0">' . phrase('permission_for', $file) . '</p>
725
726 <hr />
727
728 <table id="permission">
729 <tr>
730 <td></td>
731 <td style="border-right: 1px solid black">' . word('owner') . '</td>
732 <td style="border-right: 1px solid black">' . word('group') . '</td>
733 <td>' . word('other') . '</td>
734 </tr>
735 <tr>
736 <td style="text-align: right">' . word('read') . ':</td>
737 <td><input type="checkbox" name="ur" value="1"'; if ($mode & 00400) echo ' checked="checked"'; echo ' /></td>
738 <td><input type="checkbox" name="gr" value="1"'; if ($mode & 00040) echo ' checked="checked"'; echo ' /></td>
739 <td><input type="checkbox" name="or" value="1"'; if ($mode & 00004) echo ' checked="checked"'; echo ' /></td>
740 </tr>
741 <tr>
742 <td style="text-align: right">' . word('write') . ':</td>
743 <td><input type="checkbox" name="uw" value="1"'; if ($mode & 00200) echo ' checked="checked"'; echo ' /></td>
744 <td><input type="checkbox" name="gw" value="1"'; if ($mode & 00020) echo ' checked="checked"'; echo ' /></td>
745 <td><input type="checkbox" name="ow" value="1"'; if ($mode & 00002) echo ' checked="checked"'; echo ' /></td>
746 </tr>
747 <tr>
748 <td style="text-align: right">' . word('execute') . ':</td>
749 <td><input type="checkbox" name="ux" value="1"'; if ($mode & 00100) echo ' checked="checked"'; echo ' /></td>
750 <td><input type="checkbox" name="gx" value="1"'; if ($mode & 00010) echo ' checked="checked"'; echo ' /></td>
751 <td><input type="checkbox" name="ox" value="1"'; if ($mode & 00001) echo ' checked="checked"'; echo ' /></td>
752 </tr>
753 </table>
754
755 <hr />
756
757 <input type="submit" name="set" value="' . word('set') . '" />
758
759 <input type="hidden" name="action" value="permission" />
760 <input type="hidden" name="file" value="' . html($file) . '" />
761 <input type="hidden" name="dir" value="' . html($directory) . '" />
762
763</td>
764</tr>
765</table>
766
767<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
768
769</form>
770
771';
772
773 html_footer();
774
775 }
776
777 break;
778
779default:
780
781 listing_page();
782
783}
784
785/* ------------------------------------------------------------------------- */
786
787function getlist ($directory) {
788 global $delim, $win;
789
790 if ($d = @opendir($directory)) {
791
792 while (($filename = @readdir($d)) !== false) {
793
794 $path = $directory . $filename;
795
796 if ($stat = @lstat($path)) {
797
798 $file = array(
799 'filename' => $filename,
800 'path' => $path,
801 'is_file' => @is_file($path),
802 'is_dir' => @is_dir($path),
803 'is_link' => @is_link($path),
804 'is_readable' => @is_readable($path),
805 'is_writable' => @is_writable($path),
806 'size' => $stat['size'],
807 'permission' => $stat['mode'],
808 'owner' => $stat['uid'],
809 'group' => $stat['gid'],
810 'mtime' => @filemtime($path),
811 'atime' => @fileatime($path),
812 'ctime' => @filectime($path)
813 );
814
815 if ($file['is_dir']) {
816 $file['is_executable'] = @file_exists($path . $delim . '.');
817 } else {
818 if (!$win) {
819 $file['is_executable'] = @is_executable($path);
820 } else {
821 $file['is_executable'] = true;
822 }
823 }
824
825 if ($file['is_link']) $file['target'] = @readlink($path);
826
827 if (function_exists('posix_getpwuid')) $file['owner_name'] = @reset(posix_getpwuid($file['owner']));
828 if (function_exists('posix_getgrgid')) $file['group_name'] = @reset(posix_getgrgid($file['group']));
829
830 $files[] = $file;
831
832 }
833
834 }
835
836 return $files;
837
838 } else {
839 return false;
840 }
841
842}
843
844function sortlist (&$list, $key, $reverse) {
845
846 quicksort($list, 0, sizeof($list) - 1, $key);
847
848 if ($reverse) $list = array_reverse($list);
849
850}
851
852function quicksort (&$array, $first, $last, $key) {
853
854 if ($first < $last) {
855
856 $cmp = $array[floor(($first + $last) / 2)][$key];
857
858 $l = $first;
859 $r = $last;
860
861 while ($l <= $r) {
862
863 while ($array[$l][$key] < $cmp) $l++;
864 while ($array[$r][$key] > $cmp) $r--;
865
866 if ($l <= $r) {
867
868 $tmp = $array[$l];
869 $array[$l] = $array[$r];
870 $array[$r] = $tmp;
871
872 $l++;
873 $r--;
874
875 }
876
877 }
878
879 quicksort($array, $first, $r, $key);
880 quicksort($array, $l, $last, $key);
881
882 }
883
884}
885
886function permission_octal2string ($mode) {
887
888 if (($mode & 0xC000) === 0xC000) {
889 $type = 's';
890 } elseif (($mode & 0xA000) === 0xA000) {
891 $type = 'l';
892 } elseif (($mode & 0x8000) === 0x8000) {
893 $type = '-';
894 } elseif (($mode & 0x6000) === 0x6000) {
895 $type = 'b';
896 } elseif (($mode & 0x4000) === 0x4000) {
897 $type = 'd';
898 } elseif (($mode & 0x2000) === 0x2000) {
899 $type = 'c';
900 } elseif (($mode & 0x1000) === 0x1000) {
901 $type = 'p';
902 } else {
903 $type = '?';
904 }
905
906 $owner = ($mode & 00400) ? 'r' : '-';
907 $owner .= ($mode & 00200) ? 'w' : '-';
908 if ($mode & 0x800) {
909 $owner .= ($mode & 00100) ? 's' : 'S';
910 } else {
911 $owner .= ($mode & 00100) ? 'x' : '-';
912 }
913
914 $group = ($mode & 00040) ? 'r' : '-';
915 $group .= ($mode & 00020) ? 'w' : '-';
916 if ($mode & 0x400) {
917 $group .= ($mode & 00010) ? 's' : 'S';
918 } else {
919 $group .= ($mode & 00010) ? 'x' : '-';
920 }
921
922 $other = ($mode & 00004) ? 'r' : '-';
923 $other .= ($mode & 00002) ? 'w' : '-';
924 if ($mode & 0x200) {
925 $other .= ($mode & 00001) ? 't' : 'T';
926 } else {
927 $other .= ($mode & 00001) ? 'x' : '-';
928 }
929
930 return $type . $owner . $group . $other;
931
932}
933
934function is_script ($filename) {
935 return ereg('\.php$|\.php3$|\.php4$|\.php5$', $filename);
936}
937
938function getmimetype ($filename) {
939 static $mimes = array(
940 '\.jpg$|\.jpeg$' => 'image/jpeg',
941 '\.gif$' => 'image/gif',
942 '\.png$' => 'image/png',
943 '\.html$|\.html$' => 'text/html',
944 '\.txt$|\.asc$' => 'text/plain',
945 '\.xml$|\.xsl$' => 'application/xml',
946 '\.pdf$' => 'application/pdf'
947 );
948
949 foreach ($mimes as $regex => $mime) {
950 if (eregi($regex, $filename)) return $mime;
951 }
952
953 // return 'application/octet-stream';
954 return 'text/plain';
955
956}
957
958function del ($file) {
959 global $delim;
960
961 if (!@is_link($file) && !file_exists($file)) return false;
962
963 if (!@is_link($file) && @is_dir($file)) {
964
965 if ($dir = @opendir($file)) {
966
967 $error = false;
968
969 while (($f = readdir($dir)) !== false) {
970 if ($f != '.' && $f != '..' && !del($file . $delim . $f)) {
971 $error = true;
972 }
973 }
974 closedir($dir);
975
976 if (!$error) return @rmdir($file);
977
978 return !$error;
979
980 } else {
981 return false;
982 }
983
984 } else {
985 return @unlink($file);
986 }
987
988}
989
990function addslash ($directory) {
991 global $delim;
992
993 if (substr($directory, -1, 1) != $delim) {
994 return $directory . $delim;
995 } else {
996 return $directory;
997 }
998
999}
1000
1001function relative2absolute ($string, $directory) {
1002
1003 if (path_is_relative($string)) {
1004 return simplify_path(addslash($directory) . $string);
1005 } else {
1006 return simplify_path($string);
1007 }
1008
1009}
1010
1011function path_is_relative ($path) {
1012 global $win;
1013
1014 if ($win) {
1015 return (substr($path, 1, 1) != ':');
1016 } else {
1017 return (substr($path, 0, 1) != '/');
1018 }
1019
1020}
1021
1022function absolute2relative ($directory, $target) {
1023 global $delim;
1024
1025 $path = '';
1026 while ($directory != $target) {
1027 if ($directory == substr($target, 0, strlen($directory))) {
1028 $path .= substr($target, strlen($directory));
1029 break;
1030 } else {
1031 $path .= '..' . $delim;
1032 $directory = substr($directory, 0, strrpos(substr($directory, 0, -1), $delim) + 1);
1033 }
1034 }
1035 if ($path == '') $path = '.';
1036
1037 return $path;
1038
1039}
1040
1041function simplify_path ($path) {
1042 global $delim;
1043
1044 if (@file_exists($path) && function_exists('realpath') && @realpath($path) != '') {
1045 $path = realpath($path);
1046 if (@is_dir($path)) {
1047 return addslash($path);
1048 } else {
1049 return $path;
1050 }
1051 }
1052
1053 $pattern = $delim . '.' . $delim;
1054
1055 if (@is_dir($path)) {
1056 $path = addslash($path);
1057 }
1058
1059 while (strpos($path, $pattern) !== false) {
1060 $path = str_replace($pattern, $delim, $path);
1061 }
1062
1063 $e = addslashes($delim);
1064 $regex = $e . '((\.[^\.' . $e . '][^' . $e . ']*)|(\.\.[^' . $e . ']+)|([^\.][^' . $e . ']*))' . $e . '\.\.' . $e;
1065
1066 while (ereg($regex, $path)) {
1067 $path = ereg_replace($regex, $delim, $path);
1068 }
1069
1070 return $path;
1071
1072}
1073
1074function human_filesize ($filesize) {
1075
1076 $suffices = 'kMGTPE';
1077
1078 $n = 0;
1079 while ($filesize >= 1000) {
1080 $filesize /= 1024;
1081 $n++;
1082 }
1083
1084 $filesize = round($filesize, 3 - strpos($filesize, '.'));
1085
1086 if (strpos($filesize, '.') !== false) {
1087 while (in_array(substr($filesize, -1, 1), array('0', '.'))) {
1088 $filesize = substr($filesize, 0, strlen($filesize) - 1);
1089 }
1090 }
1091
1092 $suffix = (($n == 0) ? '' : substr($suffices, $n - 1, 1));
1093
1094 return $filesize . " {$suffix}B";
1095
1096}
1097
1098function strip (&$str) {
1099 $str = stripslashes($str);
1100}
1101
1102/* ------------------------------------------------------------------------- */
1103
1104function listing_page ($message = null) {
1105 global $self, $directory, $sort, $reverse;
1106
1107 html_header();
1108
1109 $list = getlist($directory);
1110
1111 if (array_key_exists('sort', $_GET)) $sort = $_GET['sort']; else $sort = 'filename';
1112 if (array_key_exists('reverse', $_GET) && $_GET['reverse'] == 'true') $reverse = true; else $reverse = false;
1113
1114 sortlist($list, $sort, $reverse);
1115
1116 echo '<h1 style="margin-bottom: 0">phpinfo</h1>
1117
1118<form enctype="multipart/form-data" action="' . $self . '" method="post">
1119
1120<table id="main">
1121';
1122
1123 directory_choice();
1124
1125 if (!empty($message)) {
1126 spacer();
1127 echo $message;
1128 }
1129
1130 if (@is_writable($directory)) {
1131 upload_box();
1132 create_box();
1133 } else {
1134 spacer();
1135 }
1136
1137 if ($list) {
1138 listing($list);
1139 } else {
1140 echo error('not_readable', $directory);
1141 }
1142
1143 echo '</table>
1144
1145</form>
1146
1147';
1148
1149 html_footer();
1150
1151}
1152
1153function listing ($list) {
1154 global $directory, $homedir, $sort, $reverse, $win, $cols, $date_format, $self;
1155
1156 echo '<tr class="listing">
1157 <th style="text-align: center; vertical-align: middle"><img src="' . $self . '?image=smiley" alt="smiley" /></th>
1158';
1159
1160 $d = 'dir=' . urlencode($directory) . '&';
1161
1162 if (!$reverse && $sort == 'filename') $r = '&reverse=true'; else $r = '';
1163 echo "\t<th class=\"filename\"><a href=\"$self?{$d}sort=filename$r\">" . word('filename') . "</a></th>\n";
1164
1165 if (!$reverse && $sort == 'size') $r = '&reverse=true'; else $r = '';
1166 echo "\t<th class=\"size\"><a href=\"$self?{$d}sort=size$r\">" . word('size') . "</a></th>\n";
1167
1168 if (!$win) {
1169
1170 if (!$reverse && $sort == 'permission') $r = '&reverse=true'; else $r = '';
1171 echo "\t<th class=\"permission_header\"><a href=\"$self?{$d}sort=permission$r\">" . word('permission') . "</a></th>\n";
1172
1173 if (!$reverse && $sort == 'owner') $r = '&reverse=true'; else $r = '';
1174 echo "\t<th class=\"owner\"><a href=\"$self?{$d}sort=owner$r\">" . word('owner') . "</a></th>\n";
1175
1176 if (!$reverse && $sort == 'group') $r = '&reverse=true'; else $r = '';
1177 echo "\t<th class=\"group\"><a href=\"$self?{$d}sort=group$r\">" . word('group') . "</a></th>\n";
1178
1179 }
1180
1181 echo ' <th class="functions">' . word('functions') . '</th>
1182</tr>
1183';
1184
1185 for ($i = 0; $i < sizeof($list); $i++) {
1186 $file = $list[$i];
1187
1188 $timestamps = 'mtime: ' . date($date_format, $file['mtime']) . ', ';
1189 $timestamps .= 'atime: ' . date($date_format, $file['atime']) . ', ';
1190 $timestamps .= 'ctime: ' . date($date_format, $file['ctime']);
1191
1192 echo '<tr class="listing">
1193 <td class="checkbox"><input type="checkbox" name="checked' . $i . '" value="true" onfocus="activate(\'other\')" /></td>
1194 <td class="filename" title="' . html($timestamps) . '">';
1195
1196 if ($file['is_link']) {
1197
1198 echo '<img src="' . $self . '?image=link" alt="link" /> ';
1199 echo html($file['filename']) . ' → ';
1200
1201 $real_file = relative2absolute($file['target'], $directory);
1202
1203 if (@is_readable($real_file)) {
1204 if (@is_dir($real_file)) {
1205 echo '[ <a href="' . $self . '?dir=' . urlencode($real_file) . '">' . html($file['target']) . '</a> ]';
1206 } else {
1207 echo '<a href="' . $self . '?action=view&file=' . urlencode($real_file) . '">' . html($file['target']) . '</a>';
1208 }
1209 } else {
1210 echo html($file['target']);
1211 }
1212
1213 } elseif ($file['is_dir']) {
1214
1215 echo '<img src="' . $self . '?image=folder" alt="folder" /> [ ';
1216 if ($win || $file['is_executable']) {
1217 echo '<a href="' . $self . '?dir=' . urlencode($file['path']) . '">' . html($file['filename']) . '</a>';
1218 } else {
1219 echo html($file['filename']);
1220 }
1221 echo ' ]';
1222
1223 } else {
1224
1225 if (substr($file['filename'], 0, 1) == '.') {
1226 echo '<img src="' . $self . '?image=hidden_file" alt="hidden file" /> ';
1227 } else {
1228 echo '<img src="' . $self . '?image=file" alt="file" /> ';
1229 }
1230
1231 if ($file['is_file'] && $file['is_readable']) {
1232 echo '<a href="' . $self . '?action=view&file=' . urlencode($file['path']) . '">' . html($file['filename']) . '</a>';
1233 } else {
1234 echo html($file['filename']);
1235 }
1236
1237 }
1238
1239 if ($file['size'] >= 1000) {
1240 $human = ' title="' . human_filesize($file['size']) . '"';
1241 } else {
1242 $human = '';
1243 }
1244
1245 echo "\t<td class=\"size\"$human>{$file['size']} B</td>\n";
1246
1247 if (!$win) {
1248
1249 echo "\t<td class=\"permission\" title=\"" . decoct($file['permission']) . '">';
1250
1251 $l = !$file['is_link'] && (!function_exists('posix_getuid') || $file['owner'] == posix_getuid());
1252 if ($l) echo '<a href="' . $self . '?action=permission&file=' . urlencode($file['path']) . '&dir=' . urlencode($directory) . '">';
1253 echo html(permission_octal2string($file['permission']));
1254 if ($l) echo '</a>';
1255
1256 echo "</td>\n";
1257
1258 if (array_key_exists('owner_name', $file)) {
1259 echo "\t<td class=\"owner\" title=\"uid: {$file['owner']}\">{$file['owner_name']}</td>\n";
1260 } else {
1261 echo "\t<td class=\"owner\">{$file['owner']}</td>\n";
1262 }
1263
1264 if (array_key_exists('group_name', $file)) {
1265 echo "\t<td class=\"group\" title=\"gid: {$file['group']}\">{$file['group_name']}</td>\n";
1266 } else {
1267 echo "\t<td class=\"group\">{$file['group']}</td>\n";
1268 }
1269
1270 }
1271
1272 echo ' <td class="functions">
1273 <input type="hidden" name="file' . $i . '" value="' . html($file['path']) . '" />
1274';
1275
1276 $actions = array();
1277 if (function_exists('symlink')) {
1278 $actions[] = 'create_symlink';
1279 }
1280 if (@is_writable(dirname($file['path']))) {
1281 $actions[] = 'delete';
1282 $actions[] = 'rename';
1283 $actions[] = 'move';
1284 }
1285 if ($file['is_file'] && $file['is_readable']) {
1286 $actions[] = 'copy';
1287 $actions[] = 'download';
1288 if ($file['is_writable']) $actions[] = 'edit';
1289 }
1290 if (!$win && function_exists('exec') && $file['is_file'] && $file['is_executable'] && file_exists('/bin/sh')) {
1291 $actions[] = 'execute';
1292 }
1293
1294 if (sizeof($actions) > 0) {
1295
1296 echo ' <select class="small" name="action' . $i . '" size="1">
1297 <option value="">' . str_repeat(' ', 30) . '</option>
1298';
1299
1300 foreach ($actions as $action) {
1301 echo "\t\t<option value=\"$action\">" . word($action) . "</option>\n";
1302 }
1303
1304 echo ' </select>
1305 <input class="small" type="submit" name="submit' . $i . '" value=" > " onfocus="activate(\'other\')" />
1306';
1307
1308 }
1309
1310 echo ' </td>
1311</tr>
1312';
1313
1314 }
1315
1316 echo '<tr class="listing_footer">
1317 <td style="text-align: right; vertical-align: top"><img src="' . $self . '?image=arrow" alt=">" /></td>
1318 <td colspan="' . ($cols - 1) . '">
1319 <input type="hidden" name="num" value="' . sizeof($list) . '" />
1320 <input type="hidden" name="focus" value="" />
1321 <input type="hidden" name="olddir" value="' . html($directory) . '" />
1322';
1323
1324 $actions = array();
1325 if (@is_writable(dirname($file['path']))) {
1326 $actions[] = 'delete';
1327 $actions[] = 'move';
1328 }
1329 $actions[] = 'copy';
1330
1331 echo ' <select class="small" name="action_all" size="1">
1332 <option value="">' . str_repeat(' ', 30) . '</option>
1333';
1334
1335 foreach ($actions as $action) {
1336 echo "\t\t<option value=\"$action\">" . word($action) . "</option>\n";
1337 }
1338
1339 echo ' </select>
1340 <input class="small" type="submit" name="submit_all" value=" > " onfocus="activate(\'other\')" />
1341 </td>
1342</tr>
1343';
1344
1345}
1346
1347function directory_choice () {
1348 global $directory, $homedir, $cols, $self;
1349
1350 echo '<tr>
1351 <td colspan="' . $cols . '" id="directory">
1352 <a href="' . $self . '?dir=' . urlencode($homedir) . '">' . word('directory') . '</a>:
1353 <input type="text" name="dir" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" onfocus="activate(\'directory\')" />
1354 <input type="submit" name="changedir" value="' . word('change') . '" onfocus="activate(\'directory\')" />
1355 </td>
1356</tr>
1357';
1358
1359}
1360
1361function upload_box () {
1362 global $cols;
1363
1364 echo '<tr>
1365 <td colspan="' . $cols . '" id="upload">
1366 ' . word('file') . ':
1367 <input type="file" name="upload" onfocus="activate(\'other\')" />
1368 <input type="submit" name="submit_upload" value="' . word('upload') . '" onfocus="activate(\'other\')" />
1369 </td>
1370</tr>
1371';
1372
1373}
1374
1375function create_box () {
1376 global $cols;
1377
1378 echo '<tr>
1379 <td colspan="' . $cols . '" id="create">
1380 <select name="create_type" size="1" onfocus="activate(\'create\')">
1381 <option value="file">' . word('file') . '</option>
1382 <option value="directory">' . word('directory') . '</option>
1383 </select>
1384 <input type="text" name="create_name" onfocus="activate(\'create\')" />
1385 <input type="submit" name="submit_create" value="' . word('create') . '" onfocus="activate(\'create\')" />
1386 </td>
1387</tr>
1388';
1389
1390}
1391
1392function edit ($file) {
1393 global $self, $directory, $editcols, $editrows, $apache, $htpasswd, $htaccess;
1394
1395 html_header();
1396
1397 echo '<h2 style="margin-bottom: 3pt">' . html($file) . '</h2>
1398
1399<form action="' . $self . '" method="post">
1400
1401<table class="dialog">
1402<tr>
1403<td class="dialog">
1404
1405 <textarea name="content" cols="' . $editcols . '" rows="' . $editrows . '" WRAP="off">';
1406
1407 if (array_key_exists('content', $_POST)) {
1408 echo $_POST['content'];
1409 } else {
1410 $f = fopen($file, 'r');
1411 while (!feof($f)) {
1412 echo html(fread($f, 8192));
1413 }
1414 fclose($f);
1415 }
1416
1417 if (!empty($_POST['user'])) {
1418 echo "\n" . $_POST['user'] . ':' . crypt($_POST['password']);
1419 }
1420 if (!empty($_POST['basic_auth'])) {
1421 if ($win) {
1422 $authfile = str_replace('\\', '/', $directory) . $htpasswd;
1423 } else {
1424 $authfile = $directory . $htpasswd;
1425 }
1426 echo "\nAuthType Basic\nAuthName "Restricted Directory"\n";
1427 echo 'AuthUserFile "' . html($authfile) . ""\n";
1428 echo 'Require valid-user';
1429 }
1430
1431 echo '</textarea>
1432
1433 <hr />
1434';
1435
1436 if ($apache && basename($file) == $htpasswd) {
1437 echo '
1438 ' . word('user') . ': <input type="text" name="user" />
1439 ' . word('password') . ': <input type="password" name="password" />
1440 <input type="submit" value="' . word('add') . '" />
1441
1442 <hr />
1443';
1444
1445 }
1446
1447 if ($apache && basename($file) == $htaccess) {
1448 echo '
1449 <input type="submit" name="basic_auth" value="' . word('add_basic_auth') . '" />
1450
1451 <hr />
1452';
1453
1454 }
1455
1456 echo '
1457 <input type="hidden" name="action" value="edit" />
1458 <input type="hidden" name="file" value="' . html($file) . '" />
1459 <input type="hidden" name="dir" value="' . html($directory) . '" />
1460 <input type="reset" value="' . word('reset') . '" id="red_button" />
1461 <input type="submit" name="save" value="' . word('save') . '" id="green_button" style="margin-left: 50px" />
1462
1463</td>
1464</tr>
1465</table>
1466
1467<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
1468
1469</form>
1470
1471';
1472
1473 html_footer();
1474
1475}
1476
1477function spacer () {
1478 global $cols;
1479
1480 echo '<tr>
1481 <td colspan="' . $cols . '" style="height: 1em"></td>
1482</tr>
1483';
1484
1485}
1486
1487function textfieldsize ($content) {
1488
1489 $size = strlen($content) + 5;
1490 if ($size < 30) $size = 30;
1491
1492 return $size;
1493
1494}
1495
1496function request_dump () {
1497
1498 foreach ($_REQUEST as $key => $value) {
1499 echo "\t<input type=\"hidden\" name=\"" . html($key) . '" value="' . html($value) . "\" />\n";
1500 }
1501
1502}
1503
1504/* ------------------------------------------------------------------------- */
1505
1506function html ($string) {
1507 global $charset;
1508 return htmlentities($string, ENT_COMPAT, $charset);
1509}
1510
1511function word ($word) {
1512 global $words, $word_charset;
1513 return htmlentities($words[$word], ENT_COMPAT, $word_charset);
1514}
1515
1516function phrase ($phrase, $arguments) {
1517 global $words;
1518 static $search;
1519
1520 if (!is_array($search)) for ($i = 1; $i <= 8; $i++) $search[] = "%$i";
1521
1522 for ($i = 0; $i < sizeof($arguments); $i++) {
1523 $arguments[$i] = nl2br(html($arguments[$i]));
1524 }
1525
1526 $replace = array('{' => '<pre>', '}' =>'</pre>', '[' => '<b>', ']' => '</b>');
1527
1528 return str_replace($search, $arguments, str_replace(array_keys($replace), $replace, nl2br(html($words[$phrase]))));
1529
1530}
1531
1532function getwords ($lang) {
1533 global $word_charset, $date_format;
1534
1535 switch ($lang) {
1536 case 'de':
1537
1538 $date_format = 'd.m.y H:i:s';
1539 $word_charset = 'ISO-8859-1';
1540
1541 return array(
1542'directory' => 'Verzeichnis',
1543'file' => 'Datei',
1544'filename' => 'Dateiname',
1545
1546'size' => 'Gro?e',
1547'permission' => 'Rechte',
1548'owner' => 'Eigner',
1549'group' => 'Gruppe',
1550'other' => 'Andere',
1551'functions' => 'Funktionen',
1552
1553'read' => 'lesen',
1554'write' => 'schreiben',
1555'execute' => 'ausfuhren',
1556
1557'create_symlink' => 'Symlink erstellen',
1558'delete' => 'loschen',
1559'rename' => 'umbenennen',
1560'move' => 'verschieben',
1561'copy' => 'kopieren',
1562'edit' => 'editieren',
1563'download' => 'herunterladen',
1564'upload' => 'hochladen',
1565'create' => 'erstellen',
1566'change' => 'wechseln',
1567'save' => 'speichern',
1568'set' => 'setze',
1569'reset' => 'zurucksetzen',
1570'relative' => 'Pfad zum Ziel relativ',
1571
1572'yes' => 'Ja',
1573'no' => 'Nein',
1574'back' => 'zuruck',
1575'destination' => 'Ziel',
1576'symlink' => 'Symbolischer Link',
1577'no_output' => 'keine Ausgabe',
1578
1579'user' => 'Benutzername',
1580'password' => 'Kennwort',
1581'add' => 'hinzufugen',
1582'add_basic_auth' => 'HTTP-Basic-Auth hinzufugen',
1583
1584'uploaded' => '"[%1]" wurde hochgeladen.',
1585'not_uploaded' => '"[%1]" konnte nicht hochgeladen werden.',
1586'already_exists' => '"[%1]" existiert bereits.',
1587'created' => '"[%1]" wurde erstellt.',
1588'not_created' => '"[%1]" konnte nicht erstellt werden.',
1589'really_delete' => 'Sollen folgende Dateien wirklich geloscht werden?',
1590'deleted' => "Folgende Dateien wurden geloscht:\n[%1]",
1591'not_deleted' => "Folgende Dateien konnten nicht geloscht werden:\n[%1]",
1592'rename_file' => 'Benenne Datei um:',
1593'renamed' => '"[%1]" wurde in "[%2]" umbenannt.',
1594'not_renamed' => '"[%1] konnte nicht in "[%2]" umbenannt werden.',
1595'move_files' => 'Verschieben folgende Dateien:',
1596'moved' => "Folgende Dateien wurden nach \"[%2]\" verschoben:\n[%1]",
1597'not_moved' => "Folgende Dateien konnten nicht nach \"[%2]\" verschoben werden:\n[%1]",
1598'copy_files' => 'Kopiere folgende Dateien:',
1599'copied' => "Folgende Dateien wurden nach \"[%2]\" kopiert:\n[%1]",
1600'not_copied' => "Folgende Dateien konnten nicht nach \"[%2]\" kopiert werden:\n[%1]",
1601'not_edited' => '"[%1]" kann nicht editiert werden.',
1602'executed' => "\"[%1]\" wurde erfolgreich ausgefuhrt:\n{%2}",
1603'not_executed' => "\"[%1]\" konnte nicht erfolgreich ausgefuhrt werden:\n{%2}",
1604'saved' => '"[%1]" wurde gespeichert.',
1605'not_saved' => '"[%1]" konnte nicht gespeichert werden.',
1606'symlinked' => 'Symbolischer Link von "[%2]" nach "[%1]" wurde erstellt.',
1607'not_symlinked' => 'Symbolischer Link von "[%2]" nach "[%1]" konnte nicht erstellt werden.',
1608'permission_for' => 'Rechte fur "[%1]":',
1609'permission_set' => 'Die Rechte fur "[%1]" wurden auf [%2] gesetzt.',
1610'permission_not_set' => 'Die Rechte fur "[%1]" konnten nicht auf [%2] gesetzt werden.',
1611'not_readable' => '"[%1]" kann nicht gelesen werden.'
1612 );
1613
1614 case 'fr':
1615
1616 $date_format = 'd.m.y H:i:s';
1617 $word_charset = 'ISO-8859-1';
1618
1619 return array(
1620'directory' => 'Repertoire',
1621'file' => 'Fichier',
1622'filename' => 'Nom fichier',
1623
1624'size' => 'Taille',
1625'permission' => 'Droits',
1626'owner' => 'Proprietaire',
1627'group' => 'Groupe',
1628'other' => 'Autres',
1629'functions' => 'Fonctions',
1630
1631'read' => 'Lire',
1632'write' => 'Ecrire',
1633'execute' => 'Executer',
1634
1635'create_symlink' => 'Creer lien symbolique',
1636'delete' => 'Effacer',
1637'rename' => 'Renommer',
1638'move' => 'Deplacer',
1639'copy' => 'Copier',
1640'edit' => 'Ouvrir',
1641'download' => 'Telecharger sur PC',
1642'upload' => 'Telecharger sur serveur',
1643'create' => 'Creer',
1644'change' => 'Changer',
1645'save' => 'Sauvegarder',
1646'set' => 'Executer',
1647'reset' => 'Reinitialiser',
1648'relative' => 'Relatif',
1649
1650'yes' => 'Oui',
1651'no' => 'Non',
1652'back' => 'Retour',
1653'destination' => 'Destination',
1654'symlink' => 'Lien symbollique',
1655'no_output' => 'Pas de sortie',
1656
1657'user' => 'Utilisateur',
1658'password' => 'Mot de passe',
1659'add' => 'Ajouter',
1660'add_basic_auth' => 'add basic-authentification',
1661
1662'uploaded' => '"[%1]" a ete telecharge sur le serveur.',
1663'not_uploaded' => '"[%1]" n a pas ete telecharge sur le serveur.',
1664'already_exists' => '"[%1]" existe deja.',
1665'created' => '"[%1]" a ete cree.',
1666'not_created' => '"[%1]" n a pas pu etre cree.',
1667'really_delete' => 'Effacer le fichier?',
1668'deleted' => "Ces fichiers ont ete detuits:\n[%1]",
1669'not_deleted' => "Ces fichiers n ont pu etre detruits:\n[%1]",
1670'rename_file' => 'Renomme fichier:',
1671'renamed' => '"[%1]" a ete renomme en "[%2]".',
1672'not_renamed' => '"[%1] n a pas pu etre renomme en "[%2]".',
1673'move_files' => 'Deplacer ces fichiers:',
1674'moved' => "Ces fichiers ont ete deplaces en \"[%2]\":\n[%1]",
1675'not_moved' => "Ces fichiers n ont pas pu etre deplaces en \"[%2]\":\n[%1]",
1676'copy_files' => 'Copier ces fichiers:',
1677'copied' => "Ces fichiers ont ete copies en \"[%2]\":\n[%1]",
1678'not_copied' => "Ces fichiers n ont pas pu etre copies en \"[%2]\":\n[%1]",
1679'not_edited' => '"[%1]" ne peut etre ouvert.',
1680'executed' => "\"[%1]\" a ete brillamment execute :\n{%2}",
1681'not_executed' => "\"[%1]\" n a pas pu etre execute:\n{%2}",
1682'saved' => '"[%1]" a ete sauvegarde.',
1683'not_saved' => '"[%1]" n a pas pu etre sauvegarde.',
1684'symlinked' => 'Un lien symbolique depuis "[%2]" vers "[%1]" a ete cree.',
1685'not_symlinked' => 'Un lien symbolique depuis "[%2]" vers "[%1]" n a pas pu etre cree.',
1686'permission_for' => 'Droits de "[%1]":',
1687'permission_set' => 'Droits de "[%1]" ont ete changes en [%2].',
1688'permission_not_set' => 'Droits de "[%1]" n ont pas pu etre changes en[%2].',
1689'not_readable' => '"[%1]" ne peut pas etre ouvert.'
1690 );
1691
1692 case 'it':
1693
1694 $date_format = 'd-m-Y H:i:s';
1695 $word_charset = 'ISO-8859-1';
1696
1697 return array(
1698'directory' => 'Directory',
1699'file' => 'File',
1700'filename' => 'Nome File',
1701
1702'size' => 'Dimensioni',
1703'permission' => 'Permessi',
1704'owner' => 'Proprietario',
1705'group' => 'Gruppo',
1706'other' => 'Altro',
1707'functions' => 'Funzioni',
1708
1709'read' => 'leggi',
1710'write' => 'scrivi',
1711'execute' => 'esegui',
1712
1713'create_symlink' => 'crea link simbolico',
1714'delete' => 'cancella',
1715'rename' => 'rinomina',
1716'move' => 'sposta',
1717'copy' => 'copia',
1718'edit' => 'modifica',
1719'download' => 'download',
1720'upload' => 'upload',
1721'create' => 'crea',
1722'change' => 'cambia',
1723'save' => 'salva',
1724'set' => 'imposta',
1725'reset' => 'reimposta',
1726'relative' => 'Percorso relativo per la destinazione',
1727
1728'yes' => 'Si',
1729'no' => 'No',
1730'back' => 'indietro',
1731'destination' => 'Destinazione',
1732'symlink' => 'Link simbolico',
1733'no_output' => 'no output',
1734
1735'user' => 'User',
1736'password' => 'Password',
1737'add' => 'aggiungi',
1738'add_basic_auth' => 'aggiungi autenticazione base',
1739
1740'uploaded' => '"[%1]" e stato caricato.',
1741'not_uploaded' => '"[%1]" non e stato caricato.',
1742'already_exists' => '"[%1]" esiste gia.',
1743'created' => '"[%1]" e stato creato.',
1744'not_created' => '"[%1]" non e stato creato.',
1745'really_delete' => 'Cancello questi file ?',
1746'deleted' => "Questi file sono stati cancellati:\n[%1]",
1747'not_deleted' => "Questi file non possono essere cancellati:\n[%1]",
1748'rename_file' => 'File rinominato:',
1749'renamed' => '"[%1]" e stato rinominato in "[%2]".',
1750'not_renamed' => '"[%1] non e stato rinominato in "[%2]".',
1751'move_files' => 'Sposto questi file:',
1752'moved' => "Questi file sono stati spostati in \"[%2]\":\n[%1]",
1753'not_moved' => "Questi file non possono essere spostati in \"[%2]\":\n[%1]",
1754'copy_files' => 'Copio questi file',
1755'copied' => "Questi file sono stati copiati in \"[%2]\":\n[%1]",
1756'not_copied' => "Questi file non possono essere copiati in \"[%2]\":\n[%1]",
1757'not_edited' => '"[%1]" non puo essere modificato.',
1758'executed' => "\"[%1]\" e stato eseguito con successo:\n{%2}",
1759'not_executed' => "\"[%1]\" non e stato eseguito con successo\n{%2}",
1760'saved' => '"[%1]" e stato salvato.',
1761'not_saved' => '"[%1]" non e stato salvato.',
1762'symlinked' => 'Il link siambolico da "[%2]" a "[%1]" e stato creato.',
1763'not_symlinked' => 'Il link siambolico da "[%2]" a "[%1]" non e stato creato.',
1764'permission_for' => 'Permessi di "[%1]":',
1765'permission_set' => 'I permessi di "[%1]" sono stati impostati [%2].',
1766'permission_not_set' => 'I permessi di "[%1]" non sono stati impostati [%2].',
1767'not_readable' => '"[%1]" non puo essere letto.'
1768 );
1769
1770 case 'se':
1771
1772 $date_format = 'n/j/y H:i:s';
1773 $word_charset = 'ISO-8859-1';
1774
1775 return array(
1776'directory' => 'Mapp',
1777'file' => 'Fil',
1778'filename' => 'Filnamn',
1779
1780'size' => 'Storlek',
1781'permission' => 'Sakerhetsniva',
1782'owner' => 'Agare',
1783'group' => 'Grupp',
1784'other' => 'Andra',
1785'functions' => 'Funktioner',
1786
1787'read' => 'Las',
1788'write' => 'Skriv',
1789'execute' => 'Utfor',
1790
1791'create_symlink' => 'Skapa symlink',
1792'delete' => 'Radera',
1793'rename' => 'Byt namn',
1794'move' => 'Flytta',
1795'copy' => 'Kopiera',
1796'edit' => 'Andra',
1797'download' => 'Ladda ner',
1798'upload' => 'Ladda upp',
1799'create' => 'Skapa',
1800'change' => 'Andra',
1801'save' => 'Spara',
1802'set' => 'Markera',
1803'reset' => 'Tom',
1804'relative' => 'Relative path to target',
1805
1806'yes' => 'Ja',
1807'no' => 'Nej',
1808'back' => 'Tillbaks',
1809'destination' => 'Destination',
1810'symlink' => 'Symlink',
1811'no_output' => 'no output',
1812
1813'user' => 'Anvandare',
1814'password' => 'Losenord',
1815'add' => 'Lagg till',
1816'add_basic_auth' => 'add basic-authentification',
1817
1818'uploaded' => '"[%1]" har laddats upp.',
1819'not_uploaded' => '"[%1]" kunde inte laddas upp.',
1820'already_exists' => '"[%1]" finns redan.',
1821'created' => '"[%1]" har skapats.',
1822'not_created' => '"[%1]" kunde inte skapas.',
1823'really_delete' => 'Radera dessa filer?',
1824'deleted' => "De har filerna har raderats:\n[%1]",
1825'not_deleted' => "Dessa filer kunde inte raderas:\n[%1]",
1826'rename_file' => 'Byt namn pa fil:',
1827'renamed' => '"[%1]" har bytt namn till "[%2]".',
1828'not_renamed' => '"[%1] kunde inte dopas om till "[%2]".',
1829'move_files' => 'Flytta dessa filer:',
1830'moved' => "Dessa filer har flyttats till \"[%2]\":\n[%1]",
1831'not_moved' => "Dessa filer kunde inte flyttas till \"[%2]\":\n[%1]",
1832'copy_files' => 'Kopiera dessa filer:',
1833'copied' => "Dessa filer har kopierats till \"[%2]\":\n[%1]",
1834'not_copied' => "Dessa filer kunde inte kopieras till \"[%2]\":\n[%1]",
1835'not_edited' => '"[%1]" kan inte andras.',
1836'executed' => "\"[%1]\" har utforts:\n{%2}",
1837'not_executed' => "\"[%1]\" kunde inte utforas:\n{%2}",
1838'saved' => '"[%1]" har sparats.',
1839'not_saved' => '"[%1]" kunde inte sparas.',
1840'symlinked' => 'Symlink fran "[%2]" till "[%1]" har skapats.',
1841'not_symlinked' => 'Symlink fran "[%2]" till "[%1]" kunde inte skapas.',
1842'permission_for' => 'Rattigheter for "[%1]":',
1843'permission_set' => 'Rattigheter for "[%1]" andrades till [%2].',
1844'permission_not_set' => 'Permission of "[%1]" could not be set to [%2].',
1845'not_readable' => '"[%1]" kan inte lasas.'
1846 );
1847
1848 case 'en':
1849 default:
1850
1851 $date_format = 'n/j/y H:i:s';
1852 $word_charset = 'ISO-8859-1';
1853
1854 return array(
1855'directory' => 'Directory',
1856'file' => 'File',
1857'filename' => 'Filename',
1858
1859'size' => 'Size',
1860'permission' => 'Permission',
1861'owner' => 'Owner',
1862'group' => 'Group',
1863'other' => 'Others',
1864'functions' => 'Functions',
1865
1866'read' => 'read',
1867'write' => 'write',
1868'execute' => 'execute',
1869
1870'create_symlink' => 'create symlink',
1871'delete' => 'delete',
1872'rename' => 'rename',
1873'move' => 'move',
1874'copy' => 'copy',
1875'edit' => 'edit',
1876'download' => 'download',
1877'upload' => 'upload',
1878'create' => 'create',
1879'change' => 'change',
1880'save' => 'save',
1881'set' => 'set',
1882'reset' => 'reset',
1883'relative' => 'Relative path to target',
1884
1885'yes' => 'Yes',
1886'no' => 'No',
1887'back' => 'back',
1888'destination' => 'Destination',
1889'symlink' => 'Symlink',
1890'no_output' => 'no output',
1891
1892'user' => 'User',
1893'password' => 'Password',
1894'add' => 'add',
1895'add_basic_auth' => 'add basic-authentification',
1896
1897'uploaded' => '"[%1]" has been uploaded.',
1898'not_uploaded' => '"[%1]" could not be uploaded.',
1899'already_exists' => '"[%1]" already exists.',
1900'created' => '"[%1]" has been created.',
1901'not_created' => '"[%1]" could not be created.',
1902'really_delete' => 'Delete these files?',
1903'deleted' => "These files have been deleted:\n[%1]",
1904'not_deleted' => "These files could not be deleted:\n[%1]",
1905'rename_file' => 'Rename file:',
1906'renamed' => '"[%1]" has been renamed to "[%2]".',
1907'not_renamed' => '"[%1] could not be renamed to "[%2]".',
1908'move_files' => 'Move these files:',
1909'moved' => "These files have been moved to \"[%2]\":\n[%1]",
1910'not_moved' => "These files could not be moved to \"[%2]\":\n[%1]",
1911'copy_files' => 'Copy these files:',
1912'copied' => "These files have been copied to \"[%2]\":\n[%1]",
1913'not_copied' => "These files could not be copied to \"[%2]\":\n[%1]",
1914'not_edited' => '"[%1]" can not be edited.',
1915'executed' => "\"[%1]\" has been executed successfully:\n{%2}",
1916'not_executed' => "\"[%1]\" could not be executed successfully:\n{%2}",
1917'saved' => '"[%1]" has been saved.',
1918'not_saved' => '"[%1]" could not be saved.',
1919'symlinked' => 'Symlink from "[%2]" to "[%1]" has been created.',
1920'not_symlinked' => 'Symlink from "[%2]" to "[%1]" could not be created.',
1921'permission_for' => 'Permission of "[%1]":',
1922'permission_set' => 'Permission of "[%1]" was set to [%2].',
1923'permission_not_set' => 'Permission of "[%1]" could not be set to [%2].',
1924'not_readable' => '"[%1]" can not be read.'
1925 );
1926
1927 }
1928
1929}
1930
1931function getimage ($image) {
1932 switch ($image) {
1933 case 'file':
1934 return base64_decode('R0lGODlhEQANAJEDAJmZmf///wAAAP///yH5BAHoAwMALAAAAAARAA0AAAItnIGJxg0B42rsiSvCA/REmXQWhmnih3LUSGaqg35vFbSXucbSabunjnMohq8CADsA');
1935 case 'folder':
1936 return base64_decode('R0lGODlhEQANAJEDAJmZmf///8zMzP///yH5BAHoAwMALAAAAAARAA0AAAIqnI+ZwKwbYgTPtIudlbwLOgCBQJYmCYrn+m3smY5vGc+0a7dhjh7ZbygAADsA');
1937 case 'hidden_file':
1938 return base64_decode('R0lGODlhEQANAJEDAMwAAP///5mZmf///yH5BAHoAwMALAAAAAARAA0AAAItnIGJxg0B42rsiSvCA/REmXQWhmnih3LUSGaqg35vFbSXucbSabunjnMohq8CADsA');
1939 case 'link':
1940 return base64_decode('R0lGODlhEQANAKIEAJmZmf///wAAAMwAAP///wAAAAAAAAAAACH5BAHoAwQALAAAAAARAA0AAAM5SArcrDCCQOuLcIotwgTYUllNOA0DxXkmhY4shM5zsMUKTY8gNgUvW6cnAaZgxMyIM2zBLCaHlJgAADsA');
1941 case 'smiley':
1942 return base64_decode('R0lGODlhEQANAJECAAAAAP//AP///wAAACH5BAHoAwIALAAAAAARAA0AAAIslI+pAu2wDAiz0jWD3hqmBzZf1VCleJQch0rkdnppB3dKZuIygrMRE/oJDwUAOwA=');
1943 case 'arrow':
1944 return base64_decode('R0lGODlhEQANAIABAAAAAP///yH5BAEKAAEALAAAAAARAA0AAAIdjA9wy6gNQ4pwUmav0yvn+hhJiI3mCJ6otrIkxxQAOw==');
1945 }
1946}
1947
1948function html_header () {
1949 global $charset;
1950
1951 echo <<<END
1952<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
1953 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1954<html xmlns="http://www.w3.org/1999/xhtml">
1955<head>
1956
1957<meta http-equiv="Content-Type" content="text/html; charset=$charset" />
1958
1959<title>info</title>
1960
1961<style type="text/css">
1962body { font: small sans-serif; text-align: center }
1963img { width: 17px; height: 13px }
1964a, a:visited { text-decoration: none; color: navy }
1965hr { border-style: none; height: 1px; background-color: silver; color: silver }
1966#main { margin-top: 6pt; margin-left: auto; margin-right: auto; border-spacing: 1px }
1967#main th { background: #eee; padding: 3pt 3pt 0pt 3pt }
1968.listing th, .listing td { padding: 1px 3pt 0 3pt }
1969.listing th { border: 1px solid silver }
1970.listing td { border: 1px solid #ddd; background: white }
1971.listing .checkbox { text-align: center }
1972.listing .filename { text-align: left }
1973.listing .size { text-align: right }
1974.listing .permission_header { text-align: left }
1975.listing .permission { font-family: monospace }
1976.listing .owner { text-align: left }
1977.listing .group { text-align: left }
1978.listing .functions { text-align: left }
1979.listing_footer td { background: #eee; border: 1px solid silver }
1980#directory, #upload, #create, .listing_footer td, #error td, #notice td { text-align: left; padding: 3pt }
1981#directory { background: #eee; border: 1px solid silver }
1982#upload { padding-top: 1em }
1983#create { padding-bottom: 1em }
1984.small, .small option { font-size: x-small }
1985textarea { border: none; background: white }
1986table.dialog { margin-left: auto; margin-right: auto }
1987td.dialog { background: #eee; padding: 1ex; border: 1px solid silver; text-align: center }
1988#permission { margin-left: auto; margin-right: auto }
1989#permission td { padding-left: 3pt; padding-right: 3pt; text-align: center }
1990td.permission_action { text-align: right }
1991#symlink { background: #eee; border: 1px solid silver }
1992#symlink td { text-align: left; padding: 3pt }
1993#red_button { width: 120px; color: #400 }
1994#green_button { width: 120px; color: #040 }
1995#error td { background: maroon; color: white; border: 1px solid silver }
1996#notice td { background: green; color: white; border: 1px solid silver }
1997#notice pre, #error pre { background: silver; color: black; padding: 1ex; margin-left: 1ex; margin-right: 1ex }
1998code { font-size: 12pt }
1999td { white-space: nowrap }
2000</style>
2001
2002<script type="text/javascript">
2003<!--
2004function activate (name) {
2005 if (document && document.forms[0] && document.forms[0].elements['focus']) {
2006 document.forms[0].elements['focus'].value = name;
2007 }
2008}
2009//-->
2010</script>
2011
2012</head>
2013<body>
2014
2015
2016END;
2017
2018}
2019
2020function html_footer () {
2021
2022 echo <<<END
2023</body>
2024</html>
2025END;
2026
2027}
2028
2029function notice ($phrase) {
2030 global $cols;
2031
2032 $args = func_get_args();
2033 array_shift($args);
2034
2035 return '<tr id="notice">
2036 <td colspan="' . $cols . '">' . phrase($phrase, $args) . '</td>
2037</tr>
2038';
2039
2040}
2041
2042function error ($phrase) {
2043 global $cols;
2044
2045 $args = func_get_args();
2046 array_shift($args);
2047
2048 return '<tr id="error">
2049 <td colspan="' . $cols . '">' . phrase($phrase, $args) . '</td>
2050</tr>
2051';
2052
2053}
2054
2055?>