From 9e55d2c428843c9726046a2a52839afb2fd261e2 Mon Sep 17 00:00:00 2001 From: jaswsinc Date: Thu, 8 Jan 2015 02:53:50 -0900 Subject: [PATCH] Refactor `amazon_s34_sign()`. See: websharks/s2member#440 --- s2member/includes/classes/files-in.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/s2member/includes/classes/files-in.inc.php b/s2member/includes/classes/files-in.inc.php index 729cc57c..fc3f22e4 100644 --- a/s2member/includes/classes/files-in.inc.php +++ b/s2member/includes/classes/files-in.inc.php @@ -665,7 +665,11 @@ public static function amazon_s3_sign($string = '') */ public static function amazon_s34_sign($string = '') { - $s3c['secret_key'] = $GLOBALS['WS_PLUGIN__']['s2member']['o']['amazon_s3_files_secret_key']; + $s3c = array(); // Initialize config. keys. + foreach($GLOBALS['WS_PLUGIN__']['s2member']['o'] as $option => $option_value) + if(preg_match('/^amazon_s3_files_/', $option) && ($option = preg_replace('/^amazon_s3_files_/', '', $option))) + $s3c[$option] = $option_value; + $s3_date_key = c_ws_plugin__s2member_utils_strings::hmac_sha256_sign(date('Ymd'), 'AWS4'.$s3c['secret_key']); $s3_date_region_key = c_ws_plugin__s2member_utils_strings::hmac_sha256_sign($s3c['bucket_region'], $s3_date_key); $s3_date_region_service_key = c_ws_plugin__s2member_utils_strings::hmac_sha256_sign('s3', $s3_date_region_key);