This repository was archived by the owner on Mar 4, 2019. It is now read-only.
forked from etng/youbbs
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadmin-node.php
More file actions
executable file
·94 lines (82 loc) · 3.14 KB
/
admin-node.php
File metadata and controls
executable file
·94 lines (82 loc) · 3.14 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
<?php
define('IN_SAESPOT', 1);
define('ROOT', dirname(__FILE__));
include_once(ROOT . '/config.php');
include_once(ROOT . '/common.php');
if (!$cur_user) {
$error_code = 4012;
include_once(ROOT . '/error/401.php');
exit;
}
if ($cur_user['flag']<99) {
$error_code = 4031;
include_once(ROOT . '/error/403.php');
exit;
}
$nid = intval($_GET['nid']);
if($nid){
$query = "SELECT * FROM yunbbs_categories WHERE id='$nid'";
$c_obj = $DBS->fetch_one_array($query);
if(!$c_obj){
$error_code = 4046;
$title = $options['name'].' › 节点未找到';
$pagefile = ROOT . '/templates/default/404.php';
include_once(ROOT . '/templates/default/'.$tpl.'layout.php');
exit;
}
}
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$action = $_POST['action'];
switch ($action) {
case 'find':
$n_id = trim($_POST['findid']);
$n_id ? header('Location: /admin-node-'.$n_id) : header('Location: /admin-node#edit');
break;
case 'add':
$n_name = addslashes(trim($_POST['name']));
$n_about = addslashes(trim($_POST['about']));
if ($n_name) {
$check_obj = $DBS->fetch_one_array("SELECT * FROM yunbbs_categories WHERE name='$n_name'");
if ($check_obj) {
$tip1 = $n_name.' 节点已存在,请修改为不同的节点名';
} else {
if ($DBS->query("INSERT INTO yunbbs_categories (name, about) VALUES ('$n_name', '$n_about')")) {
//更新缓存
$MMC->delete('newest_nodes');
$MMC->delete('bot_nodes');
$MMC->delete('site_infos');
$tip1 = '已成功添加';
} else {
$tip1 = '数据库更新失败,修改尚未保存,请稍后再试';
}
}
} else {
$tip1 = '节点名不能留空';
}
break;
case 'edit':
$n_name = addslashes(trim($_POST['name']));
$n_about = addslashes(trim($_POST['about']));
if ($n_name) {
if ($DBS->unbuffered_query("UPDATE yunbbs_categories SET name='$n_name',about='$n_about' WHERE id='$nid'")) {
//更新缓存
$MMC->delete('newest_nodes');
$MMC->delete('bot_nodes');
$MMC->delete('n-'.$nid);
$c_obj['name'] = $n_name;
$c_obj['about'] = $n_about;
$tip2 = '已成功保存';
} else {
$tip2 = '数据库更新失败,修改尚未保存,请稍后再试';
}
} else {
$tip2 = '节点名不能留空';
}
break;
}
}
// 页面变量
$title = '节点管理 - '.$options['name'];
$pagefile = ROOT . '/templates/default/'.$tpl.'admin-node.php';
include_once(ROOT . '/templates/default/'.$tpl.'layout.php');
?>