some cleanup/refactoring

This commit is contained in:
Robin 2010-04-25 14:21:04 +02:00
parent 76eeaaea01
commit c2bdd6134b
8 changed files with 298 additions and 361 deletions

View File

@ -22,13 +22,28 @@
*/ */
require_once('../inc/lib_base.php'); require_once('../inc/lib_base.php');
$dir=$_GET['dir']; $arguments=$_POST;
$file=$_GET['file'];
$newname=$_GET['newname']; foreach($arguments as &$argument){
if($file!=$newname and $newname!='' and isset($_SESSION['username']) and $_SESSION['username'] and strpos($dir,'..')===false){ $argument=stripslashes($argument);
$source=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file; }
$target=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$newname; ob_clean();
rename($source,$target); switch($arguments['action']){
case 'delete':
OC_FILES::delete($arguments['dir'],$arguments['file']);
break;
case 'rename':
OC_FILES::move($arguments['dir'],$arguments['file'],$arguments['dir'],$arguments['newname']);
break;
case 'new':
OC_FILES::newfile($arguments['dir'],$arguments['name'],$arguments['type']);
break;
case 'move':
OC_FILES::move($arguments['sourcedir'],$arguments['source'],$arguments['targetdir'],$arguments['target']);
break;
case 'get':
OC_FILES::get($arguments['dir'],$arguments['file']);
break;
} }
?> ?>

View File

@ -1,108 +0,0 @@
<?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/>.
*
*/
//note this file is for getting files themselves, get_files.php is for getting a list of files.
require_once('../inc/lib_base.php');
if(!function_exists('sys_get_temp_dir')) {
function sys_get_temp_dir() {
if( $temp=getenv('TMP') ) return $temp;
if( $temp=getenv('TEMP') ) return $temp;
if( $temp=getenv('TMPDIR') ) return $temp;
$temp=tempnam(__FILE__,'');
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
return null;
}
}
function addDir($dir,$zip,$internalDir=''){
$dirname=basename($dir);
$zip->addEmptyDir($internalDir.$dirname);
$internalDir.=$dirname.='/';
$files=OC_FILES::getdirectorycontent($dir);
foreach($files as $file){
$filename=$file['name'];
$file=$dir.'/'.$filename;
if(is_file($file)){
$zip->addFile($file,$internalDir.$filename);
}elseif(is_dir($file)){
addDir($file,$zip,$internalDir);
}
}
}
$files=$_GET['files'];
$dir=(isset($_GET['dir']))?$_GET['dir']:'';
if(strstr($files,'..') or strstr($dir,'..')){
die();
}
if(strpos($files,',')){
$files=explode(',',$files);
}
if(is_array($files)){
$zip = new ZipArchive();
$filename = sys_get_temp_dir()."/ownCloud.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}
foreach($files as $file){
$file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
if(is_file($file)){
$zip->addFile($file,basename($file));
}elseif(is_dir($file)){
addDir($file,$zip);
}
}
$zip->close();
}elseif(is_dir($CONFIG_DATADIRECTORY.'/'.$dir.'/'.$files)){
$zip = new ZipArchive();
$filename = sys_get_temp_dir()."/ownCloud.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}
$file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$files;
addDir($file,$zip);
$zip->close();
}else{
$zip=false;
$filename=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$files;
}
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($filename));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
ob_end_clean();
readfile($filename);
if($zip){
unlink($filename);
}
?>

View File

