Project

General

Profile

1
<?php
2
/****************************************************************************
3
* SVN Version information:
4
*
5
* $Id: view.php 1229 2009-12-28 18:39:42Z Luisehahne $
6
*
7
*****************************************************************************
8
*                          WebsiteBaker
9
*
10
* WebsiteBaker Project <http://www.websitebaker2.org/>
11
* Copyright (C) 2009, Website Baker Org. e.V.
12
*         http://start.websitebaker2.org/impressum-datenschutz.php
13
* Copyright (C) 2004-2009, Ryan Djurovich
14
*
15
*                        About WebsiteBaker
16
*
17
* Website Baker is a PHP-based Content Management System (CMS)
18
* designed with one goal in mind: to enable its users to produce websites
19
* with ease.
20
*
21
*****************************************************************************
22
*
23
*****************************************************************************
24
*                        LICENSE INFORMATION
25
*
26
* WebsiteBaker is free software; you can redistribute it and/or
27
* modify it under the terms of the GNU General Public License
28
* as published by the Free Software Foundation; either version 2
29
* of the License, or (at your option) any later version.
30
*
31
* WebsiteBaker is distributed in the hope that it will be useful,
32
* but WITHOUT ANY WARRANTY; without even the implied warranty of
33
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
34
* See the GNU General Public License for more details.
35
*
36
* You should have received a copy of the GNU General Public License
37
* along with this program; if not, write to the Free Software
38
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
39
****************************************************************************
40
*
41
*                   WebsiteBaker Extra Information
42
*
43
*
44
*
45
*
46
*****************************************************************************/
47
/**
48
 *
49
 * @category     modules
50
 * @package      news
51
 * @author       Ryan Djurovich
52
 * @copyright    2004-2009, Ryan Djurovich
53
 * @copyright    2009, Website Baker Org. e.V.
54
 * @version      $Id: view.php 1229 2009-12-28 18:39:42Z Luisehahne $
55
 * @platform     WebsiteBaker 2.8.x
56
 * @requirements >= PHP 4.3.4
57
 * @license      http://www.gnu.org/licenses/gpl.html
58
 *
59
 */
60

    
61
// Must include code to stop this file being access directly
62
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
63

    
64
// load module language file
65
$lang = (dirname(__FILE__)) . '/languages/' . LANGUAGE . '.php';
66
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang );
67

    
68
//overwrite php.ini on Apache servers for valid SESSION ID Separator
69
if(function_exists('ini_set')) {
70
	ini_set('arg_separator.output', '&amp;');
71
}
72

    
73
// Check if there is a start point defined
74
if(isset($_GET['p']) AND is_numeric($_GET['p']) AND $_GET['p'] >= 0)
75
{
76
	$position = $_GET['p'];
77
}
78
else
79
{
80
	$position = 0;
81
}
82

    
83
// Get user's username, display name, email, and id - needed for insertion into post info
84
$users = array();
85
$query_users = $database->query("SELECT user_id,username,display_name,email FROM ".TABLE_PREFIX."users");
86
if($query_users->numRows() > 0)
87
{
88
	while($user = $query_users->fetchRow())
89
    {
90
		// Insert user info into users array
91
		$user_id = $user['user_id'];
92
		$users[$user_id]['username'] = $user['username'];
93
		$users[$user_id]['display_name'] = $user['display_name'];
94
		$users[$user_id]['email'] = $user['email'];
95
	}
96
}
97
// Get groups (title, if they are active, and their image [if one has been uploaded])
98
if (isset($groups))
99
{
100
   unset($groups);
101
}
102

    
103
$groups[0]['title'] = '';
104
$groups[0]['active'] = true;
105
$groups[0]['image'] = '';
106

    
107
$query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
108
if($query_users->numRows() > 0)
109
{
110
	while($group = $query_users->fetchRow())
111
    {
112
		// Insert user info into users array
113
		$group_id = $group['group_id'];
114
		$groups[$group_id]['title'] = ($group['title']);
115
		$groups[$group_id]['active'] = $group['active'];
116
		if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg'))
117
        {
118
			$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
119
		}
120
        else
121
        {
122
			$groups[$group_id]['image'] = '';
123
		}
124
	}
125
}
126

    
127

    
128

    
129
// Check if we should show the main page or a post itself
130
if(!defined('POST_ID') OR !is_numeric(POST_ID))
131
{
132

    
133
	// Check if we should only list posts from a certain group
134
	if(isset($_GET['g']) AND is_numeric($_GET['g']))
135
    {
136
		$query_extra = " AND group_id = '".$_GET['g']."'";
137
	}
138
    else
139
    {
140
		$query_extra = '';
141
	}
142

    
143
	// Check if we should only list posts from a certain group
144
	if(isset($_GET['g']) AND is_numeric($_GET['g']))
145
    {
146
		$query_extra = " AND group_id = '".$_GET['g']."'";
147
	}
148
    else
149
    {
150
		$query_extra = '';
151
	}
152

    
153
	// Get settings
154
	$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
155
	if($query_settings->numRows() > 0)
156
    {
157
		$fetch_settings = $query_settings->fetchRow();
158
		$setting_header = ($fetch_settings['header']);
159
		$setting_post_loop = ($fetch_settings['post_loop']);
160
		$setting_footer = ($fetch_settings['footer']);
161
		$setting_posts_per_page = $fetch_settings['posts_per_page'];
162
	}
163
    else
164
    {
165
		$setting_header = '';
166
		$setting_post_loop = '';
167
		$setting_footer = '';
168
		$setting_posts_per_page = '';
169
	}
170

    
171
	$t = time();
172
	// Get total number of posts
173
	$query_total_num = $database->query("SELECT post_id, section_id FROM ".TABLE_PREFIX."mod_news_posts
174
		WHERE section_id = '$section_id' AND active = '1' AND title != '' $query_extra
175
		AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)");
176
	$total_num = $query_total_num->numRows();
177

    
178
	// Work-out if we need to add limit code to sql
179
	if($setting_posts_per_page != 0)
180
    {
181
		$limit_sql = " LIMIT $position, $setting_posts_per_page";
182
	}
183
    else
184
    {
185
		$limit_sql = "";
186
	}
187

    
188
	// Query posts (for this page)
189
	$query_posts = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts
190
		WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra
191
		AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)
