| 1 |
lars |
1 |
<?php
|
|
|
2 |
/*
|
|
|
3 |
* Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
|
4 |
*
|
|
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License").
|
|
|
6 |
* You may not use this file except in compliance with the License.
|
|
|
7 |
* A copy of the License is located at
|
|
|
8 |
*
|
|
|
9 |
* http://aws.amazon.com/apache2.0
|
|
|
10 |
*
|
|
|
11 |
* or in the "license" file accompanying this file. This file is distributed
|
|
|
12 |
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
|
13 |
* express or implied. See the License for the specific language governing
|
|
|
14 |
* permissions and limitations under the License.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
/*%******************************************************************************************%*/
|
|
|
19 |
// EXCEPTIONS
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Default CFRuntime Exception.
|
|
|
23 |
*/
|
|
|
24 |
class CFRuntime_Exception extends Exception {}
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* Parsing Exception.
|
|
|
28 |
*/
|
|
|
29 |
class Parser_Exception extends Exception {}
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
/*%******************************************************************************************%*/
|
|
|
33 |
// DETERMINE WHAT ENVIRONMENT DATA TO ADD TO THE USERAGENT FOR METRIC TRACKING
|
|
|
34 |
|
|
|
35 |
/*
|
|
|
36 |
Define a temporary callback function for this calculation. Get the PHP version and any
|
|
|
37 |
required/optional extensions that are leveraged.
|
|
|
38 |
|
|
|
39 |
Tracking this data gives Amazon better metrics about what configurations are being used
|
|
|
40 |
so that forward-looking plans for the code can be made with more certainty (e.g. What
|
|
|
41 |
version of PHP are most people running? Do they tend to have the latest PCRE?).
|
|
|
42 |
*/
|
|
|
43 |
function __aws_sdk_ua_callback()
|
|
|
44 |
{
|
|
|
45 |
$ua_append = '';
|
|
|
46 |
$extensions = get_loaded_extensions();
|
|
|
47 |
$sorted_extensions = array();
|
|
|
48 |
|
|
|
49 |
if ($extensions)
|
|
|
50 |
{
|
|
|
51 |
foreach ($extensions as $extension)
|
|
|
52 |
{
|
|
|
53 |
if ($extension === 'curl' && function_exists('curl_version'))
|
|
|
54 |
{
|
|
|
55 |
$curl_version = curl_version();
|
|
|
56 |
$sorted_extensions[strtolower($extension)] = $curl_version['version'];
|
|
|
57 |
}
|
|
|
58 |
elseif ($extension === 'pcre' && defined('PCRE_VERSION'))
|
|
|
59 |
{
|
|
|
60 |
$pcre_version = explode(' ', PCRE_VERSION);
|
|
|
61 |
$sorted_extensions[strtolower($extension)] = $pcre_version[0];
|
|
|
62 |
}
|
|
|
63 |
elseif ($extension === 'openssl' && defined('OPENSSL_VERSION_TEXT'))
|
|
|
64 |
{
|
|
|
65 |
$openssl_version = explode(' ', OPENSSL_VERSION_TEXT);
|
|
|
66 |
$sorted_extensions[strtolower($extension)] = $openssl_version[1];
|
|
|
67 |
}
|
|
|
68 |
else
|
|
|
69 |
{
|
|
|
70 |
$sorted_extensions[strtolower($extension)] = phpversion($extension);
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
foreach (array('simplexml', 'json', 'pcre', 'spl', 'curl', 'openssl', 'apc', 'xcache', 'memcache', 'memcached', 'pdo', 'pdo_sqlite', 'sqlite', 'sqlite3', 'zlib', 'xdebug') as $ua_ext)
|
|
|
76 |
{
|
|
|
77 |
if (isset($sorted_extensions[$ua_ext]) && $sorted_extensions[$ua_ext])
|
|
|
78 |
{
|
|
|
79 |
$ua_append .= ' ' . $ua_ext . '/' . $sorted_extensions[$ua_ext];
|
|
|
80 |
}
|
|
|
81 |
elseif (isset($sorted_extensions[$ua_ext]))
|
|
|
82 |
{
|
|
|
83 |
$ua_append .= ' ' . $ua_ext . '/0';
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
foreach (array('memory_limit', 'date.timezone', 'open_basedir', 'safe_mode', 'zend.enable_gc') as $cfg)
|
|
|
88 |
{
|
|
|
89 |
$cfg_value = ini_get($cfg);
|
|
|
90 |
|
|
|
91 |
if (in_array($cfg, array('memory_limit', 'date.timezone'), true))
|
|
|
92 |
{
|
|
|
93 |
$ua_append .= ' ' . $cfg . '/' . str_replace('/', '.', $cfg_value);
|
|
|
94 |
}
|
|
|
95 |
elseif (in_array($cfg, array('open_basedir', 'safe_mode', 'zend.enable_gc'), true))
|
|
|
96 |
{
|
|
|
97 |
if ($cfg_value === false || $cfg_value === '' || $cfg_value === 0)
|
|
|
98 |
{
|
|
|
99 |
$cfg_value = 'off';
|
|
|
100 |
}
|
|
|
101 |
elseif ($cfg_value === true || $cfg_value === '1' || $cfg_value === 1)
|
|
|
102 |
{
|
|
|
103 |
$cfg_value = 'on';
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
$ua_append .= ' ' . $cfg . '/' . $cfg_value;
|
|
|
107 |
}
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
return $ua_append;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
/*%******************************************************************************************%*/
|
|
|
115 |
// INTERMEDIARY CONSTANTS
|
|
|
116 |
|
|
|
117 |
define('CFRUNTIME_NAME', 'aws-sdk-php');
|
|
|
118 |
define('CFRUNTIME_VERSION', '1.5.3');
|
|
|
119 |
// define('CFRUNTIME_BUILD', gmdate('YmdHis', filemtime(__FILE__))); // @todo: Hardcode for release.
|
|
|
120 |
define('CFRUNTIME_BUILD', '20120222005519');
|
|
|
121 |
define('CFRUNTIME_USERAGENT', CFRUNTIME_NAME . '/' . CFRUNTIME_VERSION . ' PHP/' . PHP_VERSION . ' ' . str_replace(' ', '_', php_uname('s')) . '/' . str_replace(' ', '_', php_uname('r')) . ' Arch/' . php_uname('m') . ' SAPI/' . php_sapi_name() . ' Integer/' . PHP_INT_MAX . ' Build/' . CFRUNTIME_BUILD . __aws_sdk_ua_callback());
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
/*%******************************************************************************************%*/
|
|
|
125 |
// CLASS
|
|
|
126 |
|
|
|
127 |
/**
|
|
|
128 |
* Core functionality and default settings shared across all SDK classes. All methods and properties in this
|
|
|
129 |
* class are inherited by the service-specific classes.
|
|
|
130 |
*
|
|
|
131 |
* @version 2012.02.21
|
|
|
132 |
* @license See the included NOTICE.md file for more information.
|
|
|
133 |
* @copyright See the included NOTICE.md file for more information.
|
|
|
134 |
* @link http://aws.amazon.com/php/ PHP Developer Center
|
|
|
135 |
*/
|
|
|
136 |
class CFRuntime
|
|
|
137 |
{
|
|
|
138 |
/*%******************************************************************************************%*/
|
|
|
139 |
// CONSTANTS
|
|
|
140 |
|
|
|
141 |
/**
|
|
|
142 |
* Name of the software.
|
|
|
143 |
*/
|
|
|
144 |
const NAME = CFRUNTIME_NAME;
|
|
|
145 |
|
|
|
146 |
/**
|
|
|
147 |
* Version of the software.
|
|
|
148 |
*/
|
|
|
149 |
const VERSION = CFRUNTIME_VERSION;
|
|
|
150 |
|
|
|
151 |
/**
|
|
|
152 |
* Build ID of the software.
|
|
|
153 |
*/
|
|
|
154 |
const BUILD = CFRUNTIME_BUILD;
|
|
|
155 |
|
|
|
156 |
/**
|
|
|
157 |
* User agent string used to identify the software.
|
|
|
158 |
*/
|
|
|
159 |
const USERAGENT = CFRUNTIME_USERAGENT;
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
/*%******************************************************************************************%*/
|
|
|
163 |
// PROPERTIES
|
|
|
164 |
|
|
|
165 |
/**
|
|
|
166 |
* The Amazon API Key.
|
|
|
167 |
*/
|
|
|
168 |
public $key;
|
|
|
169 |
|
|
|
170 |
/**
|
|
|
171 |
* The Amazon API Secret Key.
|
|
|
172 |
*/
|
|
|
173 |
public $secret_key;
|
|
|
174 |
|
|
|
175 |
/**
|
|
|
176 |
* The Amazon Authentication Token.
|
|
|
177 |
*/
|
|
|
178 |
public $auth_token;
|
|
|
179 |
|
|
|
180 |
/**
|
|
|
181 |
* Handle for the utility functions.
|
|
|
182 |
*/
|
|
|
183 |
public $util;
|
|
|
184 |
|
|
|
185 |
/**
|
|
|
186 |
* An identifier for the current AWS service.
|
|
|
187 |
*/
|
|
|
188 |
public $service = null;
|
|
|
189 |
|
|
|
190 |
/**
|
|
|
191 |
* The supported API version.
|
|
|
192 |
*/
|
|
|
193 |
public $api_version = null;
|
|
|
194 |
|
|
|
195 |
/**
|
|
|
196 |
* The state of whether auth should be handled as AWS Query.
|
|
|
197 |
*/
|
|
|
198 |
public $use_aws_query = true;
|
|
|
199 |
|
|
|
200 |
/**
|
|
|
201 |
* The default class to use for utilities (defaults to <CFUtilities>).
|
|
|
202 |
*/
|
|
|
203 |
public $utilities_class = 'CFUtilities';
|
|
|
204 |
|
|
|
205 |
/**
|
|
|
206 |
* The default class to use for HTTP requests (defaults to <CFRequest>).
|
|
|
207 |
*/
|
|
|
208 |
public $request_class = 'CFRequest';
|
|
|
209 |
|
|
|
210 |
/**
|
|
|
211 |
* The default class to use for HTTP responses (defaults to <CFResponse>).
|
|
|
212 |
*/
|
|
|
213 |
public $response_class = 'CFResponse';
|
|
|
214 |
|
|
|
215 |
/**
|
|
|
216 |
* The default class to use for parsing XML (defaults to <CFSimpleXML>).
|
|
|
217 |
*/
|
|
|
218 |
public $parser_class = 'CFSimpleXML';
|
|
|
219 |
|
|
|
220 |
/**
|
|
|
221 |
* The default class to use for handling batch requests (defaults to <CFBatchRequest>).
|
|
|
222 |
*/
|
|
|
223 |
public $batch_class = 'CFBatchRequest';
|
|
|
224 |
|
|
|
225 |
/**
|
|
|
226 |
* The state of SSL/HTTPS use.
|
|
|
227 |
*/
|
|
|
228 |
public $use_ssl = true;
|
|
|
229 |
|
|
|
230 |
/**
|
|
|
231 |
* The state of SSL certificate verification.
|
|
|
232 |
*/
|
|
|
233 |
public $ssl_verification = true;
|
|
|
234 |
|
|
|
235 |
/**
|
|
|
236 |
* The proxy to use for connecting.
|
|
|
237 |
*/
|
|
|
238 |
public $proxy = null;
|
|
|
239 |
|
|
|
240 |
/**
|
|
|
241 |
* The alternate hostname to use, if any.
|
|
|
242 |
*/
|
|
|
243 |
public $hostname = null;
|
|
|
244 |
|
|
|
245 |
/**
|
|
|
246 |
* The state of the capability to override the hostname with <set_hostname()>.
|
|
|
247 |
*/
|
|
|
248 |
public $override_hostname = true;
|
|
|
249 |
|
|
|
250 |
/**
|
|
|
251 |
* The alternate port number to use, if any.
|
|
|
252 |
*/
|
|
|
253 |
public $port_number = null;
|
|
|
254 |
|
|
|
255 |
/**
|
|
|
256 |
* The alternate resource prefix to use, if any.
|
|
|
257 |
*/
|
|
|
258 |
public $resource_prefix = null;
|
|
|
259 |
|
|
|
260 |
/**
|
|
|
261 |
* The state of cache flow usage.
|
|
|
262 |
*/
|
|
|
263 |
public $use_cache_flow = false;
|
|
|
264 |
|
|
|
265 |
/**
|
|
|
266 |
* The caching class to use.
|
|
|
267 |
*/
|
|
|
268 |
public $cache_class = null;
|
|
|
269 |
|
|
|
270 |
/**
|
|
|
271 |
* The caching location to use.
|
|
|
272 |
*/
|
|
|
273 |
public $cache_location = null;
|
|
|
274 |
|
|
|
275 |
/**
|
|
|
276 |
* When the cache should be considered stale.
|
|
|
277 |
*/
|
|
|
278 |
public $cache_expires = null;
|
|
|
279 |
|
|
|
280 |
/**
|
|
|
281 |
* The state of cache compression.
|
|
|
282 |
*/
|
|
|
283 |
public $cache_compress = null;
|
|
|
284 |
|
|
|
285 |
/**
|
|
|
286 |
* The current instantiated cache object.
|
|
|
287 |
*/
|
|
|
288 |
public $cache_object = null;
|
|
|
289 |
|
|
|
290 |
/**
|
|
|
291 |
* The current instantiated batch request object.
|
|
|
292 |
*/
|
|
|
293 |
public $batch_object = null;
|
|
|
294 |
|
|
|
295 |
/**
|
|
|
296 |
* The internally instantiated batch request object.
|
|
|
297 |
*/
|
|
|
298 |
public $internal_batch_object = null;
|
|
|
299 |
|
|
|
300 |
/**
|
|
|
301 |
* The state of batch flow usage.
|
|
|
302 |
*/
|
|
|
303 |
public $use_batch_flow = false;
|
|
|
304 |
|
|
|
305 |
/**
|
|
|
306 |
* The state of the cache deletion setting.
|
|
|
307 |
*/
|
|
|
308 |
public $delete_cache = false;
|
|
|
309 |
|
|
|
310 |
/**
|
|
|
311 |
* The state of the debug mode setting.
|
|
|
312 |
*/
|
|
|
313 |
public $debug_mode = false;
|
|
|
314 |
|
|
|
315 |
/**
|
|
|
316 |
* The number of times to retry failed requests.
|
|
|
317 |
*/
|
|
|
318 |
public $max_retries = 3;
|
|
|
319 |
|
|
|
320 |
/**
|
|
|
321 |
* The user-defined callback function to call when a stream is read from.
|
|
|
322 |
*/
|
|
|
323 |
public $registered_streaming_read_callback = null;
|
|
|
324 |
|
|
|
325 |
/**
|
|
|
326 |
* The user-defined callback function to call when a stream is written to.
|
|
|
327 |
*/
|
|
|
328 |
public $registered_streaming_write_callback = null;
|
|
|
329 |
|
|
|
330 |
/**
|
|
|
331 |
* The credentials to use for authentication.
|
|
|
332 |
*/
|
|
|
333 |
public $credentials = array();
|
|
|
334 |
|
|
|
335 |
/**
|
|
|
336 |
* The authentication class to use.
|
|
|
337 |
*/
|
|
|
338 |
public $auth_class = null;
|
|
|
339 |
|
|
|
340 |
/**
|
|
|
341 |
* The operation to execute.
|
|
|
342 |
*/
|
|
|
343 |
public $operation = null;
|
|
|
344 |
|
|
|
345 |
/**
|
|
|
346 |
* The payload to send.
|
|
|
347 |
*/
|
|
|
348 |
public $payload = array();
|
|
|
349 |
|
|
|
350 |
/**
|
|
|
351 |
* The string prefix to prepend to the operation name.
|
|
|
352 |
*/
|
|
|
353 |
public $operation_prefix = '';
|
|
|
354 |
|
|
|
355 |
/**
|
|
|
356 |
* The number of times a request has been retried.
|
|
|
357 |
*/
|
|
|
358 |
public $redirects = 0;
|
|
|
359 |
|
|
|
360 |
/**
|
|
|
361 |
* The state of whether the response should be parsed or not.
|
|
|
362 |
*/
|
|
|
363 |
public $parse_the_response = true;
|
|
|
364 |
|
|
|
365 |
|
|
|
366 |
/*%******************************************************************************************%*/
|
|
|
367 |
// CONSTRUCTOR
|
|
|
368 |
|
|
|
369 |
/**
|
|
|
370 |
* The constructor. This class should not be instantiated directly. Rather, a service-specific class
|
|
|
371 |
* should be instantiated.
|
|
|
372 |
*
|
|
|
373 |
* @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
374 |
* <li><code>certificate_authority</code> - <code>boolean</code> - Optional - Determines which Cerificate Authority file to use. A value of boolean <code>false</code> will use the Certificate Authority file available on the system. A value of boolean <code>true</code> will use the Certificate Authority provided by the SDK. Passing a file system path to a Certificate Authority file (chmodded to <code>0755</code>) will use that. Leave this set to <code>false</code> if you're not sure.</li>
|
|
|
375 |
* <li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
|
|
|
376 |
* <li><code>default_cache_config</code> - <code>string</code> - Optional - This option allows a preferred storage type to be configured for long-term caching. This can be changed later using the <set_cache_config()> method. Valid values are: <code>apc</code>, <code>xcache</code>, or a file system path such as <code>./cache</code> or <code>/tmp/cache/</code>.</li>
|
|
|
377 |
* <li><code>key</code> - <code>string</code> - Optional - Your AWS key, or a session key. If blank, the default credential set will be used.</li>
|
|
|
378 |
* <li><code>secret</code> - <code>string</code> - Optional - Your AWS secret key, or a session secret key. If blank, the default credential set will be used.</li>
|
|
|
379 |
* <li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li></ul>
|
|
|
380 |
* @return void
|
|
|
381 |
*/
|
|
|
382 |
public function __construct(array $options = array())
|
|
|
383 |
{
|
|
|
384 |
// Instantiate the utilities class.
|
|
|
385 |
$this->util = new $this->utilities_class();
|
|
|
386 |
|
|
|
387 |
// Determine the current service.
|
|
|
388 |
$this->service = get_class($this);
|
|
|
389 |
|
|
|
390 |
// Create credentials based on the options
|
|
|
391 |
$instance_credentials = new CFCredential($options);
|
|
|
392 |
|
|
|
393 |
// Retreive a credential set from config.inc.php if it exists
|
|
|
394 |
if (isset($options['credentials']))
|
|
|
395 |
{
|
|
|
396 |
// Use a specific credential set and merge with the instance credentials
|
|
|
397 |
$this->credentials = CFCredentials::get($options['credentials'])
|
|
|
398 |
->merge($instance_credentials);
|
|
|
399 |
}
|
|
|
400 |
else
|
|
|
401 |
{
|
|
|
402 |
try
|
|
|
403 |
{
|
|
|
404 |
// Use the default credential set and merge with the instance credentials
|
|
|
405 |
$this->credentials = CFCredentials::get(CFCredentials::DEFAULT_KEY)
|
|
|
406 |
->merge($instance_credentials);
|
|
|
407 |
}
|
|
|
408 |
catch (CFCredentials_Exception $e)
|
|
|
409 |
{
|
|
|
410 |
if (isset($options['key']) && isset($options['secret']))
|
|
|
411 |
{
|
|
|
412 |
// Only the instance credentials were provided
|
|
|
413 |
$this->credentials = $instance_credentials;
|
|
|
414 |
}
|
|
|
415 |
else
|
|
|
416 |
{
|
|
|
417 |
// No credentials provided in the config file or constructor
|
|
|
418 |
throw new CFCredentials_Exception('No credentials were provided to ' . $this->service . '.');
|
|
|
419 |
}
|
|
|
420 |
}
|
|
|
421 |
}
|
|
|
422 |
|
|
|
423 |
// Set internal credentials after they are resolved
|
|
|
424 |
$this->key = $this->credentials->key;
|
|
|
425 |
$this->secret_key = $this->credentials->secret;
|
|
|
426 |
$this->auth_token = $this->credentials->token;
|
|
|
427 |
|
|
|
428 |
// Automatically enable whichever caching mechanism is set to default.
|
|
|
429 |
$this->set_cache_config($this->credentials->default_cache_config);
|
|
|
430 |
}
|
|
|
431 |
|
|
|
432 |
/**
|
|
|
433 |
* Alternate approach to constructing a new instance. Supports chaining.
|
|
|
434 |
*
|
|
|
435 |
* @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
|
|
|
436 |
* <li><code>certificate_authority</code> - <code>boolean</code> - Optional - Determines which Cerificate Authority file to use. A value of boolean <code>false</code> will use the Certificate Authority file available on the system. A value of boolean <code>true</code> will use the Certificate Authority provided by the SDK. Passing a file system path to a Certificate Authority file (chmodded to <code>0755</code>) will use that. Leave this set to <code>false</code> if you're not sure.</li>
|
|
|
437 |
* <li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
|
|
|
438 |
* <li><code>default_cache_config</code> - <code>string</code> - Optional - This option allows a preferred storage type to be configured for long-term caching. This can be changed later using the <set_cache_config()> method. Valid values are: <code>apc</code>, <code>xcache</code>, or a file system path such as <code>./cache</code> or <code>/tmp/cache/</code>.</li>
|
|
|
439 |
* <li><code>key</code> - <code>string</code> - Optional - Your AWS key, or a session key. If blank, the default credential set will be used.</li>
|
|
|
440 |
* <li><code>secret</code> - <code>string</code> - Optional - Your AWS secret key, or a session secret key. If blank, the default credential set will be used.</li>
|
|
|
441 |
* <li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li></ul>
|
|
|
442 |
* @return void
|
|
|
443 |
*/
|
|
|
444 |
public static function factory(array $options = array())
|
|
|
445 |
{
|
|
|
446 |
if (version_compare(PHP_VERSION, '5.3.0', '<'))
|
|
|
447 |
{
|
|
|
448 |
throw new Exception('PHP 5.3 or newer is required to instantiate a new class with CLASS::factory().');
|
|
|
449 |
}
|
|
|
450 |
|
|
|
451 |
$self = get_called_class();
|
|
|
452 |
return new $self($options);
|
|
|
453 |
}
|
|
|
454 |
|
|
|
455 |
|
|
|
456 |
/*%******************************************************************************************%*/
|
|
|
457 |
// MAGIC METHODS
|
|
|
458 |
|
|
|
459 |
/**
|
|
|
460 |
* A magic method that allows `camelCase` method names to be translated into `snake_case` names.
|
|
|
461 |
*
|
|
|
462 |
* @param string $name (Required) The name of the method.
|
|
|
463 |
* @param array $arguments (Required) The arguments passed to the method.
|
|
|
464 |
* @return mixed The results of the intended method.
|
|
|
465 |
*/
|
|
|
466 |
public function __call($name, $arguments)
|
|
|
467 |
{
|
|
|
468 |
// Convert camelCase method calls to snake_case.
|
|
|
469 |
$method_name = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name));
|
|
|
470 |
|
|
|
471 |
if (method_exists($this, $method_name))
|
|
|
472 |
{
|
|
|
473 |
return call_user_func_array(array($this, $method_name), $arguments);
|
|
|
474 |
}
|
|
|
475 |
|
|
|
476 |
throw new CFRuntime_Exception('The method ' . $name . '() is undefined. Attempted to map to ' . $method_name . '() which is also undefined. Error occurred');
|
|
|
477 |
}
|
|
|
478 |
|
|
|
479 |
|
|
|
480 |
/*%******************************************************************************************%*/
|
|
|
481 |
// SET CUSTOM SETTINGS
|
|
|
482 |
|
|
|
483 |
/**
|
|
|
484 |
* Set the proxy settings to use.
|
|
|
485 |
*
|
|
|
486 |
* @param string $proxy (Required) Accepts proxy credentials in the following format: `proxy://user:pass@hostname:port`
|
|
|
487 |
* @return $this A reference to the current instance.
|
|
|
488 |
*/
|
|
|
489 |
public function set_proxy($proxy)
|
|
|
490 |
{
|
|
|
491 |
$this->proxy = $proxy;
|
|
|
492 |
return $this;
|
|
|
493 |
}
|
|
|
494 |
|
|
|
495 |
/**
|
|
|
496 |
* Set the hostname to connect to. This is useful for alternate services that are API-compatible with
|
|
|
497 |
* AWS, but run from a different hostname.
|
|
|
498 |
*
|
|
|
499 |
* @param string $hostname (Required) The alternate hostname to use in place of the default one. Useful for mock or test applications living on different hostnames.
|
|
|
500 |
* @param integer $port_number (Optional) The alternate port number to use in place of the default one. Useful for mock or test applications living on different port numbers.
|
|
|
501 |
* @return $this A reference to the current instance.
|
|
|
502 |
*/
|
|
|
503 |
public function set_hostname($hostname, $port_number = null)
|
|
|
504 |
{
|
|
|
505 |
if ($this->override_hostname)
|
|
|
506 |
{
|
|
|
507 |
$this->hostname = $hostname;
|
|
|
508 |
|
|
|
509 |
if ($port_number)
|
|
|
510 |
{
|
|
|
511 |
$this->port_number = $port_number;
|
|
|
512 |
$this->hostname .= ':' . (string) $this->port_number;
|
|
|
513 |
}
|
|
|
514 |
}
|
|
|
515 |
|
|
|
516 |
return $this;
|
|
|
517 |
}
|
|
|
518 |
|
|
|
519 |
/**
|
|
|
520 |
* Set the resource prefix to use. This method is useful for alternate services that are API-compatible
|
|
|
521 |
* with AWS.
|
|
|
522 |
*
|
|
|
523 |
* @param string $prefix (Required) An alternate prefix to prepend to the resource path. Useful for mock or test applications.
|
|
|
524 |
* @return $this A reference to the current instance.
|
|
|
525 |
*/
|
|
|
526 |
public function set_resource_prefix($prefix)
|
|
|
527 |
{
|
|
|
528 |
$this->resource_prefix = $prefix;
|
|
|
529 |
return $this;
|
|
|
530 |
}
|
|
|
531 |
|
|
|
532 |
/**
|
|
|
533 |
* Disables any subsequent use of the <set_hostname()> method.
|
|
|
534 |
*
|
|
|
535 |
* @param boolean $override (Optional) Whether or not subsequent calls to <set_hostname()> should be obeyed. A `false` value disables the further effectiveness of <set_hostname()>. Defaults to `true`.
|
|
|
536 |
* @return $this A reference to the current instance.
|
|
|
537 |
*/
|
|
|
538 |
public function allow_hostname_override($override = true)
|
|
|
539 |
{
|
|
|
540 |
$this->override_hostname = $override;
|
|
|
541 |
return $this;
|
|
|
542 |
}
|
|
|
543 |
|
|
|
544 |
/**
|
|
|
545 |
* Disables SSL/HTTPS connections for hosts that don't support them. Some services, however, still
|
|
|
546 |
* require SSL support.
|
|
|
547 |
*
|
|
|
548 |
* This method will throw a user warning when invoked, which can be hidden by changing your
|
|
|
549 |
* <php:error_reporting()> settings.
|
|
|
550 |
*
|
|
|
551 |
* @return $this A reference to the current instance.
|
|
|
552 |
*/
|
|
|
553 |
public function disable_ssl()
|
|
|
554 |
{
|
|
|
555 |
trigger_error('Disabling SSL connections is potentially unsafe and highly discouraged.', E_USER_WARNING);
|
|
|
556 |
$this->use_ssl = false;
|
|
|
557 |
return $this;
|
|
|
558 |
}
|
|
|
559 |
|
|
|
560 |
/**
|
|
|
561 |
* Disables the verification of the SSL Certificate Authority. Doing so can enable an attacker to carry
|
|
|
562 |
* out a man-in-the-middle attack.
|
|
|
563 |
*
|
|
|
564 |
* https://secure.wikimedia.org/wikipedia/en/wiki/Man-in-the-middle_attack
|
|
|
565 |
*
|
|
|
566 |
* This method will throw a user warning when invoked, which can be hidden by changing your
|
|
|
567 |
* <php:error_reporting()> settings.
|
|
|
568 |
*
|
|
|
569 |
* @return $this A reference to the current instance.
|
|
|
570 |
*/
|
|
|
571 |
public function disable_ssl_verification($ssl_verification = false)
|
|
|
572 |
{
|
|
|
573 |
trigger_error('Disabling the verification of SSL certificates can lead to man-in-the-middle attacks. It is potentially unsafe and highly discouraged.', E_USER_WARNING);
|
|
|
574 |
$this->ssl_verification = $ssl_verification;
|
|
|
575 |
return $this;
|
|
|
576 |
}
|
|
|
577 |
|
|
|
578 |
/**
|
|
|
579 |
* Enables HTTP request/response header logging to `STDERR`.
|
|
|
580 |
*
|
|
|
581 |
* @param boolean $enabled (Optional) Whether or not to enable debug mode. Defaults to `true`.
|
|
|
582 |
* @return $this A reference to the current instance.
|
|
|
583 |
*/
|
|
|
584 |
public function enable_debug_mode($enabled = true)
|
|
|
585 |
{
|
|
|
586 |
$this->debug_mode = $enabled;
|
|
|
587 |
return $this;
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
/**
|
|
|
591 |
* Sets the maximum number of times to retry failed requests.
|
|
|
592 |
*
|
|
|
593 |
* @param integer $retries (Optional) The maximum number of times to retry failed requests. Defaults to `3`.
|
|
|
594 |
* @return $this A reference to the current instance.
|
|
|
595 |
*/
|
|
|
596 |
public function set_max_retries($retries = 3)
|
|
|
597 |
{
|
|
|
598 |
$this->max_retries = $retries;
|
|
|
599 |
return $this;
|
|
|
600 |
}
|
|
|
601 |
|
|
|
602 |
/**
|
|
|
603 |
* Set the caching configuration to use for response caching.
|
|
|
604 |
*
|
|
|
605 |
* @param string $location (Required) <p>The location to store the cache object in. This may vary by cache method.</p><ul><li>File - The local file system paths such as <code>./cache</code> (relative) or <code>/tmp/cache/</code> (absolute). The location must be server-writable.</li><li>APC - Pass in <code>apc</code> to use this lightweight cache. You must have the <a href="http://php.net/apc">APC extension</a> installed.</li><li>XCache - Pass in <code>xcache</code> to use this lightweight cache. You must have the <a href="http://xcache.lighttpd.net">XCache</a> extension installed.</li><li>Memcached - Pass in an indexed array of associative arrays. Each associative array should have a <code>host</code> and a <code>port</code> value representing a <a href="http://php.net/memcached">Memcached</a> server to connect to.</li><li>PDO - A URL-style string (e.g. <code>pdo.mysql://user:pass@localhost/cache</code>) or a standard DSN-style string (e.g. <code>pdo.sqlite:/sqlite/cache.db</code>). MUST be prefixed with <code>pdo.</code>. See <code>CachePDO</code> and <a href="http://php.net/pdo">PDO</a> for more details.</li></ul>
|
|
|
606 |
* @param boolean $gzip (Optional) Whether or not data should be gzipped before being stored. A value of `true` will compress the contents before caching them. A value of `false` will leave the contents uncompressed. Defaults to `true`.
|
|
|
607 |
* @return $this A reference to the current instance.
|
|
|
608 |
*/
|
|
|
609 |
public function set_cache_config($location, $gzip = true)
|
|
|
610 |
{
|
|
|
611 |
// If we have an array, we're probably passing in Memcached servers and ports.
|
|
|
612 |
if (is_array($location))
|
|
|
613 |
{
|
|
|
614 |
$this->cache_class = 'CacheMC';
|
|
|
615 |
}
|
|
|
616 |
else
|
|
|
617 |
{
|
|
|
618 |
// I would expect locations like `/tmp/cache`, `pdo.mysql://user:pass@hostname:port`, `pdo.sqlite:memory:`, and `apc`.
|
|
|
619 |
$type = strtolower(substr($location, 0, 3));
|
|
|
620 |
switch ($type)
|
|
|
621 |
{
|
|
|
622 |
case 'apc':
|
|
|
623 |
$this->cache_class = 'CacheAPC';
|
|
|
624 |
break;
|
|
|
625 |
|
|
|
626 |
case 'xca': // First three letters of `xcache`
|
|
|
627 |
$this->cache_class = 'CacheXCache';
|
|
|
628 |
break;
|
|
|
629 |
|
|
|
630 |
case 'pdo':
|
|
|
631 |
$this->cache_class = 'CachePDO';
|
|
|
632 |
$location = substr($location, 4);
|
|
|
633 |
break;
|
|
|
634 |
|
|
|
635 |
default:
|
|
|
636 |
$this->cache_class = 'CacheFile';
|
|
|
637 |
break;
|
|
|
638 |
}
|
|
|
639 |
}
|
|
|
640 |
|
|
|
641 |
// Set the remaining cache information.
|
|
|
642 |
$this->cache_location = $location;
|
|
|
643 |
$this->cache_compress = $gzip;
|
|
|
644 |
|
|
|
645 |
return $this;
|
|
|
646 |
}
|
|
|
647 |
|
|
|
648 |
/**
|
|
|
649 |
* Register a callback function to execute whenever a data stream is read from using
|
|
|
650 |
* <CFRequest::streaming_read_callback()>.
|
|
|
651 |
*
|
|
|
652 |
* The user-defined callback function should accept three arguments:
|
|
|
653 |
*
|
|
|
654 |
* <ul>
|
|
|
655 |
* <li><code>$curl_handle</code> - <code>resource</code> - Required - The cURL handle resource that represents the in-progress transfer.</li>
|
|
|
656 |
* <li><code>$file_handle</code> - <code>resource</code> - Required - The file handle resource that represents the file on the local file system.</li>
|
|
|
657 |
* <li><code>$length</code> - <code>integer</code> - Required - The length in kilobytes of the data chunk that was transferred.</li>
|
|
|
658 |
* </ul>
|
|
|
659 |
*
|
|
|
660 |
* @param string|array|function $callback (Required) The callback function is called by <php:call_user_func()>, so you can pass the following values: <ul>
|
|
|
661 |
* <li>The name of a global function to execute, passed as a string.</li>
|
|
|
662 |
* <li>A method to execute, passed as <code>array('ClassName', 'MethodName')</code>.</li>
|
|
|
663 |
* <li>An anonymous function (PHP 5.3+).</li></ul>
|
|
|
664 |
* @return $this A reference to the current instance.
|
|
|
665 |
*/
|
|
|
666 |
public function register_streaming_read_callback($callback)
|
|
|
667 |
{
|
|
|
668 |
$this->registered_streaming_read_callback = $callback;
|
|
|
669 |
return $this;
|
|
|
670 |
}
|
|
|
671 |
|
|
|
672 |
/**
|
|
|
673 |
* Register a callback function to execute whenever a data stream is written to using
|
|
|
674 |
* <CFRequest::streaming_write_callback()>.
|
|
|
675 |
*
|
|
|
676 |
* The user-defined callback function should accept two arguments:
|
|
|
677 |
*
|
|
|
678 |
* <ul>
|
|
|
679 |
* <li><code>$curl_handle</code> - <code>resource</code> - Required - The cURL handle resource that represents the in-progress transfer.</li>
|
|
|
680 |
* <li><code>$length</code> - <code>integer</code> - Required - The length in kilobytes of the data chunk that was transferred.</li>
|
|
|
681 |
* </ul>
|
|
|
682 |
*
|
|
|
683 |
* @param string|array|function $callback (Required) The callback function is called by <php:call_user_func()>, so you can pass the following values: <ul>
|
|
|
684 |
* <li>The name of a global function to execute, passed as a string.</li>
|
|
|
685 |
* <li>A method to execute, passed as <code>array('ClassName', 'MethodName')</code>.</li>
|
|
|
686 |
* <li>An anonymous function (PHP 5.3+).</li></ul>
|
|
|
687 |
* @return $this A reference to the current instance.
|
|
|
688 |
*/
|
|
|
689 |
public function register_streaming_write_callback($callback)
|
|
|
690 |
{
|
|
|
691 |
$this->registered_streaming_write_callback = $callback;
|
|
|
692 |
return $this;
|
|
|
693 |
}
|
|
|
694 |
|
|
|
695 |
|
|
|
696 |
/*%******************************************************************************************%*/
|
|
|
697 |
// SET CUSTOM CLASSES
|
|
|
698 |
|
|
|
699 |
/**
|
|
|
700 |
* Set a custom class for this functionality. Use this method when extending/overriding existing classes
|
|
|
701 |
* with new functionality.
|
|
|
702 |
*
|
|
|
703 |
* The replacement class must extend from <CFUtilities>.
|
|
|
704 |
*
|
|
|
705 |
* @param string $class (Optional) The name of the new class to use for this functionality.
|
|
|
706 |
* @return $this A reference to the current instance.
|
|
|
707 |
*/
|
|
|
708 |
public function set_utilities_class($class = 'CFUtilities')
|
|
|
709 |
{
|
|
|
710 |
$this->utilities_class = $class;
|
|
|
711 |
$this->util = new $this->utilities_class();
|
|
|
712 |
return $this;
|
|
|
713 |
}
|
|
|
714 |
|
|
|
715 |
/**
|
|
|
716 |
* Set a custom class for this functionality. Use this method when extending/overriding existing classes
|
|
|
717 |
* with new functionality.
|
|
|
718 |
*
|
|
|
719 |
* The replacement class must extend from <CFRequest>.
|
|
|
720 |
*
|
|
|
721 |
* @param string $class (Optional) The name of the new class to use for this functionality.
|
|
|
722 |
* @param $this A reference to the current instance.
|
|
|
723 |
*/
|
|
|
724 |
public function set_request_class($class = 'CFRequest')
|
|
|
725 |
{
|
|
|
726 |
$this->request_class = $class;
|
|
|
727 |
return $this;
|
|
|
728 |
}
|
|
|
729 |
|
|
|
730 |
/**
|
|
|
731 |
* Set a custom class for this functionality. Use this method when extending/overriding existing classes
|
|
|
732 |
* with new functionality.
|
|
|
733 |
*
|
|
|
734 |
* The replacement class must extend from <CFResponse>.
|
|
|
735 |
*
|
|
|
736 |
* @param string $class (Optional) The name of the new class to use for this functionality.
|
|
|
737 |
* @return $this A reference to the current instance.
|
|
|
738 |
*/
|
|
|
739 |
public function set_response_class($class = 'CFResponse')
|
|
|
740 |
{
|
|
|
741 |
$this->response_class = $class;
|
|
|
742 |
return $this;
|
|
|
743 |
}
|
|
|
744 |
|
|
|
745 |
/**
|
|
|
746 |
* Set a custom class for this functionality. Use this method when extending/overriding existing classes
|
|
|
747 |
* with new functionality.
|
|
|
748 |
*
|
|
|
749 |
* The replacement class must extend from <CFSimpleXML>.
|
|
|
750 |
*
|
|
|
751 |
* @param string $class (Optional) The name of the new class to use for this functionality.
|
|
|
752 |
* @return $this A reference to the current instance.
|
|
|
753 |
*/
|
|
|
754 |
public function set_parser_class($class = 'CFSimpleXML')
|
|
|
755 |
{
|
|
|
756 |
$this->parser_class = $class;
|
|
|
757 |
return $this;
|
|
|
758 |
}
|
|
|
759 |
|
|
|
760 |
/**
|
|
|
761 |
* Set a custom class for this functionality. Use this method when extending/overriding existing classes
|
|
|
762 |
* with new functionality.
|
|
|
763 |
*
|
|
|
764 |
* The replacement class must extend from <CFBatchRequest>.
|
|
|
765 |
*
|
|
|
766 |
* @param string $class (Optional) The name of the new class to use for this functionality.
|
|
|
767 |
* @return $this A reference to the current instance.
|
|
|
768 |
*/
|
|
|
769 |
public function set_batch_class($class = 'CFBatchRequest')
|
|
|
770 |
{
|
|
|
771 |
$this->batch_class = $class;
|
|
|
772 |
return $this;
|
|
|
773 |
}
|
|
|
774 |
|
|
|
775 |
|
|
|
776 |
/*%******************************************************************************************%*/
|
|
|
777 |
// AUTHENTICATION
|
|
|
778 |
|
|
|
779 |
/**
|
|
|
780 |
* Default, shared method for authenticating a connection to AWS.
|
|
|
781 |
*
|
|
|
782 |
* @param string $operation (Required) Indicates the operation to perform.
|
|
|
783 |
* @param array $payload (Required) An associative array of parameters for authenticating. See the individual methods for allowed keys.
|
|
|
784 |
* @return CFResponse Object containing a parsed HTTP response.
|
|
|
785 |
*/
|
|
|
786 |
public function authenticate($operation, $payload)
|
|
|
787 |
{
|
|
|
788 |
$original_payload = $payload;
|
|
|
789 |
$method_arguments = func_get_args();
|
|
|
790 |
$curlopts = array();
|
|
|
791 |
$return_curl_handle = false;
|
|
|
792 |
|
|
|
793 |
if (substr($operation, 0, strlen($this->operation_prefix)) !== $this->operation_prefix)
|
|
|
794 |
{
|
|
|
795 |
$operation = $this->operation_prefix . $operation;
|
|
|
796 |
}
|
|
|
797 |
|
|
|
798 |
// Extract the custom CURLOPT settings from the payload
|
|
|
799 |
if (is_array($payload) && isset($payload['curlopts']))
|
|
|
800 |
{
|
|
|
801 |
$curlopts = $payload['curlopts'];
|
|
|
802 |
unset($payload['curlopts']);
|
|
|
803 |
}
|
|
|
804 |
|
|
|
805 |
// Determine whether the response or curl handle should be returned
|
|
|
806 |
if (is_array($payload) && isset($payload['returnCurlHandle']))
|
|
|
807 |
{
|
|
|
808 |
$return_curl_handle = isset($payload['returnCurlHandle']) ? $payload['returnCurlHandle'] : false;
|
|
|
809 |
unset($payload['returnCurlHandle']);
|
|
|
810 |
}
|
|
|
811 |
|
|
|
812 |
// Use the caching flow to determine if we need to do a round-trip to the server.
|
|
|
813 |
if ($this->use_cache_flow)
|
|
|
814 |
{
|
|
|
815 |
// Generate an identifier specific to this particular set of arguments.
|
|
|
816 |
$cache_id = $this->key . '_' . get_class($this) . '_' . $operation . '_' . sha1(serialize($method_arguments));
|
|
|
817 |
|
|
|
818 |
// Instantiate the appropriate caching object.
|
|
|
819 |
$this->cache_object = new $this->cache_class($cache_id, $this->cache_location, $this->cache_expires, $this->cache_compress);
|
|
|
820 |
|
|
|
821 |
if ($this->delete_cache)
|
|
|
822 |
{
|
|
|
823 |
$this->use_cache_flow = false;
|
|
|
824 |
$this->delete_cache = false;
|
|
|
825 |
return $this->cache_object->delete();
|
|
|
826 |
}
|
|
|
827 |
|
|
|
828 |
// Invoke the cache callback function to determine whether to pull data from the cache or make a fresh request.
|
|
|
829 |
$data = $this->cache_object->response_manager(array($this, 'cache_callback'), $method_arguments);
|
|
|
830 |
|
|
|
831 |
// Parse the XML body
|
|
|
832 |
$data = $this->parse_callback($data);
|
|
|
833 |
|
|
|
834 |
// End!
|
|
|
835 |
return $data;
|
|
|
836 |
}
|
|
|
837 |
|
|
|
838 |
/*%******************************************************************************************%*/
|
|
|
839 |
|
|
|
840 |
// Signer
|
|
|
841 |
$signer = new $this->auth_class($this->hostname, $operation, $payload, $this->credentials);
|
|
|
842 |
$signer->key = $this->key;
|
|
|
843 |
$signer->secret_key = $this->secret_key;
|
|
|
844 |
$signer->auth_token = $this->auth_token;
|
|
|
845 |
$signer->api_version = $this->api_version;
|
|
|
846 |
$signer->utilities_class = $this->utilities_class;
|
|
|
847 |
$signer->request_class = $this->request_class;
|
|
|
848 |
$signer->response_class = $this->response_class;
|
|
|
849 |
$signer->use_ssl = $this->use_ssl;
|
|
|
850 |
$signer->proxy = $this->proxy;
|
|
|
851 |
$signer->util = $this->util;
|
|
|
852 |
$signer->registered_streaming_read_callback = $this->registered_streaming_read_callback;
|
|
|
853 |
$signer->registered_streaming_write_callback = $this->registered_streaming_write_callback;
|
|
|
854 |
$request = $signer->authenticate();
|
|
|
855 |
|
|
|
856 |
// Update RequestCore settings
|
|
|
857 |
$request->request_class = $this->request_class;
|
|
|
858 |
$request->response_class = $this->response_class;
|
|
|
859 |
$request->ssl_verification = $this->ssl_verification;
|
|
|
860 |
|
|
|
861 |
/*%******************************************************************************************%*/
|
|
|
862 |
|
|
|
863 |
// Debug mode
|
|
|
864 |
if ($this->debug_mode)
|
|
|
865 |
{
|
|
|
866 |
$request->debug_mode = $this->debug_mode;
|
|
|
867 |
}
|
|
|
868 |
|
|
|
869 |
// Set custom CURLOPT settings
|
|
|
870 |
if (count($curlopts))
|
|
|
871 |
{
|
|
|
872 |
$request->set_curlopts($curlopts);
|
|
|
873 |
}
|
|
|
874 |
|
|
|
875 |
// Manage the (newer) batch request API or the (older) returnCurlHandle setting.
|
|
|
876 |
if ($this->use_batch_flow)
|
|
|
877 |
{
|
|
|
878 |
$handle = $request->prep_request();
|
|
|
879 |
$this->batch_object->add($handle);
|
|
|
880 |
$this->use_batch_flow = false;
|
|
|
881 |
|
|
|
882 |
return $handle;
|
|
|
883 |
}
|
|
|
884 |
elseif ($return_curl_handle)
|
|
|
885 |
{
|
|
|
886 |
return $request->prep_request();
|
|
|
887 |
}
|
|
|
888 |
|
|
|
889 |
// Send!
|
|
|
890 |
$request->send_request();
|
|
|
891 |
|
|
|
892 |
// Prepare the response.
|
|
|
893 |
$headers = $request->get_response_header();
|
|
|
894 |
$headers['x-aws-stringtosign'] = $signer->string_to_sign;
|
|
|
895 |
|
|
|
896 |
if (isset($signer->canonical_request))
|
|
|
897 |
{
|
|
|
898 |
$headers['x-aws-canonicalrequest'] = $signer->canonical_request;
|
|
|
899 |
}
|
|
|
900 |
|
|
|
901 |
$headers['x-aws-request-headers'] = $request->request_headers;
|
|
|
902 |
$headers['x-aws-body'] = $signer->querystring;
|
|
|
903 |
|
|
|
904 |
$data = new $this->response_class($headers, ($this->parse_the_response === true) ? $this->parse_callback($request->get_response_body()) : $request->get_response_body(), $request->get_response_code());
|
|
|
905 |
|
|
|
906 |
// Was it Amazon's fault the request failed? Retry the request until we reach $max_retries.
|
|
|
907 |
if (
|
|
|
908 |
(integer) $request->get_response_code() === 500 || // Internal Error (presumably transient)
|
|
|
909 |
(integer) $request->get_response_code() === 503) // Service Unavailable (presumably transient)
|
|
|
910 |
{
|
|
|
911 |
if ($this->redirects <= $this->max_retries)
|
|
|
912 |
{
|
|
|
913 |
// Exponential backoff
|
|
|
914 |
$delay = (integer) (pow(4, $this->redirects) * 100000);
|
|
|
915 |
usleep($delay);
|
|
|
916 |
$this->redirects++;
|
|
|
917 |
$data = $this->authenticate($operation, $original_payload);
|
|
|
918 |
}
|
|
|
919 |
}
|
|
|
920 |
|
|
|
921 |
// DynamoDB has custom logic
|
|
|
922 |
elseif (
|
|
|
923 |
(integer) $request->get_response_code() === 400 &&
|
|
|
924 |
stripos((string) $request->get_response_body(), 'com.amazonaws.dynamodb.') !== false && (
|
|
|
925 |
stripos((string) $request->get_response_body(), 'ProvisionedThroughputExceededException') !== false
|
|
|
926 |
)
|
|
|
927 |
)
|
|
|
928 |
{
|
|
|
929 |
if ($this->redirects === 0)
|
|
|
930 |
{
|
|
|
931 |
$this->redirects++;
|
|
|
932 |
$data = $this->authenticate($operation, $original_payload);
|
|
|
933 |
}
|
|
|
934 |
elseif ($this->redirects <= max($this->max_retries, 10))
|
|
|
935 |
{
|
|
|
936 |
// Exponential backoff
|
|
|
937 |
$delay = (integer) (pow(2, ($this->redirects - 1)) * 50000);
|
|
|
938 |
usleep($delay);
|
|
|
939 |
$this->redirects++;
|
|
|
940 |
$data = $this->authenticate($operation, $original_payload);
|
|
|
941 |
}
|
|
|
942 |
}
|
|
|
943 |
|
|
|
944 |
$this->redirects = 0;
|
|
|
945 |
return $data;
|
|
|
946 |
}
|
|
|
947 |
|
|
|
948 |
|
|
|
949 |
/*%******************************************************************************************%*/
|
|
|
950 |
// BATCH REQUEST LAYER
|
|
|
951 |
|
|
|
952 |
/**
|
|
|
953 |
* Specifies that the intended request should be queued for a later batch request.
|
|
|
954 |
*
|
|
|
955 |
* @param CFBatchRequest $queue (Optional) The <CFBatchRequest> instance to use for managing batch requests. If not available, it generates a new instance of <CFBatchRequest>.
|
|
|
956 |
* @return $this A reference to the current instance.
|
|
|
957 |
*/
|
|
|
958 |
public function batch(CFBatchRequest &$queue = null)
|
|
|
959 |
{
|
|
|
960 |
if ($queue)
|
|
|
961 |
{
|
|
|
962 |
$this->batch_object = $queue;
|
|
|
963 |
}
|
|
|
964 |
elseif ($this->internal_batch_object)
|
|
|
965 |
{
|
|
|
966 |
$this->batch_object = &$this->internal_batch_object;
|
|
|
967 |
}
|
|
|
968 |
else
|
|
|
969 |
{
|
|
|
970 |
$this->internal_batch_object = new $this->batch_class();
|
|
|
971 |
$this->batch_object = &$this->internal_batch_object;
|
|
|
972 |
}
|
|
|
973 |
|
|
|
974 |
$this->use_batch_flow = true;
|
|
|
975 |
|
|
|
976 |
return $this;
|
|
|
977 |
}
|
|
|
978 |
|
|
|
979 |
/**
|
|
|
980 |
* Executes the batch request queue by sending all queued requests.
|
|
|
981 |
*
|
|
|
982 |
* @param boolean $clear_after_send (Optional) Whether or not to clear the batch queue after sending a request. Defaults to `true`. Set this to `false` if you are caching batch responses and want to retrieve results later.
|
|
|
983 |
* @return array An array of <CFResponse> objects.
|
|
|
984 |
*/
|
|
|
985 |
public function send($clear_after_send = true)
|
|
|
986 |
{
|
|
|
987 |
if ($this->use_batch_flow)
|
|
|
988 |
{
|
|
|
989 |
// When we send the request, disable batch flow.
|
|
|
990 |
$this->use_batch_flow = false;
|
|
|
991 |
|
|
|
992 |
// If we're not caching, simply send the request.
|
|
|
993 |
if (!$this->use_cache_flow)
|
|
|
994 |
{
|
|
|
995 |
$response = $this->batch_object->send();
|
|
|
996 |
$parsed_data = array_map(array($this, 'parse_callback'), $response);
|
|
|
997 |
$parsed_data = new CFArray($parsed_data);
|
|
|
998 |
|
|
|
999 |
// Clear the queue
|
|
|
1000 |
if ($clear_after_send)
|
|
|
1001 |
{
|
|
|
1002 |
$this->batch_object->queue = array();
|
|
|
1003 |
}
|
|
|
1004 |
|
|
|
1005 |
return $parsed_data;
|
|
|
1006 |
}
|
|
|
1007 |
|
|
|
1008 |
// Generate an identifier specific to this particular set of arguments.
|
|
|
1009 |
$cache_id = $this->key . '_' . get_class($this) . '_' . sha1(serialize($this->batch_object));
|
|
|
1010 |
|
|
|
1011 |
// Instantiate the appropriate caching object.
|
|
|
1012 |
$this->cache_object = new $this->cache_class($cache_id, $this->cache_location, $this->cache_expires, $this->cache_compress);
|
|
|
1013 |
|
|
|
1014 |
if ($this->delete_cache)
|
|
|
1015 |
{
|
|
|
1016 |
$this->use_cache_flow = false;
|
|
|
1017 |
$this->delete_cache = false;
|
|
|
1018 |
return $this->cache_object->delete();
|
|
|
1019 |
}
|
|
|
1020 |
|
|
|
1021 |
// Invoke the cache callback function to determine whether to pull data from the cache or make a fresh request.
|
|
|
1022 |
$data_set = $this->cache_object->response_manager(array($this, 'cache_callback_batch'), array($this->batch_object));
|
|
|
1023 |
$parsed_data = array_map(array($this, 'parse_callback'), $data_set);
|
|
|
1024 |
$parsed_data = new CFArray($parsed_data);
|
|
|
1025 |
|
|
|
1026 |
// Clear the queue
|
|
|
1027 |
if ($clear_after_send)
|
|
|
1028 |
{
|
|
|
1029 |
$this->batch_object->queue = array();
|
|
|
1030 |
}
|
|
|
1031 |
|
|
|
1032 |
// End!
|
|
|
1033 |
return $parsed_data;
|
|
|
1034 |
}
|
|
|
1035 |
|
|
|
1036 |
// Load the class
|
|
|
1037 |
$null = new CFBatchRequest();
|
|
|
1038 |
unset($null);
|
|
|
1039 |
|
|
|
1040 |
throw new CFBatchRequest_Exception('You must use $object->batch()->send()');
|
|
|
1041 |
}
|
|
|
1042 |
|
|
|
1043 |
/**
|
|
|
1044 |
* Parses a response body into a PHP object if appropriate.
|
|
|
1045 |
*
|
|
|
1046 |
* @param CFResponse|string $response (Required) The <CFResponse> object to parse, or an XML string that would otherwise be a response body.
|
|
|
1047 |
* @param string $content_type (Optional) The content-type to use when determining how to parse the content.
|
|
|
1048 |
* @return CFResponse|string A parsed <CFResponse> object, or parsed XML.
|
|
|
1049 |
*/
|
|
|
1050 |
public function parse_callback($response, $headers = null)
|
|
|
1051 |
{
|
|
|
1052 |
// Bail out
|
|
|
1053 |
if (!$this->parse_the_response) return $response;
|
|
|
1054 |
|
|
|
1055 |
// Shorten this so we have a (mostly) single code path
|
|
|
1056 |
if (isset($response->body))
|
|
|
1057 |
{
|
|
|
1058 |
if (is_string($response->body))
|
|
|
1059 |
{
|
|
|
1060 |
$body = $response->body;
|
|
|
1061 |
}
|
|
|
1062 |
else
|
|
|
1063 |
{
|
|
|
1064 |
return $response;
|
|
|
1065 |
}
|
|
|
1066 |
}
|
|
|
1067 |
elseif (is_string($response))
|
|
|
1068 |
{
|
|
|
1069 |
$body = $response;
|
|
|
1070 |
}
|
|
|
1071 |
else
|
|
|
1072 |
{
|
|
|
1073 |
return $response;
|
|
|
1074 |
}
|
|
|
1075 |
|
|
|
1076 |
// Decompress gzipped content
|
|
|
1077 |
if (isset($headers['content-encoding']))
|
|
|
1078 |
{
|
|
|
1079 |
switch (strtolower(trim($headers['content-encoding'], "\x09\x0A\x0D\x20")))
|
|
|
1080 |
{
|
|
|
1081 |
case 'gzip':
|
|
|
1082 |
case 'x-gzip':
|
|
|
1083 |
$decoder = new CFGzipDecode($body);
|
|
|
1084 |
if ($decoder->parse())
|
|
|
1085 |
{
|
|
|
1086 |
$body = $decoder->data;
|
|
|
1087 |
}
|
|
|
1088 |
break;
|
|
|
1089 |
|
|
|
1090 |
case 'deflate':
|
|
|
1091 |
if (($uncompressed = gzuncompress($body)) !== false)
|
|
|
1092 |
{
|
|
|
1093 |
$body = $uncompressed;
|
|
|
1094 |
}
|
|
|
1095 |
elseif (($uncompressed = gzinflate($body)) !== false)
|
|
|
1096 |
{
|
|
|
1097 |
$body = $uncompressed;
|
|
|
1098 |
}
|
|
|
1099 |
break;
|
|
|
1100 |
}
|
|
|
1101 |
}
|
|
|
1102 |
|
|
|
1103 |
// Look for XML cues
|
|
|
1104 |
if (
|
|
|
1105 |
(isset($headers['content-type']) && ($headers['content-type'] === 'text/xml' || $headers['content-type'] === 'application/xml')) || // We know it's XML
|
|
|
1106 |
(!isset($headers['content-type']) && (stripos($body, '<?xml') === 0 || strpos($body, '<Error>') === 0) || preg_match('/^<(\w*) xmlns="http(s?):\/\/(\w*).amazon(aws)?.com/im', $body)) // Sniff for XML
|
|
|
1107 |
)
|
|
|
1108 |
{
|
|
|
1109 |
// Strip the default XML namespace to simplify XPath expressions
|
|
|
1110 |
$body = str_replace("xmlns=", "ns=", $body);
|
|
|
1111 |
|
|
|
1112 |
try {
|
|
|
1113 |
// Parse the XML body
|
|
|
1114 |
$body = new $this->parser_class($body);
|
|
|
1115 |
}
|
|
|
1116 |
catch (Exception $e)
|
|
|
1117 |
{
|
|
|
1118 |
throw new Parser_Exception($e->getMessage());
|
|
|
1119 |
}
|
|
|
1120 |
}
|
|
|
1121 |
// Look for JSON cues
|
|
|
1122 |
elseif (
|
|
|
1123 |
(isset($headers['content-type']) && ($headers['content-type'] === 'application/json') || $headers['content-type'] === 'application/x-amz-json-1.0') || // We know it's JSON
|
|
|
1124 |
(!isset($headers['content-type']) && $this->util->is_json($body)) // Sniff for JSON
|
|
|
1125 |
)
|
|
|
1126 |
{
|
|
|
1127 |
// Normalize JSON to a CFSimpleXML object
|
|
|
1128 |
$body = CFJSON::to_xml($body, $this->parser_class);
|
|
|
1129 |
}
|
|
|
1130 |
|
|
|
1131 |
// Put the parsed data back where it goes
|
|
|
1132 |
if (isset($response->body))
|
|
|
1133 |
{
|
|
|
1134 |
$response->body = $body;
|
|
|
1135 |
}
|
|
|
1136 |
else
|
|
|
1137 |
{
|
|
|
1138 |
$response = $body;
|
|
|
1139 |
}
|
|
|
1140 |
|
|
|
1141 |
return $response;
|
|
|
1142 |
}
|
|
|
1143 |
|
|
|
1144 |
|
|
|
1145 |
/*%******************************************************************************************%*/
|
|
|
1146 |
// CACHING LAYER
|
|
|
1147 |
|
|
|
1148 |
/**
|
|
|
1149 |
* Specifies that the resulting <CFResponse> object should be cached according to the settings from
|
|
|
1150 |
* <set_cache_config()>.
|
|
|
1151 |
*
|
|
|
1152 |
* @param string|integer $expires (Required) The time the cache is to expire. Accepts a number of seconds as an integer, or an amount of time, as a string, that is understood by <php:strtotime()> (e.g. "1 hour").
|
|
|
1153 |
* @param $this A reference to the current instance.
|
|
|
1154 |
* @return $this
|
|
|
1155 |
*/
|
|
|
1156 |
public function cache($expires)
|
|
|
1157 |
{
|
|
|
1158 |
// Die if they haven't used set_cache_config().
|
|
|
1159 |
if (!$this->cache_class)
|
|
|
1160 |
{
|
|
|
1161 |
throw new CFRuntime_Exception('Must call set_cache_config() before using cache()');
|
|
|
1162 |
}
|
|
|
1163 |
|
|
|
1164 |
if (is_string($expires))
|
|
|
1165 |
{
|
|
|
1166 |
$expires = strtotime($expires);
|
|
|
1167 |
$this->cache_expires = $expires - time();
|
|
|
1168 |
}
|
|
|
1169 |
elseif (is_int($expires))
|
|
|
1170 |
{
|
|
|
1171 |
$this->cache_expires = $expires;
|
|
|
1172 |
}
|
|
|
1173 |
|
|
|
1174 |
$this->use_cache_flow = true;
|
|
|
1175 |
|
|
|
1176 |
return $this;
|
|
|
1177 |
}
|
|
|
1178 |
|
|
|
1179 |
/**
|
|
|
1180 |
* The callback function that is executed when the cache doesn't exist or has expired. The response of
|
|
|
1181 |
* this method is cached. Accepts identical parameters as the <authenticate()> method. Never call this
|
|
|
1182 |
* method directly -- it is used internally by the caching system.
|
|
|
1183 |
*
|
|
|
1184 |
* @param string $operation (Required) Indicates the operation to perform.
|
|
|
1185 |
* @param array $payload (Required) An associative array of parameters for authenticating. See the individual methods for allowed keys.
|
|
|
1186 |
* @return CFResponse A parsed HTTP response.
|
|
|
1187 |
*/
|
|
|
1188 |
public function cache_callback($operation, $payload)
|
|
|
1189 |
{
|
|
|
1190 |
// Disable the cache flow since it's already been handled.
|
|
|
1191 |
$this->use_cache_flow = false;
|
|
|
1192 |
|
|
|
1193 |
// Make the request
|
|
|
1194 |
$response = $this->authenticate($operation, $payload);
|
|
|
1195 |
|
|
|
1196 |
// If this is an XML document, convert it back to a string.
|
|
|
1197 |
if (isset($response->body) && ($response->body instanceof SimpleXMLElement))
|
|
|
1198 |
{
|
|
|
1199 |
$response->body = $response->body->asXML();
|
|
|
1200 |
}
|
|
|
1201 |
|
|
|
1202 |
return $response;
|
|
|
1203 |
}
|
|
|
1204 |
|
|
|
1205 |
/**
|
|
|
1206 |
* Used for caching the results of a batch request. Never call this method directly; it is used
|
|
|
1207 |
* internally by the caching system.
|
|
|
1208 |
*
|
|
|
1209 |
* @param CFBatchRequest $batch (Required) The batch request object to send.
|
|
|
1210 |
* @return CFResponse A parsed HTTP response.
|
|
|
1211 |
*/
|
|
|
1212 |
public function cache_callback_batch(CFBatchRequest $batch)
|
|
|
1213 |
{
|
|
|
1214 |
return $batch->send();
|
|
|
1215 |
}
|
|
|
1216 |
|
|
|
1217 |
/**
|
|
|
1218 |
* Deletes a cached <CFResponse> object using the specified cache storage type.
|
|
|
1219 |
*
|
|
|
1220 |
* @return boolean A value of `true` if cached object exists and is successfully deleted, otherwise `false`.
|
|
|
1221 |
*/
|
|
|
1222 |
public function delete_cache()
|
|
|
1223 |
{
|
|
|
1224 |
$this->use_cache_flow = true;
|
|
|
1225 |
$this->delete_cache = true;
|
|
|
1226 |
|
|
|
1227 |
return $this;
|
|
|
1228 |
}
|
|
|
1229 |
}
|
|
|
1230 |
|
|
|
1231 |
|
|
|
1232 |
/**
|
|
|
1233 |
* Contains the functionality for auto-loading service classes.
|
|
|
1234 |
*/
|
|
|
1235 |
class CFLoader
|
|
|
1236 |
{
|
|
|
1237 |
/*%******************************************************************************************%*/
|
|
|
1238 |
// AUTO-LOADER
|
|
|
1239 |
|
|
|
1240 |
/**
|
|
|
1241 |
* Automatically load classes that aren't included.
|
|
|
1242 |
*
|
|
|
1243 |
* @param string $class (Required) The classname to load.
|
|
|
1244 |
* @return boolean Whether or not the file was successfully loaded.
|
|
|
1245 |
*/
|
|
|
1246 |
public static function autoloader($class)
|
|
|
1247 |
{
|
|
|
1248 |
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
|
|
1249 |
|
|
|
1250 |
// Amazon SDK classes
|
|
|
1251 |
if (strstr($class, 'Amazon'))
|
|
|
1252 |
{
|
|
|
1253 |
if (file_exists($require_this = $path . 'services' . DIRECTORY_SEPARATOR . str_ireplace('Amazon', '', strtolower($class)) . '.class.php'))
|
|
|
1254 |
{
|
|
|
1255 |
require_once $require_this;
|
|
|
1256 |
return true;
|
|
|
1257 |
}
|
|
|
1258 |
|
|
|
1259 |
return false;
|
|
|
1260 |
}
|
|
|
1261 |
|
|
|
1262 |
// Utility classes
|
|
|
1263 |
elseif (strstr($class, 'CF'))
|
|
|
1264 |
{
|
|
|
1265 |
if (file_exists($require_this = $path . 'utilities' . DIRECTORY_SEPARATOR . str_ireplace('CF', '', strtolower($class)) . '.class.php'))
|
|
|
1266 |
{
|
|
|
1267 |
require_once $require_this;
|
|
|
1268 |
return true;
|
|
|
1269 |
}
|
|
|
1270 |
|
|
|
1271 |
return false;
|
|
|
1272 |
}
|
|
|
1273 |
|
|
|
1274 |
// Load CacheCore
|
|
|
1275 |
elseif (strstr($class, 'Cache'))
|
|
|
1276 |
{
|
|
|
1277 |
if (file_exists($require_this = $path . 'lib' . DIRECTORY_SEPARATOR . 'cachecore' . DIRECTORY_SEPARATOR . strtolower($class) . '.class.php'))
|
|
|
1278 |
{
|
|
|
1279 |
require_once $require_this;
|
|
|
1280 |
return true;
|
|
|
1281 |
}
|
|
|
1282 |
|
|
|
1283 |
return false;
|
|
|
1284 |
}
|
|
|
1285 |
|
|
|
1286 |
// Load RequestCore
|
|
|
1287 |
elseif (strstr($class, 'RequestCore') || strstr($class, 'ResponseCore'))
|
|
|
1288 |
{
|
|
|
1289 |
if (file_exists($require_this = $path . 'lib' . DIRECTORY_SEPARATOR . 'requestcore' . DIRECTORY_SEPARATOR . 'requestcore.class.php'))
|
|
|
1290 |
{
|
|
|
1291 |
require_once $require_this;
|
|
|
1292 |
return true;
|
|
|
1293 |
}
|
|
|
1294 |
|
|
|
1295 |
return false;
|
|
|
1296 |
}
|
|
|
1297 |
|
|
|
1298 |
// Load array-to-domdocument
|
|
|
1299 |
elseif (strstr($class, 'Array2DOM'))
|
|
|
1300 |
{
|
|
|
1301 |
if (file_exists($require_this = $path . 'lib' . DIRECTORY_SEPARATOR . 'dom' . DIRECTORY_SEPARATOR . 'ArrayToDOMDocument.php'))
|
|
|
1302 |
{
|
|
|
1303 |
require_once $require_this;
|
|
|
1304 |
return true;
|
|
|
1305 |
}
|
|
|
1306 |
|
|
|
1307 |
return false;
|
|
|
1308 |
}
|
|
|
1309 |
|
|
|
1310 |
// Load Authentication Signers
|
|
|
1311 |
elseif (strstr($class, 'Auth'))
|
|
|
1312 |
{
|
|
|
1313 |
if (file_exists($require_this = $path . 'authentication' . DIRECTORY_SEPARATOR . str_replace('auth', 'signature_', strtolower($class)) . '.class.php'))
|
|
|
1314 |
{
|
|
|
1315 |
require_once $require_this;
|
|
|
1316 |
return true;
|
|
|
1317 |
}
|
|
|
1318 |
|
|
|
1319 |
return false;
|
|
|
1320 |
}
|
|
|
1321 |
|
|
|
1322 |
// Load Signer interface
|
|
|
1323 |
elseif ($class === 'Signer')
|
|
|
1324 |
{
|
|
|
1325 |
if (!interface_exists('Signable', false) &&
|
|
|
1326 |
file_exists($require_this = $path . 'authentication' . DIRECTORY_SEPARATOR . 'signable.interface.php'))
|
|
|
1327 |
{
|
|
|
1328 |
require_once $require_this;
|
|
|
1329 |
}
|
|
|
1330 |
|
|
|
1331 |
if (file_exists($require_this = $path . 'authentication' . DIRECTORY_SEPARATOR . 'signer.abstract.php'))
|
|
|
1332 |
{
|
|
|
1333 |
require_once $require_this;
|
|
|
1334 |
return true;
|
|
|
1335 |
}
|
|
|
1336 |
|
|
|
1337 |
return false;
|
|
|
1338 |
}
|
|
|
1339 |
|
|
|
1340 |
// Load Symfony YAML classes
|
|
|
1341 |
elseif (strstr($class, 'sfYaml'))
|
|
|
1342 |
{
|
|
|
1343 |
if (file_exists($require_this = $path . 'lib' . DIRECTORY_SEPARATOR . 'yaml' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'sfYaml.php'))
|
|
|
1344 |
{
|
|
|
1345 |
require_once $require_this;
|
|
|
1346 |
return true;
|
|
|
1347 |
}
|
|
|
1348 |
|
|
|
1349 |
return false;
|
|
|
1350 |
}
|
|
|
1351 |
|
|
|
1352 |
return false;
|
|
|
1353 |
}
|
|
|
1354 |
}
|
|
|
1355 |
|
|
|
1356 |
// Register the autoloader.
|
|
|
1357 |
spl_autoload_register(array('CFLoader', 'autoloader'));
|
|
|
1358 |
|
|
|
1359 |
|
|
|
1360 |
/*%******************************************************************************************%*/
|
|
|
1361 |
// CONFIGURATION
|
|
|
1362 |
|
|
|
1363 |
// Look for include file in the same directory (e.g. `./config.inc.php`).
|
|
|
1364 |
if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc.php'))
|
|
|
1365 |
{
|
|
|
1366 |
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc.php';
|
|
|
1367 |
}
|
|
|
1368 |
// Fallback to `~/.aws/sdk/config.inc.php`
|
|
|
1369 |
else
|
|
|
1370 |
{
|
|
|
1371 |
if (!isset($_ENV['HOME']) && isset($_SERVER['HOME']))
|
|
|
1372 |
{
|
|
|
1373 |
$_ENV['HOME'] = $_SERVER['HOME'];
|
|
|
1374 |
}
|
|
|
1375 |
elseif (!isset($_ENV['HOME']) && !isset($_SERVER['HOME']))
|
|
|
1376 |
{
|
|
|
1377 |
$_ENV['HOME'] = `cd ~ && pwd`;
|
|
|
1378 |
if (!$_ENV['HOME'])
|
|
|
1379 |
{
|
|
|
1380 |
switch (strtolower(PHP_OS))
|
|
|
1381 |
{
|
|
|
1382 |
case 'darwin':
|
|
|
1383 |
$_ENV['HOME'] = '/Users/' . get_current_user();
|
|
|
1384 |
break;
|
|
|
1385 |
|
|
|
1386 |
case 'windows':
|
|
|
1387 |
case 'winnt':
|
|
|
1388 |
case 'win32':
|
|
|
1389 |
$_ENV['HOME'] = 'c:' . DIRECTORY_SEPARATOR . 'Documents and Settings' . DIRECTORY_SEPARATOR . get_current_user();
|
|
|
1390 |
break;
|
|
|
1391 |
|
|
|
1392 |
default:
|
|
|
1393 |
$_ENV['HOME'] = '/home/' . get_current_user();
|
|
|
1394 |
break;
|
|
|
1395 |
}
|
|
|
1396 |
}
|
|
|
1397 |
}
|
|
|
1398 |
|
|
|
1399 |
if (getenv('HOME') && file_exists(getenv('HOME') . DIRECTORY_SEPARATOR . '.aws' . DIRECTORY_SEPARATOR . 'sdk' . DIRECTORY_SEPARATOR . 'config.inc.php'))
|
|
|
1400 |
{
|
|
|
1401 |
include_once getenv('HOME') . DIRECTORY_SEPARATOR . '.aws' . DIRECTORY_SEPARATOR . 'sdk' . DIRECTORY_SEPARATOR . 'config.inc.php';
|
|
|
1402 |
}
|
|
|
1403 |
}
|