-
Notifications
You must be signed in to change notification settings - Fork 20
/
cms_db_update.php
217 lines (206 loc) · 4.9 KB
/
cms_db_update.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
/**
*
* @package Icy Phoenix
* @version $Id$
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
define('CTRACKER_DISABLED', true);
define('IN_ICYPHOENIX', true);
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(IP_ROOT_PATH . 'common.' . PHP_EXT);
$config['jquery_ui'] = true;
// Define constant to keep page_header.php from sending headers
define('AJAX_HEADERS', true);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// End session management
// We need to add a USER_ID check-in (passed via GET) to give proper AUTH to non admin users to edit only own pages
// Get SID and check it
$sid = request_var('sid', '');
if ($sid != $user->data['session_id'])
{
$result_ar = array(
'result' => AJAX_ERROR,
'error_msg' => 'Invalid session_id'
);
AJAX_message_die($result_ar);
}
// Get mode
$mode = request_var('mode', '');
$cms_type = request_var('cms_type', '');
$type = request_var('type', '');
$b_id = request_var('b_id', 0);
$b_id = ($b_id < 0) ? 0 : $b_id;
$cat = request_var('cat', 0);
$cat = ($cat < 0) ? 0 : $cat;
$m_id = request_var('m_id', 0);
$m_id = ($m_id < 0) ? 0 : $m_id;
$old_status = request_var('status', 0);
$old_status = ($old_status == 0) ? 0 : 1;
// Send AJAX headers - this is to prevent browsers from caching possible error pages
AJAX_headers();
switch ($mode)
{
case 'update_block':
if (($type != '') && ($b_id > 0))
{
if($cms_type == '1')
{
$cms_block_table = CMS_BLOCKS_TABLE;
}
else
{
$cms_block_table = CMS_ADV_BLOCKS_TABLE;
}
$new_status = ($old_status) ? 0 : 1;
switch ($type)
{
case '0':
$field = 'active';
break;
case '1':
$field = 'border';
break;
case '2':
$field = 'titlebar';
break;
case '3':
$field = 'local';
break;
case '4':
$field = 'background';
break;
default:
$result_ar = array(
'result' => AJAX_ERROR,
'error_msg' => 'Invalid type: ' . $type
);
AJAX_message_die($result_ar);
exit;
}
$sql = "UPDATE " . $cms_block_table . " SET " . $field . " = '" . $new_status . "' WHERE bid = '" . $b_id . "'";
$result = $db->sql_query($sql);
}
else
{
$result_ar = array(
'result' => AJAX_ERROR,
'error_msg' => 'Invalid type: ' . $type
);
AJAX_message_die($result_ar);
exit;
}
break;
case 'update_menu_order':
if ($user->data['user_level'] != ADMIN)
{
$result_ar = array(
'result' => AJAX_ERROR,
'error_msg' => 'NOT ALLOWED!!!'
);
AJAX_message_die($result_ar);
exit;
}
if (($cat > 0) && !empty($_POST['item']))
{
$item_order = 0;
foreach($_POST['item'] as $menu_item_id)
{
$item_order++;
$sql = "UPDATE " . CMS_NAV_MENU_TABLE . " SET menu_order = '" . $item_order . "' WHERE menu_item_id = '" . $menu_item_id . "'";
$result = $db->sql_query($sql);
}
}
else
{
$result_ar = array(
'result' => AJAX_ERROR,
'error_msg' => 'Invalid menu cat: ' . $cat
);
AJAX_message_die($result_ar);
exit;
}
break;
case 'update_modules_order':
if ($user->data['user_level'] != ADMIN)
{
$result_ar = array(
'result' => AJAX_ERROR,
'error_msg' => 'NOT ALLOWED!!!'
);
AJAX_message_die($result_ar);
exit;
}
if (!empty($_POST['item']))
{
$db->sql_transaction();
$item_order = 0;
foreach($_POST['item'] as $module_item_id)
{
$item_order++;
$sql = "UPDATE " . STATS_MODULES_TABLE . " SET display_order = '" . ($item_order * 10) . "' WHERE module_id = '" . $module_item_id . "'";
$result = $db->sql_query($sql);
}
$db->sql_transaction('commit');
}
else
{
$result_ar = array(
'result' => AJAX_ERROR,
'error_msg' => 'Invalid stats module'
);
AJAX_message_die($result_ar);
exit;
}
break;
case 'update_smileys_order':
if ($user->data['user_level'] != ADMIN)
{
$result_ar = array(
'result' => AJAX_ERROR,
'error_msg' => 'NOT ALLOWED!!!'
);
AJAX_message_die($result_ar);
exit;
}
if (!empty($_POST['item']))
{
$db->sql_transaction();
$item_order = 0;
foreach($_POST['item'] as $smiley_item_id)
{
$item_order++;
$sql = "UPDATE " . SMILIES_TABLE . " SET smilies_order = '" . $item_order . "' WHERE smilies_id = '" . $smiley_item_id . "'";
$result = $db->sql_query($sql);
}
$db->sql_transaction('commit');
$cache->destroy('_smileys');
$db->clear_cache('smileys_');
}
else
{
$result_ar = array(
'result' => AJAX_ERROR,
'error_msg' => 'Invalid smiley position'
);
AJAX_message_die($result_ar);
exit;
}
break;
default:
$result_ar = array(
'result' => AJAX_ERROR,
'error_msg' => 'Invalid mode: ' . $mode
);
AJAX_message_die($result_ar);
exit;
}
$cache->destroy('_cms_layouts_config');
empty_cache_folders(CMS_CACHE_FOLDER);
?>