forked from andig/videodb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete.php
78 lines (64 loc) · 1.58 KB
/
delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* Delete a video
*
* Handles the deletion of a video
*
* @package videoDB
* @author Andreas Gohr <a.gohr@web.de>
* @version $Id: delete.php,v 2.22 2013/03/10 16:20:31 andig2 Exp $
*/
require_once './core/functions.php';
/**
* input
*/
$id = req_int('id');
$redirect = req_int('redirect');
/**
* Remove image from cache
*
* @author Andreas Goetz <cpuidle@gmx.de>
*/
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();
// @todo check if post, fail if not?
// 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
#!! this does not work- at least not with Smarty3
#$smarty->cache->clear($id);
// goto index instead of delete template
if ($redirect)
{
header("Location: index.php?deleteid=$id");
exit;
}
// prepare templates
tpl_page();
// display templates
$smarty->assign('delete_meta', '<meta http-equiv="refresh"; content="1; url='.session_get('listview', 'index.php').'?'.strip_tags(SID).'">');
tpl_display('delete.tpl');