192
		ORDER BY position DESC".$limit_sql);
193
	$num_posts = $query_posts->numRows();
194

    
195
	// Create previous and next links
196
	if($setting_posts_per_page != 0)
197
    {
198
		if($position > 0)
199
        {
200
			if(isset($_GET['g']) AND is_numeric($_GET['g']))
201
            {
202
				$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&amp;g='.$_GET['g'].'">&lt;&lt; ';
203
			}
204
            else
205
            {
206
				$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'">&lt;&lt; ';
207
			}
208
			$pl_append = '</a>';
209
			$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append;
210
			$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append;
211
		}
212
        else
213
        {
214
			$previous_link = '';
215
			$previous_page_link = '';
216
		}
217
		if($position + $setting_posts_per_page >= $total_num)
218
        {
219
			$next_link = '';
220
			$next_page_link = '';
221
		}
222
        else
223
        {
224
			if(isset($_GET['g']) AND is_numeric($_GET['g']))
225
            {
226
				$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&amp;g='.$_GET['g'].'"> ';
227
			}
228
            else
229
            {
230
				$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> ';
231
			}
232
			$nl_append = ' &gt;&gt;</a>';
233
			$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append;
234
			$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append;
235
		}
236
		if($position+$setting_posts_per_page > $total_num)
237
        {
238
			$num_of = $position+$num_posts;
239
		}
240
        else
241
        {
242
			$num_of = $position+$setting_posts_per_page;
243
		}
244

    
245
		$out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num;
246
		$of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num;
247
		$display_previous_next_links = '';
248
	}
249
    else
250
    {
251
		$display_previous_next_links = 'none';
252
	}
253

    
254
	if ($num_posts === 0)
255
    {
256
		$setting_header = '';
257
		$setting_post_loop = '';
258
		$setting_footer = '';
259
		$setting_posts_per_page = '';
260
	}
261

    
262
	// Print header
263
	if($display_previous_next_links == 'none')
264
    {
265
		print  str_replace( array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'),
266
                            array('','','','','','', $display_previous_next_links), $setting_header);
267
	}
268
    else
269
    {
270
		print str_replace(  array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'),
271
                            array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header);
272
	}
273
	if($num_posts > 0)
