· 9 years ago · Jan 21, 2017, 02:16 PM
1<?php
2/**
3 * PHP File Manager v1.2
4 * https://github.com/alexantr/filemanager
5 */
6
7// Default language ('en', 'ru', 'fr' and other from 'filemanager-l10n.php')
8$lang = 'ru';
9
10// Auth with login/password (set true/false to enable/disable it)
11$use_auth = true;
12
13// Users: array('Username' => 'Password', 'Username2' => 'Password2', ...)
14$auth_users = array(
15 'admin' => 'admin',
16 //'user' => '12345',
17);
18
19// Readonly users (usernames array)
20$readonly_users = array(
21 //'user',
22);
23
24// Enable highlight.js (https://highlightjs.org/) on view's page
25$use_highlightjs = true;
26
27// highlight.js style
28$highlightjs_style = 'vs';
29
30// Default timezone for date() and time() - http://php.net/manual/en/timezones.php
31$default_timezone = 'Europe/Minsk'; // UTC+3
32
33// Root path for file manager
34$root_path = $_SERVER['DOCUMENT_ROOT'];
35
36// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
37// Will not working if $root_path will be outside of server document root
38$root_url = '';
39
40// Server hostname. Can set manually if wrong
41$http_host = $_SERVER['HTTP_HOST'];
42
43// input encoding for iconv
44$iconv_input_encoding = 'CP1251';
45
46//--- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL
47
48// if fm included
49if (defined('FM_EMBED')) {
50 $use_auth = false;
51} else {
52 error_reporting(E_ALL);
53 set_time_limit(600);
54
55 date_default_timezone_set($default_timezone);
56
57 ini_set('default_charset', 'UTF-8');
58 if (function_exists('mb_internal_encoding')) {
59 mb_internal_encoding('UTF-8');
60 }
61 if (function_exists('mb_regex_encoding')) {
62 mb_regex_encoding('UTF-8');
63 }
64
65 session_cache_limiter('');
66 session_name('filemanager');
67 session_start();
68}
69
70if (empty($auth_users)) {
71 $use_auth = false;
72}
73
74$is_https = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1)
75 || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https';
76
77// clean and check $root_path
78$root_path = rtrim($root_path, '\\/');
79$root_path = str_replace('\\', '/', $root_path);
80if (!@is_dir($root_path)) {
81 echo "<h1>Root path "{$root_path}" not found!</h1>";
82 exit;
83}
84
85// clean $root_url
86$root_url = fm_clean_path($root_url);
87
88// abs path for site
89defined('FM_ROOT_PATH') || define('FM_ROOT_PATH', $root_path);
90defined('FM_ROOT_URL') || define('FM_ROOT_URL', ($is_https ? 'https' : 'http') . '://' . $http_host . (!empty($root_url) ? '/' . $root_url : ''));
91defined('FM_SELF_URL') || define('FM_SELF_URL', ($is_https ? 'https' : 'http') . '://' . $http_host . $_SERVER['PHP_SELF']);
92
93// logout
94if (isset($_GET['logout'])) {
95 unset($_SESSION['logged']);
96 fm_redirect(FM_SELF_URL);
97}
98
99// Show image here
100if (isset($_GET['img'])) {
101 fm_show_image($_GET['img']);
102}
103
104// Auth
105if ($use_auth) {
106 $languages = fm_get_available_langs();
107 if (isset($_SESSION['logged'], $auth_users[$_SESSION['logged']])) {
108 // Logged
109 $lang = (isset($_SESSION['lang']) && in_array($_SESSION['lang'], $languages)) ? $_SESSION['lang'] : $lang;
110 } elseif (isset($_POST['fm_usr'], $_POST['fm_pwd'])) {
111 // Logging In
112 sleep(1);
113 if (isset($auth_users[$_POST['fm_usr']]) && $_POST['fm_pwd'] === $auth_users[$_POST['fm_usr']]) {
114 $_SESSION['logged'] = $_POST['fm_usr'];
115 if (isset($_POST['lang']) && in_array($_POST['lang'], $languages)) {
116 $_SESSION['lang'] = $_POST['lang'];
117 $lang = $_POST['lang'];
118 } elseif (defined('FM_LANG')) {
119 $lang = FM_LANG;
120 }
121 fm_set_msg(fm_t('You are logged in', $lang));
122 fm_redirect(FM_SELF_URL . '?p=');
123 } else {
124 unset($_SESSION['logged']);
125 fm_set_msg(fm_t('Wrong password', $lang), 'error');
126 fm_redirect(FM_SELF_URL);
127 }
128 } else {
129 // Form
130 if (defined('FM_LANG')) {
131 $lang = FM_LANG;
132 }
133 unset($_SESSION['logged']);
134 fm_show_header();
135 fm_show_message();
136 ?>
137 <div class="path">
138 <form action="" method="post" style="margin:10px;text-align:center">
139 <input type="text" name="fm_usr" value="" placeholder="<?php echo fm_t('Username', $lang) ?>" required>
140 <input type="password" name="fm_pwd" value="" placeholder="<?php echo fm_t('Password', $lang) ?>" required>
141 <select name="lang" title="Language">
142 <?php foreach ($languages as $l): ?>
143 <option value="<?php echo $l ?>"<?php echo $l == $lang ? ' selected' : '' ?>><?php echo $l ?></option>
144 <?php endforeach; ?>
145 </select>
146 <input type="submit" value="<?php echo fm_t('Login', $lang) ?>">
147 </form>
148 </div>
149 <?php
150 fm_show_footer();
151 exit;
152 }
153}
154
155defined('FM_LANG') || define('FM_LANG', $lang);
156define('FM_READONLY', $use_auth && !empty($readonly_users) && isset($_SESSION['logged']) && in_array($_SESSION['logged'], $readonly_users));
157define('FM_IS_WIN', DIRECTORY_SEPARATOR == '\\');
158
159// always use ?p=
160if (!isset($_GET['p'])) {
161 fm_redirect(FM_SELF_URL . '?p=');
162}
163
164// get path
165$p = isset($_GET['p']) ? $_GET['p'] : (isset($_POST['p']) ? $_POST['p'] : '');
166
167// clean path
168$p = fm_clean_path($p);
169
170// instead globals vars
171define('FM_PATH', $p);
172define('FM_USE_AUTH', $use_auth);
173define('FM_ICONV_INPUT_ENC', $iconv_input_encoding);
174define('FM_USE_HIGHLIGHTJS', $use_highlightjs);
175define('FM_HIGHLIGHTJS_STYLE', $highlightjs_style);
176
177unset($p, $use_auth, $iconv_input_encoding, $use_highlightjs, $highlightjs_style);
178
179/*************************** ACTIONS ***************************/
180
181// Delete file / folder
182if (isset($_GET['del']) && !FM_READONLY) {
183 $del = $_GET['del'];
184 $del = fm_clean_path($del);
185 $del = str_replace('/', '', $del);
186 if ($del != '' && $del != '..' && $del != '.') {
187 $path = FM_ROOT_PATH;
188 if (FM_PATH != '') {
189 $path .= '/' . FM_PATH;
190 }
191 $is_dir = is_dir($path . '/' . $del);
192 if (fm_rdelete($path . '/' . $del)) {
193 $msg = $is_dir ? fm_t('Folder <b>%s</b> deleted') : fm_t('File <b>%s</b> deleted');
194 fm_set_msg(sprintf($msg, $del));
195 } else {
196 $msg = $is_dir ? fm_t('Folder <b>%s</b> not deleted') : fm_t('File <b>%s</b> not deleted');
197 fm_set_msg(sprintf($msg, $del), 'error');
198 }
199 } else {
200 fm_set_msg(fm_t('Wrong file or folder name'), 'error');
201 }
202 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
203}
204
205// Create folder
206if (isset($_GET['new']) && !FM_READONLY) {
207 $new = $_GET['new'];
208 $new = fm_clean_path($new);
209 $new = str_replace('/', '', $new);
210 if ($new != '' && $new != '..' && $new != '.') {
211 $path = FM_ROOT_PATH;
212 if (FM_PATH != '') {
213 $path .= '/' . FM_PATH;
214 }
215 if (fm_mkdir($path . '/' . $new, false) === true) {
216 fm_set_msg(sprintf(fm_t('Folder <b>%s</b> created'), $new));
217 } elseif (fm_mkdir($path . '/' . $new, false) === $path . '/' . $new) {
218 fm_set_msg(sprintf(fm_t('Folder <b>%s</b> already exists'), $new), 'alert');
219 } else {
220 fm_set_msg(sprintf(fm_t('Folder <b>%s</b> not created'), $new), 'error');
221 }
222 } else {
223 fm_set_msg(fm_t('Wrong folder name'), 'error');
224 }
225 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
226}
227
228// Copy folder / file
229if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) {
230 // from
231 $copy = $_GET['copy'];
232 $copy = fm_clean_path($copy);
233 // empty path
234 if ($copy == '') {
235 fm_set_msg(fm_t('Source path not defined'), 'error');
236 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
237 }
238 // abs path from
239 $from = FM_ROOT_PATH . '/' . $copy;
240 // abs path to
241 $dest = FM_ROOT_PATH;
242 if (FM_PATH != '') {
243 $dest .= '/' . FM_PATH;
244 }
245 $dest .= '/' . basename($from);
246 // move?
247 $move = isset($_GET['move']);
248 // copy/move
249 if ($from != $dest) {
250 $msg_from = trim(FM_PATH . '/' . basename($from), '/');
251 if ($move) {
252 $rename = fm_rename($from, $dest);
253 if ($rename) {
254 fm_set_msg(sprintf(fm_t('Moved from <b>%s</b> to <b>%s</b>'), $copy, $msg_from));
255 } elseif ($rename === null) {
256 fm_set_msg(fm_t('File or folder with this path already exists'), 'alert');
257 } else {
258 fm_set_msg(sprintf(fm_t('Error while moving from <b>%s</b> to <b>%s</b>'), $copy, $msg_from), 'error');
259 }
260 } else {
261 if (fm_rcopy($from, $dest)) {
262 fm_set_msg(sprintf(fm_t('Copyied from <b>%s</b> to <b>%s</b>'), $copy, $msg_from));
263 } else {
264 fm_set_msg(sprintf(fm_t('Error while copying from <b>%s</b> to <b>%s</b>'), $copy, $msg_from), 'error');
265 }
266 }
267 } else {
268 fm_set_msg(fm_t('Paths must be not equal'), 'alert');
269 }
270 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
271}
272
273// Mass copy files/ folders
274if (isset($_POST['file'], $_POST['copy_to'], $_POST['finish']) && !FM_READONLY) {
275 // from
276 $path = FM_ROOT_PATH;
277 if (FM_PATH != '') {
278 $path .= '/' . FM_PATH;
279 }
280 // to
281 $copy_to_path = FM_ROOT_PATH;
282 $copy_to = fm_clean_path($_POST['copy_to']);
283 if ($copy_to != '') {
284 $copy_to_path .= '/' . $copy_to;
285 }
286 if ($path == $copy_to_path) {
287 fm_set_msg(fm_t('Paths must be not equal'), 'alert');
288 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
289 }
290 if (!is_dir($copy_to_path)) {
291 if (!fm_mkdir($copy_to_path, true)) {
292 fm_set_msg(fm_t('Unable to create destination folder'), 'error');
293 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
294 }
295 }
296 // move?
297 $move = isset($_POST['move']);
298 // copy/move
299 $errors = 0;
300 $files = $_POST['file'];
301 if (is_array($files) && count($files)) {
302 foreach ($files as $f) {
303 if ($f != '') {
304 // abs path from
305 $from = $path . '/' . $f;
306 // abs path to
307 $dest = $copy_to_path . '/' . $f;
308 // do
309 if ($move) {
310 $rename = fm_rename($from, $dest);
311 if ($rename === false) {
312 $errors++;
313 }
314 } else {
315 if (!fm_rcopy($from, $dest)) {
316 $errors++;
317 }
318 }
319 }
320 }
321 if ($errors == 0) {
322 $msg = $move ? fm_t('Selected files and folders moved') : fm_t('Selected files and folders copied');
323 fm_set_msg($msg);
324 } else {
325 $msg = $move ? fm_t('Error while moving items') : fm_t('Error while copying items');
326 fm_set_msg($msg, 'error');
327 }
328 } else {
329 fm_set_msg(fm_t('Nothing selected'), 'alert');
330 }
331 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
332}
333
334// Rename
335if (isset($_GET['ren'], $_GET['to']) && !FM_READONLY) {
336 // old name
337 $old = $_GET['ren'];
338 $old = fm_clean_path($old);
339 $old = str_replace('/', '', $old);
340 // new name
341 $new = $_GET['to'];
342 $new = fm_clean_path($new);
343 $new = str_replace('/', '', $new);
344 // path
345 $path = FM_ROOT_PATH;
346 if (FM_PATH != '') {
347 $path .= '/' . FM_PATH;
348 }
349 // rename
350 if ($old != '' && $new != '') {
351 if (fm_rename($path . '/' . $old, $path . '/' . $new)) {
352 fm_set_msg(sprintf(fm_t('Renamed from <b>%s</b> to <b>%s</b>'), $old, $new));
353 } else {
354 fm_set_msg(sprintf(fm_t('Error while renaming from <b>%s</b> to <b>%s</b>'), $old, $new), 'error');
355 }
356 } else {
357 fm_set_msg(fm_t('Names not set'), 'error');
358 }
359 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
360}
361
362// Download
363if (isset($_GET['dl'])) {
364 $dl = $_GET['dl'];
365 $dl = fm_clean_path($dl);
366 $dl = str_replace('/', '', $dl);
367 $path = FM_ROOT_PATH;
368 if (FM_PATH != '') {
369 $path .= '/' . FM_PATH;
370 }
371 if ($dl != '' && is_file($path . '/' . $dl)) {
372 header('Content-Description: File Transfer');
373 header('Content-Type: application/octet-stream');
374 header('Content-Disposition: attachment; filename="' . basename($path . '/' . $dl) . '"');
375 header('Content-Transfer-Encoding: binary');
376 header('Connection: Keep-Alive');
377 header('Expires: 0');
378 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
379 header('Pragma: public');
380 header('Content-Length: ' . filesize($path . '/' . $dl));
381 readfile($path . '/' . $dl);
382 exit;
383 } else {
384 fm_set_msg(fm_t('File not found'), 'error');
385 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
386 }
387}
388
389// Upload
390if (isset($_POST['upl']) && !FM_READONLY) {
391 $path = FM_ROOT_PATH;
392 if (FM_PATH != '') {
393 $path .= '/' . FM_PATH;
394 }
395
396 $errors = 0;
397 $uploads = 0;
398 $total = count($_FILES['upload']['name']);
399
400 for ($i = 0; $i < $total; $i++) {
401 $tmp_name = $_FILES['upload']['tmp_name'][$i];
402 if (empty($_FILES['upload']['error'][$i]) && !empty($tmp_name) && $tmp_name != 'none') {
403 if (move_uploaded_file($tmp_name, $path . '/' . $_FILES['upload']['name'][$i])) {
404 $uploads++;
405 } else {
406 $errors++;
407 }
408 }
409 }
410
411 if ($errors == 0 && $uploads > 0) {
412 fm_set_msg(sprintf(fm_t('All files uploaded to <b>%s</b>'), $path));
413 } elseif ($errors == 0 && $uploads == 0) {
414 fm_set_msg(fm_t('Nothing uploaded'), 'alert');
415 } else {
416 fm_set_msg(sprintf(fm_t('Error while uploading files. Uploaded files: %s'), $uploads), 'error');
417 }
418
419 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
420}
421
422// Mass deleting
423if (isset($_POST['group'], $_POST['delete']) && !FM_READONLY) {
424 $path = FM_ROOT_PATH;
425 if (FM_PATH != '') {
426 $path .= '/' . FM_PATH;
427 }
428
429 $errors = 0;
430 $files = $_POST['file'];
431 if (is_array($files) && count($files)) {
432 foreach ($files as $f) {
433 if ($f != '') {
434 $new_path = $path . '/' . $f;
435 if (!fm_rdelete($new_path)) {
436 $errors++;
437 }
438 }
439 }
440 if ($errors == 0) {
441 fm_set_msg(fm_t('Selected files and folder deleted'));
442 } else {
443 fm_set_msg(fm_t('Error while deleting items'), 'error');
444 }
445 } else {
446 fm_set_msg(fm_t('Nothing selected'), 'alert');
447 }
448
449 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
450}
451
452// Pack files
453if (isset($_POST['group'], $_POST['zip']) && !FM_READONLY) {
454 $path = FM_ROOT_PATH;
455 if (FM_PATH != '') {
456 $path .= '/' . FM_PATH;
457 }
458
459 if (!class_exists('ZipArchive')) {
460 fm_set_msg(fm_t('Operations with archives are not available'), 'error');
461 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
462 }
463
464 $files = $_POST['file'];
465 if (!empty($files)) {
466 chdir($path);
467
468 if (count($files) == 1) {
469 $one_file = reset($files);
470 $one_file = basename($one_file);
471 $zipname = $one_file . '_' . date('ymd_His') . '.zip';
472 } else {
473 $zipname = 'archive_' . date('ymd_His') . '.zip';
474 }
475
476 $zipper = new FM_Zipper();
477 $res = $zipper->create($zipname, $files);
478
479 if ($res) {
480 fm_set_msg(sprintf(fm_t('Archive <b>%s</b> created'), $zipname));
481 } else {
482 fm_set_msg(fm_t('Archive not created'), 'error');
483 }
484 } else {
485 fm_set_msg(fm_t('Nothing selected'), 'alert');
486 }
487
488 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
489}
490
491// Unpack
492if (isset($_GET['unzip']) && !FM_READONLY) {
493 $unzip = $_GET['unzip'];
494 $unzip = fm_clean_path($unzip);
495 $unzip = str_replace('/', '', $unzip);
496
497 $path = FM_ROOT_PATH;
498 if (FM_PATH != '') {
499 $path .= '/' . FM_PATH;
500 }
501
502 if (!class_exists('ZipArchive')) {
503 fm_set_msg(fm_t('Operations with archives are not available'), 'error');
504 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
505 }
506
507 if ($unzip != '' && is_file($path . '/' . $unzip)) {
508 $zip_path = $path . '/' . $unzip;
509
510 //to folder
511 $tofolder = '';
512 if (isset($_GET['tofolder'])) {
513 $tofolder = pathinfo($zip_path, PATHINFO_FILENAME);
514 if (fm_mkdir($path . '/' . $tofolder, true)) {
515 $path .= '/' . $tofolder;
516 }
517 }
518
519 $zipper = new FM_Zipper();
520 $res = $zipper->unzip($zip_path, $path);
521
522 if ($res) {
523 fm_set_msg(fm_t('Archive unpacked'));
524 } else {
525 fm_set_msg(fm_t('Archive not unpacked'), 'error');
526 }
527
528 } else {
529 fm_set_msg(fm_t('File not found'), 'error');
530 }
531 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
532}
533
534// Change Perms
535if (isset($_POST['chmod']) && !FM_READONLY) {
536 $path = FM_ROOT_PATH;
537 if (FM_PATH != '') {
538 $path .= '/' . FM_PATH;
539 }
540
541 $file = $_POST['chmod'];
542 $file = fm_clean_path($file);
543 $file = str_replace('/', '', $file);
544 if ($file == '' || (!is_file($path . '/' . $file) && !is_dir($path . '/' . $file))) {
545 fm_set_msg(fm_t('File not found'), 'error');
546 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
547 }
548
549 $mode = 0;
550 if (!empty($_POST['ur'])) $mode |= 0400;
551 if (!empty($_POST['uw'])) $mode |= 0200;
552 if (!empty($_POST['ux'])) $mode |= 0100;
553 if (!empty($_POST['gr'])) $mode |= 0040;
554 if (!empty($_POST['gw'])) $mode |= 0020;
555 if (!empty($_POST['gx'])) $mode |= 0010;
556 if (!empty($_POST['or'])) $mode |= 0004;
557 if (!empty($_POST['ow'])) $mode |= 0002;
558 if (!empty($_POST['ox'])) $mode |= 0001;
559
560 if (@chmod($path . '/' . $file, $mode)) {
561 fm_set_msg(fm_t('Permissions changed'));
562 } else {
563 fm_set_msg(fm_t('Permissions not changed'), 'error');
564 }
565
566 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
567}
568
569/*************************** /ACTIONS ***************************/
570
571// get current path
572$path = FM_ROOT_PATH;
573if (FM_PATH != '') {
574 $path .= '/' . FM_PATH;
575}
576
577// check path
578if (!is_dir($path)) {
579 fm_redirect(FM_SELF_URL . '?p=');
580}
581
582// get parent folder
583$parent = fm_get_parent_path(FM_PATH);
584
585$objects = is_readable($path) ? scandir($path) : array();
586$folders = array();
587$files = array();
588if (is_array($objects)) {
589 foreach ($objects as $file) {
590 if ($file == '.' || $file == '..') continue;
591 $new_path = $path . '/' . $file;
592 if (is_file($new_path)) {
593 $files[] = $file;
594 } elseif (is_dir($new_path) && $file != '.' && $file != '..') {
595 $folders[] = $file;
596 }
597 }
598}
599
600if (!empty($files)) {
601 natcasesort($files);
602}
603if (!empty($folders)) {
604 natcasesort($folders);
605}
606
607// upload form
608if (isset($_GET['upload']) && !FM_READONLY) {
609 fm_show_header(); // HEADER
610 fm_show_nav_path(FM_PATH); // current path
611 ?>
612 <div class="path">
613 <p><b><?php echo fm_t('Uploading files') ?></b></p>
614 <p class="break-word"><?php echo fm_t('Destination folder:') ?> <?php echo fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH) ?></p>
615 <form action="" method="post" enctype="multipart/form-data">
616 <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
617 <input type="hidden" name="upl" value="1">
618 <input type="file" name="upload[]"><br>
619 <input type="file" name="upload[]"><br>
620 <input type="file" name="upload[]"><br>
621 <input type="file" name="upload[]"><br>
622 <input type="file" name="upload[]"><br>
623 <br>
624 <p>
625 <button type="submit" class="btn"><i class="icon-apply"></i> <?php echo fm_t('Upload') ?></button>
626 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="icon-cancel"></i> <?php echo fm_t('Cancel') ?></a></b>
627 </p>
628 </form>
629 </div>
630 <?php
631 fm_show_footer();
632 exit;
633}
634
635// copy form POST
636if (isset($_POST['copy']) && !FM_READONLY) {
637 $copy_files = $_POST['file'];
638 if (!is_array($copy_files) || empty($copy_files)) {
639 fm_set_msg(fm_t('Nothing selected'), 'alert');
640 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
641 }
642
643 fm_show_header(); // HEADER
644 fm_show_nav_path(FM_PATH); // current path
645 ?>
646 <div class="path">
647 <p><b><?php echo fm_t('Copying') ?></b></p>
648 <form action="" method="post">
649 <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
650 <input type="hidden" name="finish" value="1">
651 <?php
652 foreach ($copy_files as $cf) {
653 echo '<input type="hidden" name="file[]" value="' . fm_enc($cf) . '">' . PHP_EOL;
654 }
655 ?>
656 <p class="break-word"><?php echo fm_t('Files:') ?> <b><?php echo implode('</b>, <b>', $copy_files) ?></b></p>
657 <p class="break-word"><?php echo fm_t('Source folder:') ?> <?php echo fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH) ?><br>
658 <label for="inp_copy_to"><?php echo fm_t('Destination folder:') ?></label>
659 <?php echo FM_ROOT_PATH ?>/<input type="text" name="copy_to" id="inp_copy_to" value="<?php echo fm_enc(FM_PATH) ?>">
660 </p>
661 <p><label><input type="checkbox" name="move" value="1"> <?php echo fm_t('Move') ?></label></p>
662 <p>
663 <button type="submit" class="btn"><i class="icon-apply"></i> <?php echo fm_t('Copy') ?></button>
664 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="icon-cancel"></i> <?php echo fm_t('Cancel') ?></a></b>
665 </p>
666 </form>
667 </div>
668 <?php
669 fm_show_footer();
670 exit;
671}
672
673// copy form
674if (isset($_GET['copy']) && !isset($_GET['finish']) && !FM_READONLY) {
675 $copy = $_GET['copy'];
676 $copy = fm_clean_path($copy);
677 if ($copy == '' || !file_exists(FM_ROOT_PATH . '/' . $copy)) {
678 fm_set_msg(fm_t('File not found'), 'error');
679 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
680 }
681
682 fm_show_header(); // HEADER
683 fm_show_nav_path(FM_PATH); // current path
684 ?>
685 <div class="path">
686 <p><b><?php echo fm_t('Copying') ?></b></p>
687 <p class="break-word">
688 <?php echo fm_t('Source path:') ?> <?php echo fm_convert_win(FM_ROOT_PATH . '/' . $copy) ?><br>
689 <?php echo fm_t('Destination folder:') ?> <?php echo fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH) ?>
690 </p>
691 <p>
692 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>&copy=<?php echo urlencode($copy) ?>&finish=1"><i class="icon-apply"></i> <?php echo fm_t('Copy') ?></a></b>
693 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>&copy=<?php echo urlencode($copy) ?>&finish=1&move=1"><i class="icon-apply"></i> <?php echo fm_t('Move') ?></a></b>
694 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="icon-cancel"></i> <?php echo fm_t('Cancel') ?></a></b>
695 </p>
696 <p><i><?php echo fm_t('Select folder:') ?></i></p>
697 <ul class="folders break-word">
698 <?php
699 if ($parent !== false) {
700 ?>
701 <li><a href="?p=<?php echo urlencode($parent) ?>&copy=<?php echo urlencode($copy) ?>"><i class="icon-arrow_up"></i> ..</a></li>
702 <?php
703 }
704 foreach ($folders as $f) {
705 ?>
706 <li><a href="?p=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>&copy=<?php echo urlencode($copy) ?>"><i class="icon-folder"></i> <?php echo fm_convert_win($f) ?></a></li>
707 <?php
708 }
709 ?>
710 </ul>
711 </div>
712 <?php
713 fm_show_footer();
714 exit;
715}
716
717// file viewer
718if (isset($_GET['view'])) {
719 $file = $_GET['view'];
720 $file = fm_clean_path($file);
721 $file = str_replace('/', '', $file);
722 if ($file == '' || !is_file($path . '/' . $file)) {
723 fm_set_msg(fm_t('File not found'), 'error');
724 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
725 }
726
727 fm_show_header(); // HEADER
728 fm_show_nav_path(FM_PATH); // current path
729
730 $file_url = FM_ROOT_URL . fm_convert_win((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file);
731 $file_path = $path . '/' . $file;
732
733 $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
734 $mime_type = fm_get_mime_type($file_path);
735 $filesize = filesize($file_path);
736
737 $is_zip = false;
738 $is_image = false;
739 $is_audio = false;
740 $is_video = false;
741 $is_text = false;
742
743 $view_title = 'File';
744 $filenames = false; // for zip
745 $content = ''; // for text
746
747 if ($ext == 'zip') {
748 $is_zip = true;
749 $view_title = 'Archive';
750 $filenames = fm_get_zif_info($file_path);
751 } elseif (in_array($ext, fm_get_image_exts())) {
752 $is_image = true;
753 $view_title = 'Image';
754 } elseif (in_array($ext, fm_get_audio_exts())) {
755 $is_audio = true;
756 $view_title = 'Audio';
757 } elseif (in_array($ext, fm_get_video_exts())) {
758 $is_video = true;
759 $view_title = 'Video';
760 } elseif (in_array($ext, fm_get_text_exts()) || substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
761 $is_text = true;
762 $content = file_get_contents($file_path);
763 }
764
765 ?>
766 <div class="path">
767 <p class="break-word"><b><?php echo fm_t($view_title) ?> <?php echo fm_convert_win($file) ?></b></p>
768 <p class="break-word">
769 <?php echo fm_t('Full path:') ?> <?php echo fm_convert_win($file_path) ?><br>
770 <?php echo fm_t('File size:') ?> <?php echo fm_get_filesize($filesize) ?> (<?php echo sprintf(fm_t('%s byte'), $filesize) ?>)<br>
771 <?php echo fm_t('MIME-type:') ?> <?php echo $mime_type ?><br>
772 <?php
773 // ZIP info
774 if ($is_zip && $filenames !== false) {
775 $total_files = 0;
776 $total_comp = 0;
777 $total_uncomp = 0;
778 foreach ($filenames as $fn) {
779 if (!$fn['folder']) {
780 $total_files++;
781 }
782 $total_comp += $fn['compressed_size'];
783 $total_uncomp += $fn['filesize'];
784 }
785 ?>
786 <?php echo fm_t('Files in archive:') ?> <?php echo $total_files ?><br>
787 <?php echo fm_t('Total size:') ?> <?php echo fm_get_filesize($total_uncomp) ?><br>
788 <?php echo fm_t('Size in archive:') ?> <?php echo fm_get_filesize($total_comp) ?><br>
789 <?php echo fm_t('Compression:') ?> <?php echo round(($total_comp / $total_uncomp) * 100) ?>%<br>
790 <?php
791 }
792 // Image info
793 if ($is_image) {
794 $image_size = getimagesize($file_path);
795 echo fm_t('Image sizes:') . ' ' . (isset($image_size[0]) ? $image_size[0] : '0') . ' x ' . (isset($image_size[1]) ? $image_size[1] : '0') . '<br>';
796 }
797 // Text info
798 if ($is_text) {
799 $is_utf8 = fm_is_utf8($content);
800 if (function_exists('iconv')) {
801 if (!$is_utf8) {
802 $content = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $content);
803 }
804 }
805 echo fm_t('Charset:') . ' ' . ($is_utf8 ? 'utf-8' : '8 bit') . '<br>';
806 }
807 ?>
808 </p>
809 <p>
810 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>&dl=<?php echo urlencode($file) ?>"><i class="icon-download"></i> <?php echo fm_t('Download') ?></a></b>
811 <b><a href="<?php echo $file_url ?>" target="_blank"><i class="icon-chain"></i> <?php echo fm_t('Open') ?></a></b>
812 <?php
813 // ZIP actions
814 if (!FM_READONLY && $is_zip && $filenames !== false) {
815 $zip_name = pathinfo($file_path, PATHINFO_FILENAME);
816 ?>
817 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>&unzip=<?php echo urlencode($file) ?>"><i class="icon-apply"></i> <?php echo fm_t('Unpack') ?></a></b>
818 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>&unzip=<?php echo urlencode($file) ?>&tofolder=1" title="<?php echo fm_t('Unpack to') ?> <?php echo fm_enc($zip_name) ?>"><i class="icon-apply"></i>
819 <?php echo fm_t('Unpack to folder') ?></a></b>
820 <?php
821 }
822 ?>
823 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="icon-goback"></i> <?php echo fm_t('Back') ?></a></b>
824 </p>
825 <?php
826 if ($is_zip) {
827 // ZIP content
828 if ($filenames !== false) {
829 echo '<code class="maxheight">';
830 foreach ($filenames as $fn) {
831 if ($fn['folder']) {
832 echo '<b>' . $fn['name'] . '</b><br>';
833 } else {
834 echo $fn['name'] . ' (' . fm_get_filesize($fn['filesize']) . ')<br>';
835 }
836 }
837 echo '</code>';
838 } else {
839 echo '<p>' . fm_t('Error while fetching archive info') . '</p>';
840 }
841 } elseif ($is_image) {
842 // Image content
843 if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico'))) {
844 echo '<p><img src="' . $file_url . '" alt="" class="preview-img"></p>';
845 }
846 } elseif ($is_audio) {
847 // Audio content
848 echo '<p><audio src="' . $file_url . '" controls preload="metadata"></audio></p>';
849 } elseif ($is_video) {
850 // Video content
851 echo '<div class="preview-video"><video src="' . $file_url . '" width="640" height="360" controls preload="metadata"></video></div>';
852 } elseif ($is_text) {
853 if (FM_USE_HIGHLIGHTJS) {
854 // highlight
855 $hljs_classes = array(
856 'shtml' => 'xml',
857 'htaccess' => 'apache',
858 'phtml' => 'php',
859 'lock' => 'json',
860 'svg' => 'xml',
861 );
862 $hljs_class = isset($hljs_classes[$ext]) ? 'lang-' . $hljs_classes[$ext] : 'lang-' . $ext;
863 if (empty($ext) || in_array(strtolower($file), fm_get_text_names()) || preg_match('#\.min\.(css|js)$#i', $file)) {
864 $hljs_class = 'nohighlight';
865 }
866 $content = '<pre class="with-hljs"><code class="' . $hljs_class . '">' . fm_enc($content) . '</code></pre>';
867 } elseif (in_array($ext, array('php', 'php4', 'php5', 'phtml', 'phps'))) {
868 // php highlight
869 $content = highlight_string($content, true);
870 } else {
871 $content = '<pre>' . fm_enc($content) . '</pre>';
872 }
873 echo $content;
874 }
875 ?>
876 </div>
877 <?php
878 fm_show_footer();
879 exit;
880}
881
882// chmod
883if (isset($_GET['chmod']) && !FM_READONLY) {
884 $file = $_GET['chmod'];
885 $file = fm_clean_path($file);
886 $file = str_replace('/', '', $file);
887 if ($file == '' || (!is_file($path . '/' . $file) && !is_dir($path . '/' . $file))) {
888 fm_set_msg(fm_t('File not found'), 'error');
889 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
890 }
891
892 fm_show_header(); // HEADER
893 fm_show_nav_path(FM_PATH); // current path
894
895 $file_url = FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file;
896 $file_path = $path . '/' . $file;
897
898 $mode = fileperms($path . '/' . $file);
899
900 ?>
901 <div class="path">
902 <p><b><?php echo fm_t('Change Permissions') ?></b></p>
903 <p>
904 <?php echo fm_t('Full path:') ?> <?php echo $file_path ?><br>
905 </p>
906 <form action="" method="post">
907 <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
908 <input type="hidden" name="chmod" value="<?php echo fm_enc($file) ?>">
909
910 <table class="compact-table">
911 <tr>
912 <td></td>
913 <td><b><?php echo fm_t('Owner') ?></b></td>
914 <td><b><?php echo fm_t('Group') ?></b></td>
915 <td><b><?php echo fm_t('Other') ?></b></td>
916 </tr>
917 <tr>
918 <td style="text-align: right"><b><?php echo fm_t('Read') ?></b></td>
919 <td><label><input type="checkbox" name="ur" value="1"<?php echo ($mode & 00400) ? ' checked' : '' ?>></label></td>
920 <td><label><input type="checkbox" name="gr" value="1"<?php echo ($mode & 00040) ? ' checked' : '' ?>></label></td>
921 <td><label><input type="checkbox" name="or" value="1"<?php echo ($mode & 00004) ? ' checked' : '' ?>></label></td>
922 </tr>
923 <tr>
924 <td style="text-align: right"><b><?php echo fm_t('Write') ?></b></td>
925 <td><label><input type="checkbox" name="uw" value="1"<?php echo ($mode & 00200) ? ' checked' : '' ?>></label></td>
926 <td><label><input type="checkbox" name="gw" value="1"<?php echo ($mode & 00020) ? ' checked' : '' ?>></label></td>
927 <td><label><input type="checkbox" name="ow" value="1"<?php echo ($mode & 00002) ? ' checked' : '' ?>></label></td>
928 </tr>
929 <tr>
930 <td style="text-align: right"><b><?php echo fm_t('Execute') ?></b></td>
931 <td><label><input type="checkbox" name="ux" value="1"<?php echo ($mode & 00100) ? ' checked' : '' ?>></label></td>
932 <td><label><input type="checkbox" name="gx" value="1"<?php echo ($mode & 00010) ? ' checked' : '' ?>></label></td>
933 <td><label><input type="checkbox" name="ox" value="1"<?php echo ($mode & 00001) ? ' checked' : '' ?>></label></td>
934 </tr>
935 </table>
936
937 <p>
938 <button type="submit" class="btn"><i class="icon-apply"></i> <?php echo fm_t('Change') ?></button>
939 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="icon-cancel"></i> <?php echo fm_t('Cancel') ?></a></b>
940 </p>
941
942 </form>
943
944 </div>
945 <?php
946 fm_show_footer();
947 exit;
948}
949
950//--- FILEMANAGER MAIN
951fm_show_header(); // HEADER
952fm_show_nav_path(FM_PATH); // current path
953
954// messages
955fm_show_message();
956
957$num_files = count($files);
958$num_folders = count($folders);
959$all_files_size = 0;
960?>
961<form action="" method="post">
962<input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
963<input type="hidden" name="group" value="1">
964<table><tr>
965<?php if (!FM_READONLY): ?><th style="width:3%"><label><input type="checkbox" title="<?php echo fm_t('Invert selection') ?>" onclick="checkbox_toggle()"></label></th><?php endif; ?>
966<th><?php echo fm_t('Name') ?></th><th style="width:10%"><?php echo fm_t('Size') ?></th>
967<th style="width:12%"><?php echo fm_t('Modified') ?></th><th style="width:6%"><?php echo fm_t('Perms') ?></th>
968<th style="width:10%"><?php echo fm_t('Owner') ?></th>
969<th style="width:<?php if (!FM_READONLY): ?>13<?php else: ?>6.5<?php endif; ?>%"></th></tr>
970<?php
971// link to parent folder
972if ($parent !== false) {
973 ?>
974<tr><?php if (!FM_READONLY): ?><td></td><?php endif; ?><td colspan="6"><a href="?p=<?php echo urlencode($parent) ?>"><i class="icon-arrow_up"></i> ..</a></td></tr>
975<?php
976}
977foreach ($folders as $f) {
978 $is_link = is_link($path . '/' . $f);
979 $img = $is_link ? 'icon-link_folder' : 'icon-folder';
980 $modif = date("d.m.y H:i", filemtime($path . '/' . $f));
981 $perms = substr(decoct(fileperms($path . '/' . $f)), -4);
982 if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
983 $owner = posix_getpwuid(fileowner($path . '/' . $f));
984 $group = posix_getgrgid(filegroup($path . '/' . $f));
985 } else {
986 $owner = array('name' => '?');
987 $group = array('name' => '?');
988 }
989 ?>
990<tr>
991<?php if (!FM_READONLY): ?><td><label><input type="checkbox" name="file[]" value="<?php echo fm_enc($f) ?>"></label></td><?php endif; ?>
992<td><div class="filename"><a href="?p=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="<?php echo $img ?>"></i> <?php echo fm_convert_win($f) ?></a><?php echo ($is_link ? ' → <i>' . readlink($path . '/' . $f) . '</i>' : '') ?></div></td>
993<td><?php echo fm_t('Folder') ?></td><td><?php echo $modif ?></td>
994<td><?php if (!FM_READONLY): ?><a title="<?php echo fm_t('Change Permissions') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&chmod=<?php echo urlencode($f) ?>"><?php echo $perms ?></a><?php else: ?><?php echo $perms ?><?php endif; ?></td>
995<td><?php echo $owner['name'] . ':' . $group['name'] ?></td>
996<td><?php if (!FM_READONLY): ?>
997<a title="<?php echo fm_t('Delete') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&del=<?php echo urlencode($f) ?>" onclick="return confirm('<?php echo fm_t('Delete folder?') ?>');"><i class="icon-cross"></i></a>
998<a title="<?php echo fm_t('Rename') ?>" href="#" onclick="rename('<?php echo fm_enc(FM_PATH) ?>', '<?php echo fm_enc($f) ?>');return false;"><i class="icon-rename"></i></a>
999<a title="<?php echo fm_t('Copy to...') ?>" href="?p=&copy=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="icon-copy"></i></a>
1000<?php endif; ?>
1001<a title="<?php echo fm_t('Direct link') ?>" href="<?php echo FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f . '/' ?>" target="_blank"><i class="icon-chain"></i></a>
1002</td></tr>
1003 <?php
1004 flush();
1005}
1006
1007foreach ($files as $f) {
1008 $is_link = is_link($path . '/' . $f);
1009 $img = $is_link ? 'icon-link_file' : fm_get_file_icon_class($path . '/' . $f);
1010 $modif = date("d.m.y H:i", filemtime($path . '/' . $f));
1011 $filesize_raw = filesize($path . '/' . $f);
1012 $filesize = fm_get_filesize($filesize_raw);
1013 $filelink = '?p=' . urlencode(FM_PATH) . '&view=' . urlencode($f);
1014 $all_files_size += $filesize_raw;
1015 $perms = substr(decoct(fileperms($path . '/' . $f)), -4);
1016 if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
1017 $owner = posix_getpwuid(fileowner($path . '/' . $f));
1018 $group = posix_getgrgid(filegroup($path . '/' . $f));
1019 } else {
1020 $owner = array('name' => '?');
1021 $group = array('name' => '?');
1022 }
1023 ?>
1024<tr>
1025<?php if (!FM_READONLY): ?><td><label><input type="checkbox" name="file[]" value="<?php echo fm_enc($f) ?>"></label></td><?php endif; ?>
1026<td><div class="filename"><a href="<?php echo $filelink ?>" title="<?php echo fm_t('File info') ?>"><i class="<?php echo $img ?>"></i> <?php echo fm_convert_win($f) ?></a><?php echo ($is_link ? ' → <i>' . readlink($path . '/' . $f) . '</i>' : '') ?></div></td>
1027<td><span title="<?php printf(fm_t('%s byte'), $filesize_raw) ?>"><?php echo $filesize ?></span></td>
1028<td><?php echo $modif ?></td>
1029<td><?php if (!FM_READONLY): ?><a title="<?php echo fm_t('Change Permissions') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&chmod=<?php echo urlencode($f) ?>"><?php echo $perms ?></a><?php else: ?><?php echo $perms ?><?php endif; ?></td>
1030<td><?php echo $owner['name'] . ':' . $group['name'] ?></td>
1031<td>
1032<?php if (!FM_READONLY): ?>
1033<a title="<?php echo fm_t('Delete') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&del=<?php echo urlencode($f) ?>" onclick="return confirm('<?php echo fm_t('Delete file?') ?>');"><i class="icon-cross"></i></a>
1034<a title="<?php echo fm_t('Rename') ?>" href="#" onclick="rename('<?php echo fm_enc(FM_PATH) ?>', '<?php echo fm_enc($f) ?>');return false;"><i class="icon-rename"></i></a>
1035<a title="<?php echo fm_t('Copy to...') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&copy=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="icon-copy"></i></a>
1036<?php endif; ?>
1037<a title="<?php echo fm_t('Direct link') ?>" href="<?php echo FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f ?>" target="_blank"><i class="icon-chain"></i></a>
1038<a title="<?php echo fm_t('Download') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&dl=<?php echo urlencode($f) ?>"><i class="icon-download"></i></a>
1039</td></tr>
1040 <?php
1041 flush();
1042}
1043
1044if (empty($folders) && empty($files)) {
1045 ?>
1046<tr><?php if (!FM_READONLY): ?><td></td><?php endif; ?><td colspan="6"><em><?php echo fm_t('Folder is empty') ?></em></td></tr>
1047<?php
1048} else {
1049 ?>
1050<tr><?php if (!FM_READONLY): ?><td class="gray"></td><?php endif; ?><td class="gray" colspan="6">
1051<?php echo fm_t('Full size:') ?> <span title="<?php printf(fm_t('%s byte'), $all_files_size) ?>"><?php echo fm_get_filesize($all_files_size) ?></span>,
1052<?php echo fm_t('files:') ?> <?php echo $num_files ?>,
1053<?php echo fm_t('folders:') ?> <?php echo $num_folders ?>
1054</td></tr>
1055<?php
1056}
1057?>
1058</table>
1059<?php if (!FM_READONLY): ?>
1060<p class="path"><a href="#" onclick="select_all();return false;"><i class="icon-checkbox"></i> <?php echo fm_t('Select all') ?></a>
1061<a href="#" onclick="unselect_all();return false;"><i class="icon-checkbox_uncheck"></i> <?php echo fm_t('Unselect all') ?></a>
1062<a href="#" onclick="invert_all();return false;"><i class="icon-checkbox_invert"></i> <?php echo fm_t('Invert selection') ?></a></p>
1063<p><input type="submit" name="delete" value="<?php echo fm_t('Delete') ?>" onclick="return confirm('<?php echo fm_t('Delete selected files and folders?') ?>')">
1064<input type="submit" name="zip" value="<?php echo fm_t('Pack') ?>" onclick="return confirm('<?php echo fm_t('Create archive?') ?>')">
1065<input type="submit" name="copy" value="<?php echo fm_t('Copy') ?>"></p>
1066<?php endif; ?>
1067</form>
1068
1069<?php
1070fm_show_footer();
1071
1072//--- END
1073
1074// Functions
1075
1076/**
1077 * Delete file or folder (recursively)
1078 * @param string $path
1079 * @return bool
1080 */
1081function fm_rdelete($path)
1082{
1083 if (is_link($path)) {
1084 return unlink($path);
1085 } elseif (is_dir($path)) {
1086 $objects = scandir($path);
1087 $ok = true;
1088 if (is_array($objects)) {
1089 foreach ($objects as $file) {
1090 if ($file != '.' && $file != '..') {
1091 if (!fm_rdelete($path . '/' . $file)) {
1092 $ok = false;
1093 }
1094 }
1095 }
1096 }
1097 return ($ok) ? rmdir($path) : false;
1098 } elseif (is_file($path)) {
1099 return unlink($path);
1100 }
1101 return false;
1102}
1103
1104/**
1105 * Recursive chmod
1106 * @param string $path
1107 * @param int $filemode
1108 * @param int $dirmode
1109 * @return bool
1110 * @todo Will use in mass chmod
1111 */
1112function fm_rchmod($path, $filemode, $dirmode)
1113{
1114 if (is_dir($path)) {
1115 if (!chmod($path, $dirmode)) {
1116 return false;
1117 }
1118 $objects = scandir($path);
1119 if (is_array($objects)) {
1120 foreach ($objects as $file) {
1121 if ($file != '.' && $file != '..') {
1122 if (!fm_rchmod($path . '/' . $file, $filemode, $dirmode)) {
1123 return false;
1124 }
1125 }
1126 }
1127 }
1128 return true;
1129 } elseif (is_link($path)) {
1130 return true;
1131 } elseif (is_file($path)) {
1132 return chmod($path, $filemode);
1133 }
1134 return false;
1135}
1136
1137/**
1138 * Safely rename
1139 * @param string $old
1140 * @param string $new
1141 * @return bool|null
1142 */
1143function fm_rename($old, $new)
1144{
1145 return (!file_exists($new) && file_exists($old)) ? rename($old, $new) : null;
1146}
1147
1148/**
1149 * Copy file or folder (recursively).
1150 * @param string $path
1151 * @param string $dest
1152 * @param bool $upd Update files
1153 * @param bool $force Create folder with same names instead file
1154 * @return bool
1155 */
1156function fm_rcopy($path, $dest, $upd = true, $force = true)
1157{
1158 if (is_dir($path)) {
1159 if (!fm_mkdir($dest, $force)) {
1160 return false;
1161 }
1162 $objects = scandir($path);
1163 $ok = true;
1164 if (is_array($objects)) {
1165 foreach ($objects as $file) {
1166 if ($file != '.' && $file != '..') {
1167 if (!fm_rcopy($path . '/' . $file, $dest . '/' . $file)) {
1168 $ok = false;
1169 }
1170 }
1171 }
1172 }
1173 return $ok;
1174 } elseif (is_file($path)) {
1175 return fm_copy($path, $dest, $upd);
1176 }
1177 return false;
1178}
1179
1180/**
1181 * Safely create folder
1182 * @param string $dir
1183 * @param bool $force
1184 * @return bool
1185 */
1186function fm_mkdir($dir, $force)
1187{
1188 if (file_exists($dir)) {
1189 if (is_dir($dir)) {
1190 return $dir;
1191 } elseif (!$force) {
1192 return false;
1193 }
1194 unlink($dir);
1195 }
1196 return mkdir($dir, 0777, true);
1197}
1198
1199/**
1200 * Safely copy file
1201 * @param string $f1
1202 * @param string $f2
1203 * @param bool $upd
1204 * @return bool
1205 */
1206function fm_copy($f1, $f2, $upd)
1207{
1208 $time1 = filemtime($f1);
1209 if (file_exists($f2)) {
1210 $time2 = filemtime($f2);
1211 if ($time2 >= $time1 && $upd) {
1212 return false;
1213 }
1214 }
1215 $ok = copy($f1, $f2);
1216 if ($ok) {
1217 touch($f2, $time1);
1218 }
1219 return $ok;
1220}
1221
1222/**
1223 * Get mime type
1224 * @param string $file_path
1225 * @return mixed|string
1226 */
1227function fm_get_mime_type($file_path)
1228{
1229 if (function_exists('finfo_open')) {
1230 $finfo = finfo_open(FILEINFO_MIME_TYPE);
1231 $mime = finfo_file($finfo, $file_path);
1232 finfo_close($finfo);
1233 return $mime;
1234 } elseif (function_exists('mime_content_type')) {
1235 return mime_content_type($file_path);
1236 } elseif (!stristr(ini_get('disable_functions'), 'shell_exec')) {
1237 $file = escapeshellarg($file_path);
1238 $mime = shell_exec('file -bi ' . $file);
1239 return $mime;
1240 } else {
1241 return '--';
1242 }
1243}
1244
1245/**
1246 * HTTP Redirect
1247 * @param string $url
1248 * @param int $code
1249 */
1250function fm_redirect($url, $code = 302)
1251{
1252 header('Location: ' . $url, true, $code);
1253 exit;
1254}
1255
1256/**
1257 * Clean path
1258 * @param string $path
1259 * @return string
1260 */
1261function fm_clean_path($path)
1262{
1263 $path = trim($path);
1264 $path = trim($path, '\\/');
1265 $path = str_replace(array('../', '..\\'), '', $path);
1266 if ($path == '..') {
1267 $path = '';
1268 }
1269 return str_replace('\\', '/', $path);
1270}
1271
1272/**
1273 * Get parent path
1274 * @param string $path
1275 * @return bool|string
1276 */
1277function fm_get_parent_path($path)
1278{
1279 $path = fm_clean_path($path);
1280 if ($path != '') {
1281 $array = explode('/', $path);
1282 if (count($array) > 1) {
1283 $array = array_slice($array, 0, -1);
1284 return implode('/', $array);
1285 }
1286 return '';
1287 }
1288 return false;
1289}
1290
1291/**
1292 * Get nice filesize
1293 * @param int $size
1294 * @return string
1295 */
1296function fm_get_filesize($size)
1297{
1298 if ($size < 1000) {
1299 return sprintf(fm_t('%s byte'), $size);
1300 } elseif (($size / 1024) < 1000) {
1301 return sprintf(fm_t('%s KB'), round(($size / 1024), 1));
1302 } elseif (($size / 1024 / 1024) < 1000) {
1303 return sprintf(fm_t('%s MB'), round(($size / 1024 / 1024), 1));
1304 } else {
1305 return sprintf(fm_t('%s GB'), round(($size / 1024 / 1024 / 1024), 1));
1306 }
1307}
1308
1309/**
1310 * Get info about zip archive
1311 * @param string $path
1312 * @return array|bool
1313 */
1314function fm_get_zif_info($path)
1315{
1316 if (function_exists('zip_open')) {
1317 $arch = zip_open($path);
1318 if ($arch) {
1319 $filenames = array();
1320 while ($zip_entry = zip_read($arch)) {
1321 $zip_name = zip_entry_name($zip_entry);
1322 $zip_folder = substr($zip_name, -1) == '/';
1323 $filenames[] = array(
1324 'name' => $zip_name,
1325 'filesize' => zip_entry_filesize($zip_entry),
1326 'compressed_size' => zip_entry_compressedsize($zip_entry),
1327 'folder' => $zip_folder
1328 //'compression_method' => zip_entry_compressionmethod($zip_entry),
1329 );
1330 }
1331 zip_close($arch);
1332 return $filenames;
1333 }
1334 }
1335 return false;
1336}
1337
1338/**
1339 * Encode html entities
1340 * @param string $text
1341 * @return string
1342 */
1343function fm_enc($text)
1344{
1345 return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
1346}
1347
1348/**
1349 * Save message in session
1350 * @param string $msg
1351 * @param string $status
1352 */
1353function fm_set_msg($msg, $status = 'ok')
1354{
1355 $_SESSION['message'] = $msg;
1356 $_SESSION['status'] = $status;
1357}
1358
1359/**
1360 * Check if string is in UTF-8
1361 * @param string $string
1362 * @return int
1363 */
1364function fm_is_utf8($string)
1365{
1366 return preg_match('//u', $string);
1367}
1368
1369/**
1370 * Convert file name to UTF-8 in Windows
1371 * @param string $filename
1372 * @return string
1373 */
1374function fm_convert_win($filename)
1375{
1376 if (FM_IS_WIN && function_exists('iconv')) {
1377 $filename = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $filename);
1378 }
1379 return $filename;
1380}
1381
1382/**
1383 * Get translated string
1384 * @param string $str
1385 * @param string|null $lang
1386 * @return string
1387 */
1388function fm_t($str, $lang = null)
1389{
1390 if ($lang === null) {
1391 if (defined('FM_LANG')) {
1392 $lang = FM_LANG;
1393 } else {
1394 return $str;
1395 }
1396 }
1397 $strings = fm_get_strings();
1398 if (!isset($strings[$lang]) || !is_array($strings[$lang])) {
1399 return $str;
1400 }
1401 if (array_key_exists($str, $strings[$lang])) {
1402 return $strings[$lang][$str];
1403 }
1404 return $str;
1405}
1406
1407/**
1408 * Get CSS classname for file
1409 * @param string $path
1410 * @return string
1411 */
1412function fm_get_file_icon_class($path)
1413{
1414 // get extension
1415 $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
1416
1417 switch ($ext) {
1418 case 'ico': case 'gif': case 'jpg': case 'jpeg': case 'jpc': case 'jp2':
1419 case 'jpx': case 'xbm': case 'wbmp': case 'png': case 'bmp': case 'tif':
1420 case 'tiff':
1421 $img = 'icon-file_image'; break;
1422 case 'txt': case 'css': case 'ini': case 'conf': case 'log': case 'htaccess':
1423 case 'passwd': case 'ftpquota': case 'sql': case 'js': case 'json': case 'sh':
1424 case 'config': case 'twig': case 'tpl': case 'md': case 'gitignore':
1425 case 'less': case 'sass': case 'scss': case 'c': case 'cpp': case 'cs': case 'py':
1426 case 'map': case 'lock': case 'dtd':
1427 $img = 'icon-file_text'; break;
1428 case 'zip': case 'rar': case 'gz': case 'tar': case '7z':
1429 $img = 'icon-file_zip'; break;
1430 case 'php': case 'php4': case 'php5': case 'phps': case 'phtml':
1431 $img = 'icon-file_php'; break;
1432 case 'htm': case 'html': case 'shtml': case 'xhtml':
1433 $img = 'icon-file_html'; break;
1434 case 'xml': case 'xsl': case 'svg':
1435 $img = 'icon-file_code'; break;
1436 case 'wav': case 'mp3': case 'mp2': case 'm4a': case 'aac': case 'ogg':
1437 case 'oga': case 'wma': case 'mka': case 'flac': case 'ac3': case 'tds':
1438 $img = 'icon-file_music'; break;
1439 case 'm3u': case 'm3u8': case 'pls': case 'cue':
1440 $img = 'icon-file_playlist'; break;
1441 case 'avi': case 'mpg': case 'mpeg': case 'mp4': case 'm4v': case 'flv':
1442 case 'f4v': case 'ogm': case 'ogv': case 'mov': case 'mkv': case '3gp':
1443 case 'asf': case 'wmv':
1444 $img = 'icon-file_film'; break;
1445 case 'eml': case 'msg':
1446 $img = 'icon-file_outlook'; break;
1447 case 'xls': case 'xlsx':
1448 $img = 'icon-file_excel'; break;
1449 case 'csv':
1450 $img = 'icon-file_csv'; break;
1451 case 'doc': case 'docx':
1452 $img = 'icon-file_word'; break;
1453 case 'ppt': case 'pptx':
1454 $img = 'icon-file_powerpoint'; break;
1455 case 'ttf': case 'ttc': case 'otf': case 'woff':case 'woff2': case 'eot': case 'fon':
1456 $img = 'icon-file_font'; break;
1457 case 'pdf':
1458 $img = 'icon-file_pdf'; break;
1459 case 'psd':
1460 $img = 'icon-file_photoshop'; break;
1461 case 'ai': case 'eps':
1462 $img = 'icon-file_illustrator'; break;
1463 case 'fla':
1464 $img = 'icon-file_flash'; break;
1465 case 'swf':
1466 $img = 'icon-file_swf'; break;
1467 case 'exe': case 'msi':
1468 $img = 'icon-file_application'; break;
1469 case 'bat':
1470 $img = 'icon-file_terminal'; break;
1471 default:
1472 $img = 'icon-document';
1473 }
1474
1475 return $img;
1476}
1477
1478/**
1479 * Get image files extensions
1480 * @return array
1481 */
1482function fm_get_image_exts()
1483{
1484 return array(
1485 'ico', 'gif', 'jpg', 'jpeg', 'jpc', 'jp2', 'jpx', 'xbm', 'wbmp', 'png', 'bmp', 'tif', 'tiff', 'psd',
1486 );
1487}
1488
1489/**
1490 * Get video files extensions
1491 * @return array
1492 */
1493function fm_get_video_exts()
1494{
1495 return array(
1496 'webm', 'mp4', 'm4v', 'ogm', 'ogv', 'mov',
1497 );
1498}
1499
1500/**
1501 * Get audio files extensions
1502 * @return array
1503 */
1504function fm_get_audio_exts()
1505{
1506 return array(
1507 'wav', 'mp3', 'ogg', 'm4a',
1508 );
1509}
1510
1511/**
1512 * Get text file extensions
1513 * @return array
1514 */
1515function fm_get_text_exts()
1516{
1517 return array(
1518 'txt', 'css', 'ini', 'conf', 'log', 'htaccess', 'passwd', 'ftpquota', 'sql', 'js', 'json', 'sh', 'config',
1519 'php', 'php4', 'php5', 'phps', 'phtml', 'htm', 'html', 'shtml', 'xhtml', 'xml', 'xsl', 'm3u', 'm3u8', 'pls', 'cue',
1520 'eml', 'msg', 'csv', 'bat', 'twig', 'tpl', 'md', 'gitignore', 'less', 'sass', 'scss', 'c', 'cpp', 'cs', 'py',
1521 'map', 'lock', 'dtd', 'svg',
1522 );
1523}
1524
1525/**
1526 * Get mime types of text files
1527 * @return array
1528 */
1529function fm_get_text_mimes()
1530{
1531 return array(
1532 'application/xml',
1533 'application/javascript',
1534 'application/x-javascript',
1535 'image/svg+xml',
1536 'message/rfc822',
1537 );
1538}
1539
1540/**
1541 * Get file names of text files w/o extensions
1542 * @return array
1543 */
1544function fm_get_text_names()
1545{
1546 return array(
1547 'license',
1548 'readme',
1549 'authors',
1550 'contributors',
1551 'changelog',
1552 );
1553}
1554
1555/**
1556 * Class to work with zip files (using ZipArchive)
1557 */
1558class FM_Zipper
1559{
1560 private $zip;
1561
1562 public function __construct()
1563 {
1564 $this->zip = new ZipArchive();
1565 }
1566
1567 /**
1568 * Create archive with name $filename and files $files (RELATIVE PATHS!)
1569 * @param string $filename
1570 * @param array|string $files
1571 * @return bool
1572 */
1573 public function create($filename, $files)
1574 {
1575 $res = $this->zip->open($filename, ZipArchive::CREATE);
1576 if ($res !== true) {
1577 return false;
1578 }
1579 if (is_array($files)) {
1580 foreach ($files as $f) {
1581 if (!$this->addFileOrDir($f)) {
1582 $this->zip->close();
1583 return false;
1584 }
1585 }
1586 $this->zip->close();
1587 return true;
1588 } else {
1589 if ($this->addFileOrDir($files)) {
1590 $this->zip->close();
1591 return true;
1592 }
1593 return false;
1594 }
1595 }
1596
1597 /**
1598 * Extract archive $filename to folder $path (RELATIVE OR ABSOLUTE PATHS)
1599 * @param string $filename
1600 * @param string $path
1601 * @return bool
1602 */
1603 public function unzip($filename, $path)
1604 {
1605 $res = $this->zip->open($filename);
1606 if ($res !== true) {
1607 return false;
1608 }
1609 if ($this->zip->extractTo($path)) {
1610 $this->zip->close();
1611 return true;
1612 }
1613 return false;
1614 }
1615
1616 /**
1617 * Add file/folder to archive
1618 * @param string $filename
1619 * @return bool
1620 */
1621 private function addFileOrDir($filename)
1622 {
1623 if (is_file($filename)) {
1624 return $this->zip->addFile($filename);
1625 } elseif (is_dir($filename)) {
1626 return $this->addDir($filename);
1627 }
1628 return false;
1629 }
1630
1631 /**
1632 * Add folder recursively
1633 * @param string $path
1634 * @return bool
1635 */
1636 private function addDir($path)
1637 {
1638 if (!$this->zip->addEmptyDir($path)) {
1639 return false;
1640 }
1641 $objects = scandir($path);
1642 if (is_array($objects)) {
1643 foreach ($objects as $file) {
1644 if ($file != '.' && $file != '..') {
1645 if (is_dir($path . '/' . $file)) {
1646 if (!$this->addDir($path . '/' . $file)) {
1647 return false;
1648 }
1649 } elseif (is_file($path . '/' . $file)) {
1650 if (!$this->zip->addFile($path . '/' . $file)) {
1651 return false;
1652 }
1653 }
1654 }
1655 }
1656 return true;
1657 }
1658 return false;
1659 }
1660}
1661
1662//--- templates functions
1663
1664/**
1665 * Show nav block
1666 * @param string $path
1667 */
1668function fm_show_nav_path($path)
1669{
1670 ?>
1671<div class="path">
1672<div class="float-right">
1673<?php if (!FM_READONLY): ?>
1674<a title="<?php echo fm_t('Upload files') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&upload"><i class="icon-upload"></i></a>
1675<a title="<?php echo fm_t('New folder') ?>" href="#" onclick="newfolder('<?php echo fm_enc(FM_PATH) ?>');return false;"><i class="icon-folder_add"></i></a>
1676<?php endif; ?>
1677<?php if (FM_USE_AUTH): ?><a title="<?php echo fm_t('Logout') ?>" href="?logout=1"><i class="icon-logout"></i></a><?php endif; ?>
1678</div>
1679 <?php
1680 $path = fm_clean_path($path);
1681 $root_url = "<a href='?p='><i class='icon-home' title='" . FM_ROOT_PATH . "'></i></a>";
1682 $sep = '<i class="icon-separator"></i>';
1683 if ($path != '') {
1684 $exploded = explode('/', $path);
1685 $count = count($exploded);
1686 $array = array();
1687 $parent = '';
1688 for ($i = 0; $i < $count; $i++) {
1689 $parent = trim($parent . '/' . $exploded[$i], '/');
1690 $parent_enc = urlencode($parent);
1691 $array[] = "<a href='?p={$parent_enc}'>" . fm_convert_win($exploded[$i]) . "</a>";
1692 }
1693 $root_url .= $sep . implode($sep, $array);
1694 }
1695 echo '<div class="break-word">' . $root_url . '</div>';
1696 ?>
1697</div>
1698<?php
1699}
1700
1701/**
1702 * Show message from session
1703 */
1704function fm_show_message()
1705{
1706 if (isset($_SESSION['message'])) {
1707 $class = isset($_SESSION['status']) ? $_SESSION['status'] : 'ok';
1708 echo '<p class="message ' . $class . '">' . $_SESSION['message'] . '</p>';
1709 unset($_SESSION['message']);
1710 unset($_SESSION['status']);
1711 }
1712}
1713
1714/**
1715 * Show page header
1716 */
1717function fm_show_header()
1718{
1719 $sprites_ver = '20160315';
1720 header("Content-Type: text/html; charset=utf-8");
1721 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
1722 header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
1723 header("Pragma: no-cache");
1724 ?>
1725<!DOCTYPE html>
1726<html>
1727<head>
1728<meta charset="utf-8">
1729<title>File Manager</title>
1730<style>
1731html,body,div,span,p,pre,a,code,em,img,small,strong,ol,ul,li,form,label,table,tr,th,td{margin:0;padding:0;vertical-align:baseline;outline:none;font-size:100%;background:transparent;border:none;text-decoration:none}
1732html{overflow-y:scroll}body{padding:0;font:13px/16px Tahoma,Arial,sans-serif;color:#222;background:#efefef}
1733input,select,textarea,button{font-size:inherit;font-family:inherit}
1734a{color:#296ea3;text-decoration:none}a:hover{color:#b00}img{vertical-align:middle;border:none}
1735a img{border:none}span{color:#777}small{font-size:11px;color:#999}p{margin-bottom:10px}
1736ul{margin-left:2em;margin-bottom:10px}ul{list-style-type:none;margin-left:0}ul li{padding:3px 0}
1737table{border-collapse:collapse;border-spacing:0;margin-bottom:10px;width:100%}
1738th,td{padding:4px 7px;text-align:left;vertical-align:top;border:1px solid #ddd;background:#fff;white-space:nowrap}
1739th,td.gray{background-color:#eee}td.gray span{color:#222}
1740tr:hover td{background-color:#f5f5f5}tr:hover td.gray{background-color:#eee}
1741code,pre{display:block;margin-bottom:10px;font:13px/16px Consolas,'Courier New',Courier,monospace;border:1px dashed #ccc;padding:5px;overflow:auto}
1742pre.with-hljs{padding:0}
1743pre.with-hljs code{margin:0;border:0;overflow:visible}
1744code.maxheight,pre.maxheight{max-height:512px}input[type="checkbox"]{margin:0;padding:0}
1745#wrapper{max-width:1000px;min-width:400px;margin:10px auto}
1746.path{padding:4px 7px;border:1px solid #ddd;background-color:#fff;margin-bottom:10px}
1747.right{text-align:right}.center{text-align:center}.float-right{float:right}
1748.message{padding:4px 7px;border:1px solid #ddd;background-color:#fff}
1749.message.ok{border-color:green;color:green}
1750.message.error{border-color:red;color:red}
1751.message.alert{border-color:orange;color:orange}
1752.btn{border:0;background:none;padding:0;margin:0;font-weight:bold;color:#296ea3;cursor:pointer}.btn:hover{color:#b00}
1753.preview-img{max-width:100%;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAKklEQVR42mL5//8/Azbw+PFjrOJMDCSCUQ3EABZc4S0rKzsaSvTTABBgAMyfCMsY4B9iAAAAAElFTkSuQmCC") repeat 0 0}
1754.preview-video{position:relative;max-width:100%;height:0;padding-bottom:62.5%;margin-bottom:10px}.preview-video video{position:absolute;width:100%;height:100%;left:0;top:0;background:#000}
1755[class*="icon-"]{display:inline-block;width:16px;height:16px;background:url("<?php echo FM_SELF_URL ?>?img=sprites&t=<?php echo $sprites_ver ?>") no-repeat 0 0;vertical-align:bottom}
1756.icon-document{background-position:-16px 0}.icon-folder{background-position:-32px 0}
1757.icon-folder_add{background-position:-48px 0}.icon-upload{background-position:-64px 0}
1758.icon-arrow_up{background-position:-80px 0}.icon-home{background-position:-96px 0}
1759.icon-separator{background-position:-112px 0}.icon-cross{background-position:-128px 0}
1760.icon-copy{background-position:-144px 0}.icon-apply{background-position:-160px 0}
1761.icon-cancel{background-position:-176px 0}.icon-rename{background-position:-192px 0}
1762.icon-checkbox{background-position:-208px 0}.icon-checkbox_invert{background-position:-224px 0}
1763.icon-checkbox_uncheck{background-position:-240px 0}.icon-download{background-position:-256px 0}
1764.icon-goback{background-position:-272px 0}.icon-folder_open{background-position:-288px 0}
1765.icon-file_application{background-position:0 -16px}.icon-file_code{background-position:-16px -16px}
1766.icon-file_csv{background-position:-32px -16px}.icon-file_excel{background-position:-48px -16px}
1767.icon-file_film{background-position:-64px -16px}.icon-file_flash{background-position:-80px -16px}
1768.icon-file_font{background-position:-96px -16px}.icon-file_html{background-position:-112px -16px}
1769.icon-file_illustrator{background-position:-128px -16px}.icon-file_image{background-position:-144px -16px}
1770.icon-file_music{background-position:-160px -16px}.icon-file_outlook{background-position:-176px -16px}
1771.icon-file_pdf{background-position:-192px -16px}.icon-file_photoshop{background-position:-208px -16px}
1772.icon-file_php{background-position:-224px -16px}.icon-file_playlist{background-position:-240px -16px}
1773.icon-file_powerpoint{background-position:-256px -16px}.icon-file_swf{background-position:-272px -16px}
1774.icon-file_terminal{background-position:-288px -16px}.icon-file_text{background-position:-304px -16px}
1775.icon-file_word{background-position:-320px -16px}.icon-file_zip{background-position:-336px -16px}
1776.icon-logout{background-position:-304px 0}.icon-chain{background-position:-320px 0}
1777.icon-link_folder{background-position:-352px -16px}.icon-link_file{background-position:-368px -16px}
1778.compact-table{border:0;width:auto}.compact-table td,.compact-table th{width:100px;border:0;text-align:center}.compact-table tr:hover td{background-color:#fff}
1779.filename{max-width:420px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
1780.break-word{word-wrap:break-word}
1781</style>
1782<link rel="icon" href="<?php echo FM_SELF_URL ?>?img=favicon" type="image/png">
1783<link rel="shortcut icon" href="<?php echo FM_SELF_URL ?>?img=favicon" type="image/png">
1784<?php if (isset($_GET['view']) && FM_USE_HIGHLIGHTJS): ?>
1785<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/styles/<?php echo FM_HIGHLIGHTJS_STYLE ?>.min.css">
1786<?php endif; ?>
1787</head>
1788<body>
1789<div id="wrapper">
1790<?php
1791}
1792
1793/**
1794 * Show page footer
1795 */
1796function fm_show_footer()
1797{
1798 ?>
1799<p class="center"><small><a href="https://github.com/alexantr/filemanager" target="_blank">PHP File Manager</a></small></p>
1800</div>
1801<script>
1802function newfolder(p){var n=prompt('<?php echo fm_t('New folder name') ?>','folder');if(n!==null&&n!==''){window.location.search='p='+encodeURIComponent(p)+'&new='+encodeURIComponent(n);}}
1803function rename(p,f){var n=prompt('<?php echo fm_t('New name') ?>',f);if(n!==null&&n!==''&&n!=f){window.location.search='p='+encodeURIComponent(p)+'&ren='+encodeURIComponent(f)+'&to='+encodeURIComponent(n);}}
1804function change_checkboxes(l,v){for(var i=l.length-1;i>=0;i--){l[i].checked=(typeof v==='boolean')?v:!l[i].checked;}}
1805function get_checkboxes(){var i=document.getElementsByName('file[]'),a=[];for(var j=i.length-1;j>=0;j--){if(i[j].type='checkbox'){a.push(i[j]);}}return a;}
1806function select_all(){var l=get_checkboxes();change_checkboxes(l,true);}
1807function unselect_all(){var l=get_checkboxes();change_checkboxes(l,false);}
1808function invert_all(){var l=get_checkboxes();change_checkboxes(l);}
1809function checkbox_toggle(){var l=get_checkboxes();l.push(this);change_checkboxes(l);}
1810</script>
1811<?php if (isset($_GET['view']) && FM_USE_HIGHLIGHTJS): ?>
1812<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/highlight.min.js"></script>
1813<script>hljs.initHighlightingOnLoad();</script>
1814<?php endif; ?>
1815</body>
1816</html>
1817<?php
1818}
1819
1820/**
1821 * Show image
1822 * @param string $img
1823 */
1824function fm_show_image($img)
1825{
1826 $modified_time = gmdate('D, d M Y 00:00:00') . ' GMT';
1827 $expires_time = gmdate('D, d M Y 00:00:00', strtotime('+1 day')) . ' GMT';
1828
1829 $img = trim($img);
1830 $images = fm_get_images();
1831 $image = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAEElEQVR42mL4//8/A0CAAQAI/AL+26JNFgAAAABJRU5ErkJggg==';
1832 if (isset($images[$img])) {
1833 $image = $images[$img];
1834 }
1835 $image = base64_decode($image);
1836 if (function_exists('mb_strlen')) {
1837 $size = mb_strlen($image, '8bit');
1838 } else {
1839 $size = strlen($image);
1840 }
1841
1842 if (function_exists('header_remove')) {
1843 header_remove('Cache-Control');
1844 header_remove('Pragma');
1845 } else {
1846 header('Cache-Control:');
1847 header('Pragma:');
1848 }
1849
1850 header('Last-Modified: ' . $modified_time, true, 200);
1851 header('Expires: ' . $expires_time);
1852 header('Content-Length: ' . $size);
1853 header('Content-Type: image/png');
1854 echo $image;
1855
1856 exit;
1857}
1858
1859/**
1860 * Get base64-encoded images
1861 * @return array
1862 */
1863function fm_get_images()
1864{
1865 return array(
1866 'favicon' => 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ
1867bWFnZVJlYWR5ccllPAAAAZVJREFUeNqkk79Lw0AUx1+uidTQim4Waxfpnl1BcHMR6uLkIF0cpYOI
1868f4KbOFcRwbGTc0HQSVQQXCqlFIXgFkhIyvWS870LaaPYH9CDy8vdfb+fey930aSUMEvT6VHVzw8x
1869rKUX3N3Hj/8M+cZ6GcOtBPl6KY5iAA7KJzfVWrfbhUKhALZtQ6myDf1+X5nsuzjLUmUOnpa+v5r1
1870Z4ZDDfsLiwER45xDEATgOI6KntfDd091GidzC8vZ4vH1QQ09+4MSMAMWRREKPMhmsyr6voYmrnb2
1871PKEizdEabUaeFCDKCCHAdV0wTVNFznMgpVqGlZ2cipzHGtKSZwCIZJgJwxB38KHT6Sjx21V75Jcn
1872LXmGAKTRpGVZUx2dAqQzSEqw9kqwuGqONTufPrw37D8lQFxCvjgPXIixANLEGfwuQacMOC4kZz+q
1873GdhJS550BjpRCdCbAJCMJRkMASEIg+4Bxz4JwAwDSEueAYDLIM+QrOk6GHiRxjXSkJY8KUCvdXZ6
1874kbuvNx+mOcbN9taGBlpLAWf9nX8EGADoCfqkKWV/cgAAAABJRU5ErkJggg==',
1875 'sprites' => 'iVBORw0KGgoAAAANSUhEUgAAAYAAAAAgCAMAAAAscl/XAAAC/VBMVEUAAABUfn4KKipIcXFSeXsx
1876VlZSUlNAZ2c4Xl4lSUkRDg7w8O/d3d3LhwAWFhYXODgMLCx8fHw9PT2TtdOOAACMXgE8lt+dmpq+
1877fgABS3RUpN+VUycuh9IgeMJUe4C5dUI6meKkAQEKCgoMWp5qtusJmxSUPgKudAAXCghQMieMAgIU
1878abNSUlJLe70VAQEsh85oaGjBEhIBOGxfAoyUbUQAkw8gui4LBgbOiFPHx8cZX6PMS1OqFha/MjIK
1879VKFGBABSAXovGAkrg86xAgIoS5Y7c6Nf7W1Hz1NmAQB3Hgx8fHyiTAAwp+eTz/JdDAJ0JwAAlxCQ
1880UAAvmeRiYp6ysrmIAABJr/ErmiKmcsATpRyfEBAOdQgOXahyAAAecr1JCwHMiABgfK92doQGBgZG
1881AGkqKiw0ldYuTHCYsF86gB05UlJmQSlra2tVWED////8/f3t9fX5/Pzi8/Px9vb2+/v0+fnn8vLf
18827OzZ6enV5+eTpKTo6Oj6/v765Z/U5eX4+Pjx+Pjv0ojWBASxw8O8vL52dnfR19CvAADR3PHr6+vi
18834uPDx8v/866nZDO7iNT335jtzIL+7aj86aTIztXDw8X13JOlpKJoaHDJAACltratrq3lAgKfAADb
18844vb76N2au9by2I9gYGVIRkhNTE90wfXq2sh8gL8QMZ3pyn27AADr+uu1traNiIh2olTTshifodQ4
1885ZM663PH97+YeRq2GqmRjmkGjnEDnfjLVVg6W4f7s6/p/0fr98+5UVF6wz+SjxNsmVb5RUVWMrc7d
1886zrrIpWI8PD3pkwhCltZFYbNZja82wPv05NPRdXzhvna4uFdIiibPegGQXankxyxe0P7PnOhTkDGA
1887gBrbhgR9fX9bW1u8nRFamcgvVrACJIvlXV06nvtdgON4mdn3og7AagBTufkucO7snJz4b28XEhIT
1888sflynsLEvIk55kr866aewo2YuYDrnFffOTk6Li6hgAn3y8XkusCHZQbt0NP571lqRDZyMw96lZXE
1889s6qcrMmJaTmVdRW2AAAAbnRSTlMAZodsJHZocHN7hP77gnaCZWdx/ki+RfqOd/7+zc9N/szMZlf8
1890z8yeQybOzlv+tP5q/qKRbk78i/vZmf798s3MojiYjTj+/vqKbFc2/vvMzJiPXPzbs4z9++bj1XbN
1891uJxhyMBWwJbp28C9tJ6L1xTnMfMAAA79SURBVGje7Jn5b8thHMcfzLDWULXq2upqHT2kbrVSrJYx
1892NzHmviWOrCudqxhbNdZqHauKJTZHm0j0ByYkVBCTiC1+EH6YRBY/EJnjD3D84PMc3++39Z1rjp+8
1893Kn189rT5Pt/363k+3YHEDOrCSKP16t48q8U1IysLAUKZk1obLBYDKjAUoB8ziLv4vyQLQD+Lcf4Q
1894jvno90kfDaQTRhcioIv7QPk2oJqF0PsIT29RzQdOEhfKG6QW8lcoLIYxjWPQD2GXr/63BhYsWrQA
1895fYc0JSaNxa8dH4zUEYag32f009DTkNTnC4WkpcRAl4ryHTt37d5/ugxCIIEfZ0Dg4poFThIXygSp
1896hfybmhSWLS0dCpDrdFMRZubUkmJ2+d344qIU8sayN8iFQaBgMDy+FWA/wjelOmbrHUKVtQgxFqFc
1897JeE2RpmLEIlfFazzer3hcOAPCQiFasNheAo9HQ1f6FZRTgzs2bOnFwn8+AnG8d6impClTkSjCXWW
1898kH80GmUGWP6A4kKkQwG616/tOhin6kii3dzl5YHqT58+bf5KQdq8IjCAg3+tk3NDCoPZC2fQuGcI
18997+8nKQMk/b41r048UKOk48zln4MgesydOw0NDbeVCA2B+FVaEIDz/0MCSkOlAa+3tDRQSgW4t1MD
1900+7d1Q8DA9/sY7weKapZ/Qp+tzwYDtLyRiOrBANQ0/3hTMBIJNsXPb0GM5ANfrLO3telmTrWXGBG7
1901fHVHbWjetKKiPCJsAkQv17VNaANv6zJTWAcvmCEtI0hnII4RLsIIBIjmHStXaqKzNCtXOvj+STxl
1902OXKwgDuEBuAOEQDxgwDIv85bCwKMw6B5DzOyoVMCHpc+Dnu9gUD4MSeAGWACTnCBnxgorgGHRqPR
1903Z8OTg5ZqtRoEwLODy79JdfiwqgkMGBAlJ4caYK3HNGGCHedPBLgqtld30IbmLZk2jTsB9jadboJ9
1904Aj4BMqlAXCqV4e3udGH8zn6CgMrtQCUIoPMEbj5Xk3jS3N78UpPL7R81kJOTHdU7QACff/9kAbD/
1905IxHvEGTcmi/1+/NlMjJsNXZKAAcIoAkwA0zAvqOMfQNFNcOsf2BGAppotl6D+P0fi6nOnFHFYk1x
1906CzOgvqEGA4ICk91uQpQee90V1W58fdYDx0Ls+JnmTwy02e32iRNJB5L5X7y4/Pzq1buXX/lb/X4Z
1907SRtTo4C8uf6/Nez11dRI0pkNCswzA+Yn7e3NZi5/aKcYaKPqLBDw5iHPKGUutCAQoKqri0QizsgW
1908lJ6/1mqNK4C41bo2P72TnwEMEEASYAa29SCBHz1J2fdo4ExRTbHl5NiSBWQ/yGYCLBnFLbFY8PPn
1909YCzWUpxhYS9IJDSIx1iydKJpKTPQ0+lyV9MuCEcQJw+tH57Hjcubhyhy00TAJEdAuocX4Gn1eNJJ
1910wHG/xB+PQ8BC/6/0ejw1nAAJAeZ5A83tNH+kuaHHZD8A1MsRUvZ/c0WgPwhQBbGAiAQz2CjzZSJr
1911GOxKw1aU6ZOhX2ZK6GYZ42ZoChbgdDED5UzAWcLRR4+cA0U1ZfmiRcuRgJkIYIwBARThuyDzE7hf
1912nulLR5qKS5aWMAFOV7WrghjAAvKKpoEByH8J5C8WMELCC5AckkhGYCeS1lZfa6uf2/AuoM51yePB
1913DYrM18AD/sE8Z2DSJLaeLHNCr385C9iowbekfHOvQWBN4dzxXhUIuIRPgD+yCskWrs3MOETIyFy7
1914sFMC9roYe0EA2YLMwIGeCBh68iDh5P2TFUOhzhs3LammFC5YUIgEVmY/mKVJ4wTUx2JvP358G4vV
19158wLo/TKKl45cWgwaTNNx1b3M6TwNh5DuANJ7xk37Kv+RBDCAtzMvoPJUZSUVID116pTUw3ecyPZI
1916vHIzfEQXMAEeAszzpKUhoR81m4GVNnJHyocN/Xnu2NLmaj/CEVBdqvX5FArvXGTYoAhIaxUb2GDo
1917jAD3doabCeAMVFABZ6mAs/fP7sCBLykal1KjYemMYYhh2zgrWUBLi2r8eFVLiyDAlpS/ccXIkSXk
1918IJTIiYAy52l8COkOoAZE+ZtMzEA/p8ApJ/lcldX4fc98fn8Nt+Fhd/Lbnc4DdF68fjgNzZMQhQkQ
1919UKK52mAQC/D5fHVe6VyEDBlWqzXDwAbUGQEHdjAOgACcAGegojsRcPAY4eD9g7uGonl5S4oWL77G
192017D+fF/AewmzkDNQaG5v1+SmCtASAWKgAVWtKKD/w0egD/TC005igO2AsctAQB6/RU1VVVUmuZwM
1921CM3oJ2CB7+1xwPkeQj4TUOM5x/o/IJoXrR8MJAkY9ab/PZ41uZwAr88nBUDA7wICyncyypkAzoCb
1922CbhIgMCbh6K8d5jFfA3346qUePywmtrDfAdcrmmfZeMENNbXq7Taj/X1Hf8qYk7VxOlcMwIRfbt2
19237bq5jBqAHUANLFlmRBzyFVUr5NyQgoUdqcGZhMFGmrfUA5D+L57vcP25thQBArZCIkCl/eCF/IE5
19246PdZHzqwjXEgtB6+0KuMM+DuRQQcowKO3T/WjE/A4ndwAmhNBXjq4q1wyluLamWIN2Aebl4uCAhq
1925x2u/JUA+Z46Ri4aeBLYHYAEggBooSHmDXBgE1lnggcQU0LgLUMekrl+EclQSSgQCVFrVnFWTKav+
1926xAlY35Vn/RTSA4gB517X3j4IGMC1oOsHB8yEetm7xSl15kL4TVIAfjDxKjIRT6Ft0iQb3da3GhuD
1927QGPjrWL0E7AlsAX8ZUTr/xFzIP7pRvQ36SsI6Yvr+QN45uN607JlKbUhg8eAOgB2S4bFarVk/PyG
19286Sss4O/y4/WL7+avxS/+e8D/+ku31tKbRBSFXSg+6iOpMRiiLrQ7JUQ3vhIXKks36h/QhY+FIFJ8
1929pEkx7QwdxYUJjRC1mAEF0aK2WEActVVpUbE2mBYp1VofaGyibW19LDSeOxdm7jCDNI0rv0lIvp7v
1930nnPnHKaQ+zHV/sxcPlPZT5Hrp69SEVg1vdgP+C/58cOT00+5P2pKreynyPWr1s+Ff4EOOzpctTt2
1931rir2A/bdxPhSghfrt9TxcCVlcWU+r5NH+ukk9fu6MYZL1NtwA9De3n6/dD4GA/N1EYwRxXzl+7NL
1932i/FJUo9y0Mp+inw/Kgp9BwZz5wxArV5e7AfcNGDcLMGL9XXnEOpcAVlcmXe+QYAJTFLfbcDoLlGv
1933/QaeQKiwfusuH8BB5EMnfYcKPGLAiCjmK98frQFDK9kvNZdW9lPk96cySKAq9gOCxmBw7hd4LcGl
1934enQDBsOoAW5AFlfkMICnhqdvDJ3pSerDRje8/93GMM9xwwznhHowAINhCA0gz5f5MOxiviYG8K4F
1935XoBHjO6RkdNuY4TI9wFuoZBPFfd6vR6EOAIaQHV9vaO+sJ8Ek7gAF5OQ7JeqoJX9FPn9qYwSqIr9
1936gGB10BYMfqkOluBIr6Y7AHQz4q4667k6q8sVIOI4n5zjARjfGDtH0j1E/FoepP4dg+Nha/fwk+Fu
1937axj0uN650e+vxHqhG6YbptcmbSjPd13H8In5TRaU7+Ix4GgAI5Fx7qkxIuY7N54T86m89mba6WTZ
1938Do/H2+HhB3Cstra2sP9EdSIGV3VCcn+Umlb2U+T9UJmsBEyqYj+gzWJrg8vSVoIjPW3vWLjQY6fx
1939DXDcKOcKNBBxyFdTQ3KmSqOpauF5upPjuE4u3UPEhQGI66FhR4/iAYQfwGUNgx7Xq3v1anxUqBdq
1940j8WG7mlD/jzfcf0jf+0Q8s9saoJnYFBzkWHgrC9qjUS58RFrVMw3ynE5IZ/Km2lsZtmMF9p/544X
1941DcAEDwDAXo/iA5bEXd9dn2VAcr/qWlrZT5H7LSqrmYBVxfsBc5trTjbbeD+g7crNNuj4lTZYocSR
1942nqa99+97aBrxgKvV5WoNNDTgeMFfSCYJzmi2ATQtiKfTrZ2t6daeHiLeD81PpVLXiPVmaBgfD1eE
1943hy8Nwyvocb1X7tx4a7JQz98eg/8/sYQ/z3cXngDJfizm94feHzqMBsBFotFohIsK+Vw5t0vcv8pD
19440SzVjPvPdixH648eO1YLmIviUMp33Xc9FpLkp2i1sp8i91sqzRUEzJUgMNbQdrPZTtceBEHvlc+f
1945P/f2XumFFUoc6Z2Nnvu/4o1OxBsC7kAgl2s4T8RN1RPJ5ITIP22rulXVsi2LeE/aja6et4T+Zxja
1946/yOVEtfzDePjfRW2cF/YVtGH9LhebuPqBqGeP9QUCjVd97/M82U7fAg77EL+WU0Igy2DDDMLDeBS
1947JBq5xEWFfDl3MiDmq/R0wNvfy7efdd5BAzDWow8Bh6OerxdLDDgGHDE/eb9oAsp+itxvqaw4QaCi
1948Eh1HXz2DFGfOHp+FGo7RCyuUONI7nZ7MWNzpRLwhj/NE3GRKfp9Iilyv0XVpuqr0iPfk8ZbQj/2E
1949/v/4kQIu+BODhwYhjgaAN9oHeqV6L/0YLwv5tu7dAXCYJfthtg22tPA8yrUicFHlfDCATKYD+o/a
195074QBoPVHjuJnAOIwAAy/JD9Fk37K/auif0L6LRc38IfjNQRO8AOoYRthhuxJCyTY/wwjaKZpCS/4
1951BaBnG+NDQ/FGFvEt5zGSRNz4fSPgu8D1XTqdblCnR3zxW4yHhP7j2M/fT09dTgnr8w1DfFEfRhj0
1952SvXWvMTwYa7gb8yA97/unQ59F5oBJnsUI6KcDz0B0H/+7S8MwG6DR8Bhd6D4Jj9GQlqPogk/JZs9
1953K/gn5H40e7aL7oToUYAfYMvUnMw40Gkw4Q80O6XcLMRZFgYwxrKl4saJjabqjRMCf6QDdOkeldJ/
1954BfSnrvWLcWgYxGX6KfPswEKLZVL6yrgXvv6g9uMBoDic3B/9e36KLvDNS7TZ7K3sGdE/wfoqDQD9
1955NGG+9AmYL/MDRM5iLo9nqDEYAJWRx5U5o+3SaHRaplS8H+Faf78Yh4bJ8k2Vz24qgJldXj8/DkCf
1956wDy8fH/sdpujTD2KxhxM/ueA249E/wTru/Dfl05bPkeC5TI/QOAvbJjL47TnI8BDy+KlOJPV6bJM
1957yfg3wNf+r99KxafOibNu5IQvKKsv2x9lTtEFvmGlXq9/rFeL/gnWD2kB6KcwcpB+wP/IyeP2svqp
19589oeiCT9Fr1cL/gmp125aUc4P+B85iX+qJ/la0k/Ze0D0T0j93jXTpv0BYUGhQhdSooYAAAAASUVO
1959RK5CYII=',
1960 );
1961}
1962
1963/**
1964 * Get all translations
1965 * @return array
1966 */
1967function fm_get_strings()
1968{
1969 static $strings;
1970 if ($strings !== null) {
1971 return $strings;
1972 }
1973 $strings = array();
1974 $strings['ru'] = array(
1975 'Folder <b>%s</b> deleted' => 'Папка <b>%s</b> удалена',
1976 'Folder <b>%s</b> not deleted' => 'Папка <b>%s</b> не удалена',
1977 'File <b>%s</b> deleted' => 'Файл <b>%s</b> удален',
1978 'File <b>%s</b> not deleted' => 'Файл <b>%s</b> не удален',
1979 'Wrong file or folder name' => 'Ð˜Ð¼Ñ Ð¿Ð°Ð¿ÐºÐ¸ или файла задано не верно',
1980 'Folder <b>%s</b> created' => 'Папка <b>%s</b> Ñоздана',
1981 'Folder <b>%s</b> already exists' => 'Папка <b>%s</b> уже ÑущеÑтвует',
1982 'Folder <b>%s</b> not created' => 'Папка <b>%s</b> не Ñоздана',
1983 'Wrong folder name' => 'Ð˜Ð¼Ñ Ð¿Ð°Ð¿ÐºÐ¸ задано не верно',
1984 'Source path not defined' => 'Ðе задан иÑходный путь',
1985 'Moved from <b>%s</b> to <b>%s</b>' => 'Перемещено из <b>%s</b> в <b>%s</b>',
1986 'File or folder with this path already exists' => 'Файл или папка уже еÑть по указанному пути',
1987 'Error while moving from <b>%s</b> to <b>%s</b>' => 'Произошла ошибка при перемещении из <b>%s</b> в <b>%s</b>',
1988 'Copyied from <b>%s</b> to <b>%s</b>' => 'Скопировано из <b>%s</b> в <b>%s</b>',
1989 'Error while copying from <b>%s</b> to <b>%s</b>' => 'Произошла ошибка при копировании из <b>%s</b> в <b>%s</b>',
1990 'Paths must be not equal' => 'Пути не должны Ñовпадать',
1991 'Unable to create destination folder' => 'Ðевозможно Ñоздать папку назначениÑ',
1992 'Selected files and folders moved' => 'Ð’Ñе отмеченные файлы и папки перемещены',
1993 'Selected files and folders copied' => 'Ð’Ñе отмеченные файлы и папки Ñопированы',
1994 'Error while moving items' => 'При перемещении возникли ошибки',
1995 'Error while copying items' => 'При копировании возникли ошибки',
1996 'Nothing selected' => 'Ðичего не выбрано',
1997 'Renamed from <b>%s</b> to <b>%s</b>' => 'Переименовано из <b>%s</b> в <b>%s</b>',
1998 'Error while renaming from <b>%s</b> to <b>%s</b>' => 'Произошла ошибка при переименовании из <b>%s</b> в <b>%s</b>',
1999 'Names not set' => 'Ðе заданы имена',
2000 'File not found' => 'Файл не найден',
2001 'All files uploaded to <b>%s</b>' => 'Ð’Ñе файлы загружены в папку <b>%s</b>',
2002 'Nothing uploaded' => 'Ðичего не загружено',
2003 'Error while uploading files. Uploaded files: %s' => 'При загрузке файлов возникли ошибки. Загружено файлов: %s',
2004 'Selected files and folder deleted' => 'Ð’Ñе отмеченные файлы и папки удалены',
2005 'Error while deleting items' => 'При удалении возникли ошибки',
2006 'Archive <b>%s</b> created' => 'Ðрхив <b>%s</b> уÑпешно Ñоздан',
2007 'Archive not created' => 'Ошибка. Ðрхив не Ñоздан',
2008 'Archive unpacked' => 'Ðрхив раÑпакован',
2009 'Archive not unpacked' => 'Ðрхив не раÑпакован',
2010 'Uploading files' => 'Загрузка файлов',
2011 'Destination folder:' => 'Папка назначениÑ:',
2012 'Upload' => 'Загрузить',
2013 'Cancel' => 'Отмена',
2014 'Copying' => 'Копирование',
2015 'Files:' => 'Файлы:',
2016 'Source folder:' => 'ИÑÑ…Ð¾Ð´Ð½Ð°Ñ Ð¿Ð°Ð¿ÐºÐ°:',
2017 'Move' => 'ПеремеÑтить',
2018 'Select folder:' => 'Выбрать папку:',
2019 'Source path:' => 'ИÑходный путь:',
2020 'Archive' => 'Ðрхив',
2021 'Full path:' => 'Полный путь:',
2022 'File size:' => 'Размер файла:',
2023 'Files in archive:' => 'Файлов в архиве:',
2024 'Total size:' => 'Общий размер:',
2025 'Size in archive:' => 'Размер в архиве:',
2026 'Compression:' => 'Степень ÑжатиÑ:',
2027 'Open' => 'Открыть',
2028 'Unpack' => 'РаÑпаковать',
2029 'Unpack to' => 'РаÑпаковать в',
2030 'Unpack to folder' => 'РаÑпаковать в папку',
2031 'Back' => 'Ðазад',
2032 'Error while fetching archive info' => 'Ошибка Ð¿Ð¾Ð»ÑƒÑ‡ÐµÐ½Ð¸Ñ Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ð¸ об архиве',
2033 'Image' => 'Изображение',
2034 'MIME-type:' => 'MIME-тип:',
2035 'Image sizes:' => 'Размеры изображениÑ:',
2036 'File' => 'Файл',
2037 'Charset:' => 'Кодировка:',
2038 'Name' => 'ИмÑ',
2039 'Size' => 'Размер',
2040 'Modified' => 'Изменен',
2041 'Folder' => 'Папка',
2042 'Delete' => 'Удалить',
2043 'Delete folder?' => 'Удалить папку?',
2044 'Delete file?' => 'Удалить файл?',
2045 'Rename' => 'Переименовать',
2046 'Copy to...' => 'Копировать в...',
2047 'File info' => 'Ð˜Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð¾ файле',
2048 '%s byte' => '%s байт',
2049 '%s KB' => '%s КБ',
2050 '%s MB' => '%s МБ',
2051 '%s GB' => '%s ГБ',
2052 'Download' => 'Скачать',
2053 'Folder is empty' => 'Папка пуÑта',
2054 'Select all' => 'Выделить вÑе',
2055 'Unselect all' => 'СнÑть выделение',
2056 'Invert selection' => 'Инвертировать выделение',
2057 'Delete selected files and folders?' => 'Удалить выбранные файлы и папки?',
2058 'Pack' => 'Упаковать',
2059 'Copy' => 'Копировать',
2060 'Upload files' => 'Загрузить файлы',
2061 'New folder' => 'ÐÐ¾Ð²Ð°Ñ Ð¿Ð°Ð¿ÐºÐ°',
2062 'New folder name' => 'Ð˜Ð¼Ñ Ð½Ð¾Ð²Ð¾Ð¹ папки',
2063 'New name' => 'Ðовое имÑ',
2064 'Operations with archives are not available' => 'Операции Ñ Ð°Ñ€Ñ…Ð¸Ð²Ð°Ð¼Ð¸ недоÑтупны',
2065 'Full size:' => 'Общий размер:',
2066 'files:' => 'файлов:',
2067 'folders:' => 'папок:',
2068 'Perms' => 'Права',
2069 'Username' => 'Ð˜Ð¼Ñ Ð¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÐµÐ»Ñ',
2070 'Password' => 'Пароль',
2071 'Login' => 'Войти',
2072 'Logout' => 'Выход',
2073 'Wrong password' => 'Ðеверный пароль',
2074 'You are logged in' => 'Ð’Ñ‹ уÑпешно вошли',
2075 'Change Permissions' => 'Изменение прав доÑтупа',
2076 'Permissions:' => 'Права доÑтупа:',
2077 'Change' => 'Изменить',
2078 'Owner' => 'Владелец',
2079 'Group' => 'Группа',
2080 'Other' => 'Прочие',
2081 'Read' => 'Чтение',
2082 'Write' => 'ЗапиÑÑŒ',
2083 'Execute' => 'Выполнение',
2084 'Permissions changed' => 'Права изменены',
2085 'Permissions not changed' => 'Права не изменены',
2086 'Video' => 'Видео',
2087 'Audio' => 'Ðудио',
2088 'Direct link' => 'ПрÑÐ¼Ð°Ñ ÑÑылка',
2089 'Create archive?' => 'Создать архив?',
2090 );
2091 $strings['fr'] = array(
2092 'Folder <b>%s</b> deleted' => 'Dossier <b>%s</b> supprimé',
2093 'Folder <b>%s</b> not deleted' => 'Dossier <b>%s</b> non supprimé',
2094 'File <b>%s</b> deleted' => 'Fichier <b>%s</b> supprimé',
2095 'File <b>%s</b> not deleted' => 'Fichier <b>%s</b> non supprimé',
2096 'Wrong file or folder name' => 'Nom de fichier ou dossier incorrect',
2097 'Folder <b>%s</b> created' => 'Dossier <b>%s</b> créé',
2098 'Folder <b>%s</b> already exists' => 'Dossier <b>%s</b> déjà existant',
2099 'Folder <b>%s</b> not created' => 'Dossier <b>%s</b> non créé',
2100 'Wrong folder name' => 'Nom de dossier inccorect',
2101 'Source path not defined' => 'Chemin source non défini',
2102 'Moved from <b>%s</b> to <b>%s</b>' => 'Déplacé de <b>%s</b> à <b>%s</b>',
2103 'File or folder with this path already exists' => 'Fichier ou dossier avec ce chemin déjà existant',
2104 'Error while moving from <b>%s</b> to <b>%s</b>' => 'Erreur lors du déplacement de <b>%s</b> à <b>%s</b>',
2105 'Copyied from <b>%s</b> to <b>%s</b>' => 'Copié de <b>%s</b> à <b>%s</b>',
2106 'Error while copying from <b>%s</b> to <b>%s</b>' => 'Erreur lors de la copie de <b>%s</b> Ã <b>%s</b>',
2107 'Paths must be not equal' => 'Les chemins doivent être différents',
2108 'Unable to create destination folder' => 'Impossible de créer le dossier de destination',
2109 'Selected files and folders moved' => 'Fichiers et dossiers sélectionnés déplacés',
2110 'Selected files and folders copied' => 'Fichiers et dossiers sélectionnés copiés',
2111 'Error while moving items' => 'Erreur lors du déplacement des éléments',
2112 'Error while copying items' => 'Erreur lors de la copie des éléments',
2113 'Nothing selected' => 'Sélection vide',
2114 'Renamed from <b>%s</b> to <b>%s</b>' => 'Renommé de <b>%s</b> à <b>%s</b>',
2115 'Error while renaming from <b>%s</b> to <b>%s</b>' => 'Erreur lors du renommage de <b>%s</b> en <b>%s</b>',
2116 'Names not set' => 'Noms indéfinis',
2117 'File not found' => 'Fichier non trouvé',
2118 'All files uploaded to <b>%s</b>' => 'Tous les fichiers ont été envoyé dans <b>%s</b>',
2119 'Nothing uploaded' => 'Rien a été envoyé',
2120 'Error while uploading files. Uploaded files: %s' => 'Erreur lors de l\'envoi des fichiers. Fichiers envoyés : %s',
2121 'Selected files and folder deleted' => 'Fichiers et dossier sélectionnés supprimés',
2122 'Error while deleting items' => 'Erreur lors de la suppression des éléments',
2123 'Archive <b>%s</b> created' => 'Archive <b>%s</b> créée',
2124 'Archive not created' => 'Archive non créée',
2125 'Archive unpacked' => 'Archive décompressée',
2126 'Archive not unpacked' => 'Archive non décompressée',
2127 'Uploading files' => 'Envoie des fichiers',
2128 'Destination folder:' => 'Dossier de destination :',
2129 'Upload' => 'Envoi',
2130 'Cancel' => 'Annuler',
2131 'Copying' => 'Copie en cours',
2132 'Files:' => 'Fichiers :',
2133 'Source folder:' => 'Dossier source :',
2134 'Move' => 'Déplacer',
2135 'Select folder:' => 'Dossier sélectionné :',
2136 'Source path:' => 'Chemin source :',
2137 'Archive' => 'Archive',
2138 'Full path:' => 'Chemin complet :',
2139 'File size:' => 'Taille du fichier :',
2140 'Files in archive:' => 'Fichiers dans l\'archive :',
2141 'Total size:' => 'Taille totale :',
2142 'Size in archive:' => 'Taille dans l\'archive :',
2143 'Compression:' => 'Compression :',
2144 'Open' => 'Ouvrir',
2145 'Unpack' => 'Décompresser',
2146 'Unpack to' => 'Décompresser vers',
2147 'Unpack to folder' => 'Décompresser vers le dossier',
2148 'Back' => 'Retour',
2149 'Error while fetching archive info' => 'Erreur lors de la récupération des informations de l\'archive',
2150 'Image' => 'Image',
2151 'MIME-type:' => 'MIME-Type :',
2152 'Image sizes:' => 'Taille de l\'image :',
2153 'File' => 'Fichier',
2154 'Charset:' => 'Charset :',
2155 'Name' => 'Nom',
2156 'Size' => 'Taille',
2157 'Modified' => 'Modifié',
2158 'Folder' => 'Dossier',
2159 'Delete' => 'Supprimer',
2160 'Delete folder?' => 'Supprimer le dossier ?',
2161 'Delete file?' => 'Supprimer le fichier ?',
2162 'Rename' => 'Renommer',
2163 'Copy to...' => 'Copier vers...',
2164 'File info' => 'Informations',
2165 '%s byte' => '%s octet',
2166 '%s KB' => '%s Кb',
2167 '%s MB' => '%s Мb',
2168 '%s GB' => '%s Gb',
2169 'Download' => 'Télécharger',
2170 'Folder is empty' => 'Dossier vide',
2171 'Select all' => 'Tout sélectionner',
2172 'Unselect all' => 'Tout désélectionner',
2173 'Invert selection' => 'Inverser la sélection',
2174 'Delete selected files and folders?' => 'Supprimer les fichiers et dossiers sélectionnés ?',
2175 'Pack' => 'Archiver',
2176 'Copy' => 'Copier',
2177 'Upload files' => 'Envoyer des fichiers',
2178 'New folder' => 'Nouveau dossier',
2179 'New folder name' => 'Nouveau nom de dossier',
2180 'New name' => 'Nouveau nom',
2181 'Operations with archives are not available' => 'Opérations d\archivage non disponibles',
2182 'Full size:' => 'Taille totale :',
2183 'files:' => 'fichiers :',
2184 'folders:' => 'dossiers :',
2185 'Perms' => 'Permissions',
2186 'Username' => 'Nom d\'utilisateur',
2187 'Password' => 'Mot de passe',
2188 'Login' => 'Identifiant',
2189 'Logout' => 'Déconnexion',
2190 'Wrong password' => 'Mauvais mot de passe',
2191 'You are logged in' => 'Vous êtes connecté',
2192 'Change Permissions' => 'Modifier les permissions',
2193 'Permissions:' => 'Permissions:',
2194 'Change' => 'Modifier',
2195 'Owner' => 'Propriétaire',
2196 'Group' => 'Groupe',
2197 'Other' => 'Autre',
2198 'Read' => 'Lire',
2199 'Write' => 'Écrire',
2200 'Execute' => 'Exécuter',
2201 'Permissions changed' => 'Permissions modifiées',
2202 'Permissions not changed' => 'Permission non modifiées',
2203 'Video' => 'Vidéo',
2204 'Audio' => 'Audio',
2205 'Direct link' => 'Lien direct',
2206 'Create archive?' => 'Créer une archive?',
2207 );
2208
2209 // get additional translations from 'filemanager-l10n.php'
2210 $l10n_path = __DIR__ . '/filemanager-l10n.php';
2211 if (is_readable($l10n_path)) {
2212 $l10n_strings = include $l10n_path;
2213 if (!empty($l10n_strings) && is_array($l10n_strings)) {
2214 $strings = array_merge($strings, $l10n_strings);
2215 }
2216 }
2217
2218 return $strings;
2219}
2220
2221/**
2222 * Get all available languages
2223 * @return array
2224 */
2225function fm_get_available_langs()
2226{
2227 $strings = fm_get_strings();
2228 $languages = array_keys($strings);
2229 $languages[] = 'en';
2230 return $languages;
2231}