-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexpand.php
123 lines (110 loc) · 4.73 KB
/
expand.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
<?php
/*
* This file is part of kusaba.
*
* kusaba is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* kusaba is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* kusaba; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* AJAX thread expansion handler
*
* Returns replies of threads which have been requested through AJAX
*
* @package kusaba
*/
require 'config.php';
/* No need to waste effort if expansion is disabled */
if (!KU_EXPAND) die();
require KU_ROOTDIR . 'inc/functions.php';
require KU_ROOTDIR . 'inc/classes/board-post.class.php';
$board_name = $tc_db->GetOne("SELECT `name` FROM `" . KU_DBPREFIX . "boards` WHERE `name` = " . $tc_db->qstr($_GET['board']) . "");
if ($board_name != '') {
$board_class = new Board($board_name);
if ($board_class->board['locale'] != '') {
changeLocale($board_class->board['locale']);
}
} else {
die('<font color="red">Invalid board.</font>');
}
require KU_ROOTDIR . 'inc/classes/bans.class.php';
$bans_class = new Bans();
if($bans_class->BanCheckSilent(KU_REMOTE_ADDR, $board_class->board, true))
{
do_redirect(KU_BOARDSPATH . '/banned.php');
}
$board_class->InitializeDwoo();
$board_class->dwoo_data->assign('isexpand', true);
$board_class->dwoo_data->assign('board', $board_class->board);
$board_class->dwoo_data->assign('file_path', KU_BOARDSPATH . '/' . $board_class->board['name']);
if (isset($_GET['preview'])) {
require KU_ROOTDIR . 'inc/classes/parse.class.php';
$parse_class = new Parse();
if (isset($_GET['board']) && isset($_GET['parentid']) && isset($_GET['message'])) {
die('<strong>' . _gettext('Post preview') . ':</strong><br /><div style="border: 1px dotted;padding: 8px;background-color: white;">' . $parse_class->ParsePost($_GET['message'], $board_class->board['name'], $board_class->board['type'], $_GET['parentid'], $board_class->board['id']) . '</div>');
}
die('Error');
}
if( isset($_GET['after']) && (int)$_GET['after']!=0 ) {
$refreshq = ' AND `id` > ' . $tc_db->qstr((int)$_GET['after']);
$getnewposts = true;
} else {
$refreshq ='';
$getnewposts = false;
}
$posts = $tc_db->GetAll('SELECT * FROM `'.KU_DBPREFIX.'posts` WHERE `boardid` = ' . $board_class->board['id'] . ' AND `IS_DELETED` = 0 AND `parentid` = '.$tc_db->qstr($_GET['threadid']) . $refreshq . ' ORDER BY `id` ASC');
if( count($posts)==0 ) die();
global $expandjavascript;
$output = '';
$expandjavascript = '';
$numimages = 0;
if ($board_class->board['type'] != 1) {
$embeds = $tc_db->GetAll("SELECT filetype FROM `" . KU_DBPREFIX . "embeds`");
foreach ($embeds as $embed) {
$board_class->board['filetypes'][] .= $embed['filetype'];
}
$board_class->dwoo_data->assign('filetypes', $board_class->board['filetypes']);
}
$pregen_replies_q = $tc_db->GetAll("SELECT * FROM `".KU_DBPREFIX."answers` WHERE `to_boardid` = '" . $board_class->board['id'] . "' AND `to_parentid` = ".$tc_db->qstr($_GET['threadid']));
foreach ($posts as $key=>$post) {
if ($post['file_type'] == 'jpg' || $post['file_type'] == 'gif' || $post['file_type'] == 'webp' || $post['file_type'] == 'png') {
$numimages++;
}
$post['n'] = $key + 2; // First reply has # 2
$posts[$key] = $board_class->BuildPost($post, false, $pregen_replies_q);
$newlastid = $post['id'];
}
$board_class->dwoo_data->assign('numimages', $numimages);
$board_class->dwoo_data->assign('posts', $posts);
$board_class->dwoo_data->assign('getnewposts', $getnewposts);
switch ($board_class->board['type']) {
case 0:
$output = $board_class->dwoo->get(KU_TEMPLATEDIR . '/img_thread.tpl', $board_class->dwoo_data);
break;
case 1:
$output = $board_class->dwoo->get(KU_TEMPLATEDIR . '/txt_thread.tpl', $board_class->dwoo_data);
break;
case 2:
$output = $board_class->dwoo->get(KU_TEMPLATEDIR . '/oek_thread.tpl', $board_class->dwoo_data);
break;
case 3:
$output = $board_class->dwoo->get(KU_TEMPLATEDIR . '/upl_thread.tpl', $board_class->dwoo_data);
break;
default:
die('<font color="red">Invalid board.</font>');
break;
}
if ($expandjavascript != '') {
$output = '<a href="#" onclick="javascript:' . $expandjavascript . 'return false;">' . _gettext('Expand all images') . '</a>' . $output;
}
echo $output;
?>