summaryrefslogtreecommitdiffstats
path: root/files
diff options
context:
space:
mode:
authorRobin <robin@Amaya.(none)>2010-04-19 19:46:42 +0200
committerRobin <robin@Amaya.(none)>2010-04-19 19:46:42 +0200
commit38bdf4083a6e0d90afb35ded0d67cab8a518b2ea (patch)
tree10a29805a025802c6dc12c2c65c18a48cb2742f7 /files
parent6591740f5dd73969458de9a586790922fe6c27ea (diff)
downloadnextcloud-server-38bdf4083a6e0d90afb35ded0d67cab8a518b2ea.tar.gz
nextcloud-server-38bdf4083a6e0d90afb35ded0d67cab8a518b2ea.zip
same fixes, this time hopefully without merge conflict
Diffstat (limited to 'files')
-rw-r--r--files/delete.php10
-rw-r--r--files/get_files.php24
-rw-r--r--files/move.php35
-rw-r--r--files/new.php38
4 files changed, 92 insertions, 15 deletions
diff --git a/files/delete.php b/files/delete.php
index 1c660d97807..7d19a45a73a 100644
--- a/files/delete.php
+++ b/files/delete.php
@@ -25,10 +25,12 @@ require_once('../inc/lib_base.php');
$dir=$_GET['dir'];
$file=$_GET['file'];
if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($dir,'..')===false){
- $file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
- if(is_file($file)){
- unlink($file);
- }
+ $file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
+ if(is_file($file)){
+ unlink($file);
+ }elseif(is_dir($file)){
+ rmdir($file);
+ }
}
?> \ No newline at end of file
diff --git a/files/get_files.php b/files/get_files.php
index 29f06d289d5..287b8cd453e 100644
--- a/files/get_files.php
+++ b/files/get_files.php
@@ -42,21 +42,23 @@ function return_bytes($val) {
header('Content-type: application/xml');
$dir=isset($_GET['dir'])?$_GET['dir']:'';
-$files=OC_FILES::getdirectorycontent($CONFIG_DATADIRECTORY.'/'.$dir);
-$dirname=$files[0]['directory'];
+$files=OC_FILES::getdirectorycontent(realpath($CONFIG_DATADIRECTORY.'/'.$dir));
+$dirname=(isset($files[0]))?$files[0]['directory']:'';
$dirname=substr($dirname,strrpos($dirname,'/'));
$max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize')));
ob_clean();
echo "<?xml version='1.0' standalone='yes'?>\n";
echo "<dir name='$dirname' max_upload='$max_upload'>\n";
-foreach($files as $file){
- $attributes='';
- foreach($file as $name=>$data){
- $data=str_replace("'",'&#39;',$data);
- if (is_string($name)) $attributes.=" $name='$data'";
- }
- $attributes.=' date=\''.date($CONFIG_DATEFORMAT,$file['mtime']).'\'';
- echo "<file$attributes/>\n";
+if(is_array($files)){
+ foreach($files as $file){
+ $attributes='';
+ foreach($file as $name=>$data){
+ $data=str_replace("'",'&#39;',$data);
+ if (is_string($name)) $attributes.=" $name='$data'";
+ }
+ $attributes.=' date=\''.date($CONFIG_DATEFORMAT,$file['mtime']).'\'';
+ echo "<file$attributes/>\n";
+ }
}
-echo "</dir>";
+echo "\n</dir>";
?> \ No newline at end of file
diff --git a/files/move.php b/files/move.php
new file mode 100644
index 00000000000..7103662c4a2
--- /dev/null
+++ b/files/move.php
@@ -0,0 +1,35 @@
+<?php
+
+/**
+* ownCloud - ajax frontend
+*
+* @author Robin Appelman
+* @copyright 2010 Robin Appelman icewind1991@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+require_once('../inc/lib_base.php');
+
+$sourceDir=$_GET['sourcedir'];
+$targetDir=$_GET['targetdir'];
+$source=$_GET['source'];
+$target=$_GET['target'];
+if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($sourceDir,'..')===false and strpos($source,'..')===false and strpos($targetDir,'..')===false and strpos($target,'..')===false){
+ $target=$CONFIG_DATADIRECTORY.'/'.$targetDir.'/'.$target.'/'.$source;
+ $source=$CONFIG_DATADIRECTORY.'/'.$sourceDir.'/'.$source;
+ rename($source,$target);
+}
+
+?> \ No newline at end of file
diff --git a/files/new.php b/files/new.php
new file mode 100644
index 00000000000..c5d5608a567
--- /dev/null
+++ b/files/new.php
@@ -0,0 +1,38 @@
+<?php
+
+/**
+* ownCloud - ajax frontend
+*
+* @author Robin Appelman
+* @copyright 2010 Robin Appelman icewind1991@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+require_once('../inc/lib_base.php');
+
+$dir=$_GET['dir'];
+$name=$_GET['name'];
+$type=$_GET['type'];
+if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($dir,'..')===false and strpos($name,'..')===false){
+ $file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$name;
+ if($type=='dir'){
+ mkdir($file);
+ }elseif($type=='file'){
+ $fileHandle=fopen($file, 'w') or die("can't open file");
+ fclose($fileHandle);
+ }
+}
+
+?> \ No newline at end of file