@ -47,12 +47,14 @@ $dirname=(isset($files[0]))?$files[0]['directory']:'';
$dirname=substr($dirname,strrpos($dirname,'/')); $dirname=substr($dirname,strrpos($dirname,'/'));
$max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize'))); $max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize')));
ob_clean(); ob_clean();
echo "<?xml version='1.0' standalone='yes'?>\n"; echo "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n";
echo "<dir name='$dirname' max_upload='$max_upload'>\n"; echo "<dir name='$dirname' max_upload='$max_upload'>\n";
if(is_array($files)){ if(is_array($files)){
foreach($files as $file){ foreach($files as $file){
$attributes=''; $attributes='';
foreach($file as $name=>$data){ foreach($file as $name=>$data){
$data=utf8_encode($data);
$data=utf8tohtml($data);
$data=str_replace("'",'&#39;',$data); $data=str_replace("'",'&#39;',$data);
if (is_string($name)) $attributes.=" $name='$data'"; if (is_string($name)) $attributes.=" $name='$data'";
} }
@ -60,5 +62,48 @@ if(is_array($files)){
echo "<file$attributes/>\n"; echo "<file$attributes/>\n";
} }
} }
echo "\n</dir>"; echo "</dir>";
// converts a UTF8-string into HTML entities
// - $utf8: the UTF8-string to convert
// - $encodeTags: booloean. TRUE will convert "<" to "&lt;"
// - return: returns the converted HTML-string
function utf8tohtml($utf8, $encodeTags=true) {
$result = '';
for ($i = 0; $i < strlen($utf8); $i++) {
$char = $utf8[$i];
$ascii = ord($char);
if ($ascii < 128) {
// one-byte character
$result .= ($encodeTags) ? htmlentities($char) : $char;
} else if ($ascii < 192) {
// non-utf8 character or not a start byte
} else if ($ascii < 224) {
// two-byte character
$result .= htmlentities(substr($utf8, $i, 2), ENT_QUOTES, 'UTF-8');
$i++;
} else if ($ascii < 240) {
// three-byte character
$ascii1 = ord($utf8[$i+1]);
$ascii2 = ord($utf8[$i+2]);
$unicode = (15 & $ascii) * 4096 +
(63 & $ascii1) * 64 +
(63 & $ascii2);
$result .= "&#$unicode;";
$i += 2;
} else if ($ascii < 248) {
// four-byte character
$ascii1 = ord($utf8[$i+1]);
$ascii2 = ord($utf8[$i+2]);
$ascii3 = ord($utf8[$i+3]);
$unicode = (15 & $ascii) * 262144 +
(63 & $ascii1) * 4096 +
(63 & $ascii2) * 64 +
(63 & $ascii3);
$result .= "&#$unicode;";
$i += 3;
}
}
return $result;
}
?> ?>

View File

@ -1,35 +0,0 @@
<?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);
}
?>

View File

@ -1,38 +0,0 @@
<?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);
}
}
?>

View File

