Файловый менеджер - Редактировать - /home/wuectly/www/03cbe/Dispatcher.php.tar
Назад
home/wuectly/www/libraries/fof30/Configuration/Domain/Dispatcher.php 0000604 00000003255 15245556207 0021536 0 ustar 00 <?php /** * @package FOF * @copyright Copyright (c)2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd * @license GNU General Public License version 2, or later */ namespace FOF30\Configuration\Domain; defined('_JEXEC') || die; use SimpleXMLElement; /** * Configuration parser for the dispatcher-specific settings * * @since 2.1 */ class Dispatcher implements DomainInterface { /** * Parse the XML data, adding them to the $ret array * * @param SimpleXMLElement $xml The XML data of the component's configuration area * @param array &$ret The parsed data, in the form of a hash array * * @return void */ public function parseDomain(SimpleXMLElement $xml, array &$ret) { // Initialise $ret['dispatcher'] = []; // Parse the dispatcher configuration $dispatcherData = $xml->dispatcher; // Sanity check if (empty($dispatcherData)) { return; } $options = $xml->xpath('dispatcher/option'); if (!empty($options)) { foreach ($options as $option) { $key = (string) $option['name']; $ret['dispatcher'][$key] = (string) $option; } } } /** * Return a configuration variable * * @param string &$configuration Configuration variables (hashed array) * @param string $var The variable we want to fetch * @param mixed $default Default value * * @return mixed The variable's value */ public function get(&$configuration, $var, $default) { if ($var == '*') { return $configuration['dispatcher']; } if (isset($configuration['dispatcher'][$var])) { return $configuration['dispatcher'][$var]; } else { return $default; } } } home/wuectly/www/libraries/fof30/Dispatcher/Dispatcher.php 0000604 00000023013 15245557174 0017604 0 ustar 00 <?php /** * @package FOF * @copyright Copyright (c)2010-2020 Nicholas K. Dionysopoulos / Akeeba Ltd * @license GNU General Public License version 2, or later */ namespace FOF30\Dispatcher; defined('_JEXEC') || die; use Exception; use FOF30\Container\Container; use FOF30\Controller\Controller; use FOF30\Dispatcher\Exception\AccessForbidden; use FOF30\TransparentAuthentication\TransparentAuthentication; /** * A generic MVC dispatcher * * @property-read \FOF30\Input\Input $input The input object (magic __get returns the Input from the Container) */ class Dispatcher { /** @var string The name of the default view, in case none is specified */ public $defaultView = null; /** @var array Local cache of the dispatcher configuration */ protected $config = []; /** @var Container The container we belong to */ protected $container = null; /** @var string The view which will be rendered by the dispatcher */ protected $view = null; /** @var string The layout for rendering the view */ protected $layout = null; /** @var Controller The controller which will be used */ protected $controller = null; /** @var bool Is this user transparently logged in? */ protected $isTransparentlyLoggedIn = false; /** * Public constructor * * The $config array can contain the following optional values: * defaultView string The view to render if none is specified in $input * * Do note that $config is passed to the Controller and through it to the Model and View. Please see these classes * for more information on the configuration variables they accept. * * @param \FOF30\Container\Container $container * @param array $config */ public function __construct(Container $container, array $config = []) { $this->container = $container; $this->config = $config; $this->defaultView = $container->appConfig->get('dispatcher.defaultView', $this->defaultView); if (isset($config['defaultView'])) { $this->defaultView = $config['defaultView']; } $this->supportCustomViewAndTaskParameters(); // Get the default values for the view and layout names $this->view = $this->input->getCmd('view', null); $this->layout = $this->input->getCmd('layout', null); // Not redundant; you may pass an empty but non-null view which is invalid, so we need the fallback if (empty($this->view)) { $this->view = $this->defaultView; $this->container->input->set('view', $this->view); } } /** * Magic get method. Handles magic properties: * $this->input mapped to $this->container->input * * @param string $name The property to fetch * * @return mixed|null */ public function __get($name) { // Handle $this->input if ($name == 'input') { return $this->container->input; } // Property not found; raise error $trace = debug_backtrace(); trigger_error( 'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); return null; } /** * The main code of the Dispatcher. It spawns the necessary controller and * runs it. * * @return void * * @throws AccessForbidden When the access is forbidden */ public function dispatch() { // Load the translations for this component; $this->container->platform->loadTranslations($this->container->componentName); // Perform transparent authentication if ($this->container->platform->getUser()->guest) { $this->transparentAuthenticationLogin(); } // Get the event names (different for CLI) $onBeforeEventName = 'onBeforeDispatch'; $onAfterEventName = 'onAfterDispatch'; if ($this->container->platform->isCli()) { $onBeforeEventName = 'onBeforeDispatchCLI'; $onAfterEventName = 'onAfterDispatchCLI'; } try { $result = $this->triggerEvent($onBeforeEventName); $error = ''; } catch (\Exception $e) { $result = false; $error = $e->getMessage(); } if ($result === false) { if ($this->container->platform->isCli()) { $this->container->platform->setHeader('Status', '403 Forbidden', true); } $this->transparentAuthenticationLogout(); $this->container->platform->showErrorPage(new AccessForbidden); } // Get and execute the controller $view = $this->input->getCmd('view', $this->defaultView); $task = $this->input->getCmd('task', 'default'); if (empty($task)) { $task = 'default'; $this->input->set('task', $task); } try { $this->controller = $this->container->factory->controller($view, $this->config); $status = $this->controller->execute($task); } catch (Exception $e) { $this->container->platform->showErrorPage($e); // Redundant; just to make code sniffers happy return; } if ($status !== false) { try { $this->triggerEvent($onAfterEventName); } catch (\Exception $e) { $status = false; } } if (($status === false)) { if ($this->container->platform->isCli()) { $this->container->platform->setHeader('Status', '403 Forbidden', true); } $this->transparentAuthenticationLogout(); $this->container->platform->showErrorPage(new AccessForbidden); } $this->transparentAuthenticationLogout(); $this->controller->redirect(); } /** * Returns a reference to the Controller object currently in use by the dispatcher * * @return Controller */ public function &getController() { return $this->controller; } /** * Triggers an object-specific event. The event runs both locally –if a suitable method exists– and through the * Joomla! plugin system. A true/false return value is expected. The first false return cancels the event. * * EXAMPLE * Component: com_foobar, Object name: item, Event: onBeforeDispatch, Arguments: array(123, 456) * The event calls: * 1. $this->onBeforeDispatch(123, 456) * 2. Joomla! plugin event onComFoobarDispatcherBeforeDispatch($this, 123, 456) * * @param string $event The name of the event, typically named onPredicateVerb e.g. onBeforeKick * @param array $arguments The arguments to pass to the event handlers * * @return bool */ protected function triggerEvent($event, array $arguments = []) { $result = true; // If there is an object method for this event, call it if (method_exists($this, $event)) { switch (count($arguments)) { case 0: $result = $this->{$event}(); break; case 1: $result = $this->{$event}($arguments[0]); break; case 2: $result = $this->{$event}($arguments[0], $arguments[1]); break; case 3: $result = $this->{$event}($arguments[0], $arguments[1], $arguments[2]); break; case 4: $result = $this->{$event}($arguments[0], $arguments[1], $arguments[2], $arguments[3]); break; case 5: $result = $this->{$event}($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4]); break; default: $result = call_user_func_array([$this, $event], $arguments); break; } } if ($result === false) { return false; } // All other event handlers live outside this object, therefore they need to be passed a reference to this // objects as the first argument. array_unshift($arguments, $this); // If we have an "on" prefix for the event (e.g. onFooBar) remove it and stash it for later. $prefix = ''; if (substr($event, 0, 2) == 'on') { $prefix = 'on'; $event = substr($event, 2); } // Get the component/model prefix for the event $prefix .= 'Com' . ucfirst($this->container->bareComponentName) . 'Dispatcher'; // The event name will be something like onComFoobarItemsBeforeSomething $event = $prefix . $event; // Call the Joomla! plugins $results = $this->container->platform->runPlugins($event, $arguments); if (!empty($results)) { foreach ($results as $result) { if ($result === false) { return false; } } } return true; } /** * Handles the transparent authentication log in */ protected function transparentAuthenticationLogin() { /** @var TransparentAuthentication $transparentAuth */ $transparentAuth = $this->container->transparentAuth; $authInfo = $transparentAuth->getTransparentAuthenticationCredentials(); if (empty($authInfo)) { return; } $this->isTransparentlyLoggedIn = $this->container->platform->loginUser($authInfo); } /** * Handles the transparent authentication log out */ protected function transparentAuthenticationLogout() { if (!$this->isTransparentlyLoggedIn) { return; } /** @var TransparentAuthentication $transparentAuth */ $transparentAuth = $this->container->transparentAuth; if (!$transparentAuth->getLogoutOnExit()) { return; } $this->container->platform->logoutUser(); } /** * Adds support for akview/aktask in lieu of view and task. * * This is for future-proofing FOF in case Joomla assigns special meaning to view and task, e.g. by trying to find a * specific controller / task class instead of letting the component's front-end router handle it. If that happens * FOF components can have a single Joomla-compatible view/task which launches the Dispatcher and perform internal * routing using akview/aktask. * * @return void * @since 3.6.3 */ private function supportCustomViewAndTaskParameters() { $view = $this->input->getCmd('akview', null); $task = $this->input->getCmd('aktask', null); if (!is_null($view)) { $this->input->remove('akview'); $this->input->set('view', $view); } if (!is_null($task)) { $this->input->remove('aktask'); $this->input->set('task', $task); } } } home/wuectly/www/libraries/fof40/Dispatcher/Dispatcher.php 0000604 00000021473 15245557224 0017611 0 ustar 00 <?php /** * @package FOF * @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd * @license GNU General Public License version 3, or later */ namespace FOF40\Dispatcher; defined('_JEXEC') || die; use Exception; use FOF40\Container\Container; use FOF40\Controller\Controller; use FOF40\Dispatcher\Exception\AccessForbidden; use FOF40\TransparentAuthentication\TransparentAuthentication; /** * A generic MVC dispatcher * * @property-read \FOF40\Input\Input $input The input object (magic __get returns the Input from the Container) */ class Dispatcher { /** @var string The name of the default view, in case none is specified */ public $defaultView; /** @var array Local cache of the dispatcher configuration */ protected $config = []; /** @var Container The container we belong to */ protected $container; /** @var string The view which will be rendered by the dispatcher */ protected $view; /** @var string The layout for rendering the view */ protected $layout; /** @var Controller The controller which will be used */ protected $controller; /** @var bool Is this user transparently logged in? */ protected $isTransparentlyLoggedIn = false; /** * Public constructor * * The $config array can contain the following optional values: * defaultView string The view to render if none is specified in $input * * Do note that $config is passed to the Controller and through it to the Model and View. Please see these classes * for more information on the configuration variables they accept. * * @param Container $container * @param array $config */ public function __construct(Container $container, array $config = []) { $this->container = $container; $this->config = $config; $this->defaultView = $container->appConfig->get('dispatcher.defaultView', $this->defaultView); if (isset($config['defaultView'])) { $this->defaultView = $config['defaultView']; } $this->supportCustomViewAndTaskParameters(); // Get the default values for the view and layout names $this->view = $this->input->getCmd('view', null); $this->layout = $this->input->getCmd('layout', null); // Not redundant; you may pass an empty but non-null view which is invalid, so we need the fallback if (empty($this->view)) { $this->view = $this->defaultView; $this->container->input->set('view', $this->view); } } /** * Magic get method. Handles magic properties: * $this->input mapped to $this->container->input * * @param string $name The property to fetch * * @return mixed|null */ public function __get(string $name) { // Handle $this->input if ($name == 'input') { return $this->container->input; } // Property not found; raise error $trace = debug_backtrace(); trigger_error( 'Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); return null; } /** * The main code of the Dispatcher. It spawns the necessary controller and * runs it. * * @return void * * @throws AccessForbidden When the access is forbidden * @throws Exception For displaying an error page */ public function dispatch(): void { // Load the translations for this component; $this->container->platform->loadTranslations($this->container->componentName); // Perform transparent authentication if ($this->container->platform->getUser()->guest) { $this->transparentAuthenticationLogin(); } // Get the event names (different for CLI) $onBeforeEventName = 'onBeforeDispatch'; $onAfterEventName = 'onAfterDispatch'; if ($this->container->platform->isCli()) { $onBeforeEventName = 'onBeforeDispatchCLI'; $onAfterEventName = 'onAfterDispatchCLI'; } try { $result = $this->triggerEvent($onBeforeEventName); $error = ''; } catch (\Exception $e) { $result = false; $error = $e->getMessage(); } if ($result === false) { if ($this->container->platform->isCli()) { $this->container->platform->setHeader('Status', '403 Forbidden', true); } $this->transparentAuthenticationLogout(); $this->container->platform->showErrorPage(new AccessForbidden); } // Get and execute the controller $view = $this->input->getCmd('view', $this->defaultView); $task = $this->input->getCmd('task', 'default'); if (empty($task)) { $task = 'default'; $this->input->set('task', $task); } try { $this->controller = $this->container->factory->controller($view, $this->config); $status = $this->controller->execute($task); } catch (Exception $e) { $this->container->platform->showErrorPage($e); // Redundant; just to make code sniffers happy return; } if ($status !== false) { try { $this->triggerEvent($onAfterEventName); } catch (\Exception $e) { $status = false; } } if ($status === false) { if ($this->container->platform->isCli()) { $this->container->platform->setHeader('Status', '403 Forbidden', true); } $this->transparentAuthenticationLogout(); $this->container->platform->showErrorPage(new AccessForbidden); } $this->transparentAuthenticationLogout(); $this->controller->redirect(); } /** * Returns a reference to the Controller object currently in use by the dispatcher * * @return Controller|null */ public function &getController(): ?Controller { return $this->controller; } /** * Triggers an object-specific event. The event runs both locally –if a suitable method exists– and through the * Joomla! plugin system. A true/false return value is expected. The first false return cancels the event. * * EXAMPLE * Component: com_foobar, Object name: item, Event: onBeforeDispatch, Arguments: array(123, 456) * The event calls: * 1. $this->onBeforeDispatch(123, 456) * 2. Joomla! plugin event onComFoobarDispatcherBeforeDispatch($this, 123, 456) * * @param string $event The name of the event, typically named onPredicateVerb e.g. onBeforeKick * @param array $arguments The arguments to pass to the event handlers * * @return bool */ protected function triggerEvent(string $event, array $arguments = []): bool { $result = true; // If there is an object method for this event, call it if (method_exists($this, $event)) { $result = $this->{$event}(...$arguments); } if ($result === false) { return false; } // All other event handlers live outside this object, therefore they need to be passed a reference to this // objects as the first argument. array_unshift($arguments, $this); // If we have an "on" prefix for the event (e.g. onFooBar) remove it and stash it for later. $prefix = ''; if (substr($event, 0, 2) == 'on') { $prefix = 'on'; $event = substr($event, 2); } // Get the component/model prefix for the event $prefix .= 'Com' . ucfirst($this->container->bareComponentName) . 'Dispatcher'; // The event name will be something like onComFoobarItemsBeforeSomething $event = $prefix . $event; // Call the Joomla! plugins $results = $this->container->platform->runPlugins($event, $arguments); return !in_array(false, $results, true); } /** * Handles the transparent authentication log in */ protected function transparentAuthenticationLogin(): void { /** @var TransparentAuthentication $transparentAuth */ $transparentAuth = $this->container->transparentAuth; $authInfo = $transparentAuth->getTransparentAuthenticationCredentials(); if (empty($authInfo)) { return; } $this->isTransparentlyLoggedIn = $this->container->platform->loginUser($authInfo); } /** * Handles the transparent authentication log out */ protected function transparentAuthenticationLogout(): void { if (!$this->isTransparentlyLoggedIn) { return; } /** @var TransparentAuthentication $transparentAuth */ $transparentAuth = $this->container->transparentAuth; if (!$transparentAuth->getLogoutOnExit()) { return; } $this->container->platform->logoutUser(); } /** * Adds support for akview/aktask in lieu of view and task. * * This is for future-proofing FOF in case Joomla assigns special meaning to view and task, e.g. by trying to find a * specific controller / task class instead of letting the component's front-end router handle it. If that happens * FOF components can have a single Joomla-compatible view/task which launches the Dispatcher and perform internal * routing using akview/aktask. * * @return void * @since 3.6.3 */ private function supportCustomViewAndTaskParameters() { $view = $this->input->getCmd('akview', null); $task = $this->input->getCmd('aktask', null); if (!is_null($view)) { $this->input->remove('akview'); $this->input->set('view', $view); } if (!is_null($task)) { $this->input->remove('aktask'); $this->input->set('task', $task); } } } home/wuectly/www/components/com_akeeba/Dispatcher/Dispatcher.php 0000604 00000011066 15245572226 0021146 0 ustar 00 <?php /** * @package akeebabackup * @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd * @license GNU General Public License version 3, or later */ namespace Akeeba\Backup\Site\Dispatcher; // Protect from unauthorized access defined('_JEXEC') || die(); use Akeeba\Backup\Admin\Dispatcher\Dispatcher as AdminDispatcher; use Akeeba\Backup\Admin\Helper\SecretWord; use Akeeba\Engine\Factory; use Akeeba\Engine\Platform; use FOF40\Container\Container; use FOF40\Dispatcher\Exception\AccessForbidden; use Joomla\CMS\Document\Document; use Joomla\CMS\Document\JsonDocument as JDocumentJSON; use Joomla\CMS\Factory as JFactory; use Joomla\CMS\Language\Text; class Dispatcher extends AdminDispatcher { /** @var string The name of the default view, in case none is specified */ public $defaultView = 'Backup'; /** * Dispatcher constructor. Overridden to set up a different default view and migrated views map than the back-end. * * @param Container $container The component's container * @param array $config Optional configuration overrides */ public function __construct(Container $container, array $config) { parent::__construct($container, $config); $this->defaultView = 'Backup'; $this->viewNameAliases = [ 'backup' => 'Backup', 'backups' => 'Backup', 'check' => 'Check', 'checks' => 'Check', 'json' => 'Json', 'jsons' => 'Json', ]; } /** * Executes before dispatching the request to the appropriate controller */ public function onBeforeDispatch() { // Make sure we have a version loaded @include_once($this->container->backEndPath . '/version.php'); if (!defined('AKEEBA_VERSION')) { define('AKEEBA_VERSION', 'dev'); define('AKEEBA_DATE', date('Y-m-d')); } // Core version: there is no front-end, throw a 403 if (!defined('AKEEBA_PRO') || !AKEEBA_PRO) { throw new AccessForbidden(Text::_('COM_AKEEBA_ERR_NO_FRONTEND_IN_CORE')); } // $this->container->platform->importPlugin('akeebabackup'); // $this->container->platform->runPlugins('onComAkeebaDispatcherBeforeDispatch', []); $this->onBeforeDispatchViewAliases(); // Load the FOF language $lang = $this->container->platform->getLanguage(); $lang->load('lib_fof40', JPATH_SITE, 'en-GB', true, true); $lang->load('lib_fof40', JPATH_SITE, null, true, false); // Necessary defines for Akeeba Engine if (!defined('AKEEBAENGINE')) { define('AKEEBAENGINE', 1); define('AKEEBAROOT', $this->container->backEndPath . '/BackupEngine'); define('ALICEROOT', $this->container->backEndPath . '/AliceEngine'); } // Make sure we have a profile set throughout the component's lifetime $profile_id = $this->container->platform->getSessionVar('profile', null, 'akeeba'); if (is_null($profile_id)) { $this->container->platform->setSessionVar('profile', 1, 'akeeba'); } // Load Akeeba Engine $basePath = $this->container->backEndPath; require_once $basePath . '/BackupEngine/Factory.php'; // Load the Akeeba Engine configuration Platform::addPlatform('joomla3x', JPATH_COMPONENT_ADMINISTRATOR . '/BackupPlatform/Joomla3x'); $akeebaEngineConfig = Factory::getConfiguration(); Platform::getInstance()->load_configuration(); unset($akeebaEngineConfig); // Prevents the "SQLSTATE[HY000]: General error: 2014" due to resource sharing with Akeeba Engine $this->fixPDOMySQLResourceSharing(); // Load the utils helper library Platform::getInstance()->load_version_defines(); // Make sure the front-end backup Secret Word is stored encrypted $params = $this->container->params; SecretWord::enforceEncryption($params, 'frontend_secret_word'); // Create a media file versioning tag $this->container->mediaVersion = md5(AKEEBA_VERSION . AKEEBA_DATE); } public function onAfterDispatch() { // Make sure that Api and Json views forcibly get format=json if (in_array($this->view, ['Api', 'Json'])) { $format = $this->input->getCmd('format', 'html'); if ($format == 'json') { return; } $app = JFactory::getApplication(); // Disable caching, disable offline, force use of index.php $app->set('caching', 0); $app->set('offline', 0); $app->set('themeFile', 'index.php'); /** @var \Joomla\CMS\Document\JsonDocument $doc */ $doc = Document::getInstance('json'); $app->loadDocument($doc); if (property_exists(JFactory::class, 'document')) { JFactory::$document = $doc; } // Set a custom document name /** @var JDocumentJSON $document */ $document = $this->container->platform->getDocument(); $document->setName('akeeba_backup'); } } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка