コード例 #1
0
 /**
  * Listener method for the Enlight_Controller_Front_DispatchLoopStartup event.
  *
  * @param \Enlight_Controller_EventArgs $args
  */
 public function onDispatchLoopStartup(Enlight_Controller_EventArgs $args)
 {
     $this->request = $args->getSubject()->Request();
     $this->response = $args->getSubject()->Response();
     if ($this->request->getModuleName() != 'api') {
         return;
     }
     $this->isApiCall = true;
     $router = new \ShopwarePlugins\RestApi\Components\Router();
     $router->assembleRoute($this->request, $this->response);
 }
コード例 #2
0
ファイル: Router.php プロジェクト: GerDner/luck-docker
 /**
  * @param \Enlight_Controller_EventArgs $args
  */
 public function onPreDispatch(\Enlight_Controller_EventArgs $args)
 {
     /** @var $front \Enlight_Controller_Front */
     $front = $args->getSubject();
     $request = $front->Request();
     /** @var $router \Shopware\Components\Routing\RouterInterface  */
     $router = $front->Router();
     // Fix context on forward
     $context = $router->getContext();
     $context->setGlobalParams($context::getGlobalParamsFromRequest($request));
 }
コード例 #3
0
 /**
  * Checks the url / the request and passes it around if necessary.
  *
  * @param Enlight_Controller_EventArgs $args
  */
 public function onPreDispatch(Enlight_Controller_EventArgs $args)
 {
     $request = $args->getRequest();
     $response = $args->getResponse();
     if ($response->isException() || $request->isPost() || $request->isXmlHttpRequest() || $request->has('callback') || $request->getModuleName() && $request->getModuleName() != 'frontend' || !$request->getParam('rewriteAlias') && !$request->getParam('rewriteOld') || !Shopware()->Session()->Bot && !$request->getCookie()) {
         return;
     }
     $router = $args->getSubject()->Router();
     $query = $request->getQuery();
     $location = $router->assemble($query);
     $current = $request->getScheme() . '://' . $request->getHttpHost() . $request->getRequestUri();
     if ($location !== $current) {
         $response->setRedirect($location, 301);
     }
 }
コード例 #4
0
ファイル: Bootstrap.php プロジェクト: GerDner/luck-docker
 /**
  * Checks the url / the request and passes it around if necessary.
  *
  * @param Enlight_Controller_EventArgs $args
  */
 public function onPreDispatch(Enlight_Controller_EventArgs $args)
 {
     $request = $args->getRequest();
     $response = $args->getResponse();
     if ($response->isException() || $request->isPost() || $request->isXmlHttpRequest() || $request->has('callback') || $request->getModuleName() != 'frontend' || !$request->getParam('rewriteAlias')) {
         return;
     }
     $router = $args->getSubject()->Router();
     $query = $request->getQuery();
     $location = $router->assemble($query);
     // Fix shop redirect / if it's not a seo url
     if (preg_match('#\\/[0-9]+$#', $location, $match) > 0) {
         $location = $request->getBaseUrl() . '/';
     }
     $current = $request->getScheme() . '://' . $request->getHttpHost() . $request->getRequestUri();
     if ($location !== $current) {
         $response->setRedirect($location, 301);
     }
 }
コード例 #5
0
ファイル: Bootstrap.php プロジェクト: GerDner/luck-docker
 /**
  * @param Enlight_Controller_EventArgs $args
  */
 public function onDispatchLoopShutdown(Enlight_Controller_EventArgs $args)
 {
     $response = $args->getSubject()->Response();
     $exceptions = $response->getException();
     if (empty($exceptions)) {
         return;
     }
     $logger = $this->get('corelogger');
     foreach ($exceptions as $exception) {
         $logger->error((string) $exception);
     }
 }