274
    {
275
		if($query_extra != '')
276
        {
277
			?>
278
			<div class="selected-group-title">
279
				<?php print '<a href="'.htmlspecialchars(strip_tags($_SERVER['PHP_SELF'])).'">'.PAGE_TITLE.'</a> &gt;&gt; '.$groups[$_GET['g']]['title']; ?>
280
			</div>
281
			<?php
282
		}
283
		while($post = $query_posts->fetchRow())
284
        {
285
			if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
286
            { // Make sure parent group is active
287
				$uid = $post['posted_by']; // User who last modified the post
288
				// Workout date and time of last modified post
289
				if ($post['published_when'] === '0') $post['published_when'] = time();
290
				if ($post['published_when'] > $post['posted_when'])
291
                {
292
					$post_date = gmdate(DATE_FORMAT, $post['published_when']+TIMEZONE);
293
					$post_time = gmdate(TIME_FORMAT, $post['published_when']+TIMEZONE);
294
				}
295
                else
296
                {
297
					$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
298
					$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
299
				}
300

    
301
				$publ_date = date(DATE_FORMAT,$post['published_when']);
302
				$publ_time = date(TIME_FORMAT,$post['published_when']);
303

    
304
				// Work-out the post link
305
				$post_link = page_link($post['link']);
306

    
307
                $post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
308
                if(file_exists($post_link_path))
309
                {
310
    				$create_date = date(DATE_FORMAT, filectime ( $post_link_path ));
311
    				$create_time = date(TIME_FORMAT, filectime ( $post_link_path ));
312
                }
313
                else
314
                {
315
                    $create_date = $publ_date;
316
                    $create_time = $publ_time;
317
                }
318

    
319
				if(isset($_GET['p']) AND $position > 0)
320
                {
321
					$post_link .= '?p='.$position;
322
				}
323
				if(isset($_GET['g']) AND is_numeric($_GET['g']))
324
                {
325
					if(isset($_GET['p']) AND $position > 0) { $post_link .= '&amp;'; } else { $post_link .= '?'; }
326
                    {
327
					$post_link .= 'g='.$_GET['g'];
328
                    }
329
				}
330

    
331
				// Get group id, title, and image
332
				$group_id = $post['group_id'];
333
				$group_title = $groups[$group_id]['title'];
334
				$group_image = $groups[$group_id]['image'];
335
				$display_image = ($group_image == '') ? "none" : "inherit";
336
				$display_group = ($group_id == 0) ? 'none' : 'inherit';
337

    
338
				if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
339

    
340
				// Replace [wblink--PAGE_ID--] with real link
341
				$short = ($post['content_short']);
342
				$wb->preprocess($short);
343

    
344
				// Replace vars with values
345
				$post_long_len = strlen($post['content_long']);
346
				$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]');
347
				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '')
348
                {
349
					if($post_long_len < 9)
350
                    {
351
						$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');
352
					}
353
                    else
354
                    {
355
					   	$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');
356
					}
357
				}
358
                else
359
                {
360
					if($post_long_len < 9)
361
                    {
362
						$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');
363
					}
364
                    else
365
                    {
366
						$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');
367
					}
368
				}
369
				print str_replace($vars, $values, $setting_post_loop);
370
			}
371
		}
372
	}
373
    // Print footer
374
    if($display_previous_next_links == 'none')
375
    {
376
    	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);
377
    }
378
    else
379
    {
380
    	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);
381
    }
382

    
383
}
384
elseif(defined('POST_ID') AND is_numeric(POST_ID))
385
{
386

    
387
  // print '<h2>'.POST_ID.'/'.PAGE_ID.'/'.POST_SECTION.'</h2>';
388
  if(defined('POST_SECTION') AND POST_SECTION == $section_id)
389
  {
390
	// Get settings
391
	$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
392
	if($query_settings->numRows() > 0)
393
    {
394
		$fetch_settings = $query_settings->fetchRow();
395
		$setting_post_header = ($fetch_settings['post_header']);
396
		$setting_post_footer = ($fetch_settings['post_footer']);
397
		$setting_comments_header = ($fetch_settings['comments_header']);
398
		$setting_comments_loop = ($fetch_settings['comments_loop']);
399
		$setting_comments_footer = ($fetch_settings['comments_footer']);
400
	} else
401
    {
402
		$setting_post_header = '';
403
		$setting_post_footer = '';
404
		$setting_comments_header = '';
405
		$setting_comments_loop = '';
406
		$setting_comments_footer = '';
407
    }
408
	// Get page info
409
	$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'");
410
	if($query_page->numRows() > 0)
411
    {
412
		$page = $query_page->fetchRow();
413
		$page_link = page_link($page['link']);
414
		if(isset($_GET['p']) AND $position > 0)
415
        {
416
			$page_link .= '?p='.$_GET['p'];
417
		}
418
		if(isset($_GET['g']) AND is_numeric($_GET['g']))
419
        {
420
			if(isset($_GET['p']) AND $position > 0) { $page_link .= '&amp;'; } else { $page_link .= '?'; }
421
			$page_link .= 'g='.$_GET['g'];
422
		}
423
	}
424
    else
425
    {
426
		exit($MESSAGE['PAGES']['NOT_FOUND']);
427
	}
428

    
429
	// Get post info
430
	$t = time();
431
	$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts
432
		WHERE post_id = '".POST_ID."' AND active = '1'
433
		AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)
434
	");
435

    
436
	if($query_post->numRows() > 0)
437
    {
438
		$post = $query_post->fetchRow();
439
		if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
440
        { // Make sure parent group is active
441
			$uid = $post['posted_by']; // User who last modified the post
442
			// Workout date and time of last modified post
443
			if ($post['published_when'] === '0') $post['published_when'] = time();
444
			if ($post['published_when'] > $post['posted_when'])
445
            {
446
				$post_date = gmdate(DATE_FORMAT, $post['published_when']+TIMEZONE);
447
				$post_time = gmdate(TIME_FORMAT, $post['published_when']+TIMEZONE);
448
			}
449
            else
450
            {
451
				$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
452
				$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
453
			}
454

    
455
			$publ_date = date(DATE_FORMAT,$post['published_when']);
456
			$publ_time = date(TIME_FORMAT,$post['published_when']);
457

    
458
				// Work-out the post link
459
				$post_link = page_link($post['link']);
460

    
461
                $post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
462
                if(file_exists($post_link_path))
463
                {
464
    				$create_date = date(DATE_FORMAT, filectime ( $post_link_path ));
465
    				$create_time = date(TIME_FORMAT, filectime ( $post_link_path ));
466
                }
467
                else
468
                {
469
                    $create_date = $publ_date;
470
                    $create_time = $publ_time;
471
                }
472
			// Get group id, title, and image
473
			$group_id = $post['group_id'];
474
			$group_title = $groups[$group_id]['title'];
475
			$group_image = $groups[$group_id]['image'];
476
			$display_image = ($group_image == '') ? "none" : "inherit";
477
			$display_group = ($group_id == 0) ? 'none' : 'inherit';
478

    
479
			if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
480

    
481
			$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]');
482
			$post_short=$post['content_short'];
483
			$wb->preprocess($post_short);
484
			if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '')
485
            {
486
				$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']);
487
			}
488
            else
489
            {
490
				$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'], '', '', '', '');
491
			}
492

    
493
			$post_long = ($post['content_long']);
494
		}
