// Show or hide files and folders that starts with a dot
$show_hidden_files = true;
// Enable highlight.js (https://highlightjs.org/) on view's page
$use_highlightjs = true;
// highlight.js style
$highlightjs_style = 'vs';
// Enable ace.js (https://ace.c9.io/) on view's page
$edit_files = true;
// Send files though mail
$send_mail = false;
// Send files though mail
$toMailId = ""; //yourmailid@mail.com
// Default timezone for date() and time() - http://php.net/manual/en/timezones.php
$default_timezone = 'Etc/UTC'; // UTC
// Root path for file manager
$root_path = $_SERVER['DOCUMENT_ROOT'];
// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
// Will not working if $root_path will be outside of server document root
$root_url = '';
// Server hostname. Can set manually if wrong
$http_host = $_SERVER['HTTP_HOST'];
// input encoding for iconv
$iconv_input_encoding = 'UTF-8';
// date() format for file modification date
$datetime_format = 'd.m.y H:i';
//AJAX Request
if (isset($_POST['ajax']) && !FM_READONLY) {
//search : get list of files from the current folder
if(isset($_POST['type']) && $_POST['type']=="search") {
$dir = $_POST['path'];
$response = scan($dir);
echo json_encode($response);
}
//Send file to mail
if (isset($_POST['type']) && $_POST['type']=="mail") {
//send mail Fn removed.
}
if (!class_exists('ZipArchive')) {
fm_set_msg('Operations with archives are not available', 'error');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
$files = $_POST['file'];
if (!empty($files)) {
chdir($path);
if (!class_exists('ZipArchive')) {
fm_set_msg('Operations with archives are not available', 'error');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
/**
* This function scans the files folder recursively, and builds a large array
* @param string $dir
* @return json
*/
function scan($dir){
$files = array();
$_dir = $dir;
$dir = FM_ROOT_PATH.'/'.$dir;
// Is there actually such a folder/file?
if(file_exists($dir)){
foreach(scandir($dir) as $f) {
if(!$f || $f[0] == '.') {
continue; // Ignore hidden files
}
if(is_dir($dir . '/' . $f)) {
// The path is a folder
$files[] = array(
"name" => $f,
"type" => "folder",
"path" => $_dir.'/'.$f,
"items" => scan($dir . '/' . $f), // Recursively get the contents of the folder
);
} else {
// It is a file
$files[] = array(
"name" => $f,
"type" => "file",
"path" => $_dir,
"size" => filesize($dir . '/' . $f) // Gets the size of this file
);
}
}
}
return $files;
}
/**
* Scan directory and return tree view
* @param string $directory
* @param boolean $first_call
*/
function php_file_tree_dir($directory, $first_call = true) {
// Recursive function called by php_file_tree() to list directories/files
/**
* Save message in session
* @param string $msg
* @param string $status
*/
function fm_set_msg($msg, $status = 'ok')
{
$_SESSION['message'] = $msg;
$_SESSION['status'] = $status;
}
/**
* Check if string is in UTF-8
* @param string $string
* @return int
*/
function fm_is_utf8($string)
{
return preg_match('//u', $string);
}
/**
* Convert file name to UTF-8 in Windows
* @param string $filename
* @return string
*/
function fm_convert_win($filename)
{
if (FM_IS_WIN && function_exists('iconv')) {
$filename = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $filename);
}
return $filename;
}
/**
* Get CSS classname for file
* @param string $path
* @return string
*/
function fm_get_file_icon_class($path)
{
// get extension
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
switch ($ext) {
case 'ico': case 'gif': case 'jpg': case 'jpeg': case 'jpc': case 'jp2':
case 'jpx': case 'xbm': case 'wbmp': case 'png': case 'bmp': case 'tif':
case 'tiff': case 'svg':
$img = 'fa fa-picture-o';
break;
case 'passwd': case 'ftpquota': case 'sql': case 'js': case 'json': case 'sh':
case 'config': case 'twig': case 'tpl': case 'md': case 'gitignore':
case 'c': case 'cpp': case 'cs': case 'py': case 'map': case 'lock': case 'dtd':
$img = 'fa fa-file-code-o';
break;
case 'txt': case 'ini': case 'conf': case 'log': case 'htaccess':
$img = 'fa fa-file-text-o';
break;
case 'css': case 'less': case 'sass': case 'scss':
$img = 'fa fa-css3';
break;
case 'zip': case 'rar': case 'gz': case 'tar': case '7z':
$img = 'fa fa-file-archive-o';
break;
case 'php': case 'php4': case 'php5': case 'phps': case 'phtml':
$img = 'fa fa-code';
break;
case 'htm': case 'html': case 'shtml': case 'xhtml':
$img = 'fa fa-html5';
break;
case 'xml': case 'xsl':
$img = 'fa fa-file-excel-o';
break;
case 'wav': case 'mp3': case 'mp2': case 'm4a': case 'aac': case 'ogg':
case 'oga': case 'wma': case 'mka': case 'flac': case 'ac3': case 'tds':
$img = 'fa fa-music';
break;
case 'm3u': case 'm3u8': case 'pls': case 'cue':
$img = 'fa fa-headphones';
break;
case 'avi': case 'mpg': case 'mpeg': case 'mp4': case 'm4v': case 'flv':
case 'f4v': case 'ogm': case 'ogv': case 'mov': case 'mkv': case '3gp':
case 'asf': case 'wmv':
$img = 'fa fa-file-video-o';
break;
case 'eml': case 'msg':
$img = 'fa fa-envelope-o';
break;
case 'xls': case 'xlsx':
$img = 'fa fa-file-excel-o';
break;
case 'csv':
$img = 'fa fa-file-text-o';
break;
case 'bak':
$img = 'fa fa-clipboard';
break;
case 'doc': case 'docx':
$img = 'fa fa-file-word-o';
break;
case 'ppt': case 'pptx':
$img = 'fa fa-file-powerpoint-o';
break;
case 'ttf': case 'ttc': case 'otf': case 'woff':case 'woff2': case 'eot': case 'fon':
$img = 'fa fa-font';
break;
case 'pdf':
$img = 'fa fa-file-pdf-o';
break;
case 'psd': case 'ai': case 'eps': case 'fla': case 'swf':
$img = 'fa fa-file-image-o';
break;
case 'exe': case 'msi':
$img = 'fa fa-file-o';
break;
case 'bat':
$img = 'fa fa-terminal';
break;
default:
$img = 'fa fa-info-circle';
}
/**
* Show image
* @param string $img
*/
function fm_show_image($img)
{
$modified_time = gmdate('D, d M Y 00:00:00') . ' GMT';
$expires_time = gmdate('D, d M Y 00:00:00', strtotime('+1 day')) . ' GMT';