Changeset 492045
- Timestamp:
- 01/19/2012 12:04:55 PM (14 years ago)
- File:
-
- 1 edited
-
amazon-s3-uploads/trunk/asssu.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
amazon-s3-uploads/trunk/asssu.php
r491999 r492045 55 55 $this->bucket_subdir = get_option('asssu_bucket_subdir'); 56 56 $this->use_ssl = (bool) get_option('asssu_use_ssl', 0); 57 $this->endpoint = get_option('asssu_endpoint'); 57 58 58 59 $this->cronScheduleTime = get_option('asssu_cron_interval', 300); … … 96 97 require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'asssu-options.php'; 97 98 } 99 100 function sss_adapter() { 101 if (isset($this->adapter)) 102 return $this->adapter; 103 104 require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'tpyo-amazon-s3-php-class'.DIRECTORY_SEPARATOR.'S3.php'; 105 $adapter = new S3($this->access_key, $this->secret_key, $this->use_ssl, $this->endpoint); 106 $this->adapter = $adapter; 107 return $adapter; 108 } 98 109 99 110 function check_sss($access_key, $secret_key, $use_ssl, $bucket_name) { 100 111 require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'tpyo-amazon-s3-php-class'.DIRECTORY_SEPARATOR.'S3.php'; 101 112 $adapter = new S3($access_key, $secret_key, $use_ssl); 102 $buckets = S3::listBuckets(); 103 if (is_array($buckets) && in_array($bucket_name, $buckets)) 113 $buckets = @$adapter->listBuckets(); 114 if (is_array($buckets) && in_array($bucket_name, $buckets)) { 115 $bucket_location = $adapter->getBucketLocation($bucket_name); 116 if ($bucket_location === 'EU') 117 $endpoint = 's3-eu-west-1.amazonaws.com'; 118 else if ($bucket_location === 'NC') 119 $endpoint = 's3-us-west-1.amazonaws.com'; 120 else if ($bucket_location === 'US') 121 $endpoint = 's3.amazonaws.com'; 122 else if ($bucket_location === 'SI') 123 $endpoint = 's3-ap-southeast-1.amazonaws.com'; 124 else if ($bucket_location === 'TO') 125 $endpoint = 's3-ap-northeast-1.amazonaws.com'; 126 else 127 return false; 128 if ($this->endpoint !== $endpoint) { 129 $this->endpoint = $endpoint; 130 update_option('asssu_endpoint', $this->endpoint); 131 } 104 132 return true; 133 } 105 134 return false; 106 135 } 107 136 108 137 function check_htaccess() { 109 require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'tpyo-amazon-s3-php-class'.DIRECTORY_SEPARATOR.'S3.php';110 $bucket_name = get_option('asssu_bucket_name');111 $location = S3::getBucketLocation($bucket_name);112 113 138 $amazon_path = 'http://'.$this->bucket_name.'.s3.amazonaws.com/'; 114 if ($location === 'EU') 115 $amazon_path_ssl = 'https://'.$this->bucket_name.'.s3.amazonaws.com/'; 116 else 117 $amazon_path_ssl = 'https://s3.amazonaws.com/'.$this->bucket_name.'/'; 139 $amazon_path_ssl = 'https://'.$this->endpoint.'/'.$this->bucket_name.'/'; 118 140 if (!empty($this->bucket_subdir)) { 119 141 $amazon_path .= $this->bucket_subdir.'/'; … … 179 201 $this->find_contents($this->upload_basedir); 180 202 181 require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'s3-php5-curl'.DIRECTORY_SEPARATOR.'S3.php'; 182 183 $adapter = new S3($this->access_key, $this->secret_key, $this->use_ssl); 203 $adapter = $this->sss_adapter(); 184 204 $buckets = @$adapter->listBuckets(); 185 205 if (is_array($buckets) && in_array($this->bucket_name, $buckets)) { … … 193 213 if (!empty($this->bucket_subdir)) 194 214 $amazon_path = $this->bucket_subdir.'/'.$amazon_path; 195 $info = $adapter->getObjectInfo($this->bucket_name, $amazon_path, true);215 $info = @$adapter->getObjectInfo($this->bucket_name, $amazon_path, true); 196 216 if (!empty($info)) { 197 217 if ($info['size'] !== filesize($local_path)) {
Note: See TracChangeset
for help on using the changeset viewer.