当前位置: 首页>>代码示例>>PHP>>正文


PHP CF_Authentication::ssl_use_cabundle方法代码示例

本文整理汇总了PHP中CF_Authentication::ssl_use_cabundle方法的典型用法代码示例。如果您正苦于以下问题:PHP CF_Authentication::ssl_use_cabundle方法的具体用法?PHP CF_Authentication::ssl_use_cabundle怎么用?PHP CF_Authentication::ssl_use_cabundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CF_Authentication的用法示例。


在下文中一共展示了CF_Authentication::ssl_use_cabundle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: switch

 /**
  * Init connection object
  *
  * @param string $error
  * @return boolean
  */
 function _init(&$error)
 {
     if (empty($this->_config['user'])) {
         $error = 'Empty username.';
         return false;
     }
     if (empty($this->_config['key'])) {
         $error = 'Empty API key.';
         return false;
     }
     if (empty($this->_config['location'])) {
         $error = 'Empty API key.';
         return false;
     }
     switch ($this->_config['location']) {
         default:
         case 'us':
             $host = US_AUTHURL;
             break;
         case 'uk':
             $host = UK_AUTHURL;
             break;
     }
     try {
         $this->_auth = new CF_Authentication($this->_config['user'], $this->_config['key'], null, $host);
         $this->_auth->ssl_use_cabundle();
         $this->_auth->authenticate();
         $this->_connection = new CF_Connection($this->_auth);
         $this->_connection->ssl_use_cabundle();
     } catch (Exception $exception) {
         $error = $exception->getMessage();
         return false;
     }
     return true;
 }
开发者ID:easinewe,项目名称:Avec2016,代码行数:41,代码来源:Rscf.php

