These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @copyright Copyright (c) 2016, ownCloud, Inc. |
||
4 | * |
||
5 | * @author Bjoern Schiessle <[email protected]> |
||
6 | * @author Björn Schießle <[email protected]> |
||
7 | * @author Joas Schilling <[email protected]> |
||
8 | * @author Lukas Reschke <[email protected]> |
||
9 | * @author Morris Jobke <[email protected]> |
||
10 | * @author Robin Appelman <[email protected]> |
||
11 | * @author Roeland Jago Douma <[email protected]> |
||
12 | * @author Thomas Müller <[email protected]> |
||
13 | * @author Vincent Petry <[email protected]> |
||
14 | * |
||
15 | * @license AGPL-3.0 |
||
16 | * |
||
17 | * This code is free software: you can redistribute it and/or modify |
||
18 | * it under the terms of the GNU Affero General Public License, version 3, |
||
19 | * as published by the Free Software Foundation. |
||
20 | * |
||
21 | * This program is distributed in the hope that it will be useful, |
||
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
24 | * GNU Affero General Public License for more details. |
||
25 | * |
||
26 | * You should have received a copy of the GNU Affero General Public License, version 3, |
||
27 | * along with this program. If not, see <http://www.gnu.org/licenses/> |
||
28 | * |
||
29 | */ |
||
30 | |||
31 | // load needed apps |
||
32 | $RUNTIME_APPTYPES = ['filesystem', 'authentication', 'logging']; |
||
33 | |||
34 | OC_App::loadApps($RUNTIME_APPTYPES); |
||
35 | |||
36 | OC_Util::obEnd(); |
||
37 | \OC::$server->getSession()->close(); |
||
38 | |||
39 | // Backends |
||
40 | $authBackend = new OCA\DAV\Connector\PublicAuth( |
||
41 | \OC::$server->getRequest(), |
||
42 | \OC::$server->getShareManager(), |
||
43 | \OC::$server->getSession() |
||
44 | ); |
||
45 | |||
46 | $serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory( |
||
47 | \OC::$server->getConfig(), |
||
48 | \OC::$server->getLogger(), |
||
49 | \OC::$server->getDatabaseConnection(), |
||
50 | \OC::$server->getUserSession(), |
||
51 | \OC::$server->getMountManager(), |
||
52 | \OC::$server->getTagManager(), |
||
53 | \OC::$server->getRequest(), |
||
54 | \OC::$server->getPreviewManager() |
||
55 | ); |
||
56 | |||
57 | $requestUri = \OC::$server->getRequest()->getRequestUri(); |
||
58 | |||
59 | $linkCheckPlugin = new \OCA\DAV\Files\Sharing\PublicLinkCheckPlugin(); |
||
60 | |||
61 | $server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin) { |
||
0 ignored issues
–
show
|
|||
62 | $isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'); |
||
63 | $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
||
64 | $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider(); |
||
65 | if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) { |
||
66 | // this is what is thrown when trying to access a non-existing share |
||
67 | throw new \Sabre\DAV\Exception\NotAuthenticated(); |
||
68 | } |
||
69 | |||
70 | $share = $authBackend->getShare(); |
||
71 | $owner = $share->getShareOwner(); |
||
72 | $isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ; |
||
73 | $fileId = $share->getNodeId(); |
||
74 | |||
75 | if (!$isReadable) { |
||
76 | return false; |
||
77 | } |
||
78 | |||
79 | \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) { |
||
80 | return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE)); |
||
81 | }); |
||
82 | |||
83 | OC_Util::setupFS($owner); |
||
84 | $ownerView = \OC\Files\Filesystem::getView(); |
||
85 | $path = $ownerView->getPath($fileId); |
||
86 | $fileInfo = $ownerView->getFileInfo($path); |
||
87 | $linkCheckPlugin->setFileInfo($fileInfo); |
||
88 | |||
89 | return new \OC\Files\View($ownerView->getAbsolutePath($path)); |
||
90 | }); |
||
91 | |||
92 | $server->addPlugin($linkCheckPlugin); |
||
93 | |||
94 | // And off we go! |
||
95 | $server->exec(); |
||
96 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.