本文整理汇总了PHP中CF_Authentication类的典型用法代码示例。如果您正苦于以下问题:PHP CF_Authentication类的具体用法?PHP CF_Authentication怎么用?PHP CF_Authentication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CF_Authentication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doRackspaceUploadNewDeleteOld
function doRackspaceUploadNewDeleteOld($RS_USERNAME, $RS_KEY)
{
//get the most recent grouping of files.
$arrRecentFiles = getMostRecentFiles();
sort($arrRecentFiles);
if (count($arrRecentFiles > 0)) {
//============================================ get our rackspace auth, connection, and container set up =====================================
//Create the authentication instance
$auth = new CF_Authentication($RS_USERNAME, $RS_KEY);
//Perform authentication request
$auth->authenticate();
//Create a connection to the storage/cdn system(s) and pass in the validated CF_Authentication instance.
$conn = new CF_Connection($auth);
//get the "salesforce_backups" container
$cont = $conn->get_container('salesforce_backups');
//============================================ end get our rackspace auth, connection, and container set up =====================================
//get the date prefix off of the most recent grouping of local files
$recentFileDate = getDatePrefix($arrRecentFiles[0]);
//get the listing of files from rackspace cloud files
$arrRackspaceFiles = $cont->list_objects();
sort($arrRackspaceFiles);
//get a distinct listing off all the rackspace prefixes (Dates)
$arrRackspaceDistinctPrefixes = filterDistinctPrefixes($arrRackspaceFiles);
//see if the most recent local date is in rackspace or not
if (!in_array($recentFileDate, $arrRackspaceDistinctPrefixes)) {
//we haven't uploaded our most recent local files yet to rackspace. Let's do it.
uploadToRackspace($cont, $arrRecentFiles);
}
//refresh our container and objects so we are sure the newly included files are in them
$cont = $conn->get_container('salesforce_backups');
//if we have more than 4 distinct date range prefixes (more than 4 weekly backups), delete the older ones so we are just left with the 4 most recent.
deleteOlderBackups($conn, $cont);
}
}
示例2: wmfGetSwiftThumbContainer
/**
* Get the Swift thumbnail container for this wiki.
*
* @param $site string
* @param $lang string
* @param $relPath string Path relative to container
* @return CF_Container|null
*/
function wmfGetSwiftThumbContainer($site, $lang, $relPath)
{
global $wmfSwiftConfig;
// from PrivateSettings.php
$auth = new CF_Authentication($wmfSwiftConfig['user'], $wmfSwiftConfig['key'], NULL, $wmfSwiftConfig['authUrl']);
try {
$auth->authenticate();
} catch (Exception $e) {
wfDebugLog('swiftThumb', "Could not establish a connection to Swift.");
return null;
}
$conn = new CF_Connection($auth);
$wikiId = "{$site}-{$lang}";
// Get the full swift container name, including any shard suffix
$name = "{$wikiId}-local-thumb";
if (in_array($wikiId, array('wikipedia-commons', 'wikipedia-en'))) {
// Code stolen from FileBackend::getContainerShard()
if (preg_match("!^(?:[^/]{2,}/)*[0-9a-f]/(?P<shard>[0-9a-f]{2})(?:/|\$)!", $relPath, $m)) {
$name .= '.' . $m['shard'];
} else {
throw new MWException("Can't determine shard of path '{$relPath}' for '{$wikiId}'.");
}
}
try {
$container = $conn->get_container($name);
} catch (NoSuchContainerException $e) {
// container not created yet
$container = null;
wfDebugLog('swiftThumb', "Could not access `{$name}`; container does not exist.");
}
return $container;
}
示例3: _init
/**
* 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;
}
示例4: connect
public function connect()
{
App::import('Vendor', 'rackspace-php-cloudfiles-5b45176/cloudfiles');
$auth = new CF_Authentication(Configure::read('Cloudfiles.username'), Configure::read('Cloudfiles.apikey'));
$auth->authenticate();
$conn = new CF_Connection($auth);
return $conn;
}
示例5: initContainer
protected function initContainer()
{
if (!$this->containerInitiated) {
$auth = new \CF_Authentication($this->username, $this->apiKey);
$auth->authenticate();
$conn = new \CF_Connection($auth, $this->serviceNet);
$container = $conn->get_container($this->name);
parent::__construct($container->cfs_auth, $container->cfs_http, $container->name, $container->object_count, $container->bytes_used);
}
$this->containerInitiated = true;
}
示例6: __construct
public function __construct($config)
{
$return = parent::__construct($config);
require_once 'cloudfiles.php';
$auth = new CF_Authentication($this->config['rsc-username'], $this->config['rsc-apikey']);
$auth->authenticate();
$this->conn = new CF_Connection($auth);
if ($this->config['rsc-ssl_use_cabundle']) {
$this->conn->ssl_use_cabundle();
}
return $return;
}
示例7: authconn
public function authconn($use_servicenet)
{
$auth = new CF_Authentication($this->authname, $this->authkey);
try {
$auth->authenticate();
} catch (AuthenticationException $e) {
//for some reason this returns two error msgs. one is echo'd even without the below echo
echo $e->getMessage();
return false;
}
$this->conn = new CF_Connection($auth, $servicenet = $use_servicenet);
}
示例8: getConnection
function getConnection()
{
require_once 'modulos/cdn/clases/cloudfiles.php';
$username = "netor27";
$api_key = "a4958be56757129de44332626cb0594b";
$auth = new CF_Authentication($username, $api_key);
$auth->authenticate();
//Creamos una conexión
//Si esta en el servidor con true
//$conn = new CF_Connection($auth, TRUE);
$conn = new CF_Connection($auth);
return $conn;
}
示例9: createSynchronizer
public function createSynchronizer()
{
$username = sfConfig::get('app_rackspace_username');
$key = sfConfig::get('app_rackspace_key');
$containerName = sfConfig::get('app_rackspace_container');
$webDir = sfConfig::get('sf_web_dir');
$ttl = sfConfig::get('app_rackspace_ttl');
$mimeTypeResolver = $this->get('mime_type_resolver');
$dispatcher = $this->get('dispatcher');
$this->logSection("rackspace", "Connecting '{$username}' to '{$containerName}'");
$auth = new CF_Authentication($username, $key);
$auth->authenticate();
$conn = new CF_Connection($auth);
$container = $conn->create_container($containerName);
$synchronizer = new knpDmRackspaceSynchronizer($container, $webDir, $ttl, $mimeTypeResolver, $dispatcher);
return $synchronizer;
}
示例10: getAuth
private static function getAuth()
{
global $wgMemc;
$cacheKey = wfMemcKey('rscloudauth');
$auth = new CF_Authentication(WH_RSCLOUD_USERNAME, WH_RSCLOUD_API_KEY);
$creds = $wgMemc->get($cacheKey);
if (!$creds) {
# $auth->ssl_use_cabundle(); # bypass cURL's old CA bundle
$auth->authenticate();
// makes a call to a remote web server
$creds = $auth->export_credentials();
$wgMemc->set($cacheKey, $creds);
} else {
$auth->load_cached_credentials($creds['auth_token'], $creds['storage_url'], $creds['cdnm_url']);
}
return $auth;
}
示例11: createSynchronizer
protected function createSynchronizer()
{
require_once dirname(__FILE__) . '/../vendor/rackspace/cloudfiles.php';
$username = sfConfig::get('app_rackspace_username');
$key = sfConfig::get('app_rackspace_key');
$containerName = sfConfig::get('app_rackspace_container');
$webDir = sfConfig::get('sf_web_dir');
$ttl = sfConfig::get('app_rackspace_ttl');
$mimeTypeResolver = $this->container->getService('mime_type_resolver');
$dispatcher = $this->container->getService('dispatcher');
$auth = new CF_Authentication($username, $key);
$auth->authenticate();
$conn = new CF_Connection($auth);
$container = $conn->create_container($containerName);
$synchronizer = new knpDmRackspaceSynchronizer($container, $webDir, $ttl, $mimeTypeResolver, $dispatcher);
return $synchronizer;
}
示例12: connect
public function connect()
{
static $bConnected = false;
if ($bConnected === true) {
return;
}
require_once PHPFOX_DIR_LIB . 'rackspace/cloudfiles.php';
$oAuth = new CF_Authentication(Phpfox::getParam('core.rackspace_username'), Phpfox::getParam('core.rackspace_key'));
try {
$oAuth->authenticate();
} catch (Exception $e) {
Phpfox_Error::trigger('Rackspace error: ' . $e->getMessage(), E_USER_ERROR);
}
$this->_oObject = new CF_Connection($oAuth);
$this->_sBucket = Phpfox::getParam('core.rackspace_container');
$this->_oContainer = $this->_oObject->get_container($this->_sBucket);
$bConnected = true;
}
示例13: process_rackspace_copy
function process_rackspace_copy($rs_backup, $rs_username, $rs_api_key, $rs_container, $rs_server)
{
pb_backupbuddy::set_greedy_script_limits();
require_once pb_backupbuddy::plugin_path() . '/lib/rackspace/cloudfiles.php';
$auth = new CF_Authentication($rs_username, $rs_api_key, NULL, $rs_server);
$auth->authenticate();
$conn = new CF_Connection($auth);
// Set container
$container = $conn->get_container($rs_container);
// Get file from Rackspace
$rsfile = $container->get_object($rs_backup);
$destination_file = ABSPATH . 'wp-content/uploads/backupbuddy_backups/' . $rs_backup;
if (file_exists($destination_file)) {
$destination_file = str_replace('backup-', 'backup_copy_' . pb_backupbuddy::random_string(5) . '-', $destination_file);
}
$fso = fopen(ABSPATH . 'wp-content/uploads/backupbuddy_backups/' . $rs_backup, 'w');
$rsfile->stream($fso);
fclose($fso);
}
示例14: 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;
}
}
示例15: connect
public static function connect($settings = array())
{
require_once dirname(__FILE__) . '/lib/rackspace/cloudfiles.php';
$auth = new CF_Authentication($settings['username'], $settings['api_key'], NULL, $settings['server']);
try {
$auth->authenticate();
} catch (Exception $e) {
global $pb_backupbuddy_destination_errors;
$message = 'Error #238338: Unable to authenticate to Rackspace Cloud Files. Details: `' . $e->getMessage() . '`.';
pb_backupbuddy::status('error', $message);
$pb_backupbuddy_destination_errors[] = $message;
return false;
}
//error_log( print_r( $auth, true ) );
if (isset($settings['service_net']) && '1' == $settings['service_net']) {
$sn_url = 'https://snet-' . substr($auth->storage_url, strlen('https://'));
$auth->storage_url = $sn_url;
}
$conn = new CF_Connection($auth);
return $conn;
}