当前位置: 首页>>代码示例>>PHP>>正文


PHP SS_HTTPRequest::getIP方法代码示例

本文整理汇总了PHP中SS_HTTPRequest::getIP方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPRequest::getIP方法的具体用法?PHP SS_HTTPRequest::getIP怎么用?PHP SS_HTTPRequest::getIP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SS_HTTPRequest的用法示例。


在下文中一共展示了SS_HTTPRequest::getIP方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCountryForRequest

 /**
  * @param \SS_HTTPRequest $request
  * @return \Heystack\Ecommerce\Locale\Interfaces\CountryInterface|null
  */
 public function getCountryForRequest(\SS_HTTPRequest $request)
 {
     $location = false;
     if ($this->isAllowedUserAgent($request->getHeader('User-Agent'))) {
         $ip = static::parseIP($request->getIP());
         if (!$ip) {
             return null;
         }
         $fp = fopen(sprintf('https://geoip.maxmind.com/a?l=%s&i=%s', $this->key, $ip), 'r', null, stream_context_create(['https' => ['timeout' => $this->timeout]]));
         if (is_resource($fp)) {
             $location = stream_get_contents($fp);
             fclose($fp);
         }
     }
     return $location ? $this->localeService->getCountry(new Identifier($location)) : null;
 }
开发者ID:heyday,项目名称:heystack-ecommerce-maxmindlocaledetector,代码行数:20,代码来源:MaxMindLocaleDetector.php

示例2: createSpamAttempt

 /**
  * Creates a failed spam attempt object witht the user's info
  *
  * @param SS_HTTPRequest
  * @return ContactFormSpamAttempt
  */
 public function createSpamAttempt(SS_HTTPRequest $r)
 {
     $spam = ContactFormSpamAttempt::create(array('IPAddress' => $r->getIP(), 'URL' => $r->getURL(), 'Notes' => $this->class));
     return $spam;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-contact-form,代码行数:11,代码来源:ContactFormSpamProtector.php

示例3: fetch

 /**
  * Fetch one or all remote dump files and writes to local filesystem.
  *
  * If filename is supplied as getVar then only that file will be retrieved, otherwise all files which don't exist locally will be retrieved up to number getVar.
  *
  * If filename is supplied as getVar then file will overwrite existing file.
  *
  * SideEffects:
  *  Reads files from remote system.
  *  Writes files to local filesystem.
  *  Outputs results
  *
  * @param SS_HTTPRequest $request
  * @return int number of files fetched
  * @throws PermissionFailureException
  */
 public function fetch(SS_HTTPRequest $request)
 {
     $options = CollectionTools::options_from_array($request->getVars(), array('RemoteHost' => $request->getIP(), 'Path' => Replicant::asset_path(), 'FileName' => '', 'UserName' => null, 'Password' => null));
     $action = ReplicantActionFetch::create();
     $action->checkPerm()->update($options)->execute();
     return $action->format();
 }
开发者ID:helpfulrobot,项目名称:govtnz-replicant,代码行数:23,代码来源:ReplicantController.php

示例4: set_message

 /**
  * sends a message to user
  * @param POST 'Message'
  * @param POST 'To'
  * @param SS_HTTPRequest $request
  */
 public function set_message(SS_HTTPRequest $request)
 {
     if (!Permission::checkMember(Member::currentUser(), "CMS_ACCESS_LiveChatAdmin")) {
         header("HTTP/1.0 403 Forbidden");
         die('You do not have permission to use the live chat module');
     }
     if (!$request->postVar('Message')) {
         header("HTTP/1.0 400 Bad Request");
         die('No Message found');
     }
     if (!$request->postVar('To')) {
         header("HTTP/1.0 400 Bad Request");
         die('No target user ID found');
     }
     // redirecting one user to another
     if (substr($request->postVar('Message'), 0, 9) == '/redirect') {
         $this->redirectChatToUser($request->postVar('To'), substr($request->postVar('Message'), 10));
         die;
     }
     LiveChatMessage::create(array('Message' => htmlentities($request->postVar('Message')), 'ToID' => is_numeric($request->postVar('To')) ? $request->postVar('To') : 0, 'Read' => false, 'FromID' => Member::currentUserID(), 'FromIP' => $request->getIP(), 'FromName' => is_numeric($request->postVar('To')) ? "" : $request->postVar('To')))->write();
     die;
     // success
 }
开发者ID:helpfulrobot,项目名称:otago-livechat,代码行数:29,代码来源:LiveChatController.php


注:本文中的SS_HTTPRequest::getIP方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。