-
Notifications
You must be signed in to change notification settings - Fork 0
/
posts.php
123 lines (119 loc) · 4.69 KB
/
posts.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
<?php
include_once("func.php");
ConnectDb();
$pid=nfilter($_GET['p']);
$result=mysql_fetch_array(mysql_query("SELECT * FROM Posts WHERE PID=" . $pid));
$un=$result['username'];
$ppid=$result['parent'];
$title=$result['title'];
$rootrow=$result;
$isroot=true;
if($ppid!=1){
$isroot=false;
$rootrow=mysql_fetch_array(mysql_query("SELECT * FROM Posts WHERE PID=".findroot($pid)));
$title="回复:" . $rootrow['title'];
}
loadHeader($title . " - NEWorld Forum");
?>
<style type="text/css">
.box img{max-width:90%;}
</style>
<div id="main_right">
<?php
loaduserinfo();
function latest_topics($pid){
echo '<div id="latest_topics">';
$results = mysql_query("SELECT * FROM Posts WHERE parent=".$pid." ORDER BY createtime DESC LIMIT 0,5");
if(mysql_num_rows($results)){
echo '<p class="nmp">本帖的最新回复:</p><div class="box" style="padding:0px;">';
while($result = mysql_fetch_array($results)){
echo "<div class='topic'>{$result["username"]}:<br /><a href='posts.php?p={$result['PID']}'>{$result['content']}</a><br />
<span style='font-size:12px;'>回复数:{$result['replycount']}<br />发布时间:{$result['createtime']}</span></div>";
}
echo '</div>';
}
echo '</div>';
}
latest_topics($pid);
?>
</div>
<div id="main_left">
<div class="box clearfix">
<?php
echo '<form action="post.php" method="post">';
echo '<input type="hidden" name="type" value="1" readonly="true">';
echo '<input type="hidden" name="pid" value="' . $pid . '" readonly="true">';
echo "<div style='float:left;'><h2>" . $title . "</h2></div>";
if(!$isroot){
echo "<div style='float:right;'>";
echo "<input type='button' value='返回上一级' class='btn' onclick=\" window.open('posts.php?p=".$ppid."','_self') \" />";
echo " | ";
echo "<input type='button' value='返回所在帖子' class='btn' onclick=\" window.open('posts.php?p=".$rootrow['PID']."','_self') \" />";
echo "</div>";
}
echo "<hr style='clear:both;'/>";
echo '<p>' . $result['content'] . '</p>';
echo "<p class='nmp' style='font-size:12px;float:right;'>";
echo "作者:<a href={$userinfoHost}?username={$result['username']}>{$result['username']}</a> | 回复数: {$result['replycount']} | ";
echo "最后回复:{$result['lastreplytime']} | 发布时间: {$result['createtime']}</p>";
$candelete=false;
if(delete_auth($pid)){
echo '<p><input type="submit" value="删除" class="btn" /></p>';
$candelete=true;
}
echo '</form>';
function show_replies($ppid,$deep,$candelete){
global $userinfoHost;
$results = mysql_query("SELECT * FROM Posts WHERE parent='" . $ppid . "' ORDER BY floor ASC");
$count=0;
while($result = mysql_fetch_array($results)){
$content=$result['content'];
$pid=$result['PID'];
$un=$result['username'];
echo '<div class="topic clearfix">';
echo "<p class='nmp'>[".($deep==0?"":$deep."层堆叠,")."{$result['floor']}楼] ";
echo "<a href={$userinfoHost}?username={$result['username']}>{$result['username']}</a>:";
echo "<br />{$result['content']}</p>";
echo "<p class='nmp' style='font-size:12px;float:right;'>";
echo "回复数: {$result['replycount']} | 最后回复:{$result['lastreplytime']} | 发布时间: {$result['createtime']}</p>";
echo '<input type="button" value="回复" class="btn" onclick="showreplybox(' . $pid . ')" />';
if(!$candelete && delete_auth($pid))$candelete=true;
if($candelete){
echo '<form action="post.php" method="post" style="display:inline;">
<input type="hidden" name="type" value="1" readonly="true">
<input type="hidden" name="pid" value="' . $pid . '" readonly="true">
<input type="submit" value="删除" class="btn" />
</form>';
}
echo '<div id="replybox_'.$pid.'" style="display:none;padding:10px;"></div>';
echo '</div>';
if($result['replycount']){
echo '<div class="box reply" style="z-index:'.$deep.';">';
show_replies($pid,$deep+1,$candelete);
echo '</div>';
}
}
}
?>
</div>
<?php
if($result['replycount']){
echo '<div class="box" style="padding:0px;margin-top:10px;">';
show_replies($pid,0,$candelete);
echo '</div>';
}
DisconnectDb();
?>
<div class="box" style="margin-top:10px;">
<p class="nmp">发表回复</p>
<hr />
<form id="postreply" action="post.php" method="post">
<input type="hidden" name="type" value="2" readonly="true" />
<input type="hidden" name="pid" value="<?php echo $_GET['p']; ?>" readonly="true" />
<input type="hidden" name="content" id="content" value="" />
<div id="editor" contenteditable="true" class="txtbox"></div>
</form>
<p><button onclick="SubmitPost();" class="btn" style='color:#ffffff;background-color:#0099ff;'>回复</button></p>
</div>
</div>
<?php loadFooter(); ?>