if ($this->_hadToken !== null) { return; } $this->_token = ($this->getQueryParam($this->generalConfig->tokenParam) ?? $this->getHeaders()->get('X-Craft-Token')) ?: null; if ($this->_token && !preg_match('/^[A-Za-z0-9_-]+$/', $this->_token)) { $this->_token = null; $this->_hadToken = false; throw new BadRequestHttpException('Invalid token'); } $this->_hadToken = $this->_token !== null; } /** * Returns the site token submitted with the request, if there is one. * * Tokens must be sent either as a query string param named after the <config3:siteToken> config setting
* @throws BadRequestHttpException if an invalid token is supplied * @see \craft\services\Tokens::createToken() * @see Controller::requireToken() */ public function getToken(): ?string { $this->_findToken(); return $this->_token; } /** * Sets the token value. *
$generalConfig = Craft::$app->getConfig()->getGeneral(); $request = Craft::$app->getRequest(); // If this is a site URL and there was a (site) token on the request, pass it along if (!$cpUrl) { if ($addToken && !isset($params[$generalConfig->tokenParam]) && ($token = $request->getToken()) !== null) { $params[$generalConfig->tokenParam] = $token; } if (!isset($params[$generalConfig->siteToken]) && ($siteToken = $request->getSiteToken()) !== null) { $params[$generalConfig->siteToken] = $siteToken; } }
// Swap the current site $currentSite = $sites->getCurrentSite(); $sites->setCurrentSite($site); } $path = trim($path, '/'); $url = self::_createUrl($path, $params, $scheme, false); /** @noinspection UnSafeIsSetOverArrayInspection - FP */ if (isset($currentSite)) { // Restore the original current site $sites->setCurrentSite($currentSite); }
{ $configService = Craft::$app->getConfig(); $generalConfig = $configService->getGeneral(); $request = Craft::$app->getRequest(); if ($request->getIsConsoleRequest() || $request->getIsSiteRequest()) { $loginUrl = UrlHelper::siteUrl($generalConfig->getLoginPath()); } else { $loginUrl = UrlHelper::cpUrl(Request::CP_PATH_LOGIN); } $stateKeyPrefix = md5('Craft.' . WebUser::class . '.' . Craft::$app->id);
}, 'session' => function() { $config = craft\helpers\App::sessionConfig(); return Craft::createObject($config); }, 'user' => function() { $config = craft\helpers\App::userConfig(); return Craft::createObject($config); }, 'errorHandler' => [ 'class' => craft\web\ErrorHandler::class, 'errorAction' => 'templates/render-error', ],
* @throws InvalidConfigException if a dependency cannot be resolved or if a dependency cannot be fulfilled. * @throws NotInstantiableException If resolved to an abstract class or an interface (since 2.0.9) * @since 2.0.7 */ public function invoke(callable $callback, $params = []) { return call_user_func_array($callback, $this->resolveCallableDependencies($callback, $params)); } /** * Resolve dependencies for a function. * * This method can be used to implement similar functionality as provided by [[invoke()]] in other
{ if (is_string($type)) { return static::$container->get($type, $params); } if (is_callable($type, true)) { return static::$container->invoke($type, $params); } if (!is_array($type)) { throw new InvalidConfigException('Unsupported configuration type: ' . gettype($type)); }
if (isset($this->_definitions[$id])) { $definition = $this->_definitions[$id]; if (is_object($definition) && !$definition instanceof Closure) { return $this->_components[$id] = $definition; } return $this->_components[$id] = Yii::createObject($definition); } elseif ($throwException) { throw new InvalidConfigException("Unknown component ID: $id"); } return null; }
* Since version 2.0.13, if a component isn't defined in the module, it will be looked up in the parent module. * The parent module may be the application. */ public function get($id, $throwException = true) { if (!isset($this->module)) { return parent::get($id, $throwException); } $component = parent::get($id, false); if ($component === null) { $component = $this->module->get($id, $throwException); }
*/ public function get($id, $throwException = true) { // Is this the first time the queue component is requested? $isFirstQueue = $id === 'queue' && !$this->has($id, true); $component = parent::get($id, $throwException); if ($isFirstQueue && $component instanceof Component) { $component->attachBehavior('queueLogger', QueueLogBehavior::class); } return $component;
/** * Returns the user component. * @return User the user component. */ public function getUser() { return $this->get('user'); } /** * {@inheritdoc} */ public function coreComponents()
// targets haven’t been instantiated yet. $targets = []; $isConsoleRequest = Craft::$app->getRequest()->getIsConsoleRequest(); if ($isConsoleRequest || Craft::$app->getUser()->enableSession) { $generalConfig = Craft::$app->getConfig()->getGeneral(); $fileTargetConfig = [ 'class' => FileTarget::class, 'fileMode' => $generalConfig->defaultFileMode, 'dirMode' => $generalConfig->defaultDirMode,
/** * @inheritdoc */ public function init() { parent::init(); $this->targets = array_merge($this->targets, App::defaultLogTargets()); } }
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
$this->setLogger($config['logger']); unset($config['logger']); } // connect logger and dispatcher $this->getLogger(); parent::__construct($config); } /** * {@inheritdoc} */ public function init()
$dependencies = $this->resolveDependencies($dependencies, $reflection); if (!$reflection->isInstantiable()) { throw new NotInstantiableException($reflection->name); } if (empty($config)) { return $reflection->newInstanceArgs($dependencies); } $config = $this->resolveDependencies($config); if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten)
$class = $class->id; } if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
return static::$container->get($class, $params, $type); } if (isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } throw new InvalidConfigException('Object configuration must be an array containing a "class" or "__class" element.'); } private static $_logger;
if (isset($this->_definitions[$id])) { $definition = $this->_definitions[$id]; if (is_object($definition) && !$definition instanceof Closure) { return $this->_components[$id] = $definition; } return $this->_components[$id] = Yii::createObject($definition); } elseif ($throwException) { throw new InvalidConfigException("Unknown component ID: $id"); } return null; }
* Since version 2.0.13, if a component isn't defined in the module, it will be looked up in the parent module. * The parent module may be the application. */ public function get($id, $throwException = true) { if (!isset($this->module)) { return parent::get($id, $throwException); } $component = parent::get($id, false); if ($component === null) { $component = $this->module->get($id, $throwException); }
*/ public function get($id, $throwException = true) { // Is this the first time the queue component is requested? $isFirstQueue = $id === 'queue' && !$this->has($id, true); $component = parent::get($id, $throwException); if ($isFirstQueue && $component instanceof Component) { $component->attachBehavior('queueLogger', QueueLogBehavior::class); } return $component;
/** * Returns the log dispatcher component. * @return \yii\log\Dispatcher the log dispatcher application component. */ public function getLog() { return $this->get('log'); } /** * Returns the error handler component. * @return \yii\web\ErrorHandler|\yii\console\ErrorHandler the error handler application component. */
ColumnSchemaBuilder::$typeCategoryMap[Schema::TYPE_LONGTEXT] = ColumnSchemaBuilder::CATEGORY_STRING; ColumnSchemaBuilder::$typeCategoryMap[Schema::TYPE_ENUM] = ColumnSchemaBuilder::CATEGORY_STRING; // Load the request before anything else, so everything else can safely check Craft::$app->has('request', true) // to avoid possible recursive fatal errors in the request initialization $request = $this->getRequest(); $this->getLog(); // Set the timezone $this->_setTimeZone(); // Set the language $this->updateTargetLanguage();
/** * Initializes the application. */ public function init() { $this->state = self::STATE_INIT; $this->_preInit(); parent::init(); if (!App::isEphemeral()) { $this->ensureResourcePathExists(); }
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
$this->state = self::STATE_BEGIN; $this->preInit($config); $this->registerErrorHandler($config); Component::__construct($config); } /** * Pre-initializes the application. * This method is called at the beginning of the application constructor. * It initializes several important application properties.
$config = $this->resolveDependencies($config); if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten) $dependencies[count($dependencies) - 1] = $config; return $reflection->newInstanceArgs($dependencies); } $object = $reflection->newInstanceArgs($dependencies); foreach ($config as $name => $value) { $object->$name = $value; }
$class = $class->id; } if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
return static::$container->get($class, $params, $type); } if (isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } throw new InvalidConfigException('Object configuration must be an array containing a "class" or "__class" element.'); } private static $_logger;
* @param class-string<T>|array{class: class-string<T>}|callable(): T $type * @param array $params * @return T */ public static function createObject($type, array $params = []) { return parent::createObject($type, $params); } /** * Checks if a string references an environment variable (`$VARIABLE_NAME`) * and/or an alias (`@aliasName`), and returns the referenced value. *
$configService->getConfigFromFile('app'), $configService->getConfigFromFile("app.{$appType}") ); // Initialize the application /** @var \craft\web\Application|craft\console\Application $app */ $app = Craft::createObject($config); // If there was a max_input_vars error, kill the request before we start processing it with incomplete data if ($lastError && strpos($lastError['message'], 'max_input_vars') !== false) { throw new ErrorException($lastError['message']); }
// Load Craft // ----------------------------------------------------------------------------- $appType = 'web'; return require __DIR__ . '/bootstrap.php';
if (class_exists('Dotenv\Dotenv') && file_exists(CRAFT_BASE_PATH.'/.env')) { (new Dotenv\Dotenv(CRAFT_BASE_PATH))->load(); } // Load and run Craft define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production'); $app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php'; $app->run();
$_GET = [ 'p' => 'fr/Espagne/barcelone/tour-prive/gaudi-unexpected-colonia-guell-casa-vicens-billets-sauter-la-ligne/58767', 'token' => 'ehw_yjcx_c4ndfgvonzkzvzbf94raovh?token=ehw_yjcx_c4ndfgvonzkzvzbf94raovh', ];