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