// Enable highlight.js (https://highlightjs.org/) on view's page
$use_highlightjs = true;
// highlight.js style
$highlightjs_style = 'vs';
// Default timezone for date() and time() - http://php.net/manual/en/timezones.php
$default_timezone = 'Europe/Minsk'; // UTC+3
// 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 = 'CP1251';
// date() format for file modification date
$datetime_format = 'd.m.y H:i';
//--- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL
// if fm included
if (defined('FM_EMBED')) {
$use_auth = false;
} else {
@set_time_limit(600);
date_default_timezone_set($default_timezone);
ini_set('default_charset', 'UTF-8');
if (version_compare(PHP_VERSION, '5.6.0', '<') && function_exists('mb_internal_encoding')) {
mb_internal_encoding('UTF-8');
}
if (function_exists('mb_regex_encoding')) {
mb_regex_encoding('UTF-8');
}
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));
}
/**
* 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':
$img = 'icon-file_image';
break;
case 'txt': case 'css': case 'ini': case 'conf': case 'log': case 'htaccess':
case 'passwd': case 'ftpquota': case 'sql': case 'js': case 'json': case 'sh':
case 'config': case 'twig': case 'tpl': case 'md': case 'gitignore':
case 'less': case 'sass': case 'scss': case 'c': case 'cpp': case 'cs': case 'py':
case 'map': case 'lock': case 'dtd':
$img = 'icon-file_text';
break;
case 'zip': case 'rar': case 'gz': case 'tar': case '7z':
$img = 'icon-file_zip';
break;
case 'php': case 'php4': case 'php5': case 'phps': case 'phtml':
$img = 'icon-file_php';
break;
case 'htm': case 'html': case 'shtml': case 'xhtml':
$img = 'icon-file_html';
break;
case 'xml': case 'xsl': case 'svg':
$img = 'icon-file_code';
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 = 'icon-file_music';
break;
case 'm3u': case 'm3u8': case 'pls': case 'cue':
$img = 'icon-file_playlist';
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 = 'icon-file_film';
break;
case 'eml': case 'msg':
$img = 'icon-file_outlook';
break;
case 'xls': case 'xlsx':
$img = 'icon-file_excel';
break;
case 'csv':
$img = 'icon-file_csv';
break;
case 'doc': case 'docx':
$img = 'icon-file_word';
break;
case 'ppt': case 'pptx':
$img = 'icon-file_powerpoint';
break;
case 'ttf': case 'ttc': case 'otf': case 'woff':case 'woff2': case 'eot': case 'fon':
$img = 'icon-file_font';
break;
case 'pdf':
$img = 'icon-file_pdf';
break;
case 'psd':
$img = 'icon-file_photoshop';
break;
case 'ai': case 'eps':
$img = 'icon-file_illustrator';
break;
case 'fla':
$img = 'icon-file_flash';
break;
case 'swf':
$img = 'icon-file_swf';
break;
case 'exe': case 'msi':
$img = 'icon-file_application';
break;
case 'bat':
$img = 'icon-file_terminal';
break;
default:
$img = 'icon-document';
}
/**
* Show page footer
*/
function fm_show_footer()
{
<p class="center"><small><a href="https://github.com/alexantr/filemanager" target="_blank">PHP File Manager</a></small></p>
</div>
<script>
function newfolder(p){var n=prompt('New folder name','folder');if(n!==null&&n!==''){window.location.search='p='+encodeURIComponent(p)+'&new='+encodeURIComponent(n);}}
function rename(p,f){var n=prompt('New name',f);if(n!==null&&n!==''&&n!=f){window.location.search='p='+encodeURIComponent(p)+'&ren='+encodeURIComponent(f)+'&to='+encodeURIComponent(n);}}
function change_checkboxes(l,v){for(var i=l.length-1;i>=0;i--){l[i].checked=(typeof v==='boolean')?v:!l[i].checked;}}
function get_checkboxes(){var i=document.getElementsByName('file[]'),a=[];for(var j=i.length-1;j>=0;j--){if(i[j].type='checkbox'){a.push(i[j]);}}return a;}
function select_all(){var l=get_checkboxes();change_checkboxes(l,true);}
function unselect_all(){var l=get_checkboxes();change_checkboxes(l,false);}
function invert_all(){var l=get_checkboxes();change_checkboxes(l);}
function checkbox_toggle(){var l=get_checkboxes();l.push(this);change_checkboxes(l);}
</script>
if (isset($_GET['view']) && FM_USE_HIGHLIGHTJS):
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
endif;
}
/**
* 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';