-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathredirect.php
183 lines (176 loc) · 5.97 KB
/
redirect.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
<?php
# **************************************************************************#
# MolyX2
# ------------------------------------------------------
# @copyright (c) 2009-2010 MolyX Group..
# @official forum http://molyx.com
# @license http://opensource.org/licenses/gpl-2.0.php GNU Public License 2.0
#
# $Id$
# **************************************************************************#
define('THIS_SCRIPT', 'redirect');
require_once('./global.php');
class redirect
{
var $posthash = '';
var $thread = array();
var $forum = array();
var $page = 0;
var $maxposts = 10;
var $moderator = array();
var $cached_users = array();
var $postcount = 0;
var $already_replied = 0;
var $canview_hideattach = 0;
var $canview_hidecontent = 0;
function show()
{
global $forums, $DB, $_INPUT, $bbuserinfo, $bboptions;
$forums->func->load_lang('showthread');
$forums->func->load_lang('post');
$_INPUT['t'] = intval($_INPUT['t']);
if ($_INPUT['t'] < 1)
{
if ($_INPUT['goto'] == 'findpost')
{
$pid = intval($_INPUT['p']);
if ($pid > 0)
{
$thread = $DB->query_first("SELECT threadid FROM " . TABLE_PREFIX . "post WHERE pid = " . intval($_INPUT['p']));
if ($thread)
{
$_INPUT['t'] = $thread['threadid'];
}
else
{
$forums->func->standard_error("errorthreadlink");
}
}
else
{
$forums->func->standard_error("errorthreadlink");
}
}
else
{
$forums->func->standard_error("errorthreadlink");
}
}
$this->thread = $DB->query_first("SELECT * FROM " . TABLE_PREFIX . "thread WHERE tid='" . $_INPUT['t'] . "'");
$this->forum = $forums->forum->single_forum($this->thread['forumid']);
if (!$this->forum['id'] OR !$this->thread['tid'])
{
$forums->func->standard_error("erroraddress");
}
require_once(ROOT_PATH . 'includes/xfunctions_hide.php');
$this->hidefunc = new hidefunc();
$forums->forum->check_permissions($this->forum['id'], 1, 'thread');
if (isset($_INPUT['goto']))
{
if ($_INPUT['goto'] == 'new')
{
if ($this->thread = $DB->query_first("SELECT tid FROM " . TABLE_PREFIX . "thread WHERE forumid='" . $this->forum['id'] . "' AND visible=1 AND open != 2 AND lastpost > '" . $this->thread['lastpost'] . "' ORDER BY lastpost LIMIT 0, 1"))
{
$_INPUT['t'] = $this->thread['tid'];
require (ROOT_PATH . 'showthread.php');
exit;
}
else
{
$forums->func->standard_error("nonewthread");
}
}
else if ($_INPUT['goto'] == 'old')
{
if ($this->thread = $DB->query_first("SELECT tid FROM " . TABLE_PREFIX . "thread WHERE forumid='" . $this->forum['id'] . "' AND visible=1 AND open != 2 AND lastpost < '" . $this->thread['lastpost'] . "' ORDER BY lastpost DESC LIMIT 0, 1"))
{
$_INPUT['t'] = $this->thread['tid'];
require (ROOT_PATH . 'showthread.php');
exit;
}
else
{
$forums->func->standard_error("nooldthread");
}
}
else if ($_INPUT['goto'] == 'lastpost')
{
$this->return_lastpost();
}
else if ($_INPUT['goto'] == 'newpost')
{
$page = 0;
$pid = "";
$last_time = $threadread[$this->thread['tid']];
$last_time = $last_time ? $last_time : $_INPUT['lastvisit'];
if ($post = $DB->query_first("SELECT pid, dateline FROM " . TABLE_PREFIX . "post WHERE threadid='" . $this->thread['tid'] . "' AND moderate != 1 AND dateline > '" . $last_time . "' ORDER BY pid LIMIT 0, 1"))
{
$pid = "#pid" . $post['pid'];
$cpost = $DB->query_first("SELECT COUNT(*) as post FROM " . TABLE_PREFIX . "post WHERE threadid='" . $this->thread['tid'] . "' AND moderate != 1 AND pid <= '" . $post['pid'] . "' LIMIT 0, 1");
if ((($cpost['post']) % $this->maxposts) == 0)
{
$pages = ($cpost['post']) / $this->maxposts;
}
else
{
$pages = ceil(($cpost['post']) / $this->maxposts);
}
$page = ($pages - 1) * $this->maxposts;
$bboptions['rewritestatus'] ? $forums->func->standard_redirect("thread-" . $this->thread['tid'] . "-" . $page . ".html" . $pid) : $forums->func->standard_redirect("showthread.php{$forums->sessionurl}t=" . $this->thread['tid'] . "&pp=$page" . $pid);
}
else
{
$this->return_lastpost();
}
}
else if ($_INPUT['goto'] == 'findpost')
{
$pid = intval($_INPUT['p']);
if ($pid > 0)
{
$cpost = $DB->query_first("SELECT COUNT(*) as post FROM " . TABLE_PREFIX . "post WHERE threadid='" . $this->thread['tid'] . "' AND pid <= '" . $pid . "' LIMIT 0, 1");
if ((($cpost['post']) % $this->maxposts) == 0)
{
$pages = ($cpost['post']) / $this->maxposts;
}
else
{
$number = (($cpost['post']) / $this->maxposts);
$pages = ceil($number);
}
$page = ($pages - 1) * $this->maxposts;
$bboptions['rewritestatus'] ? $forums->func->standard_redirect("thread-" . $this->thread['tid'] . "-" . $page . ".html" . "?p=" . $pid . "#pid" . $pid) : $forums->func->standard_redirect("showthread.php{$forums->sessionurl}t=" . $this->thread['tid'] . "&p=$pid&pp=" . $page . "#pid" . $pid);
}
else
{
$this->return_lastpost();
}
}
}
require (ROOT_PATH . 'showthread.php');
exit;
}
function return_lastpost()
{
global $forums, $DB , $bboptions;
$page = 0;
if ($this->thread['post'])
{
if ((($this->thread['post'] + 1) % $this->maxposts) == 0)
{
$pages = ($this->thread['post'] + 1) / $this->maxposts;
}
else
{
$number = (($this->thread['post'] + 1) / $this->maxposts);
$pages = ceil($number);
}
$page = ($pages - 1) * $this->maxposts;
}
$post = $DB->query_first("SELECT pid FROM " . TABLE_PREFIX . "post WHERE threadid='" . $this->thread['tid'] . "' AND moderate != 1 ORDER BY pid DESC LIMIT 0, 1");
$bboptions['rewritestatus'] ? $forums->func->standard_redirect("thread-" . $this->thread['tid'] . "-" . $page . ".html" . "#pid" . $post['pid']) :$forums->func->standard_redirect("showthread.php{$forums->sessionurl}t=" . $this->thread['tid'] . "&pp=" . $page . "#pid" . $post['pid']);
}
}
$output = new redirect();
$output->show();
?>