$settings = GeoCookie::$plugin->getSettings(); // Request ip address $ipAddress = $this->getIpAddress($settings); // Request cookie $cookie = $this->getCookie($settings); if ($cookie) { // Cookie already exists, so set the location as the cookie value and set 'cached' to true to show that the cookie already existed $location = $cookie->value; $location->cached = true; return $location; } else { // Cookie doesn't exist, so fetch the user's location using api source and store it as a cookie, set 'cached' to false to show that the cookie didn't exist $apiSource = $settings->apiSource; $location = $this->getLocation($settings, $ipAddress); // $location->cached = false; // Log this
{ // Because: https://bugs.php.net/bug.php?id=74980 if (PHP_VERSION_ID >= 70100 && strpos($message, 'Narrowing occurred during type inference. Please file a bug report') !== false) { return null; } return parent::handleError($code, $message, $file, $line); } /** * @inheritdoc */ public function getExceptionName($exception)
// Request cookie $cookie = $this->getCookie($settings); if ($cookie) { // Cookie already exists, so set the location as the cookie value and set 'cached' to true to show that the cookie already existed $location = $cookie->value; $location->cached = true; return $location; } else { // Cookie doesn't exist, so fetch the user's location using api source and store it as a cookie, set 'cached' to false to show that the cookie didn't exist $apiSource = $settings->apiSource; $location = $this->getLocation($settings, $ipAddress);
new \Twig_SimpleFunction('geocookie', [$this, 'geocookie']), ]; } public function geocookie() { return GeoCookie::$plugin->geoService->location(); } }
$this->displayBlock('bodyClass', $context, $blocks); echo "> "; // line 48 $context["location"] = $this->extensions['lukeyouell\geocookie\twigextensions\GeoCookieTwigExtension']->geocookie(); // line 49 echo " "; // line 51 $this->loadTemplate("/_includes/_headerNav", "_layout", 51)->display($context);
return ob_get_clean(); } protected function displayWithErrorHandling(array $context, array $blocks = []) { try { $this->doDisplay($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($this->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
* @throws Error * @throws RuntimeError */ protected function displayWithErrorHandling(array $context, array $blocks = []) { try { parent::displayWithErrorHandling($context, $blocks); } catch (RuntimeError $e) { if (Craft::$app->getConfig()->getGeneral()->suppressTemplateErrors) { // Just log it and move on Craft::$app->getErrorHandler()->logException($e); } else { throw $e;
{ return $this->blocks; } public function display(array $context, array $blocks = []) { $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks)); } public function render(array $context) { $level = ob_get_level(); ob_start();
* @inheritdoc */ public function display(array $context, array $blocks = []) { $name = $this->getTemplateName(); Craft::beginProfile($name, __METHOD__); parent::display($context, $blocks); Craft::endProfile($name, __METHOD__); } // Protected Methods // =========================================================================
return "_layout"; } protected function doDisplay(array $context, array $blocks = []) { $this->parent = $this->loadTemplate("_layout", "survivalCourses/_types/coursesHomepage", 1); $this->parent->display($context, array_merge($this->blocks, $blocks)); } // line 3 public function block_bodyClass($context, array $blocks = []) { echo "id=\"courses\"";
return ob_get_clean(); } protected function displayWithErrorHandling(array $context, array $blocks = []) { try { $this->doDisplay($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($this->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
* @throws Error * @throws RuntimeError */ protected function displayWithErrorHandling(array $context, array $blocks = []) { try { parent::displayWithErrorHandling($context, $blocks); } catch (RuntimeError $e) { if (Craft::$app->getConfig()->getGeneral()->suppressTemplateErrors) { // Just log it and move on Craft::$app->getErrorHandler()->logException($e); } else { throw $e;
{ return $this->blocks; } public function display(array $context, array $blocks = []) { $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks)); } public function render(array $context) { $level = ob_get_level(); ob_start();
* @inheritdoc */ public function display(array $context, array $blocks = []) { $name = $this->getTemplateName(); Craft::beginProfile($name, __METHOD__); parent::display($context, $blocks); Craft::endProfile($name, __METHOD__); } // Protected Methods // =========================================================================
// line 2 echo "\t"; $context["entry"] = craft\helpers\Template::attribute($this->env, $this->source, craft\helpers\Template::attribute($this->env, $this->source, (isset($context["craft"]) || array_key_exists("craft", $context) ? $context["craft"] : (function () { throw new RuntimeError('Variable "craft" does not exist.', 2, $this->source); })()), "entries", [0 => ["section" => "survivalCourses", "slug" => // line 4 (isset($context["slug"]) || array_key_exists("slug", $context) ? $context["slug"] : (function () { throw new RuntimeError('Variable "slug" does not exist.', 4, $this->source); })())]], "method"), "first", [], "method"); } // line 7 $this->loadTemplate(("survivalCourses/_types/" . craft\helpers\Template::attribute($this->env, $this->source, (isset($context["entry"]) || array_key_exists("entry", $context) ? $context["entry"] : (function () { throw new RuntimeError('Variable "entry" does not exist.', 7, $this->source); })()), "type", [])), "survivalCourses/_entry", 7)->display($context); } public function getTemplateName() { return "survivalCourses/_entry"; }
return ob_get_clean(); } protected function displayWithErrorHandling(array $context, array $blocks = []) { try { $this->doDisplay($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($this->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
* @throws Error * @throws RuntimeError */ protected function displayWithErrorHandling(array $context, array $blocks = []) { try { parent::displayWithErrorHandling($context, $blocks); } catch (RuntimeError $e) { if (Craft::$app->getConfig()->getGeneral()->suppressTemplateErrors) { // Just log it and move on Craft::$app->getErrorHandler()->logException($e); } else { throw $e;
{ return $this->blocks; } public function display(array $context, array $blocks = []) { $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks)); } public function render(array $context) { $level = ob_get_level(); ob_start();
* @inheritdoc */ public function display(array $context, array $blocks = []) { $name = $this->getTemplateName(); Craft::beginProfile($name, __METHOD__); parent::display($context, $blocks); Craft::endProfile($name, __METHOD__); } // Protected Methods // =========================================================================
public function render(array $context) { $level = ob_get_level(); ob_start(); try { $this->display($context); } catch (\Throwable $e) { while (ob_get_level() > $level) { ob_end_clean(); } throw $e;
* @param array $context An array of parameters to pass to the template */ public function render(array $context = []): string { // using func_get_args() allows to not expose the blocks argument // as it should only be used by internal code return $this->template->render($context, \func_get_args()[1] ?? []); } /** * Displays the template. * * @param array $context An array of parameters to pass to the template
* @throws LoaderError When the template cannot be found * @throws SyntaxError When an error occurred during compilation * @throws RuntimeError When an error occurred during rendering */ public function render($name, array $context = []) { return $this->load($name)->render($context); } /** * Displays a template. * * @param string|TemplateWrapper $name The template name
// Render and return $renderingTemplate = $this->_renderingTemplate; $this->_renderingTemplate = $template; Craft::beginProfile($template, __METHOD__); try { $output = $this->getTwig()->render($template, $variables); } catch (\RuntimeException $e) { if (!YII_DEBUG) { // Throw a generic exception instead throw new \RuntimeException('An error occurred when rendering a template.', 0, $e); } throw $e;
ob_implicit_flush(false); $isRenderingPageTemplate = $this->_isRenderingPageTemplate; $this->_isRenderingPageTemplate = true; $this->beginPage(); echo $this->renderTemplate($template, $variables); $this->endPage(); $this->_isRenderingPageTemplate = $isRenderingPageTemplate; $output = ob_get_clean();
} $headers->set('content-type', $mimeType . '; charset=' . $response->charset); } // Render and return the template $response->data = $this->getView()->renderPageTemplate($template, $variables); // Prevent a response formatter from overriding the content-type header $response->format = YiiResponse::FORMAT_RAW; return $response; }
// Merge any additional route params $routeParams = Craft::$app->getUrlManager()->getRouteParams(); unset($routeParams['template'], $routeParams['template']); $variables = array_merge($variables, $routeParams); return $this->renderTemplate($template, $variables); } /** * Shows the 'offline' template. * * @return Response
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
/** * @inheritdoc */ public function runAction($id, $params = []) { try { return parent::runAction($id, $params); } catch (\Throwable $e) { if (Craft::$app->getRequest()->getAcceptsJson()) { Craft::$app->getErrorHandler()->logException($e); $message = $e->getMessage(); if ($e instanceof ClientException) { $statusCode = $e->getCode();
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
* @param string $route * @param array $params * @return Response|null The result of the action, normalized into a Response object */ public function runAction($route, $params = []) { $result = parent::runAction($route, $params); if ($result !== null) { if ($result instanceof Response) { return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
// If this is an action request, call the controller if (($response = $this->_processActionRequest($request)) !== null) { return $response; } // If we're still here, finally let Yii do it's thing. return parent::handleRequest($request); } /** * @inheritdoc * @param string $route * @param array $params
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
(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();
$_COOKIE = [ '__utmv' => '182888117.|1=logged-in=no=1', '_ga' => 'GA1.2.780263562.1522306312', '_fbp' => 'fb.1.1549980868020.1169924902', '1031b8c41dfff97a311a7ac99863bdc5_username' => '1d114d9c1a56e735dbab4d05aa6502efb349278691c37171cb3a27686d538a80a:2:{i:0;s:41:"1031b8c41dfff97a311a7ac99863bdc5_username";i:1;s:7:"lachlan";}', 'hasConsent' => 'true', '__stripe_mid' => '4a7f777e-b8a0-4eac-b0e5-65b6f7e40274', 'CRAFT_CSRF_TOKEN' => '7d5008cc15cdc0e4dc2254e9679645498a4e3c35a2fbf4a05f4a6ed779833beaa:2:{i:0;s:16:"CRAFT_CSRF_TOKEN";i:1;s:208:"6B5UWEHDS3EwdStB2TOvF9cdYOk5Ak9EEJnD-U4A|6319e76809821dde379391b357208479fbc9fcee5c580d8260cd699cf19178726B5UWEHDS3EwdStB2TOvF9cdYOk5Ak9EEJnD-U4A|1|$2y$13$bJqiZeef/CkQ.lpbb3OqYe23NYfFweQEJYXUgswHLW4kNfp9tsOzq";}', '_gid' => 'GA1.2.1626952502.1557835980', 'geoCookie' => '7571c62c2206dfa87ff9a6f35a2495da1b15f779d5ecb457735c7cf0342d973ea:2:{i:0;s:9:"geoCookie";i:1;O:8:"stdClass":16:{s:12:"businessName";s:0:"";s:15:"businessWebsite";s:0:"";s:4:"city";s:9:"Harrogate";s:9:"continent";s:6:"Europe";s:7:"country";s:14:"United Kingdom";s:11:"countryCode";s:2:"GB";s:6:"ipName";s:0:"";s:6:"ipType";s:11:"Residential";s:3:"isp";s:12:"Virgin Media";s:3:"lat";s:7:"54.0001";s:3:"lon";s:7:"-1.5350";s:3:"org";s:20:"Virgin Media Limited";s:5:"query";s:10:"86.9.210.0";s:6:"region";s:15:"North Yorkshire";s:6:"status";s:7:"success";s:6:"cached";b:0;}}', 'CraftSessionId' => 'jeir378u9dpjd0qgh2l55m6nje', '1031b8c41dfff97a311a7ac99863bdc5_identity' => '9244e642870663738e99eeec9dd3cf7cc9765b9bcb2d6fa705d1672a3d401ee9a:2:{i:0;s:41:"1031b8c41dfff97a311a7ac99863bdc5_identity";i:1;s:250:"["1","[\\"QwK8XFjeUAsZ2ZqXVsrP6a9xRZn1fIiu-BFt_qExGpNXPNOlWYRrnl-olOHcswullKseCR3OXu9bMQLIIilEeWbZei9KByCFx3Ww\\",null,\\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36\\"]",3600]";}', ]; $_SESSION = [ 'bd62416aa8538ede709019a5e113eea5__flash' => [], '1031b8c41dfff97a311a7ac99863bdc5__token' => 'QwK8XFjeUAsZ2ZqXVsrP6a9xRZn1fIiu-BFt_qExGpNXPNOlWYRrnl-olOHcswullKseCR3OXu9bMQLIIilEeWbZei9KByCFx3Ww', '1031b8c41dfff97a311a7ac99863bdc5__id' => '1', '1031b8c41dfff97a311a7ac99863bdc5__expire' => 1557843313, 'bd62416aa8538ede709019a5e113eea5__auth_access' => [ 'saveAssetInVolume:49', 'saveAssetInVolume:101', ], ];