コード例 #6
0
ファイル: Bootstrap.php プロジェクト: GerDner/luck-docker
 /**
  * Event listener method
  *
  * @param Enlight_Controller_EventArgs $args
  */
 public function onRouteShutdown(Enlight_Controller_EventArgs $args)
 {
     $request = $args->getRequest();
     $front = $args->getSubject();
     $response = $front->Response();
     $config = $this->Config();
     if ($request->getModuleName() == 'backend' || $request->getModuleName() == 'api') {
         return;
     }
     if (!empty($config->refererCheck) && $request->isPost() && in_array($request->getControllerName(), array('account')) && ($referer = $request->getHeader('Referer')) !== null && strpos($referer, 'http') === 0) {
         /** @var $shop Shopware_Models_Shop */
         $shop = Shopware()->Shop();
         $validHosts = array($shop->getHost(), $shop->getSecureHost());
         $host = parse_url($referer, PHP_URL_HOST);
         $hostWithPort = $host . ':' . parse_url($referer, PHP_URL_PORT);
         if (!in_array($host, $validHosts) && !in_array($hostWithPort, $validHosts)) {
             $response->setException(new Exception('Referer check for frontend session failed'));
         }
     }
     $intVars = array('sCategory', 'sContent', 'sCustom');
     foreach ($intVars as $parameter) {
         if (!empty($_GET[$parameter])) {
             $_GET[$parameter] = (int) $_GET[$parameter];
         }
         if (!empty($_POST[$parameter])) {
             $_POST[$parameter] = (int) $_POST[$parameter];
         }
     }
     $regex = array();
     if (!empty($config->sql_protection)) {
         $regex[] = $this->sqlRegex;
     }
     if (!empty($config->xss_protection)) {
         $regex[] = $this->xssRegex;
     }
     if (!empty($config->rfi_protection)) {
         $regex[] = $this->rfiRegex;
     }
     if (!empty($config->own_filter)) {
         $regex[] = $config->own_filter;
     }
     if (empty($regex)) {
         return;
     }
     $regex = '#' . implode('|', $regex) . '#msi';
     $userParams = $request->getUserParams();
     $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST, &$_SERVER, &$userParams);
     while (list($key, $val) = each($process)) {
         foreach ($val as $k => $v) {
             unset($process[$key][$k]);
             if (is_array($v)) {
                 $process[$key][self::filterValue($k, $regex)] = $v;
                 $process[] =& $process[$key][self::filterValue($k, $regex)];
             } else {
                 $process[$key][self::filterValue($k, $regex)] = self::filterValue($v, $regex);
             }
         }
     }
     unset($process);
     $request->setParams($userParams);
 }
コード例 #7
0
 /**
  * Do http caching jobs
  *
  * @param \Enlight_Controller_EventArgs $args
  */
 public function onPreDispatch(\Enlight_Controller_EventArgs $args)
 {
     $this->action = $args->getSubject();
     $this->request = $args->getRequest();
     $this->response = $args->getResponse();
     $this->Application()->Events()->registerListener(new Enlight_Event_Handler_Default('Enlight_Controller_Action_PostDispatchSecure', array($this, 'onPostDispatch')));
 }
コード例 #8
0
 /**
  * This function extends a new Template. This Template replaces the original password forgotten form with
  * a extended Version.
  *
  * @param Enlight_Controller_EventArgs $args
  */
 public function onPostDispatchAccount(Enlight_Controller_EventArgs $args)
 {
     if (!$this->Config()->get('activatePlugin')) {
         return;
     }
     /** @var Shopware_Controllers_Frontend_Account $controller */
     $controller = $args->getSubject();
     $view = $controller->View();
     $this->registerComponents();
     if ($controller->Request()->getActionName() == 'password') {
         $view->extendsTemplate('frontend/plugins/swag_password_restore/index.tpl');
     } else {
         $view->extendsTemplate('frontend/plugins/swag_password_restore/messages.tpl');
     }
 }
コード例 #9
0
ファイル: Bootstrap.php プロジェクト: nhp/shopware-4
    /**
     * Do http caching jobs
     *
     * @param \Enlight_Controller_EventArgs $args
     */
    public function onPreDispatch($args)
    {
        $this->action = $action = $args->getSubject();
        $this->request = $request = $args->getRequest();
        $this->response = $response = $args->getResponse();

        if ($request->getHeader('Surrogate-Capability') === false) {
            return;
        }

        $this->initConfig();

        if ($request->getModuleName() != 'frontend' && $request->getModuleName() != 'widgets') {
            return;
        }
        if (!Shopware()->Shop()->get('esi')) {
            return;
        }

        // Allow esi tags
        $this->response->setHeader('Surrogate-Control', 'content="ESI/1.0"');

        $this->setControllerOptions();
        $this->setCacheHeaders();
        $this->setNoCacheCookie();
        $this->setCacheIdHeader();
    }