forked from freuds/nconf
-
Notifications
You must be signed in to change notification settings - Fork 7
/
delete_attr.php
87 lines (59 loc) · 2.74 KB
/
delete_attr.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
77
78
79
80
81
82
83
84
85
86
87
<?php
require_once 'include/head.php';
echo NConf_HTML::title('Delete Attribute');
if (DB_NO_WRITES == 1) {
message($info, TXT_DB_NO_WRITES);
}
if( ( ( isset($_POST["delete"]) ) AND ($_POST["delete"] == "yes") ) AND
( ( isset($_POST["id"]) ) AND ($_POST["id"] != "") )
){
// Delete entry
$query = 'DELETE FROM ConfigAttrs
WHERE id_attr='.$_POST["id"];
$result = db_handler($query, "result", "Delete entry");
if ( $result ){
message ($debug, '', "ok");
history_add("removed", "Attribute", $_POST["name"]);
echo TXT_DELETED;
$url = $_SESSION["go_back_page"];
echo '<meta http-equiv="refresh" content="'.REDIRECTING_DELAY.'; url='.$url.'">';
NConf_DEBUG::set('<a href="'.$url.'"> [ this page ] (in '.REDIRECTING_DELAY.' seconds)</a>', 'INFO', "<br>redirecting to");
}else{
message ($error, 'Error deleting id_attr '.$_POST["id"].':'.$query);
}
}elseif( !empty($_GET["id"]) ){
// Fetch attr name
$query = 'SELECT attr_name, config_class FROM ConfigAttrs, ConfigClasses WHERE id_attr='.$_GET["id"].' AND fk_id_class=ConfigClasses.id_class';
$attr = db_handler($query, "assoc", "Fetch attr name");
// warning message
$content = 'All "<b>'.$attr["config_class"].'</b>" items will lose their "<b>'.$attr["attr_name"].'</b>" attribute.
<br>All data associated with this attribute will also be lost.
This action cannot be undone.';
$content .= '<br><br>
Are you <b>REALLY SURE</b> you want to proceed?<br><br>';
// Buttons
$content_button = '
<form name="delete_attr" action="delete_attr.php" method="post">
<input type="hidden" name="id" value="'.$_GET["id"].'">
<input type="hidden" name="name" value="'.$attr["attr_name"].'">
';
if ( !empty($_GET["from"]) ) $content_button .= '<input type="hidden" name="from" value="'.$_GET["from"].'">';
$content_button .= '<input type="hidden" name="delete" value="yes">
<div id=buttons>';
$content_button .= '<input type="Submit" value="Delete" name="submit" align="middle"> ';
$content_button .= '<input type=button onClick="window.location.href=\''.$_SESSION["go_back_page"].'\'" value="Back">';
$content_button .= '</form>';
echo NConf_HTML::limit_space(
NConf_HTML::show_highlight('WARNING', $content.$content_button)
);
}else{
NConf_DEBUG::set("No item to delete", "ERROR");
}
if ( NConf_DEBUG::status('ERROR') ) {
echo NConf_HTML::limit_space( NConf_HTML::show_error() );
echo "<br><br>";
echo NConf_HTML::back_button($_SESSION["go_back_page"]);
}
mysqli_close($dbh);
require_once 'include/foot.php';
?>