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


PHP Tool::getAnonymizedClientIp方法代码示例

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


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

示例1: writeLogFile

 protected function writeLogFile($username, $error)
 {
     $logfile = PIMCORE_LOG_DIRECTORY . "/loginerror.log";
     $data = $this->readLogFile();
     $remoteHost = Tool::getAnonymizedClientIp();
     $data[] = array(time(), $remoteHost, $username);
     $lines = array();
     foreach ($data as $item) {
         $lines[] = implode(",", $item);
     }
     // only save 2000 entries
     $maxEntries = 2000;
     if (count($lines) > $maxEntries) {
         $lines = array_splice($lines, $maxEntries * -1);
     }
     File::put($logfile, implode("\n", $lines));
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:17,代码来源:LoginController.php

示例2: checkForRedirect

 /**
  * Checks for a suitable redirect
  * @throws Exception
  * @param bool $override
  * @return void
  */
 protected function checkForRedirect($override = false)
 {
     // not for admin requests
     if (Tool::isFrontentRequestByAdmin()) {
         return;
     }
     try {
         $front = \Zend_Controller_Front::getInstance();
         $config = Config::getSystemConfig();
         // get current site if available
         $sourceSite = null;
         if (Site::isSiteRequest()) {
             $sourceSite = Site::getCurrentSite();
         }
         $cacheKey = "system_route_redirect";
         if (empty($this->redirects) && !($this->redirects = Cache::load($cacheKey))) {
             $list = new Redirect\Listing();
             $list->setOrder("DESC");
             $list->setOrderKey("priority");
             $this->redirects = $list->load();
             Cache::save($this->redirects, $cacheKey, array("system", "redirect", "route"), null, 998);
         }
         $requestScheme = $_SERVER['HTTPS'] == 'on' ? \Zend_Controller_Request_Http::SCHEME_HTTPS : \Zend_Controller_Request_Http::SCHEME_HTTP;
         $matchRequestUri = $_SERVER["REQUEST_URI"];
         $matchUrl = $requestScheme . "://" . $_SERVER["HTTP_HOST"] . $matchRequestUri;
         foreach ($this->redirects as $redirect) {
             $matchAgainst = $matchRequestUri;
             if ($redirect->getSourceEntireUrl()) {
                 $matchAgainst = $matchUrl;
             }
             // if override is true the priority has to be 99 which means that overriding is ok
             if (!$override || $override && $redirect->getPriority() == 99) {
                 if (@preg_match($redirect->getSource(), $matchAgainst, $matches)) {
                     // check for a site
                     if ($sourceSite) {
                         if ($sourceSite->getId() != $redirect->getSourceSite()) {
                             continue;
                         }
                     }
                     array_shift($matches);
                     $target = $redirect->getTarget();
                     if (is_numeric($target)) {
                         $d = Document::getById($target);
                         if ($d instanceof Document\Page || $d instanceof Document\Link || $d instanceof Document\Hardlink) {
                             $target = $d->getFullPath();
                         } else {
                             \Logger::error("Target of redirect no found (Document-ID: " . $target . ")!");
                             continue;
                         }
                     }
                     // replace escaped % signs so that they didn't have effects to vsprintf (PIMCORE-1215)
                     $target = str_replace("\\%", "###URLENCODE_PLACEHOLDER###", $target);
                     $url = vsprintf($target, $matches);
                     $url = str_replace("###URLENCODE_PLACEHOLDER###", "%", $url);
                     // support for pcre backreferences
                     $url = replace_pcre_backreferences($url, $matches);
                     if ($redirect->getTargetSite() && !preg_match("@http(s)?://@i", $url)) {
                         try {
                             $targetSite = Site::getById($redirect->getTargetSite());
                             // if the target site is specified and and the target-path is starting at root (not absolute to site)
                             // the root-path will be replaced so that the page can be shown
                             $url = preg_replace("@^" . $targetSite->getRootPath() . "/@", "/", $url);
                             $url = $requestScheme . "://" . $targetSite->getMainDomain() . $url;
                         } catch (\Exception $e) {
                             \Logger::error("Site with ID " . $redirect->getTargetSite() . " not found.");
                             continue;
                         }
                     } else {
                         if (!preg_match("@http(s)?://@i", $url) && $config->general->domain && $redirect->getSourceEntireUrl()) {
                             // prepend the host and scheme to avoid infinite loops when using "domain" redirects
                             $url = ($front->getRequest()->isSecure() ? "https" : "http") . "://" . $config->general->domain . $url;
                         }
                     }
                     // pass-through parameters if specified
                     $queryString = $_SERVER["QUERY_STRING"];
                     if ($redirect->getPassThroughParameters() && !empty($queryString)) {
                         $glue = "?";
                         if (strpos($url, "?")) {
                             $glue = "&";
                         }
                         $url .= $glue;
                         $url .= $queryString;
                     }
                     header($redirect->getHttpStatus());
                     header("Location: " . $url, true, $redirect->getStatusCode());
                     // log all redirects to the redirect log
                     \Pimcore\Log\Simple::log("redirect", Tool::getAnonymizedClientIp() . " \t Custom-Redirect ID: " . $redirect->getId() . " , Source: " . $_SERVER["REQUEST_URI"] . " -> " . $url);
                     exit;
                 }
             }
         }
     } catch (\Exception $e) {
         // no suitable route found
     }
//.........这里部分代码省略.........
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:101,代码来源:Frontend.php


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