コード例 #1
0
ファイル: s3.php プロジェクト: jeanpage/ca_learn
 function getS3($key, $secret, $useservercerts, $disableverify, $nossl)
 {
     global $updraftplus;
     if (!class_exists('UpdraftPlus_S3')) {
         require_once UPDRAFTPLUS_DIR . '/includes/S3.php';
     }
     if (!class_exists('WP_HTTP_Proxy')) {
         require_once ABSPATH . 'wp-includes/class-http.php';
     }
     $proxy = new WP_HTTP_Proxy();
     $s3 = new UpdraftPlus_S3($key, $secret);
     if ($proxy->is_enabled()) {
         # WP_HTTP_Proxy returns empty strings where we want nulls
         $user = $proxy->username();
         if (empty($user)) {
             $user = null;
             $pass = null;
         } else {
             $pass = $proxy->password();
             if (empty($pass)) {
                 $pass = null;
             }
         }
         $port = (int) $proxy->port();
         if (empty($port)) {
             $port = 8080;
         }
         $s3->setProxy($proxy->host(), $user, $pass, CURLPROXY_HTTP, $port);
     }
     if (!$nossl) {
         $curl_version = function_exists('curl_version') ? curl_version() : array('features' => null);
         $curl_ssl_supported = $curl_version['features'] & CURL_VERSION_SSL;
         if ($curl_ssl_supported) {
             $s3->useSSL = true;
             if ($disableverify) {
                 $s3->useSSLValidation = false;
                 $updraftplus->log("S3: Disabling verification of SSL certificates");
             }
             if ($useservercerts) {
                 $updraftplus->log("S3: Using the server's SSL certificates");
             } else {
                 $s3->SSLCACert = UPDRAFTPLUS_DIR . '/includes/cacert.pem';
             }
         } else {
             $updraftplus->log("S3: Curl/SSL is not available. Communications will not be encrypted.");
         }
     } else {
         $s3->useSSL = false;
         $updraftplus->log("SSL was disabled via the user's preference. Communications will not be encrypted.");
     }
     return $s3;
 }
コード例 #2
0
ファイル: s3.php プロジェクト: lorier/thedailydrawing
 protected function getS3($key, $secret, $useservercerts, $disableverify, $nossl)
 {
     if (!empty($this->s3_object) && !is_wp_error($this->s3_object)) {
         return $this->s3_object;
     }
     if ('' == $key || '' == $secret) {
         return new WP_Error('no_settings', __('No settings were found', 'updraftplus'));
     }
     global $updraftplus;
     if (!class_exists('UpdraftPlus_S3')) {
         require_once UPDRAFTPLUS_DIR . '/includes/S3.php';
     }
     if (!class_exists('WP_HTTP_Proxy')) {
         require_once ABSPATH . WPINC . '/class-http.php';
     }
     $proxy = new WP_HTTP_Proxy();
     $s3 = new UpdraftPlus_S3($key, $secret);
     if ($proxy->is_enabled()) {
         # WP_HTTP_Proxy returns empty strings where we want nulls
         $user = $proxy->username();
         if (empty($user)) {
             $user = null;
             $pass = null;
         } else {
             $pass = $proxy->password();
             if (empty($pass)) {
                 $pass = null;
             }
         }
         $port = (int) $proxy->port();
         if (empty($port)) {
             $port = 8080;
         }
         $s3->setProxy($proxy->host(), $user, $pass, CURLPROXY_HTTP, $port);
     }
     if (!$nossl) {
         $curl_version = function_exists('curl_version') ? curl_version() : array('features' => null);
         $curl_ssl_supported = $curl_version['features'] & CURL_VERSION_SSL;
         if ($curl_ssl_supported) {
             if ($disableverify) {
                 $s3->setSSL(true, false);
                 $updraftplus->log("S3: Disabling verification of SSL certificates");
             } else {
                 $s3->setSSL(true, true);
             }
             if ($useservercerts) {
                 $updraftplus->log("S3: Using the server's SSL certificates");
             } else {
                 $s3->setSSLAuth(null, null, UPDRAFTPLUS_DIR . '/includes/cacert.pem');
             }
         } else {
             $s3->setSSL(false, false);
             $updraftplus->log("S3: Curl/SSL is not available. Communications will not be encrypted.");
         }
     } else {
         $s3->setSSL(false, false);
         $updraftplus->log("SSL was disabled via the user's preference. Communications will not be encrypted.");
     }
     $this->s3_object = $s3;
     return $this->s3_object;
 }