| 1 | 
        
            2
         | 
        
            Manuela
         | 
        <?php
  | 
      
      
        | 2 | 
        
         | 
        
         | 
        /**
  | 
      
      
        | 3 | 
        
         | 
        
         | 
         *
  | 
      
      
        | 4 | 
        
         | 
        
         | 
         * @category        modules
  | 
      
      
        | 5 | 
        
         | 
        
         | 
         * @package         modules_news
  | 
      
      
        | 6 | 
        
         | 
        
         | 
         * @author          WebsiteBaker Project
  | 
      
      
        | 7 | 
        
         | 
        
         | 
         * @copyright       WebsiteBaker Org. e.V.
  | 
      
      
        | 8 | 
        
         | 
        
         | 
         * @link            http://websitebaker.org/
  | 
      
      
        | 9 | 
        
         | 
        
         | 
         * @license         http://www.gnu.org/licenses/gpl.html
  | 
      
      
        | 10 | 
        
         | 
        
         | 
         * @platform        WebsiteBaker 2.8.3
  | 
      
      
        | 11 | 
        
         | 
        
         | 
         * @requirements    PHP 5.3.6 and higher
  | 
      
      
        | 12 | 
        
         | 
        
         | 
         * @version         $Id$
  | 
      
      
        | 13 | 
        
         | 
        
         | 
         * @filesource      $HeadURL$
  | 
      
      
        | 14 | 
        
         | 
        
         | 
         * @lastmodified    $Date$
  | 
      
      
        | 15 | 
        
         | 
        
         | 
         *  if ( $setting_posts_per_page && $setting_posts_per_page + $position <= $i ) { break; }
 | 
      
      
        | 16 | 
        
         | 
        
         | 
         */
  | 
      
      
        | 17 | 
        
         | 
        
         | 
        
  | 
      
      
        | 18 | 
        
         | 
        
         | 
        /* -------------------------------------------------------- */
  | 
      
      
        | 19 | 
        
         | 
        
         | 
        // Must include code to stop this file being accessed directly
  | 
      
      
        | 20 | 
        
         | 
        
         | 
        if(defined('WB_PATH') == false) { die('Illegale file access /'.basename(__DIR__).'/'.basename(__FILE__).''); }
 | 
      
      
        | 21 | 
        
         | 
        
         | 
        /* -------------------------------------------------------- */
  | 
      
      
        | 22 | 
        
         | 
        
         | 
        global $post_id, $post_section, $TEXT, $MESSAGE, $MOD_NEWS;
  | 
      
      
        | 23 | 
        
         | 
        
         | 
        // load module language file
  | 
      
      
        | 24 | 
        
         | 
        
         | 
        $sAddonName = basename(__DIR__);
  | 
      
      
        | 25 | 
        
         | 
        
         | 
        require(WB_PATH .'/modules/'.$sAddonName.'/languages/EN.php');
  | 
      
      
        | 26 | 
        
         | 
        
         | 
        if(file_exists(WB_PATH .'/modules/'.$sAddonName.'/languages/'.LANGUAGE .'.php')) {
 | 
      
      
        | 27 | 
        
         | 
        
         | 
            require(WB_PATH .'/modules/'.$sAddonName.'/languages/'.LANGUAGE .'.php');
  | 
      
      
        | 28 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 29 | 
        
         | 
        
         | 
        //overwrite php.ini on Apache servers for valid SESSION ID Separator
  | 
      
      
        | 30 | 
        
         | 
        
         | 
        if (function_exists('ini_set')) {
 | 
      
      
        | 31 | 
        
         | 
        
         | 
            ini_set('arg_separator.output', '&');
 | 
      
      
        | 32 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 33 | 
        
         | 
        
         | 
        
  | 
      
      
        | 34 | 
        
         | 
        
         | 
        $addBracket = function ()
  | 
      
      
        | 35 | 
        
         | 
        
         | 
        {
 | 
      
      
        | 36 | 
        
         | 
        
         | 
            $aList = func_get_args();
  | 
      
      
        | 37 | 
        
         | 
        
         | 
        //    return preg_replace('/^(.*)$/', '/\[$1\]/s', $aList);
 | 
      
      
        | 38 | 
        
         | 
        
         | 
            return preg_replace('/^(.*)$/', '[$1]', $aList);
 | 
      
      
        | 39 | 
        
         | 
        
         | 
        };
  | 
      
      
        | 40 | 
        
         | 
        
         | 
        $modRel = str_replace(WB_PATH, '', __DIR__).'/';
  | 
      
      
        | 41 | 
        
         | 
        
         | 
        $ModuleRel = '/modules/'.basename(__DIR__).'/';
  | 
      
      
        | 42 | 
        
         | 
        
         | 
        $ModuleUrl = WB_URL.'/modules/'.basename(__DIR__).'/';
  | 
      
      
        | 43 | 
        
         | 
        
         | 
        $ModulePath = WB_PATH.'/modules/'.basename(__DIR__).'/';
  | 
      
      
        | 44 | 
        
         | 
        
         | 
        $sRecallAddress = WB_URL.PAGES_DIRECTORY.$GLOBALS['wb']->page['link'].PAGE_EXTENSION;
  | 
      
      
        | 45 | 
        
         | 
        
         | 
        
  | 
      
      
        | 46 | 
        
         | 
        
         | 
        // Get user's username, display name, email, and id - needed for insertion into post info
  | 
      
      
        | 47 | 
        
         | 
        
         | 
        $users = array();
  | 
      
      
        | 48 | 
        
         | 
        
         | 
        $sql = 'SELECT `user_id`,`username`,`display_name`,`email` FROM `'.TABLE_PREFIX.'users`';
  | 
      
      
        | 49 | 
        
         | 
        
         | 
        if (($resUsers = $database->query($sql))) {
 | 
      
      
        | 50 | 
        
         | 
        
         | 
            while ($recUser = $resUsers->fetchRow( MYSQLI_ASSOC )) {
 | 
      
      
        | 51 | 
        
         | 
        
         | 
                $users[$recUser['user_id']] = $recUser;
  | 
      
      
        | 52 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 53 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 54 | 
        
         | 
        
         | 
        // Get all groups (id, title, active, image)
  | 
      
      
        | 55 | 
        
         | 
        
         | 
        $groups = array(
  | 
      
      
        | 56 | 
        
         | 
        
         | 
            0 => array(
  | 
      
      
        | 57 | 
        
         | 
        
         | 
                'group_id'  => 0,
  | 
      
      
        | 58 | 
        
         | 
        
         | 
                'title'     => '',
  | 
      
      
        | 59 | 
        
         | 
        
         | 
                'active'    => true,
  | 
      
      
        | 60 | 
        
         | 
        
         | 
                'image'     => ''
  | 
      
      
        | 61 | 
        
         | 
        
         | 
            )
  | 
      
      
        | 62 | 
        
         | 
        
         | 
        );
  | 
      
      
        | 63 | 
        
         | 
        
         | 
        
  | 
      
      
        | 64 | 
        
         | 
        
         | 
        
  | 
      
      
        | 65 | 
        
         | 
        
         | 
        $sql = 'SELECT `group_id`, `title`, `active` FROM `'.TABLE_PREFIX.'mod_news_groups` '
  | 
      
      
        | 66 | 
        
         | 
        
         | 
             . 'WHERE `section_id`='.(int)$section_id.' '
  | 
      
      
        | 67 | 
        
         | 
        
         | 
             . 'ORDER BY `position` ASC';
  | 
      
      
        | 68 | 
        
         | 
        
         | 
        if (($query_users = $database->query($sql))) {
 | 
      
      
        | 69 | 
        
         | 
        
         | 
            while (($group = $query_users->fetchRow( MYSQLI_ASSOC ))) {
 | 
      
      
        | 70 | 
        
         | 
        
         | 
                // Insert user info into users array
  | 
      
      
        | 71 | 
        
         | 
        
         | 
                $groups[$group['group_id']] = $group;
  | 
      
      
        | 72 | 
        
         | 
        
         | 
                $sImageUrl = MEDIA_DIRECTORY.'/.news/image'.$group['group_id'].'.jpg';
  | 
      
      
        | 73 | 
        
         | 
        
         | 
                $groups[$group['group_id']]['image'] = (is_readable(WB_PATH.$sImageUrl) ? WB_URL.$sImageUrl : '');
  | 
      
      
        | 74 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 75 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 76 | 
        
         | 
        
         | 
            // Check if we should only list posts from a certain group
  | 
      
      
        | 77 | 
        
         | 
        
         | 
            if (isset($_GET['g']) AND is_numeric($_GET['g'])) {
 | 
      
      
        | 78 | 
        
         | 
        
         | 
                $query_extra = 'AND `group_id`='.(int)$_GET['g'].' ';
  | 
      
      
        | 79 | 
        
         | 
        
         | 
            } else {
 | 
      
      
        | 80 | 
        
         | 
        
         | 
                $query_extra = '';
  | 
      
      
        | 81 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 82 | 
        
         | 
        
         | 
            // Get settings
  | 
      
      
        | 83 | 
        
         | 
        
         | 
            $setting_header = $setting_post_loop = $setting_footer = $setting_posts_per_page = '';
  | 
      
      
        | 84 | 
        
         | 
        
         | 
            $sql = 'SELECT `header`, `post_loop`, `footer`, `posts_per_page` '
  | 
      
      
        | 85 | 
        
         | 
        
         | 
                 . 'FROM `'.TABLE_PREFIX.'mod_news_settings` '
  | 
      
      
        | 86 | 
        
         | 
        
         | 
                 . 'WHERE `section_id`='.(int)$section_id;
  | 
      
      
        | 87 | 
        
         | 
        
         | 
            if (($resSettings = $database->query($sql))) {
 | 
      
      
        | 88 | 
        
         | 
        
         | 
                if (($recSettings = $resSettings->fetchRow(MYSQL_ASSOC))) {
 | 
      
      
        | 89 | 
        
         | 
        
         | 
                    foreach ($recSettings as $key=>$val) {
 | 
      
      
        | 90 | 
        
         | 
        
         | 
                        ${'setting_'.$key} = $val;
 | 
      
      
        | 91 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 92 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 93 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 94 | 
        
         | 
        
         | 
            // Get total number of posts relatet to now
  | 
      
      
        | 95 | 
        
         | 
        
         | 
        // Check if we should show the main page or a post itself
  | 
      
      
        | 96 | 
        
         | 
        
         | 
            $now = $t = time();
  | 
      
      
        | 97 | 
        
         | 
        
         | 
            $sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'mod_news_posts` '
  | 
      
      
        | 98 | 
        
         | 
        
         | 
                 . 'WHERE `section_id`='.(int)$section_id.' AND `active`=1 '
  | 
      
      
        | 99 | 
        
         | 
        
         | 
                 .        'AND `title`!=\'\' '
  | 
      
      
        | 100 | 
        
         | 
        
         | 
                 .        'AND (`published_when`=0 OR `published_when`<='.$now.') '
  | 
      
      
        | 101 | 
        
         | 
        
         | 
                 .        'AND (`published_until`=0 OR `published_until`>='.$now.') '
  | 
      
      
        | 102 | 
        
         | 
        
         | 
                 .        $query_extra;
  | 
      
      
        | 103 | 
        
         | 
        
         | 
            $total_num = intval($database->get_one($sql));
  | 
      
      
        | 104 | 
        
         | 
        
         | 
            if ( $total_num && $setting_posts_per_page ) {
 | 
      
      
        | 105 | 
        
         | 
        
         | 
                $iNumberOfPages = (int)($total_num / $setting_posts_per_page)+($total_num % $setting_posts_per_page ? 1:0 );
  | 
      
      
        | 106 | 
        
         | 
        
         | 
                $position  = intval( isset($_GET['p'] ) ? $_GET['p'] : 0 );
  | 
      
      
        | 107 | 
        
         | 
        
         | 
                $position  = abs( ( $position < $total_num) ? $position : ($iNumberOfPages*$setting_posts_per_page) );
  | 
      
      
        | 108 | 
        
         | 
        
         | 
                // Work-out if we need to add limit code to sql
  | 
      
      
        | 109 | 
        
         | 
        
         | 
                $limit_sql = ' LIMIT '.$position.', '.$setting_posts_per_page;
  | 
      
      
        | 110 | 
        
         | 
        
         | 
            } else {
 | 
      
      
        | 111 | 
        
         | 
        
         | 
                $display_previous_next_links = '';
  | 
      
      
        | 112 | 
        
         | 
        
         | 
                $position = 0;
  | 
      
      
        | 113 | 
        
         | 
        
         | 
                $next_link = '';
  | 
      
      
        | 114 | 
        
         | 
        
         | 
                $next_page_link = '';
  | 
      
      
        | 115 | 
        
         | 
        
         | 
                $previous_link = '';
  | 
      
      
        | 116 | 
        
         | 
        
         | 
                $previous_page_link = '';
  | 
      
      
        | 117 | 
        
         | 
        
         | 
                $out_of = '';
  | 
      
      
        | 118 | 
        
         | 
        
         | 
                $of = '';
  | 
      
      
        | 119 | 
        
         | 
        
         | 
                $limit_sql = '';
  | 
      
      
        | 120 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 121 | 
        
         | 
        
         | 
        
  | 
      
      
        | 122 | 
        
         | 
        
         | 
        // if(!defined('POST_ID') OR !is_numeric(POST_ID))
 | 
      
      
        | 123 | 
        
         | 
        
         | 
        if (!isset($post_id) || !is_numeric($post_id)) {
 | 
      
      
        | 124 | 
        
         | 
        
         | 
        /*
  | 
      
      
        | 125 | 
        
         | 
        
         | 
        $setting_posts_per_page = 12/5 = 2 5 = 10
  | 
      
      
        | 126 | 
        
         | 
        
         | 
        */
  | 
      
      
        | 127 | 
        
         | 
        
         | 
            // Query posts (for this page)
  | 
      
      
        | 128 | 
        
         | 
        
         | 
            $sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` '
  | 
      
      
        | 129 | 
        
         | 
        
         | 
                 . 'WHERE `section_id`='.$section_id.' '
  | 
      
      
        | 130 | 
        
         | 
        
         | 
                 .        'AND `active`=1 '
  | 
      
      
        | 131 | 
        
         | 
        
         | 
                 .        'AND `title`!=\'\' '
  | 
      
      
        | 132 | 
        
         | 
        
         | 
                 .        'AND (`published_when`=0 OR `published_when`<='.$now.') '
  | 
      
      
        | 133 | 
        
         | 
        
         | 
                 .        'AND (`published_until`=0 OR `published_until`>='.$now.') '
  | 
      
      
        | 134 | 
        
         | 
        
         | 
                 .        $query_extra
  | 
      
      
        | 135 | 
        
         | 
        
         | 
                 . 'ORDER BY `position` DESC'.$limit_sql;
  | 
      
      
        | 136 | 
        
         | 
        
         | 
            $query_posts = $database->query($sql);
  | 
      
      
        | 137 | 
        
         | 
        
         | 
        //    $total_num = $query_posts->numRows();
  | 
      
      
        | 138 | 
        
         | 
        
         | 
            // Create previous and next links
  | 
      
      
        | 139 | 
        
         | 
        
         | 
        
  | 
      
      
        | 140 | 
        
         | 
        
         | 
            if ($setting_posts_per_page != 0) {
 | 
      
      
        | 141 | 
        
         | 
        
         | 
                $spaces = str_repeat(' ', 25);
 | 
      
      
        | 142 | 
        
         | 
        
         | 
                if ( ($position > 0) && ($position < $total_num) ) {
 | 
      
      
        | 143 | 
        
         | 
        
         | 
                    if (isset($_GET['g']) AND is_numeric($_GET['g'])) {
 | 
      
      
        | 144 | 
        
         | 
        
         | 
                        $pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< ';
  | 
      
      
        | 145 | 
        
         | 
        
         | 
                    } else {
 | 
      
      
        | 146 | 
        
         | 
        
         | 
                        $pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< ';
  | 
      
      
        | 147 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 148 | 
        
         | 
        
         | 
                    $pl_append = '</a>';
  | 
      
      
        | 149 | 
        
         | 
        
         | 
                    $previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append;
  | 
      
      
        | 150 | 
        
         | 
        
         | 
                    $previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append;
  | 
      
      
        | 151 | 
        
         | 
        
         | 
                } else {
 | 
      
      
        | 152 | 
        
         | 
        
         | 
                    $previous_link = $spaces;
  | 
      
      
        | 153 | 
        
         | 
        
         | 
                    $previous_page_link = $spaces;
  | 
      
      
        | 154 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 155 | 
        
         | 
        
         | 
        
  | 
      
      
        | 156 | 
        
         | 
        
         | 
                if ($position + $setting_posts_per_page >= $total_num) {
 | 
      
      
        | 157 | 
        
         | 
        
         | 
                    $next_link = $spaces;
  | 
      
      
        | 158 | 
        
         | 
        
         | 
                    $next_page_link = $spaces;
  | 
      
      
        | 159 | 
        
         | 
        
         | 
                } else {
 | 
      
      
        | 160 | 
        
         | 
        
         | 
                    if (isset($_GET['g']) AND is_numeric($_GET['g'])) {
 | 
      
      
        | 161 | 
        
         | 
        
         | 
                        $nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> ';
  | 
      
      
        | 162 | 
        
         | 
        
         | 
                    } else {
 | 
      
      
        | 163 | 
        
         | 
        
         | 
                        $nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> ';
  | 
      
      
        | 164 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 165 | 
        
         | 
        
         | 
                    $nl_append = ' >></a>';
  | 
      
      
        | 166 | 
        
         | 
        
         | 
                    $next_link = $nl_prepend.$TEXT['NEXT'].$nl_append;
  | 
      
      
        | 167 | 
        
         | 
        
         | 
                    $next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append;
  | 
      
      
        | 168 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 169 | 
        
         | 
        
         | 
                if ($position+$setting_posts_per_page > $total_num) {  //
 | 
      
      
        | 170 | 
        
         | 
        
         | 
                    $num_of = $total_num;
  | 
      
      
        | 171 | 
        
         | 
        
         | 
                } else {
 | 
      
      
        | 172 | 
        
         | 
        
         | 
                    $num_of = $position+$setting_posts_per_page;
  | 
      
      
        | 173 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 174 | 
        
         | 
        
         | 
                if ( ($position >= 0) && ($position < $total_num) ) {
 | 
      
      
        | 175 | 
        
         | 
        
         | 
                    $out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num;
  | 
      
      
        | 176 | 
        
         | 
        
         | 
                    $of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num;
  | 
      
      
        | 177 | 
        
         | 
        
         | 
                    $display_previous_next_links = $spaces;
  | 
      
      
        | 178 | 
        
         | 
        
         | 
                } else {
 | 
      
      
        | 179 | 
        
         | 
        
         | 
                    $display_previous_next_links = 'none';
  | 
      
      
        | 180 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 181 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 182 | 
        
         | 
        
         | 
            if ($total_num=== 0) { // $num_posts
 | 
      
      
        | 183 | 
        
         | 
        
         | 
                $setting_header = '';
  | 
      
      
        | 184 | 
        
         | 
        
         | 
                $setting_post_loop = '';
  | 
      
      
        | 185 | 
        
         | 
        
         | 
                $setting_footer = '';
  | 
      
      
        | 186 | 
        
         | 
        
         | 
                $setting_posts_per_page = '';
  | 
      
      
        | 187 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 188 | 
        
         | 
        
         | 
        
  | 
      
      
        | 189 | 
        
         | 
        
         | 
        // Print header
  | 
      
      
        | 190 | 
        
         | 
        
         | 
            $aPlaceHolders = $addBracket(
  | 
      
      
        | 191 | 
        
         | 
        
         | 
                'DISPLAY_PREVIOUS_NEXT_LINKS',
  | 
      
      
        | 192 | 
        
         | 
        
         | 
                'NEXT_PAGE_LINK',
  | 
      
      
        | 193 | 
        
         | 
        
         | 
                'NEXT_LINK',
  | 
      
      
        | 194 | 
        
         | 
        
         | 
                'PREVIOUS_PAGE_LINK',
  | 
      
      
        | 195 | 
        
         | 
        
         | 
                'PREVIOUS_LINK',
  | 
      
      
        | 196 | 
        
         | 
        
         | 
                'OUT_OF',
  | 
      
      
        | 197 | 
        
         | 
        
         | 
                'OF'
  | 
      
      
        | 198 | 
        
         | 
        
         | 
            );
  | 
      
      
        | 199 | 
        
         | 
        
         | 
            if ($display_previous_next_links == 'none') {
 | 
      
      
        | 200 | 
        
         | 
        
         | 
                $aReplacements = array(
  | 
      
      
        | 201 | 
        
         | 
        
         | 
                    $display_previous_next_links
  | 
      
      
        | 202 | 
        
         | 
        
         | 
                );
  | 
      
      
        | 203 | 
        
         | 
        
         | 
            } else {
 | 
      
      
        | 204 | 
        
         | 
        
         | 
                $aReplacements = array(
  | 
      
      
        | 205 | 
        
         | 
        
         | 
                    $display_previous_next_links,
  | 
      
      
        | 206 | 
        
         | 
        
         | 
                    $next_page_link,
  | 
      
      
        | 207 | 
        
         | 
        
         | 
                    $next_link,
  | 
      
      
        | 208 | 
        
         | 
        
         | 
                    $previous_page_link,
  | 
      
      
        | 209 | 
        
         | 
        
         | 
                    $previous_link,
  | 
      
      
        | 210 | 
        
         | 
        
         | 
                    $out_of,
  | 
      
      
        | 211 | 
        
         | 
        
         | 
                    $of
  | 
      
      
        | 212 | 
        
         | 
        
         | 
                );
  | 
      
      
        | 213 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 214 | 
        
         | 
        
         | 
            print (str_replace($aPlaceHolders, $aReplacements, $setting_header));
  | 
      
      
        | 215 | 
        
         | 
        
         | 
            if ($total_num > 0) // $num_posts
  | 
      
      
        | 216 | 
        
         | 
        
         | 
            {
 | 
      
      
        | 217 | 
        
         | 
        
         | 
                $sScriptUrl = $_SERVER['SCRIPT_NAME'];
  | 
      
      
        | 218 | 
        
         | 
        
         | 
                if ($query_extra != '') {
 | 
      
      
        | 219 | 
        
         | 
        
         | 
                    echo ('<div class="selected-group-title">'
 | 
      
      
        | 220 | 
        
         | 
        
         | 
                         .'<a href="'.htmlspecialchars(strip_tags($sScriptUrl))
  | 
      
      
        | 221 | 
        
         | 
        
         | 
                         .'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']
  | 
      
      
        | 222 | 
        
         | 
        
         | 
                         .'</div>'.PHP_EOL
  | 
      
      
        | 223 | 
        
         | 
        
         | 
                    );
  | 
      
      
        | 224 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 225 | 
        
         | 
        
         | 
        
  | 
      
      
        | 226 | 
        
         | 
        
         | 
                $aPlaceHolders = $addBracket(
  | 
      
      
        | 227 | 
        
         | 
        
         | 
                    'PAGE_TITLE',
  | 
      
      
        | 228 | 
        
         | 
        
         | 
                    'GROUP_ID',
  | 
      
      
        | 229 | 
        
         | 
        
         | 
                    'GROUP_TITLE',
  | 
      
      
        | 230 | 
        
         | 
        
         | 
                    'GROUP_IMAGE',
  | 
      
      
        | 231 | 
        
         | 
        
         | 
                    'DISPLAY_GROUP',
  | 
      
      
        | 232 | 
        
         | 
        
         | 
                    'DISPLAY_IMAGE',
  | 
      
      
        | 233 | 
        
         | 
        
         | 
                    'TITLE',
  | 
      
      
        | 234 | 
        
         | 
        
         | 
                    'SHORT',
  | 
      
      
        | 235 | 
        
         | 
        
         | 
                    'MODI_DATE',
  | 
      
      
        | 236 | 
        
         | 
        
         | 
                    'MODI_TIME',
  | 
      
      
        | 237 | 
        
         | 
        
         | 
                    'CREATED_DATE',
  | 
      
      
        | 238 | 
        
         | 
        
         | 
                    'CREATED_TIME',
  | 
      
      
        | 239 | 
        
         | 
        
         | 
                    'PUBLISHED_DATE',
  | 
      
      
        | 240 | 
        
         | 
        
         | 
                    'PUBLISHED_TIME',
  | 
      
      
        | 241 | 
        
         | 
        
         | 
                    'LINK',
  | 
      
      
        | 242 | 
        
         | 
        
         | 
                    'SHOW_READ_MORE',
  | 
      
      
        | 243 | 
        
         | 
        
         | 
                    'TEXT_READ_MORE',
  | 
      
      
        | 244 | 
        
         | 
        
         | 
                    'USER_ID',
  | 
      
      
        | 245 | 
        
         | 
        
         | 
                    'USERNAME',
  | 
      
      
        | 246 | 
        
         | 
        
         | 
                    'DISPLAY_NAME',
  | 
      
      
        | 247 | 
        
         | 
        
         | 
                    'EMAIL'
  | 
      
      
        | 248 | 
        
         | 
        
         | 
                );
  | 
      
      
        | 249 | 
        
         | 
        
         | 
                $i=0;
  | 
      
      
        | 250 | 
        
         | 
        
         | 
                while (($post = $query_posts->fetchRow( MYSQLI_ASSOC )))
  | 
      
      
        | 251 | 
        
         | 
        
         | 
                {
 | 
      
      
        | 252 | 
        
         | 
        
         | 
                    ++$i;
  | 
      
      
        | 253 | 
        
         | 
        
         | 
                    if (
  | 
      
      
        | 254 | 
        
         | 
        
         | 
                        isset($groups[$post['group_id']]['active']) AND
  | 
      
      
        | 255 | 
        
         | 
        
         | 
                        $groups[$post['group_id']]['active'] != false
  | 
      
      
        | 256 | 
        
         | 
        
         | 
                    ) { // Make sure parent group is active
 | 
      
      
        | 257 | 
        
         | 
        
         | 
                        $uid = $post['posted_by']; // User who last modified the post
  | 
      
      
        | 258 | 
        
         | 
        
         | 
                        // Workout date and time of last modified post
  | 
      
      
        | 259 | 
        
         | 
        
         | 
                        if ($post['published_when'] === '0') {
 | 
      
      
        | 260 | 
        
         | 
        
         | 
                            $post['published_when'] = time();
  | 
      
      
        | 261 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 262 | 
        
         | 
        
         | 
                        if ($post['published_when'] > $post['posted_when']) {
 | 
      
      
        | 263 | 
        
         | 
        
         | 
                            $post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
  | 
      
      
        | 264 | 
        
         | 
        
         | 
                            $post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
  | 
      
      
        | 265 | 
        
         | 
        
         | 
                        } else {
 | 
      
      
        | 266 | 
        
         | 
        
         | 
                            $post_date = date(DATE_FORMAT, $post['posted_when']+TIMEZONE);
  | 
      
      
        | 267 | 
        
         | 
        
         | 
                            $post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
  | 
      
      
        | 268 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 269 | 
        
         | 
        
         | 
                        $publ_date      = date(DATE_FORMAT,$post['published_when']+TIMEZONE);
  | 
      
      
        | 270 | 
        
         | 
        
         | 
                        $publ_time      = date(TIME_FORMAT,$post['published_when']+TIMEZONE);
  | 
      
      
        | 271 | 
        
         | 
        
         | 
                        // Work-out the post link
  | 
      
      
        | 272 | 
        
         | 
        
         | 
                        $post_link      = page_link($post['link']);
  | 
      
      
        | 273 | 
        
         | 
        
         | 
                        $post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
  | 
      
      
        | 274 | 
        
         | 
        
         | 
                        $create_date    = date(DATE_FORMAT, $post['created_when']+TIMEZONE);
  | 
      
      
        | 275 | 
        
         | 
        
         | 
                        $create_time    = date(TIME_FORMAT, $post['created_when']+TIMEZONE);
  | 
      
      
        | 276 | 
        
         | 
        
         | 
                        if (isset($_GET['p']) AND $position > 0) {
 | 
      
      
        | 277 | 
        
         | 
        
         | 
                            $post_link .= '?p='.$position;
  | 
      
      
        | 278 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 279 | 
        
         | 
        
         | 
                        if (isset($_GET['g']) AND is_numeric($_GET['g'])) {
 | 
      
      
        | 280 | 
        
         | 
        
         | 
                            if (isset($_GET['p']) AND $position > 0) {
 | 
      
      
        | 281 | 
        
         | 
        
         | 
                                $post_link .= '&';
  | 
      
      
        | 282 | 
        
         | 
        
         | 
                            } else {
 | 
      
      
        | 283 | 
        
         | 
        
         | 
                                $post_link .= '?';
  | 
      
      
        | 284 | 
        
         | 
        
         | 
                            }
  | 
      
      
        | 285 | 
        
         | 
        
         | 
                            $post_link .= 'g='.$_GET['g'];
  | 
      
      
        | 286 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 287 | 
        
         | 
        
         | 
                        // Get group id, title, and image
  | 
      
      
        | 288 | 
        
         | 
        
         | 
                        $group_id      = $post['group_id'];
  | 
      
      
        | 289 | 
        
         | 
        
         | 
                        $group_title   = $groups[$group_id]['title'];
  | 
      
      
        | 290 | 
        
         | 
        
         | 
                        $group_image   = $groups[$group_id]['image'];
  | 
      
      
        | 291 | 
        
         | 
        
         | 
                        $display_image = ($group_image == '') ? "none" : "inherit";
  | 
      
      
        | 292 | 
        
         | 
        
         | 
                        $display_group = ($group_id == 0) ? 'none' : 'inherit';
  | 
      
      
        | 293 | 
        
         | 
        
         | 
        
  | 
      
      
        | 294 | 
        
         | 
        
         | 
                        if ($group_image != "") {
 | 
      
      
        | 295 | 
        
         | 
        
         | 
                            $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
  | 
      
      
        | 296 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 297 | 
        
         | 
        
         | 
                        // Replace [wblink--PAGE_ID--] with real link
  | 
      
      
        | 298 | 
        
         | 
        
         | 
                        $sMediaUrl = WB_URL.MEDIA_DIRECTORY;
  | 
      
      
        | 299 | 
        
         | 
        
         | 
                        $short = ($post['content_short']);
  | 
      
      
        | 300 | 
        
         | 
        
         | 
                        $short = (str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl, $short));
 | 
      
      
        | 301 | 
        
         | 
        
         | 
                        // Replace vars with values
  | 
      
      
        | 302 | 
        
         | 
        
         | 
        //                $post_long_len = mb_strlen($post['content_long']);
  | 
      
      
        | 303 | 
        
         | 
        
         | 
        //                $bIsEmptyLongContent = (bool)( $post_long_len == 0);
  | 
      
      
        | 304 | 
        
         | 
        
         | 
                        $bIsEmptyLongContent = !(bool)mb_strlen(
  | 
      
      
        | 305 | 
        
         | 
        
         | 
                            trim(preg_replace('/^\s*?<(p|div)>(.*)?<\/\s*?\1>$/si', '\2', $post['content_long']))
 | 
      
      
        | 306 | 
        
         | 
        
         | 
                        );
  | 
      
      
        | 307 | 
        
         | 
        
         | 
                        // set replacements for exchange
  | 
      
      
        | 308 | 
        
         | 
        
         | 
                        $aReplacements = array(
  | 
      
      
        | 309 | 
        
         | 
        
         | 
                            PAGE_TITLE,
  | 
      
      
        | 310 | 
        
         | 
        
         | 
                            $group_id,
  | 
      
      
        | 311 | 
        
         | 
        
         | 
                            $group_title,
  | 
      
      
        | 312 | 
        
         | 
        
         | 
                            $group_image,
  | 
      
      
        | 313 | 
        
         | 
        
         | 
                            $display_group,
  | 
      
      
        | 314 | 
        
         | 
        
         | 
                            $display_image,
  | 
      
      
        | 315 | 
        
         | 
        
         | 
                            $post['title'],
  | 
      
      
        | 316 | 
        
         | 
        
         | 
                            $short,
  | 
      
      
        | 317 | 
        
         | 
        
         | 
                            $post_date,
  | 
      
      
        | 318 | 
        
         | 
        
         | 
                            $post_time,
  | 
      
      
        | 319 | 
        
         | 
        
         | 
                            $create_date,
  | 
      
      
        | 320 | 
        
         | 
        
         | 
                            $create_time,
  | 
      
      
        | 321 | 
        
         | 
        
         | 
                            $publ_date,
  | 
      
      
        | 322 | 
        
         | 
        
         | 
                            $publ_time
  | 
      
      
        | 323 | 
        
         | 
        
         | 
                        );
  | 
      
      
        | 324 | 
        
         | 
        
         | 
                        if (isset($users[$uid]['username']) && $users[$uid]['username'] != '')
  | 
      
      
        | 325 | 
        
         | 
        
         | 
                        {
 | 
      
      
        | 326 | 
        
         | 
        
         | 
                            if ($bIsEmptyLongContent) {
 | 
      
      
        | 327 | 
        
         | 
        
         | 
                                $aReplacements[] = '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;';
  | 
      
      
        | 328 | 
        
         | 
        
         | 
                                $aReplacements[] = 'hidden';
  | 
      
      
        | 329 | 
        
         | 
        
         | 
                                $aReplacements[] = '';
  | 
      
      
        | 330 | 
        
         | 
        
         | 
                                $aReplacements[] = $uid;
  | 
      
      
        | 331 | 
        
         | 
        
         | 
                                $aReplacements[] = $users[$uid]['username'];
  | 
      
      
        | 332 | 
        
         | 
        
         | 
                                $aReplacements[] = $users[$uid]['display_name'];
  | 
      
      
        | 333 | 
        
         | 
        
         | 
                                $aReplacements[] = $users[$uid]['email'];
  | 
      
      
        | 334 | 
        
         | 
        
         | 
                            } else {
 | 
      
      
        | 335 | 
        
         | 
        
         | 
                                $aReplacements[] = $post_link;
  | 
      
      
        | 336 | 
        
         | 
        
         | 
                                $aReplacements[] = 'visible';
  | 
      
      
        | 337 | 
        
         | 
        
         | 
                                $aReplacements[] = $MOD_NEWS['TEXT_READ_MORE'];
  | 
      
      
        | 338 | 
        
         | 
        
         | 
                                $aReplacements[] = $uid;
  | 
      
      
        | 339 | 
        
         | 
        
         | 
                                $aReplacements[] = $users[$uid]['username'];
  | 
      
      
        | 340 | 
        
         | 
        
         | 
                                $aReplacements[] = $users[$uid]['display_name'];
  | 
      
      
        | 341 | 
        
         | 
        
         | 
                                $aReplacements[] = $users[$uid]['email'];
  | 
      
      
        | 342 | 
        
         | 
        
         | 
                            }
  | 
      
      
        | 343 | 
        
         | 
        
         | 
                        } else {
 | 
      
      
        | 344 | 
        
         | 
        
         | 
                            if ($bIsEmptyLongContent) {
 | 
      
      
        | 345 | 
        
         | 
        
         | 
                                $aReplacements[] = '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;';
  | 
      
      
        | 346 | 
        
         | 
        
         | 
                                $aReplacements[] = 'hidden';
  | 
      
      
        | 347 | 
        
         | 
        
         | 
                            } else {
 | 
      
      
        | 348 | 
        
         | 
        
         | 
                                $aReplacements[] = $post_link;
  | 
      
      
        | 349 | 
        
         | 
        
         | 
                                $aReplacements[] = 'visible';
  | 
      
      
        | 350 | 
        
         | 
        
         | 
                                $aReplacements[] = $MOD_NEWS['TEXT_READ_MORE'];
  | 
      
      
        | 351 | 
        
         | 
        
         | 
                            }
  | 
      
      
        | 352 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 353 | 
        
         | 
        
         | 
                        print (str_replace($aPlaceHolders, $aReplacements, $setting_post_loop));
  | 
      
      
        | 354 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 355 | 
        
         | 
        
         | 
        //            if ( $setting_posts_per_page == $i ) { break; }
 | 
      
      
        | 356 | 
        
         | 
        
         | 
                    if ( $setting_posts_per_page && $setting_posts_per_page + $position <= $i ) { break; }
 | 
      
      
        | 357 | 
        
         | 
        
         | 
                } // end while posts
  | 
      
      
        | 358 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 359 | 
        
         | 
        
         | 
            // Print footer
  | 
      
      
        | 360 | 
        
         | 
        
         | 
            $aPlaceHolders = $addBracket(
  | 
      
      
        | 361 | 
        
         | 
        
         | 
                'DISPLAY_PREVIOUS_NEXT_LINKS',
  | 
      
      
        | 362 | 
        
         | 
        
         | 
                'NEXT_PAGE_LINK',
  | 
      
      
        | 363 | 
        
         | 
        
         | 
                'NEXT_LINK',
  | 
      
      
        | 364 | 
        
         | 
        
         | 
                'PREVIOUS_PAGE_LINK',
  | 
      
      
        | 365 | 
        
         | 
        
         | 
                'PREVIOUS_LINK',
  | 
      
      
        | 366 | 
        
         | 
        
         | 
                'OUT_OF',
  | 
      
      
        | 367 | 
        
         | 
        
         | 
                'OF'
  | 
      
      
        | 368 | 
        
         | 
        
         | 
            );
  | 
      
      
        | 369 | 
        
         | 
        
         | 
            if ($display_previous_next_links == 'none') {
 | 
      
      
        | 370 | 
        
         | 
        
         | 
                $aReplacements = array(
  | 
      
      
        | 371 | 
        
         | 
        
         | 
                    $display_previous_next_links
  | 
      
      
        | 372 | 
        
         | 
        
         | 
                );
  | 
      
      
        | 373 | 
        
         | 
        
         | 
            } else {
 | 
      
      
        | 374 | 
        
         | 
        
         | 
                $aReplacements = array(
  | 
      
      
        | 375 | 
        
         | 
        
         | 
                    $display_previous_next_links,
  | 
      
      
        | 376 | 
        
         | 
        
         | 
                    $next_page_link,
  | 
      
      
        | 377 | 
        
         | 
        
         | 
                    $next_link,
  | 
      
      
        | 378 | 
        
         | 
        
         | 
                    $previous_page_link,
  | 
      
      
        | 379 | 
        
         | 
        
         | 
                    $previous_link,
  | 
      
      
        | 380 | 
        
         | 
        
         | 
                    $out_of,
  | 
      
      
        | 381 | 
        
         | 
        
         | 
                    $of
  | 
      
      
        | 382 | 
        
         | 
        
         | 
                );
  | 
      
      
        | 383 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 384 | 
        
         | 
        
         | 
            print (str_replace($aPlaceHolders, $aReplacements, $setting_footer));
  | 
      
      
        | 385 | 
        
         | 
        
         | 
        
  | 
      
      
        | 386 | 
        
         | 
        
         | 
        } elseif(isset($post_id) && is_numeric($post_id)) {
 | 
      
      
        | 387 | 
        
         | 
        
         | 
            if (isset($post_section) && ($post_section == $section_id)) {
 | 
      
      
        | 388 | 
        
         | 
        
         | 
                // Get settings
  | 
      
      
        | 389 | 
        
         | 
        
         | 
                $setting_post_header = $setting_post_footer = $setting_comments_header
  | 
      
      
        | 390 | 
        
         | 
        
         | 
                                     = $setting_comments_loop = $setting_comments_footer = '';
  | 
      
      
        | 391 | 
        
         | 
        
         | 
                $sql = 'SELECT `post_header`, `post_footer`, `comments_header`, `comments_loop`, `comments_footer` '
  | 
      
      
        | 392 | 
        
         | 
        
         | 
                     . 'FROM `'.TABLE_PREFIX.'mod_news_settings` '
  | 
      
      
        | 393 | 
        
         | 
        
         | 
                     . 'WHERE `section_id`='.(int)$section_id;
  | 
      
      
        | 394 | 
        
         | 
        
         | 
                if (($resSettings = $database->query($sql)) ) {
 | 
      
      
        | 395 | 
        
         | 
        
         | 
                    if (($recSettings = $resSettings->fetchRow( MYSQLI_ASSOC ))) {
 | 
      
      
        | 396 | 
        
         | 
        
         | 
                        foreach ($recSettings as $key=>$val) {
 | 
      
      
        | 397 | 
        
         | 
        
         | 
                            ${'setting_'.$key} = $val;
 | 
      
      
        | 398 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 399 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 400 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 401 | 
        
         | 
        
         | 
                // Get page info
  | 
      
      
        | 402 | 
        
         | 
        
         | 
                $sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` '
  | 
      
      
        | 403 | 
        
         | 
        
         | 
                     . 'WHERE `page_id`='.PAGE_ID;
  | 
      
      
        | 404 | 
        
         | 
        
         | 
                $query_page = $database->query($sql);
  | 
      
      
        | 405 | 
        
         | 
        
         | 
                if ($query_page->numRows() > 0) {
 | 
      
      
        | 406 | 
        
         | 
        
         | 
                    $page = $query_page->fetchRow( MYSQLI_ASSOC );
  | 
      
      
        | 407 | 
        
         | 
        
         | 
                    $page_link = page_link($page['link']);
  | 
      
      
        | 408 | 
        
         | 
        
         | 
                    if (isset($_GET['p']) AND $position > 0) {
 | 
      
      
        | 409 | 
        
         | 
        
         | 
                        $page_link .= '?p='.$_GET['p'];
  | 
      
      
        | 410 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 411 | 
        
         | 
        
         | 
                    if (isset($_GET['g']) AND is_numeric($_GET['g'])) {
 | 
      
      
        | 412 | 
        
         | 
        
         | 
                        if (isset($_GET['p']) AND $position > 0) {
 | 
      
      
        | 413 | 
        
         | 
        
         | 
                            $page_link .= '&';
  | 
      
      
        | 414 | 
        
         | 
        
         | 
                        } else {
 | 
      
      
        | 415 | 
        
         | 
        
         | 
                            $page_link .= '?';
  | 
      
      
        | 416 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 417 | 
        
         | 
        
         | 
                        $page_link .= 'g='.$_GET['g'];
  | 
      
      
        | 418 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 419 | 
        
         | 
        
         | 
                } else {
 | 
      
      
        | 420 | 
        
         | 
        
         | 
                    exit($MESSAGE['PAGES_NOT_FOUND']);
  | 
      
      
        | 421 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 422 | 
        
         | 
        
         | 
                // Get post info
  | 
      
      
        | 423 | 
        
         | 
        
         | 
                $t = time();
  | 
      
      
        | 424 | 
        
         | 
        
         | 
                $sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` '
  | 
      
      
        | 425 | 
        
         | 
        
         | 
                     . 'WHERE `post_id`='.$post_id.' AND active=1 '
  | 
      
      
        | 426 | 
        
         | 
        
         | 
                     .        'AND (`published_when`=0 OR `published_when`<='.$t.') '
  | 
      
      
        | 427 | 
        
         | 
        
         | 
                     .        'AND (`published_until`=0 OR `published_until`>='.$t.')';
  | 
      
      
        | 428 | 
        
         | 
        
         | 
                $query_post = $database->query($sql);
  | 
      
      
        | 429 | 
        
         | 
        
         | 
                if ($post = $query_post->fetchRow( MYSQLI_ASSOC )) {
 | 
      
      
        | 430 | 
        
         | 
        
         | 
                    if (isset($groups[$post['group_id']]['active'])
  | 
      
      
        | 431 | 
        
         | 
        
         | 
                        AND $groups[$post['group_id']]['active'] != false
  | 
      
      
        | 432 | 
        
         | 
        
         | 
                    ) { // Make sure parent group is active
 | 
      
      
        | 433 | 
        
         | 
        
         | 
                        $uid = $post['posted_by']; // User who last modified the post
  | 
      
      
        | 434 | 
        
         | 
        
         | 
                        // Workout date and time of last modified post
  | 
      
      
        | 435 | 
        
         | 
        
         | 
                        if ($post['published_when'] === '0') {
 | 
      
      
        | 436 | 
        
         | 
        
         | 
                            $post['published_when'] = time();
  | 
      
      
        | 437 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 438 | 
        
         | 
        
         | 
                        if ($post['published_when'] > $post['posted_when']) {
 | 
      
      
        | 439 | 
        
         | 
        
         | 
                            $post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
  | 
      
      
        | 440 | 
        
         | 
        
         | 
                            $post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
  | 
      
      
        | 441 | 
        
         | 
        
         | 
                        } else {
 | 
      
      
        | 442 | 
        
         | 
        
         | 
                            $post_date = date(DATE_FORMAT, $post['posted_when']+TIMEZONE);
  | 
      
      
        | 443 | 
        
         | 
        
         | 
                            $post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
  | 
      
      
        | 444 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 445 | 
        
         | 
        
         | 
                        $publ_date      = date(DATE_FORMAT,$post['published_when']+TIMEZONE);
  | 
      
      
        | 446 | 
        
         | 
        
         | 
                        $publ_time      = date(TIME_FORMAT,$post['published_when']+TIMEZONE);
  | 
      
      
        | 447 | 
        
         | 
        
         | 
                        // Work-out the post link
  | 
      
      
        | 448 | 
        
         | 
        
         | 
                        $post_link      = page_link($post['link']);
  | 
      
      
        | 449 | 
        
         | 
        
         | 
                        $post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
  | 
      
      
        | 450 | 
        
         | 
        
         | 
                        $create_date    = date(DATE_FORMAT, $post['created_when']+TIMEZONE);
  | 
      
      
        | 451 | 
        
         | 
        
         | 
                        $create_time    = date(TIME_FORMAT, $post['created_when']+TIMEZONE);
  | 
      
      
        | 452 | 
        
         | 
        
         | 
                        // Get group id, title, and image
  | 
      
      
        | 453 | 
        
         | 
        
         | 
                        $group_id       = $post['group_id'];
  | 
      
      
        | 454 | 
        
         | 
        
         | 
                        $group_title    = $groups[$group_id]['title'];
  | 
      
      
        | 455 | 
        
         | 
        
         | 
                        $group_image    = $groups[$group_id]['image'];
  | 
      
      
        | 456 | 
        
         | 
        
         | 
                        $display_image  = ($group_image == '') ? "none" : "inherit";
  | 
      
      
        | 457 | 
        
         | 
        
         | 
                        $display_group  = ($group_id == 0) ? 'none' : 'inherit';
  | 
      
      
        | 458 | 
        
         | 
        
         | 
                        $sMediaUrl = WB_URL.MEDIA_DIRECTORY;
  | 
      
      
        | 459 | 
        
         | 
        
         | 
                        $post_short = ($post['content_short']);
  | 
      
      
        | 460 | 
        
         | 
        
         | 
                        $post_short = (str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl, $post_short));
 | 
      
      
        | 461 | 
        
         | 
        
         | 
                        if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
  | 
      
      
        | 462 | 
        
         | 
        
         | 
        
  | 
      
      
        | 463 | 
        
         | 
        
         | 
                        $aPlaceHolders = $addBracket(
  | 
      
      
        | 464 | 
        
         | 
        
         | 
                            'PAGE_TITLE',
  | 
      
      
        | 465 | 
        
         | 
        
         | 
                            'GROUP_ID',
  | 
      
      
        | 466 | 
        
         | 
        
         | 
                            'GROUP_TITLE',
  | 
      
      
        | 467 | 
        
         | 
        
         | 
                            'GROUP_IMAGE',
  | 
      
      
        | 468 | 
        
         | 
        
         | 
                            'DISPLAY_GROUP',
  | 
      
      
        | 469 | 
        
         | 
        
         | 
                            'DISPLAY_IMAGE',
  | 
      
      
        | 470 | 
        
         | 
        
         | 
                            'TITLE',
  | 
      
      
        | 471 | 
        
         | 
        
         | 
                            'SHORT',
  | 
      
      
        | 472 | 
        
         | 
        
         | 
                            'BACK',
  | 
      
      
        | 473 | 
        
         | 
        
         | 
                            'TEXT_BACK',
  | 
      
      
        | 474 | 
        
         | 
        
         | 
                            'TEXT_LAST_CHANGED',
  | 
      
      
        | 475 | 
        
         | 
        
         | 
                            'MODI_DATE',
  | 
      
      
        | 476 | 
        
         | 
        
         | 
                            'TEXT_AT',
  | 
      
      
        | 477 | 
        
         | 
        
         | 
                            'MODI_TIME',
  | 
      
      
        | 478 | 
        
         | 
        
         | 
                            'CREATED_DATE',
  | 
      
      
        | 479 | 
        
         | 
        
         | 
                            'CREATED_TIME',
  | 
      
      
        | 480 | 
        
         | 
        
         | 
                            'PUBLISHED_DATE',
  | 
      
      
        | 481 | 
        
         | 
        
         | 
                            'PUBLISHED_TIME',
  | 
      
      
        | 482 | 
        
         | 
        
         | 
                            'TEXT_POSTED_BY',
  | 
      
      
        | 483 | 
        
         | 
        
         | 
                            'TEXT_ON',
  | 
      
      
        | 484 | 
        
         | 
        
         | 
                            'USER_ID',
  | 
      
      
        | 485 | 
        
         | 
        
         | 
                            'USERNAME',
  | 
      
      
        | 486 | 
        
         | 
        
         | 
                            'DISPLAY_NAME',
  | 
      
      
        | 487 | 
        
         | 
        
         | 
                            'EMAIL'
  | 
      
      
        | 488 | 
        
         | 
        
         | 
                        );
  | 
      
      
        | 489 | 
        
         | 
        
         | 
                        $aReplacements = array(
  | 
      
      
        | 490 | 
        
         | 
        
         | 
                            PAGE_TITLE,
  | 
      
      
        | 491 | 
        
         | 
        
         | 
                            $group_id,
  | 
      
      
        | 492 | 
        
         | 
        
         | 
                            $group_title,
  | 
      
      
        | 493 | 
        
         | 
        
         | 
                            $group_image,
  | 
      
      
        | 494 | 
        
         | 
        
         | 
                            $display_group,
  | 
      
      
        | 495 | 
        
         | 
        
         | 
                            $display_image,
  | 
      
      
        | 496 | 
        
         | 
        
         | 
                            $post['title'],
  | 
      
      
        | 497 | 
        
         | 
        
         | 
                            $post_short,
  | 
      
      
        | 498 | 
        
         | 
        
         | 
                            $page_link,
  | 
      
      
        | 499 | 
        
         | 
        
         | 
                            $MOD_NEWS['TEXT_BACK'],
  | 
      
      
        | 500 | 
        
         | 
        
         | 
                            $MOD_NEWS['TEXT_LAST_CHANGED'],
  | 
      
      
        | 501 | 
        
         | 
        
         | 
                            $post_date,
  | 
      
      
        | 502 | 
        
         | 
        
         | 
                            $MOD_NEWS['TEXT_AT'],
  | 
      
      
        | 503 | 
        
         | 
        
         | 
                            $post_time,
  | 
      
      
        | 504 | 
        
         | 
        
         | 
                            $create_date,
  | 
      
      
        | 505 | 
        
         | 
        
         | 
                            $create_time,
  | 
      
      
        | 506 | 
        
         | 
        
         | 
                            $publ_date,
  | 
      
      
        | 507 | 
        
         | 
        
         | 
                            $publ_time,
  | 
      
      
        | 508 | 
        
         | 
        
         | 
                            $MOD_NEWS['TEXT_POSTED_BY'],
  | 
      
      
        | 509 | 
        
         | 
        
         | 
                            $MOD_NEWS['TEXT_ON']
  | 
      
      
        | 510 | 
        
         | 
        
         | 
                        );
  | 
      
      
        | 511 | 
        
         | 
        
         | 
                        if (isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
 | 
      
      
        | 512 | 
        
         | 
        
         | 
                            $aReplacements[] = $uid;
  | 
      
      
        | 513 | 
        
         | 
        
         | 
                            $aReplacements[] = $users[$uid]['username'];
  | 
      
      
        | 514 | 
        
         | 
        
         | 
                            $aReplacements[] = $users[$uid]['display_name'];
  | 
      
      
        | 515 | 
        
         | 
        
         | 
                            $aReplacements[] = $users[$uid]['email'];
  | 
      
      
        | 516 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 517 | 
        
         | 
        
         | 
                        $sMediaUrl = WB_URL.MEDIA_DIRECTORY;
  | 
      
      
        | 518 | 
        
         | 
        
         | 
                        $post_long = ($post['content_long'] != '') ? $post['content_long'] : $post['content_short'];
  | 
      
      
        | 519 | 
        
         | 
        
         | 
                        $post_long = (str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl, $post_long));
 | 
      
      
        | 520 | 
        
         | 
        
         | 
                        print (str_replace($aPlaceHolders, $aReplacements, $setting_post_header));
  | 
      
      
        | 521 | 
        
         | 
        
         | 
                        print $post_long;
  | 
      
      
        | 522 | 
        
         | 
        
         | 
                        print (str_replace($aPlaceHolders, $aReplacements, $setting_post_footer));
  | 
      
      
        | 523 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 524 | 
        
         | 
        
         | 
                } else {
 | 
      
      
        | 525 | 
        
         | 
        
         | 
                        $aPlaceHolders = $addBracket(
  | 
      
      
        | 526 | 
        
         | 
        
         | 
                            'BACK',
  | 
      
      
        | 527 | 
        
         | 
        
         | 
                            'TEXT_BACK',
  | 
      
      
        | 528 | 
        
         | 
        
         | 
                            'TEXT_LAST_CHANGED',
  | 
      
      
        | 529 | 
        
         | 
        
         | 
                            'TEXT_AT',
  | 
      
      
        | 530 | 
        
         | 
        
         | 
                            'MODI_DATE',
  | 
      
      
        | 531 | 
        
         | 
        
         | 
                            'MODI_TIME'
  | 
      
      
        | 532 | 
        
         | 
        
         | 
                        );
  | 
      
      
        | 533 | 
        
         | 
        
         | 
                        $aReplacements = array(
  | 
      
      
        | 534 | 
        
         | 
        
         | 
                            $page_link,
  | 
      
      
        | 535 | 
        
         | 
        
         | 
                            $MOD_NEWS['TEXT_BACK'],
  | 
      
      
        | 536 | 
        
         | 
        
         | 
                            $MESSAGE['FRONTEND_SORRY_NO_ACTIVE_SECTIONS'],
  | 
      
      
        | 537 | 
        
         | 
        
         | 
                            '',
  | 
      
      
        | 538 | 
        
         | 
        
         | 
                            ''
  | 
      
      
        | 539 | 
        
         | 
        
         | 
                        );
  | 
      
      
        | 540 | 
        
         | 
        
         | 
                        print (str_replace($aPlaceHolders, $aReplacements, $setting_post_footer));
  | 
      
      
        | 541 | 
        
         | 
        
         | 
        
  | 
      
      
        | 542 | 
        
         | 
        
         | 
        //                $wb->print_error($MESSAGE['FRONTEND_SORRY_NO_ACTIVE_SECTIONS'], $sRecallAddress, false);
  | 
      
      
        | 543 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 544 | 
        
         | 
        
         | 
                // Show comments section if we have to
  | 
      
      
        | 545 | 
        
         | 
        
         | 
                if (($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true)
  | 
      
      
        | 546 | 
        
         | 
        
         | 
                    OR $post['commenting'] == 'public'
  | 
      
      
        | 547 | 
        
         | 
        
         | 
                ) {
 | 
      
      
        | 548 | 
        
         | 
        
         | 
                    // Print comments header
  | 
      
      
        | 549 | 
        
         | 
        
         | 
                    $aPlaceHolders = $addBracket(
  | 
      
      
        | 550 | 
        
         | 
        
         | 
                        'ADD_COMMENT_URL',
  | 
      
      
        | 551 | 
        
         | 
        
         | 
                        'TEXT_COMMENTS'
  | 
      
      
        | 552 | 
        
         | 
        
         | 
                    );
  | 
      
      
        | 553 | 
        
         | 
        
         | 
                    $aReplacements = array(
  | 
      
      
        | 554 | 
        
         | 
        
         | 
                        WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&section_id='.$section_id,
  | 
      
      
        | 555 | 
        
         | 
        
         | 
                        $MOD_NEWS['TEXT_COMMENTS']
  | 
      
      
        | 556 | 
        
         | 
        
         | 
                    );
  | 
      
      
        | 557 | 
        
         | 
        
         | 
                    print (str_replace($aPlaceHolders, $aReplacements, $setting_comments_header));
  | 
      
      
        | 558 | 
        
         | 
        
         | 
                    // Query for comments
  | 
      
      
        | 559 | 
        
         | 
        
         | 
                    $iNumberOfComments = 0;
  | 
      
      
        | 560 | 
        
         | 
        
         | 
                    $aPlaceHolders = $addBracket(
  | 
      
      
        | 561 | 
        
         | 
        
         | 
                        'COMMENT',
  | 
      
      
        | 562 | 
        
         | 
        
         | 
                        'TITLE',
  | 
      
      
        | 563 | 
        
         | 
        
         | 
                        'TEXT_ON',
  | 
      
      
        | 564 | 
        
         | 
        
         | 
                        'DATE',
  | 
      
      
        | 565 | 
        
         | 
        
         | 
                        'TEXT_AT',
  | 
      
      
        | 566 | 
        
         | 
        
         | 
                        'TIME',
  | 
      
      
        | 567 | 
        
         | 
        
         | 
                        'TEXT_BY',
  | 
      
      
        | 568 | 
        
         | 
        
         | 
                        'USER_ID',
  | 
      
      
        | 569 | 
        
         | 
        
         | 
                        'USERNAME',
  | 
      
      
        | 570 | 
        
         | 
        
         | 
                        'DISPLAY_NAME',
  | 
      
      
        | 571 | 
        
         | 
        
         | 
                        'EMAIL'
  | 
      
      
        | 572 | 
        
         | 
        
         | 
                    );
  | 
      
      
        | 573 | 
        
         | 
        
         | 
                    $sql = 'SELECT `title`, `comment`, `commented_when`, `commented_by` '
  | 
      
      
        | 574 | 
        
         | 
        
         | 
                         . 'FROM `'.TABLE_PREFIX.'mod_news_comments` '
  | 
      
      
        | 575 | 
        
         | 
        
         | 
                         . 'WHERE `post_id`='.$post_id.' '
  | 
      
      
        | 576 | 
        
         | 
        
         | 
                         . 'ORDER BY `commented_when` ASC';
  | 
      
      
        | 577 | 
        
         | 
        
         | 
        
  | 
      
      
        | 578 | 
        
         | 
        
         | 
                    if (($query_comments = $database->query($sql))) {
 | 
      
      
        | 579 | 
        
         | 
        
         | 
                        while (($comment = $query_comments->fetchRow( MYSQLI_ASSOC ))) {
 | 
      
      
        | 580 | 
        
         | 
        
         | 
                            $iNumberOfComments++;
  | 
      
      
        | 581 | 
        
         | 
        
         | 
                            // Display Comments without slashes, but with new-line characters
  | 
      
      
        | 582 | 
        
         | 
        
         | 
                            $comment['comment'] = nl2br($wb->strip_slashes($comment['comment']));
  | 
      
      
        | 583 | 
        
         | 
        
         | 
                            $comment['title'] = $wb->strip_slashes($comment['title']);
  | 
      
      
        | 584 | 
        
         | 
        
         | 
                            // Print comments loop
  | 
      
      
        | 585 | 
        
         | 
        
         | 
                            $commented_date = date(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
  | 
      
      
        | 586 | 
        
         | 
        
         | 
                            $commented_time = date(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
  | 
      
      
        | 587 | 
        
         | 
        
         | 
                            $uid = $comment['commented_by'];
  | 
      
      
        | 588 | 
        
         | 
        
         | 
                            $aReplacements = array(
  | 
      
      
        | 589 | 
        
         | 
        
         | 
                                $comment['comment'],
  | 
      
      
        | 590 | 
        
         | 
        
         | 
                                $comment['title'],
  | 
      
      
        | 591 | 
        
         | 
        
         | 
                                $MOD_NEWS['TEXT_ON'],
  | 
      
      
        | 592 | 
        
         | 
        
         | 
                                $commented_date,
  | 
      
      
        | 593 | 
        
         | 
        
         | 
                                $MOD_NEWS['TEXT_AT'],
  | 
      
      
        | 594 | 
        
         | 
        
         | 
                                $commented_time,
  | 
      
      
        | 595 | 
        
         | 
        
         | 
                                $MOD_NEWS['TEXT_BY']
  | 
      
      
        | 596 | 
        
         | 
        
         | 
                            );
  | 
      
      
        | 597 | 
        
         | 
        
         | 
                            if (isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
 | 
      
      
        | 598 | 
        
         | 
        
         | 
                                $aReplacements[] = $uid;
  | 
      
      
        | 599 | 
        
         | 
        
         | 
                                $aReplacements[] = $users[$uid]['username'];
  | 
      
      
        | 600 | 
        
         | 
        
         | 
                                $aReplacements[] = $users[$uid]['display_name'];
  | 
      
      
        | 601 | 
        
         | 
        
         | 
                                $aReplacements[] = $users[$uid]['email'];
  | 
      
      
        | 602 | 
        
         | 
        
         | 
                            } else {
 | 
      
      
        | 603 | 
        
         | 
        
         | 
                                $aReplacements[] = '0';
  | 
      
      
        | 604 | 
        
         | 
        
         | 
                                $aReplacements[] = strtolower($TEXT['UNKNOWN']);
  | 
      
      
        | 605 | 
        
         | 
        
         | 
                                $aReplacements[] = $TEXT['UNKNOWN'];
  | 
      
      
        | 606 | 
        
         | 
        
         | 
                            }
  | 
      
      
        | 607 | 
        
         | 
        
         | 
                            print (str_replace($aPlaceHolders, $aReplacements, $setting_comments_loop));
  | 
      
      
        | 608 | 
        
         | 
        
         | 
                        }
  | 
      
      
        | 609 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 610 | 
        
         | 
        
         | 
                    if (! $iNumberOfComments) {
 | 
      
      
        | 611 | 
        
         | 
        
         | 
                        // Say no comments found
  | 
      
      
        | 612 | 
        
         | 
        
         | 
                        $content = '';
  | 
      
      
        | 613 | 
        
         | 
        
         | 
                        $aReplacements = array(
  | 
      
      
        | 614 | 
        
         | 
        
         | 
                            $MOD_NEWS['NO_COMMENT_FOUND']
  | 
      
      
        | 615 | 
        
         | 
        
         | 
                        );
  | 
      
      
        | 616 | 
        
         | 
        
         | 
                        print (str_replace($aPlaceHolders, $aReplacements, $setting_comments_loop));
  | 
      
      
        | 617 | 
        
         | 
        
         | 
                    }
  | 
      
      
        | 618 | 
        
         | 
        
         | 
                    // Print comments footer
  | 
      
      
        | 619 | 
        
         | 
        
         | 
                    $aPlaceHolders = $addBracket(
  | 
      
      
        | 620 | 
        
         | 
        
         | 
                        'ADD_COMMENT_URL',
  | 
      
      
        | 621 | 
        
         | 
        
         | 
                        'TEXT_ADD_COMMENT',
  | 
      
      
        | 622 | 
        
         | 
        
         | 
                        'TEXT_COMMENTS'
  | 
      
      
        | 623 | 
        
         | 
        
         | 
                    );
  | 
      
      
        | 624 | 
        
         | 
        
         | 
                    $aReplacements = array(
  | 
      
      
        | 625 | 
        
         | 
        
         | 
                        WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&section_id='.$section_id.'&p='.$position,
  | 
      
      
        | 626 | 
        
         | 
        
         | 
                        $MOD_NEWS['TEXT_ADD_COMMENT'],
  | 
      
      
        | 627 | 
        
         | 
        
         | 
                        $MOD_NEWS['TEXT_COMMENTS']
  | 
      
      
        | 628 | 
        
         | 
        
         | 
                    );
  | 
      
      
        | 629 | 
        
         | 
        
         | 
                    print (str_replace($aPlaceHolders, $aReplacements, $setting_comments_footer));
  | 
      
      
        | 630 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 631 | 
        
         | 
        
         | 
                if (ENABLED_ASP) {
 | 
      
      
        | 632 | 
        
         | 
        
         | 
                    $_SESSION['comes_from_view'] = $post_id;
  | 
      
      
        | 633 | 
        
         | 
        
         | 
                    $_SESSION['comes_from_view_time'] = time();
  | 
      
      
        | 634 | 
        
         | 
        
         | 
                }
  | 
      
      
        | 635 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 636 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 637 | 
        
         | 
        
         | 
        unset($addBracket);
  |