-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_thread.php
203 lines (182 loc) · 8.13 KB
/
view_thread.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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
require_once("includes/session.php");
require_once("includes/functions.php");
?>
<?php
function style($admin,$username){
if($admin==1){echo "class=\"forumsadmin";}if(logged_in()&&$username==$_SESSION['username']){echo " userspost";}echo "\"";
}
$query="SELECT *
FROM `forum_threads`
WHERE `id`={$_GET['thread']}";
$threadquery=mysqli_query($connection, $query);
confirm_query($threadquery);
$thread=mysqli_fetch_array($threadquery);
$query="SELECT *
FROM `forums`
WHERE `id`={$thread['forumid']}";
$forumquery=mysqli_query($connection, $query);
confirm_query($forumquery);
$forum=mysqli_fetch_array($forumquery);
if(!canView(unserialize($forum['visible']))){
redirect_to("page/".$GLOBALS['forum_page']."?error=".urlencode('You do not have access to that!'));
}
$query="SELECT *
FROM `forum_posts`
WHERE `threadid`={$_GET['thread']}";
$result=mysqli_query($connection, $query);
confirm_query($result);
$num_posts = mysqli_num_rows($result);
$num_pages = ceil($num_posts/10);
if(isset($_GET['pg'])&&intval($_GET['pg'])>=1){
$current_page = intval($_GET['pg']);
}else{
$current_page = 1;
}
$pgOffset = $current_page;
if($current_page <= 1){
$pgOffset = 0;
}else{
$pgOffset = $current_page * 10 - 10;
}
$query="SELECT * FROM `forum_posts` WHERE `threadid`={$_GET['thread']} ORDER BY `date` ASC LIMIT 10 OFFSET ".$pgOffset;
$result_posts=mysqli_query($connection, $query);
$query="UPDATE `forum_threads` SET `views` = `views` + 1 WHERE `id` ={$_GET['thread']}";
$threadquery=mysqli_query($connection, $query);
confirm_query($threadquery);
?>
<?php
$query="SELECT * FROM `pages` WHERE `type` = 'Forum'";
$result_page_prop=mysqli_query( $connection, $query);
$page_properties = mysqli_fetch_array($result_page_prop);
$pgsettings = array(
"title" => $thread['name'],
"pageselection" => "forum",
"nav" => $page_properties['horiz_menu_visible'],
"banner" => $page_properties['banner'],
"slider" => $page_properties['slider'],
"use_google_analytics" => 1,
);
require_once("includes/begin_html.php");
?>
<h1><?php echo $thread['name']; ?></h1>
<?php if(check_permission("Forum","reply_to_thread")&&$thread['locked']==0){?>
<a class="btn green" href="new_topic?forum=<?php echo urlencode($forum['id'])."&&thread=".urlencode($thread['id']); ?>&action=newmessage">Reply</a><br/><br/>
<?php } ?>
<nav>
<div class="forummain nav-wrapper">
<div class="col s12">
<a href="<?php echo $GLOBALS['HOST'].'/page/'.$GLOBALS['forum_page']; ?>" class="breadcrumb"><?php echo $GLOBALS['site_info']['name']; ?> Forums</a>
<a href="view_forum?forum=<?php echo $forum['id']; ?>" class="breadcrumb"><?php echo $forum['name']; ?></a>
<a href="view_thread.php?thread=<?php echo $thread['id']; ?>" class="breadcrumb"><?php echo $thread['name']; ?></a>
</div>
</div>
</nav>
<?php
echo_page($num_pages, $current_page, "view_thread?thread=".$_GET['thread']);
?>
<div class="thread">
<?php
$count=($current_page * 10)-9;
while($forummessage=mysqli_fetch_array($result_posts)){
$user=get_user($forummessage['poster']);
$query="SELECT *
FROM `users_custom_fields`
WHERE `uid`={$user['id']}";
$dataquery=mysqli_query($connection, $query);
confirm_query($dataquery);
$custom_user_data_exists = mysqli_num_rows($dataquery);
$custom_user_data=mysqli_fetch_array($dataquery);
?>
<table width="100%" style="border: 1px solid; margin-bottom: 20px;" cellspacing="1" cellpadding="0">
<tr>
<td rowspan="3" style="width: 20%; height: 100%; border-right: 1px solid; vertical-align: text-top; padding: 5px; position: relative;">
<?php
$query="SELECT * FROM `ranks` WHERE `id` = {$user['rank']}";
$rank_data_result=mysqli_query( $connection, $query);
$rank_data=mysqli_fetch_array($rank_data_result);
?>
<ul>
<li>
<a href="<?php echo $GLOBALS['HOST'].'/profile/'.urlencode($user['username']); ?>"><span style="color: <?php echo $rank_data['color']?>;"><b><?php echo $user['username']; ?></b></span></a>
<?php if($site_info['user_profile_pictures']){ ?>
<br />
<a href="<?php echo $GLOBALS['HOST'].'/profile/'.urlencode($user['username']); ?>"><img src="<?php echo get_user_profile_pic($user['id']); ?>" height="100" width="100"></a>
<?php } ?>
</li>
<li>
<b><?php echo $rank_data['name']; ?></b>
</li>
<li>
Posts: <?php echo number_format($user['forum_post_count']); ?>
</li>
<?php
if($custom_user_data_exists == 1){
if($GLOBALS['site_info']['forum_post_custom_user_data']!=''){
$displayed_data = unserialize($GLOBALS['site_info']['forum_post_custom_user_data']);
}else{
$displayed_data = array();
}
if(!empty($displayed_data)){
foreach ($displayed_data as $field_id) {
$query="SELECT `name`
FROM `custom_field_users_properties`
WHERE `id`={$field_id}";
$fieldquery=mysqli_query($connection, $query);
confirm_query($fieldquery);
if(mysqli_num_rows($fieldquery) == 1){
$custom_user_field=mysqli_fetch_array($fieldquery);
echo '<li>'.$custom_user_field['name'].': '.$custom_user_data[$custom_user_field['name']].'</li>';
}
}
}
}
?>
</ul>
<div style="width: 100%; text-align: right; position:absolute; bottom: 0;">
<?php
if(check_permission("Forum","edit_thread")&&$user['username']==$_SESSION['username']&&($thread['locked']==0)){?><a class="btn blue" style="margin-right: 10px; margin-bottom: 6px;" href="new_topic.php?msg=<?php echo $forummessage['id']; ?>&&forum=<?php echo $forum['id']; ?>&&thread=<?php echo $thread['id']; ?>&&action=editpost">Edit</a>
<?php } ?>
</div>
</td>
<td style="height: 30px; border-bottom: 1px dashed; padding: 5px;">
<p style="float: left;">Posted: <?php echo date("m/d/Y h:i A" ,strtotime($forummessage['date']));?><?php if($forummessage['lasteditdate']!="0000-00-00 00:00:00"){echo ", Last Edit: ".date("m/d/Y h:i A" ,strtotime($forummessage['lasteditdate']));} ?></p><p style="float: right;" align="right"><b># <?php echo $count; ?></b></p>
</td>
</tr>
<tr>
<td style="vertical-align: text-top; padding: 5px; position: relative;">
<?php echo $forummessage['message']; ?>
</td>
</tr>
<tr>
<td style="vertical-align: text-top; padding: 5px; position: relative; padding-bottom: 45px;">
<?php if($user['forum_signature']!=''){ ?>
<div style="width: 75%; margin-left: -38%; left:50%; position:absolute; top: 0; border-top: 2px solid #000000;"></div>
<div style="width: 90%; max-height: 150px; overflow: scroll; margin-left: auto; margin-right: auto;">
<?php echo $user['forum_signature']; ?>
</div>
<?php } ?>
</td>
</tr>
</table>
<?php
$count++;
}
echo_page($num_pages, $current_page, "view_thread?thread=".$_GET['thread']);
?>
</div>
<nav style="margin-top: -20px;">
<div class="forummain nav-wrapper">
<div class="col s12">
<a href="<?php echo $GLOBALS['HOST'].'/page/'.$GLOBALS['forum_page']; ?>" class="breadcrumb"><?php echo $GLOBALS['site_info']['name']; ?> Forums</a>
<a href="view_forum?forum=<?php echo $forum['id']; ?>" class="breadcrumb"><?php echo $forum['name']; ?></a>
<a href="view_thread.php?thread=<?php echo $thread['id']; ?>" class="breadcrumb"><?php echo $thread['name']; ?></a>
</div>
</div>
</nav>
<?php if(check_permission("Forum","reply_to_thread")&&$thread['locked']==0){?>
<br/><a class="btn green" href="new_topic.php?forum=<?php echo urlencode($forum['id'])."&&thread=".urlencode($thread['id']); ?>&&action=newmessage">Reply</a><br><br>
<?php } ?>
<?php
require_once("includes/end_html.php");
?>