forked from etng/youbbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin-link.php
76 lines (63 loc) · 2.08 KB
/
admin-link.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
<?php
define('IN_SAESPOT', 1);
include(dirname(__FILE__) . '/config.php');
include(dirname(__FILE__) . '/common.php');
if (!$cur_user || $cur_user['flag']<99) exit('error: 403 Access Denied');
$act = trim($_GET['act']);
$lid = intval($_GET['lid']);
if($lid){
$query = "SELECT * FROM yunbbs_links WHERE id='$lid'";
$l_obj = $DBS->fetch_one_array($query);
if(!$l_obj){
header('location: /admin-link-list');
exit;
}
}
$tip1 = '';
$tip2 = '';
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$action = $_POST['action'];
if($action=='add'){
$n_name = trim($_POST['name']);
$n_url = trim($_POST['url']);
if($n_name && $n_url){
if($DBS->query("INSERT INTO yunbbs_links (id,name,url) VALUES (null,'$n_name','$n_url')")){
$tip1 = '已成功添加';
}else{
$tip1 = '数据库更新失败,修改尚未保存,请稍后再试';
}
}else{
$tip1 = '链接名 和 网址 不能留空';
}
}else if($action=='edit'){
$n_name = trim($_POST['name']);
$n_url = trim($_POST['url']);
if($n_name && $n_url){
if($DBS->unbuffered_query("UPDATE yunbbs_links SET name='$n_name',url='$n_url' WHERE id='$lid'")){
$l_obj['name'] = $n_name;
$l_obj['url'] = $n_url;
$tip2 = '已成功保存';
}else{
$tip2 = '数据库更新失败,修改尚未保存,请稍后再试';
}
}else{
$tip2 = '链接名 和 网址 不能留空';
}
}
}else{
if($act == 'del'){
$DBS->unbuffered_query("DELETE FROM yunbbs_links WHERE id='$lid'");
}
}
// 获取链接列表
$query_sql = "SELECT * FROM yunbbs_links";
$query = $DBS->query($query_sql);
$linkdb=array();
while ($link = $DBS->fetch_array($query)) {
$linkdb[] = $link;
}
// 页面变量
$title = '链接管理';
$pagefile = dirname(__FILE__) . '/templates/default/'.$tpl.'admin-link.php';
include(dirname(__FILE__) . '/templates/default/'.$tpl.'layout.php');
?>