|
11 | 11 |
|
12 | 12 | class Client implements ClientInterface, ReportingClientInterface, MerchantOnboardingClientInterface |
13 | 13 | { |
14 | | - const SDK_VERSION = '2.6.4'; |
| 14 | + const SDK_VERSION = '2.6.5'; |
15 | 15 | const SDK_LANGUAGE = 'PHP'; |
16 | 16 | const HASH_ALGORITHM = 'sha256'; |
17 | 17 | const API_VERSION = 'v2'; |
@@ -322,7 +322,34 @@ protected function constructUserAgentHeader() |
322 | 322 | { |
323 | 323 | return 'amazon-pay-api-sdk-php/' . self::SDK_VERSION . ' (' |
324 | 324 | . 'PHP/' . phpversion() . '; ' |
325 | | - . php_uname('s') . '/' . php_uname('m') . '/' . php_uname('r') . ')'; |
| 325 | + . self::getPhpUname('s') . '/' . self::getPhpUname('m') . '/' . self::getPhpUname('r') . ')'; |
| 326 | + } |
| 327 | + |
| 328 | + /** |
| 329 | + * Retrieves system information using the php_uname function if it's enabled |
| 330 | + * |
| 331 | + * @param mode - A mode specifying the information to retrieve (e.g., 's' for the System name) |
| 332 | + * @return string - System information or '(disabled)' if php_uname is disabled |
| 333 | + */ |
| 334 | + public function getPhpUname($mode) { |
| 335 | + $uname_disabled = self::_isDisabled(ini_get('disable_functions'), 'php_uname'); |
| 336 | + return $uname_disabled ? '(disabled)' : php_uname($mode); |
| 337 | + } |
| 338 | + |
| 339 | + /** |
| 340 | + * Checks if a given function is disabled based on a comma-seperated string of disabled functions. |
| 341 | + * |
| 342 | + * @param string $disableFunctionsOutput - String value of the 'disable_function' setting, as output by ini_get('disable_functions') |
| 343 | + * @param string $functionName - Name of the function we are interesting in seeing whether or not it is disabled |
| 344 | + * |
| 345 | + * @return bool - True if the function is disabled, false otherwise |
| 346 | + */ |
| 347 | + private static function _isDisabled($disableFunctionsOutput, $functionName) { |
| 348 | + $disabledFunctions = explode(',', $disableFunctionsOutput); |
| 349 | + if(in_array($functionName, $disabledFunctions)) { |
| 350 | + return true; |
| 351 | + } |
| 352 | + return false; |
326 | 353 | } |
327 | 354 |
|
328 | 355 | public function getPostSignedHeaders($http_request_method, $request_uri, $request_parameters, $request_payload, $other_presigned_headers = null) |
|
0 commit comments