<?php
/**
* Delete a video
*
* Handles the deletion of a video
*
* @package videoDB
* @author Andreas Gohr <hide@address.com>
* @version $Id: delete.php,v 2.19 2008/04/20 17:31:20 andig2 Exp $
*/
require_once './core/functions.php';
/**
* Remove image from cache
*
* @author Andreas Goetz <hide@address.com>
*/
function removeCacheFile($url)
{
// get extension
if (preg_match("/\.(jpe?g|gif|png)$/i", $url, $matches))
{
// check if file exists
if (cache_file_exists($url, $cache_file, CACHE_IMG, $matches[1]))
{
@unlink($cache_file);
}
}
}
// check for localnet
localnet_or_die();
// multiuser permission check
permission_or_die(PERM_WRITE, get_owner_id($id));
/*
// remove old cover image from cache
$SQL = 'SELECT imgurl FROM '.TBL_DATA.' WHERE id = '.$id;
$res = runSQL($SQL);
if (count($res))
{
removeCacheFile($res[0]['imgurl']);
}
*/
// remove actual data
runSQL('DELETE FROM '.TBL_DATA.' WHERE id = '.$id);
runSQL('DELETE FROM '.TBL_VIDEOGENRE.' WHERE video_id = '.$id);
// clear smarty cache for this item
$smarty->clear_cache($id);
// prepare templates
tpl_page();
// display templates
tpl_display('delete.tpl');
?>