apply coding style
This commit is contained in:
parent
f301bfd8c9
commit
fe49cbafc7
|
@ -15,7 +15,7 @@ $filesWithError = '';
|
||||||
$success = true;
|
$success = true;
|
||||||
//Now delete
|
//Now delete
|
||||||
foreach($files as $file) {
|
foreach($files as $file) {
|
||||||
if( !OC_Files::delete( $dir, $file )){
|
if( !OC_Files::delete( $dir, $file )) {
|
||||||
$filesWithError .= $file . "\n";
|
$filesWithError .= $file . "\n";
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ $doBreadcrumb = isset( $_GET['breadcrumb'] ) ? true : false;
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
// Make breadcrumb
|
// Make breadcrumb
|
||||||
if($doBreadcrumb){
|
if($doBreadcrumb) {
|
||||||
$breadcrumb = array();
|
$breadcrumb = array();
|
||||||
$pathtohere = "/";
|
$pathtohere = "/";
|
||||||
foreach( explode( "/", $dir ) as $i ){
|
foreach( explode( "/", $dir ) as $i ){
|
||||||
if( $i != "" ){
|
if( $i != "" ) {
|
||||||
$pathtohere .= "$i/";
|
$pathtohere .= "$i/";
|
||||||
$breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
|
$breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ $file = stripslashes($_GET["file"]);
|
||||||
$target = stripslashes($_GET["target"]);
|
$target = stripslashes($_GET["target"]);
|
||||||
|
|
||||||
|
|
||||||
if(OC_Files::move($dir,$file,$target,$file)){
|
if(OC_Files::move($dir, $file, $target, $file)) {
|
||||||
OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $file )));
|
OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $file )));
|
||||||
}else{
|
} else {
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Could not move $file" )));
|
OCP\JSON::error(array("data" => array( "message" => "Could not move $file" )));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// Init owncloud
|
// Init owncloud
|
||||||
global $eventSource;
|
global $eventSource;
|
||||||
|
|
||||||
if(!OC_User::isLoggedIn()){
|
if(!OC_User::isLoggedIn()) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ $filename = isset( $_REQUEST['filename'] ) ? stripslashes($_REQUEST['filename'])
|
||||||
$content = isset( $_REQUEST['content'] ) ? $_REQUEST['content'] : '';
|
$content = isset( $_REQUEST['content'] ) ? $_REQUEST['content'] : '';
|
||||||
$source = isset( $_REQUEST['source'] ) ? stripslashes($_REQUEST['source']) : '';
|
$source = isset( $_REQUEST['source'] ) ? stripslashes($_REQUEST['source']) : '';
|
||||||
|
|
||||||
if($source){
|
if($source) {
|
||||||
$eventSource=new OC_EventSource();
|
$eventSource=new OC_EventSource();
|
||||||
}else{
|
} else {
|
||||||
OC_JSON::callCheck();
|
OC_JSON::callCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ if($filename == '') {
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Empty Filename" )));
|
OCP\JSON::error(array("data" => array( "message" => "Empty Filename" )));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
if(strpos($filename,'/')!==false){
|
if(strpos($filename,'/')!==false) {
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Invalid Filename" )));
|
OCP\JSON::error(array("data" => array( "message" => "Invalid Filename" )));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function progress($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max){
|
function progress($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) {
|
||||||
static $filesize = 0;
|
static $filesize = 0;
|
||||||
static $lastsize = 0;
|
static $lastsize = 0;
|
||||||
global $eventSource;
|
global $eventSource;
|
||||||
|
@ -45,8 +45,8 @@ function progress($notification_code, $severity, $message, $message_code, $bytes
|
||||||
if (!isset($filesize)) {
|
if (!isset($filesize)) {
|
||||||
} else {
|
} else {
|
||||||
$progress = (int)(($bytes_transferred/$filesize)*100);
|
$progress = (int)(($bytes_transferred/$filesize)*100);
|
||||||
if($progress>$lastsize){//limit the number or messages send
|
if($progress>$lastsize) {//limit the number or messages send
|
||||||
$eventSource->send('progress',$progress);
|
$eventSource->send('progress', $progress);
|
||||||
}
|
}
|
||||||
$lastsize=$progress;
|
$lastsize=$progress;
|
||||||
}
|
}
|
||||||
|
@ -56,30 +56,30 @@ function progress($notification_code, $severity, $message, $message_code, $bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
if($source){
|
if($source){
|
||||||
if(substr($source,0,8)!='https://' and substr($source,0,7)!='http://'){
|
if(substr($source, 0, 8)!='https://' and substr($source, 0, 7)!='http://') {
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Not a valid source" )));
|
OCP\JSON::error(array("data" => array( "message" => "Not a valid source" )));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$ctx = stream_context_create(null, array('notification' =>'progress'));
|
$ctx = stream_context_create(null, array('notification' =>'progress'));
|
||||||
$sourceStream=fopen($source,'rb', false, $ctx);
|
$sourceStream=fopen($source, 'rb', false, $ctx);
|
||||||
$target=$dir.'/'.$filename;
|
$target=$dir.'/'.$filename;
|
||||||
$result=OC_Filesystem::file_put_contents($target,$sourceStream);
|
$result=OC_Filesystem::file_put_contents($target, $sourceStream);
|
||||||
if($result){
|
if($result) {
|
||||||
$mime=OC_Filesystem::getMimetype($target);
|
$mime=OC_Filesystem::getMimetype($target);
|
||||||
$eventSource->send('success',$mime);
|
$eventSource->send('success', $mime);
|
||||||
}else{
|
} else {
|
||||||
$eventSource->send('error',"Error while downloading ".$source. ' to '.$target);
|
$eventSource->send('error', "Error while downloading ".$source. ' to '.$target);
|
||||||
}
|
}
|
||||||
$eventSource->close();
|
$eventSource->close();
|
||||||
exit();
|
exit();
|
||||||
}else{
|
} else {
|
||||||
if($content){
|
if($content) {
|
||||||
if(OC_Filesystem::file_put_contents($dir.'/'.$filename,$content)){
|
if(OC_Filesystem::file_put_contents($dir.'/'.$filename, $content)) {
|
||||||
OCP\JSON::success(array("data" => array('content'=>$content)));
|
OCP\JSON::success(array("data" => array('content'=>$content)));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}elseif(OC_Files::newFile($dir, $filename, 'file')){
|
}elseif(OC_Files::newFile($dir, $filename, 'file')) {
|
||||||
OCP\JSON::success(array("data" => array('content'=>$content)));
|
OCP\JSON::success(array("data" => array('content'=>$content)));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ if(trim($foldername) == '') {
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Empty Foldername" )));
|
OCP\JSON::error(array("data" => array( "message" => "Empty Foldername" )));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
if(strpos($foldername,'/')!==false){
|
if(strpos($foldername, '/')!==false) {
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Invalid Foldername" )));
|
OCP\JSON::error(array("data" => array( "message" => "Invalid Foldername" )));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ $RUNTIME_APPTYPES=array('filesystem');
|
||||||
|
|
||||||
// Init owncloud
|
// Init owncloud
|
||||||
|
|
||||||
require_once('lib/template.php');
|
require_once 'lib/template.php';
|
||||||
|
|
||||||
OCP\JSON::checkLoggedIn();
|
OCP\JSON::checkLoggedIn();
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ $mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : '';
|
||||||
|
|
||||||
// make filelist
|
// make filelist
|
||||||
$files = array();
|
$files = array();
|
||||||
foreach( OC_Files::getdirectorycontent( $dir, $mimetype ) as $i ){
|
foreach( OC_Files::getdirectorycontent( $dir, $mimetype ) as $i ) {
|
||||||
$i["date"] = OCP\Util::formatDate($i["mtime"] );
|
$i["date"] = OCP\Util::formatDate($i["mtime"] );
|
||||||
$i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']);
|
$i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']);
|
||||||
$files[] = $i;
|
$files[] = $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,37 +6,38 @@ $force=isset($_GET['force']) and $_GET['force']=='true';
|
||||||
$dir=isset($_GET['dir'])?$_GET['dir']:'';
|
$dir=isset($_GET['dir'])?$_GET['dir']:'';
|
||||||
$checkOnly=isset($_GET['checkonly']) and $_GET['checkonly']=='true';
|
$checkOnly=isset($_GET['checkonly']) and $_GET['checkonly']=='true';
|
||||||
|
|
||||||
if(!$checkOnly){
|
if(!$checkOnly) {
|
||||||
$eventSource=new OC_EventSource();
|
$eventSource=new OC_EventSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
session_write_close();
|
session_write_close();
|
||||||
|
|
||||||
//create the file cache if necesary
|
//create the file cache if necesary
|
||||||
if($force or !OC_FileCache::inCache('')){
|
if($force or !OC_FileCache::inCache('')) {
|
||||||
if(!$checkOnly){
|
if(!$checkOnly) {
|
||||||
OCP\DB::beginTransaction();
|
OCP\DB::beginTransaction();
|
||||||
|
|
||||||
if(OC_Cache::isFast()){
|
if(OC_Cache::isFast()) {
|
||||||
OC_Cache::clear('fileid/'); //make sure the old fileid's don't mess things up
|
//make sure the old fileid's don't mess things up
|
||||||
|
OC_Cache::clear('fileid/');
|
||||||
}
|
}
|
||||||
|
|
||||||
OC_FileCache::scan($dir,$eventSource);
|
OC_FileCache::scan($dir, $eventSource);
|
||||||
OC_FileCache::clean();
|
OC_FileCache::clean();
|
||||||
OCP\DB::commit();
|
OCP\DB::commit();
|
||||||
$eventSource->send('success',true);
|
$eventSource->send('success', true);
|
||||||
}else{
|
} else {
|
||||||
OCP\JSON::success(array('data'=>array('done'=>true)));
|
OCP\JSON::success(array('data'=>array('done'=>true)));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
if($checkOnly){
|
if($checkOnly) {
|
||||||
OCP\JSON::success(array('data'=>array('done'=>false)));
|
OCP\JSON::success(array('data'=>array('done'=>false)));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if(isset($eventSource)){
|
if(isset($eventSource)) {
|
||||||
$eventSource->send('success',false);
|
$eventSource->send('success',false);
|
||||||
}else{
|
} else {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,24 +38,24 @@ $totalSize=0;
|
||||||
foreach($files['size'] as $size){
|
foreach($files['size'] as $size){
|
||||||
$totalSize+=$size;
|
$totalSize+=$size;
|
||||||
}
|
}
|
||||||
if($totalSize>OC_Filesystem::free_space('/')){
|
if($totalSize>OC_Filesystem::free_space('/')) {
|
||||||
OCP\JSON::error(array("data" => array( "message" => "Not enough space available" )));
|
OCP\JSON::error(array("data" => array( "message" => "Not enough space available" )));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=array();
|
$result=array();
|
||||||
if(strpos($dir,'..') === false){
|
if(strpos($dir, '..') === false) {
|
||||||
$fileCount=count($files['name']);
|
$fileCount=count($files['name']);
|
||||||
for($i=0;$i<$fileCount;$i++){
|
for($i=0;$i<$fileCount;$i++){
|
||||||
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
|
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
|
||||||
if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i],$target)){
|
if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
|
||||||
$meta=OC_FileCache_Cached::get($target);
|
$meta=OC_FileCache_Cached::get($target);
|
||||||
$result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'],'name'=>basename($target));
|
$result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'],'name'=>basename($target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OCP\JSON::encodedPrint($result);
|
OCP\JSON::encodedPrint($result);
|
||||||
exit();
|
exit();
|
||||||
}else{
|
} else {
|
||||||
$error='invalid dir';
|
$error='invalid dir';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue