Ejemplo n.º 1
0
 /**
  * Tests S3
  *
  * @param string $error
  * @return boolean
  */
 function test(&$error)
 {
     if (!parent::test($error)) {
         return false;
     }
     $string = 'test_azure_' . md5(time());
     if (!$this->_init($error)) {
         return false;
     }
     try {
         $containers = $this->_client->listContainers();
     } catch (Exception $exception) {
         $error = sprintf('Unable to list containers (%s).', $exception->getMessage());
         return false;
     }
     $container = null;
     foreach ((array) $containers as $_container) {
         if ($_container->Name == $this->_config['container']) {
             $container = $_container;
             break;
         }
     }
     if (!$container) {
         $error = sprintf('Container doesn\'t exist: %s.', $this->_config['container']);
         return false;
     }
     try {
         $this->_client->putBlobData($this->_config['container'], $string, $string);
     } catch (Exception $exception) {
         $error = sprintf('Unable to put blob data (%s).', $exception->getMessage());
         return false;
     }
     try {
         $data = $this->_client->getBlobData($this->_config['container'], $string);
     } catch (Exception $exception) {
         $error = sprintf('Unable to get blob data (%s).', $exception->getMessage());
         return false;
     }
     if ($data != $string) {
         try {
             $this->_client->deleteBlob($this->_config['container'], $string);
         } catch (Exception $exception) {
         }
         $error = 'Blob datas are not equal.';
         return false;
     }
     try {
         $this->_client->deleteBlob($this->_config['container'], $string);
     } catch (Exception $exception) {
         $error = sprintf('Unable to delete blob (%s).', $exception->getMessage());
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Get configuration for a specific role instance
  *
  * @param string $roleInstance Role instance name, can be found in $_SERVER['RdRoleId'] when hosted on Windows Azure.
  * @return Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance
  * @throws Microsoft_WindowsAzure_Diagnostics_Exception
  */
 public function getConfigurationForRoleInstance($roleInstance = null)
 {
     if (is_null($roleInstance)) {
         throw new Microsoft_WindowsAzure_Diagnostics_Exception('Role instance should be specified. Try reading $_SERVER[\'RdRoleId\'] for this information if the application is hosted on Windows Azure Fabric or Development Fabric.');
     }
     if ($this->_blobStorageClient->blobExists($this->_controlContainer, $roleInstance)) {
         $configurationInstance = new Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance();
         $configurationInstance->loadXml($this->_blobStorageClient->getBlobData($this->_controlContainer, $roleInstance));
         return $configurationInstance;
     }
     return new Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance();
 }
Ejemplo n.º 3
0
 /**
  * Read a specific session
  * 
  * @param int $id Session Id
  * @return string
  */
 public function read($id)
 {
     // Read data
     if ($this->_storageType == self::STORAGE_TYPE_TABLE) {
         // In table storage
         try {
             $sessionRecord = $this->_storage->retrieveEntityById($this->_sessionContainer, $this->_sessionContainerPartition, $id);
             return unserialize(base64_decode($sessionRecord->serializedData));
         } catch (Microsoft_WindowsAzure_Exception $ex) {
             return '';
         }
     } else {
         if ($this->_storageType == self::STORAGE_TYPE_BLOB) {
             // In blob storage
             try {
                 $data = $this->_storage->getBlobData($this->_sessionContainer, $this->_sessionContainerPartition . '/' . $id);
                 return unserialize(base64_decode($data));
             } catch (Microsoft_WindowsAzure_Exception $ex) {
                 return false;
             }
         }
     }
 }
Ejemplo n.º 4
0
     }
     $jobs = get_option('backwpup_jobs');
     $jobid = $_GET['jobid'];
     try {
         $storageClient = new Microsoft_WindowsAzure_Storage_Blob($jobs[$jobid]['msazureHost'], $jobs[$jobid]['msazureAccName'], $jobs[$jobid]['msazureKey']);
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         //header("Content-Type: ".$s3file->header->_info->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: ".$s3file->header->_info->size_download);
         echo $storageClient->getBlobData($jobs[$jobid]['msazureContainer'], $_GET['file']);
         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']);