1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category modules
|
5
|
* @package news
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8
|
* @link http://www.websitebaker2.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.x
|
11
|
* @requirements PHP 5.2.2 and higher
|
12
|
* @version $Id: view.php 1895 2013-03-20 01:14:23Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/news/view.php $
|
14
|
* @lastmodified $Date: 2013-03-20 02:14:23 +0100 (Wed, 20 Mar 2013) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
/* -------------------------------------------------------- */
|
19
|
// Must include code to stop this file being accessed directly
|
20
|
if(!defined('WB_URL')) {
|
21
|
require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
|
22
|
throw new IllegalFileException();
|
23
|
}
|
24
|
/* -------------------------------------------------------- */
|
25
|
global $post_id, $post_section,$TEXT,$MESSAGE;
|
26
|
|
27
|
// load module language file
|
28
|
$lang = (dirname(__FILE__)) . '/languages/' . LANGUAGE . '.php';
|
29
|
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang );
|
30
|
|
31
|
//overwrite php.ini on Apache servers for valid SESSION ID Separator
|
32
|
if(function_exists('ini_set')) {
|
33
|
ini_set('arg_separator.output', '&');
|
34
|
}
|
35
|
|
36
|
// Check if there is a start point defined
|
37
|
$position = ( isset($_GET['p']) ? intval($_GET['p']) : 0);
|
38
|
// Get user's username, display name, email, and id - needed for insertion into post info
|
39
|
$users = array();
|
40
|
$sql = 'SELECT `user_id`,`username`,`display_name`,`email` FROM `'.TABLE_PREFIX.'users`';
|
41
|
if( ($resUsers = $database->query($sql)) ) {
|
42
|
while( $recUser = $resUsers->fetchRow() ) {
|
43
|
$users[$recUser['user_id']] = $recUser;
|
44
|
}
|
45
|
}
|
46
|
// Get groups (title, if they are active, and their image [if one has been uploaded])
|
47
|
if (isset($groups))
|
48
|
{
|
49
|
unset($groups);
|
50
|
}
|
51
|
|
52
|
$groups[0]['title'] = '';
|
53
|
$groups[0]['active'] = true;
|
54
|
$groups[0]['image'] = '';
|
55
|
|
56
|
$query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
|
57
|
if($query_users->numRows() > 0)
|
58
|
{
|
59
|
|
60
|
while( false != ($group = $query_users->fetchRow()) )
|
61
|
{
|
62
|
// Insert user info into users array
|
63
|
$group_id = $group['group_id'];
|
64
|
$groups[$group_id]['title'] = ($group['title']);
|
65
|
$groups[$group_id]['active'] = $group['active'];
|
66
|
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
|
67
|
$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
|
68
|
} else {
|
69
|
$groups[$group_id]['image'] = '';
|
70
|
}
|
71
|
}
|
72
|
}
|
73
|
|
74
|
// Check if we should show the main page or a post itself
|
75
|
// if(!defined('POST_ID') OR !is_numeric(POST_ID))
|
76
|
if(!isset($post_id) || !is_numeric($post_id))
|
77
|
{
|
78
|
|
79
|
// Check if we should only list posts from a certain group
|
80
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
81
|
$query_extra = 'AND `group_id`='.(int)$_GET['g'].' ';
|
82
|
} else {
|
83
|
$query_extra = '';
|
84
|
}
|
85
|
|
86
|
// Check if we should only list posts from a certain group
|
87
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
88
|
$query_extra = 'AND `group_id`='.(int)$_GET['g'].' ';
|
89
|
} else {
|
90
|
$query_extra = '';
|
91
|
}
|
92
|
|
93
|
// Get settings
|
94
|
$setting_header = $setting_post_loop = $setting_footer = $setting_posts_per_page = '';
|
95
|
$sql = 'SELECT `header`, `post_loop`, `footer`, `posts_per_page` ';
|
96
|
$sql .= 'FROM `'.TABLE_PREFIX.'mod_news_settings` ';
|
97
|
$sql .= 'WHERE `section_id`='.(int)$section_id;
|
98
|
if( ($resSettings = $database->query($sql)) ){
|
99
|
if( ($recSettings = $resSettings->fetchRow()) ) {
|
100
|
foreach($recSettings as $key=>$val){
|
101
|
${'setting_'.$key} = $val;
|
102
|
}
|
103
|
}
|
104
|
}
|
105
|
$t = time();
|
106
|
// Get total number of posts
|
107
|
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'mod_news_posts` ';
|
108
|
$sql .= 'WHERE `section_id`='.(int)$section_id.' AND `active`=1 ';
|
109
|
$sql .= 'AND `title`!=\'\' '.$query_extra;
|
110
|
$sql .= 'AND (`published_when`=0 OR `published_when`<='.$t.') ';
|
111
|
$sql .= 'AND (`published_until`=0 OR `published_until`>='.$t.') ';
|
112
|
$total_num = intval($database->get_one($sql));
|
113
|
// Work-out if we need to add limit code to sql
|
114
|
if($setting_posts_per_page != 0) {
|
115
|
$limit_sql = " LIMIT $position, $setting_posts_per_page";
|
116
|
} else {
|
117
|
$limit_sql = "";
|
118
|
}
|
119
|
|
120
|
// Query posts (for this page)
|
121
|
$query_posts = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts
|
122
|
WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra
|
123
|
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)
|
124
|
ORDER BY position DESC".$limit_sql);
|
125
|
$num_posts = $query_posts->numRows();
|
126
|
|
127
|
// Create previous and next links
|
128
|
if($setting_posts_per_page != 0)
|
129
|
{
|
130
|
if($position > 0)
|
131
|
{
|
132
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
133
|
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< ';
|
134
|
} else {
|
135
|
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< ';
|
136
|
}
|
137
|
$pl_append = '</a>';
|
138
|
$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append;
|
139
|
$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append;
|
140
|
} else {
|
141
|
$previous_link = '';
|
142
|
$previous_page_link = '';
|
143
|
}
|
144
|
if($position + $setting_posts_per_page >= $total_num) {
|
145
|
$next_link = '';
|
146
|
$next_page_link = '';
|
147
|
} else {
|
148
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
149
|
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> ';
|
150
|
} else {
|
151
|
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> ';
|
152
|
}
|
153
|
$nl_append = ' >></a>';
|
154
|
$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append;
|
155
|
$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append;
|
156
|
}
|
157
|
if($position+$setting_posts_per_page > $total_num) {
|
158
|
$num_of = $position+$num_posts;
|
159
|
} else {
|
160
|
$num_of = $position+$setting_posts_per_page;
|
161
|
}
|
162
|
|
163
|
$out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num;
|
164
|
$of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num;
|
165
|
$display_previous_next_links = '';
|
166
|
} else {
|
167
|
$display_previous_next_links = 'none';
|
168
|
}
|
169
|
|
170
|
if ($num_posts === 0) {
|
171
|
$setting_header = '';
|
172
|
$setting_post_loop = '';
|
173
|
$setting_footer = '';
|
174
|
$setting_posts_per_page = '';
|
175
|
}
|
176
|
|
177
|
// Print header
|
178
|
if($display_previous_next_links == 'none') {
|
179
|
print str_replace( array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'),
|
180
|
array('','','','','','', $display_previous_next_links), $setting_header);
|
181
|
} else {
|
182
|
print str_replace( array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'),
|
183
|
array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header);
|
184
|
}
|
185
|
if($num_posts > 0)
|
186
|
{
|
187
|
if($query_extra != '')
|
188
|
{
|
189
|
?>
|
190
|
<div class="selected-group-title">
|
191
|
<?php print '<a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?>
|
192
|
</div>
|
193
|
<?php
|
194
|
}
|
195
|
while( false != ($post = $query_posts->fetchRow()) )
|
196
|
{
|
197
|
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
|
198
|
{ // Make sure parent group is active
|
199
|
$uid = $post['posted_by']; // User who last modified the post
|
200
|
// Workout date and time of last modified post
|
201
|
if ($post['published_when'] === '0'){ $post['published_when'] = time();}
|
202
|
if ($post['published_when'] > $post['posted_when']) {
|
203
|
$post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
|
204
|
$post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
|
205
|
} else {
|
206
|
$post_date = date(DATE_FORMAT, $post['posted_when']+TIMEZONE);
|
207
|
$post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
|
208
|
}
|
209
|
|
210
|
$publ_date = date(DATE_FORMAT,$post['published_when']+TIMEZONE);
|
211
|
$publ_time = date(TIME_FORMAT,$post['published_when']+TIMEZONE);
|
212
|
|
213
|
// Work-out the post link
|
214
|
$post_link = page_link($post['link']);
|
215
|
$post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
|
216
|
$create_date = date(DATE_FORMAT, $post['created_when']+TIMEZONE);
|
217
|
$create_time = date(TIME_FORMAT, $post['created_when']+TIMEZONE);
|
218
|
|
219
|
if(isset($_GET['p']) AND $position > 0) {
|
220
|
$post_link .= '?p='.$position;
|
221
|
}
|
222
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
223
|
if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; } {
|
224
|
$post_link .= 'g='.$_GET['g'];
|
225
|
}
|
226
|
}
|
227
|
|
228
|
// Get group id, title, and image
|
229
|
$group_id = $post['group_id'];
|
230
|
$group_title = $groups[$group_id]['title'];
|
231
|
$group_image = $groups[$group_id]['image'];
|
232
|
$display_image = ($group_image == '') ? "none" : "inherit";
|
233
|
$display_group = ($group_id == 0) ? 'none' : 'inherit';
|
234
|
|
235
|
if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
|
236
|
|
237
|
// Replace [wblink--PAGE_ID--] with real link
|
238
|
$short = ($post['content_short']);
|
239
|
// Replace vars with values
|
240
|
$post_long_len = strlen($post['content_long']);
|
241
|
$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[LINK]', '[MODI_DATE]', '[MODI_TIME]', '[CREATED_DATE]', '[CREATED_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]', '[TEXT_READ_MORE]','[SHOW_READ_MORE]');
|
242
|
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '')
|
243
|
{
|
244
|
if($post_long_len < 9) {
|
245
|
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;', $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], '', 'hidden');
|
246
|
} else {
|
247
|
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], $MOD_NEWS['TEXT_READ_MORE'], 'visible');
|
248
|
}
|
249
|
} else {
|
250
|
if($post_long_len < 9) {
|
251
|
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;', $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, '', '', '', '', '','hidden');
|
252
|
} else {
|
253
|
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, '', '', '', '', $MOD_NEWS['TEXT_READ_MORE'],'visible');
|
254
|
}
|
255
|
}
|
256
|
print str_replace($vars, $values, $setting_post_loop);
|
257
|
}
|
258
|
}
|
259
|
}
|
260
|
// Print footer
|
261
|
if($display_previous_next_links == 'none') {
|
262
|
print str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_footer);
|
263
|
} else {
|
264
|
print str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_footer);
|
265
|
}
|
266
|
|
267
|
}
|
268
|
//elseif(defined('POST_ID') AND is_numeric(POST_ID))
|
269
|
elseif(isset($post_id) && is_numeric($post_id))
|
270
|
{
|
271
|
// print '<h2>'.POST_ID.'/'.PAGE_ID.'/'.POST_SECTION.'</h2>';
|
272
|
// if(defined('POST_SECTION') AND POST_SECTION == $section_id)
|
273
|
if(isset($post_section) && ($post_section == $section_id))
|
274
|
{
|
275
|
// Get settings
|
276
|
$setting_post_header = $setting_post_footer = $setting_comments_header
|
277
|
= $setting_comments_loop = $setting_comments_footer = '';
|
278
|
$sql = 'SELECT `post_header`, `post_footer`, `comments_header`, `comments_loop`, `comments_footer` ';
|
279
|
$sql .= 'FROM `'.TABLE_PREFIX.'mod_news_settings` ';
|
280
|
$sql .= 'WHERE `section_id`='.(int)$section_id;
|
281
|
if( ($resSettings = $database->query($sql)) ){
|
282
|
if( ($recSettings = $resSettings->fetchRow()) ) {
|
283
|
foreach($recSettings as $key=>$val){
|
284
|
${'setting_'.$key} = $val;
|
285
|
}
|
286
|
}
|
287
|
}
|
288
|
// Get page info
|
289
|
$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'");
|
290
|
if($query_page->numRows() > 0) {
|
291
|
$page = $query_page->fetchRow();
|
292
|
$page_link = page_link($page['link']);
|
293
|
if(isset($_GET['p']) AND $position > 0) {
|
294
|
$page_link .= '?p='.$_GET['p'];
|
295
|
}
|
296
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
297
|
if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; }
|
298
|
$page_link .= 'g='.$_GET['g'];
|
299
|
}
|
300
|
} else {
|
301
|
exit($MESSAGE['PAGES_NOT_FOUND']);
|
302
|
}
|
303
|
|
304
|
// Get post info
|
305
|
$t = time();
|
306
|
$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts
|
307
|
WHERE post_id = '".$post_id."' AND active = '1'
|
308
|
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)");
|
309
|
|
310
|
if($query_post->numRows() > 0)
|
311
|
{
|
312
|
$post = $query_post->fetchRow();
|
313
|
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
|
314
|
{ // Make sure parent group is active
|
315
|
$uid = $post['posted_by']; // User who last modified the post
|
316
|
// Workout date and time of last modified post
|
317
|
if ($post['published_when'] === '0'){ $post['published_when'] = time();}
|
318
|
if ($post['published_when'] > $post['posted_when']) {
|
319
|
$post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
|
320
|
$post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
|
321
|
} else {
|
322
|
$post_date = date(DATE_FORMAT, $post['posted_when']+TIMEZONE);
|
323
|
$post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
|
324
|
}
|
325
|
|
326
|
$publ_date = date(DATE_FORMAT,$post['published_when']+TIMEZONE);
|
327
|
$publ_time = date(TIME_FORMAT,$post['published_when']+TIMEZONE);
|
328
|
|
329
|
// Work-out the post link
|
330
|
$post_link = page_link($post['link']);
|
331
|
|
332
|
$post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
|
333
|
$create_date = date(DATE_FORMAT, $post['created_when']+TIMEZONE);
|
334
|
$create_time = date(TIME_FORMAT, $post['created_when']+TIMEZONE);
|
335
|
// Get group id, title, and image
|
336
|
$group_id = $post['group_id'];
|
337
|
$group_title = $groups[$group_id]['title'];
|
338
|
$group_image = $groups[$group_id]['image'];
|
339
|
$display_image = ($group_image == '') ? "none" : "inherit";
|
340
|
$display_group = ($group_id == 0) ? 'none' : 'inherit';
|
341
|
|
342
|
if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
|
343
|
|
344
|
$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[BACK]', '[TEXT_BACK]', '[TEXT_LAST_CHANGED]', '[MODI_DATE]', '[TEXT_AT]', '[MODI_TIME]', '[CREATED_DATE]', '[CREATED_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[TEXT_POSTED_BY]', '[TEXT_ON]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]');
|
345
|
$post_short=$post['content_short'];
|
346
|
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
|
347
|
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $post_short, $page_link, $MOD_NEWS['TEXT_BACK'], $MOD_NEWS['TEXT_LAST_CHANGED'],$post_date, $MOD_NEWS['TEXT_AT'], $post_time, $create_date, $create_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email']);
|
348
|
} else {
|
349
|
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $post_short, $page_link, $MOD_NEWS['TEXT_BACK'], $MOD_NEWS['TEXT_LAST_CHANGED'], $post_date, $MOD_NEWS['TEXT_AT'], $post_time, $create_date, $create_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], '', '', '', '');
|
350
|
}
|
351
|
// $post_long = ($post['content_long']);
|
352
|
$post_long = ($post['content_long'] != '') ? $post['content_long'] : $post['content_short'];
|
353
|
}
|
354
|
} else {
|
355
|
$wb->print_error($MESSAGE['FRONTEND_SORRY_NO_ACTIVE_SECTIONS'], 'view.php', false);
|
356
|
}
|
357
|
|
358
|
// Print post header
|
359
|
print str_replace($vars, $values, $setting_post_header);
|
360
|
// Print long
|
361
|
print $post_long;
|
362
|
|
363
|
// Print post footer
|
364
|
print str_replace($vars, $values, $setting_post_footer);
|
365
|
|
366
|
// Show comments section if we have to
|
367
|
if(($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true) OR $post['commenting'] == 'public')
|
368
|
{
|
369
|
// Print comments header
|
370
|
$vars = array('[ADD_COMMENT_URL]','[TEXT_COMMENTS]');
|
371
|
// $pid = $admin->getIDKEY(POST_ID);
|
372
|
$values = array(WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&section_id='.$section_id, $MOD_NEWS['TEXT_COMMENTS']);
|
373
|
print str_replace($vars, $values, $setting_comments_header);
|
374
|
|
375
|
// Query for comments
|
376
|
$query_comments = $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".$post_id."' ORDER BY commented_when ASC");
|
377
|
if($query_comments->numRows() > 0)
|
378
|
{
|
379
|
while( false != ($comment = $query_comments->fetchRow()) )
|
380
|
{
|
381
|
// Display Comments without slashes, but with new-line characters
|
382
|
$comment['comment'] = nl2br($wb->strip_slashes($comment['comment']));
|
383
|
$comment['title'] = $wb->strip_slashes($comment['title']);
|
384
|
// Print comments loop
|
385
|
$commented_date = date(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
|
386
|
$commented_time = date(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
|
387
|
$uid = $comment['commented_by'];
|
388
|
$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
|
389
|
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
|
390
|
$values = array(($comment['title']), ($comment['comment']), $MOD_NEWS['TEXT_ON'], $commented_date, $MOD_NEWS['TEXT_AT'], $commented_time, $MOD_NEWS['TEXT_BY'], $uid, ($users[$uid]['username']), ($users[$uid]['display_name']), ($users[$uid]['email']));
|
391
|
} else {
|
392
|
$values = array(($comment['title']), ($comment['comment']), $MOD_NEWS['TEXT_ON'], $commented_date, $MOD_NEWS['TEXT_AT'], $commented_time, $MOD_NEWS['TEXT_BY'], '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], '');
|
393
|
}
|
394
|
print str_replace($vars, $values, $setting_comments_loop);
|
395
|
}
|
396
|
} else {
|
397
|
// Say no comments found
|
398
|
$content = '';
|
399
|
$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
|
400
|
$values = array( '', $MOD_NEWS['NO_COMMENT_FOUND'], '', '', '', '', '', '', '', '');
|
401
|
print str_replace($vars, $values, $setting_comments_loop);
|
402
|
}
|
403
|
|
404
|
// Print comments footer
|
405
|
$vars = array('[ADD_COMMENT_URL]','[TEXT_ADD_COMMENT]');
|
406
|
$values = array(WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&section_id='.$section_id, $MOD_NEWS['TEXT_ADD_COMMENT']);
|
407
|
print str_replace($vars, $values, $setting_comments_footer);
|
408
|
|
409
|
}
|
410
|
|
411
|
}
|
412
|
|
413
|
if(ENABLED_ASP) {
|
414
|
$_SESSION['comes_from_view'] = $post_id;
|
415
|
$_SESSION['comes_from_view_time'] = time();
|
416
|
}
|
417
|
|
418
|
}
|