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:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
|
if($board['closed']==0) eval ("\$newthread = \"".$tpl->get("board_newthread")."\";");
$addreply_link="threadid=$threadid";
if($thread['closed']!=0) eval ("\$addreply = \"".$tpl->get("thread_closed")."\";");
elseif($board['closed']==0) eval ("\$addreply = \"".$tpl->get("thread_addreply")."\";");
if( $activ_similar_threads_view )
{
$bad_words_list = explode("\n",$badsearchwords);
while(list($key,$val) = @each($bad_words_list) ) $bad_words_array[trim($val)] = true;
$topic_words = explode(" ",$thread['topic']);
for($i=0; $i < count($topic_words); $i++)
{
if($bad_words_array[$topic_words[$i]])
{
$topic_words[$i] = "";
}
}
$topic_words = implode(" ",$topic_words);
$result = $db->query("SELECT threadid FROM bb".$n."_threads WHERE threadid != " . $thread['threadid'] . " AND MATCH (topic) AGAINST ('". addslashes($topic_words) ."') ORDER BY lastposttime DESC");
while( $row = $db->fetch_array($result) )
{
$similar_topic_row[] = $row;
}
if( count($similar_topic_row) > 0 )
{
$similar_topic_viewbit = "";
for($i = 0; $i < count($similar_topic_row); $i++)
{
$sql = "SELECT t.*, b.boardid, b.title, b.allowicons, b.hotthread_reply, b.hotthread_view, i.iconpath, i.icontitle, p.boardpermission, p.startpermission, p.replypermission
FROM bb".$n."_boards b, bb".$n."_permissions p, bb".$n."_threads t
LEFT JOIN bb".$n."_icons i USING(iconid)
WHERE t.threadid = " . $similar_topic_row[$i]['threadid'] . "
AND t.boardid = b.boardid
AND t.closed != 3
AND b.boardid = p.boardid
AND p.groupid = " . $wbbuserdata['groupid'] . "
$visible
GROUP BY t.threadid";
$result = $db->query($sql);
while( $similar_topic = $db->fetch_array($result) )
{
if( empty($similar_topic['boardpermission']) || empty($similar_topic['startpermission']) || empty($similar_topic['replypermission']) )
{
continue;
}
$topic_name = $similar_topic['topic'];
$topic_id = $similar_topic['threadid'];
$topic_prefix = $similar_topic['prefix'];
$topic_iconid = $similar_topic['iconid'];
$topic_starter_id = $similar_topic['starterid'];
$topic_starter = $similar_topic['starter'];
$topic_lastposttime = $similar_topic['lastposttime'];
$topic_lastpost_date = formatdate($dateformat,$similar_topic['lastposttime'],1);
$topic_lastpost_time = formatdate($timeformat,$similar_topic['lastposttime']);
$topic_lastposter_id = $similar_topic['lastposterid'];
$topic_lastposter = $similar_topic['lastposter'];
$topic_reply_count = $similar_topic['replycount'];
$topic_closed = $similar_topic['closed'];
$topic_views = $similar_topic['views'];
$topic_important = $similar_topic['important'];
$topic_visible = $similar_topic['visible'];
$topic_voted = $similar_topic['voted'];
$topic_vote_points = $similar_topic['votepoints'];
$topic_poll_id = $similar_topic['pollid'];
$topic_board_id = $similar_topic['boardid'];
$topic_board_name = $similar_topic['title'];
$topic_board_allow_icon = $similar_topic['allowicons'];
$topic_board_hotthread_reply = $similar_topic['hotthread_reply'];
$topic_board_hotthread_view = $similar_topic['hotthread_view'];
$topic_icon_path = $similar_topic['iconpath'];
$topic_icon_title = $similar_topic['icontitle'];
$topic_icon = ($topic_iconid && $topic_board_allow_icon) ? makeimgtag($topic_icon_path,$topic_icon_title) : '';
if( $topic_voted )
{
$topic_avarage=number_format($topic_vote_points/$topic_voted,2);
eval ("\$topic_threadrating = \"" . $tpl->get("similar_topic_threadbit_rating") . "\";");
$topic_threadrating=str_repeat($topic_threadrating, round($topic_avarage));
}
else $topic_threadrating=" ";
$topic_board_hotthread_reply = ( $topic_board_hotthread_reply == 0 ) ? $default_hotthread_reply : $topic_board_hotthread_reply;
$topic_board_hotthread_view = ( $topic_board_hotthread_view == 0 ) ? $default_hotthread_view : $topic_board_hotthread_view;
if( $topic_important == 2 ) $topic_folder_icon="announce";
else $topic_folder_icon=ifelse($wbbuserdata['lastvisit']<$topic_lastposttime && $threadvisit[$topic_id]<$topic_lastposttime,"new").ifelse($topic_reply_count >= $topic_board_hotthread_reply || $topic_views >= $topic_board_hotthread_view,"hot").ifelse($topic_closed!=0,"lock")."folder";
if( $topic_important == 2 ) eval("\$topic_prefix = \"" . $tpl->get("similar_topic_announce") . "\";");
else if( $topic_important == 1 ) eval("\$topic_prefix = \"" . $tpl->get("similar_topic_important") . "\";");
else if( $topic_poll_id != 0 ) eval("\$topic_prefix = \"" . $tpl->get("similar_topic_poll") . "\";");
eval("\$topic_starter = \"" . $tpl->get("similar_topic_starter") . "\";");
if( $topic_reply_count + 1 > $postsperpage && $showmultipages != 0 )
{
$topic_multipage = "";
$topic_multipages = "";
$similar_multipages_lastpage = "";
$topic_xpages=ceil(($topic_reply_count + 1) / $postsperpage);
if( $topic_xpages > $showmultipages )
{
eval ("\$similar_topic_multipages_lastpage = \"" . $tpl->get("similar_topic_multipages_lastpage") . "\";");
$topic_xpages=$showmultipages;
}
for($i = 1; $i <= $topic_xpages; $i++)
{
$topic_multipage .= " ".makehreftag("thread.php?threadid=$topic_id&page=$i&sid=$session[hash]",$i);
}
eval ("\$topic_multipages = \"" . $tpl->get("similar_topic_multipages") . "\";");
}
eval("\$similar_topic_viewbit .= \"" . $tpl->get("similar_topic_threadbit") . "\";");
}
}
if( !empty($similar_topic_viewbit) )
{
eval("\$similar_topic = \"" . $tpl->get("similar_topic") . "\";");
}
}
}
if(strlen($thread['topic'])>60) $thread['topic']=parse::textwrap($thread['topic'],60);
/** Who-read-this-thread (c) Mr Hatch / rellek **/
if($wbbuserdata['userid']==0) $watchlist="";
else eval ("\$watchlist .= \"".$tpl->get("whoreadthisthreadlink")."\";");
$readcount=$db->query_first("SELECT COUNT(*) FROM bb".$n."_threads_users WHERE threadid='$threadid' AND userid='$wbbuserdata[userid]'");
if($readcount[0]==0){
$db->query("INSERT INTO bb".$n."_threads_users (threadid,userid,readtime,timesread) VALUES ('$threadid','$wbbuserdata[userid]','".time()."','1')");
}
else{
$db->query("UPDATE bb".$n."_threads_users SET readtime='".time()."',timesread=timesread+1 WHERE threadid='$threadid' AND userid='$wbbuserdata[userid]'");
}
/** Who-read-this-thread (c) Mr Hatch / rellek **/
require "quickreply.php";
eval("\$tpl->output(\"".$tpl->get("thread")."\");");
?> |