summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-05-30 22:40:28 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-05-30 22:40:28 +0200
commit5dd3e34f57bebf14766b39142d7cdc62e928f36b (patch)
treed8872275d2ccd6dc5e1a2364dd12841728228c66 /apps/files_sharing
parent555b9cc24532945f6a87741b336db535ac5b68cf (diff)
parent51a6764f3180a258dc17a6744929866aeddb8779 (diff)
downloadnextcloud-server-5dd3e34f57bebf14766b39142d7cdc62e928f36b.tar.gz
nextcloud-server-5dd3e34f57bebf14766b39142d7cdc62e928f36b.zip
Merge pull request #8444 from owncloud/cleanup-list-code
Cleanup code of files_sharing/ajax/ a little bit
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/ajax/list.php9
-rw-r--r--apps/files_sharing/ajax/publicpreview.php21
2 files changed, 13 insertions, 17 deletions
diff --git a/apps/files_sharing/ajax/list.php b/apps/files_sharing/ajax/list.php
index 82bacb3d38d..93964c5ed5b 100644
--- a/apps/files_sharing/ajax/list.php
+++ b/apps/files_sharing/ajax/list.php
@@ -20,12 +20,10 @@
*
*/
-if(!\OC_App::isEnabled('files_sharing')){
- exit;
-}
+OCP\JSON::checkAppEnabled('files_sharing');
if(!isset($_GET['t'])){
- \OC_Response::setStatus(400); //400 Bad Request
+ \OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
\OC_Log::write('core-preview', 'No token parameter was passed', \OC_Log::DEBUG);
exit;
}
@@ -53,13 +51,12 @@ $dir = $data['realPath'];
$dir = \OC\Files\Filesystem::normalizePath($dir);
if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
- \OC_Response::setStatus(404);
+ \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
\OCP\JSON::error(array('success' => false));
exit();
}
$data = array();
-$baseUrl = OCP\Util::linkTo('files_sharing', 'index.php') . '?t=' . urlencode($token) . '&dir=';
// make filelist
$files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection);
diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php
index d8c892f1b7f..0b2af7a6e59 100644
--- a/apps/files_sharing/ajax/publicpreview.php
+++ b/apps/files_sharing/ajax/publicpreview.php
@@ -5,9 +5,8 @@
* later.
* See the COPYING-README file.
*/
-if(!\OC_App::isEnabled('files_sharing')){
- exit;
-}
+
+OCP\JSON::checkAppEnabled('files_sharing');
\OC_User::setIncognitoMode(true);
@@ -19,20 +18,20 @@ $token = array_key_exists('t', $_GET) ? (string) $_GET['t'] : '';
$keepAspect = array_key_exists('a', $_GET) ? true : false;
if($token === ''){
- \OC_Response::setStatus(400); //400 Bad Request
+ \OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
\OC_Log::write('core-preview', 'No token parameter was passed', \OC_Log::DEBUG);
exit;
}
$linkedItem = \OCP\Share::getShareByToken($token);
if($linkedItem === false || ($linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder')) {
- \OC_Response::setStatus(404);
+ \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
\OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG);
exit;
}
if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) {
- \OC_Response::setStatus(500);
+ \OC_Response::setStatus(\OC_Response::STATUS_INTERNAL_SERVER_ERROR);
\OC_Log::write('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OC_Log::WARN);
exit;
}
@@ -51,9 +50,9 @@ $pathInfo = $view->getFileInfo($path);
$sharedFile = null;
if($linkedItem['item_type'] === 'folder') {
- $isvalid = \OC\Files\Filesystem::isValidPath($file);
- if(!$isvalid) {
- \OC_Response::setStatus(400); //400 Bad Request
+ $isValid = \OC\Files\Filesystem::isValidPath($file);
+ if(!$isValid) {
+ \OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
\OC_Log::write('core-preview', 'Passed filename is not valid, might be malicious (file:"' . $file . '";ip:"' . $_SERVER['REMOTE_ADDR'] . '")', \OC_Log::WARN);
exit;
}
@@ -76,7 +75,7 @@ if ($keepAspect === true) {
}
if($maxX === 0 || $maxY === 0) {
- \OC_Response::setStatus(400); //400 Bad Request
+ \OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST);
\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
exit;
}
@@ -93,6 +92,6 @@ try{
$preview->showPreview();
} catch (\Exception $e) {
- \OC_Response::setStatus(500);
+ \OC_Response::setStatus(\OC_Response::STATUS_INTERNAL_SERVER_ERROR);
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
}