예제 #1
0
파일: IP.php 프로젝트: oyoy8629/yii-core
 /**
  * Returns the last IP address in a comma separated list, subject to an optional exclusion list.
  *
  * @param string $csv Comma separated list of elements.
  * @param array $excludedIps Optional list of excluded IP addresses (or IP address ranges).
  * @return string Last (non-excluded) IP address in the list or an empty string if all given IPs are excluded.
  */
 public static function getLastIpFromList($csv, $excludedIps = null)
 {
     $p = strrpos($csv, ',');
     if ($p !== false) {
         $elements = explode(',', $csv);
         for ($i = count($elements); $i--;) {
             $element = trim(Common::sanitizeInputValue($elements[$i]));
             $ip = \Piwik\Network\IP::fromStringIP(IPUtils::sanitizeIp($element));
             if (empty($excludedIps) || !in_array($element, $excludedIps) && !$ip->isInRanges($excludedIps)) {
                 return $element;
             }
         }
         return '';
     }
     return trim(Common::sanitizeInputValue($csv));
 }
예제 #2
0
파일: Url.php 프로젝트: mgou-net/piwik
 /**
  * Returns hostname, without port numbers
  *
  * @param $host
  * @return array
  */
 public static function getHostSanitized($host)
 {
     if (!class_exists("Piwik\\Network\\IPUtils")) {
         throw new Exception("Piwik\\Network\\IPUtils could not be found, maybe you are using Piwik from git and need to update Composer. \$ php composer.phar update");
     }
     return IPUtils::sanitizeIp($host);
 }