forked from delpino73/Blue-Smiley-Organizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete-file-category.php
58 lines (33 loc) · 1.64 KB
/
delete-file-category.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
<?php
require 'class.base.php';
require 'class.html.php';
$base_instance=new base();
$html_instance=new html();
$userid=$base_instance->get_userid();
$category_id=isset($_REQUEST['category_id']) ? (int)$_REQUEST['category_id'] : exit;
if (isset($_POST['save'])) {
if (!$category_id) { exit; }
$data=$base_instance->get_data("SELECT * FROM {$base_instance->entity['FILE']['MAIN']} WHERE user='$userid' AND category='$category_id'");
for ($index=1; $index <= sizeof($data); $index++) {
$filename=$data[$index]->filename;
if (file_exists('./upload/'.$userid.'/'.$filename)) { unlink('./upload/'.$userid.'/'.$filename); }
}
$base_instance->query("DELETE FROM {$base_instance->entity['FILE']['MAIN']} WHERE user='$userid' AND category='$category_id'");
$base_instance->query("DELETE FROM {$base_instance->entity['FILE']['CATEGORY']} WHERE user='$userid' AND ID='$category_id'");
header('Location: close-me.php'); exit;
}
else {
$data=$base_instance->get_data("SELECT * FROM {$base_instance->entity['FILE']['CATEGORY']} WHERE user='$userid' AND ID='$category_id'");
if (!$data) { $base_instance->show_message('File Category not found'); exit; }
$title=$data[1]->title;
}
$html_instance->add_parameter(
array('ACTION'=>'show_form',
'HEADER'=>'<font color="#ff0000">Delete this category?</font>',
'FORM_ACTION'=>$_SERVER['PHP_SELF'],
'BUTTON_TEXT'=>'Delete'
));
$html_instance->add_form_field(array('TYPE'=>'hidden','NAME'=>'category_id','VALUE'=>"$category_id"));
$html_instance->add_form_field(array('TYPE'=>'label','TEXT'=>"Are you sure you want to delete the <b>'$title'</b> category AND the items of this category?"));
$html_instance->process();
?>