示例2: auth

 /**
  * Creates a singleton connection handle
  *
  * @return CF_Connection
  */
 private function auth()
 {
     if (is_null($this->conn)) {
         $username = Mage::getStoreConfig('imagecdn/rackspace/username');
         $api_key = Mage::getStoreConfig('imagecdn/rackspace/api_key');
         $auth = new CF_Authentication($username, $api_key);
         $auth->ssl_use_cabundle();
         $auth->authenticate();
         if ($auth->authenticated()) {
             $this->conn = new CF_Connection($auth);
             $this->conn->ssl_use_cabundle();
             return $this->conn;
         } else {
             return false;
         }
     } else {
         return $this->conn;
     }
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:24,代码来源:Rackspace.php

示例3: connect

 /**
  * Connect to the CloudFiles Service
  * @return boolean success
  * @throws CloudFilesException
  * @throws AuthenticationException
  * @throws InvalidResponseException
  */
 protected static function connect()
 {
     if ($server = self::$server_to_auth_map[self::getConfig('server')]) {
         self::$Authentication = new CF_Authentication(self::getConfig('username'), self::getConfig('api_key'), null, $server);
         self::$Authentication->ssl_use_cabundle();
         self::$Authentication->authenticate();
         $hostname = gethostname();
         // Check to see if this is a rackspace node
         if (stripos($hostname, 'rackspace') === FALSE) {
             $serviceNet = FALSE;
         } else {
             $serviceNet = TRUE;
         }
         self::$Connection = new CF_Connection(self::$Authentication, $serviceNet);
     }
     $retval = !!self::$Connection;
     if (!$retval) {
         self::error("Unable to connect to rackspace, check your settings.");
     }
     return $retval;
 }
开发者ID:rnavarro,项目名称:CakePHP-CloudFiles-Plugin,代码行数:28,代码来源:CloudFiles.php

示例4: catch

         die;
     } catch (Exception $e) {
         die($e->getMessage());
     }
     break;
 case 'downloadrsc':
     //Download RSC Backup
     check_admin_referer('download-backup');
     if (!class_exists('CF_Authentication')) {
         require_once realpath(plugin_dir_path(__FILE__) . '/../libs/rackspace/cloudfiles.php');
     }
     $jobs = get_option('backwpup_jobs');
     $jobid = $_GET['jobid'];
     try {
         $auth = new CF_Authentication($jobs[$jobid]['rscUsername'], $jobs[$jobid]['rscAPIKey']);
         $auth->ssl_use_cabundle();
         if ($auth->authenticate()) {
             $conn = new CF_Connection($auth);
             $conn->ssl_use_cabundle();
             $backwpupcontainer = $conn->get_container($jobs[$jobid]['rscContainer']);
             $backupfile = $backwpupcontainer->get_object($_GET['file']);
             header("Pragma: public");
             header("Expires: 0");
             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
             header("Content-Type: " . $backupfile->content_type);
             header("Content-Type: application/force-download");
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Disposition: attachment; filename=" . basename($_GET['file']) . ";");
             header("Content-Transfer-Encoding: binary");
             header("Content-Length: " . $backupfile->content_length);
开发者ID:hscale,项目名称:webento,代码行数:31,代码来源:header_backwpupbackups.php

示例5: backwpup_get_backup_files


//.........这里部分代码省略.........
        if (!class_exists('Microsoft_WindowsAzure_Storage_Blob')) {
            require_once dirname(__FILE__) . '/../libs/Microsoft/WindowsAzure/Storage/Blob.php';
        }
        if (class_exists('Microsoft_WindowsAzure_Storage_Blob')) {
            try {
                $storageClient = new Microsoft_WindowsAzure_Storage_Blob($jobvalue['msazureHost'], $jobvalue['msazureAccName'], $jobvalue['msazureKey']);
                $blobs = $storageClient->listBlobs($jobvalue['msazureContainer'], $jobvalue['msazuredir']);
                if (is_array($blobs)) {
                    foreach ($blobs as $blob) {
                        $files[$filecounter]['JOBID'] = $jobid;
                        $files[$filecounter]['DEST'] = $dest;
                        $files[$filecounter]['folder'] = "https://" . $jobvalue['msazureAccName'] . '.' . $jobvalue['msazureHost'] . "/" . $jobvalue['msazureContainer'] . "/" . dirname($blob->Name) . "/";
                        $files[$filecounter]['file'] = $blob->Name;
                        $files[$filecounter]['filename'] = basename($blob->Name);
                        $files[$filecounter]['downloadurl'] = backwpup_admin_url('admin.php') . '?page=backwpupbackups&action=downloadmsazure&file=' . $blob->Name . '&jobid=' . $jobid;
                        $files[$filecounter]['filesize'] = $blob->size;
                        $files[$filecounter]['time'] = strtotime($blob->lastmodified);
                        $filecounter++;
                    }
                }
            } catch (Exception $e) {
                $backwpup_message .= 'MSAZURE: ' . $e->getMessage() . '<br />';
            }
        }
    }
    //Get files/filinfo from RSC
    if ($dest == 'RSC' and !empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
        if (!class_exists('CF_Authentication')) {
            require_once dirname(__FILE__) . '/../libs/rackspace/cloudfiles.php';
        }
        if (class_exists('CF_Authentication')) {
            try {
                $auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
                $auth->ssl_use_cabundle();
                if ($auth->authenticate()) {
                    $conn = new CF_Connection($auth);
                    $conn->ssl_use_cabundle();
                    $backwpupcontainer = $conn->get_container($jobvalue['rscContainer']);
                    $contents = $backwpupcontainer->get_objects(0, NULL, NULL, $jobvalue['rscdir']);
                    foreach ($contents as $object) {
                        $files[$filecounter]['JOBID'] = $jobid;
                        $files[$filecounter]['DEST'] = $dest;
                        $files[$filecounter]['folder'] = "RSC://" . $jobvalue['rscContainer'] . "/" . dirname($object->name) . "/";
                        $files[$filecounter]['file'] = $object->name;
                        $files[$filecounter]['filename'] = basename($object->name);
                        $files[$filecounter]['downloadurl'] = backwpup_admin_url('admin.php') . '?page=backwpupbackups&action=downloadrsc&file=' . $object->name . '&jobid=' . $jobid;
                        $files[$filecounter]['filesize'] = $object->content_length;
                        $files[$filecounter]['time'] = strtotime($object->last_modified);
                        $filecounter++;
                    }
                }
            } catch (Exception $e) {
                $backwpup_message .= 'RSC: ' . $e->getMessage() . '<br />';
            }
        }
    }
    //Get files/filinfo from FTP
    if ($dest == 'FTP' and !empty($jobvalue['ftphost']) and function_exists('ftp_connect') and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass'])) {
        if (function_exists('ftp_ssl_connect') and $jobvalue['ftpssl']) {
            //make SSL FTP connection
            $ftp_conn_id = ftp_ssl_connect($jobvalue['ftphost'], $jobvalue['ftphostport'], 10);
        } elseif (!$jobvalue['ftpssl']) {
            //make normal FTP conection if SSL not work
            $ftp_conn_id = ftp_connect($jobvalue['ftphost'], $jobvalue['ftphostport'], 10);
        }
        $loginok = false;
开发者ID:hscale,项目名称:webento,代码行数:67,代码来源:func_backwpupbackups.php

示例6: transer_dir


//.........这里部分代码省略.........
         // Instantiate the AmazonS3 class
         $S3 = new AmazonS3(array('key' => trim($_POST['s3']['key']), 'secret' => trim($_POST['s3']['secret_key'])));
         $S3->ssl_verification = FALSE;
         // Init Configs
         $temp = $this->EE->config->item('ci_s3_storage');
         $s3_storage = constant('AmazonS3::' . $temp[$_POST['s3']['storage']]);
         $temp = $this->EE->config->item('ci_s3_acl');
         $s3_acl = constant('AmazonS3::' . $temp[$_POST['s3']['acl']]);
         $s3_directory = trim($_POST['s3']['directory']);
         $s3_bucket = $_POST['s3']['bucket'];
         $s3_subdir = '';
         if ($s3_directory) {
             $s3_subdir = $s3_directory . '/';
         }
         $s3_headers = $this->EE->config->item('ci_s3_headers');
         // Test it
         $resp = $S3->get_bucket_headers($s3_bucket);
         if (!$resp->isOK()) {
             if (isset($resp->body->Message)) {
                 exit('ERROR_S3: ' . $resp->body->Message);
             } else {
                 exit('ERROR_S3: Bucket error');
             }
         }
     } else {
         // Include the SDK
         if (class_exists('CF_Authentication') == FALSE) {
             require_once PATH_THIRD . 'channel_images/locations/cloudfiles/sdk/cloudfiles.php';
         }
         // Which Region?
         if ($_POST['cloudfiles']['region'] == 'uk') {
             $_POST['cloudfiles']['region'] = constant('UK_AUTHURL');
         } else {
             $_POST['cloudfiles']['region'] = constant('US_AUTHURL');
         }
         // Instantiate the Cloudfiles class
         $CF_AUTH = new CF_Authentication($_POST['cloudfiles']['username'], $_POST['cloudfiles']['api'], NULL, $_POST['cloudfiles']['region']);
         try {
             $CF_AUTH->ssl_use_cabundle();
             $CF_AUTH->authenticate();
         } catch (AuthenticationException $e) {
             exit('ERROR_CLOUDFILES:' . $e->getMessage());
         }
         $CF_CONN = new CF_Connection($CF_AUTH);
         $CF_CONN->ssl_use_cabundle();
         $CF_CONT = $CF_CONN->get_container($_POST['cloudfiles']['container']);
     }
     // -----------------------------------------
     // Loop over all dirs
     // -----------------------------------------
     $files = scandir($temp_dir);
     foreach ($files as $file) {
         $full_path = $temp_dir . $file;
         if (is_file($full_path) == false) {
             continue;
         }
         $extension = substr(strrchr($file, '.'), 1);
         // Mime type
         if ($extension == 'jpg') {
             $filemime = 'image/jpeg';
         } elseif ($extension == 'jpeg') {
             $filemime = 'image/jpeg';
         } elseif ($extension == 'png') {
             $filemime = 'image/png';
         } elseif ($extension == 'gif') {
             $filemime = 'image/gif';
         } else {
             continue;
         }
         if (isset($S3) == true) {
             $upload_arr = array();
             $upload_arr['fileUpload'] = $full_path;
             $upload_arr['contentType'] = $filemime;
             $upload_arr['acl'] = $s3_acl;
             $upload_arr['storage'] = $s3_storage;
             $upload_arr['headers'] = array();
             if ($s3_headers != FALSE && is_array($s3_headers) === TRUE) {
                 $upload_arr['headers'] = $s3_headers;
             }
             $response = $S3->create_object($s3_bucket, $s3_subdir . $entry_id . '/' . $file, $upload_arr);
             // Success?
             if (!$response->isOK()) {
                 exit((string) $response->body->Message);
             }
         } else {
             $OBJECT = $CF_CONT->create_object($entry_id . '/' . $file);
             $OBJECT->content_type = $filemime;
             try {
                 $OBJECT->load_from_filename($full_path);
             } catch (Exception $e) {
                 exit($e->getMessage());
             }
         }
         //@unlink($temp_dir.$file);
     }
     @delete_files($temp_dir, true);
     @rmdir($temp_dir);
     $o = array('success' => 'yes');
     exit($this->EE->image_helper->generate_json($o));
 }
