This repository was archived by the owner on Jul 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy paththread.php
More file actions
executable file
·157 lines (131 loc) · 5.58 KB
/
Copy paththread.php
File metadata and controls
executable file
·157 lines (131 loc) · 5.58 KB
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
<?php
include("inc/include.php");
$q = mysql_query("SELECT `url` FROM `boards`");
$boards = array();
while($l = mysql_fetch_assoc($q))
$boards[] = $l['url'];
$board = mysql_real_escape_string($_GET['board']);
if(empty($board)) $board = 's';
if( !in_array($board, $boards) )
{
header("Location: ". $cfg['htmldir']);
die();
}
$thread = mysql_real_escape_string($_GET['id']);
if( empty($thread) )
{
header("Location: ". $cfg['htmldir']);
die();
}
$q = mysql_query("SELECT * FROM `boards` WHERE `url` = '". $board ."' LIMIT 1");
$i = mysql_fetch_assoc($q);
if($i['worksafe'] == 0 AND $cfg['user']['sfw'] == '1') {
info(T_('The page you are trying to open contains material not appropriate for minors and according to your settings, you don\'t want to see such content.') .'</p><p>'. sprintf( T_('If you still want to continue to this page, you can disable the hiding of NSFW-content by %sclicking here%s.'), '<a href="'. $cfg['htmldir'] .'/scripts/sfw_redirect.php?sfw=false&goto='. urlencode($_SERVER['REQUEST_URI']) .'">', '</a>'), true, false, T_("Access prevented!"));
}
$aq = mysql_query("SELECT `posts`.`board`, `posts`.`subject`, `posts`.`deleted_time`, `boards`.`url` FROM `posts`, `boards` WHERE `boards`.`id` = `posts`.`board` AND `posts`.`id` = '". $thread ."' AND `posts`.`thread` = '0' LIMIT 1");
$a = mysql_fetch_assoc($aq);
if( mysql_num_rows($aq) == 0 OR (!empty($a['deleted_time']) AND $a['deleted_time'] != 0) )
{
// When the thread recycle bin exists, we should change to error 410 if we know that there was a thread.
if(!empty($a['deleted_time']) AND $a['deleted_time'] != 0)
{
header('HTTP/1.0 410 Gone');
header("Location: ". $cfg['htmldir'] ."/410/");
}
else
{
header('HTTP/1.0 404 Not Found');
header("Location: ". $cfg['htmldir'] ."/404/");
}
die();
}
elseif( $a['board'] != $i['id'] )
{
header('HTTP/1.0 301 Moved Permanently');
header('Location: '. $cfg['htmldir'] .'/'. $a['url'] .'/'. $thread .'/');
}
$pagesq = mysql_query("SELECT COUNT(`id`) AS 'count' FROM `posts` WHERE `thread` = '". $thread ."'");
$pages = ceil(mysql_result($pagesq, 0, "count") / $cfg['ppp']);
// Page
if(empty($_GET['page'])) $_GET['page'] = '-1';
$_GET['page'] = substr($_GET['page'], 1);
$page = $_GET['page'];
if(!is_numeric($page) OR $page < 1 OR $page > $pages AND $pages != 0 OR $_SERVER['REQUEST_URI'] == "/". $i['url'] ."/". $thread ."-1/") {
header("Location: ". $cfg['htmldir'] ."/". $i['url'] ."/". $thread ."/");
die();
}
if(!empty($a['subject'])) $title = addslashes($a['subject']) ." - ";
else $title = "";
$title = $title .'/'. $i['url'] .'/'. $thread .'-'. $page .'/ - '. $i['name'] . $cfg['site_title']; // page title
include("inc/header.php"); // Html-headi
echo common_top($i);
echo '
<p><span class="button_wrap">[</span><a href="'. $cfg['htmldir'] .'/'. $board .'/" class="button">'. T_("Return to the board") .'</a><span class="button_wrap">]</span></p>';
$lq = mysql_query("SELECT `posts`.*, `users`.`hide_region` FROM `posts` LEFT JOIN `users` USING (uid) WHERE `posts`.`deleted_time` = '0' AND `posts`.`id` = '". $thread ."' LIMIT 1");
$l = mysql_fetch_assoc($lq);
$l['pages'] = $pages;
if($l['pages'] < 1) $l['pages'] = 1;
if($page > $l['pages']) $page = $l['pages'];
$l['limit_start'] = ($page-1) * $cfg['ppp'];
$l['limit_end'] = $cfg['ppp'];
$l['page'] = $page;
if($l['locked'] == 1) {
echo '
<div class="infobar">'. T_("This thread is locked and you cannot reply to it.") .'</div>';
}
if(in_array($thread, $cfg['user']['hide']))
{
echo '
<div class="infobar">'. T_("You have hidden this thread.") .'</div>';
}
if(!$l['locked'] OR $cfg['user_class'] >= 1 AND $cfg['user_class'] <= 3) {
if($i['worksafe'] == 1) echo '
<div class="infobar">'. T_("Please remember that this board is worksafe.") .'</div>';
echo '
<div class="infobar">'. sprintf(T_("Your message will be sent as a reply to the thread %s"), $thread) .'</div>',
post_form($i, $thread, 0);
}
echo '
<form id="deleteform" method="post" action="'. $cfg['htmldir'] .'/delete/">
<input type="hidden" name="open_thread" value="'. $thread .'" />
<input type="hidden" name="open_board" value="'. $board .'" />
<input type="hidden" name="url" value="'. urlencode($_SERVER['REQUEST_URI']) .'" />
<fieldset>';
print_thread($l, "thread", $i);
echo '
<div id="bottom">
<div id="bottomleft">
<div id="pages">';
if($page != 1) echo '
<a id="prev" class="button" href="'. $cfg['htmldir'] .'/'. $board .'/'. $thread .'-'. ($page-1) .'/">'. T_("Previous") .'</a>';
for($i = 1; $i <= $l['pages']; $i++) {
if($page == $i) echo '
['. $i .']';
else echo '
[<a href="'. $cfg['htmldir'] .'/'. $board .'/'. $thread .'-'. $i .'/">'. $i .'</a>]';
}
if($page < $l['pages']) echo '
<a id="next" class="button" href="'. $cfg['htmldir'] .'/'. $board .'/'. $thread .'-'. ($page+1) .'/">'. T_("Next") .'</a>';
echo '
</div>
<div class="boardnav">
[ <a href="'. $cfg['htmldir'] .'/personal/followed/">'. T_("Followed") .'</a> |
<a href="'. $cfg['htmldir'] .'/personal/mythreads/">'. T_("My threads") .'</a> |
<a href="'. $cfg['htmldir'] .'/personal/repliedthreads/">'. T_("Replied") .'</a> ]
<div style="float: right;">
[ <a href="'. $cfg['htmldir'] .'/">'. T_('Front page') .'</a> |
<a href="'. $cfg['htmldir'] .'/search/">'. T_('Message search') .'</a> |
<a href="'. $cfg['htmldir'] .'/settings/">'. T_("Site personalization") .'</a> ]
</div>
<br />'. boardnav() .'
</div>
</div>
', buttons_bottom(), '
</div>
</fieldset>
</form>';
?>
</div>
<?php
include("inc/footer.php"); // Html-footeri
?>