-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaddtype.php
123 lines (118 loc) · 3.02 KB
/
addtype.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
if($_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest" && isset($_POST['type']) && isset($_POST['input1']))
{
$type = intval($_POST['type']);
$input1 = $_POST['input1'];
$change = false;
$delete = false;
if(isset($_POST['input2']))
$input2 = $_POST['input2'];
if(isset($_POST['change']))
$change = $_POST['change'];
if(isset($_POST['delete']))
$delete = true;
require_once("config.php");
require_once("lib/classes.php");
$sql = new sql;
$main = new main;
if(!$change && !$delete)
{
switch($type)
{
case 1:
$query = "INSERT INTO `bt_priority` (`name`,`color`) VALUES ('".$input1."','".$input2."')";
break;
case 2:
$query = "INSERT INTO `bt_section` (`name`) VALUES ('".$input1."')";
break;
case 3:
$query = "INSERT INTO `bt_subtype` (`name`) VALUES ('".$input1."')";
break;
case 4:
$query = "INSERT INTO `bt_status` (`name`) VALUES ('".$input1."')";
break;
default:
$query = false;
}
}
else if(!$delete)
{
switch($type)
{
case 1:
$query = "UPDATE `bt_priority` SET `name` = '".$input1."', `color` = '".$input2."' WHERE `id` = '".$change."'";
break;
case 2:
$query = "UPDATE `bt_section` SET `name` = '".$input1."' WHERE `id` = '".$change."'";
break;
case 3:
$query = "UPDATE `bt_subtype` SET `name` = '".$input1."' WHERE `id` = '".$change."'";
break;
case 4:
$query = "UPDATE `bt_status` SET `name` = '".$input1."' WHERE `id` = '".$change."'";
break;
default:
$query = false;
}
}
else if($delete)
{
switch($type)
{
case 1:
$query = "DELETE FROM `bt_priority` WHERE `id` = '".$change."' LIMIT 1";
break;
case 2:
$query = "DELETE FROM `bt_section` WHERE `id` = '".$change."' LIMIT 1";
break;
case 3:
$query = "DELETE FROM `bt_subtype` WHERE `id` = '".$change."' LIMIT 1";
break;
case 4:
$query = "DELETE FROM `bt_status` WHERE `id` = '".$change."' LIMIT 1";
break;
default:
$query = false;
}
}
if($query)
{
if($delete)
{
$id = $main->GetPreviousElement($type,$change);
switch($type)
{
case 1:
$upd = "UPDATE `bt_message` SET `priority` = '".$id."' WHERE `priority` = '".$change."'";
break;
case 2:
$upd = "UPDATE `bt_options` SET `type` = '".$id."' WHERE `type` = '".$change."'";
break;
case 3:
$upd = "UPDATE `bt_options` SET `subtype` = '".$id."' WHERE `subtype` = '".$change."'";
break;
case 4:
$upd = "UPDATE `bt_message` SET `status` = '".$id."' WHERE `status` = '".$change."'";
break;
default:
$upd = false;
}
if($upd)
{
if(!$sql->exe($cfg->get("realmd"),$upd))
echo 'Ошибка переноса! MySQL код некорректен!';
}
else
echo 'Ошибка! Тип '.$type.' не опознан!';
}
if($sql->exe($cfg->get("realmd"),$query))
echo 1;
else
echo 'Ошибка! MySQL код некорректен!';
}
else
echo 'Ошибка! Тип '.$type.' не опознан!';
}
else
echo 'Параметры не переданы!';
?>