You are here

protected function LingotekOAuthRequest::parseUri in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.7 lib/oauth-php/library/LingotekOAuthRequest.php \LingotekOAuthRequest::parseUri()
  2. 7.5 lib/oauth-php/library/LingotekOAuthRequest.php \LingotekOAuthRequest::parseUri()
  3. 7.6 lib/oauth-php/library/LingotekOAuthRequest.php \LingotekOAuthRequest::parseUri()

* Parse the uri into its parts. Fill in the missing parts. * *

Parameters

string $parameters optional extra parameters (from eg the http post):

1 call to LingotekOAuthRequest::parseUri()
LingotekOAuthRequest::__construct in lib/oauth-php/library/LingotekOAuthRequest.php
* Construct from the current request. Useful for checking the signature of a request. * When not supplied with any parameters this will use the current request. * *

File

lib/oauth-php/library/LingotekOAuthRequest.php, line 509

Class

LingotekOAuthRequest
Object to parse an incoming OAuth request or prepare an outgoing OAuth request

Code

protected function parseUri($parameters) {
  $ps = @parse_url($this->uri);

  // Get the current/requested method
  $ps['scheme'] = strtolower($ps['scheme']);

  // Get the current/requested host
  if (function_exists('mb_strtolower')) {
    $ps['host'] = mb_strtolower($ps['host']);
  }
  else {
    $ps['host'] = strtolower($ps['host']);
  }
  if (!preg_match('/^[a-z0-9\\.\\-]+$/', $ps['host'])) {
    throw new OAuthException2('Unsupported characters in host name');
  }

  // Get the port we are talking on
  if (empty($ps['port'])) {
    $ps['port'] = $this
      ->defaultPortForScheme($ps['scheme']);
  }
  if (empty($ps['user'])) {
    $ps['user'] = '';
  }
  if (empty($ps['pass'])) {
    $ps['pass'] = '';
  }
  if (empty($ps['path'])) {
    $ps['path'] = '/';
  }
  if (empty($ps['query'])) {
    $ps['query'] = '';
  }
  if (empty($ps['fragment'])) {
    $ps['fragment'] = '';
  }

  // Now all is complete - parse all parameters
  foreach (array(
    $ps['query'],
    $parameters,
  ) as $params) {
    if (strlen($params) > 0) {
      $params = explode('&', $params);
      foreach ($params as $p) {
        @(list($name, $value) = explode('=', $p, 2));
        if (!strlen($name)) {
          continue;
        }
        if (array_key_exists($name, $this->param)) {
          if (is_array($this->param[$name])) {
            $this->param[$name][] = $value;
          }
          else {
            $this->param[$name] = array(
              $this->param[$name],
              $value,
            );
          }
        }
        else {
          $this->param[$name] = $value;
        }
      }
    }
  }
  $this->uri_parts = $ps;
}