コード例 #1
0
 /**
  * @param \Enlight_Controller_Request_Request $request
  * @return bool
  */
 public function isRequestAllowed(\Enlight_Controller_Request_Request $request)
 {
     $clientIp = $request->getClientIp();
     $allowedIp = $this->config->get('AllowIP');
     if (empty($allowedIp)) {
         return true;
     }
     if (empty($clientIp)) {
         return false;
     }
     return strpos($allowedIp, $clientIp) !== false;
 }
コード例 #2
0
ファイル: Bootstrap.php プロジェクト: Goucher/shopware
 /**
  * Refresh visitor log
  *
  * @param Enlight_Controller_Request_Request $request
  */
 public function refreshLog($request)
 {
     $ip = $request->getClientIp(false);
     $deviceType = $request->getDeviceType();
     $shopId = Shopware()->Shop()->getId();
     $sql = '
         SELECT id
         FROM s_statistics_visitors
         WHERE datum = CURDATE()
         AND shopID = :shopId
         AND deviceType = :deviceType';
     $result = Shopware()->Db()->fetchOne($sql, array('shopId' => $shopId, 'deviceType' => $deviceType));
     if (empty($result)) {
         $sql = '
             INSERT INTO s_statistics_visitors
             (datum, shopID, pageimpressions, uniquevisits, deviceType)
             VALUES(NOW(), :shopId, 1, 1, :deviceType)
         ';
         Shopware()->Db()->query($sql, array('shopId' => $shopId, 'deviceType' => $deviceType));
         return;
     }
     $sql = 'SELECT id FROM s_statistics_pool WHERE datum = CURDATE() AND remoteaddr = ?';
     $result = Shopware()->Db()->fetchOne($sql, array($ip));
     if (empty($result)) {
         $sql = 'INSERT INTO s_statistics_pool (`remoteaddr`, `datum`) VALUES (?, NOW())';
         Shopware()->Db()->query($sql, array($ip));
         $sql = 'UPDATE s_statistics_visitors SET pageimpressions=pageimpressions+1, uniquevisits=uniquevisits+1 WHERE datum=CURDATE() AND shopID = ? AND deviceType = ?';
         Shopware()->Db()->query($sql, array($shopId, $deviceType));
     } else {
         $sql = 'UPDATE s_statistics_visitors SET pageimpressions=pageimpressions+1 WHERE datum=CURDATE() AND shopID = ? AND deviceType = ?';
         Shopware()->Db()->query($sql, array($shopId, $deviceType));
     }
 }
コード例 #3
0
ファイル: Bootstrap.php プロジェクト: GerDner/luck-docker
 /**
  * @param Request $request
  */
 protected function initServiceMode($request)
 {
     $config = $this->Application()->Config();
     if (!empty($config->setOffline) && strpos($config->offlineIp, $request->getClientIp()) === false) {
         if ($request->getControllerName() != 'error') {
             $request->setControllerName('error')->setActionName('service')->setDispatched(false);
         }
     }
 }