-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy paththread_view.php
More file actions
120 lines (90 loc) · 3.02 KB
/
Copy paththread_view.php
File metadata and controls
120 lines (90 loc) · 3.02 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
<?php
/**
*
* @module Forum
* @version 0.5.10
* @authors Julian Schuh, Bernd Michna, "Herr Rilke", Dietrich Roland Pehlke (last)
* @license GNU General Public License
* @platform 2.8.x
* @requirements PHP 5.6.x and higher
*
*/
// Include config file
require('../../config.php');
if(isset($_REQUEST['goto'])) $_REQUEST['tid'] = $_REQUEST['goto'];
if(!isset($_REQUEST['tid'])) die("E: 120023");
/**
* prüfen, ob wir auf einen einzelnes posting weiterleiten sollen
* wenn wir das an dieser stelle prüfen, müssen wir $_pages nicht
* für jeden link ausrechnen. sehr performant :)
*/
if (isset($_GET['goto']))
{
$_post_id = intval($_GET['goto']);
$sql = "SELECT f.title as forum,
p.postid, p.threadid, p.title, p.text, p.page_id, p.section_id
FROM ".TABLE_PREFIX."mod_forum_post p
JOIN ".TABLE_PREFIX."mod_forum_thread t USING(threadid)
JOIN ".TABLE_PREFIX."mod_forum_forum f ON (t.forumid = f.forumid)
WHERE p.postid = ".$_post_id."
LIMIT 1";
$res = $database->query($sql);
if( isset($res) AND $res->numRows() > 0)
{
$f = $res->fetchRow( MYSQL_ASSOC );
//anzahl Datensätze zählen, die vor unserem liegen, brauch wir für den Link:
$sql = 'SELECT COUNT(*) as total FROM '.TABLE_PREFIX.'mod_forum_post WHERE threadid = ' . $f['threadid'] . ' AND postid <= ' . $f['postid'];
$res2 = $database->query($sql);
$_count = $res2->fetchRow();
$section_id = $f['section_id'];
include_once WB_PATH . '/modules/forum/config.php';
$_pages = ceil($_count['total'] / SHOWTHREAD_PERPAGE);
// Location Ziel
$owd_link = WB_URL.'/modules/forum/thread_view.php?' .
'sid='.$f['section_id'].
'&pid='.$f['page_id'].
'&tid='.$f['threadid'].
'&page='.$_pages .
'#post'. $f['postid'];
//die($owd_link);
unset($_GET['goto']);
die(header('Location: ' . $owd_link));
}//isset($res)
}
// Validation:
$thread_query = $database->query("SELECT * FROM " . TABLE_PREFIX . "mod_forum_thread WHERE threadid = '" . intval($_REQUEST['tid']) . "'");
$thread = $thread_query->fetchRow( MYSQL_ASSOC );
if(!$thread)
{
die(header('Location: ' . WB_URL . PAGES_DIRECTORY));
}
$forum_query = $database->query("SELECT * FROM " . TABLE_PREFIX . "mod_forum_forum WHERE forumid = '" . intval($thread['forumid']) . "'");
$forum = $forum_query->fetchRow( MYSQL_ASSOC );
if(!$forum)
{
die(header('Location: ' . WB_URL . PAGES_DIRECTORY));
}
else
{
$section_id = $forum['section_id'];
$page_id = $forum['page_id'];
define('SECTION_ID', $section_id);
}
require_once(WB_PATH . '/modules/forum/backend.php');
$query_page = $database->query("
SELECT * FROM ".TABLE_PREFIX."pages AS p
INNER JOIN ".TABLE_PREFIX."sections AS s USING(page_id)
WHERE p.page_id = '$page_id' AND section_id = '$section_id'
");
if(0 == $query_page->numRows())
{
exit(header('Location: ' . WB_URL . PAGES_DIRECTORY));
}
else
{
$page = $query_page->fetchRow( MYSQL_ASSOC );
define('FORUM_DISPLAY_CONTENT', 'view_thread');
define('PAGE_CONTENT', WB_PATH . '/modules/forum/content.php');
require(WB_PATH . '/index.php');
}
?>