summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/autocomplete.php2
-rw-r--r--apps/files/ajax/delete.php2
-rw-r--r--apps/files/ajax/download.php1
-rw-r--r--apps/files/ajax/list.php4
-rw-r--r--apps/files/ajax/mimeicon.php8
-rw-r--r--apps/files/ajax/move.php2
-rw-r--r--apps/files/ajax/newfile.php58
-rw-r--r--apps/files/ajax/rawlist.php2
-rw-r--r--apps/files/ajax/rename.php2
-rw-r--r--apps/files/ajax/scan.php6
-rw-r--r--apps/files/ajax/timezone.php4
-rw-r--r--apps/files/ajax/upload.php5
12 files changed, 58 insertions, 38 deletions
diff --git a/apps/files/ajax/autocomplete.php b/apps/files/ajax/autocomplete.php
index 7ff34da96b3..e504bb24bf8 100644
--- a/apps/files/ajax/autocomplete.php
+++ b/apps/files/ajax/autocomplete.php
@@ -52,5 +52,3 @@ if(OC_Filesystem::file_exists($base) and OC_Filesystem::is_dir($base)){
}
}
OCP\JSON::encodedPrint($files);
-
-?>
diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php
index 161d820f735..695f803884e 100644
--- a/apps/files/ajax/delete.php
+++ b/apps/files/ajax/delete.php
@@ -26,5 +26,3 @@ if($success) {
} else {
OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError )));
}
-
-?>
diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php
index e9373f5f6ac..b9a4ddaf5e7 100644
--- a/apps/files/ajax/download.php
+++ b/apps/files/ajax/download.php
@@ -34,4 +34,3 @@ $files = $_GET["files"];
$dir = $_GET["dir"];
OC_Files::get($dir, $files, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
-?>
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index ceb8d158580..dae0c1a828d 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -38,9 +38,7 @@ foreach( OC_Files::getdirectorycontent( $dir ) as $i ){
}
$list = new OCP\Template( "files", "part.list", "" );
-$list->assign( "files", $files );
+$list->assign( "files", $files, false );
$data = array('files' => $list->fetchPage());
OCP\JSON::success(array('data' => $data));
-
-?>
diff --git a/apps/files/ajax/mimeicon.php b/apps/files/ajax/mimeicon.php
index 57898cd82d9..dbb8b60112a 100644
--- a/apps/files/ajax/mimeicon.php
+++ b/apps/files/ajax/mimeicon.php
@@ -1,11 +1,3 @@
<?php
-// no need for apps
-$RUNTIME_NOAPPS=false;
-
-// Init owncloud
-
-
print OC_Helper::mimetypeIcon($_GET['mime']);
-
-?>
diff --git a/apps/files/ajax/move.php b/apps/files/ajax/move.php
index 56171dd0ed3..3d4003a8edc 100644
--- a/apps/files/ajax/move.php
+++ b/apps/files/ajax/move.php
@@ -17,5 +17,3 @@ if(OC_Files::move($dir,$file,$target,$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 7236deb65c9..cc9208ad08f 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -1,16 +1,25 @@
<?php
// Init owncloud
+global $eventSource;
+if(!OC_User::isLoggedIn()){
+ exit;
+}
-OCP\JSON::checkLoggedIn();
-OCP\JSON::callCheck();
+session_write_close();
// Get the params
-$dir = isset( $_POST['dir'] ) ? stripslashes($_POST['dir']) : '';
-$filename = isset( $_POST['filename'] ) ? stripslashes($_POST['filename']) : '';
-$content = isset( $_POST['content'] ) ? $_POST['content'] : '';
-$source = isset( $_POST['source'] ) ? stripslashes($_POST['source']) : '';
+$dir = isset( $_REQUEST['dir'] ) ? stripslashes($_REQUEST['dir']) : '';
+$filename = isset( $_REQUEST['filename'] ) ? stripslashes($_REQUEST['filename']) : '';
+$content = isset( $_REQUEST['content'] ) ? $_REQUEST['content'] : '';
+$source = isset( $_REQUEST['source'] ) ? stripslashes($_REQUEST['source']) : '';
+
+if($source){
+ $eventSource=new OC_EventSource();
+}else{
+ OC_JSON::callCheck();
+}
if($filename == '') {
OCP\JSON::error(array("data" => array( "message" => "Empty Filename" )));
@@ -21,22 +30,49 @@ if(strpos($filename,'/')!==false){
exit();
}
+function progress($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max){
+ static $filesize = 0;
+ static $lastsize = 0;
+ global $eventSource;
+
+ switch($notification_code) {
+ case STREAM_NOTIFY_FILE_SIZE_IS:
+ $filesize = $bytes_max;
+ break;
+
+ case STREAM_NOTIFY_PROGRESS:
+ if ($bytes_transferred > 0) {
+ if (!isset($filesize)) {
+ } else {
+ $progress = (int)(($bytes_transferred/$filesize)*100);
+ if($progress>$lastsize){//limit the number or messages send
+ $eventSource->send('progress',$progress);
+ }
+ $lastsize=$progress;
+ }
+ }
+ break;
+ }
+}
+
if($source){
if(substr($source,0,8)!='https://' and substr($source,0,7)!='http://'){
OCP\JSON::error(array("data" => array( "message" => "Not a valid source" )));
exit();
}
- $sourceStream=fopen($source,'rb');
+
+ $ctx = stream_context_create(null, array('notification' =>'progress'));
+ $sourceStream=fopen($source,'rb', false, $ctx);
$target=$dir.'/'.$filename;
$result=OC_Filesystem::file_put_contents($target,$sourceStream);
if($result){
$mime=OC_Filesystem::getMimetype($target);
- OCP\JSON::success(array("data" => array('mime'=>$mime)));
- exit();
+ $eventSource->send('success',$mime);
}else{
- OCP\JSON::error(array("data" => array( "message" => "Error while downloading ".$source. ' to '.$target )));
- exit();
+ $eventSource->send('error',"Error while downloading ".$source. ' to '.$target);
}
+ $eventSource->close();
+ exit();
}else{
if($content){
if(OC_Filesystem::file_put_contents($dir.'/'.$filename,$content)){
diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php
index 7cb02f79673..d159f6e152f 100644
--- a/apps/files/ajax/rawlist.php
+++ b/apps/files/ajax/rawlist.php
@@ -22,5 +22,3 @@ foreach( OC_Files::getdirectorycontent( $dir, $mimetype ) as $i ){
}
OCP\JSON::success(array('data' => $files));
-
-?>
diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php
index 8e98308eb5c..45448279fa1 100644
--- a/apps/files/ajax/rename.php
+++ b/apps/files/ajax/rename.php
@@ -18,5 +18,3 @@ if( OC_Files::move( $dir, $file, $dir, $newname )) {
else{
OCP\JSON::error(array("data" => array( "message" => "Unable to rename file" )));
}
-
-?>
diff --git a/apps/files/ajax/scan.php b/apps/files/ajax/scan.php
index d695ce81617..eef38858516 100644
--- a/apps/files/ajax/scan.php
+++ b/apps/files/ajax/scan.php
@@ -10,11 +10,17 @@ if(!$checkOnly){
$eventSource=new OC_EventSource();
}
+session_write_close();
//create the file cache if necesary
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
+ }
+
OC_FileCache::scan($dir,$eventSource);
OC_FileCache::clean();
OCP\DB::commit();
diff --git a/apps/files/ajax/timezone.php b/apps/files/ajax/timezone.php
index 268ae594835..0be441a36a2 100644
--- a/apps/files/ajax/timezone.php
+++ b/apps/files/ajax/timezone.php
@@ -1,6 +1,6 @@
<?php
// FIXME: this should start a secure session if forcessl is enabled
// see lib/base.php for an example
- @session_start();
+ //session_start();
$_SESSION['timezone'] = $_GET['time'];
-?>
+ \ No newline at end of file
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index d6c799af32c..74e6eb560d8 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -7,6 +7,7 @@
OCP\JSON::setContentTypeHeader('text/plain');
OCP\JSON::checkLoggedIn();
+OCP\JSON::callCheck();
if (!isset($_FILES['files'])) {
OCP\JSON::error(array("data" => array( "message" => "No file was uploaded. Unknown error" )));
@@ -48,7 +49,7 @@ if(strpos($dir,'..') === false){
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)){
- $meta=OC_FileCache::getCached($target);
+ $meta=OC_FileCache_Cached::get($target);
$result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'],'name'=>basename($target));
}
}
@@ -59,5 +60,3 @@ if(strpos($dir,'..') === false){
}
OCP\JSON::error(array('data' => array('error' => $error, "file" => $fileName)));
-
-?>