Example #1
0
    /**
     * @param Enlight_Controller_Request_RequestHttp $request
     */
    public function refreshBasket($request)
    {
        $currentController = $request->getParam('requestController', $request->getControllerName());
        $sessionId = (string) Enlight_Components_Session::getId();

        if (!empty($currentController) && !empty($sessionId)) {
            $userId = (int) Shopware()->Session()->sUserId;
            $userAgent = (string) $request->getServer("HTTP_USER_AGENT");
            $sql = "
                UPDATE s_order_basket
                SET lastviewport = ?,
                    useragent = ?,
                    userID = ?
                WHERE sessionID=?
            ";
            Shopware()->Db()->query($sql, array(
                $currentController, $userAgent,
                $userId, $sessionId
            ));
        }
    }
Example #2
0
 /**
  * Secure cron actions according to system settings
  *
  * @param Enlight_Controller_Request_RequestHttp $request
  * @return bool If cron action is authorized
  */
 public function authorizeCronAction($request)
 {
     // If called using CLI, always execute the cron tasks
     if (php_sapi_name() == 'cli') {
         return true;
     }
     // At least one of the security policies is enabled.
     // If at least one of them validates, cron tasks will be executed
     $cronSecureAllowedKey = Shopware()->Config()->get('cronSecureAllowedKey');
     $cronSecureAllowedIp = Shopware()->Config()->get('cronSecureAllowedIp');
     $cronSecureByAccount = Shopware()->Config()->get('cronSecureByAccount');
     // No security policy specified, accept all requests
     if (empty($cronSecureAllowedKey) && empty($cronSecureAllowedIp) && !$cronSecureByAccount) {
         return true;
     }
     // Validate key
     if (!empty($cronSecureAllowedKey)) {
         $urlKey = $request->getParam('key');
         if (strcmp($cronSecureAllowedKey, $urlKey) == 0) {
             return true;
         }
     }
     // Validate ip
     if (!empty($cronSecureAllowedIp)) {
         $requestIp = $request->getServer('REMOTE_ADDR');
         if (in_array($requestIp, explode(';', $cronSecureAllowedIp))) {
             return true;
         }
     }
     // Validate user auth
     if ($cronSecureByAccount) {
         if (Shopware()->Auth()->hasIdentity() === true) {
             return true;
         }
     }
     return false;
 }