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