-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
268 lines (248 loc) · 8.47 KB
/
admin.php
File metadata and controls
268 lines (248 loc) · 8.47 KB
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?php
/**
* project: ForumCatalog
* version: 2.1
* author: Max Istlyaev aka FladeX
* e-mail: FladeX@yandex.ru
* file: admin.php
* last update: 2011.12.03
**/
session_start();
include('config.php');
include('db.php');
include('functions.php');
include('classes/Forum.php');
include('classes/Category.php');
include('classes/smarty/Smarty.class.php');
global $config;
global $sape;
$sape_links = $sape->return_links();
$forum = new Forum;
$smarty = new Smarty();
$smarty->template_dir = $config['smarty_template_dir'];
$smarty->compile_dir = $config['smarty_compile_dir'];
$smarty->config_dir = $config['smarty_config_dir'];
$smarty->cache_dir = $config['smarty_cache_dir'];
$recent_forums = $forum->display_recent_forums();
//session_start();
// Проверка пароля
if ($_SESSION['authorized'] != $admin_session)
{
$adminpass = $_POST['adminpass'];
if ($adminpass == "")
{
$smarty->assign('title', 'Вход в администраторский раздел');
$smarty->assign('password_wrong', false);
$smarty->assign('recent_forums', $recent_forums);
$smarty->assign('sape_links', $sape_links);
$smarty->display('admin_login.html');
}
else
{
if ($adminpass != $admin_password)
{
$smarty->assign('title', 'Вход в администраторский раздел');
$smarty->assign('password_wrong', true);
$smarty->assign('recent_forums', $recent_forums);
$smarty->assign('sape_links', $sape_links);
$smarty->display('admin_login.html');
}
else
{
$_SESSION['authorized'] = $admin_session;
}
}
}
//
if ($_SESSION['authorized'] == $admin_session) {
$mode = $_GET['mode'];
switch ($mode)
{
case "category":
$option = $_GET['option'];
switch ($option)
{
case "create":
$category_list = category_list("option", 0);
$smarty->assign('title', 'Создание категории');
$smarty->assign('category_list', $category_list);
$smarty->assign('recent_forums', $recent_forums);
$smarty->assign('sape_links', $sape_links);
$smarty->display('admin_category_add.html');
break;
case "new":
$title = $_POST['name'];
$catid = $_POST['parent'];
// Добавление категории в базу данных
$sql = "INSERT
INTO " . $dbprefix . "category
VALUES (NULL, '" . $catid . "', '" . $title . "')";
$result = mysql_query($sql);
if (!$result)
{
die("Невозможно исполнить запрос к базе данных: <br />" . mysql_error());
}
echo " <div class=\"news\">\n";
echo " <h1>Создание категории</h1>\n";
echo " <p>Категория успешно создана!</p>\n";
break;
case "edit":
$id = $_GET['id'];
$category = new Category;
$category_data = $category->edit_category($id);
$category_list = category_list("option", 0);
$smarty->assign('title', 'Редактирование категории');
$smarty->assign('category', $category_data);
$smarty->assign('recent_forums', $recent_forums);
$smarty->assign('sape_links', $sape_links);
$smarty->display('admin_category_edit.html');
break;
case "save":
$id = $_POST['id'];
$title = $_POST['name'];
$parent_id = 0;
$category = new Category;
$category->save_category($id, $title, $parent_id);
$smarty->assign('title', 'Редактирование категории');
$smarty->assign('recent_forums', $recent_forums);
$smarty->assign('sape_links', $sape_links);
$smarty->display('admin_category_save.html');
break;
case "delete":
$id = $_GET['id'];
// Проверка существования форума в базе данных
$sql = "SELECT *
FROM " . $dbprefix . "category
WHERE id = $id";
$result = mysql_query($sql);
if (!$result)
{
die("Невозможно исполнить запрос к базе данных: <br />" . mysql_error());
}
$category_exist = 0;
while ($result_row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$category_exist = 1;
}
if ($category_exist)
{
// Удаление форума из базы данных
$sql = "DELETE
FROM " . $dbprefix . "category
WHERE id = $id";
$result = mysql_query($sql);
if (!$result)
{
die("Невозможно исполнить запрос к базе данных: <br />" . mysql_error());
}
echo " <div class=\"news\">\n";
echo " <h1>Удаление категории</h1>\n";
echo " <p>Категория успешно удалена!</p>\n";
}
else
{
echo " <div class=\"news\">\n";
echo " <h1>Удаление категории</h1>\n";
echo " <p>Указанная категория не найдена в базе данных. Возможно, она уже была удалена.</p>\n";
}
break;
default:
$category = new Category;
$category_list = $category->display_admin_category_list();
$smarty->assign('title', 'Список категорий');
$smarty->assign('category_list', $category_list);
$smarty->assign('recent_forums', $recent_forums);
$smarty->assign('sape_links', $sape_links);
$smarty->display('admin_category_list.html');
break;
}
break;
case "delete":
$id = $_GET['id'];
// Проверка существования форума в базе данных
$sql = "SELECT *
FROM " . $dbprefix . "forums
WHERE id = $id";
$result = mysql_query($sql);
if (!$result)
{
die("Невозможно исполнить запрос к базе данных: <br />" . mysql_error());
}
$forum_exist = 0;
while ($result_row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$forum_exist = 1;
}
if ($forum_exist)
{
// Удаление форума из базы данных
$sql = "DELETE
FROM " . $dbprefix . "forums
WHERE id = $id";
$result = mysql_query($sql);
if (!$result)
{
die("Невозможно исполнить запрос к базе данных: <br />" . mysql_error());
}
echo " <div class=\"news\">\n";
echo " <h1>Удаление форума</h1>\n";
echo " <p>Форум успешно удалён!</p>\n";
}
else
{
echo " <div class=\"news\">\n";
echo " <h1>Удаление форума</h1>\n";
echo " <p>Указанный форум не найден в базе данных. Возможно, он уже был удалён.</p>\n";
}
break;
case "edit":
$id = $_GET['id'];
$forum = $forum->edit_admin_forum($id);
$category_list = category_list("option", $forum['cat']);
$year_list = array();
for ($i = 1998; $i <= date('Y'); $i++) {
$year_list[] = $i;
}
$smarty->assign('title', 'Редактирование форума');
$smarty->assign('forum', $forum);
$smarty->assign('years', $year_list);
$smarty->assign('category_list', $category_list);
$smarty->assign('cms_list', $config['cms']);
$smarty->assign('engines', $config['engines']);
$smarty->assign('recent_forums', $recent_forums);
$smarty->assign('sape_links', $sape_links);
$smarty->display('admin_forum_edit.html');
break;
case "save":
$forum_data = array();
$forum_data['id'] = $_POST['id'];
$forum_data['name'] = $_POST['name'];
$forum_data['url'] = $_POST['url'];
$forum_data['description'] = $_POST['description'];
$forum_data['engine'] = $_POST['engine'];
$forum_data['portal'] = $_POST['portal'];
$forum_data['cms'] = $_POST['cms'];
$forum_data['category'] = $_POST['category'];
$forum_data['year'] = $_POST['year'];
$forum_data['email'] = $_POST['email'];
$forum_data['active'] = isset($_POST['active']) ? $_POST['active'] : 0;
$forum_data['refusal'] = isset($_POST['refusal']) ? $_POST['refusal'] : '';
$forum_data['rss'] = isset($_POST['rss']) ? $_POST['rss'] : '';
$admin_forum_save = $forum->save_admin_forum($forum_data);
$smarty->assign('title', 'Редактирование форума');
$smarty->assign('save_result', $admin_forum_save);
$smarty->assign('recent_forums', $recent_forums);
$smarty->assign('sape_links', $sape_links);
$smarty->display('admin_forum_save.html');
break;
default:
$admin_forum_list = $forum->display_admin_forum_list();
$smarty->assign('title', 'Редактирование форумов');
$smarty->assign('admin_forum_list', $admin_forum_list);
$smarty->assign('recent_forums', $recent_forums);
$smarty->assign('sape_links', $sape_links);
$smarty->display('admin_forum_list.html');
break;
}
}
?>