File manager - Edit - /home/opticamezl/www/newok/typo3.zip
Back
PK U�\�.��C C phar-stream-wrapper/LICENSEnu �[��� MIT License Copyright (c) 2018 TYPO3 project - https://typo3.org/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK U�\�^9/� � % phar-stream-wrapper/src/Exception.phpnu �[��� <?php declare(strict_types=1); namespace TYPO3\PharStreamWrapper; /* * This file is part of the TYPO3 project. * * It is free software; you can redistribute it and/or modify it under the terms * of the MIT License (MIT). For the full copyright and license information, * please read the LICENSE file that was distributed with this source code. * * The TYPO3 project - inspiring people to share! */ class Exception extends \RuntimeException { } PK U�\O��ϼ � 3 phar-stream-wrapper/src/Resolver/PharInvocation.phpnu �[��� <?php declare(strict_types=1); namespace TYPO3\PharStreamWrapper\Resolver; /* * This file is part of the TYPO3 project. * * It is free software; you can redistribute it and/or modify it under the terms * of the MIT License (MIT). For the full copyright and license information, * please read the LICENSE file that was distributed with this source code. * * The TYPO3 project - inspiring people to share! */ use TYPO3\PharStreamWrapper\Exception; class PharInvocation { /** * @var string */ private $baseName; /** * @var string */ private $alias; /** * @var bool * @see \TYPO3\PharStreamWrapper\PharStreamWrapper::collectInvocation() */ private $confirmed = false; /** * Arbitrary variables to be used by interceptors as registry * (e.g. in order to avoid duplicate processing and assertions) * * @var array */ private $variables; /** * @param string $baseName * @param string $alias */ public function __construct(string $baseName, string $alias = '') { if ($baseName === '') { throw new Exception( 'Base-name cannot be empty', 1551283689 ); } $this->baseName = $baseName; $this->alias = $alias; } /** * @return string */ public function __toString(): string { return $this->baseName; } /** * @return string */ public function getBaseName(): string { return $this->baseName; } /** * @return null|string */ public function getAlias(): string { return $this->alias; } /** * @return bool */ public function isConfirmed(): bool { return $this->confirmed; } public function confirm() { $this->confirmed = true; } /** * @param string $name * @return mixed|null */ public function getVariable(string $name) { return $this->variables[$name] ?? null; } /** * @param string $name * @param mixed $value */ public function setVariable(string $name, $value) { $this->variables[$name] = $value; } /** * @param PharInvocation $other * @return bool */ public function equals(PharInvocation $other): bool { return $other->baseName === $this->baseName && $other->alias === $this->alias; } } PK U�\'~�(� � = phar-stream-wrapper/src/Resolver/PharInvocationCollection.phpnu �[��� <?php declare(strict_types=1); namespace TYPO3\PharStreamWrapper\Resolver; /* * This file is part of the TYPO3 project. * * It is free software; you can redistribute it and/or modify it under the terms * of the MIT License (MIT). For the full copyright and license information, * please read the LICENSE file that was distributed with this source code. * * The TYPO3 project - inspiring people to share! */ use TYPO3\PharStreamWrapper\Collectable; class PharInvocationCollection implements Collectable { const UNIQUE_INVOCATION = 1; const UNIQUE_BASE_NAME = 2; const DUPLICATE_ALIAS_WARNING = 32; /** * @var PharInvocation[] */ private $invocations = []; /** * @param PharInvocation $invocation * @return bool */ public function has(PharInvocation $invocation): bool { return in_array($invocation, $this->invocations, true); } /** * @param PharInvocation $invocation * @param null|int $flags * @return bool */ public function collect(PharInvocation $invocation, int $flags = null): bool { if ($flags === null) { $flags = static::UNIQUE_INVOCATION | static::DUPLICATE_ALIAS_WARNING; } if ($invocation->getBaseName() === '' || $invocation->getAlias() === '' || !$this->assertUniqueBaseName($invocation, $flags) || !$this->assertUniqueInvocation($invocation, $flags) ) { return false; } if ($flags & static::DUPLICATE_ALIAS_WARNING) { $this->triggerDuplicateAliasWarning($invocation); } $this->invocations[] = $invocation; return true; } /** * @param callable $callback * @param bool $reverse * @return null|PharInvocation */ public function findByCallback(callable $callback, $reverse = false) { foreach ($this->getInvocations($reverse) as $invocation) { if (call_user_func($callback, $invocation) === true) { return $invocation; } } return null; } /** * Asserts that base-name is unique. This disallows having multiple invocations for * same base-name but having different alias names. * * @param PharInvocation $invocation * @param int $flags * @return bool */ private function assertUniqueBaseName(PharInvocation $invocation, int $flags): bool { if (!($flags & static::UNIQUE_BASE_NAME)) { return true; } return $this->findByCallback( function (PharInvocation $candidate) use ($invocation) { return $candidate->getBaseName() === $invocation->getBaseName(); } ) === null; } /** * Asserts that combination of base-name and alias is unique. This allows having multiple * invocations for same base-name but having different alias names (for whatever reason). * * @param PharInvocation $invocation * @param int $flags * @return bool */ private function assertUniqueInvocation(PharInvocation $invocation, int $flags): bool { if (!($flags & static::UNIQUE_INVOCATION)) { return true; } return $this->findByCallback( function (PharInvocation $candidate) use ($invocation) { return $candidate->equals($invocation); } ) === null; } /** * Triggers warning for invocations with same alias and same confirmation state. * * @param PharInvocation $invocation * @see \TYPO3\PharStreamWrapper\PharStreamWrapper::collectInvocation() */ private function triggerDuplicateAliasWarning(PharInvocation $invocation) { $sameAliasInvocation = $this->findByCallback( function (PharInvocation $candidate) use ($invocation) { return $candidate->isConfirmed() === $invocation->isConfirmed() && $candidate->getAlias() === $invocation->getAlias(); }, true ); if ($sameAliasInvocation === null) { return; } trigger_error( sprintf( 'Alias %s cannot be used by %s, already used by %s', $invocation->getAlias(), $invocation->getBaseName(), $sameAliasInvocation->getBaseName() ), E_USER_WARNING ); } /** * @param bool $reverse * @return PharInvocation[] */ private function getInvocations(bool $reverse = false): array { if ($reverse) { return array_reverse($this->invocations); } return $this->invocations; } } PK U�\'q_5� � ; phar-stream-wrapper/src/Resolver/PharInvocationResolver.phpnu �[��� <?php declare(strict_types=1); namespace TYPO3\PharStreamWrapper\Resolver; /* * This file is part of the TYPO3 project. * * It is free software; you can redistribute it and/or modify it under the terms * of the MIT License (MIT). For the full copyright and license information, * please read the LICENSE file that was distributed with this source code. * * The TYPO3 project - inspiring people to share! */ use TYPO3\PharStreamWrapper\Helper; use TYPO3\PharStreamWrapper\Manager; use TYPO3\PharStreamWrapper\Phar\Reader; use TYPO3\PharStreamWrapper\Phar\ReaderException; use TYPO3\PharStreamWrapper\Resolvable; class PharInvocationResolver implements Resolvable { const RESOLVE_REALPATH = 1; const RESOLVE_ALIAS = 2; const ASSERT_INTERNAL_INVOCATION = 32; /** * @var string[] */ private $invocationFunctionNames = [ 'include', 'include_once', 'require', 'require_once' ]; /** * Contains resolved base names in order to reduce file IO. * * @var string[] */ private $baseNames = []; /** * Resolves PharInvocation value object (baseName and optional alias). * * Phar aliases are intended to be used only inside Phar archives, however * PharStreamWrapper needs this information exposed outside of Phar as well * It is possible that same alias is used for different $baseName values. * That's why PharInvocationCollection behaves like a stack when resolving * base-name for a given alias. On the other hand it is not possible that * one $baseName is referring to multiple aliases. * @see https://secure.php.net/manual/en/phar.setalias.php * @see https://secure.php.net/manual/en/phar.mapphar.php * * @param string $path * @param int|null $flags * @return null|PharInvocation */ public function resolve(string $path, int $flags = null) { $hasPharPrefix = Helper::hasPharPrefix($path); $flags = $flags ?? static::RESOLVE_REALPATH | static::RESOLVE_ALIAS; if ($hasPharPrefix && $flags & static::RESOLVE_ALIAS) { $invocation = $this->findByAlias($path); if ($invocation !== null) { return $invocation; } } $baseName = $this->resolveBaseName($path, $flags); if ($baseName === null) { return null; } if ($flags & static::RESOLVE_REALPATH) { $baseName = $this->baseNames[$baseName]; } return $this->retrieveInvocation($baseName, $flags); } /** * Retrieves PharInvocation, either existing in collection or created on demand * with resolving a potential alias name used in the according Phar archive. * * @param string $baseName * @param int $flags * @return PharInvocation */ private function retrieveInvocation(string $baseName, int $flags): PharInvocation { $invocation = $this->findByBaseName($baseName); if ($invocation !== null) { return $invocation; } if ($flags & static::RESOLVE_ALIAS) { $alias = (new Reader($baseName))->resolveContainer()->getAlias(); } else { $alias = ''; } // add unconfirmed(!) new invocation to collection $invocation = new PharInvocation($baseName, $alias); Manager::instance()->getCollection()->collect($invocation); return $invocation; } /** * @param string $path * @param int $flags * @return null|string */ private function resolveBaseName(string $path, int $flags) { $baseName = $this->findInBaseNames($path); if ($baseName !== null) { return $baseName; } $baseName = Helper::determineBaseFile($path); if ($baseName !== null) { $this->addBaseName($baseName); return $baseName; } $possibleAlias = $this->resolvePossibleAlias($path); if (!($flags & static::RESOLVE_ALIAS) || $possibleAlias === null) { return null; } $trace = debug_backtrace(); foreach ($trace as $item) { if (!isset($item['function']) || !isset($item['args'][0]) || !in_array($item['function'], $this->invocationFunctionNames, true)) { continue; } $currentPath = $item['args'][0]; if (Helper::hasPharPrefix($currentPath)) { continue; } $currentBaseName = Helper::determineBaseFile($currentPath); if ($currentBaseName === null) { continue; } // ensure the possible alias name (how we have been called initially) matches // the resolved alias name that was retrieved by the current possible base name try { $currentAlias = (new Reader($currentBaseName))->resolveContainer()->getAlias(); } catch (ReaderException $exception) { // most probably that was not a Phar file continue; } if (empty($currentAlias) || $currentAlias !== $possibleAlias) { continue; } $this->addBaseName($currentBaseName); return $currentBaseName; } return null; } /** * @param string $path * @return null|string */ private function resolvePossibleAlias(string $path) { $normalizedPath = Helper::normalizePath($path); return strstr($normalizedPath, '/', true) ?: null; } /** * @param string $baseName * @return null|PharInvocation */ private function findByBaseName(string $baseName) { return Manager::instance()->getCollection()->findByCallback( function (PharInvocation $candidate) use ($baseName) { return $candidate->getBaseName() === $baseName; }, true ); } /** * @param string $path * @return null|string */ private function findInBaseNames(string $path) { // return directly if the resolved base name was submitted if (in_array($path, $this->baseNames, true)) { return $path; } $parts = explode('/', Helper::normalizePath($path)); while (count($parts)) { $currentPath = implode('/', $parts); if (isset($this->baseNames[$currentPath])) { return $currentPath; } array_pop($parts); } return null; } /** * @param string $baseName */ private function addBaseName(string $baseName) { if (isset($this->baseNames[$baseName])) { return; } $this->baseNames[$baseName] = Helper::normalizeWindowsPath( realpath($baseName) ); } /** * Finds confirmed(!) invocations by alias. * * @param string $path * @return null|PharInvocation * @see \TYPO3\PharStreamWrapper\PharStreamWrapper::collectInvocation() */ private function findByAlias(string $path) { $possibleAlias = $this->resolvePossibleAlias($path); if ($possibleAlias === null) { return null; } return Manager::instance()->getCollection()->findByCallback( function (PharInvocation $candidate) use ($possibleAlias) { return $candidate->isConfirmed() && $candidate->getAlias() === $possibleAlias; }, true ); } } PK U�\bs��O O &