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 if (isset($_GET['Delete']) && isset($_GET['key'])) { $g = $table->retrieveEntityById(TABLE_GUESTBOOK, $_GET['Delete'], $_GET['key']);