diff --git a/tinyfilemanager.php b/tinyfilemanager.php index ee79410..9d036d1 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -423,7 +423,7 @@ unset($p, $use_auth, $iconv_input_encoding, $use_highlightjs, $highlightjs_style /*************************** ACTIONS ***************************/ // Handle all AJAX Request -if (isset($_POST['ajax'], $_POST['token']) && !FM_READONLY) { +if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_ID]['logged']]) && isset($_POST['ajax'], $_POST['token']) && !FM_READONLY) { if(!verifyToken($_POST['token'])) { header('HTTP/1.0 401 Unauthorized'); die("Invalid Token."); @@ -616,7 +616,7 @@ if (isset($_POST['ajax'], $_POST['token']) && !FM_READONLY) { } if ($success) { - $success = rename($temp_file, get_file_path()); + $success = rename($temp_file, strtok(get_file_path(), '?')); } if ($success) { @@ -654,9 +654,9 @@ if (isset($_GET['del'], $_POST['token']) && !FM_READONLY) { $FM_PATH=FM_PATH; fm_redirect(FM_SELF_URL . '?p=' . urlencode($FM_PATH)); } -// Create folder +// Create a new file/folder if (isset($_POST['newfilename'], $_POST['newfile'], $_POST['token']) && !FM_READONLY) { - $type = $_POST['newfile']; + $type = urldecode($_POST['newfile']); $new = str_replace( '/', '', fm_clean_path( strip_tags( $_POST['newfilename'] ) ) ); if (fm_isvalid_filename($new) && $new != '' && $new != '..' && $new != '.' && verifyToken($_POST['token'])) { $path = FM_ROOT_PATH; @@ -692,7 +692,7 @@ if (isset($_POST['newfilename'], $_POST['newfile'], $_POST['token']) && !FM_READ // Copy folder / file if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) { // from - $copy = $_GET['copy']; + $copy = urldecode($_GET['copy']); $copy = fm_clean_path($copy); // empty path if ($copy == '') { @@ -709,6 +709,7 @@ if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) { $dest .= '/' . basename($from); // move? $move = isset($_GET['move']); + $move = fm_clean_path(urldecode($move)); // copy/move/duplicate if ($from != $dest) { $msg_from = trim(FM_PATH . '/' . basename($from), '/'); @@ -832,11 +833,11 @@ if (isset($_POST['rename_from'], $_POST['rename_to'], $_POST['token']) && !FM_RE fm_set_msg("Invalid Token.", 'error'); } // old name - $old = $_POST['rename_from']; + $old = urldecode($_POST['rename_from']); $old = fm_clean_path($old); $old = str_replace('/', '', $old); // new name - $new = $_POST['rename_to']; + $new = urldecode($_POST['rename_to']); $new = fm_clean_path(strip_tags($new)); $new = str_replace('/', '', $new); // path @@ -863,7 +864,7 @@ if (isset($_GET['dl'], $_POST['token'])) { fm_set_msg("Invalid Token.", 'error'); } - $dl = $_GET['dl']; + $dl = urldecode($_GET['dl']); $dl = fm_clean_path($dl); $dl = str_replace('/', '', $dl); $path = FM_ROOT_PATH; @@ -949,8 +950,7 @@ if (!empty($_FILES) && !FM_READONLY) { while ($buff = fread($in, 4096)) { fwrite($out, $buff); } $response = array ( 'status' => 'success', - 'info' => "file upload successful", - 'fullPath' => $fullPath + 'info' => "file upload successful" ); } else { $response = array ( @@ -965,8 +965,7 @@ if (!empty($_FILES) && !FM_READONLY) { $response = array ( 'status' => 'success', - 'info' => "file upload successful", - 'fullPath' => $fullPath + 'info' => "file upload successful" ); } else { $response = array ( @@ -1027,7 +1026,7 @@ if (isset($_POST['group'], $_POST['delete'], $_POST['token']) && !FM_READONLY) { if (is_array($files) && count($files)) { foreach ($files as $f) { if ($f != '') { - $new_path = fm_clean_path($path . '/' . $f); + $new_path = $path . '/' . $f; if (!fm_rdelete($new_path)) { $errors++; } @@ -1105,7 +1104,7 @@ if (isset($_POST['unzip'], $_POST['token']) && !FM_READONLY) { fm_set_msg(lng("Invalid Token."), 'error'); } - $unzip = $_POST['unzip']; + $unzip = urldecode($_POST['unzip']); $unzip = fm_clean_path($unzip); $unzip = str_replace('/', '', $unzip); $isValid = false; @@ -1698,12 +1697,12 @@ if (isset($_GET['view'])) { $zip_name = pathinfo($file_path, PATHINFO_FILENAME); ?>
- +
 
- + @@ -1867,6 +1866,7 @@ if (isset($_GET['edit']) && !FM_READONLY) { ' . htmlspecialchars($content) . ''; + echo ''; } elseif ($is_text) { echo '
' . htmlspecialchars($content) . '
'; } else { @@ -3622,6 +3622,8 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal'; @@ -3998,7 +4008,7 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal'; // action confirm dailog modal function confirmDailog(e, id = 0, title = "Action", content = "", action = null) { e.preventDefault(); - const tplObj = {id, title, content, action}; + const tplObj = {id, title, content: decodeURIComponent(content.replace(/\+/g, ' ')), action}; let tpl = $("#js-tpl-confirm").html(); $('#wrapper').append(template(tpl,tplObj)); $("#confirmDailog-"+tplObj.id).modal('show');