-
Notifications
You must be signed in to change notification settings - Fork 16
/
user-edit-post.php
91 lines (72 loc) · 2.52 KB
/
user-edit-post.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
<?php
define('IN_SAESPOT', 1);
include(dirname(__FILE__) . '/config.php');
include(dirname(__FILE__) . '/common.php');
if (!$cur_user) exit('error: 403 Access Denied');
$tid = intval($_GET['tid']);
$query = "SELECT id,cid,title,content,closecomment,visible,top FROM yunbbs_articles WHERE id='$tid'";
$t_obj = $DBS->fetch_one_array($query);
if(!$t_obj){
exit('404');
}
if($t_obj['closecomment']){
$t_obj['closecomment'] = 'checked';
}else{
$t_obj['closecomment'] = '';
}
if($t_obj['visible']){
$t_obj['visible'] = 'checked';
}else{
$t_obj['visible'] = '';
}
if($t_obj['top']){
$t_obj['top'] = 'checked';
}else{
$t_obj['top'] = '';
}
// 获取1000个热点分类
$query = $DBS->query("SELECT `id`, `name` FROM `yunbbs_categories` ORDER BY `articles` DESC LIMIT 1000");
$all_nodes = array();
while($node = $DBS->fetch_array($query)) {
$all_nodes[$node['id']] = $node['name'];
}
if( !array_key_exists($t_obj['cid'], $all_nodes) ){
$cid = $t_obj['cid'];
$c_obj = $DBS->fetch_one_array("SELECT id,name FROM yunbbs_categories WHERE id='".$cid."'");
$all_nodes[$c_obj['id']] = $c_obj['name'];
}
unset($node);
$DBS->free_result($query);
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$old_cid = $t_obj['cid'];
$p_cid = $_POST['select_cid'];
$p_title = addslashes(trim($_POST['title']));
$p_content = addslashes(trim($_POST['content']));
$p_closecomment = intval($_POST['closecomment']);
$p_visible = intval($_POST['visible']);
$p_top = intval($_POST['top']);
if($p_title){
$p_title = htmlspecialchars($p_title);
$p_content = htmlspecialchars($p_content);
$DBS->unbuffered_query("UPDATE yunbbs_articles SET cid='$p_cid',title='$p_title',content='$p_content',closecomment='$p_closecomment',visible='$p_visible',top='$p_top' WHERE id='$tid'");
if($p_cid != $old_cid){
$DBS->unbuffered_query("UPDATE yunbbs_categories SET articles=articles+1 WHERE id='$p_cid'");
$DBS->unbuffered_query("UPDATE yunbbs_categories SET articles=articles-1 WHERE id='$old_cid'");
}
header('location: /t-'.$tid);
exit;
}else{
$tip = '标题 不能留空';
}
}else{
$p_title = $t_obj['title'];
$p_content = $t_obj['content'];
$tip = '';
}
// 页面变量
$title = '修改帖子 - '.$t_obj['title'];
// 设置回复图片最大宽度
$img_max_w = 650;
$pagefile = dirname(__FILE__) . '/templates/default/'.$tpl.'user-edit-post.php';
include(dirname(__FILE__) . '/templates/default/'.$tpl.'layout.php');
?>