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


PHP IP::getIpFromHeader方法代码示例

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


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

示例1: getLocation

 /**
  * Uses a GeoIP database to get a visitor's location based on their IP address.
  *
  * This function will return different results based on the data used and based
  * on how the GeoIP module is configured.
  *
  * If a region database is used, it may return the country code, region code,
  * city name, area code, latitude, longitude and postal code of the visitor.
  *
  * Alternatively, only the country code may be returned for another database.
  *
  * If your HTTP server is not configured to include all GeoIP information, some
  * information will not be available to Piwik.
  *
  * @param array $info Must have an 'ip' field.
  * @return array
  */
 public function getLocation($info)
 {
     $ip = $this->getIpFromInfo($info);
     // geoip modules that are built into servers can't use a forced IP. in this case we try
     // to fallback to another version.
     $myIP = IP::getIpFromHeader();
     if (!self::isSameOrAnonymizedIp($ip, $myIP) && (!isset($info['disable_fallbacks']) || !$info['disable_fallbacks'])) {
         Common::printDebug("The request is for IP address: " . $info['ip'] . " but your IP is: {$myIP}. GeoIP Server Module (apache/nginx) does not support this use case... ");
         $fallbacks = array(Pecl::ID, Php::ID);
         foreach ($fallbacks as $fallbackProviderId) {
             $otherProvider = LocationProvider::getProviderById($fallbackProviderId);
             if ($otherProvider) {
                 Common::printDebug("Used {$fallbackProviderId} to detect this visitor IP");
                 return $otherProvider->getLocation($info);
             }
         }
         Common::printDebug("FAILED to lookup the geo location of this IP address, as no fallback location providers is configured. We recommend to configure Geolocation PECL module to fix this error.");
         return false;
     }
     $result = array();
     foreach (self::$geoIpServerVars as $resultKey => $geoipVarName) {
         if (!empty($_SERVER[$geoipVarName])) {
             $result[$resultKey] = $_SERVER[$geoipVarName];
         }
     }
     foreach (self::$geoIpUtfServerVars as $resultKey => $geoipVarName) {
         if (!empty($_SERVER[$geoipVarName])) {
             $result[$resultKey] = utf8_encode($_SERVER[$geoipVarName]);
         }
     }
     $this->completeLocationResult($result);
     return $result;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:50,代码来源:ServerBased.php

示例2: index

 public function index()
 {
     Piwik::checkUserIsNotAnonymous();
     $view = new View('@MobileMessaging/index');
     $view->isSuperUser = Piwik::hasUserSuperUserAccess();
     $mobileMessagingAPI = API::getInstance();
     $view->delegatedManagement = $mobileMessagingAPI->getDelegatedManagement();
     $view->credentialSupplied = $mobileMessagingAPI->areSMSAPICredentialProvided();
     $view->accountManagedByCurrentUser = $view->isSuperUser || $view->delegatedManagement;
     $view->strHelpAddPhone = Piwik::translate('MobileMessaging_Settings_PhoneNumbers_HelpAdd', array(Piwik::translate('General_Settings'), Piwik::translate('MobileMessaging_SettingsMenu')));
     if ($view->credentialSupplied && $view->accountManagedByCurrentUser) {
         $view->provider = $mobileMessagingAPI->getSMSProvider();
         $view->creditLeft = $mobileMessagingAPI->getCreditLeft();
     }
     $view->smsProviders = SMSProvider::$availableSMSProviders;
     // construct the list of countries from the lang files
     $countries = array();
     foreach (Common::getCountriesList() as $countryCode => $continentCode) {
         if (isset(CountryCallingCodes::$countryCallingCodes[$countryCode])) {
             $countries[$countryCode] = array('countryName' => \Piwik\Plugins\UserCountry\countryTranslate($countryCode), 'countryCallingCode' => CountryCallingCodes::$countryCallingCodes[$countryCode]);
         }
     }
     $view->countries = $countries;
     $view->defaultCountry = Common::getCountry(LanguagesManager::getLanguageCodeForCurrentUser(), true, IP::getIpFromHeader());
     $view->phoneNumbers = $mobileMessagingAPI->getPhoneNumbers();
     $this->setBasicVariablesView($view);
     return $view->render();
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:28,代码来源:Controller.php

示例3: sendMail

 private function sendMail($subject, $body)
 {
     $feedbackEmailAddress = Config::getInstance()->General['feedback_email_address'];
     $subject = '[ Feedback Feature - Piwik ] ' . $subject;
     $body = Common::unsanitizeInputValue($body) . "\n" . 'Piwik ' . Version::VERSION . "\n" . 'IP: ' . IP::getIpFromHeader() . "\n" . 'URL: ' . Url::getReferrer() . "\n";
     $mail = new Mail();
     $mail->setFrom(Piwik::getCurrentUserEmail());
     $mail->addTo($feedbackEmailAddress, 'Piwik Team');
     $mail->setSubject($subject);
     $mail->setBodyText($body);
     @$mail->send();
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:12,代码来源:API.php

示例4: index

 /**
  * Main view showing listing of websites and settings
  */
 public function index()
 {
     $view = new View('@SitesManager/index');
     Site::clearCache();
     if (Piwik::isUserIsSuperUser()) {
         $sitesRaw = API::getInstance()->getAllSites();
     } else {
         $sitesRaw = API::getInstance()->getSitesWithAdminAccess();
     }
     // Gets sites after Site.setSite hook was called
     $sites = array_values(Site::getSites());
     if (count($sites) != count($sitesRaw)) {
         throw new Exception("One or more website are missing or invalid.");
     }
     foreach ($sites as &$site) {
         $site['alias_urls'] = API::getInstance()->getSiteUrlsFromId($site['idsite']);
         $site['excluded_ips'] = explode(',', $site['excluded_ips']);
         $site['excluded_parameters'] = explode(',', $site['excluded_parameters']);
         $site['excluded_user_agents'] = explode(',', $site['excluded_user_agents']);
     }
     $view->adminSites = $sites;
     $view->adminSitesCount = count($sites);
     $timezones = API::getInstance()->getTimezonesList();
     $view->timezoneSupported = SettingsServer::isTimezoneSupportEnabled();
     $view->timezones = Common::json_encode($timezones);
     $view->defaultTimezone = API::getInstance()->getDefaultTimezone();
     $view->currencies = Common::json_encode(API::getInstance()->getCurrencyList());
     $view->defaultCurrency = API::getInstance()->getDefaultCurrency();
     $view->utcTime = Date::now()->getDatetime();
     $excludedIpsGlobal = API::getInstance()->getExcludedIpsGlobal();
     $view->globalExcludedIps = str_replace(',', "\n", $excludedIpsGlobal);
     $excludedQueryParametersGlobal = API::getInstance()->getExcludedQueryParametersGlobal();
     $view->globalExcludedQueryParameters = str_replace(',', "\n", $excludedQueryParametersGlobal);
     $globalExcludedUserAgents = API::getInstance()->getExcludedUserAgentsGlobal();
     $view->globalExcludedUserAgents = str_replace(',', "\n", $globalExcludedUserAgents);
     $view->globalSearchKeywordParameters = API::getInstance()->getSearchKeywordParametersGlobal();
     $view->globalSearchCategoryParameters = API::getInstance()->getSearchCategoryParametersGlobal();
     $view->isSearchCategoryTrackingEnabled = \Piwik\Plugin\Manager::getInstance()->isPluginActivated('CustomVariables');
     $view->allowSiteSpecificUserAgentExclude = API::getInstance()->isSiteSpecificUserAgentExcludeEnabled();
     $view->globalKeepURLFragments = API::getInstance()->getKeepURLFragmentsGlobal();
     $view->currentIpAddress = IP::getIpFromHeader();
     $view->showAddSite = (bool) Common::getRequestVar('showaddsite', false);
     $this->setBasicVariablesView($view);
     return $view->render();
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:48,代码来源:Controller.php

示例5: setManageVariables

 private function setManageVariables(View $view)
 {
     $view->isSuperUser = Piwik::hasUserSuperUserAccess();
     $mobileMessagingAPI = API::getInstance();
     $view->delegatedManagement = $mobileMessagingAPI->getDelegatedManagement();
     $view->credentialSupplied = $mobileMessagingAPI->areSMSAPICredentialProvided();
     $view->accountManagedByCurrentUser = $view->isSuperUser || $view->delegatedManagement;
     $view->strHelpAddPhone = $this->translator->translate('MobileMessaging_Settings_PhoneNumbers_HelpAdd', array($this->translator->translate('General_Settings'), $this->translator->translate('MobileMessaging_SettingsMenu')));
     $view->creditLeft = 0;
     $currentProvider = '';
     if ($view->credentialSupplied && $view->accountManagedByCurrentUser) {
         $currentProvider = $mobileMessagingAPI->getSMSProvider();
         $view->creditLeft = $mobileMessagingAPI->getCreditLeft();
     }
     $view->delegateManagementOptions = array(array('key' => '0', 'value' => Piwik::translate('General_No'), 'description' => Piwik::translate('General_Default') . '. ' . Piwik::translate('MobileMessaging_Settings_LetUsersManageAPICredential_No_Help')), array('key' => '1', 'value' => Piwik::translate('General_Yes'), 'description' => Piwik::translate('MobileMessaging_Settings_LetUsersManageAPICredential_Yes_Help')));
     $providers = array();
     $providerOptions = array();
     foreach (SMSProvider::findAvailableSmsProviders() as $provider) {
         if (empty($currentProvider)) {
             $currentProvider = $provider->getId();
         }
         $providers[$provider->getId()] = $provider->getDescription();
         $providerOptions[$provider->getId()] = $provider->getId();
     }
     $view->provider = $currentProvider;
     $view->smsProviders = $providers;
     $view->smsProviderOptions = $providerOptions;
     $defaultCountry = Common::getCountry(LanguagesManager::getLanguageCodeForCurrentUser(), true, IP::getIpFromHeader());
     $view->defaultCallingCode = '';
     // construct the list of countries from the lang files
     $countries = array(array('key' => '', 'value' => ''));
     foreach ($this->regionDataProvider->getCountryList() as $countryCode => $continentCode) {
         if (isset(CountryCallingCodes::$countryCallingCodes[$countryCode])) {
             if ($countryCode == $defaultCountry) {
                 $view->defaultCallingCode = CountryCallingCodes::$countryCallingCodes[$countryCode];
             }
             $countries[] = array('key' => CountryCallingCodes::$countryCallingCodes[$countryCode], 'value' => \Piwik\Plugins\UserCountry\countryTranslate($countryCode));
         }
     }
     $view->countries = $countries;
     $view->phoneNumbers = $mobileMessagingAPI->getPhoneNumbers();
     $this->setBasicVariablesView($view);
 }
开发者ID:piwik,项目名称:piwik,代码行数:43,代码来源:Controller.php

示例6: getIp

 public function getIp()
 {
     if (!empty($this->enforcedIp)) {
         $ipString = $this->enforcedIp;
     } else {
         $ipString = IP::getIpFromHeader();
     }
     $ip = IP::P2N($ipString);
     return $ip;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:10,代码来源:Request.php

示例7: sendHttpRequestBy

 /**
  * Sends an HTTP request using the specified transport method.
  *
  * @param string $method
  * @param string $aUrl
  * @param int $timeout
  * @param string $userAgent
  * @param string $destinationPath
  * @param resource $file
  * @param int $followDepth
  * @param bool|string $acceptLanguage Accept-language header
  * @param bool $acceptInvalidSslCertificate Only used with $method == 'curl'. If set to true (NOT recommended!) the SSL certificate will not be checked
  * @param array|bool $byteRange For Range: header. Should be two element array of bytes, eg, array(0, 1024)
  *                                                  Doesn't work w/ fopen method.
  * @param bool $getExtendedInfo True to return status code, headers & response, false if just response.
  * @param string $httpMethod The HTTP method to use. Defaults to `'GET'`.
  *
  * @throws Exception
  * @return bool  true (or string/array) on success; false on HTTP response error code (1xx or 4xx)
  */
 public static function sendHttpRequestBy($method = 'socket', $aUrl, $timeout, $userAgent = null, $destinationPath = null, $file = null, $followDepth = 0, $acceptLanguage = false, $acceptInvalidSslCertificate = false, $byteRange = false, $getExtendedInfo = false, $httpMethod = 'GET')
 {
     if ($followDepth > 5) {
         throw new Exception('Too many redirects (' . $followDepth . ')');
     }
     $contentLength = 0;
     $fileLength = 0;
     // Piwik services behave like a proxy, so we should act like one.
     $xff = 'X-Forwarded-For: ' . (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] . ',' : '') . IP::getIpFromHeader();
     if (empty($userAgent)) {
         $userAgent = self::getUserAgent();
     }
     $via = 'Via: ' . (isset($_SERVER['HTTP_VIA']) && !empty($_SERVER['HTTP_VIA']) ? $_SERVER['HTTP_VIA'] . ', ' : '') . Version::VERSION . ' ' . ($userAgent ? " ({$userAgent})" : '');
     // range header
     $rangeHeader = '';
     if (!empty($byteRange)) {
         $rangeHeader = 'Range: bytes=' . $byteRange[0] . '-' . $byteRange[1] . "\r\n";
     }
     // proxy configuration
     $proxyHost = Config::getInstance()->proxy['host'];
     $proxyPort = Config::getInstance()->proxy['port'];
     $proxyUser = Config::getInstance()->proxy['username'];
     $proxyPassword = Config::getInstance()->proxy['password'];
     $aUrl = trim($aUrl);
     // other result data
     $status = null;
     $headers = array();
     if ($method == 'socket') {
         if (!self::isSocketEnabled()) {
             // can be triggered in tests
             throw new Exception("HTTP socket support is not enabled (php function fsockopen is not available) ");
         }
         // initialization
         $url = @parse_url($aUrl);
         if ($url === false || !isset($url['scheme'])) {
             throw new Exception('Malformed URL: ' . $aUrl);
         }
         if ($url['scheme'] != 'http') {
             throw new Exception('Invalid protocol/scheme: ' . $url['scheme']);
         }
         $host = $url['host'];
         $port = isset($url['port)']) ? $url['port'] : 80;
         $path = isset($url['path']) ? $url['path'] : '/';
         if (isset($url['query'])) {
             $path .= '?' . $url['query'];
         }
         $errno = null;
         $errstr = null;
         if (!empty($proxyHost) && !empty($proxyPort) || !empty($byteRange)) {
             $httpVer = '1.1';
         } else {
             $httpVer = '1.0';
         }
         $proxyAuth = null;
         if (!empty($proxyHost) && !empty($proxyPort)) {
             $connectHost = $proxyHost;
             $connectPort = $proxyPort;
             if (!empty($proxyUser) && !empty($proxyPassword)) {
                 $proxyAuth = 'Proxy-Authorization: Basic ' . base64_encode("{$proxyUser}:{$proxyPassword}") . "\r\n";
             }
             $requestHeader = "{$httpMethod} {$aUrl} HTTP/{$httpVer}\r\n";
         } else {
             $connectHost = $host;
             $connectPort = $port;
             $requestHeader = "{$httpMethod} {$path} HTTP/{$httpVer}\r\n";
         }
         // connection attempt
         if (($fsock = @fsockopen($connectHost, $connectPort, $errno, $errstr, $timeout)) === false || !is_resource($fsock)) {
             if (is_resource($file)) {
                 @fclose($file);
             }
             throw new Exception("Error while connecting to: {$host}. Please try again later. {$errstr}");
         }
         // send HTTP request header
         $requestHeader .= "Host: {$host}" . ($port != 80 ? ':' . $port : '') . "\r\n" . ($proxyAuth ? $proxyAuth : '') . 'User-Agent: ' . $userAgent . "\r\n" . ($acceptLanguage ? $acceptLanguage . "\r\n" : '') . $xff . "\r\n" . $via . "\r\n" . $rangeHeader . "Connection: close\r\n" . "\r\n";
         fwrite($fsock, $requestHeader);
         $streamMetaData = array('timed_out' => false);
         @stream_set_blocking($fsock, true);
         if (function_exists('stream_set_timeout')) {
             @stream_set_timeout($fsock, $timeout);
//.........这里部分代码省略.........
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:101,代码来源:Http.php

示例8: getAllProviderInfo

 /**
  * Returns an array mapping provider IDs w/ information about the provider,
  * for each location provider.
  *
  * The following information is provided for each provider:
  *   'id' - The provider's unique string ID.
  *   'title' - The provider's title.
  *   'description' - A description of how the location provider works.
  *   'status' - Either self::NOT_INSTALLED, self::INSTALLED or self::BROKEN.
  *   'statusMessage' - If the status is self::BROKEN, then the message describes why.
  *   'location' - A pretty formatted location of the current IP address
  *                (IP::getIpFromHeader()).
  *
  * An example result:
  * array(
  *     'geoip_php' => array('id' => 'geoip_php',
  *                          'title' => '...',
  *                          'desc' => '...',
  *                          'status' => GeoIp::BROKEN,
  *                          'statusMessage' => '...',
  *                          'location' => '...')
  *     'geoip_serverbased' => array(...)
  * )
  *
  * @param string $newline What to separate lines with in the pretty locations.
  * @param bool $includeExtra Whether to include ISP/Org info in formatted location.
  * @return array
  */
 public static function getAllProviderInfo($newline = "\n", $includeExtra = false)
 {
     $allInfo = array();
     foreach (self::getAllProviders() as $provider) {
         $info = $provider->getInfo();
         $status = self::INSTALLED;
         $location = false;
         $statusMessage = false;
         $availableOrMessage = $provider->isAvailable();
         if ($availableOrMessage !== true) {
             $status = self::NOT_INSTALLED;
             if (is_string($availableOrMessage)) {
                 $statusMessage = $availableOrMessage;
             }
         } else {
             $workingOrError = $provider->isWorking();
             if ($workingOrError === true) {
                 $locInfo = array('ip' => IP::getIpFromHeader(), 'lang' => Common::getBrowserLanguage(), 'disable_fallbacks' => true);
                 $location = $provider->getLocation($locInfo);
                 $location = self::prettyFormatLocation($location, $newline, $includeExtra);
             } else {
                 $status = self::BROKEN;
                 $statusMessage = $workingOrError;
             }
         }
         $info['status'] = $status;
         $info['statusMessage'] = $statusMessage;
         $info['location'] = $location;
         $allInfo[$info['order']] = $info;
     }
     ksort($allInfo);
     $result = array();
     foreach ($allInfo as $info) {
         $result[$info['id']] = $info;
     }
     return $result;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:65,代码来源:LocationProvider.php

示例9: getIpString

 /**
  * @return mixed|string
  * @throws Exception
  */
 public function getIpString()
 {
     $cip = $this->getParam('cip');
     if (empty($cip)) {
         return IP::getIpFromHeader();
     }
     if (!$this->isAuthenticated()) {
         Common::printDebug("WARN: Tracker API 'cip' was used with invalid token_auth");
         return IP::getIpFromHeader();
     }
     return $cip;
 }
开发者ID:normimuc,项目名称:piwik,代码行数:16,代码来源:Request.php

示例10: fopen

        }
    }
    $f = fopen($clickheatConf['logPath'] . $final . '/' . date('Y-m-d') . '.log', 'a');
}
if (is_resource($f)) {
    $logMe = true;
    if (isset($_COOKIE['clickheat-admin'])) {
        echo 'OK, but click not logged as you selected it in the admin panel ("Log my clicks/Enregistrer mes clics")';
        $logMe = false;
    } elseif (IS_PIWIK_MODULE === true) {
        $site = (string) (int) $site;
        // prevents path injection
        if (file_exists(PIWIK_INCLUDE_PATH . '/tmp/cache/tracker/' . $site . '.php')) {
            require_once PIWIK_INCLUDE_PATH . '/tmp/cache/tracker/' . $site . '.php';
            if (isset($content['excluded_ips'])) {
                $ip = IPUtils::stringToBinaryIP(\Piwik\Network\IP::fromStringIP(IP::getIpFromHeader()));
                if (isIpInRange($ip, $content['excluded_ips']) === true) {
                    echo 'OK, but click not logged as you prevent this IP to be tracked in Piwik\'s configuration';
                    $logMe = false;
                }
            }
        }
    }
    if ($logMe === true) {
        echo 'OK';
        fputs($f, (int) $_GET['x'] . '|' . (int) $_GET['y'] . '|' . (int) $_GET['w'] . '|' . $browser . '|' . (int) $_GET['c'] . "\n");
    }
    fclose($f);
} else {
    echo 'KO, file not writable';
}
开发者ID:NikitaEgorov,项目名称:plugin-clickheat,代码行数:31,代码来源:click.php

示例11: sendEmailConfirmationLink

 /**
  * Sends email confirmation link for a password reset request.
  *
  * @param array $user User info for the requested password reset.
  */
 private function sendEmailConfirmationLink($user)
 {
     $login = $user['login'];
     $email = $user['email'];
     // construct a password reset token from user information
     $resetToken = self::generatePasswordResetToken($user);
     $ip = IP::getIpFromHeader();
     $url = Url::getCurrentUrlWithoutQueryString() . "?module=Login&action=confirmResetPassword&login=" . urlencode($login) . "&resetToken=" . urlencode($resetToken);
     // send email with new password
     $mail = new Mail();
     $mail->addTo($email, $login);
     $mail->setSubject(Piwik::translate('Login_MailTopicPasswordChange'));
     $bodyText = str_replace('\\n', "\n", sprintf(Piwik::translate('Login_MailPasswordChangeBody'), $login, $ip, $url)) . "\n";
     $mail->setBodyText($bodyText);
     $fromEmailName = Config::getInstance()->General['login_password_recovery_email_name'];
     $fromEmailAddress = Config::getInstance()->General['login_password_recovery_email_address'];
     $mail->setFrom($fromEmailAddress, $fromEmailName);
     $replytoEmailName = Config::getInstance()->General['login_password_recovery_replyto_email_name'];
     $replytoEmailAddress = Config::getInstance()->General['login_password_recovery_replyto_email_address'];
     $mail->setReplyTo($replytoEmailAddress, $replytoEmailName);
     @$mail->send();
 }
开发者ID:bnkems,项目名称:piwik,代码行数:27,代码来源:Controller.php

示例12: getDefaultIp

 private function getDefaultIp()
 {
     return IP::getIpFromHeader();
 }
开发者ID:ThaDafinser,项目名称:Piwik-GeoIpChain,代码行数:4,代码来源:Controller.php

示例13: getLocationUsingProvider

 /**
  * Echo's a pretty formatted location using a specific LocationProvider.
  *
  * Input:
  *   The 'id' query parameter must be set to the ID of the LocationProvider to use.
  *
  * Output:
  *   The pretty formatted location that was obtained. Will be HTML.
  */
 public function getLocationUsingProvider()
 {
     $providerId = Common::getRequestVar('id');
     $provider = LocationProvider::getProviderById($providerId);
     if (empty($provider)) {
         throw new Exception("Invalid provider ID: '{$providerId}'.");
     }
     $location = $provider->getLocation(array('ip' => IP::getIpFromHeader(), 'lang' => Common::getBrowserLanguage(), 'disable_fallbacks' => true));
     $location = LocationProvider::prettyFormatLocation($location, $newline = '<br/>', $includeExtra = true);
     return $location;
 }
开发者ID:piwik,项目名称:piwik,代码行数:20,代码来源:Controller.php

示例14: getIpFromHeader

 /**
  * Returns the most accurate IP address availble for the current user, in
  * IPv4 format. This could be the proxy client's IP address.
  *
  * @return string IP address in presentation format.
  */
 public function getIpFromHeader()
 {
     Piwik::checkUserHasSomeViewAccess();
     return IP::getIpFromHeader();
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:11,代码来源:API.php

示例15: makeExcludeIps

 private function makeExcludeIps()
 {
     return $this->makeProperty('excluded_ips', $default = array(), FieldConfig::TYPE_ARRAY, function (FieldConfig $field) {
         $ip = IP::getIpFromHeader();
         $field->title = Piwik::translate('SitesManager_ExcludedIps');
         $field->inlineHelp = Piwik::translate('SitesManager_HelpExcludedIps', array('1.2.3.*', '1.2.*.*')) . '<br /><br />' . Piwik::translate('SitesManager_YourCurrentIpAddressIs', array('<i>' . $ip . '</i>'));
         $field->uiControl = FieldConfig::UI_CONTROL_TEXTAREA;
         $field->uiControlAttributes = array('cols' => '20', 'rows' => '4');
         $field->validate = function ($value) {
             if (!empty($value)) {
                 $ips = array_map('trim', $value);
                 $ips = array_filter($ips, 'strlen');
                 foreach ($ips as $ip) {
                     if (IPUtils::getIPRangeBounds($ip) === null) {
                         throw new Exception(Piwik::translate('SitesManager_ExceptionInvalidIPFormat', array($ip, "1.2.3.4, 1.2.3.*, or 1.2.3.4/5")));
                     }
                 }
             }
         };
         $field->transform = function ($value) {
             if (empty($value)) {
                 return array();
             }
             $ips = array_map('trim', $value);
             $ips = array_filter($ips, 'strlen');
             return $ips;
         };
     });
 }
开发者ID:piwik,项目名称:piwik,代码行数:29,代码来源:MeasurableSettings.php


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