diff --git a/README.md b/README.md index ae4ba6f..045e9ec 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ To enable/disable authentication set `$use_auth` to true or false.
  • :cd: Open Source, light and extremely simple
  • :iphone: Mobile friendly view for touch devices
  • :information_source: Basic features likes Create, Delete, Modify, View, Download, Copy and Move files
  • -
  • :arrow_double_up: Ajax Upload, Ability to drag & drop, multiple files upload and file extensions filter
  • +
  • :arrow_double_up: Ajax Upload, Ability to drag & drop, upload from URL, multiple files upload and file extensions filter
  • :file_folder: Ability to create folders and files
  • :gift: Ability to compress, extract files (zip, tar)
  • :sunglasses: Support user permissions - based on session and each user root folder mapping
  • @@ -67,7 +67,7 @@ To enable/disable authentication set `$use_auth` to true or false.
  • :zap: Backup files
  • :mag_right: Search - Search and Sorting using datatable js
  • :file_folder: Exclude folders from listing
  • -
  • :globe_with_meridians: Multi-language support (English, French, Italian, Russian)
  • +
  • :globe_with_meridians: Multi-language support (English, French, Italian, Russian, German)
  • :bangbang: lots more...
  • diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 563589c..1769aa2 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -1,9 +1,9 @@ 'Français', 'it' => 'Italiano', 'ru' => 'Russian', - 'th' => 'ภาษาไทย' + 'th' => 'ภาษาไทย', + 'de' => 'German' ); //--- EDIT BELOW CAREFULLY OR DO NOT EDIT AT ALL @@ -96,12 +107,13 @@ if ($report_errors == true) { @ini_set('display_errors', 0); } -//Set Cookie +// Set Cookie setcookie('fm_cache', true, 2147483647, "/"); // if fm included if (defined('FM_EMBED')) { $use_auth = false; + $sticky_navbar = false; } else { @set_time_limit(600); @@ -116,7 +128,7 @@ if (defined('FM_EMBED')) { } session_cache_limiter(''); - session_name('filemanager'); + session_name(FM_SESSION_ID ); @session_start(); } @@ -136,7 +148,7 @@ defined('FM_SELF_URL') || define('FM_SELF_URL', ($is_https ? 'https' : 'http') . // logout if (isset($_GET['logout'])) { - unset($_SESSION['logged']); + unset($_SESSION[FM_SESSION_ID]['logged']); fm_redirect(FM_SELF_URL); } @@ -147,18 +159,18 @@ if (isset($_GET['img'])) { // Auth if ($use_auth) { - if (isset($_SESSION['logged'], $auth_users[$_SESSION['logged']])) { + if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_ID]['logged']])) { // Logged } elseif (isset($_POST['fm_usr'], $_POST['fm_pwd'])) { // Logging In sleep(1); if(function_exists('password_verify')) { if (isset($auth_users[$_POST['fm_usr']]) && isset($_POST['fm_pwd']) && password_verify($_POST['fm_pwd'], $auth_users[$_POST['fm_usr']])) { - $_SESSION['logged'] = $_POST['fm_usr']; + $_SESSION[FM_SESSION_ID]['logged'] = $_POST['fm_usr']; fm_set_msg('You are logged in'); fm_redirect(FM_SELF_URL . '?p='); } else { - unset($_SESSION['logged']); + unset($_SESSION[FM_SESSION_ID]['logged']); fm_set_msg('Login failed. Invalid username or password', 'error'); fm_redirect(FM_SELF_URL); } @@ -167,7 +179,7 @@ if ($use_auth) { } } else { // Form - unset($_SESSION['logged']); + unset($_SESSION[FM_SESSION_ID]['logged']); fm_show_header_login(); fm_show_message(); ?> @@ -217,7 +229,7 @@ if ($use_auth) { @@ -231,8 +243,8 @@ if ($use_auth) { } // update root path -if ($use_auth && isset($_SESSION['logged'])) { - $root_path = isset($directories_users[$_SESSION['logged']]) ? $directories_users[$_SESSION['logged']] : $root_path; +if ($use_auth && isset($_SESSION[FM_SESSION_ID]['logged'])) { + $root_path = isset($directories_users[$_SESSION[FM_SESSION_ID]['logged']]) ? $directories_users[$_SESSION[FM_SESSION_ID]['logged']] : $root_path; } // clean and check $root_path @@ -247,7 +259,7 @@ defined('FM_SHOW_HIDDEN') || define('FM_SHOW_HIDDEN', $show_hidden_files); defined('FM_ROOT_PATH') || define('FM_ROOT_PATH', $root_path); defined('FM_LANG') || define('FM_LANG', $lang); defined('FM_EXTENSION') || define('FM_EXTENSION', $allowed_extensions); -define('FM_READONLY', $use_auth && !empty($readonly_users) && isset($_SESSION['logged']) && in_array($_SESSION['logged'], $readonly_users)); +define('FM_READONLY', $use_auth && !empty($readonly_users) && isset($_SESSION[FM_SESSION_ID]['logged']) && in_array($_SESSION[FM_SESSION_ID]['logged'], $readonly_users)); define('FM_IS_WIN', DIRECTORY_SEPARATOR == '\\'); // always use ?p= @@ -320,14 +332,76 @@ if (isset($_POST['ajax']) && !FM_READONLY) { echo $res; } + //upload using url + if(isset($_POST['type']) && $_POST['type'] == "upload" && !empty($_REQUEST["uploadurl"])) { + $path = FM_ROOT_PATH; + if (FM_PATH != '') { + $path .= '/' . FM_PATH; + } + + $url = !empty($_REQUEST["uploadurl"]) && preg_match("|^http(s)?://.+$|", stripslashes($_REQUEST["uploadurl"])) ? stripslashes($_REQUEST["uploadurl"]) : null; + $use_curl = false; + $temp_file = tempnam(sys_get_temp_dir(), "upload-"); + $fileinfo = new stdClass(); + $fileinfo->name = trim(basename($url), ".\x00..\x20"); + + function event_callback ($message) { + global $callback; + echo json_encode($message); + } + + function get_file_path () { + global $path, $fileinfo, $temp_file; + return $path."/".basename($fileinfo->name); + } + + $err = false; + if (!$url) { + $success = false; + } else if ($use_curl) { + @$fp = fopen($temp_file, "w"); + @$ch = curl_init($url); + curl_setopt($ch, CURLOPT_NOPROGRESS, false ); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_FILE, $fp); + @$success = curl_exec($ch); + $curl_info = curl_getinfo($ch); + if (!$success) { + $err = array("message" => curl_error($ch)); + } + @curl_close($ch); + fclose($fp); + $fileinfo->size = $curl_info["size_download"]; + $fileinfo->type = $curl_info["content_type"]; + } else { + $ctx = stream_context_create(); + @$success = copy($url, $temp_file, $ctx); + if (!$success) { + $err = error_get_last(); + } + } + + if ($success) { + $success = rename($temp_file, get_file_path()); + } + + if ($success) { + event_callback(array("done" => $fileinfo)); + } else { + unlink($temp_file); + if (!$err) { + $err = array("message" => "Invalid url parameter"); + } + event_callback(array("fail" => $err)); + } + } + exit(); } // Delete file / folder if (isset($_GET['del']) && !FM_READONLY) { - $del = $_GET['del']; - $del = fm_clean_path($del); - $del = str_replace('/', '', $del); + $del = str_replace( '/', '', fm_clean_path( $_GET['del'] ) ); if ($del != '' && $del != '..' && $del != '.') { $path = FM_ROOT_PATH; if (FM_PATH != '') { @@ -349,10 +423,8 @@ if (isset($_GET['del']) && !FM_READONLY) { // Create folder if (isset($_GET['new']) && isset($_GET['type']) && !FM_READONLY) { - $new = strip_tags($_GET['new']); $type = $_GET['type']; - $new = fm_clean_path($new); - $new = str_replace('/', '', $new); + $new = str_replace( '/', '', fm_clean_path( strip_tags( $_GET['new'] ) ) ); if ($new != '' && $new != '..' && $new != '.') { $path = FM_ROOT_PATH; if (FM_PATH != '') { @@ -818,13 +890,56 @@ if (isset($_GET['upload']) && !FM_READONLY) { ?> +
    + +
    +
    + +
    +
    +

    + + : +

    + +
    +
    +
    +
    +
    +
    +
    + -
    -
    -
    - - -
    -
    -

    - : -

    - -
    -
    +
    - - + +
    - -
    + +
    > ON @@ -1006,8 +1100,8 @@ if (isset($_GET['settings']) && !FM_READONLY) {
    - -
    + +
    +
    +
    +
    + +if (isset($_GET['help'])) { + fm_show_header(); // HEADER + fm_show_nav_path(FM_PATH); // current path + global $cfg, $lang, $lang_list; + ?> + +
    +
    +
    + + +
    +
    +
    -
    - -
    -
    -
    @@ -1263,7 +1373,7 @@ if (isset($_GET['edit'])) { fm_set_msg('File not found', 'error'); fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH)); } - + header('X-XSS-Protection:0'); fm_show_header(); // HEADER fm_show_nav_path(FM_PATH); // current path @@ -1409,7 +1519,7 @@ if (isset($_GET['chmod']) && !FM_READONLY && !FM_IS_WIN) {

    -   +  

    @@ -1507,7 +1617,7 @@ $all_files_size = 0; - + @@ -1557,7 +1667,7 @@ $all_files_size = 0; - + @@ -1585,9 +1695,11 @@ $all_files_size = 0; - Full size: , - files: , - folders: + Full size: '.fm_get_filesize($all_files_size).'' ?>, + '.$num_files.'' ?>, + '.$num_folders.'' ?>, + '.fm_get_filesize(@memory_get_usage(true)).'' ?>, + '.fm_get_filesize(@disk_free_space($path)) .' free of '.fm_get_filesize(@disk_total_space($path)).''; ?> @@ -1596,26 +1708,30 @@ $all_files_size = 0; ?>
    - -
    -
    - -
    - - +
    + +
    + +
    + + + + +
    + -
    + + + @@ -3165,14 +3313,10 @@ global $lang; //editor.setTheme("ace/theme/twilight"); //Dark Theme function ace_commend (cmd) { editor.commands.exec(cmd, editor); } editor.commands.addCommands([{ - name: 'save', - bindKey: {win: 'Ctrl-S', mac: 'Command-S'}, - exec: function(editor) { - edit_save(this, 'ace'); - } + name: 'save', bindKey: {win: 'Ctrl-S', mac: 'Command-S'}, + exec: function(editor) { edit_save(this, 'ace'); } },{ - name: 'goToNo', - bindKey: {win: 'Ctrl-G', mac: 'Command-G'}, + name: 'goToNo', bindKey: {win: 'Ctrl-G', mac: 'Command-G'}, exec: function(editor) { let x = parseInt(prompt("Enter a Line Number [1 - "+editor.session.getLength()+"]", "1"), 10); editor.gotoLine(x); @@ -3199,15 +3343,13 @@ global $lang; }); $("select#js-ace-mode, select#js-ace-theme").on("change", function(e){ e.preventDefault(); - let selectedValue = $(this).val(); - let selectionType = $(this).attr("data-type"); + let selectedValue = $(this).val(), selectionType = $(this).attr("data-type"); if(selectedValue && selectionType == "mode") { editor.getSession().setMode(selectedValue); } else if(selectedValue && selectionType == "theme") { editor.setTheme(selectedValue); } }); - @@ -3276,7 +3418,7 @@ function lng($txt) { $tr['en']['NewItem'] = 'New Item'; $tr['en']['Folder'] = 'Folder'; $tr['en']['Delete'] = 'Delete'; $tr['en']['Rename'] = 'Rename'; $tr['en']['CopyTo'] = 'Copy to'; $tr['en']['DirectLink'] = 'Direct link'; - $tr['en']['UploadingFiles'] = 'Uploading files'; $tr['en']['ChangePermissions'] = 'Change Permissions'; + $tr['en']['UploadingFiles'] = 'Upload Files'; $tr['en']['ChangePermissions'] = 'Change Permissions'; $tr['en']['Copying'] = 'Copying'; $tr['en']['CreateNewItem'] = 'Create New Item'; $tr['en']['Name'] = 'Name'; $tr['en']['AdvancedEditor'] = 'Advanced Editor'; $tr['en']['RememberMe'] = 'Remember Me'; $tr['en']['Actions'] = 'Actions'; @@ -3290,6 +3432,8 @@ function lng($txt) { $tr['en']['SourceFolder'] = 'Source Folder'; $tr['en']['Files'] = 'Files'; $tr['en']['Move'] = 'Move'; $tr['en']['Change'] = 'Change'; $tr['en']['Settings'] = 'Settings'; $tr['en']['Language'] = 'Language'; + $tr['en']['MemoryUsed'] = 'Memory used'; $tr['en']['PartitionSize'] = 'Partition size'; + // French Language $tr['fr']['AppName'] = 'Tiny File Manager'; $tr['fr']['AppTitle'] = 'File Manager'; @@ -3318,6 +3462,7 @@ function lng($txt) { $tr['fr']['SourceFolder'] = 'Dossier Source'; $tr['fr']['Files'] = 'Fichiers'; $tr['fr']['Move'] = 'Déplacer'; $tr['fr']['Change'] = 'Modifier'; $tr['fr']['Settings'] = 'Réglages'; $tr['fr']['Language'] = 'Langue'; + $tr['fr']['MemoryUsed'] = 'Mémoire utilisée'; $tr['fr']['PartitionSize'] = 'Taille de la partition'; // Italian Language $tr['it']['AppName'] = 'Tiny File Manager'; $tr['it']['AppTitle'] = 'File Manager'; @@ -3346,6 +3491,7 @@ function lng($txt) { $tr['it']['SourceFolder'] = 'Cartella di Origine'; $tr['it']['Files'] = 'File'; $tr['it']['Move'] = 'Sposta'; $tr['it']['Change'] = 'Cambia'; $tr['it']['Settings'] = 'Impostazioni'; $tr['it']['Language'] = 'Lingua'; + $tr['it']['MemoryUsed'] = 'Memoria utilizzata'; $tr['it']['PartitionSize'] = 'Dimensione della partizione'; // Russian Language $tr['ru']['AppName'] = 'Файловый менеджер'; $tr['ru']['AppTitle'] = 'Файловый менеджер'; @@ -3374,6 +3520,35 @@ function lng($txt) { $tr['ru']['SourceFolder'] = 'Путь папки'; $tr['ru']['Files'] = 'Файлы'; $tr['ru']['Move'] = 'Переместить'; $tr['ru']['Change'] = 'Изменения'; $tr['ru']['Settings'] = 'Свойства'; $tr['ru']['Language'] = 'Язык'; + $tr['ru']['MemoryUsed'] = 'Используемая память'; $tr['ru']['PartitionSize'] = 'Размер раздела'; + + // German Language + $tr['de']['AppName'] = 'Tiny File Manager'; $tr['de']['AppTitle'] = 'Datei Manager'; + $tr['de']['Login'] = 'Einloggen'; $tr['de']['Username'] = 'Benutername'; + $tr['de']['Password'] = 'Passwort'; $tr['de']['Logout'] = 'Ausloggen'; + $tr['de']['Move'] = 'Verschieben'; $tr['de']['Copy'] = 'Kopieren'; + $tr['de']['Save'] = 'Speichern'; $tr['de']['SelectAll'] = 'Alles auswählen'; + $tr['de']['UnSelectAll'] = 'Alles abwählen'; $tr['de']['File'] = 'Datei'; + $tr['de']['Back'] = 'Zurück'; $tr['de']['Size'] = 'Größe'; + $tr['de']['Perms'] = 'Perms'; $tr['de']['Modified'] = 'Geändert'; + $tr['de']['Owner'] = 'Eigentümer'; $tr['de']['Search'] = 'Suchen'; + $tr['de']['NewItem'] = 'Neues Item'; $tr['de']['Folder'] = 'Ordner'; + $tr['de']['Delete'] = 'Löschen'; $tr['de']['Rename'] = 'Umbennen'; + $tr['de']['CopyTo'] = 'Kopieren nach'; $tr['de']['DirectLink'] = 'Direktlink'; + $tr['de']['UploadingFiles'] = 'Datei hochladen'; $tr['de']['ChangePermissions'] = 'Berechtigungen ändern'; + $tr['de']['Copying'] = 'Kopieren'; $tr['de']['CreateNewItem'] = 'Neue Datei erstellen'; + $tr['de']['Name'] = 'Name'; $tr['de']['AdvancedEditor'] = 'Fortgeschrittener Editor'; + $tr['de']['RememberMe'] = 'Eingeloggt bleiben'; $tr['de']['Actions'] = 'Aktionen'; + $tr['de']['Upload'] = 'Hochladen'; $tr['de']['Cancel'] = 'Abbrechner'; + $tr['de']['InvertSelection']= 'Auswahl umkehren'; $tr['de']['DestinationFolder'] = 'Zielordner'; + $tr['de']['ItemType'] = 'Dateityp'; $tr['de']['ItemName'] = 'Dateiname'; + $tr['de']['CreateNow'] = 'Jetzt erstellen'; $tr['de']['Download'] = 'Download'; + $tr['de']['Open'] = 'Öffnen'; $tr['de']['UnZip'] = 'UnZip'; + $tr['de']['UnZipToFolder'] = 'UnZip im Ordner'; $tr['de']['Edit'] = 'Bearbeiten'; + $tr['de']['NormalEditor'] = 'Normaler Editor'; $tr['de']['BackUp'] = 'Backup'; + $tr['de']['SourceFolder'] = 'Source ordner'; $tr['de']['Files'] = 'Datein'; + $tr['de']['Move'] = 'Verschieben'; $tr['de']['Change'] = 'Verändern'; + $tr['de']['Settings'] = 'Einstellungen'; $tr['de']['Language'] = 'Sprache';