Project

General

Profile

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