function wple_remove_snapshot($filename)
{
    $snapshots = wple_get_snapshots();
    $dir = wple_snapshot_dir() . '/';
    $csv = fopen($dir . 'list.csv', 'w');
    if (!$csv) {
        throw new WPLE_Exception(WPLE_MSG_FILE_CREAT_ERROR);
    }
    foreach ($snapshots as $snapshot) {
        if ($snapshot['filename'] == $filename) {
            if (is_file($dir . $snapshot['filename'])) {
                unlink($dir . $snapshot['filename']);
            }
        } else {
            $snapshot['tables'] = implode('|', $snapshot['tables']);
            fputcsv($csv, $snapshot);
        }
    }
    fclose($csv);
}
    }
    if (!empty($msg)) {
        echo '<div class="updated"><p><strong>' . $msg . '</strong></p></div>';
    }
}
?>

	<form action="" method="post">
		<?php 
wp_nonce_field('wple_snapshot', 'wple_snapshot');
?>

		<p><?php 
$public_dir = wp_upload_dir();
$public_dir = $public_dir['baseurl'] . '/wple-snapshots/';
printf(__('Snapshot files are located in <code>%s</code>.<br/>Please ensure the directory is not accessible <a href="%s">from the web</a>.'), wple_snapshot_dir(), $public_dir);
?>
</p>

		<div class="tablenav top">
			<div class="alignleft actions">
				<select name="action">
					<option value="-1" selected="selected"><?php 
echo __('Bulk Actions');
?>
</option>
					<option value="delete"><?php 
echo __('Delete');
?>
</option>
				</select>
function wple_do_export_snapshot($filename, $export_tables)
{
    global $wple_export_file;
    $dir = wple_snapshot_dir() . '/';
    $basename = preg_replace('~\\.sql$~', '', $filename);
    $copy_counter = 1;
    while (is_file($dir . $filename)) {
        $filename = $basename . '_(' . $copy_counter . ').sql';
        $copy_counter++;
    }
    $snaphot_file = fopen($dir . $filename, 'w');
    if (!$snaphot_file) {
        throw new WPLE_Exception(WPLE_MSG_FILE_CREAT_ERROR);
    }
    fflush($wple_export_file);
    rewind($wple_export_file);
    stream_copy_to_stream($wple_export_file, $snaphot_file);
    fclose($snaphot_file);
    wple_add_snapshot($filename, $export_tables);
    $_GET['message'] = sprintf('Created snapshot <code>%s</code>', $filename);
    return $filename;
}