| Current Path : /home/wuectly/www/03cbe/ |
| Current File : /home/wuectly/www/03cbe/Dispatcher.tar |
Exception/AccessForbidden.php 0000604 00000001326 15245530470 0012234 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\Exception;
defined('_JEXEC') || die;
use Exception;
use Joomla\CMS\Language\Text;
use RuntimeException;
/**
* Exception thrown when the access to the requested resource is forbidden under the current execution context
*/
class AccessForbidden extends RuntimeException
{
public function __construct(string $message = "", int $code = 403, Exception $previous = null)
{
if (empty($message))
{
$message = Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN');
}
parent::__construct($message, $code, $previous);
}
}
Dispatcher.php 0000604 00000011066 15245530470 0007350 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');
}
}
}
Mixin/ViewAliases.php 0000604 00000005230 15245530470 0010556 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\Mixin;
defined('_JEXEC') || die;
// Protect from unauthorized access
use FOF40\Dispatcher\Dispatcher;
use Joomla\CMS\Uri\Uri;
/**
* Lets you create view aliases. When you access a view alias the real view is loaded instead. You can optionally have
* an HTTPS 301 redirection for GET requests to URLs that use the view name alias.
*
* IMPORTANT: This is a mixin (or, as we call it in PHP, a trait). Traits require PHP 5.4 or later. If you opt to use
* this trait your component will no longer work under PHP 5.3.
*
* Usage:
*
* • Override $viewNameAliases with your view names map.
* • If you want to issue HTTP 301 for GET requests set $permanentAliasRedirectionOnGET to true.
* • If you have an onBeforeDispatch method remember to alias and call this traits' onBeforeDispatch method at the top.
*
* Regarding the last point, if you've never used traits before, the code looks like this. Top of the class:
* use ViewAliases {
* onBeforeDispatch as onBeforeDispatchViewAliases;
* }
* and inside your custom onBeforeDispatch method, the first statement should be:
* $this->onBeforeDispatchViewAliases();
* Simple!
*/
trait ViewAliases
{
/**
* Maps view name aliases to actual views. The format is 'alias' => 'RealView'.
*
* @var array
*/
protected $viewNameAliases = [];
/**
* If set to true, any GET request to the alias view will result in an HTTP 301 permanent redirection to the real
* view name.
*
* This does NOT apply to POST, PUT, DELETE etc URLs. When you submit form data you cannot have a redirection. The
* browser will _typically_ not resend the submitted data.
*
* @var bool
*/
protected $permanentAliasRedirectionOnGET = false;
/**
* Transparently replaces old view names with their counterparts.
*
* If you are overriding this method in your component remember to alias it and call it from your overridden method.
*/
protected function onBeforeDispatch(): void
{
if (!array_key_exists($this->view, $this->viewNameAliases))
{
return;
}
$this->view = $this->viewNameAliases[$this->view];
$this->container->input->set('view', $this->view);
// Perform HTTP 301 Moved permanently redirection on GET requests if requested to do so
if ($this->permanentAliasRedirectionOnGET && isset($_SERVER['REQUEST_METHOD'])
&& (strtoupper($_SERVER['REQUEST_METHOD']) == 'GET')
)
{
$url = Uri::getInstance();
$url->setVar('view', $this->view);
$this->container->platform->redirect($url, 301);
}
}
}
.htaccess 0000604 00000000246 15245603155 0006346 0 ustar 00 <IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
<IfModule mod_authz_core.c>
<RequireAll>
Require all denied
</RequireAll>
</IfModule>
web.config 0000604 00000001025 15245603155 0006510 0 ustar 00 <?xml version="1.0"?>
<!--
This only works on IIS 7 or later. See https://www.iis.net/configreference/system.webserver/security/requestfiltering/fileextensions
-->
<configuration>
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="false" >
<clear />
<add fileExtension=".html" allowed="true"/>
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
</configuration>