495
	}
496
    else
497
    {
498
	    	$wb->print_error($MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'], "javascript: history.go(-1);", false);
499
	    	exit(0);
500
	}
501

    
502
	// Print post header
503
	print str_replace($vars, $values, $setting_post_header);
504

    
505
	// Replace [wblink--PAGE_ID--] with real link
506
  	$wb->preprocess($post_long);
507
	// Print long
508
	print $post_long;
509

    
510
	// Print post footer
511
	print str_replace($vars, $values, $setting_post_footer);
512

    
513
	// Show comments section if we have to
514
	if(($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true) OR $post['commenting'] == 'public')
515
    {
516
		// Print comments header
517
		$vars = array('[ADD_COMMENT_URL]','[TEXT_COMMENTS]');
518
		$values = array(WB_URL.'/modules/news/comment.php?post_id='.POST_ID.'&amp;section_id='.$section_id, $MOD_NEWS['TEXT_COMMENTS']);
519
		print str_replace($vars, $values, $setting_comments_header);
520

    
521
		// Query for comments
522
		$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");
523
		if($query_comments->numRows() > 0) {
524
			while($comment = $query_comments->fetchRow()) {
525
				// Display Comments without slashes, but with new-line characters
526
				$comment['comment'] = nl2br($wb->strip_slashes($comment['comment']));
527
				$comment['title'] = $wb->strip_slashes($comment['title']);
528
				// Print comments loop
529
				$commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
530
				$commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
531
				$uid = $comment['commented_by'];
532
				$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
533
				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
534
					$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']));
535
				} else {
536
					$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'], '');
537
				}
538
				print str_replace($vars, $values, $setting_comments_loop);
539
			}
540
		} else {
541
			// Say no comments found
542
			$content = '';
543
			if(isset($TEXT['NONE_FOUND'])) {
544
				$content .= '<tr><td>'.$TEXT['NONE_FOUND'].'<br /></td></tr>';
545
			}
546
            else
547
            {
548
				$content .= '<tr><td>None Found<br /></td></tr>';
549
			}
550
			print $content;
551
		}
552

    
553
		// Print comments footer
554
		$vars = array('[ADD_COMMENT_URL]','[TEXT_ADD_COMMENT]');
555
		$values = array(WB_URL.'/modules/news/comment.php?post_id='.POST_ID.'&amp;section_id='.$section_id, $MOD_NEWS['TEXT_ADD_COMMENT']);
556
		print str_replace($vars, $values, $setting_comments_footer);
557

    
558
	}
559

    
560
}
561

    
562
	if(ENABLED_ASP) {
563
		$_SESSION['comes_from_view'] = POST_ID;
564
		$_SESSION['comes_from_view_time'] = time();
565
	}
566

    
567
}
568
?>
(31-31/31)