summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/ajax/delete.php23
-rw-r--r--apps/files/ajax/move.php13
-rw-r--r--apps/files/ajax/newfile.php2
-rw-r--r--apps/files/ajax/newfolder.php2
-rw-r--r--apps/files/ajax/rename.php14
-rw-r--r--lib/files.php136
6 files changed, 34 insertions, 156 deletions
diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php
index 57c8c15c197..ae6158a05aa 100644
--- a/apps/files/ajax/delete.php
+++ b/apps/files/ajax/delete.php
@@ -12,17 +12,22 @@ $files = isset($_POST["file"]) ? stripslashes($_POST["file"]) : stripslashes($_P
$files = explode(';', $files);
$filesWithError = '';
-$success = true;
-//Now delete
-foreach($files as $file) {
- if( !OC_Files::delete( $dir, $file )) {
- $filesWithError .= $file . "\n";
- $success = false;
+if (OC_User::isLoggedIn()) {
+ $success = true;
+
+ //Now delete
+ foreach ($files as $file) {
+ if ($dir != '' || $file != 'Shared' && !\OC\Files\Filesystem::unlink($dir . '/' . $file)) {
+ $filesWithError .= $file . "\n";
+ $success = false;
+ }
}
+} else {
+ $success = false;
}
-if($success) {
- OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files )));
+if ($success) {
+ OCP\JSON::success(array("data" => array("dir" => $dir, "files" => $files)));
} else {
- OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError )));
+ OCP\JSON::error(array("data" => array("message" => "Could not delete:\n" . $filesWithError)));
}
diff --git a/apps/files/ajax/move.php b/apps/files/ajax/move.php
index 8b3149ef14e..f8727831228 100644
--- a/apps/files/ajax/move.php
+++ b/apps/files/ajax/move.php
@@ -11,9 +11,14 @@ $dir = stripslashes($_GET["dir"]);
$file = stripslashes($_GET["file"]);
$target = stripslashes($_GET["target"]);
-
-if(OC_Files::move($dir, $file, $target, $file)) {
- OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $file )));
-} else {
+if (OC_User::isLoggedIn() && ($dir != '' || $file != 'Shared')) {
+ $targetFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file);
+ $sourceFile = \OC\Files\Filesystem::normalizePath($target . '/' . $file);
+ if(\OC\Files\Filesystem::rename($sourceFile, $targetFile)) {
+ OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $file )));
+ } else {
+ OCP\JSON::error(array("data" => array( "message" => "Could not move $file" )));
+ }
+}else{
OCP\JSON::error(array("data" => array( "message" => "Could not move $file" )));
}
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index 4d73970b68d..f94d984d5ba 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -82,7 +82,7 @@ if($source) {
OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id)));
exit();
}
- }elseif(OC_Files::newFile($dir, $filename, 'file')) {
+ }elseif(\OC\Files\Filesystem::touch($dir . '/' . $filename)) {
$meta = OC_FileCache::get($dir.'/'.$filename);
$id = OC_FileCache::getId($dir.'/'.$filename);
OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id)));
diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php
index 0f1f2f14eb0..c36c2084551 100644
--- a/apps/files/ajax/newfolder.php
+++ b/apps/files/ajax/newfolder.php
@@ -19,7 +19,7 @@ if(strpos($foldername, '/')!==false) {
exit();
}
-if(OC_Files::newFile($dir, stripslashes($foldername), 'dir')) {
+if(\OC\Files\Filesystem::mkdir($dir . '/' . stripslashes($foldername))) {
if ( $dir != '/') {
$path = $dir.'/'.$foldername;
} else {
diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php
index 45448279fa1..a2b9b8de257 100644
--- a/apps/files/ajax/rename.php
+++ b/apps/files/ajax/rename.php
@@ -11,10 +11,14 @@ $dir = stripslashes($_GET["dir"]);
$file = stripslashes($_GET["file"]);
$newname = stripslashes($_GET["newname"]);
-// Delete
-if( OC_Files::move( $dir, $file, $dir, $newname )) {
- OCP\JSON::success(array("data" => array( "dir" => $dir, "file" => $file, "newname" => $newname )));
-}
-else{
+if (OC_User::isLoggedIn() && ($dir != '' || $file != 'Shared')) {
+ $targetFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file);
+ $sourceFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $newname);
+ if(\OC\Files\Filesystem::rename($sourceFile, $targetFile)) {
+ OCP\JSON::success(array("data" => array( "dir" => $dir, "file" => $file, "newname" => $newname )));
+ } else {
+ OCP\JSON::error(array("data" => array( "message" => "Unable to rename file" )));
+ }
+}else{
OCP\JSON::error(array("data" => array( "message" => "Unable to rename file" )));
}
diff --git a/lib/files.php b/lib/files.php
index ff9befa89e5..7ab7c89201a 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -253,77 +253,6 @@ class OC_Files {
}
/**
- * move a file or folder
- *
- * @param dir $sourceDir
- * @param file $source
- * @param dir $targetDir
- * @param file $target
- */
- public static function move($sourceDir, $source, $targetDir, $target) {
- if (OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')) {
- $targetFile = self::normalizePath($targetDir . '/' . $target);
- $sourceFile = self::normalizePath($sourceDir . '/' . $source);
- return \OC\Files\Filesystem::rename($sourceFile, $targetFile);
- } else {
- return false;
- }
- }
-
- /**
- * copy a file or folder
- *
- * @param dir $sourceDir
- * @param file $source
- * @param dir $targetDir
- * @param file $target
- */
- public static function copy($sourceDir, $source, $targetDir, $target) {
- if (OC_User::isLoggedIn()) {
- $targetFile = $targetDir . '/' . $target;
- $sourceFile = $sourceDir . '/' . $source;
- return \OC\Files\Filesystem::copy($sourceFile, $targetFile);
- }
- }
-
- /**
- * create a new file or folder
- *
- * @param dir $dir
- * @param file $name
- * @param type $type
- */
- public static function newFile($dir, $name, $type) {
- if (OC_User::isLoggedIn()) {
- $file = $dir . '/' . $name;
- if ($type == 'dir') {
- return \OC\Files\Filesystem::mkdir($file);
- } elseif ($type == 'file') {
- $fileHandle = \OC\Files\Filesystem::fopen($file, 'w');
- if ($fileHandle) {
- fclose($fileHandle);
- return true;
- } else {
- return false;
- }
- }
- }
- }
-
- /**
- * deletes a file or folder
- *
- * @param dir $dir
- * @param file $name
- */
- public static function delete($dir, $file) {
- if (OC_User::isLoggedIn() && ($dir != '' || $file != 'Shared')) {
- $file = $dir . '/' . $file;
- return \OC\Files\Filesystem::unlink($file);
- }
- }
-
- /**
* checks if the selected files are within the size constraint. If not, outputs an error page.
*
* @param dir $dir
@@ -373,55 +302,6 @@ class OC_Files {
}
/**
- * try to detect the mime type of a file
- *
- * @param string path
- * @return string guessed mime type
- */
- static function getMimeType($path) {
- return \OC\Files\Filesystem::getMimeType($path);
- }
-
- /**
- * get a file tree
- *
- * @param string path
- * @return array
- */
- static function getTree($path) {
- return \OC\Files\Filesystem::getTree($path);
- }
-
- /**
- * pull a file from a remote server
- *
- * @param string source
- * @param string token
- * @param string dir
- * @param string file
- * @return string guessed mime type
- */
- static function pull($source, $token, $dir, $file) {
- $tmpfile = tempnam(get_temp_dir(), 'remoteCloudFile');
- $fp = fopen($tmpfile, 'w+');
- $url = $source .= "/files/pull.php?token=$token";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_FILE, $fp);
- curl_exec($ch);
- fclose($fp);
- $info = curl_getinfo($ch);
- $httpCode = $info['http_code'];
- curl_close($ch);
- if ($httpCode == 200 or $httpCode == 0) {
- \OC\Files\Filesystem::fromTmpFile($tmpfile, $dir . '/' . $file);
- return true;
- } else {
- return false;
- }
- }
-
- /**
* set the maximum upload size limit for apache hosts using .htaccess
*
* @param int size filesisze in bytes
@@ -478,22 +358,6 @@ class OC_Files {
return false;
}
-
- /**
- * normalize a path, removing any double, add leading /, etc
- *
- * @param string $path
- * @return string
- */
- static public function normalizePath($path) {
- $path = '/' . $path;
- $old = '';
- while ($old != $path) { //replace any multiplicity of slashes with a single one
- $old = $path;
- $path = str_replace('//', '/', $path);
- }
- return $path;
- }
}
function fileCmp($a, $b) {