aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/delete.php7
-rw-r--r--apps/files/ajax/download.php7
-rw-r--r--apps/files/ajax/getstoragestats.php4
-rw-r--r--apps/files/ajax/list.php7
-rw-r--r--apps/files/ajax/mimeicon.php1
-rw-r--r--apps/files/ajax/move.php6
-rw-r--r--apps/files/ajax/newfile.php3
-rw-r--r--apps/files/ajax/newfolder.php1
-rw-r--r--apps/files/ajax/rawlist.php62
-rw-r--r--apps/files/ajax/rename.php1
-rw-r--r--apps/files/ajax/scan.php2
-rw-r--r--apps/files/ajax/upgrade.php44
-rw-r--r--apps/files/ajax/upload.php4
13 files changed, 46 insertions, 103 deletions
diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php
index 69f859daa97..f6aa4f0c90e 100644
--- a/apps/files/ajax/delete.php
+++ b/apps/files/ajax/delete.php
@@ -1,15 +1,14 @@
<?php
-// Init owncloud
-
-
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
+\OC::$session->close();
+
// Get data
$dir = stripslashes($_POST["dir"]);
$files = isset($_POST["file"]) ? $_POST["file"] : $_POST["files"];
-$allFiles = isset($_POST["allfiles"]) ? $_POST["allfiles"] : $_POST["allfiles"];
+$allFiles = isset($_POST["allfiles"]) ? $_POST["allfiles"] : false;
if ($allFiles === 'true') {
$allFiles = true;
}
diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php
index 6a34cbe4ef1..4b4a7f8948d 100644
--- a/apps/files/ajax/download.php
+++ b/apps/files/ajax/download.php
@@ -21,14 +21,9 @@
*
*/
-// only need filesystem apps
-$RUNTIME_APPTYPES=array('filesystem');
-
-// Init owncloud
-
-
// Check if we are a user
OCP\User::checkLoggedIn();
+\OC::$session->close();
$files = $_GET["files"];
$dir = $_GET["dir"];
diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php
index dd7c7dc5571..dd8af39bada 100644
--- a/apps/files/ajax/getstoragestats.php
+++ b/apps/files/ajax/getstoragestats.php
@@ -1,8 +1,5 @@
<?php
-// only need filesystem apps
-$RUNTIME_APPTYPES = array('filesystem');
-
$dir = '/';
if (isset($_GET['dir'])) {
@@ -10,6 +7,7 @@ if (isset($_GET['dir'])) {
}
OCP\JSON::checkLoggedIn();
+\OC::$session->close();
// send back json
OCP\JSON::success(array('data' => \OCA\Files\Helper::buildFileStorageStatistics($dir)));
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index c8286bc15ca..3bb35579d5f 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -1,12 +1,7 @@
<?php
-// only need filesystem apps
-$RUNTIME_APPTYPES=array('filesystem');
-
-// Init owncloud
-
-
OCP\JSON::checkLoggedIn();
+\OC::$session->close();
// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
diff --git a/apps/files/ajax/mimeicon.php b/apps/files/ajax/mimeicon.php
index dbb8b60112a..6557ff941ac 100644
--- a/apps/files/ajax/mimeicon.php
+++ b/apps/files/ajax/mimeicon.php
@@ -1,3 +1,4 @@
<?php
+\OC::$session->close();
print OC_Helper::mimetypeIcon($_GET['mime']);
diff --git a/apps/files/ajax/move.php b/apps/files/ajax/move.php
index 93063e52eb0..0a8dbc24a65 100644
--- a/apps/files/ajax/move.php
+++ b/apps/files/ajax/move.php
@@ -1,10 +1,8 @@
<?php
-// Init owncloud
-
-
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
+\OC::$session->close();
// Get data
$dir = stripslashes($_POST["dir"]);
@@ -18,7 +16,7 @@ if(\OC\Files\Filesystem::file_exists($target . '/' . $file)) {
exit;
}
-if ($dir != '' || $file != 'Shared') {
+if ($target != '' || strtolower($file) != 'shared') {
$targetFile = \OC\Files\Filesystem::normalizePath($target . '/' . $file);
$sourceFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file);
if(\OC\Files\Filesystem::rename($sourceFile, $targetFile)) {
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index 0187b200759..1234cf11394 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -7,7 +7,8 @@ if(!OC_User::isLoggedIn()) {
exit;
}
-session_write_close();
+\OC::$session->close();
+
// Get the params
$dir = isset( $_REQUEST['dir'] ) ? '/'.trim($_REQUEST['dir'], '/\\') : '';
$filename = isset( $_REQUEST['filename'] ) ? trim($_REQUEST['filename'], '/\\') : '';
diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php
index b2b4fb27f74..032447460f3 100644
--- a/apps/files/ajax/newfolder.php
+++ b/apps/files/ajax/newfolder.php
@@ -5,6 +5,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
+\OC::$session->close();
// Get the params
$dir = isset( $_POST['dir'] ) ? stripslashes($_POST['dir']) : '';
diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php
index 40da32b223a..f18bbffb74a 100644
--- a/apps/files/ajax/rawlist.php
+++ b/apps/files/ajax/rawlist.php
@@ -1,12 +1,10 @@
<?php
-// only need filesystem apps
-$RUNTIME_APPTYPES=array('filesystem');
-
OCP\JSON::checkLoggedIn();
+\OC::$session->close();
// Load the files
-$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
+$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
$mimetypes = isset($_GET['mimetypes']) ? json_decode($_GET['mimetypes'], true) : '';
// Clean up duplicates from array and deal with non-array requests
@@ -18,43 +16,39 @@ if (is_array($mimetypes)) {
// make filelist
$files = array();
+/**
+ * @var \OCP\Files\FileInfo[] $files
+ */
// If a type other than directory is requested first load them.
-if($mimetypes && !in_array('httpd/unix-directory', $mimetypes)) {
- foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, 'httpd/unix-directory' ) as $file ) {
- $file['directory'] = $dir;
- $file['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($file['mimetype']);
- $file["date"] = OCP\Util::formatDate($file["mtime"]);
- $file['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
- $files[] = $file;
- }
+if ($mimetypes && !in_array('httpd/unix-directory', $mimetypes)) {
+ $files = array_merge($files, \OC\Files\Filesystem::getDirectoryContent($dir, 'httpd/unix-directory'));
}
if (is_array($mimetypes) && count($mimetypes)) {
foreach ($mimetypes as $mimetype) {
- foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, $mimetype ) as $file ) {
- $file['directory'] = $dir;
- $file['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($file['mimetype']);
- $file["date"] = OCP\Util::formatDate($file["mtime"]);
- $file['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
- $files[] = $file;
- }
+ $files = array_merge($files, \OC\Files\Filesystem::getDirectoryContent($dir, $mimetype));
}
} else {
- foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $file ) {
- $file['directory'] = $dir;
- $file['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($file['mimetype']);
- $file["date"] = OCP\Util::formatDate($file["mtime"]);
- $file['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
- $files[] = $file;
- }
+ $files = array_merge($files, \OC\Files\Filesystem::getDirectoryContent($dir));
}
-
// Sort by name
-usort($files, function ($a, $b) {
- if ($a['name'] === $b['name']) {
- return 0;
- }
- return ($a['name'] < $b['name']) ? -1 : 1;
-});
+usort($files, array('\OCA\Files\Helper', 'fileCmp'));
+
+$result = array();
+foreach ($files as $file) {
+ $fileData = array();
+ $fileData['directory'] = $dir;
+ $fileData['name'] = $file->getName();
+ $fileData['type'] = $file->getType();
+ $fileData['path'] = $file['path'];
+ $fileData['id'] = $file->getId();
+ $fileData['size'] = $file->getSize();
+ $fileData['mtime'] = $file->getMtime();
+ $fileData['mimetype'] = $file->getMimetype();
+ $fileData['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($file->getMimetype());
+ $fileData["date"] = OCP\Util::formatDate($file->getMtime());
+ $fileData['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
+ $result[] = $fileData;
+}
-OC_JSON::success(array('data' => $files));
+OC_JSON::success(array('data' => $result));
diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php
index 5b07c306af8..fa3ddace63d 100644
--- a/apps/files/ajax/rename.php
+++ b/apps/files/ajax/rename.php
@@ -23,6 +23,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
+\OC::$session->close();
$files = new \OCA\Files\App(
\OC\Files\Filesystem::getView(),
diff --git a/apps/files/ajax/scan.php b/apps/files/ajax/scan.php
index 5b32b6db9b7..d5d88483801 100644
--- a/apps/files/ajax/scan.php
+++ b/apps/files/ajax/scan.php
@@ -1,6 +1,6 @@
<?php
set_time_limit(0); //scanning can take ages
-session_write_close();
+\OC::$session->close();
$force = (isset($_GET['force']) and ($_GET['force'] === 'true'));
$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
diff --git a/apps/files/ajax/upgrade.php b/apps/files/ajax/upgrade.php
deleted file mode 100644
index 7237b02c0b0..00000000000
--- a/apps/files/ajax/upgrade.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-set_time_limit(0); //scanning can take ages
-session_write_close();
-
-$user = OC_User::getUser();
-$eventSource = new OC_EventSource();
-$listener = new UpgradeListener($eventSource);
-$legacy = new \OC\Files\Cache\Legacy($user);
-
-if ($legacy->hasItems()) {
- OC_Hook::connect('\OC\Files\Cache\Upgrade', 'migrate_path', $listener, 'upgradePath');
-
- OC_DB::beginTransaction();
- $upgrade = new \OC\Files\Cache\Upgrade($legacy);
- $count = $legacy->getCount();
- $eventSource->send('total', $count);
- $upgrade->upgradePath('/' . $user . '/files');
- OC_DB::commit();
-}
-\OC\Files\Cache\Upgrade::upgradeDone($user);
-$eventSource->send('done', true);
-$eventSource->close();
-
-class UpgradeListener {
- /**
- * @var OC_EventSource $eventSource
- */
- private $eventSource;
-
- private $count = 0;
- private $lastSend = 0;
-
- public function __construct($eventSource) {
- $this->eventSource = $eventSource;
- }
-
- public function upgradePath($path) {
- $this->count++;
- if ($this->count > ($this->lastSend + 5)) {
- $this->lastSend = $this->count;
- $this->eventSource->send('count', $this->count);
- }
- }
-}
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 145f40c50da..4ed51c52775 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -58,6 +58,10 @@ if (empty($_POST['dirToken'])) {
OCP\JSON::callCheck();
+if (!\OCP\App::isEnabled('files_encryption')) {
+ // encryption app need to create keys later, so can't close too early
+ \OC::$session->close();
+}
// get array with current storage stats (e.g. max file size)