-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmarked_topic.php
134 lines (121 loc) · 5.44 KB
/
marked_topic.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
<?php
require "include/bittorrent.php";
dbconn();
loggedinorreturn();
parked();
function paging($page, $page_amount)
{
if ($page != 1 && $page != $page_amount) {
//print("<div style=\"float:left\"");
print("<a href=\"?page=1\">|首页</a><a href=\"?page=" . ($page + 1) . "\">|下页|</a><a>......</a><a href=\"?page=" . ($page - 1) . "\">|上页</a><a href=\"?page=" . $page_amount . "\">|尾页|</a>");
//print("</div>");
} else if ($page == 1 && $page_amount == 1) {
//print("<div style=\"float:left\"");
print("<a href=\"?page=1\">|首页</a><a href=\"#\">|下页|</a><a>......</a><a href=\"#\">|上页|</a><a href=\"?page=" . $page_amount . "\">|尾页|</a>");
//print("</div>");
} else if ($page == 1) {
print("<a href=\"?page=1\">|首页</a><a href=\"?page=" . ($page + 1) . "\">|下页|</a><a>......</a><a>|上页|</a><a href=\"?page=" . $page_amount . "\">|尾页|</a>");
} else {
//print("<div style=\"float:left\"");
print("<a href=\"?page=1\">|首页</a><a>|下页|</a><a>......</a><a href=\"?page=" . ($page - 1) . "\">|上页|</a><a href=\"?page=" . $page_amount . "\">|尾页|</a>");
// print("</div>");
}
print(" 当前" . $page . "页 共" . $page_amount . "页</br>");
} //分页页面选择函数结束
function topiclist($page = 1, $pagesize = 20)
{
global $CURUSER;
$all = mysql_num_rows(sql_query("SELECT * FROM marked_topic WHERE uid=$CURUSER[id]"));
if ($all > 0) {
if ($all <= $pagesize) {
$page_amount = 1;
} else {
$temp = $all / $pagesize;
if ($all % $pagesize) {
$page_amount = (int)($all / $pagesize + 1);
} else {
$page_amount = $all / $pagesize;
}
}
} else {
stdmsg("对不起", "暂无数据");
stdfoot();
exit();
}
paging($page, $page_amount);
?>
<table border="0" cellspacing="0" cellpadding="5" width=940>
<?php
print("<td align=center class=tabletitle><b>收藏的主题</b></td>");
?>
</table>
<?php
print("<table border=0 cellspacing=0 cellpadding=3 width=940><tr>" .
"<td class=colhead align=left width=80%>主题</td>" .
"<td class=colhead align=center><nobr>回复/查看</nobr></td>" .
"<td class=colhead align=center>发布者</td>" .
"<td class=colhead align=center width=20%>最近回复</td>" .
"<td class=colhead align=center>操作</td>" .
"</tr>");
$res_topics = sql_query("SELECT * FROM marked_topic INNER JOIN topics ON topics.id = marked_topic.tid WHERE marked_topic.uid = " . $CURUSER['id'] . " ORDER BY marked_topic.id DESC LIMIT" . " " . ((sqlesc($page) - 1) * sqlesc($pagesize)) . "," . sqlesc($pagesize)) or sqlerr();
while ($topicarr = mysql_fetch_assoc($res_topics)) {
$topicid = $topicarr["id"];
$topic_title = $topicarr["subject"];
$topic_userid = $topicarr["userid"];
$topic_views = $topicarr["views"];
$views = number_format($topic_views);
/// GETTING TOTAL NUMBER OF POSTS ///
global $Cache;
if (!$posts = $Cache->get_value('topic_' . $topicid . '_post_count')) {
$posts = get_row_count("posts", "WHERE topicid=" . sqlesc($topicid));
$Cache->cache_value('topic_' . $topicid . '_post_count', $posts, 3600);
}
$replies = max(0, $posts - 1);
/// GETTING USERID AND DATE OF LAST POST ///
$arr = get_post_row($topicarr['lastpost']);
$postid = 0 + $arr["id"];
$userid = 0 + $arr["userid"];
$added = gettime($arr['added'], true, false);
/// GET NAME OF LAST POSTER ///
$username = get_username($userid);
/// GET NAME OF THE AUTHOR ///
$author = get_username($topic_userid);
$subject = "<a href=forums.php?action=viewtopic&topicid=$topicid><b>" . htmlspecialchars($topicarr["subject"]) . "</b></a>";
print("<tr class=tableb><td style='padding-left: 10px' align=left class=rowfollow>$subject</td>" .
"<td align=center class=rowfollow>" . $replies . "/" . $views . "</td>" .
"<td align=center class=rowfollow>" . $author . "</td>" .
"<td align=center class=rowfollow><nobr>" . $added . " | " . $username . "</nobr></td>" .
"<td align=center class=rowfollow><a href=\"" . htmlspecialchars("marked_topic.php?action=delete&topicid=" . $topicid) . "\"><input class=\"btn\" type=\"button\" value=\"删除\" alt=\"Delete\" /></a></td></tr>");
}
?>
</table>
</td>
</tr>
<?php
}
stdhead("收藏的帖子");
global $CURUSER;
if ($_GET["action"] == "add") {
if ($tid = 0 + $_GET["topicid"]) {
$res = sql_query("SELECT * from topics where id = " . sqlesc($tid));
if ($row = mysql_fetch_array($res)) {
sql_query("insert INTO marked_topic (tid, uid) VALUES ( {$row['id']} , {$CURUSER['id']})") or sqlerr(__FILE__, __LINE__);
}
}
}
if ($_GET["action"] == "delete") {
if ($tid = 0 + $_GET["topicid"]) {
$res = sql_query("SELECT * from marked_topic where tid = " . sqlesc($tid) . " and uid = {$CURUSER['id']}");
if ($row = mysql_fetch_array($res)) {
sql_query("DELETE FROM marked_topic WHERE tid = {$row['id']} and uid = {$CURUSER['id']}") or sqlerr(__FILE__, __LINE__);
}
}
}
if (isset($_GET['page'])) {
$page = 0 + $_GET['page'];
} else {
$page = 1;
}
topiclist($page);
stdfoot();
?>