/** * Open the session store * * @return bool */ public function open() { // Make sure storage container exists if ($this->_storageType == self::STORAGE_TYPE_TABLE) { $this->_storage->createTableIfNotExists($this->_sessionContainer); } else { if ($this->_storageType == self::STORAGE_TYPE_BLOB) { $this->_storage->createContainerIfNotExists($this->_sessionContainer); } } // Ok! return true; }
define('STORAGE_ACCOUNT', '<endpoint of your storage account>'); define('STORAGE_KEY', '<storage account key>'); define('TABLE_GUESTBOOK', 'guestbook'); define('BLOB_GUESTBOOK', 'guestbook'); // Setup the connection if (DEV) { // Connect to local development storage $table = new Microsoft_WindowsAzure_Storage_Table(); $blob = new Microsoft_WindowsAzure_Storage_Blob(); } else { // Connect to Windows Azure Storage in the cloud $table = new Microsoft_WindowsAzure_Storage_Table('table.core.windows.net', STORAGE_ACCOUNT, STORAGE_KEY); $blob = new Microsoft_WindowsAzure_Storage_Blob('blob.core.windows.net', STORAGE_ACCOUNT, STORAGE_KEY); } // Ensure the table exists $table->createTableIfNotExists(TABLE_GUESTBOOK); // Ensure the blob container exists $blob->createcontainerIfNotExists(BLOB_GUESTBOOK); // Set ACL $blob->setContainerAcl(BLOB_GUESTBOOK, Microsoft_WindowsAzure_Storage_Blob::ACL_PUBLIC_CONTAINER); // If the user submitted something put it into the table storage // NOTE: Inputs are not cleaned for example purposes if (isset($_POST['NameTextBox']) && isset($_POST['MessageTextBox'])) { $g = new GuestBookEntry(); $image = $blob->putBlob(BLOB_GUESTBOOK, $_FILES['Image']['name'], $_FILES['Image']['tmp_name']); $g->GuestName = $_POST['NameTextBox']; $g->Message = $_POST['MessageTextBox']; $g->ImageUrl = $image->Url; $table->insertEntity(TABLE_GUESTBOOK, $g); } // User wishes to delete something