C:\xampp\htdocs\landing\wp-content\plugins\updraftplus\vendor\eher\oauth\src\Eher\OAuth\Request.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?php

namespace Eher\OAuth;

class 
Request {
  protected 
$parameters;
  protected 
$http_method;
  protected 
$http_url;
  
// for debug purposes
  
public $base_string;
  public static 
$version '1.0';
  public static 
$POST_INPUT 'php://input';

  function 
__construct($http_method$http_url$parameters=NULL) {
    
$parameters = ($parameters) ? $parameters : array();
    
$parameters array_mergeUtil::parse_parameters(parse_url($http_urlPHP_URL_QUERY)), $parameters);
    
$this->parameters $parameters;
    
$this->http_method $http_method;
    
$this->http_url $http_url;
  }


  
/**
   * attempt to build up a request from what was passed to the server
   */
  
public static function from_request($http_method=NULL$http_url=NULL$parameters=NULL) {
    
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
              ? 
'http'
              
'https';
    
$http_url = ($http_url) ? $http_url $scheme .
                              
'://' $_SERVER['HTTP_HOST'] .
                              
':' .
                              
$_SERVER['SERVER_PORT'] .
                              
$_SERVER['REQUEST_URI'];
    
$http_method = ($http_method) ? $http_method $_SERVER['REQUEST_METHOD'];

    
// We weren't handed any parameters, so let's find the ones relevant to
    // this request.
    // If you run XML-RPC or similar you should use this to provide your own
    // parsed parameter-list
    
if (!$parameters) {
      
// Find request headers
      
$request_headers Util::get_headers();

      
// Parse the query-string to find GET parameters
      
$parameters Util::parse_parameters($_SERVER['QUERY_STRING']);

      
// It's a POST request of the proper content-type, so parse POST
      // parameters and add those overriding any duplicates from GET
      
if ($http_method == "POST"
          
&&  isset($request_headers['Content-Type'])
          && 
strstr($request_headers['Content-Type'],
                     
'application/x-www-form-urlencoded')
          ) {
        
$post_data Util::parse_parameters(
          
file_get_contents(self::$POST_INPUT)
        );
        
$parameters array_merge($parameters$post_data);
      }

      
// We have a Authorization-header with OAuth data. Parse the header
      // and add those overriding any duplicates from GET or POST
      
if (isset($request_headers['Authorization']) && substr($request_headers['Authorization'], 06) == 'OAuth ') {
        
$header_parameters Util::split_header(
          
$request_headers['Authorization']
        );
        
$parameters array_merge($parameters$header_parameters);
      }

    }

    return new 
Request($http_method$http_url$parameters);
  }

  
/**
   * pretty much a helper function to set up the request
   */
  
public static function from_consumer_and_token($consumer$token$http_method$http_url$parameters=NULL) {
    
$parameters = ($parameters) ?  $parameters : array();
    
$defaults = array("oauth_version" => Request::$version,
                      
"oauth_nonce" => Request::generate_nonce(),
                      
"oauth_timestamp" => Request::generate_timestamp(),
                      
"oauth_consumer_key" => $consumer->key);
    if (
$token)
      
$defaults['oauth_token'] = $token->key;

    
$parameters array_merge($defaults$parameters);

    return new 
Request($http_method$http_url$parameters);
  }

  public function 
set_parameter($name$value$allow_duplicates true) {
    if (
$allow_duplicates && isset($this->parameters[$name])) {
      
// We have already added parameter(s) with this name, so add to the list
      
if (is_scalar($this->parameters[$name])) {
        
// This is the first duplicate, so transform scalar (string)
        // into an array so we can add the duplicates
        
$this->parameters[$name] = array($this->parameters[$name]);
      }

      
$this->parameters[$name][] = $value;
    } else {
      
$this->parameters[$name] = $value;
    }
  }

  public function 
get_parameter($name) {
    return isset(
$this->parameters[$name]) ? $this->parameters[$name] : null;
  }

  public function 
