From ff549f641995c422869b52d59019a3f3debc9f46 Mon Sep 17 00:00:00 2001
From: Prasath Mani
Date: Wed, 5 Jul 2017 19:20:26 +0530
Subject: [PATCH] Added - creating new file feature
---
tinyfilemanager.php | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/tinyfilemanager.php b/tinyfilemanager.php
index f9c5363..6b5c3aa 100644
--- a/tinyfilemanager.php
+++ b/tinyfilemanager.php
@@ -212,8 +212,9 @@ if (isset($_GET['del']) && !FM_READONLY) {
}
// Create folder
-if (isset($_GET['new']) && !FM_READONLY) {
+if (isset($_GET['new']) && isset($_GET['type']) && !FM_READONLY) {
$new = $_GET['new'];
+ $type = $_GET['type'];
$new = fm_clean_path($new);
$new = str_replace('/', '', $new);
if ($new != '' && $new != '..' && $new != '.') {
@@ -221,12 +222,21 @@ if (isset($_GET['new']) && !FM_READONLY) {
if (FM_PATH != '') {
$path .= '/' . FM_PATH;
}
- if (fm_mkdir($path . '/' . $new, false) === true) {
- fm_set_msg(sprintf(fm_t('Folder %s created'), $new));
- } elseif (fm_mkdir($path . '/' . $new, false) === $path . '/' . $new) {
- fm_set_msg(sprintf(fm_t('Folder %s already exists'), $new), 'alert');
+ if($_GET['type']=="file") {
+ if(!file_exists($path . '/' . $new)) {
+ @fopen($path . '/' . $new, 'w') or die('Cannot open file: '.$new);
+ fm_set_msg(sprintf(fm_t('File %s created'), $new));
+ } else {
+ fm_set_msg(sprintf(fm_t('File %s already exists'), $new), 'alert');
+ }
} else {
- fm_set_msg(sprintf(fm_t('Folder %s not created'), $new), 'error');
+ if (fm_mkdir($path . '/' . $new, false) === true) {
+ fm_set_msg(sprintf(fm_t('Folder %s created'), $new));
+ } elseif (fm_mkdir($path . '/' . $new, false) === $path . '/' . $new) {
+ fm_set_msg(sprintf(fm_t('Folder %s already exists'), $new), 'alert');
+ } else {
+ fm_set_msg(sprintf(fm_t('Folder %s not created'), $new), 'error');
+ }
}
} else {
fm_set_msg(fm_t('Wrong folder name'), 'error');
@@ -1178,7 +1188,7 @@ if (empty($folders) && empty($files)) {
-H3K | File Manager
+H3K | Tiny File Manager
@@ -1819,7 +1829,7 @@ function fm_show_nav_path($path)
@@ -1911,9 +1921,9 @@ body {margin:0 30px;margin-top: 45px;}.logo{color:#0df70d;float:left;font-size:2