开发者ID:ayuinc,项目名称:laboratoria-v2,代码行数:101,代码来源:ajax.channel_images.php

示例7: dest_rsc

function dest_rsc()
{
    global $WORKING, $STATIC;
    trigger_error($WORKING['DEST_RSC']['STEP_TRY'] . '. ' . __('Try to sending backup file to Rackspace Cloud...', 'backwpup'), E_USER_NOTICE);
    $WORKING['STEPTODO'] = 2 + filesize($STATIC['JOB']['backupdir'] . $STATIC['backupfile']);
    $WORKING['STEPDONE'] = 0;
    require_once dirname(__FILE__) . '/../libs/rackspace/cloudfiles.php';
    $auth = new CF_Authentication($STATIC['JOB']['rscUsername'], $STATIC['JOB']['rscAPIKey']);
    $auth->ssl_use_cabundle();
    try {
        if ($auth->authenticate()) {
            trigger_error(__('Connected to Rackspase ...', 'backwpup'), E_USER_NOTICE);
        }
        $conn = new CF_Connection($auth);
        $conn->ssl_use_cabundle();
        $is_container = false;
        $containers = $conn->get_containers();
        foreach ($containers as $container) {
            if ($container->name == $STATIC['JOB']['rscContainer']) {
                $is_container = true;
            }
        }
        if (!$is_container) {
            $public_container = $conn->create_container($STATIC['JOB']['rscContainer']);
            $public_container->make_private();
            if (empty($public_container)) {
                $is_container = false;
            }
        }
    } catch (Exception $e) {
        trigger_error(__('Rackspase Cloud API:', 'backwpup') . ' ' . $e->getMessage(), E_USER_ERROR);
        return;
    }
    if (!$is_container) {
        trigger_error(__('Rackspase Cloud Container not exists:', 'backwpup') . ' ' . $STATIC['JOB']['rscContainer'], E_USER_ERROR);
        return;
    }
    try {
        //Transfer Backup to Rackspace Cloud
        $backwpupcontainer = $conn->get_container($STATIC['JOB']['rscContainer']);
        //if (!empty($STATIC['JOB']['rscdir'])) //make the foldder
        //	$backwpupcontainer->create_paths($STATIC['JOB']['rscdir']);
        $backwpupbackup = $backwpupcontainer->create_object($STATIC['JOB']['rscdir'] . $STATIC['backupfile']);
        //set content Type
        if ($STATIC['JOB']['fileformart'] == '.zip') {
            $backwpupbackup->content_type = 'application/zip';
        }
        if ($STATIC['JOB']['fileformart'] == '.tar') {
            $backwpupbackup->content_type = 'application/x-ustar';
        }
        if ($STATIC['JOB']['fileformart'] == '.tar.gz') {
            $backwpupbackup->content_type = 'application/x-compressed';
        }
        if ($STATIC['JOB']['fileformart'] == '.tar.bz2') {
            $backwpupbackup->content_type = 'application/x-compressed';
        }
        trigger_error(__('Upload to RSC now started ... ', 'backwpup'), E_USER_NOTICE);
        if ($backwpupbackup->load_from_filename($STATIC['JOB']['backupdir'] . $STATIC['backupfile'])) {
            $WORKING['STEPTODO'] = 1 + filesize($STATIC['JOB']['backupdir'] . $STATIC['backupfile']);
            trigger_error(__('Backup File transferred to RSC://', 'backwpup') . $STATIC['JOB']['rscContainer'] . '/' . $STATIC['JOB']['rscdir'] . $STATIC['backupfile'], E_USER_NOTICE);
            $STATIC['JOB']['lastbackupdownloadurl'] = $STATIC['WP']['ADMINURL'] . '?page=backwpupbackups&action=downloadrsc&file=' . $STATIC['JOB']['rscdir'] . $STATIC['backupfile'] . '&jobid=' . $STATIC['JOB']['jobid'];
            $WORKING['STEPSDONE'][] = 'DEST_RSC';
            //set done
        } else {
            trigger_error(__('Can not transfer backup to RSC.', 'backwpup'), E_USER_ERROR);
        }
    } catch (Exception $e) {
        trigger_error(__('Rackspase Cloud API:', 'backwpup') . ' ' . $e->getMessage(), E_USER_ERROR);
    }
    try {
        if ($STATIC['JOB']['rscmaxbackups'] > 0) {
            //Delete old backups
            $backupfilelist = array();
            $contents = $backwpupcontainer->list_objects(0, NULL, NULL, $STATIC['JOB']['rscdir']);
            if (is_array($contents)) {
                foreach ($contents as $object) {
                    $file = basename($object);
                    if ($STATIC['JOB']['rscdir'] . $file == $object) {
                        //only in the folder and not in complete bucket
                        if ($STATIC['JOB']['fileprefix'] == substr($file, 0, strlen($STATIC['JOB']['fileprefix'])) and $STATIC['JOB']['fileformart'] == substr($file, -strlen($STATIC['JOB']['fileformart']))) {
                            $backupfilelist[] = $file;
                        }
                    }
                }
            }
            if (sizeof($backupfilelist) > 0) {
                rsort($backupfilelist);
                $numdeltefiles = 0;
                for ($i = $STATIC['JOB']['rscmaxbackups']; $i < sizeof($backupfilelist); $i++) {
                    if ($backwpupcontainer->delete_object($STATIC['JOB']['rscdir'] . $backupfilelist[$i])) {
                        //delte files on Cloud
                        $numdeltefiles++;
                    } else {
                        trigger_error(__('Can not delete file on RSC://', 'backwpup') . $STATIC['JOB']['rscContainer'] . $STATIC['JOB']['rscdir'] . $backupfilelist[$i], E_USER_ERROR);
                    }
                }
                if ($numdeltefiles > 0) {
                    trigger_error(sprintf(_n('One file deleted on RSC container', '%d files deleted on RSC container', $numdeltefiles, 'backwpup'), $numdeltefiles), E_USER_NOTICE);
                }
            }
//.........这里部分代码省略.........
开发者ID:rubyerme,项目名称:rubyerme.github.com,代码行数:101,代码来源:dest_rsc.php


注:本文中的CF_Authentication::ssl_use_cabundle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。