File manager - Edit - /home/jardides/www/Jardi-design/images/administrator/Files.tar
Back
BrowserErrorPagePlugin.php 0000604 00000005453 15247131621 0011673 0 ustar 00 <?php /** * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Lukas Reschke <lukas@statuscode.ch> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ namespace OCA\DAV\Files; use OC\AppFramework\Http\Request; use OC_Template; use OCP\IRequest; use Sabre\DAV\Exception; use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; class BrowserErrorPagePlugin extends ServerPlugin { /** @var Server */ private $server; /** * This initializes the plugin. * * This function is called by Sabre\DAV\Server, after * addPlugin is called. * * This method should set up the required event subscriptions. * * @param Server $server * @return void */ function initialize(Server $server) { $this->server = $server; $server->on('exception', array($this, 'logException'), 1000); } /** * @param IRequest $request * @return bool */ public static function isBrowserRequest(IRequest $request) { if ($request->getMethod() !== 'GET') { return false; } return $request->isUserAgent([ Request::USER_AGENT_IE, Request::USER_AGENT_MS_EDGE, Request::USER_AGENT_CHROME, Request::USER_AGENT_FIREFOX, Request::USER_AGENT_SAFARI, ]); } /** * @param \Exception $ex */ public function logException(\Exception $ex) { if ($ex instanceof Exception) { $httpCode = $ex->getHTTPCode(); $headers = $ex->getHTTPHeaders($this->server); } else { $httpCode = 500; $headers = []; } $this->server->httpResponse->addHeaders($headers); $this->server->httpResponse->setStatus($httpCode); $body = $this->generateBody(); $this->server->httpResponse->setBody($body); $this->sendResponse(); } /** * @codeCoverageIgnore * @return bool|string */ public function generateBody() { $request = \OC::$server->getRequest(); $content = new OC_Template('dav', 'exception', 'guest'); $content->assign('title', $this->server->httpResponse->getStatusText()); $content->assign('remoteAddr', $request->getRemoteAddress()); $content->assign('requestID', $request->getId()); return $content->fetchPage(); } /** * @codeCoverageIgnore */ public function sendResponse() { $this->server->sapi->sendResponse($this->server->httpResponse); exit(); } } FilesHome.php 0000604 00000003211 15247131621 0007123 0 ustar 00 <?php /** * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Thomas Müller <thomas.mueller@tmit.eu> * * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ namespace OCA\DAV\Files; use OCA\DAV\Connector\Sabre\Directory; use OCP\Files\FileInfo; use Sabre\DAV\Exception\Forbidden; use Sabre\HTTP\URLUtil; class FilesHome extends Directory { /** * @var array */ private $principalInfo; /** * FilesHome constructor. * * @param array $principalInfo */ public function __construct($principalInfo) { $this->principalInfo = $principalInfo; $view = \OC\Files\Filesystem::getView(); $rootInfo = $view->getFileInfo(''); if (!($rootInfo instanceof FileInfo)) { throw new \Exception('Home does not exist'); } parent::__construct($view, $rootInfo); } function delete() { throw new Forbidden('Permission denied to delete home folder'); } function getName() { list(,$name) = URLUtil::splitPath($this->principalInfo['uri']); return $name; } function setName($name) { throw new Forbidden('Permission denied to rename this folder'); } } RootCollection.php 0000604 00000003505 15247131621 0010215 0 ustar 00 <?php /** * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Thomas Müller <thomas.mueller@tmit.eu> * * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ namespace OCA\DAV\Files; use Sabre\DAV\INode; use Sabre\DAVACL\AbstractPrincipalCollection; use Sabre\HTTP\URLUtil; use Sabre\DAV\SimpleCollection; class RootCollection extends AbstractPrincipalCollection { /** * This method returns a node for a principal. * * The passed array contains principal information, and is guaranteed to * at least contain a uri item. Other properties may or may not be * supplied by the authentication backend. * * @param array $principalInfo * @return INode */ function getChildForPrincipal(array $principalInfo) { list(,$name) = URLUtil::splitPath($principalInfo['uri']); $user = \OC::$server->getUserSession()->getUser(); if (is_null($user) || $name !== $user->getUID()) { // a user is only allowed to see their own home contents, so in case another collection // is accessed, we return a simple empty collection for now // in the future this could be considered to be used for accessing shared files return new SimpleCollection($name); } return new FilesHome($principalInfo); } function getName() { return 'files'; } } Sharing/FilesDropPlugin.php 0000604 00000004165 15247131621 0011722 0 ustar 00 <?php /** * @copyright Copyright (c) 2016, Roeland Jago Douma <roeland@famdouma.nl> * * @author Roeland Jago Douma <roeland@famdouma.nl> * * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ namespace OCA\DAV\Files\Sharing; use OC\Files\View; use Sabre\DAV\Exception\MethodNotAllowed; use Sabre\DAV\ServerPlugin; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** * Make sure that the destination is writable */ class FilesDropPlugin extends ServerPlugin { /** @var View */ private $view; /** @var bool */ private $enabled = false; /** * @param View $view */ public function setView($view) { $this->view = $view; } public function enable() { $this->enabled = true; } /** * This initializes the plugin. * * @param \Sabre\DAV\Server $server Sabre server * * @return void * @throws MethodNotAllowed */ public function initialize(\Sabre\DAV\Server $server) { $server->on('beforeMethod', [$this, 'beforeMethod'], 999); $this->enabled = false; } public function beforeMethod(RequestInterface $request, ResponseInterface $response){ if (!$this->enabled) { return; } if ($request->getMethod() !== 'PUT') { throw new MethodNotAllowed('Only PUT is allowed on files drop'); } $path = explode('/', $request->getPath()); $path = array_pop($path); $newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view); $url = $request->getBaseUrl() . $newName; $request->setUrl($url); } } Sharing/PublicLinkCheckPlugin.php 0000604 00000003241 15247131621 0013017 0 ustar 00 <?php /** * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Robin Appelman <robin@icewind.nl> * * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ namespace OCA\DAV\Files\Sharing; use OCP\Files\FileInfo; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\ServerPlugin; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; /** * Verify that the public link share is valid */ class PublicLinkCheckPlugin extends ServerPlugin { /** * @var FileInfo */ private $fileInfo; /** * @param FileInfo $fileInfo */ public function setFileInfo($fileInfo) { $this->fileInfo = $fileInfo; } /** * This initializes the plugin. * * @param \Sabre\DAV\Server $server Sabre server * * @return void */ public function initialize(\Sabre\DAV\Server $server) { $server->on('beforeMethod', [$this, 'beforeMethod']); } public function beforeMethod(RequestInterface $request, ResponseInterface $response){ // verify that the owner didn't have his share permissions revoked if ($this->fileInfo && !$this->fileInfo->isShareable()) { throw new NotFound(); } } } FileSearchBackend.php 0000604 00000023460 15247131621 0010535 0 ustar 00 <?php /** * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl> * * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ namespace OCA\DAV\Files; use OC\Files\Search\SearchBinaryOperator; use OC\Files\Search\SearchComparison; use OC\Files\Search\SearchOrder; use OC\Files\Search\SearchQuery; use OC\Files\View; use OCA\DAV\Connector\Sabre\Directory; use OCA\DAV\Connector\Sabre\FilesPlugin; use OCA\DAV\Connector\Sabre\TagsPlugin; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\Search\ISearchOperator; use OCP\Files\Search\ISearchOrder; use OCP\Files\Search\ISearchQuery; use OCP\IUser; use OCP\Share\IManager; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\Tree; use SearchDAV\Backend\ISearchBackend; use SearchDAV\Backend\SearchPropertyDefinition; use SearchDAV\Backend\SearchResult; use SearchDAV\XML\BasicSearch; use SearchDAV\XML\Literal; use SearchDAV\XML\Operator; use SearchDAV\XML\Order; class FileSearchBackend implements ISearchBackend { /** @var Tree */ private $tree; /** @var IUser */ private $user; /** @var IRootFolder */ private $rootFolder; /** @var IManager */ private $shareManager; /** @var View */ private $view; /** * FileSearchBackend constructor. * * @param Tree $tree * @param IUser $user * @param IRootFolder $rootFolder * @param IManager $shareManager * @param View $view * @internal param IRootFolder $rootFolder */ public function __construct(Tree $tree, IUser $user, IRootFolder $rootFolder, IManager $shareManager, View $view) { $this->tree = $tree; $this->user = $user; $this->rootFolder = $rootFolder; $this->shareManager = $shareManager; $this->view = $view; } /** * Search endpoint will be remote.php/dav * * @return string */ public function getArbiterPath() { return ''; } public function isValidScope($href, $depth, $path) { // only allow scopes inside the dav server if (is_null($path)) { return false; } try { $node = $this->tree->getNodeForPath($path); return $node instanceof Directory; } catch (NotFound $e) { return false; } } public function getPropertyDefinitionsForScope($href, $path) { // all valid scopes support the same schema //todo dynamically load all propfind properties that are supported return [ // queryable properties new SearchPropertyDefinition('{DAV:}displayname', true, false, true), new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true), new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME), new SearchPropertyDefinition(FilesPlugin::SIZE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER), new SearchPropertyDefinition(TagsPlugin::FAVORITE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_BOOLEAN), new SearchPropertyDefinition(FilesPlugin::INTERNAL_FILEID_PROPERTYNAME, true, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER), // select only properties new SearchPropertyDefinition('{DAV:}resourcetype', false, true, false), new SearchPropertyDefinition('{DAV:}getcontentlength', false, true, false), new SearchPropertyDefinition(FilesPlugin::CHECKSUMS_PROPERTYNAME, false, true, false), new SearchPropertyDefinition(FilesPlugin::PERMISSIONS_PROPERTYNAME, false, true, false), new SearchPropertyDefinition(FilesPlugin::GETETAG_PROPERTYNAME, false, true, false), new SearchPropertyDefinition(FilesPlugin::OWNER_ID_PROPERTYNAME, false, true, false), new SearchPropertyDefinition(FilesPlugin::OWNER_DISPLAY_NAME_PROPERTYNAME, false, true, false), new SearchPropertyDefinition(FilesPlugin::DATA_FINGERPRINT_PROPERTYNAME, false, true, false), new SearchPropertyDefinition(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, false, true, false, SearchPropertyDefinition::DATATYPE_BOOLEAN), new SearchPropertyDefinition(FilesPlugin::FILEID_PROPERTYNAME, false, true, false, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER), ]; } /** * @param BasicSearch $search * @return SearchResult[] */ public function search(BasicSearch $search) { if (count($search->from) !== 1) { throw new \InvalidArgumentException('Searching more than one folder is not supported'); } $query = $this->transformQuery($search); $scope = $search->from[0]; if ($scope->path === null) { throw new \InvalidArgumentException('Using uri\'s as scope is not supported, please use a path relative to the search arbiter instead'); } $node = $this->tree->getNodeForPath($scope->path); if (!$node instanceof Directory) { throw new \InvalidArgumentException('Search is only supported on directories'); } $fileInfo = $node->getFileInfo(); $folder = $this->rootFolder->get($fileInfo->getPath()); /** @var Folder $folder $results */ $results = $folder->search($query); return array_map(function (Node $node) { if ($node instanceof Folder) { return new SearchResult(new \OCA\DAV\Connector\Sabre\Directory($this->view, $node, $this->tree, $this->shareManager), $this->getHrefForNode($node)); } else { return new SearchResult(new \OCA\DAV\Connector\Sabre\File($this->view, $node, $this->shareManager), $this->getHrefForNode($node)); } }, $results); } /** * @param Node $node * @return string */ private function getHrefForNode(Node $node) { $base = '/files/' . $this->user->getUID(); return $base . $this->view->getRelativePath($node->getPath()); } /** * @param BasicSearch $query * @return ISearchQuery */ private function transformQuery(BasicSearch $query) { // TODO offset, limit $orders = array_map([$this, 'mapSearchOrder'], $query->orderBy); return new SearchQuery($this->transformSearchOperation($query->where), 0, 0, $orders, $this->user); } /** * @param Order $order * @return ISearchOrder */ private function mapSearchOrder(Order $order) { return new SearchOrder($order->order === Order::ASC ? ISearchOrder::DIRECTION_ASCENDING : ISearchOrder::DIRECTION_DESCENDING, $this->mapPropertyNameToColumn($order->property)); } /** * @param Operator $operator * @return ISearchOperator */ private function transformSearchOperation(Operator $operator) { list(, $trimmedType) = explode('}', $operator->type); switch ($operator->type) { case Operator::OPERATION_AND: case Operator::OPERATION_OR: case Operator::OPERATION_NOT: $arguments = array_map([$this, 'transformSearchOperation'], $operator->arguments); return new SearchBinaryOperator($trimmedType, $arguments); case Operator::OPERATION_EQUAL: case Operator::OPERATION_GREATER_OR_EQUAL_THAN: case Operator::OPERATION_GREATER_THAN: case Operator::OPERATION_LESS_OR_EQUAL_THAN: case Operator::OPERATION_LESS_THAN: case Operator::OPERATION_IS_LIKE: if (count($operator->arguments) !== 2) { throw new \InvalidArgumentException('Invalid number of arguments for ' . $trimmedType . ' operation'); } if (!is_string($operator->arguments[0])) { throw new \InvalidArgumentException('Invalid argument 1 for ' . $trimmedType . ' operation, expected property'); } if (!($operator->arguments[1] instanceof Literal)) { throw new \InvalidArgumentException('Invalid argument 2 for ' . $trimmedType . ' operation, expected literal'); } return new SearchComparison($trimmedType, $this->mapPropertyNameToColumn($operator->arguments[0]), $this->castValue($operator->arguments[0], $operator->arguments[1]->value)); case Operator::OPERATION_IS_COLLECTION: return new SearchComparison('eq', 'mimetype', ICacheEntry::DIRECTORY_MIMETYPE); default: throw new \InvalidArgumentException('Unsupported operation ' . $trimmedType . ' (' . $operator->type . ')'); } } /** * @param string $propertyName * @return string */ private function mapPropertyNameToColumn($propertyName) { switch ($propertyName) { case '{DAV:}displayname': return 'name'; case '{DAV:}getcontenttype': return 'mimetype'; case '{DAV:}getlastmodified': return 'mtime'; case FilesPlugin::SIZE_PROPERTYNAME: return 'size'; case TagsPlugin::FAVORITE_PROPERTYNAME: return 'favorite'; case TagsPlugin::TAGS_PROPERTYNAME: return 'tagname'; case FilesPlugin::INTERNAL_FILEID_PROPERTYNAME: return 'fileid'; default: throw new \InvalidArgumentException('Unsupported property for search or order: ' . $propertyName); } } private function castValue($propertyName, $value) { $allProps = $this->getPropertyDefinitionsForScope('', ''); foreach ($allProps as $prop) { if ($prop->name === $propertyName) { $dataType = $prop->dataType; switch ($dataType) { case SearchPropertyDefinition::DATATYPE_BOOLEAN: return $value === 'yes'; case SearchPropertyDefinition::DATATYPE_DECIMAL: case SearchPropertyDefinition::DATATYPE_INTEGER: case SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER: return 0 + $value; case SearchPropertyDefinition::DATATYPE_DATETIME: if (is_numeric($value)) { return 0 + $value; } $date = \DateTime::createFromFormat(\DateTime::ATOM, $value); return ($date instanceof \DateTime) ? $date->getTimestamp() : 0; default: return $value; } } } return $value; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings