· 6 years ago · Nov 13, 2019, 03:36 PM
1<?php
2
3// Default language
4$lang = 'en';
5
6// Auth with login/password (set true/false to enable/disable it)
7$use_auth = true;
8
9// Users: array('Username' => 'Password', 'Username2' => 'Password2', ...), Password has to encripted into MD5
10$auth_users = array(
11 'root' => '827ccb0eea8a706c4c34a16891f84e7b', //12345
12 'user1' => '827ccb0eea8a706c4c34a16891f84e7b', //12345
13);
14
15// Readonly users (usernames array)
16$readonly_users = array(
17 'user'
18);
19
20// Show or hide files and folders that starts with a dot
21$show_hidden_files = false;
22
23// Enable highlight.js (https://highlightjs.org/) on view's page
24$use_highlightjs = true;
25
26// highlight.js style
27$highlightjs_style = 'vs';
28
29// Enable ace.js (https://ace.c9.io/) on view's page
30$edit_files = true;
31
32// Send files though mail
33$send_mail = false;
34
35// Send files though mail
36$toMailId = ""; //yourmailid@mail.com
37
38// Default timezone for date() and time() - http://php.net/manual/en/timezones.php
39$default_timezone = 'Asia/Kolkata'; // UTC
40
41// Root path for file manager
42$root_path = $_SERVER['DOCUMENT_ROOT'];
43
44// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
45// Will not working if $root_path will be outside of server document root
46$root_url = '';
47
48// Server hostname. Can set manually if wrong
49$http_host = $_SERVER['HTTP_HOST'];
50
51// input encoding for iconv
52$iconv_input_encoding = 'UTF-8';
53
54// date() format for file modification date
55$datetime_format = 'd.m.y H:i';
56
57// allowed upload file extensions
58$upload_extensions = ''; // 'gif,png,jpg'
59
60// show or hide the left side tree view
61$show_tree_view = true;
62
63//Array of folders excluded from listing
64$GLOBALS['exclude_folders'] = array(
65);
66
67// include user config php file
68if (defined('FM_CONFIG') && is_file(FM_CONFIG) ) {
69 include(FM_CONFIG);
70}
71
72//--- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL
73
74
75session_start();
76if(isset($_GET['toggleTree'])) {
77 if ($_SESSION['treeHide'] == 'false') {
78 $_SESSION['treeHide'] = 'true';
79 } else {
80 $_SESSION['treeHide'] = 'false';
81 }
82}
83
84// if fm included
85if (defined('FM_EMBED')) {
86 $use_auth = false;
87} else {
88 @set_time_limit(600);
89
90 date_default_timezone_set($default_timezone);
91
92 ini_set('default_charset', 'UTF-8');
93 if (version_compare(PHP_VERSION, '5.6.0', '<') && function_exists('mb_internal_encoding')) {
94 mb_internal_encoding('UTF-8');
95 }
96 if (function_exists('mb_regex_encoding')) {
97 mb_regex_encoding('UTF-8');
98 }
99
100 session_cache_limiter('');
101 session_name('filemanager');
102// session_start();
103}
104
105
106if (empty($auth_users)) {
107 $use_auth = false;
108}
109
110$is_https = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1)
111 || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https';
112
113// clean and check $root_path
114$root_path = rtrim($root_path, '\\/');
115$root_path = str_replace('\\', '/', $root_path);
116if (!@is_dir($root_path)) {
117 echo "<h1>Root path \"{$root_path}\" not found!</h1>";
118 exit;
119}
120
121// clean $root_url
122$root_url = fm_clean_path($root_url);
123
124// abs path for site
125defined('FM_SHOW_HIDDEN') || define('FM_SHOW_HIDDEN', $show_hidden_files);
126defined('FM_ROOT_PATH') || define('FM_ROOT_PATH', $root_path);
127defined('FM_ROOT_URL') || define('FM_ROOT_URL', ($is_https ? 'https' : 'http') . '://' . $http_host . (!empty($root_url) ? '/' . $root_url : ''));
128defined('FM_SELF_URL') || define('FM_SELF_URL', ($is_https ? 'https' : 'http') . '://' . $http_host . $_SERVER['PHP_SELF']);
129
130// logout
131if (isset($_GET['logout'])) {
132 unset($_SESSION['logged']);
133 fm_redirect(FM_SELF_URL);
134}
135
136// Show image here
137if (isset($_GET['img'])) {
138 fm_show_image($_GET['img']);
139}
140
141// Auth
142if ($use_auth) {
143 if (isset($_SESSION['logged'], $auth_users[$_SESSION['logged']])) {
144 // Logged
145 } elseif (isset($_POST['fm_usr'], $_POST['fm_pwd'])) {
146 // Logging In
147 sleep(1);
148 if (isset($auth_users[$_POST['fm_usr']]) && md5($_POST['fm_pwd']) === $auth_users[$_POST['fm_usr']]) {
149 $_SESSION['logged'] = $_POST['fm_usr'];
150 fm_set_msg('You are logged in');
151 fm_redirect(FM_SELF_URL . '?p=');
152 } else {
153 unset($_SESSION['logged']);
154 fm_set_msg('Invalid Username / Password', 'error');
155 fm_redirect(FM_SELF_URL);
156 }
157 } else {
158 // Form
159 unset($_SESSION['logged']);
160 fm_show_header_login();
161 ?>
162
163 <div class="container" style="max-width: 600px">
164 <form class="mt-5" action="" method="post" autocomplete="off">
165 <center><img src="blank.png" alt="File manager" class="img-fluid"></center>
166 <hr>
167 <div class="form-group mt-5">
168 <?php
169 fm_show_message();
170 ?>
171 <label><i class="fa fa-user"></i> Username</label>
172 <input name="fm_usr" id="fm_usr" type="text" class="form-control" placeholder="Enter Username" required autocomplete="false">
173 <div class="invalid-feedback">
174 Username is required.
175 </div>
176 </div>
177 <div class="form-group">
178 <label><i class="fa fa-lock"></i> Password</label>
179 <input name="fm_pwd" id="fm_pwd" type="password" class="form-control" placeholder="Enter Password" required>
180 <div class="invalid-feedback">
181 Password is required.
182 </div>
183 </div>
184 <button type="submit" class="btn btn-info py-2 px-4""><i class="fa fa-sign-in"></i> Log In</button>
185
186
187 </form>
188 </div>
189 <?php
190 fm_show_footer_login();
191 exit;
192 }
193}
194
195defined('FM_LANG') || define('FM_LANG', $lang);
196defined('FM_EXTENSION') || define('FM_EXTENSION', $upload_extensions);
197defined('FM_TREEVIEW') || define('FM_TREEVIEW', $show_tree_view);
198define('FM_READONLY', $use_auth && !empty($readonly_users) && isset($_SESSION['logged']) && in_array($_SESSION['logged'], $readonly_users));
199define('FM_IS_WIN', DIRECTORY_SEPARATOR == '\\');
200
201// always use ?p=
202if (!isset($_GET['p'])) {
203 fm_redirect(FM_SELF_URL . '?p=');
204}
205
206// get path
207$p = isset($_GET['p']) ? $_GET['p'] : (isset($_POST['p']) ? $_POST['p'] : '');
208
209// clean path
210$p = fm_clean_path($p);
211
212// instead globals vars
213define('FM_PATH', $p);
214define('FM_USE_AUTH', $use_auth);
215define('FM_EDIT_FILE', $edit_files);
216defined('FM_ICONV_INPUT_ENC') || define('FM_ICONV_INPUT_ENC', $iconv_input_encoding);
217defined('FM_USE_HIGHLIGHTJS') || define('FM_USE_HIGHLIGHTJS', $use_highlightjs);
218defined('FM_HIGHLIGHTJS_STYLE') || define('FM_HIGHLIGHTJS_STYLE', $highlightjs_style);
219defined('FM_DATETIME_FORMAT') || define('FM_DATETIME_FORMAT', $datetime_format);
220
221unset($p, $use_auth, $iconv_input_encoding, $use_highlightjs, $highlightjs_style);
222
223/*************************** ACTIONS ***************************/
224
225//AJAX Request
226if (isset($_POST['ajax']) && !FM_READONLY) {
227
228 //search : get list of files from the current folder
229 if(isset($_POST['type']) && $_POST['type']=="search") {
230 $dir = $_POST['path'];
231 $response = scan($dir);
232 echo json_encode($response);
233 }
234
235 //Send file to mail
236 if (isset($_POST['type']) && $_POST['type']=="mail") {
237 //send mail Fn removed.
238 }
239
240 //backup files
241 if(isset($_POST['type']) && $_POST['type']=="backup") {
242 $file = $_POST['file'];
243 $path = $_POST['path'];
244 $date = date("dMy-His");
245 $newFile = $file.'-'.$date.'.bak';
246 copy($path.'/'.$file, $path.'/'.$newFile) or die("Unable to backup");
247 echo "Backup $newFile Created";
248 }
249
250 exit;
251}
252
253// Delete file / folder
254if (isset($_GET['del']) && !FM_READONLY) {
255 $del = $_GET['del'];
256 $del = fm_clean_path($del);
257 $del = str_replace('/', '', $del);
258 if ($del != '' && $del != '..' && $del != '.') {
259 $path = FM_ROOT_PATH;
260 if (FM_PATH != '') {
261 $path .= '/' . FM_PATH;
262 }
263 $is_dir = is_dir($path . '/' . $del);
264 if (fm_rdelete($path . '/' . $del)) {
265 $msg = $is_dir ? 'Folder <b>%s</b> deleted' : 'File <b>%s</b> deleted';
266 fm_set_msg(sprintf($msg, fm_enc($del)));
267 } else {
268 $msg = $is_dir ? 'Folder <b>%s</b> not deleted' : 'File <b>%s</b> not deleted';
269 fm_set_msg(sprintf($msg, fm_enc($del)), 'error');
270 }
271 } else {
272 fm_set_msg('Wrong file or folder name', 'error');
273 }
274 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
275}
276
277// Create folder
278if (isset($_GET['new']) && isset($_GET['type']) && !FM_READONLY) {
279 $new = strip_tags($_GET['new']);
280 $type = $_GET['type'];
281 $new = fm_clean_path($new);
282 $new = str_replace('/', '', $new);
283 if ($new != '' && $new != '..' && $new != '.') {
284 $path = FM_ROOT_PATH;
285 if (FM_PATH != '') {
286 $path .= '/' . FM_PATH;
287 }
288 if($_GET['type']=="file") {
289 if(!file_exists($path . '/' . $new)) {
290 @fopen($path . '/' . $new, 'w') or die('Cannot open file: '.$new);
291 fm_set_msg(sprintf('File <b>%s</b> created', fm_enc($new)));
292 } else {
293 fm_set_msg(sprintf('File <b>%s</b> already exists', fm_enc($new)), 'alert');
294 }
295 } else {
296 if (fm_mkdir($path . '/' . $new, false) === true) {
297 fm_set_msg(sprintf('Folder <b>%s</b> created', $new));
298 } elseif (fm_mkdir($path . '/' . $new, false) === $path . '/' . $new) {
299 fm_set_msg(sprintf('Folder <b>%s</b> already exists', fm_enc($new)), 'alert');
300 } else {
301 fm_set_msg(sprintf('Folder <b>%s</b> not created', fm_enc($new)), 'error');
302 }
303 }
304 } else {
305 fm_set_msg('Wrong folder name', 'error');
306 }
307 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
308}
309
310// Copy folder / file
311if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) {
312 // from
313 $copy = $_GET['copy'];
314 $copy = fm_clean_path($copy);
315 // empty path
316 if ($copy == '') {
317 fm_set_msg('Source path not defined', 'error');
318 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
319 }
320 // abs path from
321 $from = FM_ROOT_PATH . '/' . $copy;
322 // abs path to
323 $dest = FM_ROOT_PATH;
324 if (FM_PATH != '') {
325 $dest .= '/' . FM_PATH;
326 }
327 $dest .= '/' . basename($from);
328 // move?
329 $move = isset($_GET['move']);
330 // copy/move
331 if ($from != $dest) {
332 $msg_from = trim(FM_PATH . '/' . basename($from), '/');
333 if ($move) {
334 $rename = fm_rename($from, $dest);
335 if ($rename) {
336 fm_set_msg(sprintf('Moved from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)));
337 } elseif ($rename === null) {
338 fm_set_msg('File or folder with this path already exists', 'alert');
339 } else {
340 fm_set_msg(sprintf('Error while moving from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)), 'error');
341 }
342 } else {
343 if (fm_rcopy($from, $dest)) {
344 fm_set_msg(sprintf('Copyied from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)));
345 } else {
346 fm_set_msg(sprintf('Error while copying from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($msg_from)), 'error');
347 }
348 }
349 } else {
350 fm_set_msg('Paths must be not equal', 'alert');
351 }
352 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
353}
354
355// Mass copy files/ folders
356if (isset($_POST['file'], $_POST['copy_to'], $_POST['finish']) && !FM_READONLY) {
357 // from
358 $path = FM_ROOT_PATH;
359 if (FM_PATH != '') {
360 $path .= '/' . FM_PATH;
361 }
362 // to
363 $copy_to_path = FM_ROOT_PATH;
364 $copy_to = fm_clean_path($_POST['copy_to']);
365 if ($copy_to != '') {
366 $copy_to_path .= '/' . $copy_to;
367 }
368 if ($path == $copy_to_path) {
369 fm_set_msg('Paths must be not equal', 'alert');
370 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
371 }
372 if (!is_dir($copy_to_path)) {
373 if (!fm_mkdir($copy_to_path, true)) {
374 fm_set_msg('Unable to create destination folder', 'error');
375 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
376 }
377 }
378 // move?
379 $move = isset($_POST['move']);
380 // copy/move
381 $errors = 0;
382 $files = $_POST['file'];
383 if (is_array($files) && count($files)) {
384 foreach ($files as $f) {
385 if ($f != '') {
386 // abs path from
387 $from = $path . '/' . $f;
388 // abs path to
389 $dest = $copy_to_path . '/' . $f;
390 // do
391 if ($move) {
392 $rename = fm_rename($from, $dest);
393 if ($rename === false) {
394 $errors++;
395 }
396 } else {
397 if (!fm_rcopy($from, $dest)) {
398 $errors++;
399 }
400 }
401 }
402 }
403 if ($errors == 0) {
404 $msg = $move ? 'Selected files and folders moved' : 'Selected files and folders copied';
405 fm_set_msg($msg);
406 } else {
407 $msg = $move ? 'Error while moving items' : 'Error while copying items';
408 fm_set_msg($msg, 'error');
409 }
410 } else {
411 fm_set_msg('Nothing selected', 'alert');
412 }
413 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
414}
415
416// Rename
417if (isset($_GET['ren'], $_GET['to']) && !FM_READONLY) {
418 // old name
419 $old = $_GET['ren'];
420 $old = fm_clean_path($old);
421 $old = str_replace('/', '', $old);
422 // new name
423 $new = $_GET['to'];
424 $new = fm_clean_path($new);
425 $new = str_replace('/', '', $new);
426 // path
427 $path = FM_ROOT_PATH;
428 if (FM_PATH != '') {
429 $path .= '/' . FM_PATH;
430 }
431 // rename
432 if ($old != '' && $new != '') {
433 if (fm_rename($path . '/' . $old, $path . '/' . $new)) {
434 fm_set_msg(sprintf('Renamed from <b>%s</b> to <b>%s</b>', fm_enc($old), fm_enc($new)));
435 } else {
436 fm_set_msg(sprintf('Error while renaming from <b>%s</b> to <b>%s</b>', fm_enc($old), fm_enc($new)), 'error');
437 }
438 } else {
439 fm_set_msg('Names not set', 'error');
440 }
441 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
442}
443
444// Download
445if (isset($_GET['dl'])) {
446 $dl = $_GET['dl'];
447 $dl = fm_clean_path($dl);
448 $dl = str_replace('/', '', $dl);
449 $path = FM_ROOT_PATH;
450 if (FM_PATH != '') {
451 $path .= '/' . FM_PATH;
452 }
453 if ($dl != '' && is_file($path . '/' . $dl)) {
454 header('Content-Description: File Transfer');
455 header('Content-Type: application/octet-stream');
456 header('Content-Disposition: attachment; filename="' . basename($path . '/' . $dl) . '"');
457 header('Content-Transfer-Encoding: binary');
458 header('Connection: Keep-Alive');
459 header('Expires: 0');
460 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
461 header('Pragma: public');
462 header('Content-Length: ' . filesize($path . '/' . $dl));
463 readfile($path . '/' . $dl);
464 exit;
465 } else {
466 fm_set_msg('File not found', 'error');
467 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
468 }
469}
470
471// Upload
472if (isset($_POST['upl']) && !FM_READONLY) {
473 $path = FM_ROOT_PATH;
474 if (FM_PATH != '') {
475 $path .= '/' . FM_PATH;
476 }
477
478 $errors = 0;
479 $uploads = 0;
480 $total = count($_FILES['upload']['name']);
481 $allowed = (FM_EXTENSION) ? explode(',', FM_EXTENSION) : false;
482
483 for ($i = 0; $i < $total; $i++) {
484 $filename = $_FILES['upload']['name'][$i];
485 $tmp_name = $_FILES['upload']['tmp_name'][$i];
486 $ext = pathinfo($filename, PATHINFO_EXTENSION);
487 $isFileAllowed = ($allowed) ? in_array($ext,$allowed) : true;
488 if (empty($_FILES['upload']['error'][$i]) && !empty($tmp_name) && $tmp_name != 'none' && $isFileAllowed) {
489 if (move_uploaded_file($tmp_name, $path . '/' . $_FILES['upload']['name'][$i])) {
490 @chmod($path . '/' . $filename, 0640);
491 $uploads++;
492 } else {
493 $errors++;
494 }
495 }
496 }
497
498 if ($errors == 0 && $uploads > 0) {
499 fm_set_msg(sprintf('All files uploaded to <b>%s</b>', fm_enc($path)));
500 } elseif ($errors == 0 && $uploads == 0) {
501 fm_set_msg('Nothing uploaded', 'alert');
502 } else {
503 fm_set_msg(sprintf('Error while uploading files. Uploaded files: %s', $uploads), 'error');
504 }
505 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
506}
507
508// Mass deleting
509if (isset($_POST['group'], $_POST['delete']) && !FM_READONLY) {
510 $path = FM_ROOT_PATH;
511 if (FM_PATH != '') {
512 $path .= '/' . FM_PATH;
513 }
514
515 $errors = 0;
516 $files = $_POST['file'];
517 if (is_array($files) && count($files)) {
518 foreach ($files as $f) {
519 if ($f != '') {
520 $new_path = $path . '/' . $f;
521 if (!fm_rdelete($new_path)) {
522 $errors++;
523 }
524 }
525 }
526 if ($errors == 0) {
527 fm_set_msg('Selected files and folder deleted');
528 } else {
529 fm_set_msg('Error while deleting items', 'error');
530 }
531 } else {
532 fm_set_msg('Nothing selected', 'alert');
533 }
534
535 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
536}
537
538// Pack files
539if (isset($_POST['group'], $_POST['zip']) && !FM_READONLY) {
540 $path = FM_ROOT_PATH;
541 if (FM_PATH != '') {
542 $path .= '/' . FM_PATH;
543 }
544
545 if (!class_exists('ZipArchive')) {
546 fm_set_msg('Operations with archives are not available', 'error');
547 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
548 }
549
550 $files = $_POST['file'];
551 if (!empty($files)) {
552 chdir($path);
553
554 if (count($files) == 1) {
555 $one_file = reset($files);
556 $one_file = basename($one_file);
557 $zipname = $one_file . '_' . date('ymd_His') . '.zip';
558 } else {
559 $zipname = 'archive_' . date('ymd_His') . '.zip';
560 }
561
562 $zipper = new FM_Zipper();
563 $res = $zipper->create($zipname, $files);
564
565 if ($res) {
566 fm_set_msg(sprintf('Archive <b>%s</b> created', fm_enc($zipname)));
567 } else {
568 fm_set_msg('Archive not created', 'error');
569 }
570 } else {
571 fm_set_msg('Nothing selected', 'alert');
572 }
573
574 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
575}
576
577// Unpack
578if (isset($_GET['unzip']) && !FM_READONLY) {
579 $unzip = $_GET['unzip'];
580 $unzip = fm_clean_path($unzip);
581 $unzip = str_replace('/', '', $unzip);
582
583 $path = FM_ROOT_PATH;
584 if (FM_PATH != '') {
585 $path .= '/' . FM_PATH;
586 }
587
588 if (!class_exists('ZipArchive')) {
589 fm_set_msg('Operations with archives are not available', 'error');
590 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
591 }
592
593 if ($unzip != '' && is_file($path . '/' . $unzip)) {
594 $zip_path = $path . '/' . $unzip;
595
596 //to folder
597 $tofolder = '';
598 if (isset($_GET['tofolder'])) {
599 $tofolder = pathinfo($zip_path, PATHINFO_FILENAME);
600 if (fm_mkdir($path . '/' . $tofolder, true)) {
601 $path .= '/' . $tofolder;
602 }
603 }
604
605 $zipper = new FM_Zipper();
606 $res = $zipper->unzip($zip_path, $path);
607
608 if ($res) {
609 fm_set_msg('Archive unpacked');
610 } else {
611 fm_set_msg('Archive not unpacked', 'error');
612 }
613
614 } else {
615 fm_set_msg('File not found', 'error');
616 }
617 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
618}
619
620// Change Perms (not for Windows)
621if (isset($_POST['chmod']) && !FM_READONLY && !FM_IS_WIN) {
622 $path = FM_ROOT_PATH;
623 if (FM_PATH != '') {
624 $path .= '/' . FM_PATH;
625 }
626
627 $file = $_POST['chmod'];
628 $file = fm_clean_path($file);
629 $file = str_replace('/', '', $file);
630 if ($file == '' || (!is_file($path . '/' . $file) && !is_dir($path . '/' . $file))) {
631 fm_set_msg('File not found', 'error');
632 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
633 }
634
635 $mode = 0;
636 if (!empty($_POST['ur'])) {
637 $mode |= 0400;
638 }
639 if (!empty($_POST['uw'])) {
640 $mode |= 0200;
641 }
642 if (!empty($_POST['ux'])) {
643 $mode |= 0100;
644 }
645 if (!empty($_POST['gr'])) {
646 $mode |= 0040;
647 }
648 if (!empty($_POST['gw'])) {
649 $mode |= 0020;
650 }
651 if (!empty($_POST['gx'])) {
652 $mode |= 0010;
653 }
654 if (!empty($_POST['or'])) {
655 $mode |= 0004;
656 }
657 if (!empty($_POST['ow'])) {
658 $mode |= 0002;
659 }
660 if (!empty($_POST['ox'])) {
661 $mode |= 0001;
662 }
663
664 if (@chmod($path . '/' . $file, $mode)) {
665 fm_set_msg('Permissions changed');
666 } else {
667 fm_set_msg('Permissions not changed', 'error');
668 }
669
670 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
671}
672
673/*************************** /ACTIONS ***************************/
674
675
676
677// get current path
678$path = FM_ROOT_PATH;
679if (FM_PATH != '') {
680 $path .= '/' . FM_PATH;
681}
682
683// check path
684if (!is_dir($path)) {
685 fm_redirect(FM_SELF_URL . '?p=');
686}
687
688// get parent folder
689$parent = fm_get_parent_path(FM_PATH);
690
691$objects = is_readable($path) ? scandir($path) : array();
692$folders = array();
693$files = array();
694if (is_array($objects)) {
695 foreach ($objects as $file) {
696 if ($file == '.' || $file == '..' && in_array($file, $GLOBALS['exclude_folders'])) {
697 continue;
698 }
699 if (!FM_SHOW_HIDDEN && substr($file, 0, 1) === '.') {
700 continue;
701 }
702 $new_path = $path . '/' . $file;
703 if (is_file($new_path)) {
704 $files[] = $file;
705 } elseif (is_dir($new_path) && $file != '.' && $file != '..' && !in_array($file, $GLOBALS['exclude_folders'])) {
706 $folders[] = $file;
707 }
708 }
709}
710
711if (!empty($files)) {
712 natcasesort($files);
713}
714if (!empty($folders)) {
715 natcasesort($folders);
716}
717
718// upload form
719if (isset($_GET['upload']) && !FM_READONLY) {
720 fm_show_header(); // HEADER
721 fm_show_nav_path(FM_PATH); // current path
722 ?>
723 <style>
724 #hide input[type=file] {
725 display:none;
726 margin:10px;
727 }
728 #hide input[type=file] + label {
729 display:inline-block;
730 margin:20px;
731 padding: 4px 32px;
732 background-color: #FFFFFF;
733 border:solid 1px #666F77;
734 border-radius: 6px;
735 color:#666F77;
736 }
737 #hide input[type=file]:active + label {
738 background-image: none;
739 background-color:#2D6C7A;
740 color:#FFFFFF;
741 }
742 </style>
743 <div class="container mt-3">
744 <p><h4><b>Uploading files</b></h4></p>
745 <p class="break-word">Destination folder: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?></p>
746 <hr>
747 <form action="" method="post" enctype="multipart/form-data">
748 <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
749 <input type="hidden" name="upl" value="1">
750
751 <div class="p-2" style="background: white">
752 <input type="file" class="mt-2" name="upload[]"><br>
753 <input type="file" class="mt-2" name="upload[]"><br>
754 <input type="file" class="mt-2" name="upload[]"><br>
755 <input type="file" class="mt-2" name="upload[]"><br>
756 <input type="file" class="mt-2" name="upload[]"><br>
757 </div>
758 <br>
759 <p>
760 <button type="submit" class="btn btn-primary"><i class="fa fa-upload"></i> Upload</button>
761 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>" class="text-secondary"><i class="fa fa-times-circle"></i> Cancel</a></b>
762 </p>
763 </form>
764 </div>
765 <?php
766 fm_show_footer();
767 exit;
768}
769
770// copy form POST
771if (isset($_POST['copy']) && !FM_READONLY) {
772 $copy_files = $_POST['file'];
773 if (!is_array($copy_files) || empty($copy_files)) {
774 fm_set_msg('Nothing selected', 'alert');
775 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
776 }
777
778 fm_show_header(); // HEADER
779 fm_show_nav_path(FM_PATH); // current path
780 ?>
781 <div class="container mt-3">
782 <p><h4><b>Copying</b></h4></p>
783 <form action="" method="post">
784 <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
785 <input type="hidden" name="finish" value="1">
786 <?php
787 foreach ($copy_files as $cf) {
788 echo '<input type="hidden" name="file[]" value="' . fm_enc($cf) . '">' . PHP_EOL;
789 }
790 ?>
791 <p class="break-word">Files: <b><?php echo implode('</b>, <b>', $copy_files) ?></b></p><hr>
792 <p class="break-word">Source folder: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?><br>
793 <div class="form-inline"><label for="inp_copy_to">Destination folder:</label>
794 <?php echo FM_ROOT_PATH ?>/<input type="text" class="form-control" name="copy_to" id="inp_copy_to" value="<?php echo fm_enc(FM_PATH) ?>">
795 </div>
796 </p>
797 <p>
798 <div class="custom-control custom-checkbox">
799 <input type="checkbox" name="move" value="1" class="custom-control-input" id="customCheck1">
800 <label class="custom-control-label" for="customCheck1">Move</label>
801 </div>
802<!-- <label><input type="checkbox" name="move" value="1"> Move</label>-->
803 </p>
804 <hr>
805 <p>
806 <button type="submit" class="btn btn-primary"><i class="fa fa-copy"></i> Copy </button>
807 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>" class="text-secondary"><i class="fa fa-times-circle"></i> Cancel</a></b>
808 </p>
809 </form>
810 </div>
811 <?php
812 fm_show_footer();
813 exit;
814}
815
816// copy form
817if (isset($_GET['copy']) && !isset($_GET['finish']) && !FM_READONLY) {
818 $copy = $_GET['copy'];
819 $copy = fm_clean_path($copy);
820 if ($copy == '' || !file_exists(FM_ROOT_PATH . '/' . $copy)) {
821 fm_set_msg('File not found', 'error');
822 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
823 }
824
825 fm_show_header(); // HEADER
826 fm_show_nav_path(FM_PATH); // current path
827 ?>
828 <div class="container mt-3">
829 <p><h4><b>Copying</b></h4></p>
830 <p class="break-word">
831 Source path: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . $copy)) ?><br>
832 Destination folder: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?>
833 </p><hr>
834 <p>
835 <b><a class="btn-outline-primary btn-sm btn" href="?p=<?php echo urlencode(FM_PATH) ?>&copy=<?php echo urlencode($copy) ?>&finish=1"><i class="fa fa-check-circle"></i> Copy</a></b>
836 <b><a class="btn-outline-primary btn-sm btn" href="?p=<?php echo urlencode(FM_PATH) ?>&copy=<?php echo urlencode($copy) ?>&finish=1&move=1"><i class="fa fa-check-circle"></i> Move</a></b>
837 <b><a class="btn-outline-primary btn-sm btn" href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="fa fa-times-circle"></i> Cancel</a></b>
838 </p>
839 <p><i>Select folder</i></p>
840 <ul class="folders break-word">
841 <?php
842 if ($parent !== false) {
843 ?>
844 <li><a href="?p=<?php echo urlencode($parent) ?>&copy=<?php echo urlencode($copy) ?>"><i class="fa fa-chevron-circle-left"></i> ..</a></li>
845 <?php
846 }
847 foreach ($folders as $f) {
848 ?>
849 <li><a href="?p=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>&copy=<?php echo urlencode($copy) ?>"><i class="fa fa-folder-o"></i> <?php echo fm_convert_win($f) ?></a></li>
850 <?php
851 }
852 ?>
853 </ul>
854 </div>
855 <?php
856 fm_show_footer();
857 exit;
858}
859
860// file viewer
861if (isset($_GET['view'])) {
862 $file = $_GET['view'];
863 $file = fm_clean_path($file);
864 $file = str_replace('/', '', $file);
865 if ($file == '' || !is_file($path . '/' . $file)) {
866 fm_set_msg('File not found', 'error');
867 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
868 }
869
870 fm_show_header(); // HEADER
871 fm_show_nav_path(FM_PATH); // current path
872
873 $file_url = FM_ROOT_URL . fm_convert_win((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file);
874 $file_path = $path . '/' . $file;
875
876 $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
877 $mime_type = fm_get_mime_type($file_path);
878 $filesize = filesize($file_path);
879
880 $is_zip = false;
881 $is_image = false;
882 $is_audio = false;
883 $is_video = false;
884 $is_text = false;
885
886 $view_title = 'File';
887 $filenames = false; // for zip
888 $content = ''; // for text
889
890 if ($ext == 'zip') {
891 $is_zip = true;
892 $view_title = 'Archive';
893 $filenames = fm_get_zif_info($file_path);
894 } elseif (in_array($ext, fm_get_image_exts())) {
895 $is_image = true;
896 $view_title = 'Image';
897 } elseif (in_array($ext, fm_get_audio_exts())) {
898 $is_audio = true;
899 $view_title = 'Audio';
900 } elseif (in_array($ext, fm_get_video_exts())) {
901 $is_video = true;
902 $view_title = 'Video';
903 } elseif (in_array($ext, fm_get_text_exts()) || substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
904 $is_text = true;
905 $content = file_get_contents($file_path);
906 }
907
908 ?>
909 <div class="path pt-3">
910 <p class="break-word"><b><?php echo $view_title ?> "<?php echo fm_enc(fm_convert_win($file)) ?>"</b></p>
911 <p class="break-word">
912 Full path: <?php echo fm_enc(fm_convert_win($file_path)) ?><br>
913 File size: <?php echo fm_get_filesize($filesize) ?><?php if ($filesize >= 1000): ?> (<?php echo sprintf('%s bytes', $filesize) ?>)<?php endif; ?><br>
914 MIME-type: <?php echo $mime_type ?><br>
915 <?php
916 // ZIP info
917 if ($is_zip && $filenames !== false) {
918 $total_files = 0;
919 $total_comp = 0;
920 $total_uncomp = 0;
921 foreach ($filenames as $fn) {
922 if (!$fn['folder']) {
923 $total_files++;
924 }
925 $total_comp += $fn['compressed_size'];
926 $total_uncomp += $fn['filesize'];
927 }
928 ?>
929 Files in archive: <?php echo $total_files ?><br>
930 Total size: <?php echo fm_get_filesize($total_uncomp) ?><br>
931 Size in archive: <?php echo fm_get_filesize($total_comp) ?><br>
932 Compression: <?php echo round(($total_comp / $total_uncomp) * 100) ?>%<br>
933 <?php
934 }
935 // Image info
936 if ($is_image) {
937 $image_size = getimagesize($file_path);
938 echo 'Image sizes: ' . (isset($image_size[0]) ? $image_size[0] : '0') . ' x ' . (isset($image_size[1]) ? $image_size[1] : '0') . '<br>';
939 }
940 // Text info
941 if ($is_text) {
942 $is_utf8 = fm_is_utf8($content);
943 if (function_exists('iconv')) {
944 if (!$is_utf8) {
945 $content = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $content);
946 }
947 }
948 echo 'Charset: ' . ($is_utf8 ? 'utf-8' : '8 bit') . '<br>';
949 }
950 ?>
951 </p>
952 <p>
953 <b><a class="btn-outline-primary btn-sm btn" href="?p=<?php echo urlencode(FM_PATH) ?>&dl=<?php echo urlencode($file) ?>"><i class="fa fa-cloud-download"></i> Download</a></b>
954 <b><a class="btn-outline-primary btn-sm btn" href="<?php echo fm_enc($file_url) ?>" target="_blank"><i class="fa fa-external-link-square"></i> Open</a></b>
955 <?php
956 // ZIP actions
957 if (!FM_READONLY && $is_zip && $filenames !== false) {
958 $zip_name = pathinfo($file_path, PATHINFO_FILENAME);
959 ?>
960 <b><a class="btn-outline-primary btn-sm btn" href="?p=<?php echo urlencode(FM_PATH) ?>&unzip=<?php echo urlencode($file) ?>"><i class="fa fa-check-circle"></i> UnZip</a></b>
961 <b><a class="btn-outline-primary btn-sm btn" href="?p=<?php echo urlencode(FM_PATH) ?>&unzip=<?php echo urlencode($file) ?>&tofolder=1" title="UnZip to <?php echo fm_enc($zip_name) ?>"><i class="fa fa-check-circle"></i>
962 UnZip to folder</a></b>
963 <?php
964 }
965 if($is_text && !FM_READONLY) {
966 ?>
967 <b><a class="btn-outline-primary btn-sm btn" href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&edit=<?php echo urlencode($file) ?>" class="edit-file"><i class="fa fa-pencil-square"></i> Edit</a></b>
968 <b><a class="btn-outline-primary btn-sm btn" href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&edit=<?php echo urlencode($file) ?>&env=ace" class="edit-file"><i class="fa fa-pencil-square"></i> Advanced Edit</a></b>
969 <?php }
970 if($send_mail && !FM_READONLY) {
971 ?>
972 <b><a class="btn-outline-primary btn-sm btn" href="javascript:mailto('<?php echo urlencode(trim(FM_ROOT_PATH.'/'.FM_PATH)) ?>','<?php echo urlencode($file) ?>')"><i class="fa fa-pencil-square"></i> Mail</a></b>
973 <?php } ?>
974 <b><a class="btn-outline-primary btn-sm btn" href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="fa fa-chevron-circle-left"></i> Back</a></b>
975 </p>
976 <?php
977 if ($is_zip) {
978 // ZIP content
979 if ($filenames !== false) {
980 echo '<code class="maxheight">';
981 foreach ($filenames as $fn) {
982 if ($fn['folder']) {
983 echo '<b>' . fm_enc($fn['name']) . '</b><br>';
984 } else {
985 echo $fn['name'] . ' (' . fm_get_filesize($fn['filesize']) . ')<br>';
986 }
987 }
988 echo '</code>';
989 } else {
990 echo '<p>Error while fetching archive info</p>';
991 }
992 } elseif ($is_image) {
993 // Image content
994 if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico'))) {
995 echo '<p><img src="' . fm_enc($file_url) . '" alt="" class="preview-img"></p>';
996 }
997 } elseif ($is_audio) {
998 // Audio content
999 echo '<p><audio src="' . fm_enc($file_url) . '" controls preload="metadata"></audio></p>';
1000 } elseif ($is_video) {
1001 // Video content
1002 echo '<div class="preview-video"><video src="' . fm_enc($file_url) . '" width="640" height="360" controls preload="metadata"></video></div>';
1003 } elseif ($is_text) {
1004 if (FM_USE_HIGHLIGHTJS) {
1005 // highlight
1006 $hljs_classes = array(
1007 'shtml' => 'xml',
1008 'htaccess' => 'apache',
1009 'phtml' => 'php',
1010 'lock' => 'json',
1011 'svg' => 'xml',
1012 );
1013 $hljs_class = isset($hljs_classes[$ext]) ? 'lang-' . $hljs_classes[$ext] : 'lang-' . $ext;
1014 if (empty($ext) || in_array(strtolower($file), fm_get_text_names()) || preg_match('#\.min\.(css|js)$#i', $file)) {
1015 $hljs_class = 'nohighlight';
1016 }
1017 $content = '<pre class="with-hljs"><code class="' . $hljs_class . '">' . fm_enc($content) . '</code></pre>';
1018 } elseif (in_array($ext, array('php', 'php4', 'php5', 'phtml', 'phps'))) {
1019 // php highlight
1020 $content = highlight_string($content, true);
1021 } else {
1022 $content = '<pre>' . fm_enc($content) . '</pre>';
1023 }
1024 echo $content;
1025 }
1026 ?>
1027 </div>
1028 <?php
1029 fm_show_footer();
1030 exit;
1031}
1032
1033// file editor
1034if (isset($_GET['edit'])) {
1035 $file = $_GET['edit'];
1036 $file = fm_clean_path($file);
1037 $file = str_replace('/', '', $file);
1038 if ($file == '' || !is_file($path . '/' . $file)) {
1039 fm_set_msg('File not found', 'error');
1040 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
1041 }
1042
1043 fm_show_header(); // HEADER
1044 fm_show_nav_path(FM_PATH); // current path
1045
1046 $file_url = FM_ROOT_URL . fm_convert_win((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file);
1047 $file_path = $path . '/' . $file;
1048
1049 //normal editer
1050 $isNormalEditor = true;
1051 if(isset($_GET['env'])) {
1052 if($_GET['env'] == "ace") {
1053 $isNormalEditor = false;
1054 }
1055 }
1056
1057 //Save File
1058 if(isset($_POST['savedata'])) {
1059 $writedata = $_POST['savedata'];
1060 $fd=fopen($file_path,"w");
1061 @fwrite($fd, $writedata);
1062 fclose($fd);
1063 fm_set_msg('File Saved Successfully', 'alert');
1064 }
1065
1066 $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
1067 $mime_type = fm_get_mime_type($file_path);
1068 $filesize = filesize($file_path);
1069 $is_text = false;
1070 $content = ''; // for text
1071
1072 if (in_array($ext, fm_get_text_exts()) || substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
1073 $is_text = true;
1074 $content = file_get_contents($file_path);
1075 }
1076
1077 ?>
1078 <div class="path pt-3">
1079 <div class="mb-3">
1080 <a title="Cancel" class="btn-outline-primary btn-sm btn" href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&view=<?php echo urlencode($file) ?>"><i class="fa fa-reply-all"></i> Cancel</a>
1081 <a title="Backup" class="btn-outline-primary btn-sm btn" href="javascript:backup('<?php echo urlencode($path) ?>','<?php echo urlencode($file) ?>')"><i class="fa fa-database"></i> Backup</a>
1082 <?php if($is_text) { ?>
1083 <?php if($isNormalEditor) { ?>
1084 <a class="btn-outline-primary btn-sm btn" title="Advanced" href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&edit=<?php echo urlencode($file) ?>&env=ace"><i class="fa fa-paper-plane"></i> Advanced Editor</a>
1085 <button class="btn-outline-primary btn-sm btn" type="button" name="Save" data-url="<?php echo fm_enc($file_url) ?>" onclick="edit_save(this,'nrl')"><i class="fa fa-floppy-o"></i> Save</button>
1086 <?php } else { ?>
1087 <a class="btn-outline-primary btn-sm btn" title="Plain Editor" href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&edit=<?php echo urlencode($file) ?>"><i class="fa fa-text-height"></i> Plain Editor</a>
1088 <button class="btn-outline-primary btn-sm btn" type="button" name="Save" data-url="<?php echo fm_enc($file_url) ?>" onclick="edit_save(this,'ace')"><i class="fa fa-floppy-o"></i> Save</button>
1089 <?php } ?>
1090 <?php } ?>
1091 </div>
1092 <?php
1093 if ($is_text && $isNormalEditor) {
1094 echo '<textarea id="normal-editor" rows="33" cols="120" style="width: 99.5%;">'. htmlspecialchars($content) .'</textarea>';
1095 } elseif ($is_text) {
1096 echo '<div id="editor" contenteditable="true">'. htmlspecialchars($content) .'</div>';
1097 } else {
1098 fm_set_msg('FILE EXTENSION HAS NOT SUPPORTED', 'error');
1099 }
1100 ?>
1101 </div>
1102 <?php
1103 fm_show_footer();
1104 exit;
1105}
1106
1107// chmod (not for Windows)
1108if (isset($_GET['chmod']) && !FM_READONLY && !FM_IS_WIN) {
1109 $file = $_GET['chmod'];
1110 $file = fm_clean_path($file);
1111 $file = str_replace('/', '', $file);
1112 if ($file == '' || (!is_file($path . '/' . $file) && !is_dir($path . '/' . $file))) {
1113 fm_set_msg('File not found', 'error');
1114 fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
1115 }
1116
1117 fm_show_header(); // HEADER
1118 fm_show_nav_path(FM_PATH); // current path
1119
1120 $file_url = FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file;
1121 $file_path = $path . '/' . $file;
1122
1123 $mode = fileperms($path . '/' . $file);
1124
1125 ?>
1126 <div class="path">
1127 <div class="py-3 container">
1128 <p><b><?php echo '<h4><b>Change Permissions</b></h4>'; ?></b></p>
1129 <p>
1130 <?php echo 'Full path:'; ?> <?php echo $file_path ?><br><hr>
1131 </p>
1132 <form action="" method="post">
1133 <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
1134 <input type="hidden" name="chmod" value="<?php echo fm_enc($file) ?>">
1135
1136 <table class="compact-table">
1137 <tr>
1138 <td></td>
1139 <td><b>Owner</b></td>
1140 <td><b>Group</b></td>
1141 <td><b>Other</b></td>
1142 </tr>
1143 <tr>
1144 <td style="text-align: right"><b>Read</b></td>
1145 <td><label><input type="checkbox" name="ur" value="1"<?php echo ($mode & 00400) ? ' checked' : '' ?>></label></td>
1146 <td><label><input type="checkbox" name="gr" value="1"<?php echo ($mode & 00040) ? ' checked' : '' ?>></label></td>
1147 <td><label><input type="checkbox" name="or" value="1"<?php echo ($mode & 00004) ? ' checked' : '' ?>></label></td>
1148 </tr>
1149 <tr>
1150 <td style="text-align: right"><b>Write</b></td>
1151 <td><label><input type="checkbox" name="uw" value="1"<?php echo ($mode & 00200) ? ' checked' : '' ?>></label></td>
1152 <td><label><input type="checkbox" name="gw" value="1"<?php echo ($mode & 00020) ? ' checked' : '' ?>></label></td>
1153 <td><label><input type="checkbox" name="ow" value="1"<?php echo ($mode & 00002) ? ' checked' : '' ?>></label></td>
1154 </tr>
1155 <tr>
1156 <td style="text-align: right"><b>Execute</b></td>
1157 <td><label><input type="checkbox" name="ux" value="1"<?php echo ($mode & 00100) ? ' checked' : '' ?>></label></td>
1158 <td><label><input type="checkbox" name="gx" value="1"<?php echo ($mode & 00010) ? ' checked' : '' ?>></label></td>
1159 <td><label><input type="checkbox" name="ox" value="1"<?php echo ($mode & 00001) ? ' checked' : '' ?>></label></td>
1160 </tr>
1161 </table>
1162
1163 <p>
1164 <button type="submit" class="btn btn-primary"><i class="fa fa-check-circle"></i> Change</button>
1165 <b><a href="?p=<?php echo urlencode(FM_PATH) ?>" class="text-secondary"><i class="fa fa-times-circle"></i> Cancel</a></b>
1166 </p>
1167
1168 </form>
1169
1170 </div>
1171 </div>
1172 <?php
1173 fm_show_footer();
1174 exit;
1175}
1176
1177//--- FILEMANAGER MAIN
1178fm_show_header(); // HEADER
1179fm_show_nav_path(FM_PATH); // current path
1180
1181// messages
1182fm_show_message();
1183
1184$num_files = count($files);
1185$num_folders = count($folders);
1186$all_files_size = 0;
1187?>
1188<form class="mt-3 mx-3" action="" method="post">
1189 <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
1190 <input type="hidden" name="group" value="1">
1191 <?php if(FM_TREEVIEW) { ?>
1192 <div class="row">
1193 <div class="col-sm-3 <?php echo $_SESSION['treeHide'] == 'true'?'d-none':''; ?>">
1194 <div class="file-tree-view border w-100" id="file-tree-view">
1195 <div class="tree-title"><i class="fa fa-align-left fa-fw"></i> Browse</div>
1196 <?php
1197 //file tre view
1198 echo php_file_tree($root_path, "javascript:alert('You clicked on [link]');");
1199 ?>
1200 </div>
1201 </div>
1202 <?php } ?>
1203 <div class="col-sm-<?php echo $_SESSION['treeHide'] == 'true'?'12':'9'; ?> mt-3 mt-md-0">
1204 <div class="table-responsive">
1205 <table class="table" id="main-table"><thead><tr>
1206 <?php if (!FM_READONLY): ?>
1207 <th style="width:3%">
1208 <label>
1209 <input type="checkbox" title="Invert selection" onclick="checkbox_toggle()">
1210 </label>
1211 </th><?php endif; ?>
1212 <th>Name</th>
1213 <th style="width:10%">Size</th>
1214 <th style="width:12%">Modified</th>
1215 <?php if (!FM_IS_WIN): ?>
1216 <th style="width:6%">Perms</th>
1217 <th style="width:10%">Owner</th><?php endif; ?>
1218 <th style="width:<?php if (!FM_READONLY): ?>13<?php else: ?>6.5<?php endif; ?>%">Actions</th>
1219 </tr>
1220 </thead>
1221 <?php
1222 // link to parent folder
1223 if ($parent !== false) {
1224 ?>
1225 <tr><?php if (!FM_READONLY): ?><td></td><?php endif; ?><td colspan="<?php echo !FM_IS_WIN ? '6' : '4' ?>"><a href="?p=<?php echo urlencode($parent) ?>"><i class="fa fa-chevron-circle-left"></i> ..</a></td></tr>
1226 <?php
1227 }
1228 foreach ($folders as $f) {
1229 $is_link = is_link($path . '/' . $f);
1230 $img = $is_link ? 'icon-link_folder' : 'fa fa-folder-o';
1231 $modif = date(FM_DATETIME_FORMAT, filemtime($path . '/' . $f));
1232 $perms = substr(decoct(fileperms($path . '/' . $f)), -4);
1233 if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
1234 $owner = posix_getpwuid(fileowner($path . '/' . $f));
1235 $group = posix_getgrgid(filegroup($path . '/' . $f));
1236 } else {
1237 $owner = array('name' => '?');
1238 $group = array('name' => '?');
1239 }
1240 ?>
1241 <tr>
1242 <?php if (!FM_READONLY): ?>
1243 <td>
1244 <label>
1245 <input type="checkbox" name="file[]" value="<?php echo fm_enc($f) ?>">
1246 </label>
1247 </td><?php endif; ?>
1248 <td>
1249 <div class="filename"><a href="?p=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i
1250 class="<?php echo $img ?>"></i> <?php echo fm_convert_win($f) ?>
1251 </a><?php echo($is_link ? ' → <i>' . readlink($path . '/' . $f) . '</i>' : '') ?></div>
1252 </td>
1253 <td>Folder</td>
1254 <td><?php echo $modif ?></td>
1255 <?php if (!FM_IS_WIN): ?>
1256 <td><?php if (!FM_READONLY): ?><a title="Change Permissions"
1257 href="?p=<?php echo urlencode(FM_PATH) ?>&chmod=<?php echo urlencode($f) ?>"><?php echo $perms ?></a><?php else: ?><?php echo $perms ?><?php endif; ?>
1258 </td>
1259 <td><?php echo $owner['name'] . ':' . $group['name'] ?></td>
1260 <?php endif; ?>
1261 <td class="inline-actions"><?php if (!FM_READONLY): ?>
1262 <a title="Delete" href="?p=<?php echo urlencode(FM_PATH) ?>&del=<?php echo urlencode($f) ?>"
1263 onclick="return confirm('Delete folder?');"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
1264 <a title="Rename" href="#"
1265 onclick="rename('<?php echo fm_enc(FM_PATH) ?>', '<?php echo fm_enc($f) ?>');return false;"><i
1266 class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
1267 <a title="Copy to..."
1268 href="?p=&copy=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i
1269 class="fa fa-files-o" aria-hidden="true"></i></a>
1270 <?php endif; ?>
1271 <a title="Direct link"
1272 href="<?php echo fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f . '/') ?>"
1273 target="_blank"><i class="fa fa-link" aria-hidden="true"></i></a>
1274 </td>
1275 </tr>
1276 <?php
1277 flush();
1278 }
1279
1280 foreach ($files as $f) {
1281 $is_link = is_link($path . '/' . $f);
1282 $img = $is_link ? 'fa fa-file-text-o' : fm_get_file_icon_class($path . '/' . $f);
1283 $modif = date("d.m.y H:i", filemtime($path . '/' . $f));
1284 $filesize_raw = filesize($path . '/' . $f);
1285 $filesize = fm_get_filesize($filesize_raw);
1286 $filelink = '?p=' . urlencode(FM_PATH) . '&view=' . urlencode($f);
1287 $all_files_size += $filesize_raw;
1288 $perms = substr(decoct(fileperms($path . '/' . $f)), -4);
1289 if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
1290 $owner = posix_getpwuid(fileowner($path . '/' . $f));
1291 $group = posix_getgrgid(filegroup($path . '/' . $f));
1292 } else {
1293 $owner = array('name' => '?');
1294 $group = array('name' => '?');
1295 }
1296 ?>
1297 <tr>
1298 <?php if (!FM_READONLY): ?><td><label><input type="checkbox" name="file[]" value="<?php echo fm_enc($f) ?>"></label></td><?php endif; ?>
1299 <td><div class="filename"><a href="<?php echo $filelink ?>" title="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>
1300 <td><span title="<?php printf('%s bytes', $filesize_raw) ?>"><?php echo $filesize ?></span></td>
1301 <td><?php echo $modif ?></td>
1302 <?php if (!FM_IS_WIN): ?>
1303 <td><?php if (!FM_READONLY): ?><a title="<?php echo '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>
1304 <td><?php echo fm_enc($owner['name'] . ':' . $group['name']) ?></td>
1305 <?php endif; ?>
1306 <td class="inline-actions">
1307 <?php if (!FM_READONLY): ?>
1308 <a title="Delete" href="?p=<?php echo urlencode(FM_PATH) ?>&del=<?php echo urlencode($f) ?>" onclick="return confirm('Delete file?');"><i class="fa fa-trash-o"></i></a>
1309 <a title="Rename" href="#" onclick="rename('<?php echo fm_enc(FM_PATH) ?>', '<?php echo fm_enc($f) ?>');return false;"><i class="fa fa-pencil-square-o"></i></a>
1310 <a title="Copy to..." href="?p=<?php echo urlencode(FM_PATH) ?>&copy=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="fa fa-files-o"></i></a>
1311 <?php endif; ?>
1312 <a title="Direct link" href="<?php echo fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f) ?>" target="_blank"><i class="fa fa-link"></i></a>
1313 <a title="Download" href="?p=<?php echo urlencode(FM_PATH) ?>&dl=<?php echo urlencode($f) ?>"><i class="fa fa-download"></i></a>
1314 </td></tr>
1315 <?php
1316 flush();
1317 }
1318
1319 if (empty($folders) && empty($files)) {
1320 ?>
1321 <tr><?php if (!FM_READONLY): ?><td></td><?php endif; ?><td colspan="<?php echo !FM_IS_WIN ? '6' : '4' ?>"><em><?php echo 'Folder is empty' ?></em></td></tr>
1322 <?php
1323 } else {
1324 ?>
1325 <tr><?php if (!FM_READONLY): ?><td class="gray"></td><?php endif; ?><td class="gray" colspan="<?php echo !FM_IS_WIN ? '6' : '4' ?>">
1326 Full size: <span title="<?php printf('%s bytes', $all_files_size) ?>"><?php echo fm_get_filesize($all_files_size) ?></span>,
1327 files: <?php echo $num_files ?>,
1328 folders: <?php echo $num_folders ?>
1329 </td></tr>
1330 <?php
1331 }
1332 ?>
1333 </table>
1334 </div>
1335 </div>
1336 </div>
1337 <?php if (!FM_READONLY): ?>
1338 <div class="mb-5 row">
1339 <div class="col-sm-9 offset-sm-3"><a href="#/select-all" class="mt-2 mt-sm-0 btn2 btn btn-small btn-outline-primary" onclick="select_all();return false;"><i class="fa fa-check-square"></i> Select all</a>
1340 <a href="#/unselect-all" class="mt-2 mt-sm-0 btn2 btn btn-small btn-outline-primary" onclick="unselect_all();return false;"><i class="fa fa-window-close"></i> Unselect all</a>
1341 <a href="#/invert-all" class="mt-2 mt-sm-0 btn2 btn btn-small btn-outline-primary" onclick="invert_all();return false;"><i class="fa fa-th-list"></i> Invert selection</a>
1342 <input type="submit" class="hidden" name="delete" id="a-delete" value="Delete" onclick="return confirm('Delete selected files and folders?')">
1343 <a href="javascript:document.getElementById('a-delete').click();" class="mt-2 mt-sm-0 btn2 btn btn-small btn-outline-primary"><i class="fa fa-trash"></i> Delete </a>
1344 <input type="submit" class="hidden" name="zip" id="a-zip" value="Zip" onclick="return confirm('Create archive?')">
1345 <a href="javascript:document.getElementById('a-zip').click();" class="mt-2 mt-sm-0 btn2 btn btn-small btn-outline-primary"><i class="fa fa-file-archive-o"></i> Zip </a>
1346 <input type="submit" class="hidden" name="copy" id="a-copy" value="Copy">
1347 <a href="javascript:document.getElementById('a-copy').click();" class="mt-2 mt-sm-0 btn2 btn btn-small btn-outline-primary"><i class="fa fa-files-o"></i> Copy </a>
1348 </div>
1349 </div>
1350 <?php endif; ?>
1351</form>
1352
1353<?php
1354fm_show_footer();
1355
1356//--- END
1357
1358// Functions
1359
1360/**
1361 * Delete file or folder (recursively)
1362 * @param string $path
1363 * @return bool
1364 */
1365function fm_rdelete($path)
1366{
1367 if (is_link($path)) {
1368 return unlink($path);
1369 } elseif (is_dir($path)) {
1370 $objects = scandir($path);
1371 $ok = true;
1372 if (is_array($objects)) {
1373 foreach ($objects as $file) {
1374 if ($file != '.' && $file != '..') {
1375 if (!fm_rdelete($path . '/' . $file)) {
1376 $ok = false;
1377 }
1378 }
1379 }
1380 }
1381 return ($ok) ? rmdir($path) : false;
1382 } elseif (is_file($path)) {
1383 return unlink($path);
1384 }
1385 return false;
1386}
1387
1388/**
1389 * Recursive chmod
1390 * @param string $path
1391 * @param int $filemode
1392 * @param int $dirmode
1393 * @return bool
1394 * @todo Will use in mass chmod
1395 */
1396function fm_rchmod($path, $filemode, $dirmode)
1397{
1398 if (is_dir($path)) {
1399 if (!chmod($path, $dirmode)) {
1400 return false;
1401 }
1402 $objects = scandir($path);
1403 if (is_array($objects)) {
1404 foreach ($objects as $file) {
1405 if ($file != '.' && $file != '..') {
1406 if (!fm_rchmod($path . '/' . $file, $filemode, $dirmode)) {
1407 return false;
1408 }
1409 }
1410 }
1411 }
1412 return true;
1413 } elseif (is_link($path)) {
1414 return true;
1415 } elseif (is_file($path)) {
1416 return chmod($path, $filemode);
1417 }
1418 return false;
1419}
1420
1421/**
1422 * Safely rename
1423 * @param string $old
1424 * @param string $new
1425 * @return bool|null
1426 */
1427function fm_rename($old, $new)
1428{
1429 return (!file_exists($new) && file_exists($old)) ? rename($old, $new) : null;
1430}
1431
1432/**
1433 * Copy file or folder (recursively).
1434 * @param string $path
1435 * @param string $dest
1436 * @param bool $upd Update files
1437 * @param bool $force Create folder with same names instead file
1438 * @return bool
1439 */
1440function fm_rcopy($path, $dest, $upd = true, $force = true)
1441{
1442 if (is_dir($path)) {
1443 if (!fm_mkdir($dest, $force)) {
1444 return false;
1445 }
1446 $objects = scandir($path);
1447 $ok = true;
1448 if (is_array($objects)) {
1449 foreach ($objects as $file) {
1450 if ($file != '.' && $file != '..') {
1451 if (!fm_rcopy($path . '/' . $file, $dest . '/' . $file)) {
1452 $ok = false;
1453 }
1454 }
1455 }
1456 }
1457 return $ok;
1458 } elseif (is_file($path)) {
1459 return fm_copy($path, $dest, $upd);
1460 }
1461 return false;
1462}
1463
1464/**
1465 * Safely create folder
1466 * @param string $dir
1467 * @param bool $force
1468 * @return bool
1469 */
1470function fm_mkdir($dir, $force)
1471{
1472 if (file_exists($dir)) {
1473 if (is_dir($dir)) {
1474 return $dir;
1475 } elseif (!$force) {
1476 return false;
1477 }
1478 unlink($dir);
1479 }
1480 return mkdir($dir, 0777, true);
1481}
1482
1483/**
1484 * Safely copy file
1485 * @param string $f1
1486 * @param string $f2
1487 * @param bool $upd
1488 * @return bool
1489 */
1490function fm_copy($f1, $f2, $upd)
1491{
1492 $time1 = filemtime($f1);
1493 if (file_exists($f2)) {
1494 $time2 = filemtime($f2);
1495 if ($time2 >= $time1 && $upd) {
1496 return false;
1497 }
1498 }
1499 $ok = copy($f1, $f2);
1500 if ($ok) {
1501 touch($f2, $time1);
1502 }
1503 return $ok;
1504}
1505
1506/**
1507 * Get mime type
1508 * @param string $file_path
1509 * @return mixed|string
1510 */
1511function fm_get_mime_type($file_path)
1512{
1513 if (function_exists('finfo_open')) {
1514 $finfo = finfo_open(FILEINFO_MIME_TYPE);
1515 $mime = finfo_file($finfo, $file_path);
1516 finfo_close($finfo);
1517 return $mime;
1518 } elseif (function_exists('mime_content_type')) {
1519 return mime_content_type($file_path);
1520 } elseif (!stristr(ini_get('disable_functions'), 'shell_exec')) {
1521 $file = escapeshellarg($file_path);
1522 $mime = shell_exec('file -bi ' . $file);
1523 return $mime;
1524 } else {
1525 return '--';
1526 }
1527}
1528
1529/**
1530 * HTTP Redirect
1531 * @param string $url
1532 * @param int $code
1533 */
1534function fm_redirect($url, $code = 302)
1535{
1536 header('Location: ' . $url, true, $code);
1537 exit;
1538}
1539
1540/**
1541 * Clean path
1542 * @param string $path
1543 * @return string
1544 */
1545function fm_clean_path($path)
1546{
1547 $path = trim($path);
1548 $path = trim($path, '\\/');
1549 $path = str_replace(array('../', '..\\'), '', $path);
1550 if ($path == '..') {
1551 $path = '';
1552 }
1553 return str_replace('\\', '/', $path);
1554}
1555
1556/**
1557 * Get parent path
1558 * @param string $path
1559 * @return bool|string
1560 */
1561function fm_get_parent_path($path)
1562{
1563 $path = fm_clean_path($path);
1564 if ($path != '') {
1565 $array = explode('/', $path);
1566 if (count($array) > 1) {
1567 $array = array_slice($array, 0, -1);
1568 return implode('/', $array);
1569 }
1570 return '';
1571 }
1572 return false;
1573}
1574
1575/**
1576 * Get nice filesize
1577 * @param int $size
1578 * @return string
1579 */
1580function fm_get_filesize($size)
1581{
1582 if ($size < 1000) {
1583 return sprintf('%s B', $size);
1584 } elseif (($size / 1024) < 1000) {
1585 return sprintf('%s KiB', round(($size / 1024), 2));
1586 } elseif (($size / 1024 / 1024) < 1000) {
1587 return sprintf('%s MiB', round(($size / 1024 / 1024), 2));
1588 } elseif (($size / 1024 / 1024 / 1024) < 1000) {
1589 return sprintf('%s GiB', round(($size / 1024 / 1024 / 1024), 2));
1590 } else {
1591 return sprintf('%s TiB', round(($size / 1024 / 1024 / 1024 / 1024), 2));
1592 }
1593}
1594
1595/**
1596 * Get info about zip archive
1597 * @param string $path
1598 * @return array|bool
1599 */
1600function fm_get_zif_info($path)
1601{
1602 if (function_exists('zip_open')) {
1603 $arch = zip_open($path);
1604 if ($arch) {
1605 $filenames = array();
1606 while ($zip_entry = zip_read($arch)) {
1607 $zip_name = zip_entry_name($zip_entry);
1608 $zip_folder = substr($zip_name, -1) == '/';
1609 $filenames[] = array(
1610 'name' => $zip_name,
1611 'filesize' => zip_entry_filesize($zip_entry),
1612 'compressed_size' => zip_entry_compressedsize($zip_entry),
1613 'folder' => $zip_folder
1614 //'compression_method' => zip_entry_compressionmethod($zip_entry),
1615 );
1616 }
1617 zip_close($arch);
1618 return $filenames;
1619 }
1620 }
1621 return false;
1622}
1623
1624/**
1625 * Encode html entities
1626 * @param string $text
1627 * @return string
1628 */
1629function fm_enc($text)
1630{
1631 return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
1632}
1633
1634/**
1635 * This function scans the files folder recursively, and builds a large array
1636 * @param string $dir
1637 * @return json
1638 */
1639function scan($dir){
1640 $files = array();
1641 $_dir = $dir;
1642 $dir = FM_ROOT_PATH.'/'.$dir;
1643 // Is there actually such a folder/file?
1644 if(file_exists($dir)){
1645 foreach(scandir($dir) as $f) {
1646 if(!$f || $f[0] == '.') {
1647 continue; // Ignore hidden files
1648 }
1649
1650 if(is_dir($dir . '/' . $f)) {
1651 // The path is a folder
1652 $files[] = array(
1653 "name" => $f,
1654 "type" => "folder",
1655 "path" => $_dir.'/'.$f,
1656 "items" => scan($dir . '/' . $f), // Recursively get the contents of the folder
1657 );
1658 } else {
1659 // It is a file
1660 $files[] = array(
1661 "name" => $f,
1662 "type" => "file",
1663 "path" => $_dir,
1664 "size" => filesize($dir . '/' . $f) // Gets the size of this file
1665 );
1666 }
1667 }
1668 }
1669 return $files;
1670}
1671
1672/**
1673 * Scan directory and return tree view
1674 * @param string $directory
1675 * @param boolean $first_call
1676 */
1677function php_file_tree_dir($directory, $first_call = true) {
1678 // Recursive function called by php_file_tree() to list directories/files
1679
1680 $php_file_tree = "";
1681 // Get and sort directories/files
1682 if( function_exists("scandir") ) $file = scandir($directory);
1683 natcasesort($file);
1684 // Make directories first
1685 $files = $dirs = array();
1686 foreach($file as $this_file) {
1687 if( is_dir("$directory/$this_file" ) ) {
1688 if(!in_array($this_file, $GLOBALS['exclude_folders'])){
1689 $dirs[] = $this_file;
1690 }
1691 } else {
1692 $files[] = $this_file;
1693 }
1694 }
1695 $file = array_merge($dirs, $files);
1696
1697 if( count($file) > 2 ) { // Use 2 instead of 0 to account for . and .. "directories"
1698 $php_file_tree = "<ul";
1699 if( $first_call ) { $php_file_tree .= " class=\"pl-2 pt-2 php-file-tree\""; $first_call = false; }
1700 $php_file_tree .= ">";
1701 foreach( $file as $this_file ) {
1702 if( $this_file != "." && $this_file != ".." ) {
1703 if( is_dir("$directory/$this_file") ) {
1704 // Directory
1705 $php_file_tree .= "<li class=\"pft-directory\"><i class=\"fa fa-folder-o\"></i><a href=\"#\">" . htmlspecialchars($this_file) . "</a>";
1706 $php_file_tree .= php_file_tree_dir("$directory/$this_file", false);
1707 $php_file_tree .= "</li>";
1708 } else {
1709 // File
1710 $ext = fm_get_file_icon_class($this_file);
1711 $path = str_replace($_SERVER['DOCUMENT_ROOT'],"",$directory);
1712 $link = "?p="."$path" ."&view=".urlencode($this_file);
1713 $php_file_tree .= "<li class=\"pft-file\"><a href=\"$link\"> <i class=\"$ext\"></i>" . htmlspecialchars($this_file) . "</a></li>";
1714 }
1715 }
1716 }
1717 $php_file_tree .= "</ul>";
1718 }
1719 return $php_file_tree;
1720}
1721
1722/**
1723 * Scan directory and render tree view
1724 * @param string $directory
1725 */
1726function php_file_tree($directory) {
1727 // Remove trailing slash
1728 $code = "";
1729 if( substr($directory, -1) == "/" ) $directory = substr($directory, 0, strlen($directory) - 1);
1730 if(function_exists('php_file_tree_dir')) {
1731 $code .= php_file_tree_dir($directory);
1732 return $code;
1733 }
1734}
1735
1736/**
1737 * Save message in session
1738 * @param string $msg
1739 * @param string $status
1740 */
1741function fm_set_msg($msg, $status = 'ok')
1742{
1743 $_SESSION['message'] = $msg;
1744 $_SESSION['status'] = $status;
1745}
1746
1747/**
1748 * Check if string is in UTF-8
1749 * @param string $string
1750 * @return int
1751 */
1752function fm_is_utf8($string)
1753{
1754 return preg_match('//u', $string);
1755}
1756
1757/**
1758 * Convert file name to UTF-8 in Windows
1759 * @param string $filename
1760 * @return string
1761 */
1762function fm_convert_win($filename)
1763{
1764 if (FM_IS_WIN && function_exists('iconv')) {
1765 $filename = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $filename);
1766 }
1767 return $filename;
1768}
1769
1770/**
1771 * Get CSS classname for file
1772 * @param string $path
1773 * @return string
1774 */
1775function fm_get_file_icon_class($path)
1776{
1777 // get extension
1778 $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
1779
1780 switch ($ext) {
1781 case 'ico': case 'gif': case 'jpg': case 'jpeg': case 'jpc': case 'jp2':
1782 case 'jpx': case 'xbm': case 'wbmp': case 'png': case 'bmp': case 'tif':
1783 case 'tiff': case 'svg':
1784 $img = 'fa fa-picture-o';
1785 break;
1786 case 'passwd': case 'ftpquota': case 'sql': case 'js': case 'json': case 'sh':
1787 case 'config': case 'twig': case 'tpl': case 'md': case 'gitignore':
1788 case 'c': case 'cpp': case 'cs': case 'py': case 'map': case 'lock': case 'dtd':
1789 $img = 'fa fa-file-code-o';
1790 break;
1791 case 'txt': case 'ini': case 'conf': case 'log': case 'htaccess':
1792 $img = 'fa fa-file-text-o';
1793 break;
1794 case 'css': case 'less': case 'sass': case 'scss':
1795 $img = 'fa fa-css3';
1796 break;
1797 case 'zip': case 'rar': case 'gz': case 'tar': case '7z':
1798 $img = 'fa fa-file-archive-o';
1799 break;
1800 case 'php': case 'php4': case 'php5': case 'phps': case 'phtml':
1801 $img = 'fa fa-code';
1802 break;
1803 case 'htm': case 'html': case 'shtml': case 'xhtml':
1804 $img = 'fa fa-html5';
1805 break;
1806 case 'xml': case 'xsl':
1807 $img = 'fa fa-file-excel-o';
1808 break;
1809 case 'wav': case 'mp3': case 'mp2': case 'm4a': case 'aac': case 'ogg':
1810 case 'oga': case 'wma': case 'mka': case 'flac': case 'ac3': case 'tds':
1811 $img = 'fa fa-music';
1812 break;
1813 case 'm3u': case 'm3u8': case 'pls': case 'cue':
1814 $img = 'fa fa-headphones';
1815 break;
1816 case 'avi': case 'mpg': case 'mpeg': case 'mp4': case 'm4v': case 'flv':
1817 case 'f4v': case 'ogm': case 'ogv': case 'mov': case 'mkv': case '3gp':
1818 case 'asf': case 'wmv':
1819 $img = 'fa fa-file-video-o';
1820 break;
1821 case 'eml': case 'msg':
1822 $img = 'fa fa-envelope-o';
1823 break;
1824 case 'xls': case 'xlsx':
1825 $img = 'fa fa-file-excel-o';
1826 break;
1827 case 'csv':
1828 $img = 'fa fa-file-text-o';
1829 break;
1830 case 'bak':
1831 $img = 'fa fa-clipboard';
1832 break;
1833 case 'doc': case 'docx':
1834 $img = 'fa fa-file-word-o';
1835 break;
1836 case 'ppt': case 'pptx':
1837 $img = 'fa fa-file-powerpoint-o';
1838 break;
1839 case 'ttf': case 'ttc': case 'otf': case 'woff':case 'woff2': case 'eot': case 'fon':
1840 $img = 'fa fa-font';
1841 break;
1842 case 'pdf':
1843 $img = 'fa fa-file-pdf-o';
1844 break;
1845 case 'psd': case 'ai': case 'eps': case 'fla': case 'swf':
1846 $img = 'fa fa-file-image-o';
1847 break;
1848 case 'exe': case 'msi':
1849 $img = 'fa fa-file-o';
1850 break;
1851 case 'bat':
1852 $img = 'fa fa-terminal';
1853 break;
1854 default:
1855 $img = 'fa fa-info-circle';
1856 }
1857
1858 return $img;
1859}
1860
1861/**
1862 * Get image files extensions
1863 * @return array
1864 */
1865function fm_get_image_exts()
1866{
1867 return array('ico', 'gif', 'jpg', 'jpeg', 'jpc', 'jp2', 'jpx', 'xbm', 'wbmp', 'png', 'bmp', 'tif', 'tiff', 'psd');
1868}
1869
1870/**
1871 * Get video files extensions
1872 * @return array
1873 */
1874function fm_get_video_exts()
1875{
1876 return array('webm', 'mp4', 'm4v', 'ogm', 'ogv', 'mov');
1877}
1878
1879/**
1880 * Get audio files extensions
1881 * @return array
1882 */
1883function fm_get_audio_exts()
1884{
1885 return array('wav', 'mp3', 'ogg', 'm4a');
1886}
1887
1888/**
1889 * Get text file extensions
1890 * @return array
1891 */
1892function fm_get_text_exts()
1893{
1894 return array(
1895 'txt', 'css', 'ini', 'conf', 'log', 'htaccess', 'passwd', 'ftpquota', 'sql', 'js', 'json', 'sh', 'config',
1896 'php', 'php4', 'php5', 'phps', 'phtml', 'htm', 'html', 'shtml', 'xhtml', 'xml', 'xsl', 'm3u', 'm3u8', 'pls', 'cue',
1897 'eml', 'msg', 'csv', 'bat', 'twig', 'tpl', 'md', 'gitignore', 'less', 'sass', 'scss', 'c', 'cpp', 'cs', 'py',
1898 'map', 'lock', 'dtd', 'svg',
1899 );
1900}
1901
1902/**
1903 * Get mime types of text files
1904 * @return array
1905 */
1906function fm_get_text_mimes()
1907{
1908 return array(
1909 'application/xml',
1910 'application/javascript',
1911 'application/x-javascript',
1912 'image/svg+xml',
1913 'message/rfc822',
1914 );
1915}
1916
1917/**
1918 * Get file names of text files w/o extensions
1919 * @return array
1920 */
1921function fm_get_text_names()
1922{
1923 return array(
1924 'license',
1925 'readme',
1926 'authors',
1927 'contributors',
1928 'changelog',
1929 );
1930}
1931
1932/**
1933 * Class to work with zip files (using ZipArchive)
1934 */
1935class FM_Zipper
1936{
1937 private $zip;
1938
1939 public function __construct()
1940 {
1941 $this->zip = new ZipArchive();
1942 }
1943
1944 /**
1945 * Create archive with name $filename and files $files (RELATIVE PATHS!)
1946 * @param string $filename
1947 * @param array|string $files
1948 * @return bool
1949 */
1950 public function create($filename, $files)
1951 {
1952 $res = $this->zip->open($filename, ZipArchive::CREATE);
1953 if ($res !== true) {
1954 return false;
1955 }
1956 if (is_array($files)) {
1957 foreach ($files as $f) {
1958 if (!$this->addFileOrDir($f)) {
1959 $this->zip->close();
1960 return false;
1961 }
1962 }
1963 $this->zip->close();
1964 return true;
1965 } else {
1966 if ($this->addFileOrDir($files)) {
1967 $this->zip->close();
1968 return true;
1969 }
1970 return false;
1971 }
1972 }
1973
1974 /**
1975 * Extract archive $filename to folder $path (RELATIVE OR ABSOLUTE PATHS)
1976 * @param string $filename
1977 * @param string $path
1978 * @return bool
1979 */
1980 public function unzip($filename, $path)
1981 {
1982 $res = $this->zip->open($filename);
1983 if ($res !== true) {
1984 return false;
1985 }
1986 if ($this->zip->extractTo($path)) {
1987 $this->zip->close();
1988 return true;
1989 }
1990 return false;
1991 }
1992
1993 /**
1994 * Add file/folder to archive
1995 * @param string $filename
1996 * @return bool
1997 */
1998 private function addFileOrDir($filename)
1999 {
2000 if (is_file($filename)) {
2001 return $this->zip->addFile($filename);
2002 } elseif (is_dir($filename)) {
2003 return $this->addDir($filename);
2004 }
2005 return false;
2006 }
2007
2008 /**
2009 * Add folder recursively
2010 * @param string $path
2011 * @return bool
2012 */
2013 private function addDir($path)
2014 {
2015 if (!$this->zip->addEmptyDir($path)) {
2016 return false;
2017 }
2018 $objects = scandir($path);
2019 if (is_array($objects)) {
2020 foreach ($objects as $file) {
2021 if ($file != '.' && $file != '..') {
2022 if (is_dir($path . '/' . $file)) {
2023 if (!$this->addDir($path . '/' . $file)) {
2024 return false;
2025 }
2026 } elseif (is_file($path . '/' . $file)) {
2027 if (!$this->zip->addFile($path . '/' . $file)) {
2028 return false;
2029 }
2030 }
2031 }
2032 }
2033 return true;
2034 }
2035 return false;
2036 }
2037}
2038
2039//--- templates functions
2040
2041/**
2042 * Show nav block
2043 * @param string $path
2044 */
2045function fm_show_nav_path($path)
2046{
2047 global $lang;
2048 ?>
2049 <nav class="navbar navbar-light bg-light navbar-expand-lg" style="background: linear-gradient(to left, #99ccff 0%, #ccffcc 100%);">
2050
2051 <?php
2052 $path = fm_clean_path($path);
2053 $root_url = "<a href='?p='><i class='fa fa-home' aria-hidden='true' title='" . FM_ROOT_PATH . "'></i></a>";
2054 $sep = '<i class="fa fa-caret-right text-secondary"></i>';
2055 if ($path != '') {
2056 $exploded = explode('/', $path);
2057 $count = count($exploded);
2058 $array = array();
2059 $parent = '';
2060 for ($i = 0; $i < $count; $i++) {
2061 $parent = trim($parent . '/' . $exploded[$i], '/');
2062 $parent_enc = urlencode($parent);
2063 $array[] = "<a href='?p={$parent_enc}'>" . fm_enc(fm_convert_win($exploded[$i])) . "</a>";
2064 }
2065 $root_url .= $sep . implode($sep, $array);
2066 }
2067 echo '<div class="nav-item break-word float-left">' . $root_url . '</div>';
2068 ?>
2069
2070 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
2071 <span class="navbar-toggler-icon"></span>
2072 </button>
2073 <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
2074 <div class="navbar-nav float-rightd ml-auto">
2075 <?php if (!FM_READONLY): ?>
2076 <li class="nav-item"><a class="nav-link mx-1" title="Search" href="javascript:showSearch('<?php echo urlencode(FM_PATH) ?>')"><i class="fa fa-search fa-fw"></i> Search</a></li>
2077 <li class="nav-item"><a class="nav-link mx-1" title="Upload files" href="?p=<?php echo urlencode(FM_PATH) ?>&upload"><i class="fa fa-cloud-upload fa-fw" aria-hidden="true"></i> Upload Files</a></li>
2078 <li class="nav-item"><a class="nav-link mx-1" title="New folder" href style="outline: none;" data-toggle="modal" data-target="#createNewItem"><i class="fa fa-plus-square fa-fw"></i> New Item</a></li>
2079 <li class="nav-item"><a href="?toggleTree=true" class="nav-link mx-1" title="Toggle Directories List"><i class="fa fa-eye-slash fa-fw"></i> Toggle Tree View</a></li>
2080 <?php endif; ?>
2081 <?php if (FM_USE_AUTH): ?><li class="nav-item"><a class="nav-link ml-1" title="Logout" href="?logout=1"><i class="fa fa-sign-out fa-fw" aria-hidden="true"></i> Log Out</a></li><?php endif; ?>
2082 </div>
2083 </div>
2084 </nav>
2085 <?php
2086}
2087
2088/**
2089 * Show message from session
2090 */
2091function fm_show_message()
2092{
2093 if (isset($_SESSION['message'])) {
2094 $class = isset($_SESSION['status']) ? $_SESSION['status'] : 'alert-success';
2095 if($class == 'error'){
2096 $class = 'alert-danger';
2097 }
2098 if($class == 'alert'){
2099 $class = 'alert-info';
2100 }
2101 if($class == 'ok'){
2102 $class = 'alert-success';
2103 }
2104
2105 echo '<p class="mt-2 mx-3 alert ' . $class . '">' . $_SESSION['message'] . '</p>';
2106 unset($_SESSION['message']);
2107 unset($_SESSION['status']);
2108 }
2109}
2110
2111/**
2112 * Show page header in Login Form
2113 */
2114function fm_show_header_login()
2115{
2116$sprites_ver = '20160315';
2117header("Content-Type: text/html; charset=utf-8");
2118header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
2119header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
2120header("Pragma: no-cache");
2121
2122global $lang;
2123?>
2124 <!DOCTYPE html>
2125<html>
2126<head>
2127 <meta charset="utf-8">
2128 <title>File Manager</title>
2129 <meta name="Description" CONTENT="Web Storage">
2130 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
2131 <link rel="icon" href="<?php echo FM_SELF_URL ?>?img=favicon" type="image/png">
2132 <link rel="shortcut icon" href="<?php echo FM_SELF_URL ?>?img=favicon" type="image/png">
2133 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
2134 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
2135 <style>
2136 html{
2137 max-height: 100% !important;
2138 height: 100%;
2139 }
2140 /*a img,img{border:none}.filename,td,th{white-space:nowrap}.close,.close:focus,.close:hover,.php-file-tree a,a{text-decoration:none}a,body,code,div,em,form,html,img,label,li,ol,p,pre,small,span,strong,table,td,th,tr,ul{margin:0;padding:0;vertical-align:baseline;outline:0;font-size:100%;background:0 0;border:none;text-decoration:none}p,table,ul{margin-bottom:10px}html{overflow-y:scroll}body{padding:0;font:13px/16px Tahoma,Arial,sans-serif;color:#222;background:#F7F7F7;margin:50px 30px 0}button,input,select,textarea{font-size:inherit;font-family:inherit}a{color:#296ea3}a:hover{color:#b00}img{vertical-align:middle}span{color:#777}small{font-size:11px;color:#999}ul{list-style-type:none;margin-left:0}ul li{padding:3px 0}table{border-collapse:collapse;border-spacing:0;width:100%}.file-tree-view+#main-table{width:75%!important;float:left}td,th{padding:4px 7px;text-align:left;vertical-align:top;border:1px solid #ddd;background:#fff}td.gray,th{background-color:#eee}td.gray span{color:#222}tr:hover td{background-color:#f5f5f5}tr:hover td.gray{background-color:#eee}.table{width:100%;max-width:100%;margin-bottom:1rem}.table td,.table th{padding:.55rem;vertical-align:top;border-top:1px solid #ddd}.table thead th{vertical-align:bottom;border-bottom:2px solid #eceeef}.table tbody+tbody{border-top:2px solid #eceeef}.table .table{background-color:#fff}code,pre{display:block;margin-bottom:10px;font:13px/16px Consolas,'Courier New',Courier,monospace;border:1px dashed #ccc;padding:5px;overflow:auto}.hidden,.modal{display:none}.btn,.close{font-weight:700}pre.with-hljs{padding:0}pre.with-hljs code{margin:0;border:0;overflow:visible}code.maxheight,pre.maxheight{max-height:512px}input[type=checkbox]{margin:0;padding:0}.message,.path{padding:4px 7px;border:1px solid #ddd;background-color:#fff}.fa.fa-caret-right{font-size:1.2em;margin:0 4px;vertical-align:middle;color:#ececec}.fa.fa-home{font-size:1.2em;vertical-align:bottom}#wrapper{min-width:400px;margin:0 auto}.path{margin-bottom:10px}.right{text-align:right}.center,.close,.login-form{text-align:center}.float-right{float:right}.float-left{float:left}.message.ok{border-color:green;color:green}.message.error{border-color:red;color:red}.message.alert{border-color:orange;color:orange}.btn{border:0;background:0 0;padding:0;margin:0;color:#296ea3;cursor:pointer}.btn:hover{color:#b00}.preview-img{max-width:100%;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAKklEQVR42mL5//8/Azbw+PFjrOJMDCSCUQ3EABZc4S0rKzsaSvTTABBgAMyfCMsY4B9iAAAAAElFTkSuQmCC)}.inline-actions>a>i{font-size:1em;margin-left:5px;background:#3785c1;color:#fff;padding:3px;border-radius:3px}.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}.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}.filename{max-width:420px;overflow:hidden;text-overflow:ellipsis}.break-word{word-wrap:break-word;margin-left:30px}.break-word.float-left a{color:#7d7d7d}.break-word+.float-right{padding-right:30px;position:relative}.break-word+.float-right>a{color:#7d7d7d;font-size:1.2em;margin-right:4px}.modal{position:fixed;z-index:1;padding-top:100px;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:#000;background-color:rgba(0,0,0,.4)}#editor,.edit-file-actions{position:absolute;right:30px}.modal-content{background-color:#fefefe;margin:auto;padding:20px;border:1px solid #888;width:80%}.close:focus,.close:hover{color:#000;cursor:pointer}#editor{top:50px;bottom:5px;left:30px}.edit-file-actions{top:0;background:#fff;margin-top:5px}.edit-file-actions>a,.edit-file-actions>button{background:#fff;padding:5px 15px;cursor:pointer;color:#296ea3;border:1px solid #296ea3}.btn2 btn btn-small btn-outline-primary{background:#fff;padding:2px 6px;border:1px solid;cursor:pointer;color:#296ea3}.main-nav{position:fixed;top:0;left:0;padding:10px 30px 10px 1px;width:100%;background:#fff;color:#000;border:0;box-shadow:0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12),0 2px 4px -1px rgba(0,0,0,.2)}.login-form{width:320px;margin:0 auto;box-shadow:0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12),0 5px 5px -3px rgba(0,0,0,.2)}.login-form label,.path.login-form input{padding:8px;margin:10px}.footer-links{background:0 0;border:0;clear:both}select[name=lang]{border:none;position:relative;text-transform:uppercase;left:-30%;top:12px;color:silver}input[type=search]{height:30px;margin:5px;width:80%;border:1px solid #ccc}.path.login-form input[type=submit]{background-color:#4285f4;color:#fff;border:1px solid;border-radius:2px;font-weight:700;cursor:pointer}.modalDialog{position:fixed;font-family:Arial,Helvetica,sans-serif;top:0;right:0;bottom:0;left:0;background:rgba(0,0,0,.8);z-index:99999;opacity:0;-webkit-transition:opacity .4s ease-in;-moz-transition:opacity .4s ease-in;transition:opacity .4s ease-in;pointer-events:none}.modalDialog:target{opacity:1;pointer-events:auto}.modalDialog>.model-wrapper{max-width:400px;position:relative;margin:10% auto;padding:15px;border-radius:2px;background:#fff}.close{float:right;background:#fff;color:#000;line-height:25px;position:absolute;right:0;top:0;width:24px;border-radius:0 5px 0 0;font-size:18px}.close:hover{background:#e4e4e4}.modalDialog p{line-height:30px}div#searchresultWrapper{max-height:320px;overflow:auto}div#searchresultWrapper li{margin:8px 0;list-style:none}li.file:before,li.folder:before{font:normal normal normal 14px/1 FontAwesome;content:"\f016";margin-right:5px}li.folder:before{content:"\f114"}i.fa.fa-folder-o{color:#eeaf4b}i.fa.fa-picture-o{color:#26b99a}i.fa.fa-file-archive-o{color:#da7d7d}.footer-links i.fa.fa-file-archive-o{color:#296ea3}i.fa.fa-css3{color:#f36fa0}i.fa.fa-file-code-o{color:#ec6630}i.fa.fa-code{color:#cc4b4c}i.fa.fa-file-text-o{color:#0096e6}i.fa.fa-html5{color:#d75e72}i.fa.fa-file-excel-o{color:#09c55d}i.fa.fa-file-powerpoint-o{color:#f6712e}.file-tree-view{width:24%;float:left;overflow:auto;border:1px solid #ddd;border-right:0;background:#fff}.file-tree-view .tree-title{background:#eee;padding:9px 2px 9px 10px;font-weight:700}.file-tree-view ul{margin-left:15px;margin-bottom:0}.file-tree-view i{padding-right:3px}.php-file-tree{font-size:100%;letter-spacing:1px;line-height:1.5;margin-left:5px!important}.php-file-tree a{color:#296ea3}.php-file-tree A:hover{color:#b00}.php-file-tree .open{font-style:italic;color:#2183ce}.php-file-tree .closed{font-style:normal}#file-tree-view::-webkit-scrollbar{width:10px;background-color:#F5F5F5}#file-tree-view::-webkit-scrollbar-track{border-radius:10px;background:rgba(0,0,0,.1);border:1px solid #ccc}#file-tree-view::-webkit-scrollbar-thumb{border-radius:10px;background:linear-gradient(left,#fff,#e4e4e4);border:1px solid #aaa}#file-tree-view::-webkit-scrollbar-thumb:hover{background:#fff}#file-tree-view::-webkit-scrollbar-thumb:active{background:linear-gradient(left,#22ADD4,#1E98BA)}*/
2141 </style>
2142</head>
2143<body style="background: linear-gradient(to top left, #99ccff 0%, #ccffcc 100%);background-repeat: no-repeat;background-size: cover">
2144
2145
2146<div id="wrapper"">
2147
2148 <?php
2149 }
2150
2151 /**
2152 * Show page footer in Login Form
2153 */
2154 function fm_show_footer_login()
2155 {
2156 ?>
2157</div>
2158<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
2159<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
2160<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
2161</body>
2162</html>
2163<?php
2164}
2165
2166/**
2167 * Show page header
2168 */
2169function fm_show_header()
2170{
2171$sprites_ver = '20160315';
2172header("Content-Type: text/html; charset=utf-8");
2173header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
2174header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
2175header("Pragma: no-cache");
2176
2177global $lang;
2178?>
2179 <!DOCTYPE html>
2180<html>
2181<head>
2182 <meta charset="utf-8">
2183 <title>File Manager</title>
2184 <meta name="Description" CONTENT="Web Storage">
2185 <link rel="icon" href="<?php echo FM_SELF_URL ?>?img=favicon" type="image/png">
2186 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
2187 <link rel="shortcut icon" href="<?php echo FM_SELF_URL ?>?img=favicon" type="image/png">
2188 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
2189 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
2190 <?php if (isset($_GET['view']) && FM_USE_HIGHLIGHTJS): ?>
2191 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/styles/<?php echo FM_HIGHLIGHTJS_STYLE ?>.min.css">
2192 <?php endif; ?>
2193 <style>
2194 a img, img {
2195 border: none
2196 }
2197
2198 .filename, td, th {
2199 white-space: nowrap
2200 }
2201
2202 .close, .close:focus, .close:hover, .php-file-tree a, a {
2203 text-decoration: none
2204 }
2205
2206 body, code, div, em, form, html, img, label, li, ol, p, pre, small, span, strong, table, td, th, tr, ul {
2207 margin: 0;
2208 padding: 0;
2209 vertical-align: baseline;
2210 outline: 0;
2211 /*font-size: 100%;*/
2212 background: 0 0;
2213 border: none;
2214 text-decoration: none
2215 }
2216
2217 p, table, ul {
2218 margin-bottom: 10px
2219 }
2220
2221 html {
2222 overflow-y: scroll
2223 }
2224
2225 body {
2226 padding: 0;
2227 /*font: 13px/16px Tahoma, Arial, sans-serif;*/
2228 color: #222;
2229 background: #F7F7F7;
2230 /*margin: 50px 30px 0*/
2231 }
2232
2233 button, input, select, textarea {
2234 font-size: inherit;
2235 font-family: inherit
2236 }
2237
2238 /*da {*/
2239 /*color: #296ea3*/
2240 /*}*/
2241
2242 /*da:hover {*/
2243 /*color: #b00*/
2244 /*}*/
2245
2246 img {
2247 vertical-align: middle
2248 }
2249
2250 span {
2251 color: #777
2252 }
2253
2254 small {
2255 font-size: 11px;
2256 color: #999
2257 }
2258
2259 ul {
2260 list-style-type: none;
2261 margin-left: 0
2262 }
2263
2264 ul li {
2265 padding: 3px 0
2266 }
2267
2268 table {
2269 border-collapse: collapse;
2270 border-spacing: 0;
2271 width: 100%
2272 }
2273
2274 .file-tree-view + #main-table {
2275 width: 75% !important;
2276 float: left
2277 }
2278
2279 td, th {
2280 padding: 4px 7px;
2281 text-align: left;
2282 vertical-align: top;
2283 border: 1px solid #ddd;
2284 background: #fff
2285 }
2286
2287 td.gray, th {
2288 background-color: #eee
2289 }
2290
2291 td.gray span {
2292 color: #222
2293 }
2294
2295 tr:hover td {
2296 background-color: #f5f5f5
2297 }
2298
2299 tr:hover td.gray {
2300 background-color: #eee
2301 }
2302
2303 .table {
2304 width: 100%;
2305 max-width: 100%;
2306 margin-bottom: 1rem
2307 }
2308
2309 .table td, .table th {
2310 padding: .55rem;
2311 vertical-align: top;
2312 border-top: 1px solid #ddd
2313 }
2314
2315 .table thead th {
2316 vertical-align: bottom;
2317 border-bottom: 2px solid #eceeef
2318 }
2319
2320 .table tbody + tbody {
2321 border-top: 2px solid #eceeef
2322 }
2323
2324 .table .table {
2325 background-color: #fff
2326 }
2327
2328 code, pre {
2329 display: block;
2330 margin-bottom: 10px;
2331 font: 13px/16px Consolas, 'Courier New', Courier, monospace;
2332 border: 1px dashed #ccc;
2333 padding: 5px;
2334 overflow: auto
2335 }
2336
2337 .hidden, .modal {
2338 display: none
2339 }
2340
2341 .btn, .close {
2342 font-weight: 700
2343 }
2344
2345 pre.with-hljs {
2346 padding: 0
2347 }
2348
2349 pre.with-hljs code {
2350 margin: 0;
2351 border: 0;
2352 overflow: visible
2353 }
2354
2355 code.maxheight, pre.maxheight {
2356 max-height: 512px
2357 }
2358
2359 input[type=checkbox] {
2360 margin: 0;
2361 padding: 0
2362 }
2363
2364 .message, .path {
2365 padding: 4px 7px;
2366 border: 1px solid #ddd;
2367 background-color: #fff
2368 }
2369
2370 .fa.fa-caret-right {
2371 font-size: 1.2em;
2372 margin: 0 4px;
2373 vertical-align: middle;
2374 color: #ececec
2375 }
2376
2377 .fa.fa-home {
2378 font-size: 1.2em;
2379 vertical-align: bottom
2380 }
2381
2382 #wrappder {
2383 min-width: 400px;
2384 margin: 0 auto
2385 }
2386
2387 .path {
2388 margin-bottom: 10px
2389 }
2390
2391 .right {
2392 text-align: right
2393 }
2394
2395 .center, .close, .login-form {
2396 text-align: center
2397 }
2398
2399 .float-right {
2400 float: right
2401 }
2402
2403 .float-left {
2404 float: left
2405 }
2406
2407 .message.ok {
2408 border-color: green;
2409 color: green
2410 }
2411
2412 .message.error {
2413 border-color: red;
2414 color: red
2415 }
2416
2417 .message.alert {
2418 border-color: orange;
2419 color: orange
2420 }
2421
2422 .btn2{
2423 color: #296ea3 !important;
2424 border-color: #296ea3 !important;
2425 }
2426
2427 .btn2:hover{
2428 background-color: #296ea3 !important;
2429 color: white !important;
2430 }
2431
2432
2433
2434 /*.btn:hover {*/
2435 /*color: #b00*/
2436 /*}*/
2437
2438 .preview-img {
2439 max-width: 100%;
2440 background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAKklEQVR42mL5//8/Azbw+PFjrOJMDCSCUQ3EABZc4S0rKzsaSvTTABBgAMyfCMsY4B9iAAAAAElFTkSuQmCC)
2441 }
2442
2443 .inline-actions > a > i {
2444 font-size: 1em;
2445 margin-left: 5px;
2446 background: #3785c1;
2447 color: #fff;
2448 padding: 3px;
2449 border-radius: 3px
2450 }
2451
2452 .preview-video {
2453 position: relative;
2454 max-width: 100%;
2455 height: 0;
2456 padding-bottom: 62.5%;
2457 margin-bottom: 10px
2458 }
2459
2460 .preview-video video {
2461 position: absolute;
2462 width: 100%;
2463 height: 100%;
2464 left: 0;
2465 top: 0;
2466 background: #000
2467 }
2468
2469 .compact-table {
2470 border: 0;
2471 width: auto
2472 }
2473
2474 .compact-table td, .compact-table th {
2475 width: 100px;
2476 border: 0;
2477 text-align: center
2478 }
2479
2480 .compact-table tr:hover td {
2481 background-color: #fff
2482 }
2483
2484 .filename {
2485 max-width: 420px;
2486 overflow: hidden;
2487 text-overflow: ellipsis
2488 }
2489
2490 .break-word {
2491 word-wrap: break-word;
2492 /*margin-left: 30px*/
2493 }
2494
2495 .break-word.float-left a {
2496 color: #7d7d7d
2497 }
2498
2499 .break-word + .float-right {
2500 padding-right: 30px;
2501 position: relative
2502 }
2503
2504 .break-word + .float-right > a {
2505 color: #7d7d7d;
2506 font-size: 1.2em;
2507 margin-right: 4px
2508 }
2509
2510 /*.modal {*/
2511 /*position: fixed;*/
2512 /*z-index: 1;*/
2513 /*padding-top: 100px;*/
2514 /*left: 0;*/
2515 /*top: 0;*/
2516 /*width: 100%;*/
2517 /*height: 100%;*/
2518 /*overflow: auto;*/
2519 /*background-color: #000;*/
2520 /*background-color: rgba(0, 0, 0, .4)*/
2521 /*}*/
2522
2523 #editor, .edit-file-actions {
2524 position: absolute;
2525 right: 30px
2526 }
2527
2528 /*.modal-content {*/
2529 /*background-color: #fefefe;*/
2530 /*margin: auto;*/
2531 /*padding: 20px;*/
2532 /*border: 1px solid #888;*/
2533 /*width: 80%*/
2534 /*}*/
2535
2536 .close:focus, .close:hover {
2537 color: #000;
2538 cursor: pointer
2539 }
2540
2541 #editor {
2542 top: 230px;
2543 bottom: 5px;
2544 left: 10px;
2545 right: 10px;
2546 }
2547
2548 .edit-file-actions {
2549 top: 0;
2550 background: #fff;
2551 margin-top: 5px
2552 }
2553
2554 .edit-file-actions > a, .edit-file-actions > button {
2555 background: #fff;
2556 padding: 5px 15px;
2557 cursor: pointer;
2558 color: #296ea3;
2559 border: 1px solid #296ea3
2560 }
2561
2562 .group-btn {
2563 background: #fff;
2564 padding: 2px 6px;
2565 border: 1px solid;
2566 cursor: pointer;
2567 color: #296ea3
2568 }
2569
2570 .main-nav {
2571 position: fixed;
2572 top: 0;
2573 left: 0;
2574 padding: 10px 30px 10px 1px;
2575 width: 100%;
2576 background: #fff;
2577 color: #000;
2578 border: 0;
2579 box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2)
2580 }
2581
2582 .login-form {
2583 width: 320px;
2584 margin: 0 auto;
2585 box-shadow: 0 8px 10px 1px rgba(0, 0, 0, .14), 0 3px 14px 2px rgba(0, 0, 0, .12), 0 5px 5px -3px rgba(0, 0, 0, .2)
2586 }
2587
2588 .login-form label, .path.login-form input {
2589 padding: 8px;
2590 margin: 10px
2591 }
2592
2593 .footer-links {
2594 background: 0 0;
2595 border: 0;
2596 clear: both
2597 }
2598
2599 select[name=lang] {
2600 border: none;
2601 position: relative;
2602 text-transform: uppercase;
2603 left: -30%;
2604 top: 12px;
2605 color: silver
2606 }
2607
2608 input[type=search] {
2609 height: 30px;
2610 margin: 5px;
2611 width: 80%;
2612 border: 1px solid #ccc
2613 }
2614
2615 .path.login-form input[type=submit] {
2616 background-color: #4285f4;
2617 color: #fff;
2618 border: 1px solid;
2619 border-radius: 2px;
2620 font-weight: 700;
2621 cursor: pointer
2622 }
2623
2624 .modalDialog {
2625 position: fixed;
2626 font-family: Arial, Helvetica, sans-serif;
2627 top: 0;
2628 right: 0;
2629 bottom: 0;
2630 left: 0;
2631 background: rgba(0, 0, 0, .8);
2632 z-index: 99999;
2633 opacity: 0;
2634 -webkit-transition: opacity .4s ease-in;
2635 -moz-transition: opacity .4s ease-in;
2636 transition: opacity .4s ease-in;
2637 pointer-events: none
2638 }
2639
2640 .modalDialog:target {
2641 opacity: 1;
2642 pointer-events: auto
2643 }
2644
2645 .modalDialog > .model-wrapper {
2646 max-width: 600px;
2647 position: relative;
2648 margin: 10% auto;
2649 padding: 15px;
2650 border-radius: 2px;
2651 background: #fff
2652 }
2653
2654 .close {
2655 float: right;
2656 background: #fff;
2657 color: #000;
2658 line-height: 25px;
2659 position: absolute;
2660 right: 0;
2661 top: 0;
2662 width: 24px;
2663 border-radius: 0 5px 0 0;
2664 font-size: 18px
2665 }
2666
2667 .close:hover {
2668 background: #e4e4e4
2669 }
2670
2671 .modalDialog p {
2672 line-height: 30px
2673 }
2674
2675 div#searchresultWrapper {
2676 max-height: 320px;
2677 overflow: auto
2678 }
2679
2680 div#searchresultWrapper li {
2681 margin: 8px 0;
2682 list-style: none
2683 }
2684
2685 li.file:before, li.folder:before {
2686 font: normal normal normal 14px/1 FontAwesome;
2687 content: "\f016";
2688 margin-right: 5px
2689 }
2690
2691 li.folder:before {
2692 content: "\f114"
2693 }
2694
2695 i.fa.fa-folder-o {
2696 color: #eeaf4b
2697 }
2698
2699 i.fa.fa-picture-o {
2700 color: #26b99a
2701 }
2702
2703 i.fa.fa-file-archive-o {
2704 color: #da7d7d
2705 }
2706
2707 .footer-links i.fa.fa-file-archive-o {
2708 color: #296ea3
2709 }
2710
2711 i.fa.fa-css3 {
2712 color: #f36fa0
2713 }
2714
2715 i.fa.fa-file-code-o {
2716 color: #ec6630
2717 }
2718
2719 i.fa.fa-code {
2720 color: #cc4b4c
2721 }
2722
2723 i.fa.fa-file-text-o {
2724 color: #0096e6
2725 }
2726
2727 i.fa.fa-html5 {
2728 color: #d75e72
2729 }
2730
2731 i.fa.fa-file-excel-o {
2732 color: #09c55d
2733 }
2734
2735 i.fa.fa-file-powerpoint-o {
2736 color: #f6712e
2737 }
2738
2739 .file-tree-view {
2740 width: 24%;
2741 float: left;
2742 overflow: auto;
2743 border: 1px solid #ddd;
2744 border-right: 0;
2745 background: #fff
2746 }
2747
2748 .file-tree-view .tree-title {
2749 background: #eee;
2750 padding: 9px 2px 9px 10px;
2751 font-weight: 700
2752 }
2753
2754 .file-tree-view ul {
2755 margin-left: 15px;
2756 margin-bottom: 0
2757 }
2758
2759 .file-tree-view i {
2760 padding-right: 3px
2761 }
2762
2763 .php-file-tree {
2764 font-size: 100%;
2765 letter-spacing: 1px;
2766 line-height: 1.5;
2767 margin-left: 5px !important
2768 }
2769
2770 .php-file-tree a {
2771 color: #296ea3
2772 }
2773
2774 .php-file-tree A:hover {
2775 color: #b00
2776 }
2777
2778 .php-file-tree .open {
2779 font-style: italic;
2780 color: #2183ce
2781 }
2782
2783 .php-file-tree .closed {
2784 font-style: normal
2785 }
2786
2787 #file-tree-view::-webkit-scrollbar {
2788 width: 10px;
2789 background-color: #F5F5F5
2790 }
2791
2792 #file-tree-view::-webkit-scrollbar-track {
2793 border-radius: 10px;
2794 background: rgba(0, 0, 0, .1);
2795 border: 1px solid #ccc
2796 }
2797
2798 #file-tree-view::-webkit-scrollbar-thumb {
2799 border-radius: 10px;
2800 background: linear-gradient(left, #fff, #e4e4e4);
2801 border: 1px solid #aaa
2802 }
2803
2804 #file-tree-view::-webkit-scrollbar-thumb:hover {
2805 background: #fff
2806 }
2807
2808 #file-tree-view::-webkit-scrollbar-thumb:active {
2809 background: linear-gradient(left, #22ADD4, #1E98BA)
2810 }
2811 </style>
2812</head>
2813<body style="background: white">
2814<nav class="navbar p-0 pl-2 navbar-light bg-light" style="background: linear-gradient(to left, #99ccff 0%, #ccffcc 100%);">
2815 <a class="navbar-brand" href="#"><img src="blank.png"></a>
2816</nav>
2817<div id="wrapper">
2818
2819
2820 <div class="modal" tabindex="-1" role="dialog" id="createNewItem">
2821 <div class="modal-dialog" role="document">
2822 <div class="modal-content">
2823 <div class="modal-header">
2824 <h5 class="modal-title"><i class="fa fa-plus-square fa-fw"></i> Create New Item</h5>
2825 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
2826 <span aria-hidden="true">×</span>
2827 </button>
2828 </div>
2829 <div class="modal-body">
2830 <p>
2831 <label for="newfile">Item Type : </label>
2832 <div class="custom-control custom-radio custom-control-inline">
2833 <input type="radio" id="customRadioInline1" name="newfile" value="file" class="custom-control-input">
2834 <label class="custom-control-label" for="customRadioInline1">File</label>
2835 </div>
2836 <div class="custom-control custom-radio custom-control-inline">
2837 <input type="radio" id="customRadioInline2" name="newfile" value="folder" class="custom-control-input" checked>
2838 <label class="custom-control-label" for="customRadioInline2">Folder</label>
2839 </div><br><br>
2840
2841 <label for="newfilename">Item Name : </label>
2842 <input type="text" class="form-control" name="newfilename" id="newfilename" value="" placeholder="Enter Name">
2843
2844 </p>
2845 </div>
2846
2847 <div class="modal-footer">
2848 <button type="submit" name="submit" value="Create Now" onclick="newfolder('<?php echo fm_enc(FM_PATH) ?>');return false;" class="btn btn-success"><i class="fa fa-plus-square fa-fw"></i> Create Now</button>
2849 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
2850 </div>
2851 </div>
2852 </div>
2853 </div>
2854
2855<!-- <div id="searchResult" class="modalDialog">-->
2856<!-- <div class="model-wrapper"><a href="#close" title="Close" class="close">X</a>-->
2857<!-- <input type="search" name="search" value="" placeholder="Find a item in current folder...">-->
2858<!-- <h2>Search Results</h2>-->
2859<!-- <div id="searchresultWrapper"></div>-->
2860<!-- </div>-->
2861<!-- </div>-->
2862
2863 <div class="modal" tabindex="-1" role="dialog" id="searchResult">
2864 <div class="modal-dialog" role="document">
2865 <div class="modal-content">
2866 <div class="modal-header">
2867 <h5 class="modal-title"><i class="fa fa-search fa-fw"></i> Search Files and Folders</h5>
2868 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
2869 <span aria-hidden="true">×</span>
2870 </button>
2871 </div>
2872 <div class="modal-body">
2873 <div class="model-wrappe">
2874 <input type="search" name="search" value="" class="w-100 form-control" placeholder="Find a item in current folder...">
2875 <div id="searchresultWrapper" class="mt-2 p-2"></div>
2876 </div>
2877 </div>
2878
2879 <div class="modal-footer">
2880 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
2881 </div>
2882 </div>
2883 </div>
2884 </div>
2885
2886 <?php
2887 }
2888
2889 /**
2890 * Show page footer
2891 */
2892 function fm_show_footer()
2893 {
2894 ?>
2895</div>
2896<script>
2897 function newfolder(e) {
2898 var t = document.getElementById("newfilename").value,
2899 n = document.querySelector('input[name="newfile"]:checked').value;
2900 null !== t && "" !== t && n && (window.location.hash = "#", window.location.search = "p=" + encodeURIComponent(e) + "&new=" + encodeURIComponent(t) + "&type=" + encodeURIComponent(n))
2901 }
2902
2903 function rename(e, t) {
2904 var n = prompt("New name", t);
2905 null !== n && "" !== n && n != t && (window.location.search = "p=" + encodeURIComponent(e) + "&ren=" + encodeURIComponent(t) + "&to=" + encodeURIComponent(n))
2906 }
2907
2908 function change_checkboxes(e, t) {
2909 for (var n = e.length - 1; n >= 0; n--) e[n].checked = "boolean" == typeof t ? t : !e[n].checked
2910 }
2911
2912 function get_checkboxes() {
2913 for (var e = document.getElementsByName("file[]"), t = [], n = e.length - 1; n >= 0; n--) (e[n].type = "checkbox") && t.push(e[n]);
2914 return t
2915 }
2916
2917 function select_all() {
2918 change_checkboxes(get_checkboxes(), !0)
2919 }
2920
2921 function unselect_all() {
2922 change_checkboxes(get_checkboxes(), !1)
2923 }
2924
2925 function invert_all() {
2926 change_checkboxes(get_checkboxes())
2927 }
2928
2929 function mailto(e, t) {
2930 var n = new XMLHttpRequest, a = "path=" + e + "&file=" + t + "&type=mail&ajax=true";
2931 n.open("POST", "", !0), n.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), n.onreadystatechange = function () {
2932 4 == n.readyState && 200 == n.status && alert(n.responseText)
2933 }, n.send(a)
2934 }
2935
2936 function showSearch(e) {
2937 var t = new XMLHttpRequest, n = "path=" + e + "&type=search&ajax=true";
2938 t.open("POST", "", !0), t.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), t.onreadystatechange = function () {
2939 4 == t.readyState && 200 == t.status && (window.searchObj = t.responseText, document.getElementById("searchresultWrapper").innerHTML = "", window.location.hash = "#searchResult",$('#searchResult').modal('show'))
2940 }, t.send(n)
2941 }
2942
2943 function getSearchResult(e, t) {
2944 var n = [], a = [];
2945 return e.forEach(function (e) {
2946 "folder" === e.type ? (getSearchResult(e.items, t), e.name.toLowerCase().match(t) && n.push(e)) : "file" === e.type && e.name.toLowerCase().match(t) && a.push(e)
2947 }), {folders: n, files: a}
2948 }
2949
2950 function checkbox_toggle() {
2951 var e = get_checkboxes();
2952 e.push(this), change_checkboxes(e)
2953 }
2954
2955 function backup(e, t) {
2956 var n = new XMLHttpRequest, a = "path=" + e + "&file=" + t + "&type=backup&ajax=true";
2957 return n.open("POST", "", !0), n.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), n.onreadystatechange = function () {
2958 4 == n.readyState && 200 == n.status && alert(n.responseText)
2959 }, n.send(a), !1
2960 }
2961
2962 function edit_save(e, t) {
2963 var n = "ace" == t ? editor.getSession().getValue() : document.getElementById("normal-editor").value;
2964 if (n) {
2965 var a = document.createElement("form");
2966 a.setAttribute("method", "POST"), a.setAttribute("action", "");
2967 var o = document.createElement("textarea");
2968 o.setAttribute("type", "textarea"), o.setAttribute("name", "savedata");
2969 var c = document.createTextNode(n);
2970 o.appendChild(c), a.appendChild(o), document.body.appendChild(a), a.submit()
2971 }
2972 }
2973
2974 function init_php_file_tree() {
2975 if (document.getElementsByTagName) {
2976 for (var e = document.getElementsByTagName("LI"), t = 0; t < e.length; t++) {
2977 var n = e[t].className;
2978 if (n.indexOf("pft-directory") > -1) for (var a = e[t].childNodes, o = 0; o < a.length; o++) "A" == a[o].tagName && (a[o].onclick = function () {
2979 for (var e = this.nextSibling; ;) {
2980 if (null == e) return !1;
2981 if ("UL" == e.tagName) {
2982 var t = "none" == e.style.display;
2983 return e.style.display = t ? "block" : "none", this.className = t ? "open" : "closed", !1
2984 }
2985 e = e.nextSibling
2986 }
2987 return !1
2988 }, a[o].className = n.indexOf("open") > -1 ? "open" : "closed"), "UL" == a[o].tagName && (a[o].style.display = n.indexOf("open") > -1 ? "block" : "none")
2989 }
2990 return !1
2991 }
2992 }
2993
2994 var searchEl = document.querySelector("input[type=search]"), timeout = null;
2995 searchEl.onkeyup = function (e) {
2996 clearTimeout(timeout);
2997 var t = JSON.parse(window.searchObj), n = document.querySelector("input[type=search]").value;
2998 timeout = setTimeout(function () {
2999 if (n.length >= 2) {
3000 var e = getSearchResult(t, n), a = "", o = "";
3001 e.folders.forEach(function (e) {
3002 a += '<li class="' + e.type + '"><a href="?p=' + e.path + '">' + e.name + "</a></li>"
3003 }), e.files.forEach(function (e) {
3004 o += '<li class="' + e.type + '"><a href="?p=' + e.path + "&view=" + e.name + '">' + e.name + "</a></li>"
3005 }), document.getElementById("searchresultWrapper").innerHTML = '<div class="model-wrapper">'+a+o+"</div>"
3006 }
3007 }, 500)
3008 }, window.onload = init_php_file_tree;
3009 if (document.getElementById("file-tree-view")) {
3010 var tableViewHt = document.getElementById("main-table").offsetHeight - 2;
3011 document.getElementById("file-tree-view").setAttribute("style", "height:" + tableViewHt + "px")
3012 }
3013 ;
3014
3015 if ("serviceWorker" in navigator) {
3016 navigator.serviceWorker.register("/serviceworker.js").then(function(registration){
3017 console.log("Service Worker registered with scope:", registration);
3018 }).catch(function(err) {
3019 console.log("Service worker registration failed:", err);
3020 });
3021 }
3022</script>
3023<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
3024<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
3025<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
3026<?php if (isset($_GET['view']) && FM_USE_HIGHLIGHTJS): ?>
3027 <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
3028 <script>hljs.initHighlightingOnLoad();</script>
3029<?php endif; ?>
3030<?php if (isset($_GET['edit']) && isset($_GET['env']) && FM_EDIT_FILE): ?>
3031 <script src="//cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js"></script>
3032 <script>var editor = ace.edit("editor");editor.getSession().setMode("ace/mode/javascript");</script>
3033<?php endif; ?>
3034</body>
3035</html>
3036<?php
3037}
3038
3039/**
3040 * Show image
3041 * @param string $img
3042 */
3043function fm_show_image($img)
3044{
3045 $modified_time = gmdate('D, d M Y 00:00:00') . ' GMT';
3046 $expires_time = gmdate('D, d M Y 00:00:00', strtotime('+1 day')) . ' GMT';
3047
3048 $img = trim($img);
3049 $images = fm_get_images();
3050 $image = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAEElEQVR42mL4//8/A0CAAQAI/AL+26JNFgAAAABJRU5ErkJggg==';
3051 if (isset($images[$img])) {
3052 $image = $images[$img];
3053 }
3054 $image = base64_decode($image);
3055 if (function_exists('mb_strlen')) {
3056 $size = mb_strlen($image, '8bit');
3057 } else {
3058 $size = strlen($image);
3059 }
3060
3061 if (function_exists('header_remove')) {
3062 header_remove('Cache-Control');
3063 header_remove('Pragma');
3064 } else {
3065 header('Cache-Control:');
3066 header('Pragma:');
3067 }
3068
3069 header('Last-Modified: ' . $modified_time, true, 200);
3070 header('Expires: ' . $expires_time);
3071 header('Content-Length: ' . $size);
3072 header('Content-Type: image/png');
3073 echo $image;
3074
3075 exit;
3076}
3077
3078/**
3079 * Get base64-encoded images
3080 * @return array
3081 */
3082function fm_get_images()
3083{
3084 return array(
3085 'favicon' => 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ
3086bWFnZVJlYWR5ccllPAAAAZVJREFUeNqkk79Lw0AUx1+uidTQim4Waxfpnl1BcHMR6uLkIF0cpYOI
3087f4KbOFcRwbGTc0HQSVQQXCqlFIXgFkhIyvWS870LaaPYH9CDy8vdfb+fey930aSUMEvT6VHVzw8x
3088rKUX3N3Hj/8M+cZ6GcOtBPl6KY5iAA7KJzfVWrfbhUKhALZtQ6myDf1+X5nsuzjLUmUOnpa+v5r1
3089Z4ZDDfsLiwER45xDEATgOI6KntfDd091GidzC8vZ4vH1QQ09+4MSMAMWRREKPMhmsyr6voYmrnb2
3090PKEizdEabUaeFCDKCCHAdV0wTVNFznMgpVqGlZ2cipzHGtKSZwCIZJgJwxB38KHT6Sjx21V75Jcn
3091LXmGAKTRpGVZUx2dAqQzSEqw9kqwuGqONTufPrw37D8lQFxCvjgPXIixANLEGfwuQacMOC4kZz+q
3092GdhJS550BjpRCdCbAJCMJRkMASEIg+4Bxz4JwAwDSEueAYDLIM+QrOk6GHiRxjXSkJY8KUCvdXZ6
3093kbuvNx+mOcbN9taGBlpLAWf9nX8EGADoCfqkKWV/cgAAAABJRU5ErkJggg==',
3094 'sprites' => 'iVBORw0KGgoAAAANSUhEUgAAAYAAAAAgCAMAAAAscl/XAAAC/VBMVEUAAABUfn4KKipIcXFSeXsx
3095VlZSUlNAZ2c4Xl4lSUkRDg7w8O/d3d3LhwAWFhYXODgMLCx8fHw9PT2TtdOOAACMXgE8lt+dmpq+
3096fgABS3RUpN+VUycuh9IgeMJUe4C5dUI6meKkAQEKCgoMWp5qtusJmxSUPgKudAAXCghQMieMAgIU
3097abNSUlJLe70VAQEsh85oaGjBEhIBOGxfAoyUbUQAkw8gui4LBgbOiFPHx8cZX6PMS1OqFha/MjIK
3098VKFGBABSAXovGAkrg86xAgIoS5Y7c6Nf7W1Hz1NmAQB3Hgx8fHyiTAAwp+eTz/JdDAJ0JwAAlxCQ
3099UAAvmeRiYp6ysrmIAABJr/ErmiKmcsATpRyfEBAOdQgOXahyAAAecr1JCwHMiABgfK92doQGBgZG
3100AGkqKiw0ldYuTHCYsF86gB05UlJmQSlra2tVWED////8/f3t9fX5/Pzi8/Px9vb2+/v0+fnn8vLf
31017OzZ6enV5+eTpKTo6Oj6/v765Z/U5eX4+Pjx+Pjv0ojWBASxw8O8vL52dnfR19CvAADR3PHr6+vi
31024uPDx8v/866nZDO7iNT335jtzIL+7aj86aTIztXDw8X13JOlpKJoaHDJAACltratrq3lAgKfAADb
31034vb76N2au9by2I9gYGVIRkhNTE90wfXq2sh8gL8QMZ3pyn27AADr+uu1traNiIh2olTTshifodQ4
3104ZM663PH97+YeRq2GqmRjmkGjnEDnfjLVVg6W4f7s6/p/0fr98+5UVF6wz+SjxNsmVb5RUVWMrc7d
3105zrrIpWI8PD3pkwhCltZFYbNZja82wPv05NPRdXzhvna4uFdIiibPegGQXankxyxe0P7PnOhTkDGA
3106gBrbhgR9fX9bW1u8nRFamcgvVrACJIvlXV06nvtdgON4mdn3og7AagBTufkucO7snJz4b28XEhIT
3107sflynsLEvIk55kr866aewo2YuYDrnFffOTk6Li6hgAn3y8XkusCHZQbt0NP571lqRDZyMw96lZXE
3108s6qcrMmJaTmVdRW2AAAAbnRSTlMAZodsJHZocHN7hP77gnaCZWdx/ki+RfqOd/7+zc9N/szMZlf8
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
3178RK5CYII=',
3179 );
3180}
3181?>