<?php
if (! $_GET['id'] ) { dieWithError("No id to delete received"); }
$vsf->connect() or dieWithError("Error connecting to database: " . $vsf->mysql_error);
// look up the filename from the database
$query = "SELECT filename FROM episodes WHERE id = " . mysql_real_escape_string($_GET['id']);
$result = mysql_query($query) or die("query failed: ". mysql_error());
if ( @mysql_num_rows($result) == 0 ) {
die("no episode with that id");
}
else {
$row = mysql_fetch_array($result);
extract($row);
// now delete the file
$thefile = $vsf->config->misc->datadir . "/$filename";
if ( file_exists($thefile) ) {
if (! @unlink($thefile) ) { dieWithError("unable to delete $filename"); }
}
// then delete the file from the database
$query = "DELETE FROM episodes WHERE id = " . mysql_real_escape_string($_GET['id']);
$result = mysql_query($query) or die("File is deleted but delete query failed.");
// and regenerate the RSS feed file
include('act_genrssfile.php');
// redisplay the episode list
print "<p style='color: green;'>Episode <b>$title</b> deleted.</p>";
include('dsp_list_episodes.php');
}
?>