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


PHP Tool::getClientIp方法代码示例

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


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

示例1: routeStartup

 /**
  * @param \Zend_Controller_Request_Abstract $request
  */
 public function routeStartup(\Zend_Controller_Request_Abstract $request)
 {
     $maintenance = false;
     $file = \Pimcore\Tool\Admin::getMaintenanceModeFile();
     if (is_file($file)) {
         $conf = (include $file);
         if (isset($conf["sessionId"])) {
             if ($conf["sessionId"] != $_COOKIE["pimcore_admin_sid"]) {
                 $maintenance = true;
             }
         } else {
             @unlink($file);
         }
     }
     // do not activate the maintenance for the server itself
     // this is to avoid problems with monitoring agents
     $serverIps = ["127.0.0.1"];
     if ($maintenance && !in_array(\Pimcore\Tool::getClientIp(), $serverIps)) {
         header("HTTP/1.1 503 Service Temporarily Unavailable", 503);
         $file = PIMCORE_PATH . "/static/html/maintenance.html";
         $customFile = PIMCORE_CUSTOM_CONFIGURATION_DIRECTORY . "/maintenance.html";
         if (file_exists($customFile)) {
             $file = $customFile;
         }
         echo file_get_contents($file);
         exit;
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:31,代码来源:Maintenance.php

示例2: routeStartup

 /**
  * @param \Zend_Controller_Request_Abstract $request
  */
 public function routeStartup(\Zend_Controller_Request_Abstract $request)
 {
     $maintenance = false;
     $file = \Pimcore\Tool\Admin::getMaintenanceModeFile();
     if (is_file($file)) {
         $conf = new \Zend_Config_Xml($file);
         if ($conf->sessionId) {
             if ($conf->sessionId != $_COOKIE["pimcore_admin_sid"]) {
                 $maintenance = true;
             }
         } else {
             @unlink($file);
         }
     }
     // do not activate the maintenance for the server itself
     // this is to avoid problems with monitoring agents
     $serverIps = array("127.0.0.1");
     if ($maintenance && !in_array(\Pimcore\Tool::getClientIp(), $serverIps)) {
         header("HTTP/1.1 503 Service Temporarily Unavailable", 503);
         echo file_get_contents(PIMCORE_PATH . "/static/html/maintenance.html");
         exit;
     }
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:26,代码来源:Maintenance.php

示例3: getCountry

 /**
  * Get current Users Country
  *
  * @return Country|null
  * @throws \Exception
  */
 public static function getCountry()
 {
     $session = self::getSession();
     $country = null;
     if ($session->countryId) {
         $country = Country::getById($session->countryId);
         if ($country instanceof Country) {
             return $country;
         }
     }
     if (self::getSession()->user instanceof User) {
         $user = self::getSession()->user;
         if (count($user->getAddresses()) > 0) {
             $country = $user->getAddresses()->get(0);
         }
     }
     if (!$country instanceof Country) {
         if (file_exists(CORESHOP_CONFIGURATION_PATH . "/GeoIP/GeoIP.dat")) {
             $gi = geoip_open(CORESHOP_CONFIGURATION_PATH . "/GeoIP/GeoIP.dat", GEOIP_MEMORY_CACHE);
             $country = geoip_country_code_by_addr($gi, \Pimcore\Tool::getClientIp());
             geoip_close($gi);
             $country = Country::getByIsoCode($country);
         } else {
             $enabled = Country::getActiveCountries();
             if (count($enabled) > 0) {
                 return $enabled[0];
             } else {
                 throw new \Exception("no enabled countries found");
             }
         }
     }
     if (!$country instanceof Country) {
         //Using Default Country: AT
         //TODO: Default Country configurable thru settings
         $country = Country::getById(7);
         //throw new \Exception("Country with code $country not found");
     }
     $session->countryId = $country->getId();
     return $country;
 }
开发者ID:Cube-Solutions,项目名称:pimcore-coreshop,代码行数:46,代码来源:Tool.php

示例4: addNoteOnObject

 /**
  * @param $object
  * @param $title
  */
 public function addNoteOnObject($object, $title)
 {
     $note = new Model\Element\Note();
     $note->setElement($object);
     $note->setDate(time());
     $note->setType("newsletter");
     $note->setTitle($title);
     $note->setUser(0);
     $note->setData(["ip" => ["type" => "text", "data" => Tool::getClientIp()]]);
     $note->save();
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:15,代码来源:Newsletter.php

示例5: getSystemAction

 public function getSystemAction()
 {
     $this->checkPermission("system_settings");
     $values = Config::getSystemConfig();
     if (($handle = fopen(PIMCORE_PATH . "/config/timezones.csv", "r")) !== FALSE) {
         while (($rowData = fgetcsv($handle, 10000, ",", '"')) !== false) {
             $timezones[] = $rowData[0];
         }
         fclose($handle);
     }
     $locales = Tool::getSupportedLocales();
     $languageOptions = array();
     foreach ($locales as $short => $translation) {
         if (!empty($short)) {
             $languageOptions[] = array("language" => $short, "display" => $translation . " ({$short})");
             $validLanguages[] = $short;
         }
     }
     $valueArray = $values->toArray();
     $valueArray['general']['validLanguage'] = explode(",", $valueArray['general']['validLanguages']);
     //for "wrong" legacy values
     if (is_array($valueArray['general']['validLanguage'])) {
         foreach ($valueArray['general']['validLanguage'] as $existingValue) {
             if (!in_array($existingValue, $validLanguages)) {
                 $languageOptions[] = array("language" => $existingValue, "display" => $existingValue);
             }
         }
     }
     //cache exclude patterns - add as array
     if (!empty($valueArray['cache']['excludePatterns'])) {
         $patterns = explode(",", $valueArray['cache']['excludePatterns']);
         if (is_array($patterns)) {
             foreach ($patterns as $pattern) {
                 $valueArray['cache']['excludePatternsArray'][] = array("value" => $pattern);
             }
         }
     }
     //remove password from values sent to frontend
     $valueArray['database']["params"]['password'] = "##SECRET_PASS##";
     //admin users as array
     $adminUsers = array();
     $userList = new Model\User\Listing();
     $userList->setCondition("admin = 1 and email is not null and email != ''");
     $users = $userList->load();
     if (is_array($users)) {
         foreach ($users as $user) {
             $adminUsers[] = array("id" => $user->getId(), "username" => $user->getName());
         }
     }
     $adminUsers[] = array("id" => "", "username" => "-");
     $response = array("values" => $valueArray, "adminUsers" => $adminUsers, "config" => array("timezones" => $timezones, "languages" => $languageOptions, "client_ip" => Tool::getClientIp(), "google_private_key_exists" => file_exists(\Pimcore\Google\Api::getPrivateKeyPath()), "google_private_key_path" => \Pimcore\Google\Api::getPrivateKeyPath()));
     $this->_helper->json($response);
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:53,代码来源:SettingsController.php

示例6: inDebugMode

 /**
  * @static
  * @return bool
  */
 public static function inDebugMode()
 {
     if (defined("PIMCORE_DEBUG")) {
         return PIMCORE_DEBUG;
     }
     $conf = Config::getSystemConfig();
     $debug = (bool) $conf->general->debug;
     // enable debug mode only for one IP
     if ($conf->general->debug_ip && $conf->general->debug) {
         $debug = false;
         $debugIpAddresses = explode_and_trim(',', $conf->general->debug_ip);
         if (in_array(Tool::getClientIp(), $debugIpAddresses)) {
             $debug = true;
         }
     }
     return $debug;
 }
开发者ID:pdaniel-frk,项目名称:pimcore,代码行数:21,代码来源:Pimcore.php


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