original_string: protected static function resolveRelativeURL($url)
      {
          $https  = !empty($_SERVER['HTTPS']) && ('off' != strtolower($_SERVER['HTTPS']));
          $scheme = ($https? 'https:': 'http:');
          if ('//' == substr($url, 0, 2)) {
              return $scheme . $url;
  
          } else {
              $host   = $scheme . '//' . $_SERVER['SERVER_NAME'] .
                        (($https && 443 == $_SERVER['SERVER_PORT'] ||
                          !$https && 80 == $_SERVER['SERVER_PORT'])? '': ':' . $_SERVER['SERVER_PORT']);
              if ('' == $url) {
                  return $host . $_SERVER['REQUEST_URI'];
  
              } elseif ('/' == $url[0]) {
                  list($actPath, $actQuery) = self::splitUri($url);
                  return $host . self::normalizePath($actPath) . $actQuery;
  
              } else {
                  list($basePath, $baseQuery) = self::splitUri($_SERVER['REQUEST_URI']);
                  list($actPath, $actQuery)   = self::splitUri($url);
                  if ('' == $actPath) {
                      return $host . $basePath . $actQuery;
                  } else {
                      $path = substr($basePath, 0, strrpos($basePath, '/') + 1) . $actPath;
                      return $host . self::normalizePath($path) . $actQuery;
                  }
              }
          }
      }
code: protected static function resolveRelativeURL($url)
      {
          $https  = !empty($_SERVER['HTTPS']) && ('off' != strtolower($_SERVER['HTTPS']));
          $scheme = ($https? 'https:': 'http:');
          if ('//' == substr($url, 0, 2)) {
              return $scheme . $url;
  
          } else {
              $host   = $scheme . '//' . $_SERVER['SERVER_NAME'] .
                        (($https && 443 == $_SERVER['SERVER_PORT'] ||
                          !$https && 80 == $_SERVER['SERVER_PORT'])? '': ':' . $_SERVER['SERVER_PORT']);
              if ('' == $url) {
                  return $host . $_SERVER['REQUEST_URI'];
  
              } elseif ('/' == $url[0]) {
                  list($actPath, $actQuery) = self::splitUri($url);
                  return $host . self::normalizePath($actPath) . $actQuery;
  
              } else {
                  list($basePath, $baseQuery) = self::splitUri($_SERVER['REQUEST_URI']);
                  list($actPath, $actQuery)   = self::splitUri($url);
                  if ('' == $actPath) {
                      return $host . $basePath . $actQuery;
                  } else {
                      $path = substr($basePath, 0, strrpos($basePath, '/') + 1) . $actPath;
                      return $host . self::normalizePath($path) . $actQuery;
                  }
              }
          }
      }
code_tokens: protected static function resolveRelativeURL ( $ url ) { $ https = ! empty ( $ _SERVER [ 'HTTPS' ] ) && ( 'off' != strtolower ( $ _SERVER [ 'HTTPS' ] ) ) ; $ scheme = ( $ https ? 'https:' : 'http:' ) ; if ( '//' == substr ( $ url , 0 , 2 ) ) { return $ scheme . $ url ; } else { $ host = $ scheme . '//' . $ _SERVER [ 'SERVER_NAME' ] . ( ( $ https && 443 == $ _SERVER [ 'SERVER_PORT' ] || ! $ https && 80 == $ _SERVER [ 'SERVER_PORT' ] ) ? '' : ':' . $ _SERVER [ 'SERVER_PORT' ] ) ; if ( '' == $ url ) { return $ host . $ _SERVER [ 'REQUEST_URI' ] ; } elseif ( '/' == $ url [ 0 ] ) { list ( $ actPath , $ actQuery ) = self :: splitUri ( $ url ) ; return $ host . self :: normalizePath ( $ actPath ) . $ actQuery ; } else { list ( $ basePath , $ baseQuery ) = self :: splitUri ( $ _SERVER [ 'REQUEST_URI' ] ) ; list ( $ actPath , $ actQuery ) = self :: splitUri ( $ url ) ; if ( '' == $ actPath ) { return $ host . $ basePath . $ actQuery ; } else { $ path = substr ( $ basePath , 0 , strrpos ( $ basePath , '/' ) + 1 ) . $ actPath ; return $ host . self :: normalizePath ( $ path ) . $ actQuery ; } } } }
docstring: Resolves relative URL using current page's URL as base
  
  The method follows procedure described in section 4 of RFC 1808 and
  passes the examples provided in section 5 of said RFC. Values from
  $_SERVER array are used for calculation of "current URL"
  
  @param    string  Relative URL, probably from form's action attribute
  @return   string  Absolute URL
docstring_tokens: Resolves relative URL using current page s URL as base