Welcome to mirror list, hosted at ThFree Co, Russian Federation.

share.php « ajax « files_sharing « apps - github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 79ebf9187b9c727c723f479b71c8e8b24f1f20bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once(OC::$APPSROOT . '/apps/files_sharing/lib_share.php');

OCP\JSON::checkAppEnabled('files_sharing');
OCP\JSON::checkLoggedIn();

$userDirectory = '/'.OCP\USER::getUser().'/files';
$sources = explode(';', $_POST['sources']);
$uid_shared_with = $_POST['uid_shared_with'];
$permissions = $_POST['permissions'];
foreach ($sources as $source) {
	$path = ltrim($source, '/'); 
	$source = $userDirectory.$source;
	// Check if the file exists or if the file is being reshared
	if ($source && (OC_FILESYSTEM::file_exists($path) && OC_FILESYSTEM::is_readable($path) || OC_Share::getSource($source))) {
		try {
			$shared = new OC_Share($source, $uid_shared_with, $permissions);
			// If this is a private link, return the token
			if ($uid_shared_with == OC_Share::PUBLICLINK) {
				OCP\JSON::success(array('data' => $shared->getToken()));
			} else {
				OCP\JSON::success();
			}
		} catch (Exception $exception) {
			OCP\Util::writeLog('files_sharing', 'Unexpected Error : '.$exception->getMessage(),OCP\Util::ERROR);
			OCP\JSON::error();
		}
	} else {
		OCP\Util::writeLog('files_sharing', 'File does not exist or is not readable :'.$source,OCP\Util::ERROR);
		OCP\JSON::error();
	}
}

?>