@ -29,132 +29,197 @@
*/ */
class OC_FILES { class OC_FILES {
/** /**
* show a web GUI filebrowser * show a web GUI filebrowser
* *
* @param basedir $basedir * @param basedir $basedir
* @param dir $dir * @param dir $dir
*/ */
public static function showbrowser($basedir,$dir){/* public static function showbrowser($basedir,$dir){
global $CONFIG_DATEFORMAT; echo '<div id="content"></div>';
global $WEBROOT; }
$directory=$basedir.'/'.$dir; /**
* get the content of a directory
// exit if try to access files outside our directory * @param dir $directory
if(strstr($dir,'..')<>false) exit(); */
$directory=realpath($directory); public static function getdirectorycontent($directory){
$filesfound=true;
$dirs=explode('/',$dir); $content=array();
$dirs=array();
// breadcrumb $file=array();
if(count($dirs)>1) { $files=array();
echo('<div class="center"><table cellpadding="2" cellspacing="0" border="0"><tr>'); if (is_dir($directory)) {
echo('<td class="nametext"><a href="'.$WEBROOT.'/">home</a></td>'); if ($dh = opendir($directory)) {
$currentdir=''; while (($filename = readdir($dh)) !== false) {
foreach($dirs as $d) { if($filename<>'.' and $filename<>'..'){
$currentdir.='/'.$d.''; $file=array();
if($d<>'') echo('<td class="nametext"><a href="'.$WEBROOT.'/?dir='.$currentdir.'"><img src="'.$WEBROOT.'/img/arrow.png" />&nbsp;'.$d.'</a></td>'); $filesfound=true;
} $file['name']=$filename;
echo('</tr></table></div>'); $file['directory']=$directory;
} $stat=stat($directory.'/'.$filename);
$file=array_merge($file,$stat);
// files and directories $file['type']=filetype($directory .'/'. $filename);
echo('<div class="center"><table cellpadding="6" cellspacing="0" border="0" class="browser">'); if($file['type']=='dir'){
$filesfound=false; $dirs[$file['name']]=$file;
$content=self::getdirectorycontent($directory); }else{
if($content){ $files[$file['name']]=$file;
foreach($content as $file){ }
echo('<tr class="browserline">'); }
OC_UTIL::showicon($file['type']); }
if($file['type']=='dir') echo('<td class="nametext"><a href="'.$WEBROOT.'/?dir='.$dir.'/'.$file['name'].'">'.$file['name'].'</a></td>'); closedir($dh);
if($file['type']<>'dir') echo('<td class="nametext"><a href="'.$WEBROOT.'/?dir='.$dir.'&file='.$file['name'].'">'.$file['name'].'</a></td>'); }
if($file['type']<>'dir') echo('<td class="sizetext">'.$file['size'].' byte</td>'); else echo('<td></td>'); }
echo('<td class="sizetext">'.date($CONFIG_DATEFORMAT,$file['mtime']).'</td>'); ksort($dirs);
echo('</tr>'); ksort($files);
} $content=array_merge($dirs,$files);
} if($filesfound){
echo('</table>'); return $content;
if(!$content) echo('<p>no files here</p>'); }else{
echo('</div>');*/ return false;
echo '<div id="content"></div>'; }
} }
/**
* get the content of a directory
* @param dir $directory
*/
public static function getdirectorycontent($directory){
$filesfound=true;
$content=array();
$dirs=array();
$file=array();
$files=array();
if (is_dir($directory)) {
if ($dh = opendir($directory)) {
while (($filename = readdir($dh)) !== false) {
if($filename<>'.' and $filename<>'..'){
$file=array();
$filesfound=true;
$file['name']=$filename;
$file['directory']=$directory;
$stat=stat($directory.'/'.$filename);
$file=array_merge($file,$stat);
$file['type']=filetype($directory .'/'. $filename);
if($file['type']=='dir'){
$dirs[$file['name']]=$file;
}else{
$files[$file['name']]=$file;
}
}
}
closedir($dh);
}
}
ksort($dirs);
ksort($files);
$content=array_merge($dirs,$files);
if($filesfound){
return $content;
}else{
return false;
}
}
/** /**
* return the cntent of a file * return the content of a file or return a zip file containning multiply files
* *
* @param dir $dir * @param dir $dir
* @param file $file * @param file $file
*/ */
public static function get($dir,$file){ public static function get($dir,$files){
if(isset($_SESSION['username']) and $_SESSION['username']<>'') { global $CONFIG_DATADIRECTORY;
global $CONFIG_DATADIRECTORY; if(strstr($files,'..') or strstr($dir,'..')){
$filename=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file; die();
}
// exit if try to access files outside our directory if(is_array($files)){
if(strstr($filename,'..')<>false) exit(); $zip = new ZipArchive();
$filename = sys_get_temp_dir()."/ownCloud.zip";
OC_LOG::event($_SESSION['username'],3,$dir.'/'.$file); if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
header('Content-Description: File Transfer'); }
header('Content-Type: application/octet-stream'); foreach($files as $file){
header('Content-Disposition: attachment; filename='.basename($file)); $file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
header('Content-Transfer-Encoding: binary'); if(is_file($file)){
header('Expires: 0'); $zip->addFile($file,basename($file));
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); }elseif(is_dir($file)){
header('Pragma: public'); zipAddDir($file,$zip);
header('Content-Length: ' . filesize($filename)); }
readfile($filename); }
} $zip->close();
exit; }elseif(is_dir($CONFIG_DATADIRECTORY.'/'.$dir.'/'.$files)){
} $zip = new ZipArchive();
$filename = sys_get_temp_dir()."/ownCloud.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}
$file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$files;
zipAddDir($file,$zip);
$zip->close();
}else{
$zip=false;
$filename=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$files;
}
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($filename));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
ob_end_clean();
readfile($filename);
if($zip){
unlink($filename);
}
}
/**
* 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){
global $CONFIG_DATADIRECTORY;
if(OC_USER::isLoggedIn() and strpos($sourceDir,'..')===false and strpos($source,'..')===false and strpos($targetDir,'..')===false and strpos($target,'..')===false){
$targetFile=$CONFIG_DATADIRECTORY.'/'.$targetDir.'/'.$target;
$sourceFile=$CONFIG_DATADIRECTORY.'/'.$sourceDir.'/'.$source;
rename($sourceFile,$targetFile);
}
}
/**
* create a new file or folder
*
* @param dir $dir
* @param file $name
* @param type $type
*/
public static function newfile($dir,$name,$type){
global $CONFIG_DATADIRECTORY;
if(OC_USER::isLoggedIn() 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);
}
}
}
/**
* deletes a file or folder
*
* @param dir $dir
* @param file $name
*/
public static function delete($dir,$file){
global $CONFIG_DATADIRECTORY;
if(OC_USER::isLoggedIn() and strpos($dir,'..')===false){
$file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file;
if(is_file($file)){
unlink($file);
}elseif(is_dir($file)){
rmdir($file);
}
}
}
} }
function zipAddDir($dir,$zip,$internalDir=''){
$dirname=basename($dir);
$zip->addEmptyDir($internalDir.$dirname);
$internalDir.=$dirname.='/';
$files=OC_FILES::getdirectorycontent($dir);
foreach($files as $file){
$filename=$file['name'];
$file=$dir.'/'.$filename;
if(is_file($file)){
$zip->addFile($file,$internalDir.$filename);
}elseif(is_dir($file)){
zipAddDir($file,$zip,$internalDir);
}
}
}
if(!function_exists('sys_get_temp_dir')) {
function sys_get_temp_dir() {
if( $temp=getenv('TMP') ) return $temp;
if( $temp=getenv('TEMP') ) return $temp;
if( $temp=getenv('TMPDIR') ) return $temp;
$temp=tempnam(__FILE__,'');
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
return null;
}
}
?> ?>

