Esempio n. 1
0
 /**
  * Determine if the the passed url is external to the current running platform
  *
  * @param RokUpdater_Uri $uri
  *
  * @return mixed
  */
 public function isExternal($uri)
 {
     if (is_string($uri)) {
         $uri = new RokUpdater_Uri($uri);
     }
     if (@file_exists($uri->getComponents(RokUpdater_Uri_Components::PATH, RokUpdater_Uri_Builder::FORMAT_RAW))) {
         return false;
     }
     //if the url does not have a scheme must be internal
     if (is_null($uri->getHost())) {
         return false;
     }
     if ($uri->getHost() == $this->site_uri->getHost()) {
         if ($uri->getPort() === RokUpdater_Uri::PORT_UNDEFINED) {
             return false;
         }
         if ($uri->getPort() === $this->site_uri->getPort()) {
             return false;
         }
     }
     // if its a vfs url its a unit test and local
     if ($uri->getScheme() == 'vfs') {
         return false;
     }
     //the url has a host and it isn't internal
     return true;
 }
Esempio n. 2
0
 /**
  * @param  RokUpdater_Uri   $uri
  * @param  array $components
  * @param  bool  $esc
  *
  * @return string
  */
 private static function getAbsoluteComponents(RokUpdater_Uri $uri, $components, $esc)
 {
     $result = '';
     if ($components & RokUpdater_Uri_Components::SCHEME) {
         $cmp = $uri->getScheme();
         if (!empty($cmp)) {
             $result .= "{$cmp}:";
         }
     }
     // AUTHORITY_START:
     if ($components & RokUpdater_Uri_Components::AUTHORITY_START) {
         $result .= "//";
     }
     //USER_INFO:
     if ($components & RokUpdater_Uri_Components::USERINFO) {
         $cmp = $uri->getUserInfo();
         if (!empty($cmp)) {
             if ($esc && strpos($cmp, ':') !== false) {
                 $parts = explode(':', $cmp, 2);
                 $result .= rawurlencode($parts[0]) . ':' . rawurlencode($parts[1]);
             } else {
                 if ($esc) {
                     $result .= rawurlencode($cmp);
                 } else {
                     $result .= $cmp;
                 }
             }
             $result .= '@';
         }
     }
     //HOST:
     if ($components & RokUpdater_Uri_Components::HOST) {
         $cmp = $uri->getHost();
         if (!empty($cmp)) {
             $result .= $cmp;
         }
     }
     //PORT:
     if ($components & RokUpdater_Uri_Components::STRONG_PORT || $components & RokUpdater_Uri_Components::PORT) {
         $cmp = $uri->getPort();
         if (!($cmp === -1 || $components & RokUpdater_Uri_Components::PORT && $uri->isDefaultPort())) {
             $result .= ":{$cmp}";
         }
     }
     return $result;
 }