示例#1
0
 /**
  * Is the URL on the same host and in the same script path?
  *
  * @param string $url
  * @return bool True if local; false otherwise.
  */
 public static function isLocalUrl($url)
 {
     // handle case-sensitivity differences
     $pathContains = Core_Common::isWindows() ? 'stripos' : 'strpos';
     // test the scheme/protocol portion of the reconstructed "current" URL
     if (!strncasecmp($url, 'http://', 7) || !strncasecmp($url, 'https://', 8)) {
         // determine the offset to begin the comparison
         $offset = strpos($url, '://');
         $current = strstr(self::getCurrentUrlWithoutFileName(), '://');
         if ($pathContains($url, $current, $offset) === $offset) {
             return true;
         }
     }
     return false;
 }