예제 #1
0
 /**
  * Garbage collector
  * 
  * @param int $lifeTime Session maximal lifetime
  * @see session.gc_divisor  100
  * @see session.gc_maxlifetime 1440
  * @see session.gc_probability 1
  * @usage Execution rate 1/100 (session.gc_probability/session.gc_divisor)
  * @return boolean
  */
 public function gc($lifeTime)
 {
     if ($this->_storageType == self::STORAGE_TYPE_TABLE) {
         // In table storage
         try {
             $result = $this->_storage->retrieveEntities($this->_sessionContainer, 'PartitionKey eq \'' . $this->_sessionContainerPartition . '\' and sessionExpires lt ' . (time() - $lifeTime));
             foreach ($result as $sessionRecord) {
                 $this->_storage->deleteEntity($this->_sessionContainer, $sessionRecord);
             }
             return true;
         } catch (Microsoft_WindowsAzure_exception $ex) {
             return false;
         }
     } else {
         if ($this->_storageType == self::STORAGE_TYPE_BLOB) {
             // In blob storage
             try {
                 $result = $this->_storage->listBlobs($this->_sessionContainer, $this->_sessionContainerPartition, '', null, null, 'metadata');
                 foreach ($result as $sessionRecord) {
                     if ($sessionRecord->Metadata['sessionexpires'] < time() - $lifeTime) {
                         $this->_storage->deleteBlob($this->_sessionContainer, $sessionRecord->Name);
                     }
                 }
                 return true;
             } catch (Microsoft_WindowsAzure_exception $ex) {
                 return false;
             }
         }
     }
 }
예제 #2
0
 /**
  * Garbage collector
  *
  * @param int $lifeTime Session maximal lifetime
  * @see session.gc_divisor  100
  * @see session.gc_maxlifetime 1440
  * @see session.gc_probability 1
  * @usage Execution rate 1/100 (session.gc_probability/session.gc_divisor)
  * @return boolean
  */
 public function gc($lifeTime)
 {
     try {
         $result = $this->_tableStorage->retrieveEntities($this->_sessionTable, 'PartitionKey eq \'' . $this->_sessionTablePartition . '\' and sessionExpires lt ' . (time() - $lifeTime));
         foreach ($result as $sessionRecord) {
             $this->_tableStorage->deleteEntity($this->_sessionTable, $sessionRecord);
         }
         return true;
     } catch (Microsoft_WindowsAzure_exception $ex) {
         return false;
     }
 }
// 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']);
    $table->deleteEntity(TABLE_GUESTBOOK, $g);
    header("Location: index.php");
}
// Get all the guest book entries for display
$entries = $table->retrieveEntities(TABLE_GUESTBOOK);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Windows Azure Guestbook</title>
    <link href="main.css" rel="stylesheet" type="text/css" />
   
</head>
<body>
     <div class="general">