Ejemplo n.º 1
0
 /**
  * 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.
  *
  * @param string	uri				might include parameters
  * @param string	method			GET, PUT, POST etc.
  * @param string	parameters		additional post parameters, urlencoded (RFC1738)
  * @param array		headers			headers for request
  * @param string	body			optional body of the OAuth request (POST or PUT)
  */
 function __construct($uri = null, $method = null, $parameters = '', $headers = array(), $body = null)
 {
     if (is_object($_SERVER)) {
         // Tainted arrays - the normal stuff in anyMeta
         if (!$method) {
             $method = $_SERVER->REQUEST_METHOD->getRawUnsafe();
         }
         if (empty($uri)) {
             $uri = $_SERVER->REQUEST_URI->getRawUnsafe();
         }
     } else {
         // non anyMeta systems
         if (!$method) {
             if (isset($_SERVER['REQUEST_METHOD'])) {
                 $method = $_SERVER['REQUEST_METHOD'];
             } else {
                 $method = 'GET';
             }
         }
         $proto = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
         if (empty($uri)) {
             if (strpos($_SERVER['REQUEST_URI'], "://") !== false) {
                 $uri = $_SERVER['REQUEST_URI'];
             } else {
                 $uri = sprintf('%s://%s%s', $proto, $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
             }
         }
     }
     $headers = OAuthRequestLogger::getAllHeaders();
     $this->method = strtoupper($method);
     // If this is a post then also check the posted variables
     if (strcasecmp($method, 'POST') == 0) {
         // TODO: what to do with 'multipart/form-data'?
         if ($this->getRequestContentType() == 'multipart/form-data') {
             // Get the posted body (when available)
             if (!isset($headers['X-OAuth-Test'])) {
                 $parameters .= $this->getRequestBodyOfMultipart();
             }
         }
         if ($this->getRequestContentType() == 'application/x-www-form-urlencoded') {
             // Get the posted body (when available)
             if (!isset($headers['X-OAuth-Test'])) {
                 $parameters .= $this->getRequestBody();
             }
         } else {
             $body = $this->getRequestBody();
         }
     } else {
         if (strcasecmp($method, 'PUT') == 0) {
             $body = $this->getRequestBody();
         }
     }
     $this->method = strtoupper($method);
     $this->headers = $headers;
     // Store the values, prepare for oauth
     $this->uri = $uri;
     $this->body = $body;
     $this->parseUri($parameters);
     $this->parseHeaders();
     $this->transcodeParams();
 }
Ejemplo n.º 2
0
 function __construct($message)
 {
     Exception::__construct($message);
     OAuthRequestLogger::addNote('OAuthException2: ' . $message);
 }