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