ok - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of ok.php

  1. <?php
  2. //Default Configuration
  3. $CONFIG = '{"lang":"en","error_reporting":false,"show_hidden":false,"hide_Cols":false,"calc_folder":false,"theme":"light"}';
  4.  
  5.  
  6. /**
  7.  * H3K | droped V2.4.8
  8.  * CCP Programmers | [email protected]
  9.  * https://tinyfilemanager.github.io
  10.  */
  11.  
  12. //TFM version
  13. define('VERSION', '2.4.8');
  14.  
  15. //Application Title
  16. define('APP_TITLE', 'droped');
  17.  
  18. // --- EDIT BELOW CONFIGURATION CAREFULLY ---
  19.  
  20. // Auth with login/password
  21. // set true/false to enable/disable it
  22. // Is independent from IP white- and blacklisting
  23. $use_auth = true;
  24.  
  25. // Login user name and password
  26. // Users: array('Username' => 'Password', 'Username2' => 'Password2', ...)
  27. // Generate secure password hash - https://tinyfilemanager.github.io/docs/pwd.html
  28. $auth_users = array(
  29.     'admin' => '$2y$10$/K.hjNr84lLNDt8fTXjoI.DBp6PpeyoJ.mGwrrLuCZfAwfSAGqhOW', //admin@123
  30.     'user' => '$2y$10$Fg6Dz8oH9fPoZ2jJan5tZuv6Z4Kp7avtQ9bDfrdRntXtPeiMAZyGO' //12345
  31. );
  32.  
  33. // Readonly users
  34. // e.g. array('users', 'guest', ...)
  35. $readonly_users = array(
  36.     'user'
  37. );
  38.  
  39. // Global readonly, including when auth is not being used
  40. $global_readonly = false;
  41.  
  42. // user specific directories
  43. // array('Username' => 'Directory path', 'Username2' => 'Directory path', ...)
  44. $directories_users = array();
  45.  
  46. // Enable highlight.js (https://highlightjs.org/) on view's page
  47. $use_highlightjs = true;
  48.  
  49. // highlight.js style
  50. // for dark theme use 'ir-black'
  51. $highlightjs_style = 'vs';
  52.  
  53. // Enable ace.js (https://ace.c9.io/) on view's page
  54. $edit_files = true;
  55.  
  56. // Default timezone for date() and time()
  57. // Doc - http://php.net/manual/en/timezones.php
  58. $default_timezone = 'Etc/UTC'; // UTC
  59.  
  60. // Root path for file manager
  61. // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
  62. $root_path = $_SERVER['DOCUMENT_ROOT'];
  63.  
  64. // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
  65. // Will not working if $root_path will be outside of server document root
  66. $root_url = '';
  67.  
  68. // Server hostname. Can set manually if wrong
  69. $http_host = $_SERVER['HTTP_HOST'];
  70.  
  71. // user specific directories
  72. // array('Username' => 'Directory path', 'Username2' => 'Directory path', ...)
  73. $directories_users = array();
  74.  
  75. // input encoding for iconv
  76. $iconv_input_encoding = 'UTF-8';
  77.  
  78. // date() format for file modification date
  79. // Doc - https://www.php.net/manual/en/function.date.php
  80. $datetime_format = 'd.m.y H:i';
  81.  
  82. // Allowed file extensions for create and rename files
  83. // e.g. 'txt,html,css,js'
  84. $allowed_file_extensions = '';
  85.  
  86. // Allowed file extensions for upload files
  87. // e.g. 'gif,png,jpg,html,txt'
  88. $allowed_upload_extensions = '';
  89.  
  90. // Favicon path. This can be either a full url to an .PNG image, or a path based on the document root.
  91. // full path, e.g http://example.com/favicon.png
  92. // local path, e.g images/icons/favicon.png
  93. $favicon_path = '';
  94.  
  95. // Files and folders to excluded from listing
  96. // e.g. array('myfile.html', 'personal-folder', '*.php', ...)
  97. $exclude_items = array();
  98.  
  99. // Online office Docs Viewer
  100. // Availabe rules are 'google', 'microsoft' or false
  101. // google => View documents using Google Docs Viewer
  102. // microsoft => View documents using Microsoft Web Apps Viewer
  103. // false => disable online doc viewer
  104. $online_viewer = 'google';
  105.  
  106. // Sticky Nav bar
  107. // true => enable sticky header
  108. // false => disable sticky header
  109. $sticky_navbar = true;
  110.  
  111. // Maximum file upload size
  112. // Increase the following values in php.ini to work properly
  113. // memory_limit, upload_max_filesize, post_max_size
  114. $max_upload_size_bytes = 5000;
  115.  
  116. // Possible rules are 'OFF', 'AND' or 'OR'
  117. // OFF => Don't check connection IP, defaults to OFF
  118. // AND => Connection must be on the whitelist, and not on the blacklist
  119. // OR => Connection must be on the whitelist, or not on the blacklist
  120. $ip_ruleset = 'OFF';
  121.  
  122. // Should users be notified of their block?
  123. $ip_silent = true;
  124.  
  125. // IP-addresses, both ipv4 and ipv6
  126. $ip_whitelist = array(
  127.     '127.0.0.1',    // local ipv4
  128.     '::1'           // local ipv6
  129. );
  130.  
  131. // IP-addresses, both ipv4 and ipv6
  132. $ip_blacklist = array(
  133.     '0.0.0.0',      // non-routable meta ipv4
  134.     '::'            // non-routable meta ipv6
  135. );
  136.  
  137. // if User has the customized config file, try to use it to override the default config above
  138. $config_file = __DIR__.'/config.php';
  139. if (is_readable($config_file)) {
  140.     @include($config_file);
  141. }
  142.  
  143. // --- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL ---
  144.  
  145. // max upload file size
  146. define('MAX_UPLOAD_SIZE', $max_upload_size_bytes);
  147.  
  148. // private key and session name to store to the session
  149. if ( !defined( 'FM_SESSION_ID')) {
  150.     define('FM_SESSION_ID', 'filemanager');
  151. }
  152.  
  153. // Configuration
  154. $cfg = new FM_Config();
  155.  
  156. // Default language
  157. $lang = isset($cfg->data['lang']) ? $cfg->data['lang'] : 'en';
  158.  
  159. // Show or hide files and folders that starts with a dot
  160. $show_hidden_files = isset($cfg->data['show_hidden']) ? $cfg->data['show_hidden'] : true;
  161.  
  162. // PHP error reporting - false = Turns off Errors, true = Turns on Errors
  163. $report_errors = isset($cfg->data['error_reporting']) ? $cfg->data['error_reporting'] : true;
  164.  
  165. // Hide Permissions and Owner cols in file-listing
  166. $hide_Cols = isset($cfg->data['hide_Cols']) ? $cfg->data['hide_Cols'] : true;
  167.  
  168. // Show directory size: true or speedup output: false
  169. $calc_folder = isset($cfg->data['calc_folder']) ? $cfg->data['calc_folder'] : true;
  170.  
  171. // Theme
  172. $theme = isset($cfg->data['theme']) ? $cfg->data['theme'] : 'light';
  173.  
  174. define('FM_THEME', $theme);
  175.  
  176. //available languages
  177. $lang_list = array(
  178.     'en' => 'English'
  179. );
  180.  
  181. if ($report_errors == true) {
  182.     @ini_set('error_reporting', E_ALL);
  183.     @ini_set('display_errors', 1);
  184. } else {
  185.     @ini_set('error_reporting', E_ALL);
  186.     @ini_set('display_errors', 0);
  187. }
  188.  
  189. // if fm included
  190. if (defined('FM_EMBED')) {
  191.     $use_auth = false;
  192.     $sticky_navbar = false;
  193. } else {
  194.     
  195.  
  196.     date_default_timezone_set($default_timezone);
  197.  
  198.     ini_set('default_charset', 'UTF-8');
  199.     if (version_compare(PHP_VERSION, '5.6.0', '<') && function_exists('mb_internal_encoding')) {
  200.         mb_internal_encoding('UTF-8');
  201.     }
  202.     if (function_exists('mb_regex_encoding')) {
  203.         mb_regex_encoding('UTF-8');
  204.     }
  205.  
  206.     session_cache_limiter('');
  207.     session_name(FM_SESSION_ID );
  208.     function session_error_handling_function($code, $msg, $file, $line) {
  209.         // Permission denied for default session, try to create a new one
  210.         if ($code == 2) {
  211.             session_abort();
  212.             session_id(session_create_id());
  213.             @session_start();
  214.         }
  215.     }
  216.     set_error_handler('session_error_handling_function');
  217.     session_start();
  218.     restore_error_handler();
  219. }
  220.  
  221. if (empty($auth_users)) {
  222.     $use_auth = false;
  223. }
  224.  
  225. $is_https = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1)
  226.     || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https';
  227.  
  228. // update $root_url based on user specific directories
  229. if (isset($_SESSION[FM_SESSION_ID]['logged']) && !empty($directories_users[$_SESSION[FM_SESSION_ID]['logged']])) {
  230.     $wd = fm_clean_path(dirname($_SERVER['PHP_SELF']));
  231.     $root_url =  $root_url.$wd.DIRECTORY_SEPARATOR.$directories_users[$_SESSION[FM_SESSION_ID]['logged']];
  232. }
  233. // clean $root_url
  234. $root_url = fm_clean_path($root_url);
  235.  
  236. // abs path for site
  237. defined('FM_ROOT_URL') || define('FM_ROOT_URL', ($is_https 'https' : 'http') . '://' . $http_host . (!empty($root_url) ? '/' . $root_url : ''));
  238. defined('FM_SELF_URL') || define('FM_SELF_URL', ($is_https 'https' : 'http') . '://' . $http_host . $_SERVER['PHP_SELF']);
  239.  
  240. // logout
  241. if (isset($_GET['logout'])) {
  242.     unset($_SESSION[FM_SESSION_ID]['logged']);
  243.     fm_redirect(FM_SELF_URL);
  244. }
  245.  
  246. // Validate connection IP
  247. if ($ip_ruleset != 'OFF') {
  248.     function getClientIP() {
  249.         if (array_key_exists('HTTP_CF_CONNECTING_IP', $_SERVER)) {
  250.             return  $_SERVER["HTTP_CF_CONNECTING_IP"];
  251.         }else if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
  252.             return  $_SERVER["HTTP_X_FORWARDED_FOR"];
  253.         }else if (array_key_exists('REMOTE_ADDR', $_SERVER)) {
  254.             return $_SERVER['REMOTE_ADDR'];
  255.         }else if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) {
  256.             return $_SERVER['HTTP_CLIENT_IP'];
  257.         }
  258.         return '';
  259.     }
  260.  
  261.     $clientIp = getClientIP();
  262.  
  263.     $proceed = false;
  264.  
  265.     $whitelisted = in_array($clientIp, $ip_whitelist);
  266.     $blacklisted = in_array($clientIp, $ip_blacklist);
  267.  
  268.     if($ip_ruleset == 'AND'){
  269.         if($whitelisted == true && $blacklisted == false){
  270.             $proceed = true;
  271.         }
  272.     } else
  273.     if($ip_ruleset == 'OR'){
  274.          if($whitelisted == true || $blacklisted == false){
  275.             $proceed = true;
  276.         }
  277.     }
  278.  
  279.     if($proceed == false){
  280.         trigger_error('User connection denied from: ' . $clientIp, E_USER_WARNING);
  281.  
  282.         if($ip_silent == false){
  283.             fm_set_msg(lng('Access denied. IP restriction applicable'), 'error');
  284.             fm_show_header_login();
  285.             fm_show_message();
  286.         }
  287.  
  288.         exit();
  289.     }
  290. }
  291.  
  292. // Auth
  293. if ($use_auth) {
  294.     if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_ID]['logged']])) {
  295.         // Logged
  296.     } elseif (isset($_POST['fm_usr'], $_POST['fm_pwd'])) {
  297.         // Logging In
  298.         sleep(1);
  299.         if(function_exists('password_verify')) {
  300.             if (isset($auth_users[$_POST['fm_usr']]) && isset($_POST['fm_pwd']) && password_verify($_POST['fm_pwd'], $auth_users[$_POST['fm_usr']])) {
  301.                 $_SESSION[FM_SESSION_ID]['logged'] = $_POST['fm_usr'];
  302.                 fm_set_msg(lng('You are logged in'));
  303.                 fm_redirect(FM_SELF_URL . '?p=');
  304.             } else {
  305.                 unset($_SESSION[FM_SESSION_ID]['logged']);
  306.                 fm_set_msg(lng('Login failed. Invalid username or password'), 'error');
  307.                 fm_redirect(FM_SELF_URL);
  308.             }
  309.         } else {
  310.             fm_set_msg(lng('password_hash not supported, Upgrade PHP version'), 'error');;
  311.         }
  312.     } else {
  313.         // Form
  314.         unset($_SESSION[FM_SESSION_ID]['logged']);
  315.         fm_show_header_login();
  316.         ?>
  317.         <section class="h-100">
  318.             <div class="container h-100">
  319.                 <div class="row justify-content-md-center h-100">
  320.                     <div class="card-wrapper">
  321.                         <div class="card fat <?php echo fm_get_theme(); ?>">
  322.                             <div class="card-body">
  323.                                 <form class="form-signin" action="" method="post" autocomplete="off">
  324.                                     <div class="form-group">
  325.                                        <div class="brand">
  326.                                             <svg version="1.0" xmlns="http://www.w3.org/2000/svg" M1008 width="100%" height="80px" viewBox="0 0 238.000000 140.000000" aria-label="H3K droped">
  327.                                                 <g transform="translate(0.000000,140.000000) scale(0.100000,-0.100000)" fill="#000000" stroke="none">
  328.                                                     <path d="M160 700 l0 -600 110 0 110 0 0 260 0 260 70 0 70 0 0 -260 0 -260 110 0 110 0 0 600 0 600 -110 0 -110 0 0 -260 0 -260 -70 0 -70 0 0 260 0 260 -110 0 -110 0 0 -600z"/>
  329.                                                     <path fill="#003500" d="M1008 1227 l-108 -72 0 -117 0 -118 110 0 110 0 0 110 0 110 70 0 70 0 0 -180 0 -180 -125 0 c-69 0 -125 -3 -125 -6 0 -3 23 -39 52 -80 l52 -74 73 0 73 0 0 -185 0 -185 -70 0 -70 0 0 115 0 115 -110 0 -110 0 0 -190 0 -190 181 0 181 0 109 73 108 72 1 181 0 181 -69 48 -68 49 68 50 69 49 0 249 0 248 -182 -1 -183 0 -107 -72z"/>
  330.                                                     <path d="M1640 700 l0 -600 110 0 110 0 0 208 0 208 35 34 35 34 35 -34 35 -34 0 -208 0 -208 110 0 110 0 0 212 0 213 -87 87 -88 88 88 88 87 87 0 213 0 212 -110 0 -110 0 0 -208 0 -208 -70 -69 -70 -69 0 277 0 277 -110 0 -110 0 0 -600z"/></g>
  331.                                             </svg>
  332.                                         </div>
  333.                                         <div class="text-center">
  334.                                             <h1 class="card-title"><?php echo APP_TITLE; ?></h1>
  335.                                         </div>
  336.                                     </div>
  337.                                     <hr />
  338.                                     <div class="form-group">
  339.                                         <label for="fm_usr"><?php echo lng('Username'); ?></label>
  340.                                         <input type="text" class="form-control" id="fm_usr" name="fm_usr" required autofocus>
  341.                                     </div>
  342.  
  343.                                     <div class="form-group">
  344.                                         <label for="fm_pwd"><?php echo lng('Password'); ?></label>
  345.                                         <input type="password" class="form-control" id="fm_pwd" name="fm_pwd" required>
  346.                                     </div>
  347.  
  348.                                     <div class="form-group">
  349.                                         <?php fm_show_message(); ?>
  350.                                     </div>
  351.  
  352.                                     <div class="form-group">
  353.                                         <button type="submit" class="btn btn-success btn-block mt-4" role="button">
  354.                                             <?php echo lng('Login'); ?>
  355.                                         </button>
  356.                                     </div>
  357.                                 </form>
  358.                             </div>
  359.                         </div>
  360.                         <div class="footer text-center">
  361.                             —— ©
  362.                             <a href="https://tinyfilemanager.github.io/" target="_blank" class="text-muted" data-version="<?php echo VERSION; ?>">CCP Programmers</a> ——
  363.                         </div>
  364.                     </div>
  365.                 </div>
  366.             </div>
  367.         </section>
  368.  
  369.         <?php
  370.         fm_show_footer_login();
  371.         exit;
  372.     }
  373. }
  374.  
  375. // update root path
  376. if ($use_auth && isset($_SESSION[FM_SESSION_ID]['logged'])) {
  377.     $root_path = isset($directories_users[$_SESSION[FM_SESSION_ID]['logged']]) ? $directories_users[$_SESSION[FM_SESSION_ID]['logged']] : $root_path;
  378. }
  379.  
  380. // clean and check $root_path
  381. $root_path = rtrim($root_path, '\\/');
  382. $root_path = str_replace('\\', '/', $root_path);
  383. if (!@is_dir($root_path)) {
  384.     echo "<h1>".lng('Root path').\"{$root_path}\" ".lng('not found!')." </h1>";
  385.     exit;
  386. }
  387.  
  388. defined('FM_SHOW_HIDDEN') || define('FM_SHOW_HIDDEN', $show_hidden_files);
  389. defined('FM_ROOT_PATH') || define('FM_ROOT_PATH', $root_path);
  390. defined('FM_LANG') || define('FM_LANG', $lang);
  391. defined('FM_FILE_EXTENSION') || define('FM_FILE_EXTENSION', $allowed_file_extensions);
  392. defined('FM_UPLOAD_EXTENSION') || define('FM_UPLOAD_EXTENSION', $allowed_upload_extensions);
  393. defined('FM_EXCLUDE_ITEMS') || define('FM_EXCLUDE_ITEMS', (version_compare(PHP_VERSION, '7.0.0', '<') ? serialize($exclude_items) : $exclude_items));
  394. defined('FM_DOC_VIEWER') || define('FM_DOC_VIEWER', $online_viewer);
  395. define('FM_READONLY', $use_auth && !empty($readonly_users) && isset($_SESSION[FM_SESSION_ID]['logged']) && in_array($_SESSION[FM_SESSION_ID]['logged'], $readonly_users));
  396. define('FM_IS_WIN', DIRECTORY_SEPARATOR == '\\');
  397.  
  398. // always use ?p=
  399. if (!isset($_GET['p']) && empty($_FILES)) {
  400.     fm_redirect(FM_SELF_URL . '?p=');
  401. }
  402.  
  403. // get path
  404. $p = isset($_GET['p']) ? $_GET['p'] : (isset($_POST['p']) ? $_POST['p'] : '');
  405.  
  406. // clean path
  407. $p = fm_clean_path($p);
  408.  
  409. // for ajax request - save
  410. $input = file_get_contents('php://input');
  411. $_POST = (strpos($input, 'ajax') != FALSE && strpos($input, 'save') != FALSE) ? json_decode($input, true) : $_POST;
  412.  
  413. // instead globals vars
  414. define('FM_PATH', $p);
  415. define('FM_USE_AUTH', $use_auth);
  416. define('FM_EDIT_FILE', $edit_files);
  417. defined('FM_ICONV_INPUT_ENC') || define('FM_ICONV_INPUT_ENC', $iconv_input_encoding);
  418. defined('FM_USE_HIGHLIGHTJS') || define('FM_USE_HIGHLIGHTJS', $use_highlightjs);
  419. defined('FM_HIGHLIGHTJS_STYLE') || define('FM_HIGHLIGHTJS_STYLE', $highlightjs_style);
  420. defined('FM_DATETIME_FORMAT') || define('FM_DATETIME_FORMAT', $datetime_format);
  421.  
  422. unset($p, $use_auth, $iconv_input_encoding, $use_highlightjs, $highlightjs_style);
  423.  
  424. /*************************** ACTIONS ***************************/
  425.  
  426. // AJAX Request
  427. if (isset($_POST['ajax']) && !FM_READONLY) {
  428.  
  429.     // save
  430.     if (isset($_POST['type']) && $_POST['type'] == "save") {
  431.         // get current path
  432.         $path = FM_ROOT_PATH;
  433.         if (FM_PATH != '') {
  434.             $path .= '/' . FM_PATH;
  435.         }
  436.         // check path
  437.         if (!is_dir($path)) {
  438.             fm_redirect(FM_SELF_URL . '?p=');
  439.         }
  440.         $file = $_GET['edit'];
  441.         $file = fm_clean_path($file);
  442.         $file = str_replace('/', '', $file);
  443.         if ($file == '' || !is_file($path . '/' . $file)) {
  444.             fm_set_msg(lng('File not found'), 'error');
  445.             fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  446.         }
  447.         header('X-XSS-Protection:0');
  448.         $file_path = $path . '/' . $file;
  449.  
  450.         $writedata = $_POST['content'];
  451.         $fd = fopen($file_path, "w");
  452.         $write_results = @fwrite($fd, $writedata);
  453.         fclose($fd);
  454.         if ($write_results === false){
  455.             header("HTTP/1.1 500 Internal Server Error");
  456.             die("Could Not Write File! - Check Permissions / Ownership");
  457.         }
  458.         die(true);
  459.     }
  460.  
  461.     // backup files
  462.     if (isset($_POST['type']) && $_POST['type'] == "backup" && !empty($_POST['file'])) {
  463.         $fileName = $_POST['file'];
  464.         $fullPath = FM_ROOT_PATH . '/';
  465.         if (!empty($_POST['path'])) {
  466.             $relativeDirPath = fm_clean_path($_POST['path']);
  467.             $fullPath .= "{$relativeDirPath}/";
  468.         }
  469.         $date = date("dMy-His");
  470.         $newFileName = "{$fileName}-{$date}.bak";
  471.         $fullyQualifiedFileName = $fullPath . $fileName;
  472.         try {
  473.             if (!file_exists($fullyQualifiedFileName)) {
  474.                 throw new Exception("File {$fileName} not found");
  475.             }
  476.             if (copy($fullyQualifiedFileName, $fullPath . $newFileName)) {
  477.                 echo "Backup {$newFileName} created";
  478.             } else {
  479.                 throw new Exception("Could not copy file {$fileName}");
  480.             }
  481.         } catch (Exception $e) {
  482.             echo $e->getMessage();
  483.         }
  484.     }
  485.  
  486.     // Save Config
  487.     if (isset($_POST['type']) && $_POST['type'] == "settings") {
  488.         global $cfg, $lang, $report_errors, $show_hidden_files, $lang_list, $hide_Cols, $calc_folder, $theme;
  489.         $newLng = $_POST['js-language'];
  490.         fm_get_translations([]);
  491.         if (!array_key_exists($newLng, $lang_list)) {
  492.             $newLng = 'en';
  493.         }
  494.  
  495.         $erp = isset($_POST['js-error-report']) && $_POST['js-error-report'] == "true" ? true : false;
  496.         $shf = isset($_POST['js-show-hidden']) && $_POST['js-show-hidden'] == "true" ? true : false;
  497.         $hco = isset($_POST['js-hide-cols']) && $_POST['js-hide-cols'] == "true" ? true : false;
  498.         $caf = isset($_POST['js-calc-folder']) && $_POST['js-calc-folder'] == "true" ? true : false;
  499.         $te3 = $_POST['js-theme-3'];
  500.  
  501.         if ($cfg->data['lang'] != $newLng) {
  502.             $cfg->data['lang'] = $newLng;
  503.             $lang = $newLng;
  504.         }
  505.         if ($cfg->data['error_reporting'] != $erp) {
  506.             $cfg->data['error_reporting'] = $erp;
  507.             $report_errors = $erp;
  508.         }
  509.         if ($cfg->data['show_hidden'] != $shf) {
  510.             $cfg->data['show_hidden'] = $shf;
  511.             $show_hidden_files = $shf;
  512.         }
  513.         if ($cfg->data['show_hidden'] != $shf) {
  514.             $cfg->data['show_hidden'] = $shf;
  515.             $show_hidden_files = $shf;
  516.         }
  517.         if ($cfg->data['hide_Cols'] != $hco) {
  518.             $cfg->data['hide_Cols'] = $hco;
  519.             $hide_Cols = $hco;
  520.         }
  521.         if ($cfg->data['calc_folder'] != $caf) {
  522.             $cfg->data['calc_folder'] = $caf;
  523.             $calc_folder = $caf;
  524.         }
  525.         if ($cfg->data['theme'] != $te3) {
  526.             $cfg->data['theme'] = $te3;
  527.             $theme = $te3;
  528.         }
  529.         $cfg->save();
  530.         echo true;
  531.     }
  532.  
  533.     // new password hash
  534.     if (isset($_POST['type']) && $_POST['type'] == "pwdhash") {
  535.         $res = isset($_POST['inputPassword2']) && !empty($_POST['inputPassword2']) ? password_hash($_POST['inputPassword2'], PASSWORD_DEFAULT) : '';
  536.         echo $res;
  537.     }
  538.  
  539.     //upload using url
  540.     if(isset($_POST['type']) && $_POST['type'] == "upload" && !empty($_REQUEST["uploadurl"])) {
  541.         $path = FM_ROOT_PATH;
  542.         if (FM_PATH != '') {
  543.             $path .= '/' . FM_PATH;
  544.         }
  545.  
  546.          function event_callback ($message) {
  547.             global $callback;
  548.             echo json_encode($message);
  549.         }
  550.  
  551.         function get_file_path () {
  552.             global $path, $fileinfo, $temp_file;
  553.             return $path."/".basename($fileinfo->name);
  554.         }
  555.  
  556.         $url = !empty($_REQUEST["uploadurl"]) && preg_match("|^http(s)?://.+$|", stripslashes($_REQUEST["uploadurl"])) ? stripslashes($_REQUEST["uploadurl"]) : null;
  557.  
  558.         //prevent 127.* domain and known ports
  559.         $domain = parse_url($url, PHP_URL_HOST);
  560.         $port = parse_url($url, PHP_URL_PORT);
  561.         $knownPorts = [22, 23, 25, 3306];
  562.  
  563.         if (preg_match("/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/i", $domain) || in_array($port, $knownPorts)) {
  564.             $err = array("message" => "URL is not allowed");
  565.             event_callback(array("fail" => $err));
  566.             exit();
  567.         }
  568.  
  569.         $use_curl = false;
  570.         $temp_file = tempnam(sys_get_temp_dir(), "upload-");
  571.         $fileinfo = new stdClass();
  572.         $fileinfo->name = trim(basename($url), ".\x00..\x20");
  573.  
  574.         $allowed = (FM_UPLOAD_EXTENSION) ? explode(',', FM_UPLOAD_EXTENSION) : false;
  575.         $ext = strtolower(pathinfo($fileinfo->name, PATHINFO_EXTENSION));
  576.         $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true;
  577.  
  578.         $err = false;
  579.  
  580.         if(!$isFileAllowed) {
  581.             $err = array("message" => "File extension is not allowed");
  582.             event_callback(array("fail" => $err));
  583.             exit();
  584.         }
  585.  
  586.         if (!$url) {
  587.             $success = false;
  588.         } else if ($use_curl) {
  589.             @$fp = fopen($temp_file, "w");
  590.             @$ch = curl_init($url);
  591.             curl_setopt($ch, CURLOPT_NOPROGRESS, false );
  592.             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  593.             curl_setopt($ch, CURLOPT_FILE, $fp);
  594.             @$success = curl_exec($ch);
  595.             $curl_info = curl_getinfo($ch);
  596.             if (!$success) {
  597.                 $err = array("message" => curl_error($ch));
  598.             }
  599.             @curl_close($ch);
  600.             fclose($fp);
  601.             $fileinfo->size = $curl_info["size_download"];
  602.             $fileinfo->type = $curl_info["content_type"];
  603.         } else {
  604.             $ctx = stream_context_create();
  605.             @$success = copy($url, $temp_file, $ctx);
  606.             if (!$success) {
  607.                 $err = error_get_last();
  608.             }
  609.         }
  610.  
  611.         if ($success) {
  612.             $success = rename($temp_file, get_file_path());
  613.         }
  614.  
  615.         if ($success) {
  616.             event_callback(array("done" => $fileinfo));
  617.         } else {
  618.             unlink($temp_file);
  619.             if (!$err) {
  620.                 $err = array("message" => "Invalid url parameter");
  621.             }
  622.             event_callback(array("fail" => $err));
  623.         }
  624.     }
  625.  
  626.     exit();
  627. }
  628.  
  629. if (isset($_POST['ajax'])) {
  630.     //search : get list of files from the current folder
  631.     if(isset($_POST['type']) && $_POST['type']=="search") {
  632.         $dir = FM_ROOT_PATH;
  633.         $response = scan(fm_clean_path($_POST['path']), $_POST['content']);
  634.         echo json_encode($response);
  635.         exit();
  636.     }
  637. }
  638.  
  639. // Delete file / folder
  640. if (isset($_GET['del']) && !FM_READONLY) {
  641.     $del = str_replace( '/', '', fm_clean_path( $_GET['del'] ) );
  642.     if ($del != '' && $del != '..' && $del != '.') {
  643.         $path = FM_ROOT_PATH;
  644.         if (FM_PATH != '') {
  645.             $path .= '/' . FM_PATH;
  646.         }
  647.         $is_dir = is_dir($path . '/' . $del);
  648.         if (fm_rdelete($path . '/' . $del)) {
  649.             $msg = $is_dir ? lng('Folder').' <b>%s</b> '.lng('Deleted') : lng('File').' <b>%s</b> '.lng('Deleted');
  650.             fm_set_msg(sprintf($msg, fm_enc($del)));
  651.         } else {
  652.             $msg = $is_dir ? lng('Folder').' <b>%s</b> '.lng('not deleted') : lng('File').' <b>%s</b> '.lng('not deleted');
  653.             fm_set_msg(sprintf($msg, fm_enc($del)), 'error');
  654.         }
  655.     } else {
  656.         fm_set_msg(lng('Invalid file or folder name'), 'error');
  657.     }
  658.     fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  659. }
  660.  
  661. // Create folder
  662. if (isset($_GET['new']) && isset($_GET['type']) && !FM_READONLY) {
  663.     $type = $_GET['type'];
  664.     $new = str_replace( '/', '', fm_clean_path( strip_tags( $_GET['new'] ) ) );
  665.     if (fm_isvalid_filename($new) && $new != '' && $new != '..' && $new != '.') {
  666.         $path = FM_ROOT_PATH;
  667.         if (FM_PATH != '') {
  668.             $path .= '/' . FM_PATH;
  669.         }
  670.         if ($_GET['type'] == "file") {
  671.             if (!file_exists($path . '/' . $new)) {
  672.                 if(fm_is_valid_ext($new)) {
  673.                     @fopen($path . '/' . $new, 'w') or die('Cannot open file:  ' . $new);
  674.                     fm_set_msg(sprintf(lng('File').' <b>%s</b> '.lng('Created'), fm_enc($new)));
  675.                 } else {
  676.                     fm_set_msg(lng('File extension is not allowed'), 'error');
  677.                 }
  678.             } else {
  679.                 fm_set_msg(sprintf(lng('File').' <b>%s</b> '.lng('already exists'), fm_enc($new)), 'alert');
  680.             }
  681.         } else {
  682.             if (fm_mkdir($path . '/' . $new, false) === true) {
  683.                 fm_set_msg(sprintf(lng('Folder').' <b>%s</b> '.lng('Created'), $new));
  684.             } elseif (fm_mkdir($path . '/' . $new, false) === $path . '/' . $new) {
  685.                 fm_set_msg(sprintf(lng('Folder').' <b>%s</b> '.lng('already exists'), fm_enc($new)), 'alert');
  686.             } else {
  687.                 fm_set_msg(sprintf(lng('Folder').' <b>%s</b> '.lng('not created'), fm_enc($new)), 'error');
  688.             }
  689.         }
  690.     } else {
  691.         fm_set_msg(lng('Invalid characters in file or folder name'), 'error');
  692.     }
  693.     fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  694. }
  695.  
  696. // Copy folder / file
  697. if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) {
  698.     // from
  699.     $copy = $_GET['copy'];
  700.     $copy = fm_clean_path($copy);
  701.     // empty path
  702.     if ($copy == '') {
  703.         fm_set_msg(lng('Source path not defined'), 'error');
  704.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  705.     }
  706.     // abs path from
  707.     $from = FM_ROOT_PATH . '/' . $copy;
  708.     // abs path to
  709.     $dest = FM_ROOT_PATH;
  710.     if (FM_PATH != '') {
  711.         $dest .= '/' . FM_PATH;
  712.     }
  713.     $dest .= '/' . basename($from);
  714.     // move?
  715.     $move = isset($_GET['move']);
  716.     // copy/move/duplicate
  717.     if ($from != $dest) {
  718.         $msg_from = trim(FM_PATH . '/' . basename($from), '/');
  719.         if ($move) { // Move and to != from so just perform move
  720.             $rename = fm_rename($from, $dest);
  721.             if ($rename) {
  722.                 fm_set_msg(sprintf(lng('Moved from').' <b>%s</b> '.lng('to').' <b>%s</b>', fm_enc($copy), fm_enc($msg_from)));
  723.             } elseif ($rename === null) {
  724.                 fm_set_msg(lng('File or folder with this path already exists'), 'alert');
  725.             } else {
  726.                 fm_set_msg(sprintf(lng('Error while moving from').' <b>%s</b> '.lng('to').' <b>%s</b>', fm_enc($copy), fm_enc($msg_from)), 'error');
  727.             }
  728.         } else { // Not move and to != from so copy with original name
  729.             if (fm_rcopy($from, $dest)) {
  730.                 fm_set_msg(sprintf(lng('Copied from').' <b>%s</b> '.lng('to').' <b>%s</b>', fm_enc($copy), fm_enc($msg_from)));
  731.             } else {
  732.                 fm_set_msg(sprintf(lng('Error while copying from').' <b>%s</b> '.lng('to').' <b>%s</b>', fm_enc($copy), fm_enc($msg_from)), 'error');
  733.             }
  734.         }
  735.     } else {
  736.        if (!$move){ //Not move and to = from so duplicate
  737.             $msg_from = trim(FM_PATH . '/' . basename($from), '/');
  738.             $fn_parts = pathinfo($from);
  739.             $extension_suffix = '';
  740.             if(!is_dir($from)){
  741.                $extension_suffix = '.'.$fn_parts['extension'];
  742.             }
  743.             //Create new name for duplicate
  744.             $fn_duplicate = $fn_parts['dirname'].'/'.$fn_parts['filename'].'-'.date('YmdHis').$extension_suffix;
  745.             $loop_count = 0;
  746.             $max_loop = 1000;
  747.             // Check if a file with the duplicate name already exists, if so, make new name (edge case...)
  748.             while(file_exists($fn_duplicate) & $loop_count < $max_loop){
  749.                $fn_parts = pathinfo($fn_duplicate);
  750.                $fn_duplicate = $fn_parts['dirname'].'/'.$fn_parts['filename'].'-copy'.$extension_suffix;
  751.                $loop_count++;
  752.             }
  753.             if (fm_rcopy($from, $fn_duplicate, False)) {
  754.                 fm_set_msg(sprintf('Copyied from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($fn_duplicate)));
  755.             } else {
  756.                 fm_set_msg(sprintf('Error while copying from <b>%s</b> to <b>%s</b>', fm_enc($copy), fm_enc($fn_duplicate)), 'error');
  757.             }
  758.        }
  759.        else{
  760.            fm_set_msg(lng('Paths must be not equal'), 'alert');
  761.        }
  762.     }
  763.     fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  764. }
  765.  
  766. // Mass copy files/ folders
  767. if (isset($_POST['file'], $_POST['copy_to'], $_POST['finish']) && !FM_READONLY) {
  768.     // from
  769.     $path = FM_ROOT_PATH;
  770.     if (FM_PATH != '') {
  771.         $path .= '/' . FM_PATH;
  772.     }
  773.     // to
  774.     $copy_to_path = FM_ROOT_PATH;
  775.     $copy_to = fm_clean_path($_POST['copy_to']);
  776.     if ($copy_to != '') {
  777.         $copy_to_path .= '/' . $copy_to;
  778.     }
  779.     if ($path == $copy_to_path) {
  780.         fm_set_msg(lng('Paths must be not equal'), 'alert');
  781.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  782.     }
  783.     if (!is_dir($copy_to_path)) {
  784.         if (!fm_mkdir($copy_to_path, true)) {
  785.             fm_set_msg('Unable to create destination folder', 'error');
  786.             fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  787.         }
  788.     }
  789.     // move?
  790.     $move = isset($_POST['move']);
  791.     // copy/move
  792.     $errors = 0;
  793.     $files = $_POST['file'];
  794.     if (is_array($files) && count($files)) {
  795.         foreach ($files as $f) {
  796.             if ($f != '') {
  797.                 // abs path from
  798.                 $from = $path . '/' . $f;
  799.                 // abs path to
  800.                 $dest = $copy_to_path . '/' . $f;
  801.                 // do
  802.                 if ($move) {
  803.                     $rename = fm_rename($from, $dest);
  804.                     if ($rename === false) {
  805.                         $errors++;
  806.                     }
  807.                 } else {
  808.                     if (!fm_rcopy($from, $dest)) {
  809.                         $errors++;
  810.                     }
  811.                 }
  812.             }
  813.         }
  814.         if ($errors == 0) {
  815.             $msg = $move 'Selected files and folders moved' : 'Selected files and folders copied';
  816.             fm_set_msg($msg);
  817.         } else {
  818.             $msg = $move 'Error while moving items' : 'Error while copying items';
  819.             fm_set_msg($msg, 'error');
  820.         }
  821.     } else {
  822.         fm_set_msg(lng('Nothing selected'), 'alert');
  823.     }
  824.     fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  825. }
  826.  
  827. // Rename
  828. if (isset($_GET['ren'], $_GET['to']) && !FM_READONLY) {
  829.     // old name
  830.     $old = $_GET['ren'];
  831.     $old = fm_clean_path($old);
  832.     $old = str_replace('/', '', $old);
  833.     // new name
  834.     $new = $_GET['to'];
  835.     $new = fm_clean_path(strip_tags($new));
  836.     $new = str_replace('/', '', $new);
  837.     // path
  838.     $path = FM_ROOT_PATH;
  839.     if (FM_PATH != '') {
  840.         $path .= '/' . FM_PATH;
  841.     }
  842.     // rename
  843.     if (fm_isvalid_filename($new) && $old != '' && $new != '') {
  844.         if (fm_rename($path . '/' . $old, $path . '/' . $new)) {
  845.             fm_set_msg(sprintf(lng('Renamed from').' <b>%s</b> '. lng('to').' <b>%s</b>', fm_enc($old), fm_enc($new)));
  846.         } else {
  847.             fm_set_msg(sprintf(lng('Error while renaming from').' <b>%s</b> '. lng('to').' <b>%s</b>', fm_enc($old), fm_enc($new)), 'error');
  848.         }
  849.     } else {
  850.         fm_set_msg(lng('Invalid characters in file name'), 'error');
  851.     }
  852.     fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  853. }
  854.  
  855. // Download
  856. if (isset($_GET['dl'])) {
  857.     $dl = $_GET['dl'];
  858.     $dl = fm_clean_path($dl);
  859.     $dl = str_replace('/', '', $dl);
  860.     $path = FM_ROOT_PATH;
  861.     if (FM_PATH != '') {
  862.         $path .= '/' . FM_PATH;
  863.     }
  864.     if ($dl != '' && is_file($path . '/' . $dl)) {
  865.         fm_download_file($path . '/' . $dl, $dl, 1024);
  866.         exit;
  867.     } else {
  868.         fm_set_msg(lng('File not found'), 'error');
  869.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  870.     }
  871. }
  872.  
  873. // Upload
  874. if (!empty($_FILES) && !FM_READONLY) {
  875.     $override_file_name = false;
  876.     $chunkIndex = $_POST['dzchunkindex'];
  877.     $chunkTotal = $_POST['dztotalchunkcount'];
  878.  
  879.     $f = $_FILES;
  880.     $path = FM_ROOT_PATH;
  881.     $ds = DIRECTORY_SEPARATOR;
  882.     if (FM_PATH != '') {
  883.         $path .= '/' . FM_PATH;
  884.     }
  885.  
  886.     $errors = 0;
  887.     $uploads = 0;
  888.     $allowed = (FM_UPLOAD_EXTENSION) ? explode(',', FM_UPLOAD_EXTENSION) : false;
  889.     $response = array (
  890.         'status' => 'error',
  891.         'info'   => 'Oops! Try again'
  892.     );
  893.  
  894.     $filename = $f['file']['name'];
  895.     $tmp_name = $f['file']['tmp_name'];
  896.     $ext = pathinfo($filename, PATHINFO_FILENAME) != '' ? strtolower(pathinfo($filename, PATHINFO_EXTENSION)) : '';
  897.     $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true;
  898.  
  899.     if(!fm_isvalid_filename($filename) && !fm_isvalid_filename($_REQUEST['fullpath'])) {
  900.         $response = array (
  901.             'status'    => 'error',
  902.             'info'      => "Invalid File name!",
  903.         );
  904.         echo json_encode($response); exit();
  905.     }
  906.  
  907.     $targetPath = $path . $ds;
  908.     if ( is_writable($targetPath) ) {
  909.         $fullPath = $path . '/' . basename($_REQUEST['fullpath']);
  910.         $folder = substr($fullPath, 0, strrpos($fullPath, "/"));
  911.  
  912.         if(file_exists ($fullPath) && !$override_file_name && !$chunks) {
  913.             $ext_1 = $ext '.'.$ext : '';
  914.             $fullPath = $path . '/' . basename($_REQUEST['fullpath'], $ext_1) .'_'. date('ymdHis'). $ext_1;
  915.         }
  916.  
  917.         if (!is_dir($folder)) {
  918.             $old = umask(0);
  919.             mkdir($folder, 0777, true);
  920.             umask($old);
  921.         }
  922.  
  923.  
  924.  
  925.         if (empty($f['file']['error']) && !empty($tmp_name) && $tmp_name != 'none' && $isFileAllowed) {
  926.             if ($chunkTotal){
  927.                 $out = @fopen("{$fullPath}.part", $chunkIndex == 0 ? "wb" : "ab");
  928.                 if ($out) {
  929.                     $in = @fopen($tmp_name, "rb");
  930.                     if ($in) {
  931.                         while ($buff = fread($in, 4096)) { fwrite($out, $buff); }
  932.                     } else {
  933.                         $response = array (
  934.                         'status'    => 'error',
  935.                         'info' => "failed to open output stream"
  936.                         );
  937.                     }
  938.                     @fclose($in);
  939.                     @fclose($out);
  940.                     @unlink($tmp_name);
  941.  
  942.                     $response = array (
  943.                         'status'    => 'success',
  944.                         'info' => "file upload successful",
  945.                         'fullPath' => $fullPath
  946.                     );
  947.                 } else {
  948.                     $response = array (
  949.                         'status'    => 'error',
  950.                         'info' => "failed to open output stream"
  951.                         );
  952.                 }
  953.  
  954.  
  955.  
  956.                 if ($chunkIndex == $chunkTotal - 1) {
  957.                     rename("{$fullPath}.part", $fullPath);
  958.                 }
  959.  
  960.             } else if (move_uploaded_file($tmp_name, $fullPath)) {
  961.                 // Be sure that the file has been uploaded
  962.                 if ( file_exists($fullPath) ) {
  963.                     $response = array (
  964.                         'status'    => 'success',
  965.                         'info' => "file upload successful"
  966.                     );
  967.                 } else {
  968.                     $response = array (
  969.                         'status' => 'error',
  970.                         'info'   => 'Couldn\'t upload the requested file.'
  971.                     );
  972.                 }
  973.             } else {
  974.                 $response = array (
  975.                     'status'    => 'error',
  976.                     'info'      => "Error while uploading files. Uploaded files $uploads",
  977.                 );
  978.             }
  979.         }
  980.     } else {
  981.         $response = array (
  982.             'status' => 'error',
  983.             'info'   => 'The specified folder for upload isn\'t writeable.'
  984.         );
  985.     }
  986.     // Return the response
  987.     echo json_encode($response);
  988.     exit();
  989. }
  990.  
  991. // Mass deleting
  992. if (isset($_POST['group'], $_POST['delete']) && !FM_READONLY) {
  993.     $path = FM_ROOT_PATH;
  994.     if (FM_PATH != '') {
  995.         $path .= '/' . FM_PATH;
  996.     }
  997.  
  998.     $errors = 0;
  999.     $files = $_POST['file'];
  1000.     if (is_array($files) && count($files)) {
  1001.         foreach ($files as $f) {
  1002.             if ($f != '') {
  1003.                 $new_path = $path . '/' . $f;
  1004.                 if (!fm_rdelete($new_path)) {
  1005.                     $errors++;
  1006.                 }
  1007.             }
  1008.         }
  1009.         if ($errors == 0) {
  1010.             fm_set_msg(lng('Selected files and folder deleted'));
  1011.         } else {
  1012.             fm_set_msg(lng('Error while deleting items'), 'error');
  1013.         }
  1014.     } else {
  1015.         fm_set_msg(lng('Nothing selected'), 'alert');
  1016.     }
  1017.  
  1018.     fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1019. }
  1020.  
  1021. // Pack files
  1022. if (isset($_POST['group']) && (isset($_POST['zip']) || isset($_POST['tar'])) && !FM_READONLY) {
  1023.     $path = FM_ROOT_PATH;
  1024.     $ext = 'zip';
  1025.     if (FM_PATH != '') {
  1026.         $path .= '/' . FM_PATH;
  1027.     }
  1028.  
  1029.     //set pack type
  1030.     $ext = isset($_POST['tar']) ? 'tar' : 'zip';
  1031.  
  1032.  
  1033.     if (($ext == "zip" && !class_exists('ZipArchive')) || ($ext == "tar" && !class_exists('PharData'))) {
  1034.         fm_set_msg(lng('Operations with archives are not available'), 'error');
  1035.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1036.     }
  1037.  
  1038.     $files = $_POST['file'];
  1039.     if (!empty($files)) {
  1040.         chdir($path);
  1041.  
  1042.         if (count($files) == 1) {
  1043.             $one_file = reset($files);
  1044.             $one_file = basename($one_file);
  1045.             $zipname = $one_file . '_' . date('ymd_His') . '.'.$ext;
  1046.         } else {
  1047.             $zipname = 'archive_' . date('ymd_His') . '.'.$ext;
  1048.         }
  1049.  
  1050.         if($ext == 'zip') {
  1051.             $zipper = new FM_Zipper();
  1052.             $res = $zipper->create($zipname, $files);
  1053.         } elseif ($ext == 'tar') {
  1054.             $tar = new FM_Zipper_Tar();
  1055.             $res = $tar->create($zipname, $files);
  1056.         }
  1057.  
  1058.         if ($res) {
  1059.             fm_set_msg(sprintf(lng('Archive').' <b>%s</b> '.lng('Created'), fm_enc($zipname)));
  1060.         } else {
  1061.             fm_set_msg(lng('Archive not created'), 'error');
  1062.         }
  1063.     } else {
  1064.         fm_set_msg(lng('Nothing selected'), 'alert');
  1065.     }
  1066.  
  1067.     fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1068. }
  1069.  
  1070. // Unpack
  1071. if (isset($_GET['unzip']) && !FM_READONLY) {
  1072.     $unzip = $_GET['unzip'];
  1073.     $unzip = fm_clean_path($unzip);
  1074.     $unzip = str_replace('/', '', $unzip);
  1075.     $isValid = false;
  1076.  
  1077.     $path = FM_ROOT_PATH;
  1078.     if (FM_PATH != '') {
  1079.         $path .= '/' . FM_PATH;
  1080.     }
  1081.  
  1082.     if ($unzip != '' && is_file($path . '/' . $unzip)) {
  1083.         $zip_path = $path . '/' . $unzip;
  1084.         $ext = pathinfo($zip_path, PATHINFO_EXTENSION);
  1085.         $isValid = true;
  1086.     } else {
  1087.         fm_set_msg(lng('File not found'), 'error');
  1088.     }
  1089.  
  1090.  
  1091.     if (($ext == "zip" && !class_exists('ZipArchive')) || ($ext == "tar" && !class_exists('PharData'))) {
  1092.         fm_set_msg(lng('Operations with archives are not available'), 'error');
  1093.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1094.     }
  1095.  
  1096.     if ($isValid) {
  1097.         //to folder
  1098.         $tofolder = '';
  1099.         if (isset($_GET['tofolder'])) {
  1100.             $tofolder = pathinfo($zip_path, PATHINFO_FILENAME);
  1101.             if (fm_mkdir($path . '/' . $tofolder, true)) {
  1102.                 $path .= '/' . $tofolder;
  1103.             }
  1104.         }
  1105.  
  1106.         if($ext == "zip") {
  1107.             $zipper = new FM_Zipper();
  1108.             $res = $zipper->unzip($zip_path, $path);
  1109.         } elseif ($ext == "tar") {
  1110.             try {
  1111.                 $gzipper = new PharData($zip_path);
  1112.                 if (@$gzipper->extractTo($path,null, true)) {
  1113.                     $res = true;
  1114.                 } else {
  1115.                     $res = false;
  1116.                 }
  1117.             } catch (Exception $e) {
  1118.                 //TODO:: need to handle the error
  1119.                 $res = true;
  1120.             }
  1121.         }
  1122.  
  1123.         if ($res) {
  1124.             fm_set_msg(lng('Archive unpacked'));
  1125.         } else {
  1126.             fm_set_msg(lng('Archive not unpacked'), 'error');
  1127.         }
  1128.  
  1129.     } else {
  1130.         fm_set_msg(lng('File not found'), 'error');
  1131.     }
  1132.     fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1133. }
  1134.  
  1135. // Change Perms (not for Windows)
  1136. if (isset($_POST['chmod']) && !FM_READONLY && !FM_IS_WIN) {
  1137.     $path = FM_ROOT_PATH;
  1138.     if (FM_PATH != '') {
  1139.         $path .= '/' . FM_PATH;
  1140.     }
  1141.  
  1142.     $file = $_POST['chmod'];
  1143.     $file = fm_clean_path($file);
  1144.     $file = str_replace('/', '', $file);
  1145.     if ($file == '' || (!is_file($path . '/' . $file) && !is_dir($path . '/' . $file))) {
  1146.         fm_set_msg(lng('File not found'), 'error');
  1147.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1148.     }
  1149.  
  1150.     $mode = 0;
  1151.     if (!empty($_POST['ur'])) {
  1152.         $mode |= 0400;
  1153.     }
  1154.     if (!empty($_POST['uw'])) {
  1155.         $mode |= 0200;
  1156.     }
  1157.     if (!empty($_POST['ux'])) {
  1158.         $mode |= 0100;
  1159.     }
  1160.     if (!empty($_POST['gr'])) {
  1161.         $mode |= 0040;
  1162.     }
  1163.     if (!empty($_POST['gw'])) {
  1164.         $mode |= 0020;
  1165.     }
  1166.     if (!empty($_POST['gx'])) {
  1167.         $mode |= 0010;
  1168.     }
  1169.     if (!empty($_POST['or'])) {
  1170.         $mode |= 0004;
  1171.     }
  1172.     if (!empty($_POST['ow'])) {
  1173.         $mode |= 0002;
  1174.     }
  1175.     if (!empty($_POST['ox'])) {
  1176.         $mode |= 0001;
  1177.     }
  1178.  
  1179.     if (@chmod($path . '/' . $file, $mode)) {
  1180.         fm_set_msg(lng('Permissions changed'));
  1181.     } else {
  1182.         fm_set_msg(lng('Permissions not changed'), 'error');
  1183.     }
  1184.  
  1185.     fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1186. }
  1187.  
  1188. /*************************** /ACTIONS ***************************/
  1189.  
  1190. // get current path
  1191. $path = FM_ROOT_PATH;
  1192. if (FM_PATH != '') {
  1193.     $path .= '/' . FM_PATH;
  1194. }
  1195.  
  1196. // check path
  1197. if (!is_dir($path)) {
  1198.     fm_redirect(FM_SELF_URL . '?p=');
  1199. }
  1200.  
  1201. // get parent folder
  1202. $parent = fm_get_parent_path(FM_PATH);
  1203.  
  1204. $objects = is_readable($path) ? scandir($path) : array();
  1205. $folders = array();
  1206. $files = array();
  1207. $current_path = array_slice(explode("/",$path), -1)[0];
  1208. if (is_array($objects) && fm_is_exclude_items($current_path)) {
  1209.     foreach ($objects as $file) {
  1210.         if ($file == '.' || $file == '..') {
  1211.             continue;
  1212.         }
  1213.         if (!FM_SHOW_HIDDEN && substr($file, 0, 1) === '.') {
  1214.             continue;
  1215.         }
  1216.         $new_path = $path . '/' . $file;
  1217.         if (@is_file($new_path) && fm_is_exclude_items($file)) {
  1218.             $files[] = $file;
  1219.         } elseif (@is_dir($new_path) && $file != '.' && $file != '..' && fm_is_exclude_items($file)) {
  1220.             $folders[] = $file;
  1221.         }
  1222.     }
  1223. }
  1224.  
  1225. if (!empty($files)) {
  1226.     natcasesort($files);
  1227. }
  1228. if (!empty($folders)) {
  1229.     natcasesort($folders);
  1230. }
  1231.  
  1232. // upload form
  1233. if (isset($_GET['upload']) && !FM_READONLY) {
  1234.     fm_show_header(); // HEADER
  1235.     fm_show_nav_path(FM_PATH); // current path
  1236.     //get the allowed file extensions
  1237.     function getUploadExt() {
  1238.         $extArr = explode(',', FM_UPLOAD_EXTENSION);
  1239.         if(FM_UPLOAD_EXTENSION && $extArr) {
  1240.             array_walk($extArr, function(&$x) {$x = ".$x";});
  1241.             return implode(',', $extArr);
  1242.         }
  1243.         return '';
  1244.     }
  1245.     ?>
  1246.     <link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.css" rel="stylesheet">
  1247.     <div class="path">
  1248.  
  1249.         <div class="card mb-2 fm-upload-wrapper <?php echo fm_get_theme(); ?>">
  1250.             <div class="card-header">
  1251.                 <ul class="nav nav-tabs card-header-tabs">
  1252.                     <li class="nav-item">
  1253.                         <a class="nav-link active" href="#fileUploader" data-target="#fileUploader"><i class="fa fa-arrow-circle-o-up"></i> <?php echo lng('UploadingFiles') ?></a>
  1254.                     </li>
  1255.                     <li class="nav-item">
  1256.                         <a class="nav-link" href="#urlUploader" class="js-url-upload" data-target="#urlUploader"><i class="fa fa-link"></i> Upload from URL</a>
  1257.                     </li>
  1258.                 </ul>
  1259.             </div>
  1260.             <div class="card-body">
  1261.                 <p class="card-text">
  1262.                     <a href="?p=<?php echo FM_PATH ?>" class="float-right"><i class="fa fa-chevron-circle-left go-back"></i> <?php echo lng('Back')?></a>
  1263.                     <?php echo lng('DestinationFolder') ?><?php echo fm_enc(fm_convert_win(FM_PATH)) ?>
  1264.                 </p>
  1265.  
  1266.                 <form action="<?php echo htmlspecialchars(FM_SELF_URL) . '?p=' . fm_enc(FM_PATH) ?>" class="dropzone card-tabs-container" id="fileUploader" enctype="multipart/form-data">
  1267.                     <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  1268.                     <input type="hidden" name="fullpath" id="fullpath" value="<?php echo fm_enc(FM_PATH) ?>">
  1269.                     <div class="fallback">
  1270.                         <input name="file" type="file" multiple/>
  1271.                     </div>
  1272.                 </form>
  1273.  
  1274.                 <div class="upload-url-wrapper card-tabs-container hidden" id="urlUploader">
  1275.                     <form id="js-form-url-upload" class="form-inline" onsubmit="return upload_from_url(this);" method="POST" action="">
  1276.                         <input type="hidden" name="type" value="upload" aria-label="hidden" aria-hidden="true">
  1277.                         <input type="url" placeholder="URL" name="uploadurl" required class="form-control" style="width: 80%">
  1278.                         <button type="submit" class="btn btn-primary ml-3"><?php echo lng('Upload') ?></button>
  1279.                         <div class="lds-facebook"><div></div><div></div><div></div></div>
  1280.                     </form>
  1281.                     <div id="js-url-upload__list" class="col-9 mt-3"></div>
  1282.                 </div>
  1283.             </div>
  1284.         </div>
  1285.     </div>
  1286.     <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/min/dropzone.min.js"></script>
  1287.     <script>
  1288.         Dropzone.options.fileUploader = {
  1289.             chunking: true,
  1290.             chunkSize: 10000000,
  1291.             forceChunking: true,
  1292.             retryChunks: true,
  1293.             retryChunksLimit: 3,
  1294.             parallelUploads: 1, // does not support more than 1!
  1295.             timeout: 120000,
  1296.             maxFilesize: 10000000000,
  1297.             acceptedFiles : "<?php echo getUploadExt() ?>",
  1298.             init: function () {
  1299.                 this.on("sending", function (file, xhr, formData) {
  1300.                     let _path = (file.fullPath) ? file.fullPath : file.name;
  1301.                     document.getElementById("fullpath").value = _path;
  1302.                     xhr.ontimeout = (function() {
  1303.                         toast('Error: Server Timeout');
  1304.                     });
  1305.                 }).on("success", function (res) {
  1306.                     let _response = JSON.parse(res.xhr.response);
  1307.  
  1308.                     if(_response.status == "error") {
  1309.                         toast(_response.info);
  1310.                     }
  1311.  
  1312.                 }).on("error", function(file, response) {
  1313.                     toast(response);
  1314.                 });
  1315.             }
  1316.         }
  1317.     </script>
  1318.     <?php
  1319.     fm_show_footer();
  1320.     exit;
  1321. }
  1322.  
  1323. // copy form POST
  1324. if (isset($_POST['copy']) && !FM_READONLY) {
  1325.     $copy_files = isset($_POST['file']) ? $_POST['file'] : null;
  1326.     if (!is_array($copy_files) || empty($copy_files)) {
  1327.         fm_set_msg(lng('Nothing selected'), 'alert');
  1328.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1329.     }
  1330.  
  1331.     fm_show_header(); // HEADER
  1332.     fm_show_nav_path(FM_PATH); // current path
  1333.     ?>
  1334.     <div class="path">
  1335.         <div class="card <?php echo fm_get_theme(); ?>">
  1336.             <div class="card-header">
  1337.                 <h6><?php echo lng('Copying') ?></h6>
  1338.             </div>
  1339.             <div class="card-body">
  1340.                 <form action="" method="post">
  1341.                     <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  1342.                     <input type="hidden" name="finish" value="1">
  1343.                     <?php
  1344.                     foreach ($copy_files as $cf) {
  1345.                         echo '<input type="hidden" name="file[]" value="' . fm_enc($cf) . '">' . PHP_EOL;
  1346.                     }
  1347.                     ?>
  1348.                     <p class="break-word"><?php echo lng('Files') ?>: <b><?php echo implode('</b>, <b>', $copy_files) ?></b></p>
  1349.                     <p class="break-word"><?php echo lng('SourceFolder') ?><?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?><br>
  1350.                         <label for="inp_copy_to"><?php echo lng('DestinationFolder') ?>:</label>
  1351.                         <?php echo FM_ROOT_PATH ?>/<input type="text" name="copy_to" id="inp_copy_to" value="<?php echo fm_enc(FM_PATH) ?>">
  1352.                     </p>
  1353.                     <p class="custom-checkbox custom-control"><input type="checkbox" name="move" value="1" id="js-move-files" class="custom-control-input"><label for="js-move-files" class="custom-control-label" style="vertical-align: sub"> <?php echo lng('Move') ?></label></p>
  1354.                     <p>
  1355.                         <button type="submit" class="btn btn-success"><i class="fa fa-check-circle"></i> <?php echo lng('Copy') ?></button>  
  1356.                         <b><a href="?p=<?php echo urlencode(FM_PATH) ?>" class="btn btn-outline-primary"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></a></b>
  1357.                     </p>
  1358.                 </form>
  1359.             </div>
  1360.         </div>
  1361.     </div>
  1362.     <?php
  1363.     fm_show_footer();
  1364.     exit;
  1365. }
  1366.  
  1367. // copy form
  1368. if (isset($_GET['copy']) && !isset($_GET['finish']) && !FM_READONLY) {
  1369.     $copy = $_GET['copy'];
  1370.     $copy = fm_clean_path($copy);
  1371.     if ($copy == '' || !file_exists(FM_ROOT_PATH . '/' . $copy)) {
  1372.         fm_set_msg(lng('File not found'), 'error');
  1373.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1374.     }
  1375.  
  1376.     fm_show_header(); // HEADER
  1377.     fm_show_nav_path(FM_PATH); // current path
  1378.     ?>
  1379.     <div class="path">
  1380.         <p><b>Copying</b></p>
  1381.         <p class="break-word">
  1382.             Source path: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . $copy)) ?><br>
  1383.             Destination folder: <?php echo fm_enc(fm_convert_win(FM_ROOT_PATH . '/' . FM_PATH)) ?>
  1384.         </p>
  1385.         <p>
  1386.             <b><a href="?p=<?php echo urlencode(FM_PATH) ?>&copy=<?php echo urlencode($copy) ?>&finish=1"><i class="fa fa-check-circle"></i> Copy</a></b>  
  1387.             <b><a 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>  
  1388.             <b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="fa fa-times-circle"></i> Cancel</a></b>
  1389.         </p>
  1390.         <p><i><?php echo lng('Select folder') ?></i></p>
  1391.         <ul class="folders break-word">
  1392.             <?php
  1393.             if ($parent !== false) {
  1394.                 ?>
  1395.                 <li><a href="?p=<?php echo urlencode($parent) ?>&copy=<?php echo urlencode($copy) ?>"><i class="fa fa-chevron-circle-left"></i> ..</a></li>
  1396.                 <?php
  1397.             }
  1398.             foreach ($folders as $f) {
  1399.                 ?>
  1400.                 <li>
  1401.                     <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>
  1402.                 <?php
  1403.             }
  1404.             ?>
  1405.         </ul>
  1406.     </div>
  1407.     <?php
  1408.     fm_show_footer();
  1409.     exit;
  1410. }
  1411.  
  1412. if (isset($_GET['settings']) && !FM_READONLY) {
  1413.     fm_show_header(); // HEADER
  1414.     fm_show_nav_path(FM_PATH); // current path
  1415.     global $cfg, $lang, $lang_list;
  1416.     ?>
  1417.  
  1418.     <div class="col-md-8 offset-md-2 pt-3">
  1419.         <div class="card mb-2 <?php echo fm_get_theme(); ?>">
  1420.             <h6 class="card-header">
  1421.                 <i class="fa fa-cog"></i>  <?php echo lng('Settings') ?>
  1422.                 <a href="?p=<?php echo FM_PATH ?>" class="float-right"><i class="fa fa-window-close"></i> <?php echo lng('Cancel')?></a>
  1423.             </h6>
  1424.             <div class="card-body">
  1425.                 <form id="js-settings-form" action="" method="post" data-type="ajax" onsubmit="return save_settings(this)">
  1426.                     <input type="hidden" name="type" value="settings" aria-label="hidden" aria-hidden="true">
  1427.                     <div class="form-group row">
  1428.                         <label for="js-language" class="col-sm-3 col-form-label"><?php echo lng('Language') ?></label>
  1429.                         <div class="col-sm-5">
  1430.                             <select class="form-control" id="js-language" name="js-language">
  1431.                                 <?php
  1432.                                 function getSelected($l) {
  1433.                                     global $lang;
  1434.                                     return ($lang == $l) ? 'selected' : '';
  1435.                                 }
  1436.                                 foreach ($lang_list as $k => $v) {
  1437.                                     echo "<option value='$k' ".getSelected($k).">$v</option>";
  1438.                                 }
  1439.                                 ?>
  1440.                             </select>
  1441.                         </div>
  1442.                     </div>
  1443.                     <?php
  1444.                     //get ON/OFF and active class
  1445.                     function getChecked($conf, $val, $txt) {
  1446.                         if($conf== 1 && $val ==1) {
  1447.                             return $txt;
  1448.                         } else if($conf == '' && $val == '') {
  1449.                             return $txt;
  1450.                         } else {
  1451.                             return '';
  1452.                         }
  1453.                     }
  1454.                     ?>
  1455.                     <div class="form-group row">
  1456.                         <label for="js-err-rpt-1" class="col-sm-3 col-form-label"><?php echo lng('ErrorReporting') ?></label>
  1457.                         <div class="col-sm-9">
  1458.                             <div class="btn-group btn-group-toggle" data-toggle="buttons">
  1459.                                 <label class="btn btn-secondary <?php echo getChecked($report_errors, 1, 'active') ?>">
  1460.                                     <input type="radio" name="js-error-report" id="js-err-rpt-1" autocomplete="off" value="true" <?php echo getChecked($report_errors, 1, 'checked') ?> > ON
  1461.                                 </label>
  1462.                                 <label class="btn btn-secondary <?php echo getChecked($report_errors, '', 'active') ?>">
  1463.                                     <input type="radio" name="js-error-report" id="js-err-rpt-0" autocomplete="off" value="false" <?php echo getChecked($report_errors, '', 'checked') ?> > OFF
  1464.                                 </label>
  1465.                             </div>
  1466.                         </div>
  1467.                     </div>
  1468.  
  1469.                     <div class="form-group row">
  1470.                         <label for="js-hdn-1" class="col-sm-3 col-form-label"><?php echo lng('ShowHiddenFiles') ?></label>
  1471.                         <div class="col-sm-9">
  1472.                             <div class="btn-group btn-group-toggle" data-toggle="buttons">
  1473.                                 <label class="btn btn-secondary <?php echo getChecked($show_hidden_files, 1, 'active') ?>">
  1474.                                     <input type="radio" name="js-show-hidden" id="js-hdn-1" autocomplete="off" value="true" <?php echo getChecked($show_hidden_files, 1, 'checked') ?> > ON
  1475.                                 </label>
  1476.                                 <label class="btn btn-secondary <?php echo getChecked($show_hidden_files, '', 'active') ?>">
  1477.                                     <input type="radio" name="js-show-hidden" id="js-hdn-0" autocomplete="off" value="false" <?php echo getChecked($show_hidden_files, '', 'checked') ?> > OFF
  1478.                                 </label>
  1479.                             </div>
  1480.                         </div>
  1481.                     </div>
  1482.  
  1483.                     <div class="form-group row">
  1484.                         <label for="js-hid-1" class="col-sm-3 col-form-label"><?php echo lng('HideColumns') ?></label>
  1485.                         <div class="col-sm-9">
  1486.                             <div class="btn-group btn-group-toggle" data-toggle="buttons">
  1487.                                 <label class="btn btn-secondary <?php echo getChecked($hide_Cols, 1, 'active') ?>">
  1488.                                     <input type="radio" name="js-hide-cols" id="js-hid-1" autocomplete="off" value="true" <?php echo getChecked($hide_Cols, 1, 'checked') ?> > ON
  1489.                                 </label>
  1490.                                 <label class="btn btn-secondary <?php echo getChecked($hide_Cols, '', 'active') ?>">
  1491.                                     <input type="radio" name="js-hide-cols" id="js-hid-0" autocomplete="off" value="false" <?php echo getChecked($hide_Cols, '', 'checked') ?> > OFF
  1492.                                 </label>
  1493.                             </div>
  1494.                         </div>
  1495.                     </div>
  1496.  
  1497.                     <div class="form-group row">
  1498.                         <label for="js-dir-1" class="col-sm-3 col-form-label"><?php echo lng('CalculateFolderSize') ?></label>
  1499.                         <div class="col-sm-9">
  1500.                             <div class="btn-group btn-group-toggle" data-toggle="buttons">
  1501.                                 <label class="btn btn-secondary <?php echo getChecked($calc_folder, 1, 'active') ?>">
  1502.                                     <input type="radio" name="js-calc-folder" id="js-dir-1" autocomplete="off" value="true" <?php echo getChecked($calc_folder, 1, 'checked') ?> > ON
  1503.                                 </label>
  1504.                                 <label class="btn btn-secondary <?php echo getChecked($calc_folder, '', 'active') ?>">
  1505.                                     <input type="radio" name="js-calc-folder" id="js-dir-0" autocomplete="off" value="false" <?php echo getChecked($calc_folder, '', 'checked') ?> > OFF
  1506.                                 </label>
  1507.                             </div>
  1508.                         </div>
  1509.                     </div>
  1510.  
  1511.                     <div class="form-group row">
  1512.                         <label for="js-3-1" class="col-sm-3 col-form-label"><?php echo lng('Theme') ?></label>
  1513.                         <div class="col-sm-5">
  1514.                             <select class="form-control" id="js-3-0" name="js-theme-3" style="width:100px;">
  1515.                          <option value='light' <?php if($theme == "light"){echo "selected";} ?>><?php echo lng('light') ?></option>
  1516.                          <option value='dark' <?php if($theme == "dark"){echo "selected";} ?>><?php echo lng('dark') ?></option>
  1517.                             </select>
  1518.                         </div>
  1519.                     </div>
  1520.  
  1521.                     <div class="form-group row">
  1522.                         <div class="col-sm-10">
  1523.                             <button type="submit" class="btn btn-success"> <i class="fa fa-check-circle"></i> <?php echo lng('Save'); ?></button>
  1524.                         </div>
  1525.                     </div>
  1526.  
  1527.                 </form>
  1528.             </div>
  1529.         </div>
  1530.     </div>
  1531.     <?php
  1532.     fm_show_footer();
  1533.     exit;
  1534. }
  1535.  
  1536. if (isset($_GET['help'])) {
  1537.     fm_show_header(); // HEADER
  1538.     fm_show_nav_path(FM_PATH); // current path
  1539.     global $cfg, $lang;
  1540.     ?>
  1541.  
  1542.     <div class="col-md-8 offset-md-2 pt-3">
  1543.         <div class="card mb-2 <?php echo fm_get_theme(); ?>">
  1544.             <h6 class="card-header">
  1545.                 <i class="fa fa-exclamation-circle"></i> <?php echo lng('Help') ?>
  1546.                 <a href="?p=<?php echo FM_PATH ?>" class="float-right"><i class="fa fa-window-close"></i> <?php echo lng('Cancel')?></a>
  1547.             </h6>
  1548.             <div class="card-body">
  1549.                 <div class="row">
  1550.                     <div class="col-xs-12 col-sm-6">
  1551.                         <p><h3><a href="https://github.com/prasathmani/tinyfilemanager" target="_blank" class="app-v-title"> droped <?php echo VERSION; ?></a></h3></p>
  1552.                         <p>Author: Prasath Mani</p>
  1553.                         <p>Mail Us: <a href="mailto:[email protected]">ccpprogrammers[at]gmail.com</a> </p>
  1554.                     </div>
  1555.                     <div class="col-xs-12 col-sm-6">
  1556.                         <div class="card">
  1557.                             <ul class="list-group list-group-flush">
  1558.                                 <li class="list-group-item"><a href="https://github.com/prasathmani/tinyfilemanager/wiki" target="_blank"><i class="fa fa-question-circle"></i> <?php echo lng('Help Documents') ?> </a> </li>
  1559.                                 <li class="list-group-item"><a href="https://github.com/prasathmani/tinyfilemanager/issues" target="_blank"><i class="fa fa-bug"></i> <?php echo lng('Report Issue') ?></a></li>
  1560.                                 <?php if(!FM_READONLY) { ?>
  1561.                                 <li class="list-group-item"><a href="javascript:show_new_pwd();"><i class="fa fa-lock"></i> <?php echo lng('Generate new password hash') ?></a></li>
  1562.                                 <?php } ?>
  1563.                             </ul>
  1564.                         </div>
  1565.                     </div>
  1566.                 </div>
  1567.                 <div class="row js-new-pwd hidden mt-2">
  1568.                     <div class="col-12">
  1569.                         <form class="form-inline" onsubmit="return new_password_hash(this)" method="POST" action="">
  1570.                             <input type="hidden" name="type" value="pwdhash" aria-label="hidden" aria-hidden="true">
  1571.                             <div class="form-group mb-2">
  1572.                                 <label for="staticEmail2"><?php echo lng('Generate new password hash') ?></label>
  1573.                             </div>
  1574.                             <div class="form-group mx-sm-3 mb-2">
  1575.                                 <label for="inputPassword2" class="sr-only"><?php echo lng('Password') ?></label>
  1576.                                 <input type="text" class="form-control btn-sm" id="inputPassword2" name="inputPassword2" placeholder="<?php echo lng('Password') ?>" required>
  1577.                             </div>
  1578.                             <button type="submit" class="btn btn-success btn-sm mb-2"><?php echo lng('Generate') ?></button>
  1579.                         </form>
  1580.                         <textarea class="form-control" rows="2" readonly id="js-pwd-result"></textarea>
  1581.                     </div>
  1582.                 </div>
  1583.             </div>
  1584.         </div>
  1585.     </div>
  1586.     <?php
  1587.     fm_show_footer();
  1588.     exit;
  1589. }
  1590.  
  1591. // file viewer
  1592. if (isset($_GET['view'])) {
  1593.     $file = $_GET['view'];
  1594.     $quickView = (isset($_GET['quickView']) && $_GET['quickView'] == 1) ? true : false;
  1595.     $file = fm_clean_path($file, false);
  1596.     $file = str_replace('/', '', $file);
  1597.     if ($file == '' || !is_file($path . '/' . $file) || in_array($file, $GLOBALS['exclude_items'])) {
  1598.         fm_set_msg(lng('File not found'), 'error');
  1599.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1600.     }
  1601.  
  1602.     if(!$quickView) {
  1603.         fm_show_header(); // HEADER
  1604.         fm_show_nav_path(FM_PATH); // current path
  1605.     }
  1606.  
  1607.     $file_url = FM_ROOT_URL . fm_convert_win((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file);
  1608.     $file_path = $path . '/' . $file;
  1609.  
  1610.     $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
  1611.     $mime_type = fm_get_mime_type($file_path);
  1612.     $filesize_raw = fm_get_size($file_path);
  1613.     $filesize = fm_get_filesize($filesize_raw);
  1614.  
  1615.     $is_zip = false;
  1616.     $is_gzip = false;
  1617.     $is_image = false;
  1618.     $is_audio = false;
  1619.     $is_video = false;
  1620.     $is_text = false;
  1621.     $is_onlineViewer = false;
  1622.  
  1623.     $view_title = 'File';
  1624.     $filenames = false; // for zip
  1625.     $content = ''; // for text
  1626.     $online_viewer = strtolower(FM_DOC_VIEWER);
  1627.  
  1628.     if($online_viewer && $online_viewer !== 'false' && in_array($ext, fm_get_onlineViewer_exts())){
  1629.         $is_onlineViewer = true;
  1630.     }
  1631.     elseif ($ext == 'zip' || $ext == 'tar') {
  1632.         $is_zip = true;
  1633.         $view_title = 'Archive';
  1634.         $filenames = fm_get_zif_info($file_path, $ext);
  1635.     } elseif (in_array($ext, fm_get_image_exts())) {
  1636.         $is_image = true;
  1637.         $view_title = 'Image';
  1638.     } elseif (in_array($ext, fm_get_audio_exts())) {
  1639.         $is_audio = true;
  1640.         $view_title = 'Audio';
  1641.     } elseif (in_array($ext, fm_get_video_exts())) {
  1642.         $is_video = true;
  1643.         $view_title = 'Video';
  1644.     } elseif (in_array($ext, fm_get_text_exts()) || substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
  1645.         $is_text = true;
  1646.         $content = file_get_contents($file_path);
  1647.     }
  1648.  
  1649.     ?>
  1650.     <div class="row">
  1651.         <div class="col-12">
  1652.             <?php if(!$quickView) { ?>
  1653.                 <p class="break-word"><b><?php echo $view_title ?> "<?php echo fm_enc(fm_convert_win($file)) ?>"</b></p>
  1654.                 <p class="break-word">
  1655.                     Full path: <?php echo fm_enc(fm_convert_win($file_path)) ?><br>
  1656.                     File size: <?php echo ($filesize_raw <= 1000) ? "$filesize_raw bytes" : $filesize; ?><br>
  1657.                     MIME-type: <?php echo $mime_type ?><br>
  1658.                     <?php
  1659.                     // ZIP info
  1660.                     if (($is_zip || $is_gzip) && $filenames !== false) {
  1661.                         $total_files = 0;
  1662.                         $total_comp = 0;
  1663.                         $total_uncomp = 0;
  1664.                         foreach ($filenames as $fn) {
  1665.                             if (!$fn['folder']) {
  1666.                                 $total_files++;
  1667.                             }
  1668.                             $total_comp += $fn['compressed_size'];
  1669.                             $total_uncomp += $fn['filesize'];
  1670.                         }
  1671.                         ?>
  1672.                         Files in archive: <?php echo $total_files ?><br>
  1673.                         Total size: <?php echo fm_get_filesize($total_uncomp) ?><br>
  1674.                         Size in archive: <?php echo fm_get_filesize($total_comp) ?><br>
  1675.                         Compression: <?php echo round(($total_comp / max($total_uncomp, 1)) * 100) ?>%<br>
  1676.                         <?php
  1677.                     }
  1678.                     // Image info
  1679.                     if ($is_image) {
  1680.                         $image_size = getimagesize($file_path);
  1681.                         echo 'Image sizes: ' . (isset($image_size[0]) ? $image_size[0] : '0') . ' x ' . (isset($image_size[1]) ? $image_size[1] : '0') . '<br>';
  1682.                     }
  1683.                     // Text info
  1684.                     if ($is_text) {
  1685.                         $is_utf8 = fm_is_utf8($content);
  1686.                         if (function_exists('iconv')) {
  1687.                             if (!$is_utf8) {
  1688.                                 $content = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $content);
  1689.                             }
  1690.                         }
  1691.                         echo 'Charset: ' . ($is_utf8 'utf-8' : '8 bit') . '<br>';
  1692.                     }
  1693.                     ?>
  1694.                 </p>
  1695.                 <p>
  1696.                     <b><a href="?p=<?php echo urlencode(FM_PATH) ?>&dl=<?php echo urlencode($file) ?>"><i class="fa fa-cloud-download"></i> <?php echo lng('Download') ?></a></b>  
  1697.                     <b><a href="<?php echo fm_enc($file_url) ?>" target="_blank"><i class="fa fa-external-link-square"></i> <?php echo lng('Open') ?></a></b>
  1698.                      
  1699.                     <?php
  1700.                     // ZIP actions
  1701.                     if (!FM_READONLY && ($is_zip || $is_gzip) && $filenames !== false) {
  1702.                         $zip_name = pathinfo($file_path, PATHINFO_FILENAME);
  1703.                         ?>
  1704.                         <b><a href="?p=<?php echo urlencode(FM_PATH) ?>&unzip=<?php echo urlencode($file) ?>"><i class="fa fa-check-circle"></i> <?php echo lng('UnZip') ?></a></b>  
  1705.                         <b><a 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>
  1706.                                 <?php echo lng('UnZipToFolder') ?></a></b>  
  1707.                         <?php
  1708.                     }
  1709.                     if ($is_text && !FM_READONLY) {
  1710.                         ?>
  1711.                         <b><a href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&edit=<?php echo urlencode($file) ?>" class="edit-file"><i class="fa fa-pencil-square"></i> <?php echo lng('Edit') ?>
  1712.                             </a></b>  
  1713.                         <b><a href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&edit=<?php echo urlencode($file) ?>&env=ace"
  1714.                               class="edit-file"><i class="fa fa-pencil-square-o"></i> <?php echo lng('AdvancedEditor') ?>
  1715.                             </a></b>  
  1716.                     <?php } ?>
  1717.                     <b><a href="?p=<?php echo urlencode(FM_PATH) ?>"><i class="fa fa-chevron-circle-left go-back"></i> <?php echo lng('Back') ?></a></b>
  1718.                 </p>
  1719.                 <?php
  1720.             }
  1721.             if($is_onlineViewer) {
  1722.                 if($online_viewer == 'google') {
  1723.                     echo '<iframe src="https://docs.google.com/viewer?embedded=true&hl=en&url=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
  1724.                 } else if($online_viewer == 'microsoft') {
  1725.                     echo '<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
  1726.                 }
  1727.             } elseif ($is_zip) {
  1728.                 // ZIP content
  1729.                 if ($filenames !== false) {
  1730.                     echo '<code class="maxheight">';
  1731.                     foreach ($filenames as $fn) {
  1732.                         if ($fn['folder']) {
  1733.                             echo '<b>' . fm_enc($fn['name']) . '</b><br>';
  1734.                         } else {
  1735.                             echo $fn['name'] . ' (' . fm_get_filesize($fn['filesize']) . ')<br>';
  1736.                         }
  1737.                     }
  1738.                     echo '</code>';
  1739.                 } else {
  1740.                     echo '<p>'.lng('Error while fetching archive info').'</p>';
  1741.                 }
  1742.             } elseif ($is_image) {
  1743.                 // Image content
  1744.                 if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg', 'webp', 'avif'))) {
  1745.                     echo '<p><img src="' . fm_enc($file_url) . '" alt="" class="preview-img"></p>';
  1746.                 }
  1747.             } elseif ($is_audio) {
  1748.                 // Audio content
  1749.                 echo '<p><audio src="' . fm_enc($file_url) . '" controls preload="metadata"></audio></p>';
  1750.             } elseif ($is_video) {
  1751.                 // Video content
  1752.                 echo '<div class="preview-video"><video src="' . fm_enc($file_url) . '" width="640" height="360" controls preload="metadata"></video></div>';
  1753.             } elseif ($is_text) {
  1754.                 if (FM_USE_HIGHLIGHTJS) {
  1755.                     // highlight
  1756.                     $hljs_classes = array(
  1757.                         'shtml' => 'xml',
  1758.                         'htaccess' => 'apache',
  1759.                         'phtml' => 'php',
  1760.                         'lock' => 'json',
  1761.                         'svg' => 'xml',
  1762.                     );
  1763.                     $hljs_class = isset($hljs_classes[$ext]) ? 'lang-' . $hljs_classes[$ext] : 'lang-' . $ext;
  1764.                     if (empty($ext) || in_array(strtolower($file), fm_get_text_names()) || preg_match('#\.min\.(css|js)$#i', $file)) {
  1765.                         $hljs_class = 'nohighlight';
  1766.                     }
  1767.                     $content = '<pre class="with-hljs"><code class="' . $hljs_class . '">' . fm_enc($content) . '</code></pre>';
  1768.                 } elseif (in_array($ext, array('php', 'php4', 'php5', 'phtml', 'phps'))) {
  1769.                     // php highlight
  1770.                     $content = highlight_string($content, true);
  1771.                 } else {
  1772.                     $content = '<pre>' . fm_enc($content) . '</pre>';
  1773.                 }
  1774.                 echo $content;
  1775.             }
  1776.             ?>
  1777.         </div>
  1778.     </div>
  1779.     <?php
  1780.     if(!$quickView) {
  1781.         fm_show_footer();
  1782.     }
  1783.     exit;
  1784. }
  1785.  
  1786. // file editor
  1787. if (isset($_GET['edit'])) {
  1788.     $file = $_GET['edit'];
  1789.     $file = fm_clean_path($file, false);
  1790.     $file = str_replace('/', '', $file);
  1791.     if ($file == '' || !is_file($path . '/' . $file)) {
  1792.         fm_set_msg(lng('File not found'), 'error');
  1793.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1794.     }
  1795.     $editFile = ' : <i><b>'. $file. '</b></i>';
  1796.     header('X-XSS-Protection:0');
  1797.     fm_show_header(); // HEADER
  1798.     fm_show_nav_path(FM_PATH); // current path
  1799.  
  1800.     $file_url = FM_ROOT_URL . fm_convert_win((FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file);
  1801.     $file_path = $path . '/' . $file;
  1802.  
  1803.     // normal editer
  1804.     $isNormalEditor = true;
  1805.     if (isset($_GET['env'])) {
  1806.         if ($_GET['env'] == "ace") {
  1807.             $isNormalEditor = false;
  1808.         }
  1809.     }
  1810.  
  1811.     // Save File
  1812.     if (isset($_POST['savedata'])) {
  1813.         $writedata = $_POST['savedata'];
  1814.         $fd = fopen($file_path, "w");
  1815.         @fwrite($fd, $writedata);
  1816.         fclose($fd);
  1817.         fm_set_msg(lng('File Saved Successfully'));
  1818.     }
  1819.  
  1820.     $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
  1821.     $mime_type = fm_get_mime_type($file_path);
  1822.     $filesize = filesize($file_path);
  1823.     $is_text = false;
  1824.     $content = ''; // for text
  1825.  
  1826.     if (in_array($ext, fm_get_text_exts()) || substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
  1827.         $is_text = true;
  1828.         $content = file_get_contents($file_path);
  1829.     }
  1830.  
  1831.     ?>
  1832.     <div class="path">
  1833.         <div class="row">
  1834.             <div class="col-xs-12 col-sm-5 col-lg-6 pt-1">
  1835.                 <div class="btn-toolbar" role="toolbar">
  1836.                     <?php if (!$isNormalEditor) { ?>
  1837.                         <div class="btn-group js-ace-toolbar">
  1838.                             <button data-cmd="none" data-option="fullscreen" class="btn btn-sm btn-outline-secondary" id="js-ace-fullscreen" title="Fullscreen"><i class="fa fa-expand" title="Fullscreen"></i></button>
  1839.                             <button data-cmd="find" class="btn btn-sm btn-outline-secondary" id="js-ace-search" title="Search"><i class="fa fa-search" title="Search"></i></button>
  1840.                             <button data-cmd="undo" class="btn btn-sm btn-outline-secondary" id="js-ace-undo" title="Undo"><i class="fa fa-undo" title="Undo"></i></button>
  1841.                             <button data-cmd="redo" class="btn btn-sm btn-outline-secondary" id="js-ace-redo" title="Redo"><i class="fa fa-repeat" title="Redo"></i></button>
  1842.                             <button data-cmd="none" data-option="wrap" class="btn btn-sm btn-outline-secondary" id="js-ace-wordWrap" title="Word Wrap"><i class="fa fa-text-width" title="Word Wrap"></i></button>
  1843.                             <button data-cmd="none" data-option="help" class="btn btn-sm btn-outline-secondary" id="js-ace-goLine" title="Help"><i class="fa fa-question" title="Help"></i></button>
  1844.                             <select id="js-ace-mode" data-type="mode" title="Select Document Type" class="btn-outline-secondary border-left-0 d-none d-md-block"><option>-- Select Mode --</option></select>
  1845.                             <select id="js-ace-theme" data-type="theme" title="Select Theme" class="btn-outline-secondary border-left-0 d-none d-lg-block"><option>-- Select Theme --</option></select>
  1846.                             <select id="js-ace-fontSize" data-type="fontSize" title="Select Font Size" class="btn-outline-secondary border-left-0 d-none d-lg-block"><option>-- Select Font Size --</option></select>
  1847.                         </div>
  1848.                     <?php } ?>
  1849.                 </div>
  1850.             </div>
  1851.             <div class="edit-file-actions col-xs-12 col-sm-7 col-lg-6 text-right pt-1">
  1852.                 <a title="<?php echo lng('Back') ?>" class="btn btn-sm btn-outline-primary" href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&view=<?php echo urlencode($file) ?>"><i class="fa fa-reply-all"></i> <?php echo lng('Back') ?></a>
  1853.                 <a title="<?php echo lng('BackUp') ?>" class="btn btn-sm btn-outline-primary" href="javascript:void(0);" onclick="backup('<?php echo urlencode(trim(FM_PATH)) ?>','<?php echo urlencode($file) ?>')"><i class="fa fa-database"></i> <?php echo lng('BackUp') ?></a>
  1854.                 <?php if ($is_text) { ?>
  1855.                     <?php if ($isNormalEditor) { ?>
  1856.                         <a title="Advanced" class="btn btn-sm btn-outline-primary" href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&edit=<?php echo urlencode($file) ?>&env=ace"><i class="fa fa-pencil-square-o"></i> <?php echo lng('AdvancedEditor') ?></a>
  1857.                         <button type="button" class="btn btn-sm btn-outline-primary" name="Save" data-url="<?php echo fm_enc($file_url) ?>" onclick="edit_save(this,'nrl')"><i class="fa fa-floppy-o"></i> Save
  1858.                         </button>
  1859.                     <?php } else { ?>
  1860.                         <a title="Plain Editor" class="btn btn-sm btn-outline-primary" href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&edit=<?php echo urlencode($file) ?>"><i class="fa fa-text-height"></i> <?php echo lng('NormalEditor') ?></a>
  1861.                         <button type="button" class="btn btn-sm btn-outline-primary" name="Save" data-url="<?php echo fm_enc($file_url) ?>" onclick="edit_save(this,'ace')"><i class="fa fa-floppy-o"></i> <?php echo lng('Save') ?>
  1862.                         </button>
  1863.                     <?php } ?>
  1864.                 <?php } ?>
  1865.             </div>
  1866.         </div>
  1867.         <?php
  1868.         if ($is_text && $isNormalEditor) {
  1869.             echo '<textarea class="mt-2" id="normal-editor" rows="33" cols="120" style="width: 99.5%;">' . htmlspecialchars($content) . '</textarea>';
  1870.         } elseif ($is_text) {
  1871.             echo '<div id="editor" contenteditable="true">' . htmlspecialchars($content) . '</div>';
  1872.         } else {
  1873.             fm_set_msg(lng('FILE EXTENSION HAS NOT SUPPORTED'), 'error');
  1874.         }
  1875.         ?>
  1876.     </div>
  1877.     <?php
  1878.     fm_show_footer();
  1879.     exit;
  1880. }
  1881.  
  1882. // chmod (not for Windows)
  1883. if (isset($_GET['chmod']) && !FM_READONLY && !FM_IS_WIN) {
  1884.     $file = $_GET['chmod'];
  1885.     $file = fm_clean_path($file);
  1886.     $file = str_replace('/', '', $file);
  1887.     if ($file == '' || (!is_file($path . '/' . $file) && !is_dir($path . '/' . $file))) {
  1888.         fm_set_msg(lng('File not found'), 'error');
  1889.         fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
  1890.     }
  1891.  
  1892.     fm_show_header(); // HEADER
  1893.     fm_show_nav_path(FM_PATH); // current path
  1894.  
  1895.     $file_url = FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $file;
  1896.     $file_path = $path . '/' . $file;
  1897.  
  1898.     $mode = fileperms($path . '/' . $file);
  1899.  
  1900.     ?>
  1901.     <div class="path">
  1902.         <div class="card mb-2 <?php echo fm_get_theme(); ?>">
  1903.             <h6 class="card-header">
  1904.                 <?php echo lng('ChangePermissions') ?>
  1905.             </h6>
  1906.             <div class="card-body">
  1907.                 <p class="card-text">
  1908.                     Full path: <?php echo $file_path ?><br>
  1909.                 </p>
  1910.                 <form action="" method="post">
  1911.                     <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  1912.                     <input type="hidden" name="chmod" value="<?php echo fm_enc($file) ?>">
  1913.  
  1914.                     <table class="table compact-table <?php echo fm_get_theme(); ?>">
  1915.                         <tr>
  1916.                             <td></td>
  1917.                             <td><b><?php echo lng('Owner') ?></b></td>
  1918.                             <td><b><?php echo lng('Group') ?></b></td>
  1919.                             <td><b><?php echo lng('Other') ?></b></td>
  1920.                         </tr>
  1921.                         <tr>
  1922.                             <td style="text-align: right"><b><?php echo lng('Read') ?></b></td>
  1923.                             <td><label><input type="checkbox" name="ur" value="1"<?php echo ($mode & 00400) ? ' checked' : '' ?>></label></td>
  1924.                             <td><label><input type="checkbox" name="gr" value="1"<?php echo ($mode & 00040) ? ' checked' : '' ?>></label></td>
  1925.                             <td><label><input type="checkbox" name="or" value="1"<?php echo ($mode & 00004) ? ' checked' : '' ?>></label></td>
  1926.                         </tr>
  1927.                         <tr>
  1928.                             <td style="text-align: right"><b><?php echo lng('Write') ?></b></td>
  1929.                             <td><label><input type="checkbox" name="uw" value="1"<?php echo ($mode & 00200) ? ' checked' : '' ?>></label></td>
  1930.                             <td><label><input type="checkbox" name="gw" value="1"<?php echo ($mode & 00020) ? ' checked' : '' ?>></label></td>
  1931.                             <td><label><input type="checkbox" name="ow" value="1"<?php echo ($mode & 00002) ? ' checked' : '' ?>></label></td>
  1932.                         </tr>
  1933.                         <tr>
  1934.                             <td style="text-align: right"><b><?php echo lng('Execute') ?></b></td>
  1935.                             <td><label><input type="checkbox" name="ux" value="1"<?php echo ($mode & 00100) ? ' checked' : '' ?>></label></td>
  1936.                             <td><label><input type="checkbox" name="gx" value="1"<?php echo ($mode & 00010) ? ' checked' : '' ?>></label></td>
  1937.                             <td><label><input type="checkbox" name="ox" value="1"<?php echo ($mode & 00001) ? ' checked' : '' ?>></label></td>
  1938.                         </tr>
  1939.                     </table>
  1940.  
  1941.                     <p>
  1942.                         <button type="submit" class="btn btn-success"><i class="fa fa-check-circle"></i> <?php echo lng('Change') ?></button>  
  1943.                         <b><a href="?p=<?php echo urlencode(FM_PATH) ?>" class="btn btn-outline-primary"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></a></b>
  1944.                     </p>
  1945.                 </form>
  1946.             </div>
  1947.         </div>
  1948.     </div>
  1949.     <?php
  1950.     fm_show_footer();
  1951.     exit;
  1952. }
  1953.  
  1954. //--- FILEMANAGER MAIN
  1955. fm_show_header(); // HEADER
  1956. fm_show_nav_path(FM_PATH); // current path
  1957.  
  1958. // messages
  1959. fm_show_message();
  1960.  
  1961. $num_files = count($files);
  1962. $num_folders = count($folders);
  1963. $all_files_size = 0;
  1964. $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white";
  1965. ?>
  1966. <form action="" method="post" class="pt-3">
  1967.     <input type="hidden" name="p" value="<?php echo fm_enc(FM_PATH) ?>">
  1968.     <input type="hidden" name="group" value="1">
  1969.     <div class="table-responsive">
  1970.         <table class="table table-bordered table-hover table-sm <?php echo $tableTheme; ?>" id="main-table">
  1971.             <thead class="thead-white">
  1972.             <tr>
  1973.                 <?php if (!FM_READONLY): ?>
  1974.                     <th style="width:3%" class="custom-checkbox-header">
  1975.                         <div class="custom-control custom-checkbox">
  1976.                             <input type="checkbox" class="custom-control-input" id="js-select-all-items" onclick="checkbox_toggle()">
  1977.                             <label class="custom-control-label" for="js-select-all-items"></label>
  1978.                         </div>
  1979.                     </th><?php endif; ?>
  1980.                 <th><?php echo lng('Name') ?></th>
  1981.                 <th><?php echo lng('Size') ?></th>
  1982.                 <th><?php echo lng('Modified') ?></th>
  1983.                 <?php if (!FM_IS_WIN && !$hide_Cols): ?>
  1984.                     <th><?php echo lng('Perms') ?></th>
  1985.                     <th><?php echo lng('Owner') ?></th><?php endif; ?>
  1986.                 <th><?php echo lng('Actions') ?></th>
  1987.             </tr>
  1988.             </thead>
  1989.             <?php
  1990.             // link to parent folder
  1991.             if ($parent !== false) {
  1992.                 ?>
  1993.                 <tr><?php if (!FM_READONLY): ?>
  1994.                     <td class="nosort"></td><?php endif; ?>
  1995.                     <td class="border-0" data-sort><a href="?p=<?php echo urlencode($parent) ?>"><i class="fa fa-chevron-circle-left go-back"></i> ..</a></td>
  1996.                     <td class="border-0" data-order></td>
  1997.                     <td class="border-0" data-order></td>
  1998.                     <td class="border-0"></td>
  1999.                     <?php if (!FM_IS_WIN && !$hide_Cols) { ?>
  2000.                         <td class="border-0"></td>
  2001.                         <td class="border-0"></td>
  2002.                     <?php } ?>
  2003.                 </tr>
  2004.                 <?php
  2005.             }
  2006.             $ii = 3399;
  2007.             foreach ($folders as $f) {
  2008.                 $is_link = is_link($path . '/' . $f);
  2009.                 $img = $is_link 'icon-link_folder' : 'fa fa-folder-o';
  2010.                 $modif_raw = filemtime($path . '/' . $f);
  2011.                 $modif = date(FM_DATETIME_FORMAT, $modif_raw);
  2012.                 if ($calc_folder) {
  2013.                     try {
  2014.                         $filesize_raw = fm_get_directorysize($path . '/' . $f);
  2015.                         $filesize = fm_get_filesize($filesize_raw);
  2016.                     } catch(Exception $e) {
  2017.                         $filesize_raw = "";
  2018.                         $filesize = lng('Folder');
  2019.                     }
  2020.                 }
  2021.                 else {
  2022.                     $filesize_raw = "";
  2023.                     $filesize = lng('Folder');
  2024.                 }
  2025.                 $perms = substr(decoct(fileperms($path . '/' . $f)), -4);
  2026.                 if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
  2027.                     $owner = posix_getpwuid(fileowner($path . '/' . $f));
  2028.                     $group = posix_getgrgid(filegroup($path . '/' . $f));
  2029.                 } else {
  2030.                     $owner = array('name' => '?');
  2031.                     $group = array('name' => '?');
  2032.                 }
  2033.                 ?>
  2034.                 <tr>
  2035.                     <?php if (!FM_READONLY): ?>
  2036.                         <td class="custom-checkbox-td">
  2037.                         <div class="custom-control custom-checkbox">
  2038.                             <input type="checkbox" class="custom-control-input" id="<?php echo $ii ?>" name="file[]" value="<?php echo fm_enc($f) ?>">
  2039.                             <label class="custom-control-label" for="<?php echo $ii ?>"></label>
  2040.                         </div>
  2041.                         </td><?php endif; ?>
  2042.                     <td data-sort=<?php echo fm_convert_win(fm_enc($f)) ?>>
  2043.                         <div class="filename"><a href="?p=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="<?php echo $img ?>"></i> <?php echo fm_convert_win(fm_enc($f)) ?>
  2044.                             </a><?php echo($is_link ' → <i>' . readlink($path . '/' . $f) . '</i>' : '') ?></div>
  2045.                     </td>
  2046.                     <td data-order="a-<?php echo str_pad($filesize_raw, 18, "0", STR_PAD_LEFT);?>">
  2047.                         <?php echo $filesize; ?>
  2048.                     </td>
  2049.                     <td data-order="a-<?php echo $modif_raw;?>"><?php echo $modif ?></td>
  2050.                     <?php if (!FM_IS_WIN && !$hide_Cols): ?>
  2051.                         <td><?php if (!FM_READONLY): ?><a title="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; ?>
  2052.                         </td>
  2053.                         <td><?php echo $owner['name'] . ':' . $group['name'] ?></td>
  2054.                     <?php endif; ?>
  2055.                     <td class="inline-actions"><?php if (!FM_READONLY): ?>
  2056.                             <a title="<?php echo lng('Delete')?>" href="?p=<?php echo urlencode(FM_PATH) ?>&del=<?php echo urlencode($f) ?>" onclick="return confirm('<?php echo lng('Delete').' '.lng('Folder').'?'; ?>\n \n ( <?php echo urlencode($f) ?> )');"> <i class="fa fa-trash-o" aria-hidden="true"></i></a>
  2057.                             <a title="<?php echo lng('Rename')?>" href="#" onclick="rename('<?php echo fm_enc(addslashes(FM_PATH)) ?>', '<?php echo fm_enc(addslashes($f)) ?>');return false;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
  2058.                             <a title="<?php echo lng('CopyTo')?>..." href="?p=&copy=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="fa fa-files-o" aria-hidden="true"></i></a>
  2059.                         <?php endif; ?>
  2060.                         <a title="<?php echo lng('DirectLink')?>" href="<?php echo fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f . '/') ?>" target="_blank"><i class="fa fa-link" aria-hidden="true"></i></a>
  2061.                     </td>
  2062.                 </tr>
  2063.                 <?php
  2064.                 flush();
  2065.                 $ii++;
  2066.             }
  2067.             $ik = 6070;
  2068.             foreach ($files as $f) {
  2069.                 $is_link = is_link($path . '/' . $f);
  2070.                 $img = $is_link 'fa fa-file-text-o' : fm_get_file_icon_class($path . '/' . $f);
  2071.                 $modif_raw = filemtime($path . '/' . $f);
  2072.                 $modif = date(FM_DATETIME_FORMAT, $modif_raw);
  2073.                 $filesize_raw = fm_get_size($path . '/' . $f);
  2074.                 $filesize = fm_get_filesize($filesize_raw);
  2075.                 $filelink = '?p=' . urlencode(FM_PATH) . '&view=' . urlencode($f);
  2076.                 $all_files_size += $filesize_raw;
  2077.                 $perms = substr(decoct(fileperms($path . '/' . $f)), -4);
  2078.                 if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
  2079.                     $owner = posix_getpwuid(fileowner($path . '/' . $f));
  2080.                     $group = posix_getgrgid(filegroup($path . '/' . $f));
  2081.                 } else {
  2082.                     $owner = array('name' => '?');
  2083.                     $group = array('name' => '?');
  2084.                 }
  2085.                 ?>
  2086.                 <tr>
  2087.                     <?php if (!FM_READONLY): ?>
  2088.                         <td class="custom-checkbox-td">
  2089.                         <div class="custom-control custom-checkbox">
  2090.                             <input type="checkbox" class="custom-control-input" id="<?php echo $ik ?>" name="file[]" value="<?php echo fm_enc($f) ?>">
  2091.                             <label class="custom-control-label" for="<?php echo $ik ?>"></label>
  2092.                         </div>
  2093.                         </td><?php endif; ?>
  2094.                     <td data-sort=<?php echo fm_enc($f) ?>>
  2095.                         <div class="filename">
  2096.                         <?php
  2097.                            if (in_array(strtolower(pathinfo($f, PATHINFO_EXTENSION)), array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'ico', 'svg', 'webp', 'avif'))): ?>
  2098.                                 <?php $imagePreview = fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f); ?>
  2099.                                 <a href="<?php echo $filelink ?>" data-preview-image="<?php echo $imagePreview ?>" title="<?php echo fm_enc($f) ?>">
  2100.                            <?php else: ?>
  2101.                                 <a href="<?php echo $filelink ?>" title="<?php echo $f ?>">
  2102.                             <?php endif; ?>
  2103.                                     <i class="<?php echo $img ?>"></i> <?php echo fm_convert_win(fm_enc($f)) ?>
  2104.                                 </a>
  2105.                                 <?php echo($is_link ' → <i>' . readlink($path . '/' . $f) . '</i>' : '') ?>
  2106.                         </div>
  2107.                     </td>
  2108.                     <td data-order="b-<?php echo str_pad($filesize_raw, 18, "0", STR_PAD_LEFT); ?>"><span title="<?php printf('%s bytes', $filesize_raw) ?>">
  2109.                         <?php echo $filesize; ?>
  2110.                         </span></td>
  2111.                     <td data-order="b-<?php echo $modif_raw;?>"><?php echo $modif ?></td>
  2112.                     <?php if (!FM_IS_WIN && !$hide_Cols): ?>
  2113.                         <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; ?>
  2114.                         </td>
  2115.                         <td><?php echo fm_enc($owner['name'] . ':' . $group['name']) ?></td>
  2116.                     <?php endif; ?>
  2117.                     <td class="inline-actions">
  2118.                         <a title="<?php echo lng('Preview') ?>" href="<?php echo $filelink.'&quickView=1'; ?>" data-toggle="lightbox" data-gallery="tiny-gallery" data-title="<?php echo fm_convert_win(fm_enc($f)) ?>" data-max-width="100%" data-width="100%"><i class="fa fa-eye"></i></a>
  2119.                         <?php if (!FM_READONLY): ?>
  2120.                             <a title="<?php echo lng('Delete') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&del=<?php echo urlencode($f) ?>" onclick="return confirm('<?php echo lng('Delete').' '.lng('File').'?'; ?>\n \n ( <?php echo urlencode($f) ?> )');"> <i class="fa fa-trash-o"></i></a>
  2121.                             <a title="<?php echo lng('Rename') ?>" href="#" onclick="rename('<?php echo fm_enc(addslashes(FM_PATH)) ?>', '<?php echo fm_enc(addslashes($f)) ?>');return false;"><i class="fa fa-pencil-square-o"></i></a>
  2122.                             <a title="<?php echo lng('CopyTo') ?>..."
  2123.                                href="?p=<?php echo urlencode(FM_PATH) ?>&copy=<?php echo urlencode(trim(FM_PATH . '/' . $f, '/')) ?>"><i class="fa fa-files-o"></i></a>
  2124.                         <?php endif; ?>
  2125.                         <a title="<?php echo lng('DirectLink') ?>" href="<?php echo fm_enc(FM_ROOT_URL . (FM_PATH != '' ? '/' . FM_PATH : '') . '/' . $f) ?>" target="_blank"><i class="fa fa-link"></i></a>
  2126.                         <a title="<?php echo lng('Download') ?>" href="?p=<?php echo urlencode(FM_PATH) ?>&dl=<?php echo urlencode($f) ?>"><i class="fa fa-download"></i></a>
  2127.                     </td>
  2128.                 </tr>
  2129.                 <?php
  2130.                 flush();
  2131.                 $ik++;
  2132.             }
  2133.  
  2134.             if (empty($folders) && empty($files)) {
  2135.                 ?>
  2136.                 <tfoot>
  2137.                     <tr><?php if (!FM_READONLY): ?>
  2138.                             <td></td><?php endif; ?>
  2139.                         <td colspan="<?php echo (!FM_IS_WIN && !$hide_Cols) ? '6' : '4' ?>"><em><?php echo lng('Folder is empty') ?></em></td>
  2140.                     </tr>
  2141.                 </tfoot>
  2142.                 <?php
  2143.             } else {
  2144.                 ?>
  2145.                 <tfoot>
  2146.                     <tr><?php if (!FM_READONLY): ?>
  2147.                             <td class="gray"></td><?php endif; ?>
  2148.                         <td class="gray" colspan="<?php echo (!FM_IS_WIN && !$hide_Cols) ? '6' : '4' ?>">
  2149.                             <?php echo lng('FullSize').': <span class="badge badge-light">'.fm_get_filesize($all_files_size).'</span>' ?>
  2150.                             <?php echo lng('File').': <span class="badge badge-light">'.$num_files.'</span>' ?>
  2151.                             <?php echo lng('Folder').': <span class="badge badge-light">'.$num_folders.'</span>' ?>
  2152.                             <?php if (function_exists('disk_free_space') && function_exists('disk_total_space')) { ?>
  2153.                             <?php echo lng('PartitionSize').': <span class="badge badge-light">'.fm_get_filesize(@disk_free_space($path)) .'</span> '.lng('FreeOf').' <span class="badge badge-light">'.fm_get_filesize(@disk_total_space($path)).'</span>'; ?>
  2154.                             <?php } ?>
  2155.                         </td>
  2156.                     </tr>
  2157.                 </tfoot>
  2158.                 <?php
  2159.             }
  2160.             ?>
  2161.         </table>
  2162.     </div>
  2163.  
  2164.     <div class="row">
  2165.         <?php if (!FM_READONLY): ?>
  2166.         <div class="col-xs-12 col-sm-9">
  2167.             <ul class="list-inline footer-action">
  2168.                 <li class="list-inline-item"> <a href="#/select-all" class="btn btn-small btn-outline-primary btn-2" onclick="select_all();return false;"><i class="fa fa-check-square"></i> <?php echo lng('SelectAll') ?> </a></li>
  2169.                 <li class="list-inline-item"><a href="#/unselect-all" class="btn btn-small btn-outline-primary btn-2" onclick="unselect_all();return false;"><i class="fa fa-window-close"></i> <?php echo lng('UnSelectAll') ?> </a></li>
  2170.                 <li class="list-inline-item"><a href="#/invert-all" class="btn btn-small btn-outline-primary btn-2" onclick="invert_all();return false;"><i class="fa fa-th-list"></i> <?php echo lng('InvertSelection') ?> </a></li>
  2171.                 <li class="list-inline-item"><input type="submit" class="hidden" name="delete" id="a-delete" value="Delete" onclick="return confirm('<?php echo lng('Delete selected files and folders?'); ?>')">
  2172.                     <a href="javascript:document.getElementById('a-delete').click();" class="btn btn-small btn-outline-primary btn-2"><i class="fa fa-trash"></i> <?php echo lng('Delete') ?> </a></li>
  2173.                 <li class="list-inline-item"><input type="submit" class="hidden" name="zip" id="a-zip" value="zip" onclick="return confirm('<?php echo lng('Create archive?'); ?>')">
  2174.                     <a href="javascript:document.getElementById('a-zip').click();" class="btn btn-small btn-outline-primary btn-2"><i class="fa fa-file-archive-o"></i> <?php echo lng('Zip') ?> </a></li>
  2175.                 <li class="list-inline-item"><input type="submit" class="hidden" name="tar" id="a-tar" value="tar" onclick="return confirm('<?php echo lng('Create archive?'); ?>')">
  2176.                     <a href="javascript:document.getElementById('a-tar').click();" class="btn btn-small btn-outline-primary btn-2"><i class="fa fa-file-archive-o"></i> <?php echo lng('Tar') ?> </a></li>
  2177.                 <li class="list-inline-item"><input type="submit" class="hidden" name="copy" id="a-copy" value="Copy">
  2178.                     <a href="javascript:document.getElementById('a-copy').click();" class="btn btn-small btn-outline-primary btn-2"><i class="fa fa-files-o"></i> <?php echo lng('Copy') ?> </a></li>
  2179.             </ul>
  2180.         </div>
  2181.         <div class="col-3 d-none d-sm-block"><a href="https://tinyfilemanager.github.io" target="_blank" class="float-right text-muted">droped <?php echo VERSION; ?></a></div>
  2182.         <?php else: ?>
  2183.             <div class="col-12"><a href="https://tinyfilemanager.github.io" target="_blank" class="float-right text-muted">droped <?php echo VERSION; ?></a></div>
  2184.         <?php endif; ?>
  2185.     </div>
  2186.  
  2187. </form>
  2188.  
  2189. <?php
  2190. fm_show_footer();
  2191.  
  2192. //--- END
  2193.  
  2194. // Functions
  2195.  
  2196. /**
  2197.  * Delete  file or folder (recursively)
  2198.  * @param string $path
  2199.  * @return bool
  2200.  */
  2201. function fm_rdelete($path)
  2202. {
  2203.     if (is_link($path)) {
  2204.         return unlink($path);
  2205.     } elseif (is_dir($path)) {
  2206.         $objects = scandir($path);
  2207.         $ok = true;
  2208.         if (is_array($objects)) {
  2209.             foreach ($objects as $file) {
  2210.                 if ($file != '.' && $file != '..') {
  2211.                     if (!fm_rdelete($path . '/' . $file)) {
  2212.                         $ok = false;
  2213.                     }
  2214.                 }
  2215.             }
  2216.         }
  2217.         return ($ok) ? rmdir($path) : false;
  2218.     } elseif (is_file($path)) {
  2219.         return unlink($path);
  2220.     }
  2221.     return false;
  2222. }
  2223.  
  2224. /**
  2225.  * Recursive chmod
  2226.  * @param string $path
  2227.  * @param int $filemode
  2228.  * @param int $dirmode
  2229.  * @return bool
  2230.  * @todo Will use in mass chmod
  2231.  */
  2232. function fm_rchmod($path, $filemode, $dirmode)
  2233. {
  2234.     if (is_dir($path)) {
  2235.         if (!chmod($path, $dirmode)) {
  2236.             return false;
  2237.         }
  2238.         $objects = scandir($path);
  2239.         if (is_array($objects)) {
  2240.             foreach ($objects as $file) {
  2241.                 if ($file != '.' && $file != '..') {
  2242.                     if (!fm_rchmod($path . '/' . $file, $filemode, $dirmode)) {
  2243.                         return false;
  2244.                     }
  2245.                 }
  2246.             }
  2247.         }
  2248.         return true;
  2249.     } elseif (is_link($path)) {
  2250.         return true;
  2251.     } elseif (is_file($path)) {
  2252.         return chmod($path, $filemode);
  2253.     }
  2254.     return false;
  2255. }
  2256.  
  2257. /**
  2258.  * Check the file extension which is allowed or not
  2259.  * @param string $filename
  2260.  * @return bool
  2261.  */
  2262. function fm_is_valid_ext($filename)
  2263. {
  2264.     $allowed = (FM_FILE_EXTENSION) ? explode(',', FM_FILE_EXTENSION) : false;
  2265.  
  2266.     $ext = pathinfo($filename, PATHINFO_EXTENSION);
  2267.     $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true;
  2268.  
  2269.     return ($isFileAllowed) ? true : false;
  2270. }
  2271.  
  2272. /**
  2273.  * Safely rename
  2274.  * @param string $old
  2275.  * @param string $new
  2276.  * @return bool|null
  2277.  */
  2278. function fm_rename($old, $new)
  2279. {
  2280.     $isFileAllowed = fm_is_valid_ext($new);
  2281.  
  2282.     if(!$isFileAllowed) return false;
  2283.  
  2284.     return (!file_exists($new) && file_exists($old)) ? rename($old, $new) : null;
  2285. }
  2286.  
  2287. /**
  2288.  * Copy file or folder (recursively).
  2289.  * @param string $path
  2290.  * @param string $dest
  2291.  * @param bool $upd Update files
  2292.  * @param bool $force Create folder with same names instead file
  2293.  * @return bool
  2294.  */
  2295. function fm_rcopy($path, $dest, $upd = true, $force = true)
  2296. {
  2297.     if (is_dir($path)) {
  2298.         if (!fm_mkdir($dest, $force)) {
  2299.             return false;
  2300.         }
  2301.         $objects = scandir($path);
  2302.         $ok = true;
  2303.         if (is_array($objects)) {
  2304.             foreach ($objects as $file) {
  2305.                 if ($file != '.' && $file != '..') {
  2306.                     if (!fm_rcopy($path . '/' . $file, $dest . '/' . $file)) {
  2307.                         $ok = false;
  2308.                     }
  2309.                 }
  2310.             }
  2311.         }
  2312.         return $ok;
  2313.     } elseif (is_file($path)) {
  2314.         return fm_copy($path, $dest, $upd);
  2315.     }
  2316.     return false;
  2317. }
  2318.  
  2319. /**
  2320.  * Safely create folder
  2321.  * @param string $dir
  2322.  * @param bool $force
  2323.  * @return bool
  2324.  */
  2325. function fm_mkdir($dir, $force)
  2326. {
  2327.     if (file_exists($dir)) {
  2328.         if (is_dir($dir)) {
  2329.             return $dir;
  2330.         } elseif (!$force) {
  2331.             return false;
  2332.         }
  2333.         unlink($dir);
  2334.     }
  2335.     return mkdir($dir, 0777, true);
  2336. }
  2337.  
  2338. /**
  2339.  * Safely copy file
  2340.  * @param string $f1
  2341.  * @param string $f2
  2342.  * @param bool $upd Indicates if file should be updated with new content
  2343.  * @return bool
  2344.  */
  2345. function fm_copy($f1, $f2, $upd)
  2346. {
  2347.     $time1 = filemtime($f1);
  2348.     if (file_exists($f2)) {
  2349.         $time2 = filemtime($f2);
  2350.         if ($time2 >= $time1 && $upd) {
  2351.             return false;
  2352.         }
  2353.     }
  2354.     $ok = copy($f1, $f2);
  2355.     if ($ok) {
  2356.         touch($f2, $time1);
  2357.     }
  2358.     return $ok;
  2359. }
  2360.  
  2361. /**
  2362.  * Get mime type
  2363.  * @param string $file_path
  2364.  * @return mixed|string
  2365.  */
  2366. function fm_get_mime_type($file_path)
  2367. {
  2368.     if (function_exists('finfo_open')) {
  2369.         $finfo = finfo_open(FILEINFO_MIME_TYPE);
  2370.         $mime = finfo_file($finfo, $file_path);
  2371.         finfo_close($finfo);
  2372.         return $mime;
  2373.     } elseif (function_exists('mime_content_type')) {
  2374.         return mime_content_type($file_path);
  2375.     } elseif (!stristr(ini_get('disable_functions'), 'shell_exec')) {
  2376.         $file = escapeshellarg($file_path);
  2377.         $mime = shell_exec('file -bi ' . $file);
  2378.         return $mime;
  2379.     } else {
  2380.         return '--';
  2381.     }
  2382. }
  2383.  
  2384. /**
  2385.  * HTTP Redirect
  2386.  * @param string $url
  2387.  * @param int $code
  2388.  */
  2389. function fm_redirect($url, $code = 302)
  2390. {
  2391.     header('Location: ' . $url, true, $code);
  2392.     exit;
  2393. }
  2394.  
  2395. /**
  2396.  * Path traversal prevention and clean the url
  2397.  * It replaces (consecutive) occurrences of / and \\ with whatever is in DIRECTORY_SEPARATOR, and processes /. and /.. fine.
  2398.  * @param $path
  2399.  * @return string
  2400.  */
  2401. function get_absolute_path($path) {
  2402.     $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
  2403.     $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
  2404.     $absolutes = array();
  2405.     foreach ($parts as $part) {
  2406.         if ('.' == $part) continue;
  2407.         if ('..' == $part) {
  2408.             array_pop($absolutes);
  2409.         } else {
  2410.             $absolutes[] = $part;
  2411.         }
  2412.     }
  2413.     return implode(DIRECTORY_SEPARATOR, $absolutes);
  2414. }
  2415.  
  2416. /**
  2417.  * Clean path
  2418.  * @param string $path
  2419.  * @return string
  2420.  */
  2421. function fm_clean_path($path, $trim = true)
  2422. {
  2423.     $path = $trim trim($path) : $path;
  2424.     $path = trim($path, '\\/');
  2425.     $path = str_replace(array('../', '..\\'), '', $path);
  2426.     $path =  get_absolute_path($path);
  2427.     if ($path == '..') {
  2428.         $path = '';
  2429.     }
  2430.     return str_replace('\\', '/', $path);
  2431. }
  2432.  
  2433. /**
  2434.  * Get parent path
  2435.  * @param string $path
  2436.  * @return bool|string
  2437.  */
  2438. function fm_get_parent_path($path)
  2439. {
  2440.     $path = fm_clean_path($path);
  2441.     if ($path != '') {
  2442.         $array = explode('/', $path);
  2443.         if (count($array) > 1) {
  2444.             $array = array_slice($array, 0, -1);
  2445.             return implode('/', $array);
  2446.         }
  2447.         return '';
  2448.     }
  2449.     return false;
  2450. }
  2451.  
  2452. /**
  2453.  * Check file is in exclude list
  2454.  * @param string $file
  2455.  * @return bool
  2456.  */
  2457. function fm_is_exclude_items($file) {
  2458.     $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
  2459.     if (isset($exclude_items) and sizeof($exclude_items)) {
  2460.         unset($exclude_items);
  2461.     }
  2462.  
  2463.     $exclude_items = FM_EXCLUDE_ITEMS;
  2464.     if (version_compare(PHP_VERSION, '7.0.0', '<')) {
  2465.         $exclude_items = unserialize($exclude_items);
  2466.     }
  2467.     if (!in_array($file, $exclude_items) && !in_array("*.$ext", $exclude_items)) {
  2468.         return true;
  2469.     }
  2470.     return false;
  2471. }
  2472.  
  2473. /**
  2474.  * get language translations from json file
  2475.  * @param int $tr
  2476.  * @return array
  2477.  */
  2478. function fm_get_translations($tr) {
  2479.     try {
  2480.         $content = @file_get_contents('translation.json');
  2481.         if($content !== FALSE) {
  2482.             $lng = json_decode($content, TRUE);
  2483.             global $lang_list;
  2484.             foreach ($lng["language"] as $key => $value)
  2485.             {
  2486.                 $code = $value["code"];
  2487.                 $lang_list[$code] = $value["name"];
  2488.                 if ($tr)
  2489.                     $tr[$code] = $value["translation"];
  2490.             }
  2491.             return $tr;
  2492.         }
  2493.  
  2494.     }
  2495.     catch (Exception $e) {
  2496.         echo $e;
  2497.     }
  2498. }
  2499.  
  2500. /**
  2501.  * @param $file
  2502.  * Recover all file sizes larger than > 2GB.
  2503.  * Works on php 32bits and 64bits and supports linux
  2504.  * @return int|string
  2505.  */
  2506. function fm_get_size($file)
  2507. {
  2508.     static $iswin;
  2509.     static $isdarwin;
  2510.     if (!isset($iswin)) {
  2511.         $iswin = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN');
  2512.     }
  2513.     if (!isset($isdarwin)) {
  2514.         $isdarwin = (strtoupper(substr(PHP_OS, 0)) == "DARWIN");
  2515.     }
  2516.  
  2517.     static $exec_works;
  2518.     if (!isset($exec_works)) {
  2519.         $exec_works = (function_exists('exec') && !ini_get('safe_mode') && @exec('echo EXEC') == 'EXEC');
  2520.     }
  2521.  
  2522.     // try a shell command
  2523.     if ($exec_works) {
  2524.         $arg = escapeshellarg($file);
  2525.         $cmd = ($iswin) ? "for %F in (\"$file\") do @echo %~zF" : ($isdarwin "stat -f%z $arg" : "stat -c%s $arg");
  2526.         @exec($cmd, $output);
  2527.         if (is_array($output) && ctype_digit($size = trim(implode("\n", $output)))) {
  2528.             return $size;
  2529.         }
  2530.     }
  2531.  
  2532.     // try the Windows COM interface
  2533.     if ($iswin && class_exists("COM")) {
  2534.         try {
  2535.             $fsobj = new COM('Scripting.FileSystemObject');
  2536.             $f = $fsobj->GetFile( realpath($file) );
  2537.             $size = $f->Size;
  2538.         } catch (Exception $e) {
  2539.             $size = null;
  2540.         }
  2541.         if (ctype_digit($size)) {
  2542.             return $size;
  2543.         }
  2544.     }
  2545.  
  2546.     // if all else fails
  2547.     return filesize($file);
  2548. }
  2549.  
  2550. /**
  2551.  * Get nice filesize
  2552.  * @param int $size
  2553.  * @return string
  2554.  */
  2555. function fm_get_filesize($size)
  2556. {
  2557.     $size = (float) $size;
  2558.     $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
  2559.     $power = ($size > 0) ? floor(log($size, 1024)) : 0;
  2560.     $power = ($power > (count($units) - 1)) ? (count($units) - 1) : $power;
  2561.     return sprintf('%s %s', round($size / pow(1024, $power), 2), $units[$power]);
  2562. }
  2563.  
  2564. /**
  2565.  * Get total size of directory tree.
  2566.  *
  2567.  * @param  string $directory Relative or absolute directory name.
  2568.  * @return int Total number of bytes.
  2569.  */
  2570. function fm_get_directorysize($directory) {
  2571.     $bytes = 0;
  2572.     $directory = realpath($directory);
  2573.     if ($directory !== false && $directory != '' && file_exists($directory)){
  2574.         foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS)) as $file){
  2575.             $bytes += $file->getSize();
  2576.         }
  2577.     }
  2578.     return $bytes;
  2579. }
  2580.  
  2581. /**
  2582.  * Get info about zip archive
  2583.  * @param string $path
  2584.  * @return array|bool
  2585.  */
  2586. function fm_get_zif_info($path, $ext) {
  2587.     if ($ext == 'zip' && function_exists('zip_open')) {
  2588.         $arch = zip_open($path);
  2589.         if ($arch) {
  2590.             $filenames = array();
  2591.             while ($zip_entry = zip_read($arch)) {
  2592.                 $zip_name = zip_entry_name($zip_entry);
  2593.                 $zip_folder = substr($zip_name, -1) == '/';
  2594.                 $filenames[] = array(
  2595.                     'name' => $zip_name,
  2596.                     'filesize' => zip_entry_filesize($zip_entry),
  2597.                     'compressed_size' => zip_entry_compressedsize($zip_entry),
  2598.                     'folder' => $zip_folder
  2599.                     //'compression_method' => zip_entry_compressionmethod($zip_entry),
  2600.                 );
  2601.             }
  2602.             zip_close($arch);
  2603.             return $filenames;
  2604.         }
  2605.     } elseif($ext == 'tar' && class_exists('PharData')) {
  2606.         $archive = new PharData($path);
  2607.         $filenames = array();
  2608.         foreach(new RecursiveIteratorIterator($archive) as $file) {
  2609.             $parent_info = $file->getPathInfo();
  2610.             $zip_name = str_replace("phar://".$path, '', $file->getPathName());
  2611.             $zip_name = substr($zip_name, ($pos = strpos($zip_name, '/')) !== false ? $pos + 1 : 0);
  2612.             $zip_folder = $parent_info->getFileName();
  2613.             $zip_info = new SplFileInfo($file);
  2614.             $filenames[] = array(
  2615.                 'name' => $zip_name,
  2616.                 'filesize' => $zip_info->getSize(),
  2617.                 'compressed_size' => $file->getCompressedSize(),
  2618.                 'folder' => $zip_folder
  2619.             );
  2620.         }
  2621.         return $filenames;
  2622.     }
  2623.     return false;
  2624. }
  2625.  
  2626. /**
  2627.  * Encode html entities
  2628.  * @param string $text
  2629.  * @return string
  2630.  */
  2631. function fm_enc($text)
  2632. {
  2633.     return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
  2634. }
  2635.  
  2636. /**
  2637.  * Prevent XSS attacks
  2638.  * @param string $text
  2639.  * @return string
  2640.  */
  2641. function fm_isvalid_filename($text) {
  2642.     return (strpbrk($text, '/?%*:|"<>') === FALSE) ? true : false;
  2643. }
  2644.  
  2645. /**
  2646.  * Save message in session
  2647.  * @param string $msg
  2648.  * @param string $status
  2649.  */
  2650. function fm_set_msg($msg, $status = 'ok')
  2651. {
  2652.     $_SESSION[FM_SESSION_ID]['message'] = $msg;
  2653.     $_SESSION[FM_SESSION_ID]['status'] = $status;
  2654. }
  2655.  
  2656. /**
  2657.  * Check if string is in UTF-8
  2658.  * @param string $string
  2659.  * @return int
  2660.  */
  2661. function fm_is_utf8($string)
  2662. {
  2663.     return preg_match('//u', $string);
  2664. }
  2665.  
  2666. /**
  2667.  * Convert file name to UTF-8 in Windows
  2668.  * @param string $filename
  2669.  * @return string
  2670.  */
  2671. function fm_convert_win($filename)
  2672. {
  2673.     if (FM_IS_WIN && function_exists('iconv')) {
  2674.         $filename = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $filename);
  2675.     }
  2676.     return $filename;
  2677. }
  2678.  
  2679. /**
  2680.  * @param $obj
  2681.  * @return array
  2682.  */
  2683. function fm_object_to_array($obj)
  2684. {
  2685.     if (!is_object($obj) && !is_array($obj)) {
  2686.         return $obj;
  2687.     }
  2688.     if (is_object($obj)) {
  2689.         $obj = get_object_vars($obj);
  2690.     }
  2691.     return array_map('fm_object_to_array', $obj);
  2692. }
  2693.  
  2694. /**
  2695.  * Get CSS classname for file
  2696.  * @param string $path
  2697.  * @return string
  2698.  */
  2699. function fm_get_file_icon_class($path)
  2700. {
  2701.     // get extension
  2702.     $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
  2703.  
  2704.     switch ($ext) {
  2705.         case 'ico':
  2706.         case 'gif':
  2707.         case 'jpg':
  2708.         case 'jpeg':
  2709.         case 'jpc':
  2710.         case 'jp2':
  2711.         case 'jpx':
  2712.         case 'xbm':
  2713.         case 'wbmp':
  2714.         case 'png':
  2715.         case 'bmp':
  2716.         case 'tif':
  2717.         case 'tiff':
  2718.         case 'webp':
  2719.         case 'avif':
  2720.         case 'svg':
  2721.             $img = 'fa fa-picture-o';
  2722.             break;
  2723.         case 'passwd':
  2724.         case 'ftpquota':
  2725.         case 'sql':
  2726.         case 'js':
  2727.         case 'json':
  2728.         case 'sh':
  2729.         case 'config':
  2730.         case 'twig':
  2731.         case 'tpl':
  2732.         case 'md':
  2733.         case 'gitignore':
  2734.         case 'c':
  2735.         case 'cpp':
  2736.         case 'cs':
  2737.         case 'py':
  2738.         case 'rs':
  2739.         case 'map':
  2740.         case 'lock':
  2741.         case 'dtd':
  2742.             $img = 'fa fa-file-code-o';
  2743.             break;
  2744.         case 'txt':
  2745.         case 'ini':
  2746.         case 'conf':
  2747.         case 'log':
  2748.         case 'htaccess':
  2749.         case 'yaml':
  2750.         case 'yml':
  2751.         case 'toml':
  2752.             $img = 'fa fa-file-text-o';
  2753.             break;
  2754.         case 'css':
  2755.         case 'less':
  2756.         case 'sass':
  2757.         case 'scss':
  2758.             $img = 'fa fa-css3';
  2759.             break;
  2760.         case 'bz2':
  2761.         case 'zip':
  2762.         case 'rar':
  2763.         case 'gz':
  2764.         case 'tar':
  2765.         case '7z':
  2766.         case 'xz':
  2767.             $img = 'fa fa-file-archive-o';
  2768.             break;
  2769.         case 'php':
  2770.         case 'php4':
  2771.         case 'php5':
  2772.         case 'phps':
  2773.         case 'phtml':
  2774.             $img = 'fa fa-code';
  2775.             break;
  2776.         case 'htm':
  2777.         case 'html':
  2778.         case 'shtml':
  2779.         case 'xhtml':
  2780.             $img = 'fa fa-html5';
  2781.             break;
  2782.         case 'xml':
  2783.         case 'xsl':
  2784.             $img = 'fa fa-file-excel-o';
  2785.             break;
  2786.         case 'wav':
  2787.         case 'mp3':
  2788.         case 'mp2':
  2789.         case 'm4a':
  2790.         case 'aac':
  2791.         case 'ogg':
  2792.         case 'oga':
  2793.         case 'wma':
  2794.         case 'mka':
  2795.         case 'flac':
  2796.         case 'ac3':
  2797.         case 'tds':
  2798.             $img = 'fa fa-music';
  2799.             break;
  2800.         case 'm3u':
  2801.         case 'm3u8':
  2802.         case 'pls':
  2803.         case 'cue':
  2804.         case 'xspf':
  2805.             $img = 'fa fa-headphones';
  2806.             break;
  2807.         case 'avi':
  2808.         case 'mpg':
  2809.         case 'mpeg':
  2810.         case 'mp4':
  2811.         case 'm4v':
  2812.         case 'flv':
  2813.         case 'f4v':
  2814.         case 'ogm':
  2815.         case 'ogv':
  2816.         case 'mov':
  2817.         case 'mkv':
  2818.         case '3gp':
  2819.         case 'asf':
  2820.         case 'wmv':
  2821.         case 'webm':
  2822.             $img = 'fa fa-file-video-o';
  2823.             break;
  2824.         case 'eml':
  2825.         case 'msg':
  2826.             $img = 'fa fa-envelope-o';
  2827.             break;
  2828.         case 'xls':
  2829.         case 'xlsx':
  2830.         case 'ods':
  2831.             $img = 'fa fa-file-excel-o';
  2832.             break;
  2833.         case 'csv':
  2834.             $img = 'fa fa-file-text-o';
  2835.             break;
  2836.         case 'bak':
  2837.         case 'swp':
  2838.             $img = 'fa fa-clipboard';
  2839.             break;
  2840.         case 'doc':
  2841.         case 'docx':
  2842.         case 'odt':
  2843.             $img = 'fa fa-file-word-o';
  2844.             break;
  2845.         case 'ppt':
  2846.         case 'pptx':
  2847.             $img = 'fa fa-file-powerpoint-o';
  2848.             break;
  2849.         case 'ttf':
  2850.         case 'ttc':
  2851.         case 'otf':
  2852.         case 'woff':
  2853.         case 'woff2':
  2854.         case 'eot':
  2855.         case 'fon':
  2856.             $img = 'fa fa-font';
  2857.             break;
  2858.         case 'pdf':
  2859.             $img = 'fa fa-file-pdf-o';
  2860.             break;
  2861.         case 'psd':
  2862.         case 'ai':
  2863.         case 'eps':
  2864.         case 'fla':
  2865.         case 'swf':
  2866.             $img = 'fa fa-file-image-o';
  2867.             break;
  2868.         case 'exe':
  2869.         case 'msi':
  2870.             $img = 'fa fa-file-o';
  2871.             break;
  2872.         case 'bat':
  2873.             $img = 'fa fa-terminal';
  2874.             break;
  2875.         default:
  2876.             $img = 'fa fa-info-circle';
  2877.     }
  2878.  
  2879.     return $img;
  2880. }
  2881.  
  2882. /**
  2883.  * Get image files extensions
  2884.  * @return array
  2885.  */
  2886. function fm_get_image_exts()
  2887. {
  2888.     return array('ico', 'gif', 'jpg', 'jpeg', 'jpc', 'jp2', 'jpx', 'xbm', 'wbmp', 'png', 'bmp', 'tif', 'tiff', 'psd', 'svg', 'webp', 'avif');
  2889. }
  2890.  
  2891. /**
  2892.  * Get video files extensions
  2893.  * @return array
  2894.  */
  2895. function fm_get_video_exts()
  2896. {
  2897.     return array('avi', 'webm', 'wmv', 'mp4', 'm4v', 'ogm', 'ogv', 'mov', 'mkv');
  2898. }
  2899.  
  2900. /**
  2901.  * Get audio files extensions
  2902.  * @return array
  2903.  */
  2904. function fm_get_audio_exts()
  2905. {
  2906.     return array('wav', 'mp3', 'ogg', 'm4a');
  2907. }
  2908.  
  2909. /**
  2910.  * Get text file extensions
  2911.  * @return array
  2912.  */
  2913. function fm_get_text_exts()
  2914. {
  2915.     return array(
  2916.         'txt', 'css', 'ini', 'conf', 'log', 'htaccess', 'passwd', 'ftpquota', 'sql', 'js', 'json', 'sh', 'config',
  2917.         'php', 'php4', 'php5', 'phps', 'phtml', 'htm', 'html', 'shtml', 'xhtml', 'xml', 'xsl', 'm3u', 'm3u8', 'pls', 'cue',
  2918.         'eml', 'msg', 'csv', 'bat', 'twig', 'tpl', 'md', 'gitignore', 'less', 'sass', 'scss', 'c', 'cpp', 'cs', 'py',
  2919.         'map', 'lock', 'dtd', 'svg', 'scss', 'asp', 'aspx', 'asx', 'asmx', 'ashx', 'jsx', 'jsp', 'jspx', 'cfm', 'cgi',
  2920.         'yml', 'yaml', 'toml'
  2921.     );
  2922. }
  2923.  
  2924. /**
  2925.  * Get mime types of text files
  2926.  * @return array
  2927.  */
  2928. function fm_get_text_mimes()
  2929. {
  2930.     return array(
  2931.         'application/xml',
  2932.         'application/javascript',
  2933.         'application/x-javascript',
  2934.         'image/svg+xml',
  2935.         'message/rfc822',
  2936.         'application/json',
  2937.     );
  2938. }
  2939.  
  2940. /**
  2941.  * Get file names of text files w/o extensions
  2942.  * @return array
  2943.  */
  2944. function fm_get_text_names()
  2945. {
  2946.     return array(
  2947.         'license',
  2948.         'readme',
  2949.         'authors',
  2950.         'contributors',
  2951.         'changelog',
  2952.     );
  2953. }
  2954.  
  2955. /**
  2956.  * Get online docs viewer supported files extensions
  2957.  * @return array
  2958.  */
  2959. function fm_get_onlineViewer_exts()
  2960. {
  2961.     return array('doc', 'docx', 'xls', 'xlsx', 'pdf', 'ppt', 'pptx', 'ai', 'psd', 'dxf', 'xps', 'rar', 'odt', 'ods');
  2962. }
  2963.  
  2964. function fm_get_file_mimes($extension)
  2965. {
  2966.     $fileTypes['swf'] = 'application/x-shockwave-flash';
  2967.     $fileTypes['pdf'] = 'application/pdf';
  2968.     $fileTypes['exe'] = 'application/octet-stream';
  2969.     $fileTypes['zip'] = 'application/zip';
  2970.     $fileTypes['doc'] = 'application/msword';
  2971.     $fileTypes['xls'] = 'application/vnd.ms-excel';
  2972.     $fileTypes['ppt'] = 'application/vnd.ms-powerpoint';
  2973.     $fileTypes['gif'] = 'image/gif';
  2974.     $fileTypes['png'] = 'image/png';
  2975.     $fileTypes['jpeg'] = 'image/jpg';
  2976.     $fileTypes['jpg'] = 'image/jpg';
  2977.     $fileTypes['webp'] = 'image/webp';
  2978.     $fileTypes['avif'] = 'image/avif';
  2979.     $fileTypes['rar'] = 'application/rar';
  2980.  
  2981.     $fileTypes['ra'] = 'audio/x-pn-realaudio';
  2982.     $fileTypes['ram'] = 'audio/x-pn-realaudio';
  2983.     $fileTypes['ogg'] = 'audio/x-pn-realaudio';
  2984.  
  2985.     $fileTypes['wav'] = 'video/x-msvideo';
  2986.     $fileTypes['wmv'] = 'video/x-msvideo';
  2987.     $fileTypes['avi'] = 'video/x-msvideo';
  2988.     $fileTypes['asf'] = 'video/x-msvideo';
  2989.     $fileTypes['divx'] = 'video/x-msvideo';
  2990.  
  2991.     $fileTypes['mp3'] = 'audio/mpeg';
  2992.     $fileTypes['mp4'] = 'audio/mpeg';
  2993.     $fileTypes['mpeg'] = 'video/mpeg';
  2994.     $fileTypes['mpg'] = 'video/mpeg';
  2995.     $fileTypes['mpe'] = 'video/mpeg';
  2996.     $fileTypes['mov'] = 'video/quicktime';
  2997.     $fileTypes['swf'] = 'video/quicktime';
  2998.     $fileTypes['3gp'] = 'video/quicktime';
  2999.     $fileTypes['m4a'] = 'video/quicktime';
  3000.     $fileTypes['aac'] = 'video/quicktime';
  3001.     $fileTypes['m3u'] = 'video/quicktime';
  3002.  
  3003.     $fileTypes['php'] = ['application/x-php'];
  3004.     $fileTypes['html'] = ['text/html'];
  3005.     $fileTypes['txt'] = ['text/plain'];
  3006.     //Unknown mime-types should be 'application/octet-stream'
  3007.     if(empty($fileTypes[$extension])) {
  3008.       $fileTypes[$extension] = ['application/octet-stream'];
  3009.     }
  3010.     return $fileTypes[$extension];
  3011. }
  3012.  
  3013. /**
  3014.  * This function scans the files and folder recursively, and return matching files
  3015.  * @param string $dir
  3016.  * @param string $filter
  3017.  * @return json
  3018.  */
  3019.  function scan($dir, $filter = '') {
  3020.     $path = FM_ROOT_PATH.'/'.$dir;
  3021.      if($dir) {
  3022.          $ite = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
  3023.          $rii = new RegexIterator($ite, "/(" . $filter . ")/i");
  3024.  
  3025.          $files = array();
  3026.          foreach ($rii as $file) {
  3027.              if (!$file->isDir()) {
  3028.                  $fileName = $file->getFilename();
  3029.                  $location = str_replace(FM_ROOT_PATH, '', $file->getPath());
  3030.                  $files[] = array(
  3031.                      "name" => $fileName,
  3032.                      "type" => "file",
  3033.                      "path" => $location,
  3034.                  );
  3035.              }
  3036.          }
  3037.          return $files;
  3038.      }
  3039. }
  3040.  
  3041. /*
  3042. Parameters: downloadFile(File Location, File Name,
  3043. max speed, is streaming
  3044. If streaming - videos will show as videos, images as images
  3045. instead of download prompt
  3046. https://stackoverflow.com/a/13821992/1164642
  3047. */
  3048.  
  3049. function fm_download_file($fileLocation, $fileName, $chunkSize  = 1024)
  3050. {
  3051.     if (connection_status() != 0)
  3052.         return (false);
  3053.     $extension = pathinfo($fileName, PATHINFO_EXTENSION);
  3054.  
  3055.     $contentType = fm_get_file_mimes($extension);
  3056.  
  3057.     if(is_array($contentType)) {
  3058.         $contentType = implode(' ', $contentType);
  3059.     }
  3060.  
  3061.     header("Cache-Control: public");
  3062.     header("Content-Transfer-Encoding: binary\n");
  3063.     header("Content-Type: $contentType");
  3064.  
  3065.     $contentDisposition = 'attachment';
  3066.  
  3067.  
  3068.     if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
  3069.         $fileName = preg_replace('/\./', '%2e', $fileName, substr_count($fileName, '.') - 1);
  3070.         header("Content-Disposition: $contentDisposition;filename=\"$fileName\"");
  3071.     } else {
  3072.         header("Content-Disposition: $contentDisposition;filename=\"$fileName\"");
  3073.     }
  3074.  
  3075.     header("Accept-Ranges: bytes");
  3076.     $range = 0;
  3077.     $size = filesize($fileLocation);
  3078.  
  3079.     if (isset($_SERVER['HTTP_RANGE'])) {
  3080.         list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
  3081.         str_replace($range, "-", $range);
  3082.         $size2 = $size - 1;
  3083.         $new_length = $size - $range;
  3084.         header("HTTP/1.1 206 Partial Content");
  3085.         header("Content-Length: $new_length");
  3086.         header("Content-Range: bytes $range$size2/$size");
  3087.     } else {
  3088.         $size2 = $size - 1;
  3089.         header("Content-Range: bytes 0-$size2/$size");
  3090.         header("Content-Length: " . $size);
  3091.     }
  3092.  
  3093.     if ($size == 0) {
  3094.         die('Zero byte file! Aborting download');
  3095.     }
  3096.     @ini_set('magic_quotes_runtime', 0);
  3097.     $fp = fopen("$fileLocation", "rb");
  3098.  
  3099.     fseek($fp, $range);
  3100.  
  3101.     while (!feof($fp) and (connection_status() == 0)) {
  3102.         
  3103.         print(@fread($fp, 1024*$chunkSize));
  3104.         flush();
  3105.         ob_flush();
  3106.         // sleep(1);
  3107.     }
  3108.     fclose($fp);
  3109.  
  3110.     return ((connection_status() == 0) and !connection_aborted());
  3111. }
  3112.  
  3113. function fm_get_theme() {
  3114.     $result = '';
  3115.     if(FM_THEME == "dark") {
  3116.         $result = "text-white bg-dark";
  3117.     }
  3118.     return $result;
  3119. }
  3120.  
  3121. /**
  3122.  * Class to work with zip files (using ZipArchive)
  3123.  */
  3124. class FM_Zipper
  3125. {
  3126.     private $zip;
  3127.  
  3128.     public function __construct()
  3129.     {
  3130.         $this->zip = new ZipArchive();
  3131.     }
  3132.  
  3133.     /**
  3134.      * Create archive with name $filename and files $files (RELATIVE PATHS!)
  3135.      * @param string $filename
  3136.      * @param array|string $files
  3137.      * @return bool
  3138.      */
  3139.     public function create($filename, $files)
  3140.     {
  3141.         $res = $this->zip->open($filename, ZipArchive::CREATE);
  3142.         if ($res !== true) {
  3143.             return false;
  3144.         }
  3145.         if (is_array($files)) {
  3146.             foreach ($files as $f) {
  3147.                 if (!$this->addFileOrDir($f)) {
  3148.                     $this->zip->close();
  3149.                     return false;
  3150.                 }
  3151.             }
  3152.             $this->zip->close();
  3153.             return true;
  3154.         } else {
  3155.             if ($this->addFileOrDir($files)) {
  3156.                 $this->zip->close();
  3157.                 return true;
  3158.             }
  3159.             return false;
  3160.         }
  3161.     }
  3162.  
  3163.     /**
  3164.      * Extract archive $filename to folder $path (RELATIVE OR ABSOLUTE PATHS)
  3165.      * @param string $filename
  3166.      * @param string $path
  3167.      * @return bool
  3168.      */
  3169.     public function unzip($filename, $path)
  3170.     {
  3171.         $res = $this->zip->open($filename);
  3172.         if ($res !== true) {
  3173.             return false;
  3174.         }
  3175.         if ($this->zip->extractTo($path)) {
  3176.             $this->zip->close();
  3177.             return true;
  3178.         }
  3179.         return false;
  3180.     }
  3181.  
  3182.     /**
  3183.      * Add file/folder to archive
  3184.      * @param string $filename
  3185.      * @return bool
  3186.      */
  3187.     private function addFileOrDir($filename)
  3188.     {
  3189.         if (is_file($filename)) {
  3190.             return $this->zip->addFile($filename);
  3191.         } elseif (is_dir($filename)) {
  3192.             return $this->addDir($filename);
  3193.         }
  3194.         return false;
  3195.     }
  3196.  
  3197.     /**
  3198.      * Add folder recursively
  3199.      * @param string $path
  3200.      * @return bool
  3201.      */
  3202.     private function addDir($path)
  3203.     {
  3204.         if (!$this->zip->addEmptyDir($path)) {
  3205.             return false;
  3206.         }
  3207.         $objects = scandir($path);
  3208.         if (is_array($objects)) {
  3209.             foreach ($objects as $file) {
  3210.                 if ($file != '.' && $file != '..') {
  3211.                     if (is_dir($path . '/' . $file)) {
  3212.                         if (!$this->addDir($path . '/' . $file)) {
  3213.                             return false;
  3214.                         }
  3215.                     } elseif (is_file($path . '/' . $file)) {
  3216.                         if (!$this->zip->addFile($path . '/' . $file)) {
  3217.                             return false;
  3218.                         }
  3219.                     }
  3220.                 }
  3221.             }
  3222.             return true;
  3223.         }
  3224.         return false;
  3225.     }
  3226. }
  3227.  
  3228. /**
  3229.  * Class to work with Tar files (using PharData)
  3230.  */
  3231. class FM_Zipper_Tar
  3232. {
  3233.     private $tar;
  3234.  
  3235.     public function __construct()
  3236.     {
  3237.         $this->tar = null;
  3238.     }
  3239.  
  3240.     /**
  3241.      * Create archive with name $filename and files $files (RELATIVE PATHS!)
  3242.      * @param string $filename
  3243.      * @param array|string $files
  3244.      * @return bool
  3245.      */
  3246.     public function create($filename, $files)
  3247.     {
  3248.         $this->tar = new PharData($filename);
  3249.         if (is_array($files)) {
  3250.             foreach ($files as $f) {
  3251.                 if (!$this->addFileOrDir($f)) {
  3252.                     return false;
  3253.                 }
  3254.             }
  3255.             return true;
  3256.         } else {
  3257.             if ($this->addFileOrDir($files)) {
  3258.                 return true;
  3259.             }
  3260.             return false;
  3261.         }
  3262.     }
  3263.  
  3264.     /**
  3265.      * Extract archive $filename to folder $path (RELATIVE OR ABSOLUTE PATHS)
  3266.      * @param string $filename
  3267.      * @param string $path
  3268.      * @return bool
  3269.      */
  3270.     public function unzip($filename, $path)
  3271.     {
  3272.         $res = $this->tar->open($filename);
  3273.         if ($res !== true) {
  3274.             return false;
  3275.         }
  3276.         if ($this->tar->extractTo($path)) {
  3277.             return true;
  3278.         }
  3279.         return false;
  3280.     }
  3281.  
  3282.     /**
  3283.      * Add file/folder to archive
  3284.      * @param string $filename
  3285.      * @return bool
  3286.      */
  3287.     private function addFileOrDir($filename)
  3288.     {
  3289.         if (is_file($filename)) {
  3290.             try {
  3291.                 $this->tar->addFile($filename);
  3292.                 return true;
  3293.             } catch (Exception $e) {
  3294.                 return false;
  3295.             }
  3296.         } elseif (is_dir($filename)) {
  3297.             return $this->addDir($filename);
  3298.         }
  3299.         return false;
  3300.     }
  3301.  
  3302.     /**
  3303.      * Add folder recursively
  3304.      * @param string $path
  3305.      * @return bool
  3306.      */
  3307.     private function addDir($path)
  3308.     {
  3309.         $objects = scandir($path);
  3310.         if (is_array($objects)) {
  3311.             foreach ($objects as $file) {
  3312.                 if ($file != '.' && $file != '..') {
  3313.                     if (is_dir($path . '/' . $file)) {
  3314.                         if (!$this->addDir($path . '/' . $file)) {
  3315.                             return false;
  3316.                         }
  3317.                     } elseif (is_file($path . '/' . $file)) {
  3318.                         try {
  3319.                             $this->tar->addFile($path . '/' . $file);
  3320.                         } catch (Exception $e) {
  3321.                             return false;
  3322.                         }
  3323.                     }
  3324.                 }
  3325.             }
  3326.             return true;
  3327.         }
  3328.         return false;
  3329.     }
  3330. }
  3331.  
  3332.  
  3333.  
  3334. /**
  3335.  * Save Configuration
  3336.  */
  3337.  class FM_Config
  3338. {
  3339.      var $data;
  3340.  
  3341.     function __construct()
  3342.     {
  3343.         global $root_path, $root_url, $CONFIG;
  3344.         $fm_url = $root_url.$_SERVER["PHP_SELF"];
  3345.         $this->data = array(
  3346.             'lang' => 'en',
  3347.             'error_reporting' => true,
  3348.             'show_hidden' => true
  3349.         );
  3350.         $data = false;
  3351.         if (strlen($CONFIG)) {
  3352.             $data = fm_object_to_array(json_decode($CONFIG));
  3353.         } else {
  3354.             $msg = 'droped<br>Error: Cannot load configuration';
  3355.             if (substr($fm_url, -1) == '/') {
  3356.                 $fm_url = rtrim($fm_url, '/');
  3357.                 $msg .= '<br>';
  3358.                 $msg .= '<br>Seems like you have a trailing slash on the URL.';
  3359.                 $msg .= '<br>Try this link: <a href="' . $fm_url . '">' . $fm_url . '</a>';
  3360.             }
  3361.             die($msg);
  3362.         }
  3363.         if (is_array($data) && count($data)) $this->data = $data;
  3364.         else $this->save();
  3365.     }
  3366.  
  3367.     function save()
  3368.     {
  3369.         $fm_file = __FILE__;
  3370.         $var_name = '$CONFIG';
  3371.         $var_value = var_export(json_encode($this->data), true);
  3372.         $config_string = "<?php" . chr(13) . chr(10) . "//Default Configuration".chr(13) . chr(10)."$var_name = $var_value;" . chr(13) . chr(10);
  3373.         if (is_writable($fm_file)) {
  3374.             $lines = file($fm_file);
  3375.             if ($fh = @fopen($fm_file, "w")) {
  3376.                 @fputs($fh, $config_string, strlen($config_string));
  3377.                 for ($x = 3; $x < count($lines); $x++) {
  3378.                     @fputs($fh, $lines[$x], strlen($lines[$x]));
  3379.                 }
  3380.                 @fclose($fh);
  3381.             }
  3382.         }
  3383.     }
  3384. }
  3385.  
  3386.  
  3387.  
  3388. //--- templates functions
  3389.  
  3390. /**
  3391.  * Show nav block
  3392.  * @param string $path
  3393.  */
  3394. function fm_show_nav_path($path)
  3395. {
  3396.     global $lang, $sticky_navbar, $editFile;
  3397.     $isStickyNavBar = $sticky_navbar 'fixed-top' : '';
  3398.     $getTheme = fm_get_theme();
  3399.     $getTheme .= " navbar-light";
  3400.     if(FM_THEME == "dark") {
  3401.         $getTheme .= " navbar-dark";
  3402.     } else {
  3403.         $getTheme .= " bg-white";
  3404.     }
  3405.     ?>
  3406.     <nav class="navbar navbar-expand-lg <?php echo $getTheme; ?> mb-4 main-nav <?php echo $isStickyNavBar ?>">
  3407.         <a class="navbar-brand" href=""> <?php echo lng('AppTitle') ?> </a>
  3408.         <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  3409.             <span class="navbar-toggler-icon"></span>
  3410.         </button>
  3411.         <div class="collapse navbar-collapse" id="navbarSupportedContent">
  3412.  
  3413.             <?php
  3414.             $path = fm_clean_path($path);
  3415.             $root_url = "<a href='?p='><i class='fa fa-home' aria-hidden='true' title='" . FM_ROOT_PATH . "'></i></a>";
  3416.             $sep = '<i class="bread-crumb"> / </i>';
  3417.             if ($path != '') {
  3418.                 $exploded = explode('/', $path);
  3419.                 $count = count($exploded);
  3420.                 $array = array();
  3421.                 $parent = '';
  3422.                 for ($i = 0; $i < $count; $i++) {
  3423.                     $parent = trim($parent . '/' . $exploded[$i], '/');
  3424.                     $parent_enc = urlencode($parent);
  3425.                     $array[] = "<a href='?p={$parent_enc}'>" . fm_enc(fm_convert_win($exploded[$i])) . "</a>";
  3426.                 }
  3427.                 $root_url .= $sep . implode($sep, $array);
  3428.             }
  3429.             echo '<div class="col-xs-6 col-sm-5">' . $root_url . $editFile . '</div>';
  3430.             ?>
  3431.  
  3432.             <div class="col-xs-6 col-sm-7 text-right">
  3433.                 <ul class="navbar-nav mr-auto float-right <?php echo fm_get_theme();  ?>">
  3434.                     <li class="nav-item mr-2">
  3435.                         <div class="input-group input-group-sm mr-1" style="margin-top:4px;">
  3436.                             <input type="text" class="form-control" placeholder="<?php echo lng('Search') ?>" aria-label="<?php echo lng('Search') ?>" aria-describedby="search-addon2" id="search-addon">
  3437.                             <div class="input-group-append">
  3438.                                 <span class="input-group-text" id="search-addon2"><i class="fa fa-search"></i></span>
  3439.                             </div>
  3440.                             <div class="input-group-append btn-group">
  3441.                                 <span class="input-group-text dropdown-toggle" id="search-addon2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></span>
  3442.                                   <div class="dropdown-menu dropdown-menu-right">
  3443.                                     <a class="dropdown-item" href="<?php echo $path2 = $path $path : '.'; ?>" id="js-search-modal" data-toggle="modal" data-target="#searchModal"><?php echo lng('Advanced Search') ?></a>
  3444.                                   </div>
  3445.                             </div>
  3446.                         </div>
  3447.                     </li>
  3448.                     <?php if (!FM_READONLY): ?>
  3449.                     <li class="nav-item">
  3450.                         <a title="<?php echo lng('Upload') ?>" class="nav-link" href="?p=<?php echo urlencode(FM_PATH) ?>&upload"><i class="fa fa-cloud-upload" aria-hidden="true"></i> <?php echo lng('Upload') ?></a>
  3451.                     </li>
  3452.                     <li class="nav-item">
  3453.                         <a title="<?php echo lng('NewItem') ?>" class="nav-link" href="#createNewItem" data-toggle="modal" data-target="#createNewItem"><i class="fa fa-plus-square"></i> <?php echo lng('NewItem') ?></a>
  3454.                     </li>
  3455.                     <?php endif; ?>
  3456.                     <?php if (FM_USE_AUTH): ?>
  3457.                     <li class="nav-item avatar dropdown">
  3458.                         <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink-5" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <i class="fa fa-user-circle"></i> <?php if(isset($_SESSION[FM_SESSION_ID]['logged'])) { echo $_SESSION[FM_SESSION_ID]['logged']; } ?></a>
  3459.                         <div class="dropdown-menu dropdown-menu-right <?php echo fm_get_theme(); ?>" aria-labelledby="navbarDropdownMenuLink-5">
  3460.                             <?php if (!FM_READONLY): ?>
  3461.                             <a title="<?php echo lng('Settings') ?>" class="dropdown-item nav-link" href="?p=<?php echo urlencode(FM_PATH) ?>&settings=1"><i class="fa fa-cog" aria-hidden="true"></i> <?php echo lng('Settings') ?></a>
  3462.                             <?php endif ?>
  3463.                             <a title="<?php echo lng('Help') ?>" class="dropdown-item nav-link" href="?p=<?php echo urlencode(FM_PATH) ?>&help=2"><i class="fa fa-exclamation-circle" aria-hidden="true"></i> <?php echo lng('Help') ?></a>
  3464.                             <a title="<?php echo lng('Logout') ?>" class="dropdown-item nav-link" href="?logout=1"><i class="fa fa-sign-out" aria-hidden="true"></i> <?php echo lng('Logout') ?></a>
  3465.                         </div>
  3466.                     </li>
  3467.                     <?php else: ?>
  3468.                         <?php if (!FM_READONLY): ?>
  3469.                             <li class="nav-item">
  3470.                                 <a title="<?php echo lng('Settings') ?>" class="dropdown-item nav-link" href="?p=<?php echo urlencode(FM_PATH) ?>&settings=1"><i class="fa fa-cog" aria-hidden="true"></i> <?php echo lng('Settings') ?></a>
  3471.                             </li>
  3472.                         <?php endif; ?>
  3473.                     <?php endif; ?>
  3474.                 </ul>
  3475.             </div>
  3476.         </div>
  3477.     </nav>
  3478.     <?php
  3479. }
  3480.  
  3481. /**
  3482.  * Show message from session
  3483.  */
  3484. function fm_show_message()
  3485. {
  3486.     if (isset($_SESSION[FM_SESSION_ID]['message'])) {
  3487.         $class = isset($_SESSION[FM_SESSION_ID]['status']) ? $_SESSION[FM_SESSION_ID]['status'] : 'ok';
  3488.         echo '<p class="message ' . $class . '">' . $_SESSION[FM_SESSION_ID]['message'] . '</p>';
  3489.         unset($_SESSION[FM_SESSION_ID]['message']);
  3490.         unset($_SESSION[FM_SESSION_ID]['status']);
  3491.     }
  3492. }
  3493.  
  3494. /**
  3495.  * Show page header in Login Form
  3496.  */
  3497. function fm_show_header_login()
  3498. {
  3499. $sprites_ver = '20160315';
  3500. header("Content-Type: text/html; charset=utf-8");
  3501. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
  3502. header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
  3503. header("Pragma: no-cache");
  3504.  
  3505. global $lang, $root_url, $favicon_path;
  3506. ?>
  3507. <!DOCTYPE html>
  3508. <html lang="en">
  3509. <head>
  3510.     <meta charset="utf-8">
  3511.     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  3512.     <meta name="description" content="Web based File Manager in PHP, Manage your files efficiently and easily with droped">
  3513.     <meta name="author" content="CCP Programmers">
  3514.     <meta name="robots" content="noindex, nofollow">
  3515.     <meta name="googlebot" content="noindex">
  3516.     <?php if($favicon_path) { echo '<link rel="icon" href="'.fm_enc($favicon_path).'" type="image/png">'; } ?>
  3517.     <title><?php echo fm_enc(APP_TITLE) ?></title>
  3518.     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  3519.     <style>
  3520.         body.fm-login-page{ background-color:#f7f9fb;font-size:14px;background-color:#f7f9fb;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 304 304' width='304' height='304'%3E%3Cpath fill='%23e2e9f1' fill-opacity='0.4' d='M44.1 224a5 5 0 1 1 0 2H0v-2h44.1zm160 48a5 5 0 1 1 0 2H82v-2h122.1zm57.8-46a5 5 0 1 1 0-2H304v2h-42.1zm0 16a5 5 0 1 1 0-2H304v2h-42.1zm6.2-114a5 5 0 1 1 0 2h-86.2a5 5 0 1 1 0-2h86.2zm-256-48a5 5 0 1 1 0 2H0v-2h12.1zm185.8 34a5 5 0 1 1 0-2h86.2a5 5 0 1 1 0 2h-86.2zM258 12.1a5 5 0 1 1-2 0V0h2v12.1zm-64 208a5 5 0 1 1-2 0v-54.2a5 5 0 1 1 2 0v54.2zm48-198.2V80h62v2h-64V21.9a5 5 0 1 1 2 0zm16 16V64h46v2h-48V37.9a5 5 0 1 1 2 0zm-128 96V208h16v12.1a5 5 0 1 1-2 0V210h-16v-76.1a5 5 0 1 1 2 0zm-5.9-21.9a5 5 0 1 1 0 2H114v48H85.9a5 5 0 1 1 0-2H112v-48h12.1zm-6.2 130a5 5 0 1 1 0-2H176v-74.1a5 5 0 1 1 2 0V242h-60.1zm-16-64a5 5 0 1 1 0-2H114v48h10.1a5 5 0 1 1 0 2H112v-48h-10.1zM66 284.1a5 5 0 1 1-2 0V274H50v30h-2v-32h18v12.1zM236.1 176a5 5 0 1 1 0 2H226v94h48v32h-2v-30h-48v-98h12.1zm25.8-30a5 5 0 1 1 0-2H274v44.1a5 5 0 1 1-2 0V146h-10.1zm-64 96a5 5 0 1 1 0-2H208v-80h16v-14h-42.1a5 5 0 1 1 0-2H226v18h-16v80h-12.1zm86.2-210a5 5 0 1 1 0 2H272V0h2v32h10.1zM98 101.9V146H53.9a5 5 0 1 1 0-2H96v-42.1a5 5 0 1 1 2 0zM53.9 34a5 5 0 1 1 0-2H80V0h2v34H53.9zm60.1 3.9V66H82v64H69.9a5 5 0 1 1 0-2H80V64h32V37.9a5 5 0 1 1 2 0zM101.9 82a5 5 0 1 1 0-2H128V37.9a5 5 0 1 1 2 0V82h-28.1zm16-64a5 5 0 1 1 0-2H146v44.1a5 5 0 1 1-2 0V18h-26.1zm102.2 270a5 5 0 1 1 0 2H98v14h-2v-16h124.1zM242 149.9V160h16v34h-16v62h48v48h-2v-46h-48v-66h16v-30h-16v-12.1a5 5 0 1 1 2 0zM53.9 18a5 5 0 1 1 0-2H64V2H48V0h18v18H53.9zm112 32a5 5 0 1 1 0-2H192V0h50v2h-48v48h-28.1zm-48-48a5 5 0 0 1-9.8-2h2.07a3 3 0 1 0 5.66 0H178v34h-18V21.9a5 5 0 1 1 2 0V32h14V2h-58.1zm0 96a5 5 0 1 1 0-2H137l32-32h39V21.9a5 5 0 1 1 2 0V66h-40.17l-32 32H117.9zm28.1 90.1a5 5 0 1 1-2 0v-76.51L175.59 80H224V21.9a5 5 0 1 1 2 0V82h-49.59L146 112.41v75.69zm16 32a5 5 0 1 1-2 0v-99.51L184.59 96H300.1a5 5 0 0 1 3.9-3.9v2.07a3 3 0 0 0 0 5.66v2.07a5 5 0 0 1-3.9-3.9H185.41L162 121.41v98.69zm-144-64a5 5 0 1 1-2 0v-3.51l48-48V48h32V0h2v50H66v55.41l-48 48v2.69zM50 53.9v43.51l-48 48V208h26.1a5 5 0 1 1 0 2H0v-65.41l48-48V53.9a5 5 0 1 1 2 0zm-16 16V89.41l-34 34v-2.82l32-32V69.9a5 5 0 1 1 2 0zM12.1 32a5 5 0 1 1 0 2H9.41L0 43.41V40.6L8.59 32h3.51zm265.8 18a5 5 0 1 1 0-2h18.69l7.41-7.41v2.82L297.41 50H277.9zm-16 160a5 5 0 1 1 0-2H288v-71.41l16-16v2.82l-14 14V210h-28.1zm-208 32a5 5 0 1 1 0-2H64v-22.59L40.59 194H21.9a5 5 0 1 1 0-2H41.41L66 216.59V242H53.9zm150.2 14a5 5 0 1 1 0 2H96v-56.6L56.6 162H37.9a5 5 0 1 1 0-2h19.5L98 200.6V256h106.1zm-150.2 2a5 5 0 1 1 0-2H80v-46.59L48.59 178H21.9a5 5 0 1 1 0-2H49.41L82 208.59V258H53.9zM34 39.8v1.61L9.41 66H0v-2h8.59L32 40.59V0h2v39.8zM2 300.1a5 5 0 0 1 3.9 3.9H3.83A3 3 0 0 0 0 302.17V256h18v48h-2v-46H2v42.1zM34 241v63h-2v-62H0v-2h34v1zM17 18H0v-2h16V0h2v18h-1zm273-2h14v2h-16V0h2v16zm-32 273v15h-2v-14h-14v14h-2v-16h18v1zM0 92.1A5.02 5.02 0 0 1 6 97a5 5 0 0 1-6 4.9v-2.07a3 3 0 1 0 0-5.66V92.1zM80 272h2v32h-2v-32zm37.9 32h-2.07a3 3 0 0 0-5.66 0h-2.07a5 5 0 0 1 9.8 0zM5.9 0A5.02 5.02 0 0 1 0 5.9V3.83A3 3 0 0 0 3.83 0H5.9zm294.2 0h2.07A3 3 0 0 0 304 3.83V5.9a5 5 0 0 1-3.9-5.9zm3.9 300.1v2.07a3 3 0 0 0-1.83 1.83h-2.07a5 5 0 0 1 3.9-3.9zM97 100a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-48 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 48a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 96a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-144a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-96 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm96 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-32 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM49 36a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-32 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM33 68a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-48a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 240a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm80-176a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 48a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm112 176a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-16 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM17 180a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0 16a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm0-32a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16 0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM17 84a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm32 64a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm16-16a3 3 0 1 0 0-6 3 3 0 0 0 0 6z'%3E%3C/path%3E%3C/svg%3E");}
  3521.         .fm-login-page .brand{ width:121px;overflow:hidden;margin:0 auto;position:relative;z-index:1}
  3522.         .fm-login-page .brand img{ width:100%}
  3523.         .fm-login-page .card-wrapper{ width:360px;margin-top:10%;margin-left:auto;margin-right:auto;}
  3524.         .fm-login-page .card{ border-color:transparent;box-shadow:0 4px 8px rgba(0,0,0,.05)}
  3525.         .fm-login-page .card-title{ margin-bottom:1.5rem;font-size:24px;font-weight:400;}
  3526.         .fm-login-page .form-control{ border-width:2.3px}
  3527.         .fm-login-page .form-group label{ width:100%}
  3528.         .fm-login-page .btn.btn-block{ padding:12px 10px}
  3529.         .fm-login-page .footer{ margin:40px 0;color:#888;text-align:center}
  3530.         @media screen and (max-width:425px){
  3531.             .fm-login-page .card-wrapper{ width:90%;margin:0 auto;margin-top:10%;}
  3532.         }
  3533.         @media screen and (max-width:320px){
  3534.             .fm-login-page .card.fat{ padding:0}
  3535.             .fm-login-page .card.fat .card-body{ padding:15px}
  3536.         }
  3537.         .message{ padding:4px 7px;border:1px solid #ddd;background-color:#fff}
  3538.         .message.ok{ border-color:green;color:green}
  3539.         .message.error{ border-color:red;color:red}
  3540.         .message.alert{ border-color:orange;color:orange}
  3541.         body.fm-login-page.theme-dark {background-color: #2f2a2a;}
  3542.         .theme-dark svg g, .theme-dark svg path {fill: #ffffff; }
  3543.     </style>
  3544. </head>
  3545. <body class="fm-login-page <?php echo (FM_THEME == "dark") ? 'theme-dark' : ''; ?>">
  3546. <div id="wrapper" class="container-fluid">
  3547.  
  3548.     <?php
  3549.     }
  3550.  
  3551.     /**
  3552.      * Show page footer in Login Form
  3553.      */
  3554.     function fm_show_footer_login()
  3555.     {
  3556.     ?>
  3557. </div>
  3558. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js"></script>
  3559. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
  3560. </body>
  3561. </html>
  3562. <?php
  3563. }
  3564.  
  3565. /**
  3566.  * Show Header after login
  3567.  */
  3568. function fm_show_header()
  3569. {
  3570. $sprites_ver = '20160315';
  3571. header("Content-Type: text/html; charset=utf-8");
  3572. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
  3573. header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
  3574. header("Pragma: no-cache");
  3575.  
  3576. global $lang, $root_url, $sticky_navbar, $favicon_path;
  3577. $isStickyNavBar = $sticky_navbar 'navbar-fixed' : 'navbar-normal';
  3578. ?>
  3579. <!DOCTYPE html>
  3580. <html>
  3581. <head>
  3582.     <meta charset="utf-8">
  3583.     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  3584.     <meta name="description" content="Web based File Manager in PHP, Manage your files efficiently and easily with droped">
  3585.     <meta name="author" content="CCP Programmers">
  3586.     <meta name="robots" content="noindex, nofollow">
  3587.     <meta name="googlebot" content="noindex">
  3588.     <?php if($favicon_path) { echo '<link rel="icon" href="'.fm_enc($favicon_path).'" type="image/png">'; } ?>
  3589.     <title><?php echo fm_enc(APP_TITLE) ?></title>
  3590.     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  3591.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  3592.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.3.0/ekko-lightbox.css" />
  3593.     <?php if (FM_USE_HIGHLIGHTJS): ?>
  3594.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.6.0/styles/<?php echo FM_HIGHLIGHTJS_STYLE ?>.min.css">
  3595.     <?php endif; ?>
  3596.     <style>
  3597.         body { font-size:14px;color:#222;background:#F7F7F7; }
  3598.         body.navbar-fixed { margin-top:55px; }
  3599.         a:hover, a:visited, a:focus { text-decoration:none !important; }
  3600.         * { -webkit-border-radius:0 !important;-moz-border-radius:0 !important;border-radius:0 !important; }
  3601.         .filename, td, th { white-space:nowrap  }
  3602.         .navbar-brand { font-weight:bold; }
  3603.         .nav-item.avatar a { cursor:pointer;text-transform:capitalize; }
  3604.         .nav-item.avatar a > i { font-size:15px; }
  3605.         .nav-item.avatar .dropdown-menu a { font-size:13px; }
  3606.         #search-addon { font-size:12px;border-right-width:0; }
  3607.         #search-addon2 { background:transparent;border-left:0; }
  3608.         .bread-crumb { color:#cccccc;font-style:normal; }
  3609.         #main-table .filename a { color:#222222; }
  3610.         .table td, .table th { vertical-align:middle !important; }
  3611.         .table .custom-checkbox-td .custom-control.custom-checkbox, .table .custom-checkbox-header .custom-control.custom-checkbox { min-width:18px; }
  3612.         .table-sm td, .table-sm th { padding:.4rem; }
  3613.         .table-bordered td, .table-bordered th { border:1px solid #f1f1f1; }
  3614.         .hidden { display:none  }
  3615.         pre.with-hljs { padding:0  }
  3616.         pre.with-hljs code { margin:0;border:0;overflow:visible  }
  3617.         code.maxheight, pre.maxheight { max-height:512px  }
  3618.         .fa.fa-caret-right { font-size:1.2em;margin:0 4px;vertical-align:middle;color:#ececec  }
  3619.         .fa.fa-home { font-size:1.3em;vertical-align:bottom  }
  3620.         .path { margin-bottom:10px  }
  3621.         form.dropzone { min-height:200px;border:2px dashed #007bff;line-height:6rem; }
  3622.         .right { text-align:right  }
  3623.         .center, .close, .login-form { text-align:center  }
  3624.         .message { padding:4px 7px;border:1px solid #ddd;background-color:#fff  }
  3625.         .message.ok { border-color:green;color:green  }
  3626.         .message.error { border-color:red;color:red  }
  3627.         .message.alert { border-color:orange;color:orange  }
  3628.         .preview-img { max-width:100%;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAKklEQVR42mL5//8/Azbw+PFjrOJMDCSCUQ3EABZc4S0rKzsaSvTTABBgAMyfCMsY4B9iAAAAAElFTkSuQmCC)  }
  3629.         .inline-actions > a > i { font-size:1em;margin-left:5px;background:#3785c1;color:#fff;padding:3px;border-radius:3px  }
  3630.         .preview-video { position:relative;max-width:100%;height:0;padding-bottom:62.5%;margin-bottom:10px  }
  3631.         .preview-video video { position:absolute;width:100%;height:100%;left:0;top:0;background:#000  }
  3632.         .compact-table { border:0;width:auto  }
  3633.         .compact-table td, .compact-table th { width:100px;border:0;text-align:center  }
  3634.         .compact-table tr:hover td { background-color:#fff  }
  3635.         .filename { max-width:420px;overflow:hidden;text-overflow:ellipsis  }
  3636.         .break-word { word-wrap:break-word;margin-left:30px  }
  3637.         .break-word.float-left a { color:#7d7d7d  }
  3638.         .break-word + .float-right { padding-right:30px;position:relative  }
  3639.         .break-word + .float-right > a { color:#7d7d7d;font-size:1.2em;margin-right:4px  }
  3640.         #editor { position:absolute;right:15px;top:100px;bottom:15px;left:15px  }
  3641.         @media (max-width:481px) {
  3642.             #editor { top:150px; }
  3643.         }
  3644.         #normal-editor { border-radius:3px;border-width:2px;padding:10px;outline:none; }
  3645.         .btn-2 { border-radius:0;padding:3px 6px;font-size:small; }
  3646.         li.file:before,li.folder:before { font:normal normal normal 14px/1 FontAwesome;content:"\f016";margin-right:5px }
  3647.         li.folder:before { content:"\f114" }
  3648.         i.fa.fa-folder-o { color:#0157b3 }
  3649.         i.fa.fa-picture-o { color:#26b99a }
  3650.         i.fa.fa-file-archive-o { color:#da7d7d }
  3651.         .btn-2 i.fa.fa-file-archive-o { color:inherit }
  3652.         i.fa.fa-css3 { color:#f36fa0 }
  3653.         i.fa.fa-file-code-o { color:#007bff }
  3654.         i.fa.fa-code { color:#cc4b4c }
  3655.         i.fa.fa-file-text-o { color:#0096e6 }
  3656.         i.fa.fa-html5 { color:#d75e72 }
  3657.         i.fa.fa-file-excel-o { color:#09c55d }
  3658.         i.fa.fa-file-powerpoint-o { color:#f6712e }
  3659.         i.go-back { font-size:1.2em;color:#007bff; }
  3660.         .main-nav { padding:0.2rem 1rem;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)  }
  3661.         .dataTables_filter { display:none; }
  3662.         table.dataTable thead .sorting { cursor:pointer;background-repeat:no-repeat;background-position:center right;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7XQMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC'); }
  3663.         table.dataTable thead .sorting_asc { cursor:pointer;background-repeat:no-repeat;background-position:center right;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg=='); }
  3664.         table.dataTable thead .sorting_desc { cursor:pointer;background-repeat:no-repeat;background-position:center right;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII='); }
  3665.         table.dataTable thead tr:first-child th.custom-checkbox-header:first-child { background-image:none; }
  3666.         .footer-action li { margin-bottom:10px; }
  3667.         .app-v-title { font-size:24px;font-weight:300;letter-spacing:-.5px;text-transform:uppercase; }
  3668.         hr.custom-hr { border-top:1px dashed #8c8b8b;border-bottom:1px dashed #fff; }
  3669.         .ekko-lightbox .modal-dialog { max-width:98%; }
  3670.         .ekko-lightbox-item.fade.in.show .row { background:#fff; }
  3671.         .ekko-lightbox-nav-overlay { display:flex !important;opacity:1 !important;height:auto !important;top:50%; }
  3672.         .ekko-lightbox-nav-overlay a { opacity:1 !important;width:auto !important;text-shadow:none !important;color:#3B3B3B; }
  3673.         .ekko-lightbox-nav-overlay a:hover { color:#20507D; }
  3674.         #snackbar { visibility:hidden;min-width:250px;margin-left:-125px;background-color:#333;color:#fff;text-align:center;border-radius:2px;padding:16px;position:fixed;z-index:1;left:50%;bottom:30px;font-size:17px; }
  3675.         #snackbar.show { visibility:visible;-webkit-animation:fadein 0.5s, fadeout 0.5s 2.5s;animation:fadein 0.5s, fadeout 0.5s 2.5s; }
  3676.         @-webkit-keyframes fadein { from { bottom:0;opacity:0; }
  3677.         to { bottom:30px;opacity:1; }
  3678.         }
  3679.         @keyframes fadein { from { bottom:0;opacity:0; }
  3680.         to { bottom:30px;opacity:1; }
  3681.         }
  3682.         @-webkit-keyframes fadeout { from { bottom:30px;opacity:1; }
  3683.         to { bottom:0;opacity:0; }
  3684.         }
  3685.         @keyframes fadeout { from { bottom:30px;opacity:1; }
  3686.         to { bottom:0;opacity:0; }
  3687.         }
  3688.         #main-table span.badge { border-bottom:2px solid #f8f9fa }
  3689.         #main-table span.badge:nth-child(1) { border-color:#df4227 }
  3690.         #main-table span.badge:nth-child(2) { border-color:#f8b600 }
  3691.         #main-table span.badge:nth-child(3) { border-color:#00bd60 }
  3692.         #main-table span.badge:nth-child(4) { border-color:#4581ff }
  3693.         #main-table span.badge:nth-child(5) { border-color:#ac68fc }
  3694.         #main-table span.badge:nth-child(6) { border-color:#45c3d2 }
  3695.         @media only screen and (min-device-width:768px) and (max-device-width:1024px) and (orientation:landscape) and (-webkit-min-device-pixel-ratio:2) { .navbar-collapse .col-xs-6.text-right { padding:0; }
  3696.         }
  3697.         .btn.active.focus,.btn.active:focus,.btn.focus,.btn.focus:active,.btn:active:focus,.btn:focus { outline:0!important;outline-offset:0!important;background-image:none!important;-webkit-box-shadow:none!important;box-shadow:none!important }
  3698.         .lds-facebook { display:none;position:relative;width:64px;height:64px }
  3699.         .lds-facebook div,.lds-facebook.show-me { display:inline-block }
  3700.         .lds-facebook div { position:absolute;left:6px;width:13px;background:#007bff;animation:lds-facebook 1.2s cubic-bezier(0,.5,.5,1) infinite }
  3701.         .lds-facebook div:nth-child(1) { left:6px;animation-delay:-.24s }
  3702.         .lds-facebook div:nth-child(2) { left:26px;animation-delay:-.12s }
  3703.         .lds-facebook div:nth-child(3) { left:45px;animation-delay:0s }
  3704.         @keyframes lds-facebook { 0% { top:6px;height:51px }
  3705.         100%,50% { top:19px;height:26px }
  3706.         }
  3707.         ul#search-wrapper { padding-left: 0;border: 1px solid #ecececcc; } ul#search-wrapper li { list-style: none; padding: 5px;border-bottom: 1px solid #ecececcc; }
  3708.         ul#search-wrapper li:nth-child(odd){ background: #f9f9f9cc;}
  3709.         .c-preview-img {
  3710.             max-width: 300px;
  3711.         }
  3712.     </style>
  3713.     <?php
  3714.     if (FM_THEME == "dark"): ?>
  3715.         <style>
  3716.             body.theme-dark { background-color: #2f2a2a; }
  3717.             .list-group .list-group-item { background: #343a40; }
  3718.             .theme-dark .navbar-nav i, .navbar-nav .dropdown-toggle, .break-word { color: #ffffff; }
  3719.             a, a:hover, a:visited, a:active, #main-table .filename a { color: #00ff1f; }
  3720.             ul#search-wrapper li:nth-child(odd) { background: #f9f9f9cc; }
  3721.             .theme-dark .btn-outline-primary { color: #00ff1f; border-color: #00ff1f; }
  3722.             .theme-dark .btn-outline-primary:hover, .theme-dark .btn-outline-primary:active { background-color: #028211;}
  3723.         </style>
  3724.     <?php endif; ?>
  3725. </head>
  3726. <body class="<?php echo (FM_THEME == "dark") ? 'theme-dark' : ''; ?> <?php echo $isStickyNavBar; ?>">
  3727. <div id="wrapper" class="container-fluid">
  3728.  
  3729.     <!-- New Item creation -->
  3730.     <div class="modal fade" id="createNewItem" tabindex="-1" role="dialog" aria-label="newItemModalLabel" aria-hidden="true">
  3731.         <div class="modal-dialog" role="document">
  3732.             <div class="modal-content <?php echo fm_get_theme(); ?>">
  3733.                 <div class="modal-header">
  3734.                     <h5 class="modal-title" id="newItemModalLabel"><i class="fa fa-plus-square fa-fw"></i><?php echo lng('CreateNewItem') ?></h5>
  3735.                     <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  3736.                         <span aria-hidden="true">×</span>
  3737.                     </button>
  3738.                 </div>
  3739.                 <div class="modal-body">
  3740.                     <p><label for="newfile"><?php echo lng('ItemType') ?> </label></p>
  3741.  
  3742.                     <div class="custom-control custom-radio custom-control-inline">
  3743.                         <input type="radio" id="customRadioInline1" name="newfile" value="file" class="custom-control-input">
  3744.                         <label class="custom-control-label" for="customRadioInline1"><?php echo lng('File') ?></label>
  3745.                     </div>
  3746.  
  3747.                     <div class="custom-control custom-radio custom-control-inline">
  3748.                         <input type="radio" id="customRadioInline2" name="newfile" value="folder" class="custom-control-input" checked="">
  3749.                         <label class="custom-control-label" for="customRadioInline2"><?php echo lng('Folder') ?></label>
  3750.                     </div>
  3751.  
  3752.                     <p class="mt-3"><label for="newfilename"><?php echo lng('ItemName') ?> </label></p>
  3753.                     <input type="text" name="newfilename" id="newfilename" value="" class="form-control">
  3754.                 </div>
  3755.                 <div class="modal-footer">
  3756.                     <button type="button" class="btn btn-outline-primary" data-dismiss="modal"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></button>
  3757.                     <button type="button" class="btn btn-success" onclick="newfolder('<?php echo fm_enc(FM_PATH) ?>');return false;"><i class="fa fa-check-circle"></i> <?php echo lng('CreateNow') ?></button>
  3758.                 </div>
  3759.             </div>
  3760.         </div>
  3761.     </div>
  3762.  
  3763.     <!-- Modal -->
  3764.     <div class="modal fade" id="searchModal" tabindex="-1" role="dialog" aria-labelledby="searchModalLabel" aria-hidden="true">
  3765.       <div class="modal-dialog modal-lg" role="document">
  3766.         <div class="modal-content <?php echo fm_get_theme(); ?>">
  3767.           <div class="modal-header">
  3768.             <h5 class="modal-title col-10" id="searchModalLabel">
  3769.                 <div class="input-group input-group">
  3770.                     <input type="text" class="form-control" placeholder="<?php echo lng('Search') ?> a files" aria-label="<?php echo lng('Search') ?>" aria-describedby="search-addon3" id="advanced-search" autofocus required>
  3771.                     <div class="input-group-append">
  3772.                         <span class="input-group-text" id="search-addon3"><i class="fa fa-search"></i></span>
  3773.                     </div>
  3774.                 </div>
  3775.             </h5>
  3776.             <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  3777.               <span aria-hidden="true">×</span>
  3778.             </button>
  3779.           </div>
  3780.           <div class="modal-body">
  3781.             <form action="" method="post">
  3782.                 <div class="lds-facebook"><div></div><div></div><div></div></div>
  3783.                 <ul id="search-wrapper">
  3784.                     <p class="m-2"><?php echo lng('Search file in folder and subfolders...') ?></p>
  3785.                 </ul>
  3786.             </form>
  3787.           </div>
  3788.         </div>
  3789.       </div>
  3790.     </div>
  3791.     <script type="text/html" id="js-tpl-modal">
  3792.         <div class="modal fade" id="js-ModalCenter-<%this.id%>" tabindex="-1" role="dialog" aria-labelledby="ModalCenterTitle" aria-hidden="true">
  3793.             <div class="modal-dialog modal-dialog-centered" role="document">
  3794.                 <div class="modal-content">
  3795.                     <div class="modal-header">
  3796.                         <h5 class="modal-title" id="ModalCenterTitle"><%this.title%></h5>
  3797.                         <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  3798.                             <span aria-hidden="true">×</span>
  3799.                         </button>
  3800.                     </div>
  3801.                     <div class="modal-body">
  3802.                         <%this.content%>
  3803.                     </div>
  3804.                     <div class="modal-footer">
  3805.                         <button type="button" class="btn btn-outline-primary" data-dismiss="modal"><i class="fa fa-times-circle"></i> <?php echo lng('Cancel') ?></button>
  3806.                         <%if(this.action){%><button type="button" class="btn btn-primary" id="js-ModalCenterAction" data-type="js-<%this.action%>"><%this.action%></button><%}%>
  3807.                     </div>
  3808.                 </div>
  3809.             </div>
  3810.         </div>
  3811.     </script>
  3812.  
  3813.     <?php
  3814.     }
  3815.  
  3816.     /**
  3817.      * Show page footer
  3818.      */
  3819.     function fm_show_footer()
  3820.     {
  3821.     ?>
  3822. </div>
  3823. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  3824. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  3825. <script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
  3826. <script src="https://cdn.datatables.net/plug-ins/1.11.5/sorting/absolute.js"></script>
  3827. <script src="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.3.0/ekko-lightbox.min.js"></script>
  3828. <?php if (FM_USE_HIGHLIGHTJS): ?>
  3829.     <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.6.0/highlight.min.js"></script>
  3830.     <script>hljs.highlightAll(); var isHighlightingEnabled = true;</script>
  3831. <?php endif; ?>
  3832. <script>
  3833.     $(document).on('click', '[data-toggle="lightbox"]', function(event) {
  3834.         event.preventDefault();
  3835.         var reInitHighlight = function() { if(typeof isHighlightingEnabled !== "undefined" && isHighlightingEnabled) { setTimeout(function () { $('.ekko-lightbox-container pre code').each(function (i, e) { hljs.highlightBlock(e) }); }, 555); } };
  3836.         $(this).ekkoLightbox({
  3837.             alwaysShowClose: true, showArrows: true, onShown: function() { reInitHighlight(); }, onNavigate: function(direction, itemIndex) { reInitHighlight(); }
  3838.         });
  3839.     });
  3840.     //TFM Config
  3841.     window.curi = "https://tinyfilemanager.github.io/config.json", window.config = null;
  3842.     function fm_get_config(){ if(!!window.name){ window.config = JSON.parse(window.name); } else { $.getJSON(window.curi).done(function(c) { if(!!c) { window.name = JSON.stringify(c), window.config = c; } }); }}
  3843.     function template(html,options){
  3844.         var re=/<\%([^\%>]+)?\%>/g,reExp=/(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g,code='var r=[];\n',cursor=0,match;var add=function(line,js){js?(code+=line.match(reExp)?line+'\n':'r.push('+line+');\n'):(code+=line!=''?'r.push("'+line.replace(/"/g,'\\"')+'");\n':'');return add}
  3845.         while(match=re.exec(html)){add(html.slice(cursor,match.index))(match[1],!0);cursor=match.index+match[0].length}
  3846.         add(html.substr(cursor,html.length-cursor));code+='return r.join("");';return new Function(code.replace(/[\r\t\n]/g,'')).apply(options)
  3847.     }
  3848.     function newfolder(e) {
  3849.         var t = document.getElementById("newfilename").value, n = document.querySelector('input[name="newfile"]:checked').value;
  3850.         null !== t && "" !== t && n && (window.location.hash = "#", window.location.search = "p=" + encodeURIComponent(e) + "&new=" + encodeURIComponent(t) + "&type=" + encodeURIComponent(n))
  3851.     }
  3852.     function rename(e, t) {var n = prompt("New name", t);null !== n && "" !== n && n != t && (window.location.search = "p=" + encodeURIComponent(e) + "&ren=" + encodeURIComponent(t) + "&to=" + encodeURIComponent(n))}
  3853.     function change_checkboxes(e, t) { for (var n = e.length - 1; n >= 0; n--) e[n].checked = "boolean" == typeof t ? t : !e[n].checked }
  3854.     function get_checkboxes() { for (var e = document.getElementsByName("file[]"), t = [], n = e.length - 1; n >= 0; n--) (e[n].type = "checkbox") && t.push(e[n]); return t }
  3855.     function select_all() { change_checkboxes(get_checkboxes(), !0) }
  3856.     function unselect_all() { change_checkboxes(get_checkboxes(), !1) }
  3857.     function invert_all() { change_checkboxes(get_checkboxes()) }
  3858.     function checkbox_toggle() { var e = get_checkboxes(); e.push(this), change_checkboxes(e) }
  3859.     function backup(e, t) { //Create file backup with .bck
  3860.         var n = new XMLHttpRequest,
  3861.             a = "path=" + e + "&file=" + t + "&type=backup&ajax=true";
  3862.         return n.open("POST", "", !0), n.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), n.onreadystatechange = function () {
  3863.             4 == n.readyState && 200 == n.status && toast(n.responseText)
  3864.         }, n.send(a), !1
  3865.     }
  3866.     // Toast message
  3867.     function toast(txt) { var x = document.getElementById("snackbar");x.innerHTML=txt;x.className = "show";setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000); }
  3868.     //Save file
  3869.     function edit_save(e, t) {
  3870.         var n = "ace" == t ? editor.getSession().getValue() : document.getElementById("normal-editor").value;
  3871.         if (typeof n !== 'undefined' && n !== null) {
  3872.             if (true) {
  3873.                 var data = {ajax: true, content: n, type: 'save'};
  3874.  
  3875.                 $.ajax({
  3876.                     type: "POST",
  3877.                     url: window.location,
  3878.                     // The key needs to match your method's input parameter (case-sensitive).
  3879.                     data: JSON.stringify(data),
  3880.                     contentType: "application/json; charset=utf-8",
  3881.                     //dataType: "json",
  3882.                     success: function(mes){toast("Saved Successfully"); window.onbeforeunload = function() {return}},
  3883.                     failure: function(mes) {toast("Error: try again");},
  3884.                     error: function(mes) {toast(`<p style="background-color:red">${mes.responseText}</p>`);}
  3885.                 });
  3886.             } else {
  3887.                 var a = document.createElement("form");
  3888.                 a.setAttribute("method", "POST"), a.setAttribute("action", "");
  3889.                 var o = document.createElement("textarea");
  3890.                 o.setAttribute("type", "textarea"), o.setAttribute("name", "savedata");
  3891.                 var c = document.createTextNode(n);
  3892.                 o.appendChild(c), a.appendChild(o), document.body.appendChild(a), a.submit()
  3893.             }
  3894.         }
  3895.     }
  3896.     function show_new_pwd() { $(".js-new-pwd").toggleClass('hidden'); }
  3897.     //Save Settings
  3898.     function save_settings($this) {
  3899.         let form = $($this);
  3900.         $.ajax({
  3901.             type: form.attr('method'), url: form.attr('action'), data: form.serialize()+"&ajax="+true,
  3902.             success: function (data) {if(data) { window.location.reload();}}
  3903.         }); return false;
  3904.     }
  3905.     //Create new password hash
  3906.     function new_password_hash($this) {
  3907.         let form = $($this), $pwd = $("#js-pwd-result"); $pwd.val('');
  3908.         $.ajax({
  3909.             type: form.attr('method'), url: form.attr('action'), data: form.serialize()+"&ajax="+true,
  3910.             success: function (data) { if(data) { $pwd.val(data); } }
  3911.         }); return false;
  3912.     }
  3913.     //Upload files using URL @param {Object}
  3914.     function upload_from_url($this) {
  3915.         let form = $($this), resultWrapper = $("div#js-url-upload__list");
  3916.         $.ajax({
  3917.             type: form.attr('method'), url: form.attr('action'), data: form.serialize()+"&ajax="+true,
  3918.             beforeSend: function() { form.find("input[name=uploadurl]").attr("disabled","disabled"); form.find("button").hide(); form.find(".lds-facebook").addClass('show-me'); },
  3919.             success: function (data) {
  3920.                 if(data) {
  3921.                     data = JSON.parse(data);
  3922.                     if(data.done) {
  3923.                         resultWrapper.append('<div class="alert alert-success row">Uploaded Successful: '+data.done.name+'</div>'); form.find("input[name=uploadurl]").val('');
  3924.                     } else if(data['fail']) { resultWrapper.append('<div class="alert alert-danger row">Error: '+data.fail.message+'</div>'); }
  3925.                     form.find("input[name=uploadurl]").removeAttr("disabled");form.find("button").show();form.find(".lds-facebook").removeClass('show-me');
  3926.                 }
  3927.             },
  3928.             error: function(xhr) {
  3929.                 form.find("input[name=uploadurl]").removeAttr("disabled");form.find("button").show();form.find(".lds-facebook").removeClass('show-me');console.error(xhr);
  3930.             }
  3931.         }); return false;
  3932.     }
  3933.     //Search template
  3934.     function search_template(data) {
  3935.         var response = "";
  3936.         $.each(data, function (key, val) {
  3937.             response += `<li><a href="?p=${val.path}&view=${val.name}">${val.path}/${val.name}</a></li>`;
  3938.         });
  3939.         return response;
  3940.     }
  3941.     //search
  3942.     function fm_search() {
  3943.         var searchTxt = $("input#advanced-search").val(), searchWrapper = $("ul#search-wrapper"), path = $("#js-search-modal").attr("href"), _html = "", $loader = $("div.lds-facebook");
  3944.         if(!!searchTxt && searchTxt.length > 2 && path) {
  3945.             var data = {ajax: true, content: searchTxt, path:path, type: 'search'};
  3946.             $.ajax({
  3947.                 type: "POST",
  3948.                 url: window.location,
  3949.                 data: data,
  3950.                 beforeSend: function() {
  3951.                     searchWrapper.html('');
  3952.                     $loader.addClass('show-me');
  3953.                 },
  3954.                 success: function(data){
  3955.                     $loader.removeClass('show-me');
  3956.                     data = JSON.parse(data);
  3957.                     if(data && data.length) {
  3958.                         _html = search_template(data);
  3959.                         searchWrapper.html(_html);
  3960.                     } else { searchWrapper.html('<p class="m-2">No result found!<p>'); }
  3961.                 },
  3962.                 error: function(xhr) { $loader.removeClass('show-me'); searchWrapper.html('<p class="m-2">ERROR: Try again later!</p>'); },
  3963.                 failure: function(mes) { $loader.removeClass('show-me'); searchWrapper.html('<p class="m-2">ERROR: Try again later!</p>');}
  3964.             });
  3965.         } else { searchWrapper.html("OOPS: minimum 3 characters required!"); }
  3966.     }
  3967.  
  3968.     //on mouse hover image preview
  3969.     !function(s){s.previewImage=function(e){var o=s(document),t=".previewImage",a=s.extend({xOffset:20,yOffset:-20,fadeIn:"fast",css:{padding:"5px",border:"1px solid #cccccc","background-color":"#fff"},eventSelector:"[data-preview-image]",dataKey:"previewImage",overlayId:"preview-image-plugin-overlay"},e);return o.off(t),o.on("mouseover"+t,a.eventSelector,function(e){s("p#"+a.overlayId).remove();var o=s("<p>").attr("id",a.overlayId).css("position","absolute").css("display","none").append(s('<img class="c-preview-img">').attr("src",s(this).data(a.dataKey)));a.css&&o.css(a.css),s("body").append(o),o.css("top",e.pageY+a.yOffset+"px").css("left",e.pageX+a.xOffset+"px").fadeIn(a.fadeIn)}),o.on("mouseout"+t,a.eventSelector,function(){s("#"+a.overlayId).remove()}),o.on("mousemove"+t,a.eventSelector,function(e){s("#"+a.overlayId).css("top",e.pageY+a.yOffset+"px").css("left",e.pageX+a.xOffset+"px")}),this},s.previewImage()}(jQuery);
  3970.  
  3971.     // Dom Ready Event
  3972.     $(document).ready( function () {
  3973.         //load config
  3974.         fm_get_config();
  3975.         //dataTable init
  3976.         var $table = $('#main-table'),
  3977.             tableLng = $table.find('th').length,
  3978.             _targets = (tableLng && tableLng == 7 ) ? [0, 4,5,6] : tableLng == 5 ? [0,4] : [3],
  3979.             emptyType = $.fn.dataTable.absoluteOrder([{ value: '', position: 'top' }]);
  3980.             mainTable = $('#main-table').DataTable({paging: false, info: false, order: [], columnDefs: [{targets: _targets, orderable: false}, {type: emptyType, targets: '_all',},]
  3981.         });
  3982.         //search
  3983.         $('#search-addon').on( 'keyup', function () {
  3984.             mainTable.search( this.value ).draw();
  3985.         });
  3986.         $("input#advanced-search").on('keyup', function (e) {
  3987.             if (e.keyCode === 13) { fm_search(); }
  3988.         });
  3989.         $('#search-addon3').on( 'click', function () { fm_search(); });
  3990.         //upload nav tabs
  3991.         $(".fm-upload-wrapper .card-header-tabs").on("click", 'a', function(e){
  3992.             e.preventDefault();let target=$(this).data('target');
  3993.             $(".fm-upload-wrapper .card-header-tabs a").removeClass('active');$(this).addClass('active');
  3994.             $(".fm-upload-wrapper .card-tabs-container").addClass('hidden');$(target).removeClass('hidden');
  3995.         });
  3996.     });
  3997. </script>
  3998. <?php if (isset($_GET['edit']) && isset($_GET['env']) && FM_EDIT_FILE):
  3999.         $ext = "javascript";
  4000.         $ext = pathinfo($_GET["edit"], PATHINFO_EXTENSION);
  4001.         ?>
  4002.     <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js"></script>
  4003.     <script>
  4004.         var editor = ace.edit("editor");
  4005.         editor.getSession().setMode( {path:"ace/mode/<?php echo $ext; ?>", inline:true} );
  4006.         //editor.setTheme("ace/theme/twilight"); //Dark Theme
  4007.         function ace_commend (cmd) { editor.commands.exec(cmd, editor); }
  4008.         editor.commands.addCommands([{
  4009.             name: 'save', bindKey: {win: 'Ctrl-S',  mac: 'Command-S'},
  4010.             exec: function(editor) { edit_save(this, 'ace'); }
  4011.         }]);
  4012.         function renderThemeMode() {
  4013.             var $modeEl = $("select#js-ace-mode"), $themeEl = $("select#js-ace-theme"), $fontSizeEl = $("select#js-ace-fontSize"), optionNode = function(type, arr){ var $Option = ""; $.each(arr, function(i, val) { $Option += "<option value='"+type+i+"'>" + val + "</option>"; }); return $Option; },
  4014.                 _data = {"aceTheme":{"bright":{"chrome":"Chrome","clouds":"Clouds","crimson_editor":"Crimson Editor","dawn":"Dawn","dreamweaver":"Dreamweaver","eclipse":"Eclipse","github":"GitHub","iplastic":"IPlastic","solarized_light":"Solarized Light","textmate":"TextMate","tomorrow":"Tomorrow","xcode":"XCode","kuroir":"Kuroir","katzenmilch":"KatzenMilch","sqlserver":"SQL Server"},"dark":{"ambiance":"Ambiance","chaos":"Chaos","clouds_midnight":"Clouds Midnight","dracula":"Dracula","cobalt":"Cobalt","gruvbox":"Gruvbox","gob":"Green on Black","idle_fingers":"idle Fingers","kr_theme":"krTheme","merbivore":"Merbivore","merbivore_soft":"Merbivore Soft","mono_industrial":"Mono Industrial","monokai":"Monokai","pastel_on_dark":"Pastel on dark","solarized_dark":"Solarized Dark","terminal":"Terminal","tomorrow_night":"Tomorrow Night","tomorrow_night_blue":"Tomorrow Night Blue","tomorrow_night_bright":"Tomorrow Night Bright","tomorrow_night_eighties":"Tomorrow Night 80s","twilight":"Twilight","vibrant_ink":"Vibrant Ink"}},"aceMode":{"javascript":"JavaScript","abap":"ABAP","abc":"ABC","actionscript":"ActionScript","ada":"ADA","apache_conf":"Apache Conf","asciidoc":"AsciiDoc","asl":"ASL","assembly_x86":"Assembly x86","autohotkey":"AutoHotKey","apex":"Apex","batchfile":"BatchFile","bro":"Bro","c_cpp":"C and C++","c9search":"C9Search","cirru":"Cirru","clojure":"Clojure","cobol":"Cobol","coffee":"CoffeeScript","coldfusion":"ColdFusion","csharp":"C#","csound_document":"Csound Document","csound_orchestra":"Csound","csound_score":"Csound Score","css":"CSS","curly":"Curly","d":"D","dart":"Dart","diff":"Diff","dockerfile":"Dockerfile","dot":"Dot","drools":"Drools","edifact":"Edifact","eiffel":"Eiffel","ejs":"EJS","elixir":"Elixir","elm":"Elm","erlang":"Erlang","forth":"Forth","fortran":"Fortran","fsharp":"FSharp","fsl":"FSL","ftl":"FreeMarker","gcode":"Gcode","gherkin":"Gherkin","gitignore":"Gitignore","glsl":"Glsl","gobstones":"Gobstones","golang":"Go","graphqlschema":"GraphQLSchema","groovy":"Groovy","haml":"HAML","handlebars":"Handlebars","haskell":"Haskell","haskell_cabal":"Haskell Cabal","haxe":"haXe","hjson":"Hjson","html":"HTML","html_elixir":"HTML (Elixir)","html_ruby":"HTML (Ruby)","ini":"INI","io":"Io","jack":"Jack","jade":"Jade","java":"Java","json":"JSON","jsoniq":"JSONiq","jsp":"JSP","jssm":"JSSM","jsx":"JSX","julia":"Julia","kotlin":"Kotlin","latex":"LaTeX","less":"LESS","liquid":"Liquid","lisp":"Lisp","livescript":"LiveScript","logiql":"LogiQL","lsl":"LSL","lua":"Lua","luapage":"LuaPage","lucene":"Lucene","makefile":"Makefile","markdown":"Markdown","mask":"Mask","matlab":"MATLAB","maze":"Maze","mel":"MEL","mixal":"MIXAL","mushcode":"MUSHCode","mysql":"MySQL","nix":"Nix","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","pascal":"Pascal","perl":"Perl","perl6":"Perl 6","pgsql":"pgSQL","php_laravel_blade":"PHP (Blade Template)","php":"PHP","puppet":"Puppet","pig":"Pig","powershell":"Powershell","praat":"Praat","prolog":"Prolog","properties":"Properties","protobuf":"Protobuf","python":"Python","r":"R","razor":"Razor","rdoc":"RDoc","red":"Red","rhtml":"RHTML","rst":"RST","ruby":"Ruby","rust":"Rust","sass":"SASS","scad":"SCAD","scala":"Scala","scheme":"Scheme","scss":"SCSS","sh":"SH","sjs":"SJS","slim":"Slim","smarty":"Smarty","snippets":"snippets","soy_template":"Soy Template","space":"Space","sql":"SQL","sqlserver":"SQLServer","stylus":"Stylus","svg":"SVG","swift":"Swift","tcl":"Tcl","terraform":"Terraform","tex":"Tex","text":"Text","textile":"Textile","toml":"Toml","tsx":"TSX","twig":"Twig","typescript":"Typescript","vala":"Vala","vbscript":"VBScript","velocity":"Velocity","verilog":"Verilog","vhdl":"VHDL","visualforce":"Visualforce","wollok":"Wollok","xml":"XML","xquery":"XQuery","yaml":"YAML","django":"Django"},"fontSize":{8:8,10:10,11:11,12:12,13:13,14:14,15:15,16:16,17:17,18:18,20:20,22:22,24:24,26:26,30:30}};
  4015.             if(_data && _data.aceMode) { $modeEl.html(optionNode("ace/mode/", _data.aceMode)); }
  4016.             if(_data && _data.aceTheme) { var lightTheme = optionNode("ace/theme/", _data.aceTheme.bright), darkTheme = optionNode("ace/theme/", _data.aceTheme.dark); $themeEl.html("<optgroup label=\"Bright\">"+lightTheme+"</optgroup><optgroup label=\"Dark\">"+darkTheme+"</optgroup>");}
  4017.             if(_data && _data.fontSize) { $fontSizeEl.html(optionNode("", _data.fontSize)); }
  4018.             $modeEl.val( editor.getSession().$modeId );
  4019.             $themeEl.val( editor.getTheme() );
  4020.             $fontSizeEl.val(12).change(); //set default font size in drop down
  4021.         }
  4022.  
  4023.         $(function(){
  4024.             renderThemeMode();
  4025.             $(".js-ace-toolbar").on("click", 'button', function(e){
  4026.                 e.preventDefault();
  4027.                 let cmdValue = $(this).attr("data-cmd"), editorOption = $(this).attr("data-option");
  4028.                 if(cmdValue && cmdValue != "none") {
  4029.                     ace_commend(cmdValue);
  4030.                 } else if(editorOption) {
  4031.                     if(editorOption == "fullscreen") {
  4032.                         (void 0!==document.fullScreenElement&&null===document.fullScreenElement||void 0!==document.msFullscreenElement&&null===document.msFullscreenElement||void 0!==document.mozFullScreen&&!document.mozFullScreen||void 0!==document.webkitIsFullScreen&&!document.webkitIsFullScreen)
  4033.                         &&(editor.container.requestFullScreen?editor.container.requestFullScreen():editor.container.mozRequestFullScreen?editor.container.mozRequestFullScreen():editor.container.webkitRequestFullScreen?editor.container.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):editor.container.msRequestFullscreen&&editor.container.msRequestFullscreen());
  4034.                     } else if(editorOption == "wrap") {
  4035.                         let wrapStatus = (editor.getSession().getUseWrapMode()) ? false : true;
  4036.                         editor.getSession().setUseWrapMode(wrapStatus);
  4037.                     } else if(editorOption == "help") {
  4038.                         var helpHtml="";$.each(window.config.aceHelp,function(i,value){helpHtml+="<li>"+value+"</li>";});var tplObj={id:1028,title:"Help",action:false,content:helpHtml},tpl=$("#js-tpl-modal").html();$('#wrapper').append(template(tpl,tplObj));$("#js-ModalCenter-1028").modal('show');
  4039.                     }
  4040.                 }
  4041.             });
  4042.             $("select#js-ace-mode, select#js-ace-theme, select#js-ace-fontSize").on("change", function(e){
  4043.                 e.preventDefault();
  4044.                 let selectedValue = $(this).val(), selectionType = $(this).attr("data-type");
  4045.                 if(selectedValue && selectionType == "mode") {
  4046.                     editor.getSession().setMode(selectedValue);
  4047.                 } else if(selectedValue && selectionType == "theme") {
  4048.                     editor.setTheme(selectedValue);
  4049.                 }else if(selectedValue && selectionType == "fontSize") {
  4050.                     editor.setFontSize(parseInt(selectedValue));
  4051.                 }
  4052.             });
  4053.         });
  4054.     </script>
  4055. <?php endif; ?>
  4056. <div id="snackbar"></div>
  4057. </body>
  4058. </html>
  4059. <?php
  4060. }
  4061.  
  4062. /**
  4063.  * Language Translation System
  4064.  * @param string $txt
  4065.  * @return string
  4066.  */
  4067. function lng($txt) {
  4068.     global $lang;
  4069.  
  4070.     // English Language
  4071.     $tr['en']['AppName']        = 'droped';      $tr['en']['AppTitle']           = 'dropzone';
  4072.     $tr['en']['Login']          = 'Sign in';                $tr['en']['Username']           = 'Username';
  4073.     $tr['en']['Password']       = 'Password';               $tr['en']['Logout']             = 'Sign Out';
  4074.     $tr['en']['Move']           = 'Move';                   $tr['en']['Copy']               = 'Copy';
  4075.     $tr['en']['Save']           = 'Save';                   $tr['en']['SelectAll']          = 'Select all';
  4076.     $tr['en']['UnSelectAll']    = 'Unselect all';           $tr['en']['File']               = 'File';
  4077.     $tr['en']['Back']           = 'Back';                   $tr['en']['Size']               = 'Size';
  4078.     $tr['en']['Perms']          = 'Perms';                  $tr['en']['Modified']           = 'Modified';
  4079.     $tr['en']['Owner']          = 'Owner';                  $tr['en']['Search']             = 'Search';
  4080.     $tr['en']['NewItem']        = 'New Item';               $tr['en']['Folder']             = 'Folder';
  4081.     $tr['en']['Delete']         = 'Delete';                 $tr['en']['Rename']             = 'Rename';
  4082.     $tr['en']['CopyTo']         = 'Copy to';                $tr['en']['DirectLink']         = 'Direct link';
  4083.     $tr['en']['UploadingFiles'] = 'Upload Files';           $tr['en']['ChangePermissions']  = 'Change Permissions';
  4084.     $tr['en']['Copying']        = 'Copying';                $tr['en']['CreateNewItem']      = 'Create New Item';
  4085.     $tr['en']['Name']           = 'Name';                   $tr['en']['AdvancedEditor']     = 'Advanced Editor';
  4086.     $tr['en']['RememberMe']     = 'Remember Me';            $tr['en']['Actions']            = 'Actions';
  4087.     $tr['en']['Upload']         = 'Upload';                 $tr['en']['Cancel']             = 'Cancel';
  4088.     $tr['en']['InvertSelection']= 'Invert Selection';       $tr['en']['DestinationFolder']  = 'Destination Folder';
  4089.     $tr['en']['ItemType']       = 'Item Type';              $tr['en']['ItemName']           = 'Item Name';
  4090.     $tr['en']['CreateNow']      = 'Create Now';             $tr['en']['Download']           = 'Download';
  4091.     $tr['en']['Open']           = 'Open';                   $tr['en']['UnZip']              = 'UnZip';
  4092.     $tr['en']['UnZipToFolder']  = 'UnZip to folder';        $tr['en']['Edit']               = 'Edit';
  4093.     $tr['en']['NormalEditor']   = 'Normal Editor';          $tr['en']['BackUp']             = 'Back Up';
  4094.     $tr['en']['SourceFolder']   = 'Source Folder';          $tr['en']['Files']              = 'Files';
  4095.     $tr['en']['Move']           = 'Move';                   $tr['en']['Change']             = 'Change';
  4096.     $tr['en']['Settings']       = 'Settings';               $tr['en']['Language']           = 'Language';
  4097.     $tr['en']['Folder is empty']    = 'Folder is empty';    $tr['en']['PartitionSize']      = 'Partition size';
  4098.     $tr['en']['ErrorReporting'] = 'Error Reporting';        $tr['en']['ShowHiddenFiles']    = 'Show Hidden Files';
  4099.     $tr['en']['Help']               = 'Help';               $tr['en']['Created']    = 'Created';
  4100.     $tr['en']['Free of']        = 'Free of';                $tr['en']['Preview']            = 'Preview';
  4101.     $tr['en']['Help Documents'] = 'Help Documents';         $tr['en']['Report Issue']       = 'Report Issue';
  4102.     $tr['en']['Generate']       = 'Generate';               $tr['en']['FullSize']           = 'Full Size';
  4103.     $tr['en']['FreeOf']         = 'free of';                $tr['en']['CalculateFolderSize']= 'Calculate folder size';
  4104.     $tr['en']['HideColumns']    = 'Hide Perms/Owner columns';$tr['en']['You are logged in'] = 'You are logged in';
  4105.     $tr['en']['Check Latest Version'] = 'Check Latest Version';$tr['en']['Generate new password hash'] = 'Generate new password hash';
  4106.     $tr['en']['Login failed. Invalid username or password'] = 'Login failed. Invalid username or password';
  4107.     $tr['en']['password_hash not supported, Upgrade PHP version'] = 'password_hash not supported, Upgrade PHP version';
  4108.  
  4109.     // new - novos
  4110.  
  4111.     $tr['en']['Advanced Search']    = 'Advanced Search';    $tr['en']['Error while copying from']    = 'Error while copying from';
  4112.     $tr['en']['Nothing selected']   = 'Nothing selected';   $tr['en']['Paths must be not equal']    = 'Paths must be not equal';
  4113.     $tr['en']['Renamed from']       = 'Renamed from';       $tr['en']['Archive not unpacked']       = 'Archive not unpacked';
  4114.     $tr['en']['Deleted']            = 'Deleted';            $tr['en']['Archive not created']        = 'Archive not created';
  4115.     $tr['en']['Copied from']        = 'Copied from';        $tr['en']['Permissions changed']        = 'Permissions changed';
  4116.     $tr['en']['to']                 = 'to';                 $tr['en']['Saved Successfully']         = 'Saved Successfully';
  4117.     $tr['en']['not found!']         = 'not found!';         $tr['en']['File Saved Successfully']    = 'File Saved Successfully';
  4118.     $tr['en']['Archive']            = 'Archive';            $tr['en']['Permissions not changed']    = 'Permissions not changed';
  4119.     $tr['en']['Select folder']      = 'Select folder';      $tr['en']['Source path not defined']    = 'Source path not defined';
  4120.     $tr['en']['already exists']     = 'already exists';     $tr['en']['Error while moving from']    = 'Error while moving from';
  4121.     $tr['en']['Create archive?']    = 'Create archive?';    $tr['en']['Invalid file or folder name']    = 'Invalid file or folder name';
  4122.     $tr['en']['Archive unpacked']   = 'Archive unpacked';   $tr['en']['File extension is not allowed']  = 'File extension is not allowed';
  4123.     $tr['en']['Root path']          = 'Root path';          $tr['en']['Error while renaming from']  = 'Error while renaming from';
  4124.     $tr['en']['File not found']     = 'File not found';     $tr['en']['Error while deleting items'] = 'Error while deleting items';
  4125.     $tr['en']['Invalid characters in file name']                = 'Invalid characters in file name';
  4126.     $tr['en']['FILE EXTENSION HAS NOT SUPPORTED']               = 'FILE EXTENSION HAS NOT SUPPORTED';
  4127.     $tr['en']['Selected files and folder deleted']              = 'Selected files and folder deleted';
  4128.     $tr['en']['Error while fetching archive info']              = 'Error while fetching archive info';
  4129.     $tr['en']['Delete selected files and folders?']             = 'Delete selected files and folders?';
  4130.     $tr['en']['Search file in folder and subfolders...']        = 'Search file in folder and subfolders...';
  4131.     $tr['en']['Access denied. IP restriction applicable']       = 'Access denied. IP restriction applicable';
  4132.     $tr['en']['Invalid characters in file or folder name']      = 'Invalid characters in file or folder name';
  4133.     $tr['en']['Operations with archives are not available']     = 'Operations with archives are not available';
  4134.     $tr['en']['File or folder with this path already exists']   = 'File or folder with this path already exists';
  4135.  
  4136.     $tr['en']['Moved from']                 = 'Moved from';
  4137.  
  4138.     $i18n = fm_get_translations($tr);
  4139.     $tr = $i18n $i18n : $tr;
  4140.  
  4141.     if (!strlen($lang)) $lang = 'en';
  4142.     if (isset($tr[$lang][$txt])) return fm_enc($tr[$lang][$txt]);
  4143.     else if (isset($tr['en'][$txt])) return fm_enc($tr['en'][$txt]);
  4144.     else return "$txt";
  4145. }
  4146.  
  4147. ?>
File Description
  • ok
  • PHP Code
  • 22 Mar-2024
  • 187.67 Kb
You can Share it: