// now go over all snaps, if encounter a snap for a go_ahead_volume which
    // is older than, well, older_than, delete it.
    $dodelete = true;
    if (NOOP) {
        $dodelete = false;
        echo "WARNING: the global NOOP is set in the source code for debbugging purpose so we won't be actually performing deletions\n\n";
    } else {
        if ($noop) {
            $dodelete = false;
            echo "WARNING: not actually deleting, you specified --noop\n\n";
        }
    }
    foreach ($snaps as $snap) {
        $snapTimestamp = strtotime($snap->getStartTime());
        if (in_array($snap->getVolumeId(), $go_ahead_volumes)) {
            if (!keepSnapShot($snap->getStartTime())) {
                echo "Deleting volume " . $snap->getVolumeId() . " snapshot " . $snap->getSnapshotId() . " created on: " . date('m/d/y \\a\\t H:i:s e', strtotime($snap->getStartTime())) . "\n";
                // and now really delete using EC2 library
                $request = new Amazon_EC2_Model_DeleteSnapshotRequest();
                $request->setSnapshotId($snap->getSnapshotId());
                if ($dodelete) {
                    $response = $service->deleteSnapshot($request);
                }
            }
        }
    }
    echo "\n\n";
} else {
    die("\n\nNo snapshots found, quitting.\n\n");
}
/**
 * 
 * This is just file I use to experiment on stuff. You can safely ignore,
 *
 * @author Erik Dasque
 * @version 0.01
 * @copyright Vivaki, 7 March, 2010
 * @package default
 **/
date_default_timezone_set('UTC');
$now = time();
$older_than_month = $now - 28 * 24 * 60 * 60;
// echo "Older than month: ".date('F d, Y',$older_than_month)."\n";
//echo "Older than week: ".date('F d, Y',$older_than)."\n";
for ($date = $older_than_month - 50 * 24 * 60 * 60; $date < $now; $date = $date + 24 * 60 * 60) {
    // echo "-> ".date('F d, Y',$date)."\n";
    keepSnapShot(date('F d, Y', $date));
}
//echo keepSnapShot("3/05/10");
//echo keepSnapShot("3/1/10");
//echo keepSnapShot("3/7/10");
/**
 * function keepSnapShot
 *
 * @return true if we should keep the snapshot, false otherwise
 * Keeps snapshots from the first day of the month, the last month worth of sunday and the last 7 days
 * @author Erik Dasque
 **/
function keepSnapShot($creation_date)
{
    $now = time();
    $older_than = $now - 7 * 24 * 60 * 60;