get_parameters() {
    return 
$this->parameters;
  }

  public function 
unset_parameter($name) {
    unset(
$this->parameters[$name]);
  }

  
/**
   * The request parameters, sorted and concatenated into a normalized string.
   * @return string
   */
  
public function get_signable_parameters() {
    
// Grab all parameters
    
$params $this->parameters;

    
// Remove oauth_signature if present
    // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
    
if (isset($params['oauth_signature'])) {
      unset(
$params['oauth_signature']);
    }

    return 
Util::build_http_query($params);
  }

  
/**
   * Returns the base string of this request
   *
   * The base string defined as the method, the url
   * and the parameters (normalized), each urlencoded
   * and the concated with &.
   */
  
public function get_signature_base_string() {
    
$parts = array(
      
$this->get_normalized_http_method(),
      
$this->get_normalized_http_url(),
      
$this->get_signable_parameters()
    );

    
$parts Util::urlencode_rfc3986($parts);

    return 
implode('&'$parts);
  }

  
/**
   * just uppercases the http method
   */
  
public function get_normalized_http_method() {
    return 
strtoupper($this->http_method);
  }

  
/**
   * parses the url and rebuilds it to be
   * scheme://host/path
   */
  
public function get_normalized_http_url() {
    
$parts parse_url($this->http_url);

    
$scheme = (isset($parts['scheme'])) ? $parts['scheme'] : 'http';
    
$port = (isset($parts['port'])) ? $parts['port'] : (($scheme == 'https') ? '443' '80');
    
$host = (isset($parts['host'])) ? $parts['host'] : '';
    
$path = (isset($parts['path'])) ? $parts['path'] : '';

    if ((
$scheme == 'https' && $port != '443')
        || (
$scheme == 'http' && $port != '80')) {
      
$host "$host:$port";
    }
    return 
"$scheme://$host$path";
  }

  
/**
   * builds a url usable for a GET request
   */
  
public function to_url() {
    
$post_data $this->to_postdata();
    
$out $this->get_normalized_http_url();
    if (
$post_data) {
      
$out .= '?'.$post_data;
    }
    return 
$out;
  }

  
/**
   * builds the data one would send in a POST request
   */
  
public function to_postdata() {
    return 
Util::build_http_query($this->parameters);
  }

  
/**
   * builds the Authorization: header
   */
  
public function to_header($realm=null) {
    
$first true;
    if(
$realm) {
      
$out 'Authorization: OAuth realm="' Util::urlencode_rfc3986($realm) . '"';
      
$first false;
    } else
      
$out 'Authorization: OAuth';

    
$total = array();
    foreach (
$this->parameters as $k => $v) {
      if (
substr($k05) != "oauth") continue;
      if (
is_array($v)) {
        throw new 
OAuthException('Arrays not supported in headers');
      }
      
$out .= ($first) ? ' ' ',';
      
$out .= Util::urlencode_rfc3986($k) .
              
'="' .
              
Util::urlencode_rfc3986($v) .
              
'"';
      
$first false;
    }
    return 
$out;
  }

  public function 
__toString() {
    return 
$this->to_url();
  }


  public function 
sign_request($signature_method$consumer$token) {
    
$this->set_parameter(
      
"oauth_signature_method",
      
$signature_method->get_name(),
      
false
    
);
    
$signature $this->build_signature($signature_method$consumer$token);
    
$this->set_parameter("oauth_signature"$signaturefalse);
  }

  public function 
build_signature($signature_method$consumer$token) {
    
$signature $signature_method->build_signature($this$consumer$token);
    return 
$signature;
  }

  
/**
   * util function: current timestamp
   */
  
private static function generate_timestamp() {
    return 
time();
  }

  
/**
   * util function: current nonce
   */
  
private static function generate_nonce() {
    
$mt microtime();
    
$rand mt_rand();

    return 
md5($mt $rand); // md5s look nicer than numbers
  
}
}

x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586