View File

@ -1,5 +1,3 @@
<?php
/** /**
* ownCloud - ajax frontend * ownCloud - ajax frontend
* *
@ -20,17 +18,17 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
require_once('../inc/lib_base.php');
$dir=$_GET['dir']; OC_API=new Object();
$file=$_GET['file'];
if(isset($_SESSION['username']) and $_SESSION['username'] and strpos($dir,'..')===false){ OC_API.run=function(action,params,callback,callbackparams){
$file=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file; var xmlloader=new OCXMLLoader();
if(is_file($file)){ xmlloader.setCallBack(callback);
unlink($file); xmlloader.method="POST";
}elseif(is_dir($file)){ var paramString='action='+action;
rmdir($file); for(name in params){
paramString+='&'+name+'='+encodeURIComponent(params[name]);
} }
} xmlloader.arg=callbackparams;
xmlloader.load('files/api.php',paramString);
?> }

View File

@ -87,6 +87,10 @@ OC_FILES.getdirectorycontent=function(dir,callback,refresh){
OC_FILES.dir=''; OC_FILES.dir='';
OC_FILES.get=function(dir,file){
window.location='files/get_file.php?dir='+encodeURIComponent(dir)+'&files='+encodeURIComponent(file);
}
OC_FILES.upload=function(dir,iframeId){ OC_FILES.upload=function(dir,iframeId){
var file=new Object; var file=new Object;
var fileSelector=document.getElementById('fileSelector'); var fileSelector=document.getElementById('fileSelector');
@ -133,7 +137,7 @@ OC_FILES.upload_callback=function(iframeId){
if(OC_FILES.cache.incomplete[file.dir][file.name]){ if(OC_FILES.cache.incomplete[file.dir][file.name]){
OC_FILES.browser.files.remove(file.name); OC_FILES.browser.files.remove(file.name);
OC_FILES.cache.files[file.name]=OC_FILES.cache.incomplete[file.dir][file.name] OC_FILES.cache.files[file.name]=OC_FILES.cache.incomplete[file.dir][file.name]
delete OC_FILES.cache.incomplete[file.dir][file.name]; OC_FILES.cache.incomplete[file.dir][file.name]=null;
OC_FILES.cache.files[file.name]['type']=file.type; OC_FILES.cache.files[file.name]['type']=file.type;
this.uploadForm.parentNode.removeChild(this.uploadForm); this.uploadForm.parentNode.removeChild(this.uploadForm);
this.parentNode.removeChild(this); this.parentNode.removeChild(this);
@ -154,14 +158,12 @@ OC_FILES.rename=function(dir,file,event){
OC_FILES.browser.show(OC_FILES.dir); OC_FILES.browser.show(OC_FILES.dir);
return false; return false;
} }
xmlloader=new OCXMLLoader(); arg=new Object;
xmlloader.setCallBack(OC_FILES.rename_callback); arg.oldname=file;
xmlloader.arg=new Object; arg.newname=newname;
xmlloader.arg.oldname=file; arg.dir=dir;
xmlloader.arg.newname=newname; arg.type=OC_FILES.cache.files[file]['type'];
xmlloader.arg.dir=dir; OC_API.run('rename',{dir:dir,file:file,newname:newname},OC_FILES.rename_callback,arg)
xmlloader.arg.type=OC_FILES.cache.files[file]['type'];
xmlloader.load('files/rename.php?dir='+dir+'&file='+file+'&newname='+newname);
if(!OC_FILES.cache.incomplete[dir]){ if(!OC_FILES.cache.incomplete[dir]){
OC_FILES.cache.incomplete[dir]=Array(); OC_FILES.cache.incomplete[dir]=Array();
} }
@ -184,12 +186,9 @@ OC_FILES.rename_callback=function(req,file){
} }
OC_FILES.remove=function(dir,file){ OC_FILES.remove=function(dir,file){
remove=confirm('remove file \''+file+'\'?'); remove=confirm('delete file \''+file+'\'?');
if(remove){ if(remove){
xmlloader=new OCXMLLoader(); OC_API.run('delete',{dir:dir,file:file},OC_FILES.remove_callback,file)
xmlloader.setCallBack(OC_FILES.remove_callback);
xmlloader.arg=file;
xmlloader.load('files/delete.php?dir='+dir+'&file='+file);
OC_FILES.browser.files.remove(file); OC_FILES.browser.files.remove(file);
delete OC_FILES.cache.files[file]; delete OC_FILES.cache.files[file];
} }
@ -212,13 +211,11 @@ OC_FILES.getSelected=function(){
} }
OC_FILES.newFile=function(type,name,dir){ OC_FILES.newFile=function(type,name,dir){
xmlloader=new OCXMLLoader(); arg=new Object;
xmlloader.arg=new Object; arg.name=name;
xmlloader.arg.name=name; arg.dir=dir;
xmlloader.arg.dir=dir; arg.type=type;
xmlloader.arg.type=type; OC_API.run('new',{dir:dir,name:name,type:type},OC_FILES.new_callback,arg)
xmlloader.setCallBack(OC_FILES.new_callback);
xmlloader.load('files/new.php?type='+type+'&dir='+dir+'&name='+name);
if(!OC_FILES.cache.incomplete[dir]){ if(!OC_FILES.cache.incomplete[dir]){
OC_FILES.cache.incomplete[dir]=Array(); OC_FILES.cache.incomplete[dir]=Array();
} }
@ -248,17 +245,15 @@ OC_FILES.move=function(source,target,sourceDir,targetDir){
if(!OC_FILES.cache.incomplete[targetDir+'/'+target]){ if(!OC_FILES.cache.incomplete[targetDir+'/'+target]){
OC_FILES.cache.incomplete[targetDir+'/'+target]=Array(); OC_FILES.cache.incomplete[targetDir+'/'+target]=Array();
} }
xmlloader=new OCXMLLoader(); arg=new Object;
xmlloader.arg=new Object; arg.source=source;
xmlloader.arg.source=source; arg.target=target;
xmlloader.arg.target=target; arg.sourceDir=sourceDir;
xmlloader.arg.sourceDir=sourceDir; arg.targetDir=targetDir;
xmlloader.arg.targetDir=targetDir; arg.type=OC_FILES.cache.files[source]['type'];
xmlloader.arg.type=OC_FILES.cache.files[source]['type'];
OC_FILES.cache.files[source]['type']='incomplete'; OC_FILES.cache.files[source]['type']='incomplete';
OC_FILES.cache.incomplete[targetDir+'/'+target][source]=OC_FILES.cache.files[source] OC_FILES.cache.incomplete[targetDir+'/'+target][source]=OC_FILES.cache.files[source];
xmlloader.setCallBack(OC_FILES.move_callback); OC_API.run('move',{sourcedir:sourceDir,source:source,targetdir:targetDir,target:target},OC_FILES.move_callback,arg);
xmlloader.load('files/move.php?sourcedir='+sourceDir+'&targetdir='+targetDir+'&source='+source+'&target='+target);
} }
} }
@ -293,11 +288,12 @@ OC_FILES.actions_selected.download=function(){
if(files.length==0){ if(files.length==0){
return false; return false;
}else if(files.length>1){ }else if(files.length>1){
files.join(';'); files=files.join(';');
}else{ }else{
files=files[0]; files=files[0];
} }
window.location=WEBROOT+'/files/get_file.php?dir='+OC_FILES.dir+'&files='+files; OC_FILES.get(dir,files);
// window.location=WEBROOT+'/files/get_file.php?dir='+OC_FILES.dir+'&files='+files;
} }
OC_FILES.actions_selected['delete']=function(){ OC_FILES.actions_selected['delete']=function(){
@ -361,7 +357,7 @@ OC_FILES.fileActions.all.rename=function(){
OC_FILES.browser.show_rename(this.dir,this.file); OC_FILES.browser.show_rename(this.dir,this.file);
} }
OC_FILES.fileActions.all.download=function(){ OC_FILES.fileActions.all.download=function(){
window.location=WEBROOT+'/files/get_file.php?dir='+this.dir+'&files='+this.file; OC_FILES.get(this.dir,this.file);
} }
OC_FILES.fileActions.all['default']=OC_FILES.fileActions.all.download; OC_FILES.fileActions.all['default']=OC_FILES.fileActions.all.download;
@ -373,13 +369,12 @@ OC_FILES.fileActions.dir.open=function(){
OC_FILES.fileActions.dir['default']=OC_FILES.fileActions.dir.open; OC_FILES.fileActions.dir['default']=OC_FILES.fileActions.dir.open;
OC_FILES.fileActions.dir.dropOn=function(file){ OC_FILES.fileActions.dir.dropOn=function(file){
OC_FILES.move(file.file,this.file,file.dir,this.dir); OC_FILES.move(file.file,file.file,file.dir,this.dir+'/'+this.file);
} }
OC_FILES.fileActions.jpg=new Object() OC_FILES.fileActions.jpg=new Object()
OC_FILES.fileActions.jpg.show=function(){ OC_FILES.fileActions.jpg.show=function(){
// window.open(WEBROOT+'/files/open_file.php?dir='+this.dir+'&file='+this.file);
OC_FILES.browser.showImage(this.dir,this.file); OC_FILES.browser.showImage(this.dir,this.file);
} }