コード例 #1
0
 public function get_service($opts, $useservercerts = false, $disablesslverify = null)
 {
     $user = $opts['user'];
     $apikey = $opts['apikey'];
     $authurl = $opts['authurl'];
     $region = !empty($opts['region']) ? $opts['region'] : null;
     require_once UPDRAFTPLUS_DIR . '/vendor/autoload.php';
     global $updraftplus;
     # The new authentication APIs don't match the values we were storing before
     $new_authurl = 'https://lon.auth.api.rackspacecloud.com' == $authurl || 'uk' == $authurl ? Rackspace::UK_IDENTITY_ENDPOINT : Rackspace::US_IDENTITY_ENDPOINT;
     if (null === $disablesslverify) {
         $disablesslverify = UpdraftPlus_Options::get_updraft_option('updraft_ssl_disableverify');
     }
     if (empty($user) || empty($apikey)) {
         throw new Exception(__('Authorisation failed (check your credentials)', 'updraftplus'));
     }
     $updraftplus->log("Cloud Files authentication URL: " . $new_authurl);
     $client = new Rackspace($new_authurl, array('username' => $user, 'apiKey' => $apikey));
     $this->client = $client;
     if ($disablesslverify) {
         $client->setSslVerification(false);
     } else {
         if ($useservercerts) {
             $client->setConfig(array($client::SSL_CERT_AUTHORITY, 'system'));
         } else {
             $client->setSslVerification(UPDRAFTPLUS_DIR . '/includes/cacert.pem', true, 2);
         }
     }
     return $client->objectStoreService('cloudFiles', $region);
 }