sdk.class.php 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313
  1. <?php
  2. /*
  3. * Copyright 2010-2011 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. // EXCEPTIONS
  18. /**
  19. * Default CFRuntime Exception.
  20. */
  21. class CFRuntime_Exception extends Exception {}
  22. /*%******************************************************************************************%*/
  23. // DETERMINE WHAT ENVIRONMENT DATA TO ADD TO THE USERAGENT FOR METRIC TRACKING
  24. /*
  25. Define a temporary callback function for this calculation. Get the PHP version and any
  26. required/optional extensions that are leveraged.
  27. Tracking this data gives Amazon better metrics about what configurations are being used
  28. so that forward-looking plans for the code can be made with more certainty (e.g. What
  29. version of PHP are most people running? Do they tend to have the latest PCRE?).
  30. */
  31. function __aws_sdk_ua_callback()
  32. {
  33. $ua_append = '';
  34. $extensions = get_loaded_extensions();
  35. $sorted_extensions = array();
  36. if ($extensions)
  37. {
  38. foreach ($extensions as $extension)
  39. {
  40. if ($extension === 'curl' && function_exists('curl_version'))
  41. {
  42. $curl_version = curl_version();
  43. $sorted_extensions[strtolower($extension)] = $curl_version['version'];
  44. }
  45. elseif ($extension === 'pcre' && defined('PCRE_VERSION'))
  46. {
  47. $pcre_version = explode(' ', PCRE_VERSION);
  48. $sorted_extensions[strtolower($extension)] = $pcre_version[0];
  49. }
  50. elseif ($extension === 'openssl' && defined('OPENSSL_VERSION_TEXT'))
  51. {
  52. $openssl_version = explode(' ', OPENSSL_VERSION_TEXT);
  53. $sorted_extensions[strtolower($extension)] = $openssl_version[1];
  54. }
  55. else
  56. {
  57. $sorted_extensions[strtolower($extension)] = phpversion($extension);
  58. }
  59. }
  60. }
  61. foreach (array('simplexml', 'json', 'pcre', 'spl', 'curl', 'openssl', 'apc', 'xcache', 'memcache', 'memcached', 'pdo', 'pdo_sqlite', 'sqlite', 'sqlite3', 'zlib', 'xdebug') as $ua_ext)
  62. {
  63. if (isset($sorted_extensions[$ua_ext]) && $sorted_extensions[$ua_ext])
  64. {
  65. $ua_append .= ' ' . $ua_ext . '/' . $sorted_extensions[$ua_ext];
  66. }
  67. elseif (isset($sorted_extensions[$ua_ext]))
  68. {
  69. $ua_append .= ' ' . $ua_ext . '/0';
  70. }
  71. }
  72. foreach (array('memory_limit', 'date.timezone', 'open_basedir', 'safe_mode', 'zend.enable_gc') as $cfg)
  73. {
  74. $cfg_value = get_cfg_var($cfg);
  75. if (in_array($cfg, array('memory_limit', 'date.timezone'), true))
  76. {
  77. $ua_append .= ' ' . $cfg . '/' . str_replace('/', '.', $cfg_value);
  78. }
  79. elseif (in_array($cfg, array('open_basedir', 'safe_mode', 'zend.enable_gc'), true))
  80. {
  81. if ($cfg_value === false || $cfg_value === '' || $cfg_value === 0)
  82. {
  83. $cfg_value = 'off';
  84. }
  85. elseif ($cfg_value === true || $cfg_value === '1' || $cfg_value === 1)
  86. {
  87. $cfg_value = 'on';
  88. }
  89. $ua_append .= ' ' . $cfg . '/' . $cfg_value;
  90. }
  91. }
  92. return $ua_append;
  93. }
  94. /*%******************************************************************************************%*/
  95. // INTERMEDIARY CONSTANTS
  96. define('CFRUNTIME_NAME', 'aws-sdk-php');
  97. define('CFRUNTIME_VERSION', '1.5.0.1');
  98. // define('CFRUNTIME_BUILD', gmdate('YmdHis', filemtime(__FILE__))); // @todo: Hardcode for release.
  99. define('CFRUNTIME_BUILD', '20111221014733');
  100. 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());
  101. /*%******************************************************************************************%*/
  102. // CLASS
  103. /**
  104. * Core functionality and default settings shared across all SDK classes. All methods and properties in this
  105. * class are inherited by the service-specific classes.
  106. *
  107. * @version 2011.11.18
  108. * @license See the included NOTICE.md file for more information.
  109. * @copyright See the included NOTICE.md file for more information.
  110. * @link http://aws.amazon.com/php/ PHP Developer Center
  111. */
  112. class CFRuntime
  113. {
  114. /*%******************************************************************************************%*/
  115. // CONSTANTS
  116. /**
  117. * Name of the software.
  118. */
  119. const NAME = CFRUNTIME_NAME;
  120. /**
  121. * Version of the software.
  122. */
  123. const VERSION = CFRUNTIME_VERSION;
  124. /**
  125. * Build ID of the software.
  126. */
  127. const BUILD = CFRUNTIME_BUILD;
  128. /**
  129. * User agent string used to identify the software.
  130. */
  131. const USERAGENT = CFRUNTIME_USERAGENT;
  132. /*%******************************************************************************************%*/
  133. // PROPERTIES
  134. /**
  135. * The Amazon API Key.
  136. */
  137. public $key;
  138. /**
  139. * The Amazon API Secret Key.
  140. */
  141. public $secret_key;
  142. /**
  143. * The Amazon Authentication Token.
  144. */
  145. public $auth_token;
  146. /**
  147. * Handle for the utility functions.
  148. */
  149. public $util;
  150. /**
  151. * An identifier for the current AWS service.
  152. */
  153. public $service = null;
  154. /**
  155. * The supported API version.
  156. */
  157. public $api_version = null;
  158. /**
  159. * The state of whether auth should be handled as AWS Query.
  160. */
  161. public $use_aws_query = true;
  162. /**
  163. * The default class to use for utilities (defaults to <CFUtilities>).
  164. */
  165. public $utilities_class = 'CFUtilities';
  166. /**
  167. * The default class to use for HTTP requests (defaults to <CFRequest>).
  168. */
  169. public $request_class = 'CFRequest';
  170. /**
  171. * The default class to use for HTTP responses (defaults to <CFResponse>).
  172. */
  173. public $response_class = 'CFResponse';
  174. /**
  175. * The default class to use for parsing XML (defaults to <CFSimpleXML>).
  176. */
  177. public $parser_class = 'CFSimpleXML';
  178. /**
  179. * The default class to use for handling batch requests (defaults to <CFBatchRequest>).
  180. */
  181. public $batch_class = 'CFBatchRequest';
  182. /**
  183. * The number of seconds to adjust the request timestamp by (defaults to 0).
  184. */
  185. public $adjust_offset = 0;
  186. /**
  187. * The state of SSL/HTTPS use.
  188. */
  189. public $use_ssl = true;
  190. /**
  191. * The state of SSL certificate verification.
  192. */
  193. public $ssl_verification = true;
  194. /**
  195. * The proxy to use for connecting.
  196. */
  197. public $proxy = null;
  198. /**
  199. * The alternate hostname to use, if any.
  200. */
  201. public $hostname = null;
  202. /**
  203. * The state of the capability to override the hostname with <set_hostname()>.
  204. */
  205. public $override_hostname = true;
  206. /**
  207. * The alternate port number to use, if any.
  208. */
  209. public $port_number = null;
  210. /**
  211. * The alternate resource prefix to use, if any.
  212. */
  213. public $resource_prefix = null;
  214. /**
  215. * The state of cache flow usage.
  216. */
  217. public $use_cache_flow = false;
  218. /**
  219. * The caching class to use.
  220. */
  221. public $cache_class = null;
  222. /**
  223. * The caching location to use.
  224. */
  225. public $cache_location = null;
  226. /**
  227. * When the cache should be considered stale.
  228. */
  229. public $cache_expires = null;
  230. /**
  231. * The state of cache compression.
  232. */
  233. public $cache_compress = null;
  234. /**
  235. * The current instantiated cache object.
  236. */
  237. public $cache_object = null;
  238. /**
  239. * The current instantiated batch request object.
  240. */
  241. public $batch_object = null;
  242. /**
  243. * The internally instantiated batch request object.
  244. */
  245. public $internal_batch_object = null;
  246. /**
  247. * The state of batch flow usage.
  248. */
  249. public $use_batch_flow = false;
  250. /**
  251. * The state of the cache deletion setting.
  252. */
  253. public $delete_cache = false;
  254. /**
  255. * The state of the debug mode setting.
  256. */
  257. public $debug_mode = false;
  258. /**
  259. * The number of times to retry failed requests.
  260. */
  261. public $max_retries = 3;
  262. /**
  263. * The user-defined callback function to call when a stream is read from.
  264. */
  265. public $registered_streaming_read_callback = null;
  266. /**
  267. * The user-defined callback function to call when a stream is written to.
  268. */
  269. public $registered_streaming_write_callback = null;
  270. /**
  271. * The credentials to use for authentication.
  272. */
  273. public $credentials = array();
  274. /**
  275. * The authentication class to use.
  276. */
  277. public $auth_class = null;
  278. /**
  279. * The operation to execute.
  280. */
  281. public $operation = null;
  282. /**
  283. * The payload to send.
  284. */
  285. public $payload = array();
  286. /**
  287. * The string prefix to prepend to the operation name.
  288. */
  289. public $operation_prefix = '';
  290. /**
  291. * The number of times a request has been retried.
  292. */
  293. public $redirects = 0;
  294. /*%******************************************************************************************%*/
  295. // CONSTRUCTOR
  296. /**
  297. * The constructor. This class should not be instantiated directly. Rather, a service-specific class
  298. * should be instantiated.
  299. *
  300. * @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
  301. * <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>
  302. * <li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
  303. * <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>
  304. * <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>
  305. * <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>
  306. * <li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li></ul>
  307. * @return void
  308. */
  309. public function __construct(array $options = array())
  310. {
  311. // Instantiate the utilities class.
  312. $this->util = new $this->utilities_class();
  313. // Determine the current service.
  314. $this->service = get_class($this);
  315. // Store the requested credentials
  316. $this->credentials = CFCredentials::get(
  317. (isset($options['credentials']) ? $options['credentials'] : CFCredentials::DEFAULT_KEY)
  318. );
  319. $this->credentials = new CFCredential(array_merge($this->credentials->to_array(), $options));
  320. // Automatically enable whichever caching mechanism is set to default.
  321. $this->set_cache_config($this->credentials->default_cache_config);
  322. if (isset($options['key']) && isset($options['secret']))
  323. {
  324. $this->key = $options['key'];
  325. $this->secret_key = $options['secret'];
  326. $this->auth_token = isset($options['token']) ? $options['token'] : null;
  327. return;
  328. }
  329. else
  330. {
  331. $this->key = $this->credentials->key;
  332. $this->secret_key = $this->credentials->secret;
  333. $this->auth_token = $this->credentials->token;
  334. return;
  335. }
  336. }
  337. /**
  338. * Alternate approach to constructing a new instance. Supports chaining.
  339. *
  340. * @param array $options (Optional) An associative array of parameters that can have the following keys: <ul>
  341. * <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>
  342. * <li><code>credentials</code> - <code>string</code> - Optional - The name of the credential set to use for authentication.</li>
  343. * <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>
  344. * <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>
  345. * <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>
  346. * <li><code>token</code> - <code>string</code> - Optional - An AWS session token.</li></ul>
  347. * @return void
  348. */
  349. public static function factory(array $options = array())
  350. {
  351. if (version_compare(PHP_VERSION, '5.3.0', '<'))
  352. {
  353. throw new Exception('PHP 5.3 or newer is required to instantiate a new class with CLASS::factory().');
  354. }
  355. $self = get_called_class();
  356. return new $self($options);
  357. }
  358. /*%******************************************************************************************%*/
  359. // MAGIC METHODS
  360. /**
  361. * A magic method that allows `camelCase` method names to be translated into `snake_case` names.
  362. *
  363. * @param string $name (Required) The name of the method.
  364. * @param array $arguments (Required) The arguments passed to the method.
  365. * @return mixed The results of the intended method.
  366. */
  367. public function __call($name, $arguments)
  368. {
  369. // Convert camelCase method calls to snake_case.
  370. $method_name = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name));
  371. if (method_exists($this, $method_name))
  372. {
  373. return call_user_func_array(array($this, $method_name), $arguments);
  374. }
  375. throw new CFRuntime_Exception('The method ' . $name . '() is undefined. Attempted to map to ' . $method_name . '() which is also undefined. Error occurred');
  376. }
  377. /*%******************************************************************************************%*/
  378. // SET CUSTOM SETTINGS
  379. /**
  380. * Set the proxy settings to use.
  381. *
  382. * @param string $proxy (Required) Accepts proxy credentials in the following format: `proxy://user:pass@hostname:port`
  383. * @return $this A reference to the current instance.
  384. */
  385. public function set_proxy($proxy)
  386. {
  387. $this->proxy = $proxy;
  388. return $this;
  389. }
  390. /**
  391. * Set the hostname to connect to. This is useful for alternate services that are API-compatible with
  392. * AWS, but run from a different hostname.
  393. *
  394. * @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.
  395. * @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.
  396. * @return $this A reference to the current instance.
  397. */
  398. public function set_hostname($hostname, $port_number = null)
  399. {
  400. if ($this->override_hostname)
  401. {
  402. $this->hostname = $hostname;
  403. if ($port_number)
  404. {
  405. $this->port_number = $port_number;
  406. $this->hostname .= ':' . (string) $this->port_number;
  407. }
  408. }
  409. return $this;
  410. }
  411. /**
  412. * Set the resource prefix to use. This method is useful for alternate services that are API-compatible
  413. * with AWS.
  414. *
  415. * @param string $prefix (Required) An alternate prefix to prepend to the resource path. Useful for mock or test applications.
  416. * @return $this A reference to the current instance.
  417. */
  418. public function set_resource_prefix($prefix)
  419. {
  420. $this->resource_prefix = $prefix;
  421. return $this;
  422. }
  423. /**
  424. * Disables any subsequent use of the <set_hostname()> method.
  425. *
  426. * @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`.
  427. * @return $this A reference to the current instance.
  428. */
  429. public function allow_hostname_override($override = true)
  430. {
  431. $this->override_hostname = $override;
  432. return $this;
  433. }
  434. /**
  435. * Disables SSL/HTTPS connections for hosts that don't support them. Some services, however, still
  436. * require SSL support.
  437. *
  438. * This method will throw a user warning when invoked, which can be hidden by changing your
  439. * <php:error_reporting()> settings.
  440. *
  441. * @return $this A reference to the current instance.
  442. */
  443. public function disable_ssl()
  444. {
  445. trigger_error('Disabling SSL connections is potentially unsafe and highly discouraged.', E_USER_WARNING);
  446. $this->use_ssl = false;
  447. return $this;
  448. }
  449. /**
  450. * Disables the verification of the SSL Certificate Authority. Doing so can enable an attacker to carry
  451. * out a man-in-the-middle attack.
  452. *
  453. * https://secure.wikimedia.org/wikipedia/en/wiki/Man-in-the-middle_attack
  454. *
  455. * This method will throw a user warning when invoked, which can be hidden by changing your
  456. * <php:error_reporting()> settings.
  457. *
  458. * @return $this A reference to the current instance.
  459. */
  460. public function disable_ssl_verification($ssl_verification = false)
  461. {
  462. 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);
  463. $this->ssl_verification = $ssl_verification;
  464. return $this;
  465. }
  466. /**
  467. * Enables HTTP request/response header logging to `STDERR`.
  468. *
  469. * @param boolean $enabled (Optional) Whether or not to enable debug mode. Defaults to `true`.
  470. * @return $this A reference to the current instance.
  471. */
  472. public function enable_debug_mode($enabled = true)
  473. {
  474. $this->debug_mode = $enabled;
  475. return $this;
  476. }
  477. /**
  478. * Sets the maximum number of times to retry failed requests.
  479. *
  480. * @param integer $retries (Optional) The maximum number of times to retry failed requests. Defaults to `3`.
  481. * @return $this A reference to the current instance.
  482. */
  483. public function set_max_retries($retries = 3)
  484. {
  485. $this->max_retries = $retries;
  486. return $this;
  487. }
  488. /**
  489. * Set the caching configuration to use for response caching.
  490. *
  491. * @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>
  492. * @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`.
  493. * @return $this A reference to the current instance.
  494. */
  495. public function set_cache_config($location, $gzip = true)
  496. {
  497. // If we have an array, we're probably passing in Memcached servers and ports.
  498. if (is_array($location))
  499. {
  500. $this->cache_class = 'CacheMC';
  501. }
  502. else
  503. {
  504. // I would expect locations like `/tmp/cache`, `pdo.mysql://user:pass@hostname:port`, `pdo.sqlite:memory:`, and `apc`.
  505. $type = strtolower(substr($location, 0, 3));
  506. switch ($type)
  507. {
  508. case 'apc':
  509. $this->cache_class = 'CacheAPC';
  510. break;
  511. case 'xca': // First three letters of `xcache`
  512. $this->cache_class = 'CacheXCache';
  513. break;
  514. case 'pdo':
  515. $this->cache_class = 'CachePDO';
  516. $location = substr($location, 4);
  517. break;
  518. default:
  519. $this->cache_class = 'CacheFile';
  520. break;
  521. }
  522. }
  523. // Set the remaining cache information.
  524. $this->cache_location = $location;
  525. $this->cache_compress = $gzip;
  526. return $this;
  527. }
  528. /**
  529. * Register a callback function to execute whenever a data stream is read from using
  530. * <CFRequest::streaming_read_callback()>.
  531. *
  532. * The user-defined callback function should accept three arguments:
  533. *
  534. * <ul>
  535. * <li><code>$curl_handle</code> - <code>resource</code> - Required - The cURL handle resource that represents the in-progress transfer.</li>
  536. * <li><code>$file_handle</code> - <code>resource</code> - Required - The file handle resource that represents the file on the local file system.</li>
  537. * <li><code>$length</code> - <code>integer</code> - Required - The length in kilobytes of the data chunk that was transferred.</li>
  538. * </ul>
  539. *
  540. * @param string|array|function $callback (Required) The callback function is called by <php:call_user_func()>, so you can pass the following values: <ul>
  541. * <li>The name of a global function to execute, passed as a string.</li>
  542. * <li>A method to execute, passed as <code>array('ClassName', 'MethodName')</code>.</li>
  543. * <li>An anonymous function (PHP 5.3+).</li></ul>
  544. * @return $this A reference to the current instance.
  545. */
  546. public function register_streaming_read_callback($callback)
  547. {
  548. $this->registered_streaming_read_callback = $callback;
  549. return $this;
  550. }
  551. /**
  552. * Register a callback function to execute whenever a data stream is written to using
  553. * <CFRequest::streaming_write_callback()>.
  554. *
  555. * The user-defined callback function should accept two arguments:
  556. *
  557. * <ul>
  558. * <li><code>$curl_handle</code> - <code>resource</code> - Required - The cURL handle resource that represents the in-progress transfer.</li>
  559. * <li><code>$length</code> - <code>integer</code> - Required - The length in kilobytes of the data chunk that was transferred.</li>
  560. * </ul>
  561. *
  562. * @param string|array|function $callback (Required) The callback function is called by <php:call_user_func()>, so you can pass the following values: <ul>
  563. * <li>The name of a global function to execute, passed as a string.</li>
  564. * <li>A method to execute, passed as <code>array('ClassName', 'MethodName')</code>.</li>
  565. * <li>An anonymous function (PHP 5.3+).</li></ul>
  566. * @return $this A reference to the current instance.
  567. */
  568. public function register_streaming_write_callback($callback)
  569. {
  570. $this->registered_streaming_write_callback = $callback;
  571. return $this;
  572. }
  573. /*%******************************************************************************************%*/
  574. // SET CUSTOM CLASSES
  575. /**
  576. * Set a custom class for this functionality. Use this method when extending/overriding existing classes
  577. * with new functionality.
  578. *
  579. * The replacement class must extend from <CFUtilities>.
  580. *
  581. * @param string $class (Optional) The name of the new class to use for this functionality.
  582. * @return $this A reference to the current instance.
  583. */
  584. public function set_utilities_class($class = 'CFUtilities')
  585. {
  586. $this->utilities_class = $class;
  587. $this->util = new $this->utilities_class();
  588. return $this;
  589. }
  590. /**
  591. * Set a custom class for this functionality. Use this method when extending/overriding existing classes
  592. * with new functionality.
  593. *
  594. * The replacement class must extend from <CFRequest>.
  595. *
  596. * @param string $class (Optional) The name of the new class to use for this functionality.
  597. * @param $this A reference to the current instance.
  598. */
  599. public function set_request_class($class = 'CFRequest')
  600. {
  601. $this->request_class = $class;
  602. return $this;
  603. }
  604. /**
  605. * Set a custom class for this functionality. Use this method when extending/overriding existing classes
  606. * with new functionality.
  607. *
  608. * The replacement class must extend from <CFResponse>.
  609. *
  610. * @param string $class (Optional) The name of the new class to use for this functionality.
  611. * @return $this A reference to the current instance.
  612. */
  613. public function set_response_class($class = 'CFResponse')
  614. {
  615. $this->response_class = $class;
  616. return $this;
  617. }
  618. /**
  619. * Set a custom class for this functionality. Use this method when extending/overriding existing classes
  620. * with new functionality.
  621. *
  622. * The replacement class must extend from <CFSimpleXML>.
  623. *
  624. * @param string $class (Optional) The name of the new class to use for this functionality.
  625. * @return $this A reference to the current instance.
  626. */
  627. public function set_parser_class($class = 'CFSimpleXML')
  628. {
  629. $this->parser_class = $class;
  630. return $this;
  631. }
  632. /**
  633. * Set a custom class for this functionality. Use this method when extending/overriding existing classes
  634. * with new functionality.
  635. *
  636. * The replacement class must extend from <CFBatchRequest>.
  637. *
  638. * @param string $class (Optional) The name of the new class to use for this functionality.
  639. * @return $this A reference to the current instance.
  640. */
  641. public function set_batch_class($class = 'CFBatchRequest')
  642. {
  643. $this->batch_class = $class;
  644. return $this;
  645. }
  646. /*%******************************************************************************************%*/
  647. // AUTHENTICATION
  648. /**
  649. * Default, shared method for authenticating a connection to AWS.
  650. *
  651. * @return CFResponse Object containing a parsed HTTP response.
  652. */
  653. public function authenticate($operation, $payload)
  654. {
  655. if (substr($operation, 0, strlen($this->operation_prefix)) !== $this->operation_prefix)
  656. {
  657. $operation = $this->operation_prefix . $operation;
  658. }
  659. $method_arguments = func_get_args();
  660. $curlopts = array();
  661. // Extract the custom CURLOPT settings from the payload
  662. if (is_array($payload) && isset($payload['curlopts']))
  663. {
  664. $curlopts = $payload['curlopts'];
  665. unset($payload['curlopts']);
  666. }
  667. // Determine whether the response or curl handle should be returned
  668. $return_curl_handle = isset($payload['returnCurlHandle']) ? $payload['returnCurlHandle'] : false;
  669. unset($payload['returnCurlHandle']);
  670. // Use the caching flow to determine if we need to do a round-trip to the server.
  671. if ($this->use_cache_flow)
  672. {
  673. // Generate an identifier specific to this particular set of arguments.
  674. $cache_id = $this->key . '_' . get_class($this) . '_' . $operation . '_' . sha1(serialize($method_arguments));
  675. // Instantiate the appropriate caching object.
  676. $this->cache_object = new $this->cache_class($cache_id, $this->cache_location, $this->cache_expires, $this->cache_compress);
  677. if ($this->delete_cache)
  678. {
  679. $this->use_cache_flow = false;
  680. $this->delete_cache = false;
  681. return $this->cache_object->delete();
  682. }
  683. // Invoke the cache callback function to determine whether to pull data from the cache or make a fresh request.
  684. $data = $this->cache_object->response_manager(array($this, 'cache_callback'), $method_arguments);
  685. // Parse the XML body
  686. $data = $this->parse_callback($data);
  687. // End!
  688. return $data;
  689. }
  690. /*%******************************************************************************************%*/
  691. // Signer
  692. $signer = new $this->auth_class($this->hostname, $operation, $payload, $this->credentials);
  693. $signer->key = $this->key;
  694. $signer->secret_key = $this->secret_key;
  695. $signer->auth_token = $this->auth_token;
  696. $signer->api_version = $this->api_version;
  697. $signer->utilities_class = $this->utilities_class;
  698. $signer->request_class = $this->request_class;
  699. $signer->response_class = $this->response_class;
  700. $signer->use_ssl = $this->use_ssl;
  701. $signer->proxy = $this->proxy;
  702. $signer->util = $this->util;
  703. $signer->registered_streaming_read_callback = $this->registered_streaming_read_callback;
  704. $signer->registered_streaming_write_callback = $this->registered_streaming_write_callback;
  705. $request = $signer->authenticate();
  706. // Update RequestCore settings
  707. $request->request_class = $this->request_class;
  708. $request->response_class = $this->response_class;
  709. $request->ssl_verification = $this->ssl_verification;
  710. /*%******************************************************************************************%*/
  711. // Debug mode
  712. if ($this->debug_mode)
  713. {
  714. $request->debug_mode = $this->debug_mode;
  715. }
  716. // Set custom CURLOPT settings
  717. if (count($curlopts))
  718. {
  719. $request->set_curlopts($curlopts);
  720. }
  721. // Manage the (newer) batch request API or the (older) returnCurlHandle setting.
  722. if ($this->use_batch_flow)
  723. {
  724. $handle = $request->prep_request();
  725. $this->batch_object->add($handle);
  726. $this->use_batch_flow = false;
  727. return $handle;
  728. }
  729. elseif ($return_curl_handle)
  730. {
  731. return $request->prep_request();
  732. }
  733. // Send!
  734. $request->send_request();
  735. // Prepare the response.
  736. $headers = $request->get_response_header();
  737. $headers['x-aws-stringtosign'] = $signer->string_to_sign;
  738. $headers['x-aws-request-headers'] = $request->request_headers;
  739. $headers['x-aws-body'] = $signer->querystring;
  740. $data = new $this->response_class($headers, $this->parse_callback($request->get_response_body(), $headers), $request->get_response_code());
  741. // Was it Amazon's fault the request failed? Retry the request until we reach $max_retries.
  742. if (
  743. ((integer) $request->get_response_code() === 400 && (string) $request->get_response_body() === '{"__type": "com.amazon.coral.availability#ThrottlingException"}') || // Bad Request (throttled)
  744. (integer) $request->get_response_code() === 500 || // Internal Error (presumably transient)
  745. (integer) $request->get_response_code() === 503) // Service Unavailable (presumably transient)
  746. {
  747. if ($this->redirects <= $this->max_retries)
  748. {
  749. // Exponential backoff
  750. $delay = (integer) (pow(4, $this->redirects) * 100000);
  751. usleep($delay);
  752. $this->redirects++;
  753. $data = $this->authenticate($operation, $payload);
  754. }
  755. }
  756. $this->redirects = 0;
  757. return $data;
  758. }
  759. /*%******************************************************************************************%*/
  760. // BATCH REQUEST LAYER
  761. /**
  762. * Specifies that the intended request should be queued for a later batch request.
  763. *
  764. * @param CFBatchRequest $queue (Optional) The <CFBatchRequest> instance to use for managing batch requests. If not available, it generates a new instance of <CFBatchRequest>.
  765. * @return $this A reference to the current instance.
  766. */
  767. public function batch(CFBatchRequest &$queue = null)
  768. {
  769. if ($queue)
  770. {
  771. $this->batch_object = $queue;
  772. }
  773. elseif ($this->internal_batch_object)
  774. {
  775. $this->batch_object = &$this->internal_batch_object;
  776. }
  777. else
  778. {
  779. $this->internal_batch_object = new $this->batch_class();
  780. $this->batch_object = &$this->internal_batch_object;
  781. }
  782. $this->use_batch_flow = true;
  783. return $this;
  784. }
  785. /**
  786. * Executes the batch request queue by sending all queued requests.
  787. *
  788. * @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.
  789. * @return array An array of <CFResponse> objects.
  790. */
  791. public function send($clear_after_send = true)
  792. {
  793. if ($this->use_batch_flow)
  794. {
  795. // When we send the request, disable batch flow.
  796. $this->use_batch_flow = false;
  797. // If we're not caching, simply send the request.
  798. if (!$this->use_cache_flow)
  799. {
  800. $response = $this->batch_object->send();
  801. $parsed_data = array_map(array($this, 'parse_callback'), $response);
  802. $parsed_data = new CFArray($parsed_data);
  803. // Clear the queue
  804. if ($clear_after_send)
  805. {
  806. $this->batch_object->queue = array();
  807. }
  808. return $parsed_data;
  809. }
  810. // Generate an identifier specific to this particular set of arguments.
  811. $cache_id = $this->key . '_' . get_class($this) . '_' . sha1(serialize($this->batch_object));
  812. // Instantiate the appropriate caching object.
  813. $this->cache_object = new $this->cache_class($cache_id, $this->cache_location, $this->cache_expires, $this->cache_compress);
  814. if ($this->delete_cache)
  815. {
  816. $this->use_cache_flow = false;
  817. $this->delete_cache = false;
  818. return $this->cache_object->delete();
  819. }
  820. // Invoke the cache callback function to determine whether to pull data from the cache or make a fresh request.
  821. $data_set = $this->cache_object->response_manager(array($this, 'cache_callback_batch'), array($this->batch_object));
  822. $parsed_data = array_map(array($this, 'parse_callback'), $data_set);
  823. $parsed_data = new CFArray($parsed_data);
  824. // Clear the queue
  825. if ($clear_after_send)
  826. {
  827. $this->batch_object->queue = array();
  828. }
  829. // End!
  830. return $parsed_data;
  831. }
  832. // Load the class
  833. $null = new CFBatchRequest();
  834. unset($null);
  835. throw new CFBatchRequest_Exception('You must use $object->batch()->send()');
  836. }
  837. /**
  838. * Parses a response body into a PHP object if appropriate.
  839. *
  840. * @param CFResponse|string $response (Required) The <CFResponse> object to parse, or an XML string that would otherwise be a response body.
  841. * @param string $content_type (Optional) The content-type to use when determining how to parse the content.
  842. * @return CFResponse|string A parsed <CFResponse> object, or parsed XML.
  843. */
  844. public function parse_callback($response, $headers = null)
  845. {
  846. // Shorten this so we have a (mostly) single code path
  847. if (isset($response->body))
  848. {
  849. if (is_string($response->body))
  850. {
  851. $body = $response->body;
  852. }
  853. else
  854. {
  855. return $response;
  856. }
  857. }
  858. elseif (is_string($response))
  859. {
  860. $body = $response;
  861. }
  862. else
  863. {
  864. return $response;
  865. }
  866. // Decompress gzipped content
  867. if (isset($headers['content-encoding']))
  868. {
  869. switch (strtolower(trim($headers['content-encoding'], "\x09\x0A\x0D\x20")))
  870. {
  871. case 'gzip':
  872. case 'x-gzip':
  873. if (strpos($headers['_info']['url'], 'monitoring.') !== false)
  874. {
  875. // CloudWatch incorrectly uses the deflate algorithm when they say gzip.
  876. if (($uncompressed = gzuncompress($body)) !== false)
  877. {
  878. $body = $uncompressed;
  879. }
  880. elseif (($uncompressed = gzinflate($body)) !== false)
  881. {
  882. $body = $uncompressed;
  883. }
  884. break;
  885. }
  886. else
  887. {
  888. // Everyone else uses gzip correctly.
  889. $decoder = new CFGzipDecode($body);
  890. if ($decoder->parse())
  891. {
  892. $body = $decoder->data;
  893. }
  894. break;
  895. }
  896. case 'deflate':
  897. if (strpos($headers['_info']['url'], 'monitoring.') !== false)
  898. {
  899. // CloudWatch incorrectly does nothing when they say deflate.
  900. continue;
  901. }
  902. else
  903. {
  904. // Everyone else uses deflate correctly.
  905. if (($uncompressed = gzuncompress($body)) !== false)
  906. {
  907. $body = $uncompressed;
  908. }
  909. elseif (($uncompressed = gzinflate($body)) !== false)
  910. {
  911. $body = $uncompressed;
  912. }
  913. }
  914. break;
  915. }
  916. }
  917. // Look for XML cues
  918. if (
  919. (isset($headers['content-type']) && ($headers['content-type'] === 'text/xml' || $headers['content-type'] === 'application/xml')) || // We know it's XML
  920. (!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
  921. )
  922. {
  923. // Strip the default XML namespace to simplify XPath expressions
  924. $body = str_replace("xmlns=", "ns=", $body);
  925. // Parse the XML body
  926. $body = new $this->parser_class($body);
  927. }
  928. // Look for JSON cues
  929. elseif (
  930. (isset($headers['content-type']) && ($headers['content-type'] === 'application/json') || $headers['content-type'] === 'application/x-amz-json-1.0') || // We know it's JSON
  931. (!isset($headers['content-type']) && $this->util->is_json($body)) // Sniff for JSON
  932. )
  933. {
  934. // Normalize JSON to a CFSimpleXML object
  935. $body = CFJSON::to_xml($body);
  936. }
  937. // Put the parsed data back where it goes
  938. if (isset($response->body))
  939. {
  940. $response->body = $body;
  941. }
  942. else
  943. {
  944. $response = $body;
  945. }
  946. return $response;
  947. }
  948. /*%******************************************************************************************%*/
  949. // CACHING LAYER
  950. /**
  951. * Specifies that the resulting <CFResponse> object should be cached according to the settings from
  952. * <set_cache_config()>.
  953. *
  954. * @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").
  955. * @param $this A reference to the current instance.
  956. * @return $this
  957. */
  958. public function cache($expires)
  959. {
  960. // Die if they haven't used set_cache_config().
  961. if (!$this->cache_class)
  962. {
  963. throw new CFRuntime_Exception('Must call set_cache_config() before using cache()');
  964. }
  965. if (is_string($expires))
  966. {
  967. $expires = strtotime($expires);
  968. $this->cache_expires = $expires - time();
  969. }
  970. elseif (is_int($expires))
  971. {
  972. $this->cache_expires = $expires;
  973. }
  974. $this->use_cache_flow = true;
  975. return $this;
  976. }
  977. /**
  978. * The callback function that is executed when the cache doesn't exist or has expired. The response of
  979. * this method is cached. Accepts identical parameters as the <authenticate()> method. Never call this
  980. * method directly -- it is used internally by the caching system.
  981. *
  982. * @param string $action (Required) Indicates the action to perform.
  983. * @param array $opt (Optional) An associative array of parameters for authenticating. See the individual methods for allowed keys.
  984. * @param string $domain (Optional) The URL of the queue to perform the action on.
  985. * @param integer $signature_version (Optional) The signature version to use. Defaults to 2.
  986. * @return CFResponse A parsed HTTP response.
  987. */
  988. public function cache_callback($action, $opt = null, $domain = null, $signature_version = 2)
  989. {
  990. // Disable the cache flow since it's already been handled.
  991. $this->use_cache_flow = false;
  992. // Make the request
  993. $response = $this->authenticate($action, $opt, $domain, $signature_version);
  994. // If this is an XML document, convert it back to a string.
  995. if (isset($response->body) && ($response->body instanceof SimpleXMLElement))
  996. {
  997. $response->body = $response->body->asXML();
  998. }
  999. return $response;
  1000. }
  1001. /**
  1002. * Used for caching the results of a batch request. Never call this method directly; it is used
  1003. * internally by the caching system.
  1004. *
  1005. * @param CFBatchRequest $batch (Required) The batch request object to send.
  1006. * @return CFResponse A parsed HTTP response.
  1007. */
  1008. public function cache_callback_batch(CFBatchRequest $batch)
  1009. {
  1010. return $batch->send();
  1011. }
  1012. /**
  1013. * Deletes a cached <CFResponse> object using the specified cache storage type.
  1014. *
  1015. * @return boolean A value of `true` if cached object exists and is successfully deleted, otherwise `false`.
  1016. */
  1017. public function delete_cache()
  1018. {
  1019. $this->use_cache_flow = true;
  1020. $this->delete_cache = true;
  1021. return $this;
  1022. }
  1023. }
  1024. /**
  1025. * Contains the functionality for auto-loading service classes.
  1026. */
  1027. class CFLoader
  1028. {
  1029. /*%******************************************************************************************%*/
  1030. // AUTO-LOADER
  1031. /**
  1032. * Automatically load classes that aren't included.
  1033. *
  1034. * @param string $class (Required) The classname to load.
  1035. * @return void
  1036. */
  1037. public static function autoloader($class)
  1038. {
  1039. $path = dirname(__FILE__) . DIRECTORY_SEPARATOR;
  1040. // Amazon SDK classes
  1041. if (strstr($class, 'Amazon'))
  1042. {
  1043. require_once $path . 'services' . DIRECTORY_SEPARATOR . str_ireplace('Amazon', '', strtolower($class)) . '.class.php';
  1044. }
  1045. // Utility classes
  1046. elseif (strstr($class, 'CF'))
  1047. {
  1048. require_once $path . 'utilities' . DIRECTORY_SEPARATOR . str_ireplace('CF', '', strtolower($class)) . '.class.php';
  1049. }
  1050. // Load CacheCore
  1051. elseif (strstr($class, 'Cache'))
  1052. {
  1053. require_once $path . 'lib' . DIRECTORY_SEPARATOR . 'cachecore' . DIRECTORY_SEPARATOR . strtolower($class) . '.class.php';
  1054. }
  1055. // Load RequestCore
  1056. elseif (strstr($class, 'RequestCore') || strstr($class, 'ResponseCore'))
  1057. {
  1058. require_once $path . 'lib' . DIRECTORY_SEPARATOR . 'requestcore' . DIRECTORY_SEPARATOR . 'requestcore.class.php';
  1059. }
  1060. // Load Authentication Signers
  1061. elseif (strstr($class, 'Auth'))
  1062. {
  1063. require_once $path . 'authentication' . DIRECTORY_SEPARATOR . str_replace('auth', 'signature_', strtolower($class)) . '.class.php';
  1064. }
  1065. // Load Signer interface
  1066. elseif ($class === 'Signer')
  1067. {
  1068. if (!interface_exists('Signable', false))
  1069. {
  1070. require_once $path . 'authentication' . DIRECTORY_SEPARATOR . 'signable.interface.php';
  1071. }
  1072. require_once $path . 'authentication' . DIRECTORY_SEPARATOR . 'signer.abstract.php';
  1073. }
  1074. // Load Symfony YAML classes
  1075. elseif (strstr($class, 'sfYaml'))
  1076. {
  1077. require_once $path . 'lib' . DIRECTORY_SEPARATOR . 'yaml' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'sfYaml.php';
  1078. }
  1079. return true;
  1080. }
  1081. }
  1082. // Register the autoloader.
  1083. spl_autoload_register(array('CFLoader', 'autoloader'));
  1084. /*%******************************************************************************************%*/
  1085. // CONFIGURATION
  1086. // Look for include file in the same directory (e.g. `./config.inc.php`).
  1087. if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc.php'))
  1088. {
  1089. include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc.php';
  1090. }
  1091. // Fallback to `~/.aws/sdk/config.inc.php`
  1092. else
  1093. {
  1094. if (!isset($_ENV['HOME']) && isset($_SERVER['HOME']))
  1095. {
  1096. $_ENV['HOME'] = $_SERVER['HOME'];
  1097. }
  1098. elseif (!isset($_ENV['HOME']) && !isset($_SERVER['HOME']))
  1099. {
  1100. $_ENV['HOME'] = `cd ~ && pwd`;
  1101. if (!$_ENV['HOME'])
  1102. {
  1103. switch (strtolower(PHP_OS))
  1104. {
  1105. case 'darwin':
  1106. $_ENV['HOME'] = '/Users/' . get_current_user();
  1107. break;
  1108. case 'windows':
  1109. case 'winnt':
  1110. case 'win32':
  1111. $_ENV['HOME'] = 'c:\Documents and Settings' . DIRECTORY_SEPARATOR . get_current_user();
  1112. break;
  1113. default:
  1114. $_ENV['HOME'] = '/home/' . get_current_user();
  1115. break;
  1116. }
  1117. }
  1118. }
  1119. if (getenv('HOME') && file_exists(getenv('HOME') . DIRECTORY_SEPARATOR . '.aws' . DIRECTORY_SEPARATOR . 'sdk' . DIRECTORY_SEPARATOR . 'config.inc.php'))
  1120. {
  1121. include_once getenv('HOME') . DIRECTORY_SEPARATOR . '.aws' . DIRECTORY_SEPARATOR . 'sdk' . DIRECTORY_SEPARATOR . 'config.inc.php';
  1122. }
  1123. }