diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 5428512..77be814 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -64,6 +64,10 @@ $GLOBALS['exclude_items'] = array(); // Google Docs Viewer $GLOBALS['online_viewer'] = true; +// private key and session name to store to the session +if ( !defined( 'FM_SESSION_ID')) { + define('FM_SESSION_ID', 'filemanager'); +} //Configuration $cfg = new FM_Config(); @@ -115,7 +119,7 @@ if (defined('FM_EMBED')) { } session_cache_limiter(''); - session_name('filemanager'); + session_name(FM_SESSION_ID ); @session_start(); } @@ -135,7 +139,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); } @@ -146,18 +150,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); } @@ -166,7 +170,7 @@ if ($use_auth) { } } else { // Form - unset($_SESSION['logged']); + unset($_SESSION[FM_SESSION_ID]['logged']); fm_show_header_login(); fm_show_message(); ?> @@ -230,8 +234,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 @@ -246,7 +250,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= @@ -327,7 +331,7 @@ if (isset($_POST['ajax']) && !FM_READONLY) { } $url = !empty($_REQUEST["uploadurl"]) && preg_match("|^http(s)?://.+$|", stripslashes($_REQUEST["uploadurl"])) ? stripslashes($_REQUEST["uploadurl"]) : null; - $use_curl = false;defined("CURLOPT_PROGRESSFUNCTION"); + $use_curl = false; $temp_file = tempnam(sys_get_temp_dir(), "upload-"); $fileinfo = new stdClass(); $fileinfo->name = trim(basename($url), ".\x00..\x20"); @@ -388,9 +392,7 @@ if (isset($_POST['ajax']) && !FM_READONLY) { // 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 != '') { @@ -412,10 +414,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 != '') { @@ -882,18 +882,25 @@ if (isset($_GET['upload']) && !FM_READONLY) {
-
-
- -    Upload from URL - -
+ +
+
+ +

+ :

-
-
@@ -2008,8 +2014,8 @@ function fm_enc($text) */ function fm_set_msg($msg, $status = 'ok') { - $_SESSION['message'] = $msg; - $_SESSION['status'] = $status; + $_SESSION[FM_SESSION_ID]['message'] = $msg; + $_SESSION[FM_SESSION_ID]['status'] = $status; } /** @@ -2622,7 +2628,7 @@ function fm_show_nav_path($path)