| 1 | 
        
            5
         | 
        
            stefan
         | 
        <?php
  | 
      
      
        | 2 | 
        
            4
         | 
        
            ryan
         | 
        
  | 
      
      
        | 3 | 
        
            36
         | 
        
            stefan
         | 
        // $Id$
  | 
      
      
        | 4 | 
        
            4
         | 
        
            ryan
         | 
        
  | 
      
      
        | 5 | 
        
            5
         | 
        
            stefan
         | 
        /*
  | 
      
      
        | 6 | 
        
         | 
        
         | 
        
  | 
      
      
        | 7 | 
        
         | 
        
         | 
         Website Baker Project <http://www.websitebaker.org/>
  | 
      
      
        | 8 | 
        
         | 
        
         | 
         Copyright (C) 2004-2005, 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 | 
        
            4
         | 
        
            ryan
         | 
        // Must include code to stop this file being access directly
  | 
      
      
        | 27 | 
        
         | 
        
         | 
        if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
 | 
      
      
        | 28 | 
        
            5
         | 
        
            stefan
         | 
        
  | 
      
      
        | 29 | 
        
         | 
        
         | 
        // Check if there is a start point defined
  | 
      
      
        | 30 | 
        
         | 
        
         | 
        if(isset($_GET['p']) AND is_numeric($_GET['p']) AND $_GET['p'] >= 0) {
 | 
      
      
        | 31 | 
        
         | 
        
         | 
        	$position = $_GET['p'];
  | 
      
      
        | 32 | 
        
         | 
        
         | 
        } else {
 | 
      
      
        | 33 | 
        
         | 
        
         | 
        	$position = 0;
  | 
      
      
        | 34 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 35 | 
        
         | 
        
         | 
        
  | 
      
      
        | 36 | 
        
         | 
        
         | 
        // Get user's username, display name, email, and id - needed for insertion into post info
  | 
      
      
        | 37 | 
        
         | 
        
         | 
        $users = array();
  | 
      
      
        | 38 | 
        
         | 
        
         | 
        $query_users = $database->query("SELECT user_id,username,display_name,email FROM ".TABLE_PREFIX."users");
 | 
      
      
        | 39 | 
        
         | 
        
         | 
        if($query_users->numRows() > 0) {
 | 
      
      
        | 40 | 
        
         | 
        
         | 
        	while($user = $query_users->fetchRow()) {
 | 
      
      
        | 41 | 
        
         | 
        
         | 
        		// Insert user info into users array
  | 
      
      
        | 42 | 
        
         | 
        
         | 
        		$user_id = $user['user_id'];
  | 
      
      
        | 43 | 
        
         | 
        
         | 
        		$users[$user_id]['username'] = $user['username'];
  | 
      
      
        | 44 | 
        
         | 
        
         | 
        		$users[$user_id]['display_name'] = $user['display_name'];
  | 
      
      
        | 45 | 
        
         | 
        
         | 
        		$users[$user_id]['email'] = $user['email'];
  | 
      
      
        | 46 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 47 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 48 | 
        
         | 
        
         | 
        
  | 
      
      
        | 49 | 
        
         | 
        
         | 
        // Get groups (title, if they are active, and their image [if one has been uploaded])
  | 
      
      
        | 50 | 
        
         | 
        
         | 
        $groups[0]['title'] = '';
  | 
      
      
        | 51 | 
        
         | 
        
         | 
        $groups[0]['active'] = true;
  | 
      
      
        | 52 | 
        
         | 
        
         | 
        $groups[0]['image'] = '';
  | 
      
      
        | 53 | 
        
         | 
        
         | 
        $query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
 | 
      
      
        | 54 | 
        
         | 
        
         | 
        if($query_users->numRows() > 0) {
 | 
      
      
        | 55 | 
        
         | 
        
         | 
        	while($group = $query_users->fetchRow()) {
 | 
      
      
        | 56 | 
        
         | 
        
         | 
        		// Insert user info into users array
  | 
      
      
        | 57 | 
        
         | 
        
         | 
        		$group_id = $group['group_id'];
  | 
      
      
        | 58 | 
        
            42
         | 
        
            stefan
         | 
        		$groups[$group_id]['title'] = $this->strip_slashes_dummy($group['title']);
  | 
      
      
        | 59 | 
        
            5
         | 
        
            stefan
         | 
        		$groups[$group_id]['active'] = $group['active'];
  | 
      
      
        | 60 | 
        
         | 
        
         | 
        		if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
 | 
      
      
        | 61 | 
        
         | 
        
         | 
        			$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
  | 
      
      
        | 62 | 
        
         | 
        
         | 
        		} else {
 | 
      
      
        | 63 | 
        
         | 
        
         | 
        			$groups[$group_id]['image'] = '';
  | 
      
      
        | 64 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 65 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 66 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 67 | 
        
         | 
        
         | 
        
  | 
      
      
        | 68 | 
        
         | 
        
         | 
        // Check if we should show the main page or a post itself
  | 
      
      
        | 69 | 
        
         | 
        
         | 
        if(!defined('POST_ID') OR !is_numeric(POST_ID)) {
 | 
      
      
        | 70 | 
        
         | 
        
         | 
        
  | 
      
      
        | 71 | 
        
         | 
        
         | 
        	// Check if we should only list posts from a certain group
  | 
      
      
        | 72 | 
        
         | 
        
         | 
        	if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
 | 
      
      
        | 73 | 
        
         | 
        
         | 
        		$query_extra = " AND group_id = '".$_GET['g']."'";
  | 
      
      
        | 74 | 
        
         | 
        
         | 
        		?>
  | 
      
      
        | 75 | 
        
         | 
        
         | 
        		<style type="text/css">.selected_group_title { font-size: 14px; text-align: center; }</style>
 | 
      
      
        | 76 | 
        
         | 
        
         | 
        		<?php
  | 
      
      
        | 77 | 
        
         | 
        
         | 
        	} else {
 | 
      
      
        | 78 | 
        
         | 
        
         | 
        		$query_extra = '';
  | 
      
      
        | 79 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 80 | 
        
         | 
        
         | 
        
  | 
      
      
        | 81 | 
        
            4
         | 
        
            ryan
         | 
        	// Get settings
  | 
      
      
        | 82 | 
        
            5
         | 
        
            stefan
         | 
        	$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
 | 
      
      
        | 83 | 
        
         | 
        
         | 
        	if($query_settings->numRows() > 0) {
 | 
      
      
        | 84 | 
        
         | 
        
         | 
        		$fetch_settings = $query_settings->fetchRow();
  | 
      
      
        | 85 | 
        
            42
         | 
        
            stefan
         | 
        		$setting_header = $this->strip_slashes_dummy($fetch_settings['header']);
  | 
      
      
        | 86 | 
        
         | 
        
         | 
        		$setting_post_loop = $this->strip_slashes_dummy($fetch_settings['post_loop']);
  | 
      
      
        | 87 | 
        
         | 
        
         | 
        		$setting_footer = $this->strip_slashes_dummy($fetch_settings['footer']);
  | 
      
      
        | 88 | 
        
            5
         | 
        
            stefan
         | 
        		$setting_posts_per_page = $fetch_settings['posts_per_page'];
  | 
      
      
        | 89 | 
        
         | 
        
         | 
        	} else {
 | 
      
      
        | 90 | 
        
         | 
        
         | 
        		$setting_header = '';
  | 
      
      
        | 91 | 
        
         | 
        
         | 
        		$setting_post_loop = '';
  | 
      
      
        | 92 | 
        
         | 
        
         | 
        		$setting_footer = '';
  | 
      
      
        | 93 | 
        
         | 
        
         | 
        		$setting_posts_per_page = '';
  | 
      
      
        | 94 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 95 | 
        
         | 
        
         | 
        
  | 
      
      
        | 96 | 
        
         | 
        
         | 
        	// Get total number of posts
  | 
      
      
        | 97 | 
        
         | 
        
         | 
        	$query_total_num = $database->query("SELECT post_id FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra");
 | 
      
      
        | 98 | 
        
         | 
        
         | 
        	$total_num = $query_total_num->numRows();
  | 
      
      
        | 99 | 
        
            4
         | 
        
            ryan
         | 
        
  | 
      
      
        | 100 | 
        
            5
         | 
        
            stefan
         | 
        	// Work-out if we need to add limit code to sql
  | 
      
      
        | 101 | 
        
         | 
        
         | 
        	if($setting_posts_per_page != 0) {
 | 
      
      
        | 102 | 
        
         | 
        
         | 
        		$limit_sql = " LIMIT $position,$setting_posts_per_page";
  | 
      
      
        | 103 | 
        
         | 
        
         | 
        	} else {
 | 
      
      
        | 104 | 
        
         | 
        
         | 
        		$limit_sql = "";
  | 
      
      
        | 105 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 106 | 
        
         | 
        
         | 
        
  | 
      
      
        | 107 | 
        
         | 
        
         | 
        	// Query posts (for this page)
  | 
      
      
        | 108 | 
        
         | 
        
         | 
        	$query_posts = $database->query("SELECT group_id,post_id,title,link,short,posted_by,posted_when FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra ORDER BY position DESC".$limit_sql);
 | 
      
      
        | 109 | 
        
         | 
        
         | 
        	$num_posts = $query_posts->numRows();
  | 
      
      
        | 110 | 
        
         | 
        
         | 
        
  | 
      
      
        | 111 | 
        
         | 
        
         | 
        	// Create previous and next links
  | 
      
      
        | 112 | 
        
         | 
        
         | 
        	if($setting_posts_per_page != 0) {
 | 
      
      
        | 113 | 
        
         | 
        
         | 
        		if($position > 0) {
 | 
      
      
        | 114 | 
        
         | 
        
         | 
        			if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
 | 
      
      
        | 115 | 
        
         | 
        
         | 
        				$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< ';
  | 
      
      
        | 116 | 
        
         | 
        
         | 
        			} else {
 | 
      
      
        | 117 | 
        
         | 
        
         | 
        				$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< ';
  | 
      
      
        | 118 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 119 | 
        
         | 
        
         | 
        			$pl_append = '</a>';
  | 
      
      
        | 120 | 
        
         | 
        
         | 
        			$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append;
  | 
      
      
        | 121 | 
        
         | 
        
         | 
        			$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append;
  | 
      
      
        | 122 | 
        
         | 
        
         | 
        		} else {
 | 
      
      
        | 123 | 
        
         | 
        
         | 
        			$previous_link = '';
  | 
      
      
        | 124 | 
        
         | 
        
         | 
        			$previous_page_link = '';
  | 
      
      
        | 125 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 126 | 
        
         | 
        
         | 
        		if($position+$setting_posts_per_page >= $total_num) {
 | 
      
      
        | 127 | 
        
         | 
        
         | 
        			$next_link = '';
  | 
      
      
        | 128 | 
        
         | 
        
         | 
        			$next_page_link = '';
  | 
      
      
        | 129 | 
        
         | 
        
         | 
        		} else {
 | 
      
      
        | 130 | 
        
         | 
        
         | 
        			if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
 | 
      
      
        | 131 | 
        
         | 
        
         | 
        				$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> ';
  | 
      
      
        | 132 | 
        
         | 
        
         | 
        			} else {
 | 
      
      
        | 133 | 
        
         | 
        
         | 
        				$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> ';
  | 
      
      
        | 134 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 135 | 
        
         | 
        
         | 
        			$nl_append = ' >></a>';
  | 
      
      
        | 136 | 
        
         | 
        
         | 
        			$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append;
  | 
      
      
        | 137 | 
        
         | 
        
         | 
        			$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append;
  | 
      
      
        | 138 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 139 | 
        
         | 
        
         | 
        		if($position+$setting_posts_per_page > $total_num) {
 | 
      
      
        | 140 | 
        
         | 
        
         | 
        			$num_of = $position+$num_posts;
  | 
      
      
        | 141 | 
        
         | 
        
         | 
        		} else {
 | 
      
      
        | 142 | 
        
         | 
        
         | 
        			$num_of = $position+$setting_posts_per_page;
  | 
      
      
        | 143 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 144 | 
        
         | 
        
         | 
        		$out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num;
  | 
      
      
        | 145 | 
        
         | 
        
         | 
        		$of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num;
  | 
      
      
        | 146 | 
        
         | 
        
         | 
        		$display_previous_next_links = '';
  | 
      
      
        | 147 | 
        
         | 
        
         | 
        	} else {
 | 
      
      
        | 148 | 
        
         | 
        
         | 
        		$display_previous_next_links = 'none';
  | 
      
      
        | 149 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 150 | 
        
         | 
        
         | 
        
  | 
      
      
        | 151 | 
        
         | 
        
         | 
        	// Print header
  | 
      
      
        | 152 | 
        
         | 
        
         | 
        	if($display_previous_next_links == 'none') {
 | 
      
      
        | 153 | 
        
         | 
        
         | 
        		echo  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_header);
 | 
      
      
        | 154 | 
        
         | 
        
         | 
        	} else {
 | 
      
      
        | 155 | 
        
         | 
        
         | 
        		echo 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_header);
 | 
      
      
        | 156 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 157 | 
        
         | 
        
         | 
        
  | 
      
      
        | 158 | 
        
         | 
        
         | 
        	if($num_posts > 0) {
 | 
      
      
        | 159 | 
        
         | 
        
         | 
        		if($query_extra != '') {
 | 
      
      
        | 160 | 
        
         | 
        
         | 
        			?>
  | 
      
      
        | 161 | 
        
         | 
        
         | 
        			<div class="selected_group_title">
  | 
      
      
        | 162 | 
        
         | 
        
         | 
        				<?php echo '<a href="'.$_SERVER['PHP_SELF'].'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?>
  | 
      
      
        | 163 | 
        
         | 
        
         | 
        			</div>
  | 
      
      
        | 164 | 
        
         | 
        
         | 
        			<?php
  | 
      
      
        | 165 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 166 | 
        
         | 
        
         | 
        		while($post = $query_posts->fetchRow()) {
 | 
      
      
        | 167 | 
        
         | 
        
         | 
        			if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active
 | 
      
      
        | 168 | 
        
         | 
        
         | 
        				$uid = $post['posted_by']; // User who last modified the post
  | 
      
      
        | 169 | 
        
         | 
        
         | 
        				// Workout date and time of last modified post
  | 
      
      
        | 170 | 
        
         | 
        
         | 
        				$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
  | 
      
      
        | 171 | 
        
         | 
        
         | 
        				$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
  | 
      
      
        | 172 | 
        
         | 
        
         | 
        				// Work-out the post link
  | 
      
      
        | 173 | 
        
         | 
        
         | 
        				$post_link = page_link($post['link']);
  | 
      
      
        | 174 | 
        
         | 
        
         | 
        				if(isset($_GET['p']) AND $position > 0) {
 | 
      
      
        | 175 | 
        
         | 
        
         | 
        					$post_link .= '?p='.$position;
  | 
      
      
        | 176 | 
        
         | 
        
         | 
        				}
  | 
      
      
        | 177 | 
        
         | 
        
         | 
        				if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
 | 
      
      
        | 178 | 
        
         | 
        
         | 
        					if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; }
 | 
      
      
        | 179 | 
        
         | 
        
         | 
        					$post_link .= 'g='.$_GET['g'];
  | 
      
      
        | 180 | 
        
         | 
        
         | 
        				}
  | 
      
      
        | 181 | 
        
         | 
        
         | 
        				// Get group id, title, and image
  | 
      
      
        | 182 | 
        
         | 
        
         | 
        				$group_id = $post['group_id'];
  | 
      
      
        | 183 | 
        
         | 
        
         | 
        				$group_title = $groups[$group_id]['title'];
  | 
      
      
        | 184 | 
        
         | 
        
         | 
        				$group_image = $groups[$group_id]['image'];
  | 
      
      
        | 185 | 
        
         | 
        
         | 
        				if($group_image == '') { $display_image = 'none'; } else { $display_image = ''; }
 | 
      
      
        | 186 | 
        
         | 
        
         | 
        				if($group_id == 0) { $display_group = 'none'; } else { $display_group = ''; }
 | 
      
      
        | 187 | 
        
         | 
        
         | 
        				// Replace [wblink--PAGE_ID--] with real link
  | 
      
      
        | 188 | 
        
            42
         | 
        
            stefan
         | 
        				$short = $this->strip_slashes_dummy($post['short']);
  | 
      
      
        | 189 | 
        
            5
         | 
        
            stefan
         | 
        				$this->preprocess($short);
  | 
      
      
        | 190 | 
        
         | 
        
         | 
        				// Replace vars with values
  | 
      
      
        | 191 | 
        
         | 
        
         | 
        				$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[LINK]', '[DATE]', '[TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]', '[TEXT_READ_MORE]');
 | 
      
      
        | 192 | 
        
         | 
        
         | 
        				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
 | 
      
      
        | 193 | 
        
            42
         | 
        
            stefan
         | 
        					$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $this->strip_slashes_dummy($post['title']), $short, $post_link, $post_date, $post_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], $TEXT['READ_MORE']);
  | 
      
      
        | 194 | 
        
            5
         | 
        
            stefan
         | 
        				} else {
 | 
      
      
        | 195 | 
        
            42
         | 
        
            stefan
         | 
        					$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $this->strip_slashes_dummy($post['title']), $short, $post_link, $post_date, $post_time, '', '', '', '', $TEXT['READ_MORE']);
  | 
      
      
        | 196 | 
        
            5
         | 
        
            stefan
         | 
        				}
  | 
      
      
        | 197 | 
        
         | 
        
         | 
        				echo str_replace($vars, $values, $setting_post_loop);
  | 
      
      
        | 198 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 199 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 200 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 201 | 
        
         | 
        
         | 
        
  | 
      
      
        | 202 | 
        
         | 
        
         | 
        	// Print footer
  | 
      
      
        | 203 | 
        
         | 
        
         | 
        	if($display_previous_next_links == 'none') {
 | 
      
      
        | 204 | 
        
         | 
        
         | 
        		echo  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);
 | 
      
      
        | 205 | 
        
         | 
        
         | 
        	} else {
 | 
      
      
        | 206 | 
        
         | 
        
         | 
        		echo 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);
 | 
      
      
        | 207 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 208 | 
        
         | 
        
         | 
        
  | 
      
      
        | 209 | 
        
         | 
        
         | 
        } elseif(defined('POST_ID') AND is_numeric(POST_ID)) {
 | 
      
      
        | 210 | 
        
         | 
        
         | 
        
  | 
      
      
        | 211 | 
        
         | 
        
         | 
        	// Get settings
  | 
      
      
        | 212 | 
        
         | 
        
         | 
        	$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
 | 
      
      
        | 213 | 
        
         | 
        
         | 
        	if($query_settings->numRows() > 0) {
 | 
      
      
        | 214 | 
        
         | 
        
         | 
        		$fetch_settings = $query_settings->fetchRow();
  | 
      
      
        | 215 | 
        
            42
         | 
        
            stefan
         | 
        		$setting_post_header = $this->strip_slashes_dummy($fetch_settings['post_header']);
  | 
      
      
        | 216 | 
        
         | 
        
         | 
        		$setting_post_footer = $this->strip_slashes_dummy($fetch_settings['post_footer']);
  | 
      
      
        | 217 | 
        
         | 
        
         | 
        		$setting_comments_header = $this->strip_slashes_dummy($fetch_settings['comments_header']);
  | 
      
      
        | 218 | 
        
         | 
        
         | 
        		$setting_comments_loop = $this->strip_slashes_dummy($fetch_settings['comments_loop']);
  | 
      
      
        | 219 | 
        
         | 
        
         | 
        		$setting_comments_footer = $this->strip_slashes_dummy($fetch_settings['comments_footer']);
  | 
      
      
        | 220 | 
        
            5
         | 
        
            stefan
         | 
        	} else {
 | 
      
      
        | 221 | 
        
         | 
        
         | 
        		$setting_post_header = '';
  | 
      
      
        | 222 | 
        
         | 
        
         | 
        		$setting_post_footer = '';
  | 
      
      
        | 223 | 
        
         | 
        
         | 
        		$setting_comments_header = '';
  | 
      
      
        | 224 | 
        
         | 
        
         | 
        		$setting_comments_loop = '';
  | 
      
      
        | 225 | 
        
         | 
        
         | 
        		$setting_comments_footer = '';
  | 
      
      
        | 226 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 227 | 
        
         | 
        
         | 
        
  | 
      
      
        | 228 | 
        
         | 
        
         | 
        	// Get page info
  | 
      
      
        | 229 | 
        
         | 
        
         | 
        	$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'");
 | 
      
      
        | 230 | 
        
         | 
        
         | 
        	if($query_page->numRows() > 0) {
 | 
      
      
        | 231 | 
        
         | 
        
         | 
        		$page = $query_page->fetchRow();
  | 
      
      
        | 232 | 
        
         | 
        
         | 
        		$page_link = page_link($page['link']);
  | 
      
      
        | 233 | 
        
         | 
        
         | 
        		if(isset($_GET['p']) AND $position > 0) {
 | 
      
      
        | 234 | 
        
         | 
        
         | 
        			$page_link .= '?p='.$_GET['p'];
  | 
      
      
        | 235 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 236 | 
        
         | 
        
         | 
        		if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
 | 
      
      
        | 237 | 
        
         | 
        
         | 
        			if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; }
 | 
      
      
        | 238 | 
        
         | 
        
         | 
        			$page_link .= 'g='.$_GET['g'];
  | 
      
      
        | 239 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 240 | 
        
         | 
        
         | 
        	} else {
 | 
      
      
        | 241 | 
        
         | 
        
         | 
        		exit('Page not found');
 | 
      
      
        | 242 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 243 | 
        
         | 
        
         | 
        
  | 
      
      
        | 244 | 
        
         | 
        
         | 
        	// Get post info
  | 
      
      
        | 245 | 
        
         | 
        
         | 
        	$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '".POST_ID."' AND active = '1'");
 | 
      
      
        | 246 | 
        
         | 
        
         | 
        	if($query_post->numRows() > 0) {
 | 
      
      
        | 247 | 
        
         | 
        
         | 
        		$post = $query_post->fetchRow();
  | 
      
      
        | 248 | 
        
         | 
        
         | 
        		if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active
 | 
      
      
        | 249 | 
        
         | 
        
         | 
        			$uid = $post['posted_by']; // User who last modified the post
  | 
      
      
        | 250 | 
        
         | 
        
         | 
        			// Workout date and time of last modified post
  | 
      
      
        | 251 | 
        
         | 
        
         | 
        			$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
  | 
      
      
        | 252 | 
        
         | 
        
         | 
        			$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
  | 
      
      
        | 253 | 
        
         | 
        
         | 
        			// Get group id, title, and image
  | 
      
      
        | 254 | 
        
         | 
        
         | 
        			$group_id = $post['group_id'];
  | 
      
      
        | 255 | 
        
         | 
        
         | 
        			$group_title = $groups[$group_id]['title'];
  | 
      
      
        | 256 | 
        
         | 
        
         | 
        			$group_image = $groups[$group_id]['image'];
  | 
      
      
        | 257 | 
        
         | 
        
         | 
        			if($group_image == '') { $display_image = 'none'; } else { $display_image = ''; }
 | 
      
      
        | 258 | 
        
         | 
        
         | 
        			if($group_id == 0) { $display_group = 'none'; } else { $display_group = ''; }
 | 
      
      
        | 259 | 
        
         | 
        
         | 
        			$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[BACK]', '[DATE]', '[TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]');
 | 
      
      
        | 260 | 
        
         | 
        
         | 
        			if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
 | 
      
      
        | 261 | 
        
            42
         | 
        
            stefan
         | 
        				$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $this->strip_slashes_dummy($post['title']), $this->strip_slashes_dummy($post['short']), $page_link, $post_date, $post_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email']);
  | 
      
      
        | 262 | 
        
            5
         | 
        
            stefan
         | 
        			} else {
 | 
      
      
        | 263 | 
        
            42
         | 
        
            stefan
         | 
        				$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $this->strip_slashes_dummy($post['title']), $this->strip_slashes_dummy($post['short']), $page_link, $post_date, $post_time, '', '', '', '');
  | 
      
      
        | 264 | 
        
            5
         | 
        
            stefan
         | 
        			}
  | 
      
      
        | 265 | 
        
            42
         | 
        
            stefan
         | 
        			$post_long = $this->strip_slashes_dummy($post['long']);
  | 
      
      
        | 266 | 
        
            5
         | 
        
            stefan
         | 
        		}
  | 
      
      
        | 267 | 
        
         | 
        
         | 
        	} else {
 | 
      
      
        | 268 | 
        
         | 
        
         | 
        		header('Location: '.WB_URL.'/pages/');
 | 
      
      
        | 269 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 270 | 
        
         | 
        
         | 
        
  | 
      
      
        | 271 | 
        
         | 
        
         | 
        	// Print post header
  | 
      
      
        | 272 | 
        
         | 
        
         | 
        	echo str_replace($vars, $values, $setting_post_header);
  | 
      
      
        | 273 | 
        
         | 
        
         | 
        
  | 
      
      
        | 274 | 
        
         | 
        
         | 
        	// Replace [wblink--PAGE_ID--] with real link
  | 
      
      
        | 275 | 
        
         | 
        
         | 
          	$this->preprocess($postlong);
  | 
      
      
        | 276 | 
        
         | 
        
         | 
        	// Print long
  | 
      
      
        | 277 | 
        
         | 
        
         | 
        	echo $post_long;
  | 
      
      
        | 278 | 
        
         | 
        
         | 
        
  | 
      
      
        | 279 | 
        
         | 
        
         | 
        	// Print post footer
  | 
      
      
        | 280 | 
        
         | 
        
         | 
        	echo str_replace($vars, $values, $setting_post_footer);
  | 
      
      
        | 281 | 
        
         | 
        
         | 
        
  | 
      
      
        | 282 | 
        
         | 
        
         | 
        	// Show comments section if we have to
  | 
      
      
        | 283 | 
        
         | 
        
         | 
        	if($post['commenting'] == 'private' AND isset($admin) AND $admin->is_authenticated() == true OR $post['commenting'] == 'public') {
 | 
      
      
        | 284 | 
        
         | 
        
         | 
        
  | 
      
      
        | 285 | 
        
         | 
        
         | 
        		// Print comments header
  | 
      
      
        | 286 | 
        
         | 
        
         | 
        		echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID, $setting_comments_header);
 | 
      
      
        | 287 | 
        
         | 
        
         | 
        
  | 
      
      
        | 288 | 
        
         | 
        
         | 
        		// Query for comments
  | 
      
      
        | 289 | 
        
         | 
        
         | 
        		$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");
 | 
      
      
        | 290 | 
        
         | 
        
         | 
        		if($query_comments->numRows() > 0) {
 | 
      
      
        | 291 | 
        
         | 
        
         | 
        			while($comment = $query_comments->fetchRow()) {
 | 
      
      
        | 292 | 
        
         | 
        
         | 
        				// Display Comments without slashes, but with new-line characters
  | 
      
      
        | 293 | 
        
            42
         | 
        
            stefan
         | 
        				$comment['comment'] = nl2br($this->strip_slashes_dummy($comment['comment']));
  | 
      
      
        | 294 | 
        
         | 
        
         | 
        				$comment['title'] = $this->strip_slashes_dummy($comment['title']);
  | 
      
      
        | 295 | 
        
            5
         | 
        
            stefan
         | 
        				// Print comments loop
  | 
      
      
        | 296 | 
        
         | 
        
         | 
        				$commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
  | 
      
      
        | 297 | 
        
         | 
        
         | 
        				$commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
  | 
      
      
        | 298 | 
        
         | 
        
         | 
        				$uid = $comment['commented_by'];
  | 
      
      
        | 299 | 
        
         | 
        
         | 
        				$vars = array('[TITLE]','[COMMENT]','[DATE]','[TIME]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
 | 
      
      
        | 300 | 
        
         | 
        
         | 
        				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
 | 
      
      
        | 301 | 
        
            42
         | 
        
            stefan
         | 
        					$values = array($this->strip_slashes_dummy($comment['title']), $this->strip_slashes_dummy($comment['comment']), $commented_date, $commented_time, $uid, $this->strip_slashes_dummy($users[$uid]['username']), $this->strip_slashes_dummy($users[$uid]['display_name']), $this->strip_slashes_dummy($users[$uid]['email']));
  | 
      
      
        | 302 | 
        
            5
         | 
        
            stefan
         | 
        				} else {
 | 
      
      
        | 303 | 
        
            42
         | 
        
            stefan
         | 
        					$values = array($this->strip_slashes_dummy($comment['title']), $this->strip_slashes_dummy($comment['comment']), $commented_date, $commented_time, '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], '');
  | 
      
      
        | 304 | 
        
            5
         | 
        
            stefan
         | 
        				}
  | 
      
      
        | 305 | 
        
         | 
        
         | 
        				echo str_replace($vars, $values, $setting_comments_loop);
  | 
      
      
        | 306 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 307 | 
        
         | 
        
         | 
        		} else {
 | 
      
      
        | 308 | 
        
         | 
        
         | 
        			// Say no comments found
  | 
      
      
        | 309 | 
        
         | 
        
         | 
        			if(isset($TEXT['NONE_FOUND'])) {
 | 
      
      
        | 310 | 
        
         | 
        
         | 
        				echo $TEXT['NONE_FOUND'].'<br />';
  | 
      
      
        | 311 | 
        
         | 
        
         | 
        			} else {
 | 
      
      
        | 312 | 
        
         | 
        
         | 
        				echo 'None Found<br />';
  | 
      
      
        | 313 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 314 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 315 | 
        
         | 
        
         | 
        
  | 
      
      
        | 316 | 
        
         | 
        
         | 
        		// Print comments footer
  | 
      
      
        | 317 | 
        
         | 
        
         | 
        		echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID, $setting_comments_footer);
 | 
      
      
        | 318 | 
        
         | 
        
         | 
        
  | 
      
      
        | 319 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 320 | 
        
         | 
        
         | 
        
  | 
      
      
        | 321 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 322 | 
        
         | 
        
         | 
        
  | 
      
      
        | 323 | 
        
         | 
        
         | 
        ?>
  |