/**
     * fetch_data.
     * Fetch Boards, Topics, Messages and Attaches.
     */
    function fetch_data()
    {
        global $context, $smcFunc, $modSettings, $settings, $boardurl, $scripturl, $txt;
        $boards = !empty($this->cfg['config']['settings']['board']) ? $this->cfg['config']['settings']['board'] : array();
        $this->cfg['config']['settings']['total'] = empty($this->cfg['config']['settings']['total']) ? 1 : $this->cfg['config']['settings']['total'];
        $this->posts = null;
        $this->attaches = null;
        $this->imgName = '';
        if (!empty($boards)) {
            // Load the message icons
            $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled');
            $icon_sources = array();
            foreach ($stable_icons as $icon) {
                $icon_sources[$icon] = 'images_url';
            }
            // find the n post from each board
            $this->cfg['config']['settings']['total'] = empty($this->cfg['config']['settings']['total']) ? 1 : $this->cfg['config']['settings']['total'];
            $msgids = array();
            $curboard = 0;
            $request = $smcFunc['db_query']('', '
				SELECT b.id_board, b.name, t.id_topic, t.num_replies, t.num_views, m.*
				FROM {db_prefix}topics as t
				LEFT JOIN {db_prefix}boards as b ON (t.id_board = b.id_board)
				LEFT JOIN {db_prefix}messages as m ON (t.id_first_msg = m.id_msg)
				WHERE b.id_board IN ({array_int:boards}) AND {query_wanna_see_board}
					' . ($modSettings['postmod_active'] ? ' AND m.approved = {int:approv}' : '') . '
					AND t.id_last_msg >= {int:min_msg}
				ORDER BY b.id_board ASC, t.id_topic DESC', array('boards' => $boards, 'min_msg' => $modSettings['maxMsgID'] - 100 * $this->cfg['config']['settings']['total'], 'approv' => 1));
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                if ($row['id_board'] != $curboard) {
                    $curboard = $row['id_board'];
                    $max = $this->cfg['config']['settings']['total'];
                }
                if (!empty($max)) {
                    $msgids[$row['id_topic']] = $row['id_msg'];
                    $max--;
                    $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
                    // Check that this message icon is there...
                    if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) {
                        $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
                    }
                    censorText($row['subject']);
                    censorText($row['body']);
                    // Rescale inline Images ?
                    if (!empty($this->cfg['config']['settings']['rescale']) || empty($this->cfg['config']['settings']['rescale']) && !is_numeric($this->cfg['config']['settings']['rescale'])) {
                        // find all images
                        if (preg_match_all('~<img[^>]*>~iS', $row['body'], $matches) > 0) {
                            // remove smileys
                            foreach ($matches[0] as $i => $data) {
                                if (strpos($data, $modSettings['smileys_url']) !== false) {
                                    unset($matches[0][$i]);
                                }
                            }
                            // images found?
                            if (count($matches[0]) > 0) {
                                $this->imgName = $this->cfg['blocktype'] . '-' . $this->cfg['id'];
                                if (empty($this->cfg['config']['settings']['rescale'])) {
                                    $fnd = array('~ class?=?"[^"]*"~', '~ alt?=?"[^"]*"~', '~ title?=?"[^"]*"~');
                                } else {
                                    $fnd = array('~ width?=?"\\d+"~', '~ height?=?"\\d+"~', '~ class?=?"[^"]*"~', '~ alt?=?"[^"]*"~', '~ title?=?"[^"]*"~');
                                }
                                // modify the images for highslide
                                foreach ($matches[0] as $i => $data) {
                                    $datlen = strlen($data);
                                    preg_match('~src?=?"([^\\"]*\\")~i', $data, $src);
                                    $alt = substr(strrchr($src[1], '/'), 1);
                                    $alt = str_replace(array('_', '-'), ' ', strtoupper(substr($alt, 0, strrpos($alt, '.'))));
                                    $tmp = str_replace($src[0], ' class="' . $this->imgName . '" alt="' . $alt . '" ' . $src[0], preg_replace($fnd, '', $data));
                                    // highslide disabled?
                                    if (!empty($context['pmx']['settings']['disableHS']) || !empty($context['pmx']['settings']['disableHSonfront'])) {
                                        $row['body'] = substr_replace($row['body'], $tmp, strpos($row['body'], $data), $datlen);
                                    } elseif (empty($this->cfg['config']['settings']['disableHSimg']) && empty($context['pmx']['settings']['disableHSonfront'])) {
                                        $row['body'] = substr_replace($row['body'], '<a href="' . $boardurl . '" class="' . $this->imgName . ' highslide" title="' . $txt['pmx_hs_expand'] . '" onclick="return hs.expand(this, {src: \'' . str_replace('"', '', $src[1]) . '\', align: \'center\', headingEval: \'this.thumb.alt\'})">' . $tmp . '</a>', strpos($row['body'], $data), $datlen);
                                    } else {
                                        $row['body'] = substr_replace($row['body'], $tmp, strpos($row['body'], $data), $datlen);
                                    }
                                }
                            }
                        }
                    } elseif (is_numeric($this->cfg['config']['settings']['rescale'])) {
                        $row['body'] = PortaMx_revoveLinks($row['body'], false, true);
                    }
                    // teaser enabled ?
                    if (!empty($this->cfg['config']['settings']['teaser'])) {
                        $row['body'] = PortaMx_Tease_posts($row['body'], $this->cfg['config']['settings']['teaser'], '', false, false);
                    }
                    $this->posts[] = array('id_board' => $row['id_board'], 'board_name' => $row['name'], 'id' => $row['id_topic'], 'message_id' => $row['id_msg'], 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.png" alt="' . $row['icon'] . '" />', 'subject' => $row['subject'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'body' => $row['body'], 'replies' => $row['num_replies'], 'views' => $row['num_views'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '', 'link' => !empty($row['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>' : $row['poster_name']), 'locked' => !empty($row['locked']));
                }
            }
            $smcFunc['db_free_result']($request);
            // any post found?
            if (!is_null($this->posts)) {
                // get attachments if show thumnails set
                $allow_boards = boardsAllowedTo('view_attachments');
                if (!empty($this->cfg['config']['settings']['thumbs']) && !empty($allow_boards)) {
                    $request = $smcFunc['db_query']('', '
						SELECT a.id_msg, a.id_attach, a.id_thumb, a.filename, m.id_topic
						FROM {db_prefix}attachments AS a
						LEFT JOIN {db_prefix}messages AS m ON (a.id_msg = m.id_msg)
						WHERE a.id_msg IN({array_int:messages}) AND a.mime_type LIKE {string:like}' . ($allow_boards === array(0) ? '' : (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : ' AND m.approved = 1 AND a.approved = 1') . ' AND m.id_board IN ({array_int:boards})') . '
						ORDER BY m.id_msg DESC, a.id_attach ASC', array('messages' => $msgids, 'like' => 'IMAGE%', 'boards' => $allow_boards));
                    $thumbs = array();
                    $msgcnt = array();
                    $saved = !empty($this->cfg['config']['settings']['thumbcnt']) ? $this->cfg['config']['settings']['thumbcnt'] : 0;
                    while ($row = $smcFunc['db_fetch_assoc']($request)) {
                        if (!in_array($row['id_attach'], $thumbs)) {
                            if (!empty($this->cfg['config']['settings']['thumbcnt'])) {
                                if (!in_array($row['id_msg'], $msgcnt)) {
                                    $saved = $this->cfg['config']['settings']['thumbcnt'];
                                } elseif (in_array($row['id_msg'], $msgcnt) && empty($saved)) {
                                    continue;
                                }
                            }
                            $saved--;
                            $msgcnt[] = $row['id_msg'];
                            $thumbs[] = $row['id_thumb'];
                            $this->attaches[$row['id_msg']][] = array('topic' => $row['id_topic'], 'image' => $row['id_attach'], 'thumb' => empty($row['id_thumb']) ? $row['id_attach'] : $row['id_thumb'], 'fname' => str_replace('_thumb', '', $row['filename']));
                        }
                    }
                    $smcFunc['db_free_result']($request);
                }
            }
        }
    }
    /**
     * fetch_data.
     * Fetch Messages and Attaches.
     */
    function fetch_data()
    {
        global $context, $scripturl, $boardurl, $smcFunc, $settings, $modSettings, $txt;
        // init vars
        $this->posts = null;
        $this->attaches = null;
        $this->imgName = '';
        $posts = null;
        // get messages by posts
        if ($this->cfg['config']['settings']['selectby'] == 'posts') {
            // check ALL posts set
            if (in_array('0', $this->cfg['config']['settings']['posts'])) {
                $posts = $context['pmx']['promotes'];
            } else {
                $posts = $this->cfg['config']['settings']['posts'];
            }
        } elseif (!empty($this->cfg['config']['settings']['boards'])) {
            $request = $smcFunc['db_query']('', '
				SELECT m.id_msg
				FROM {db_prefix}messages AS m
				INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
				WHERE m.id_msg IN ({array_int:posts}) AND b.id_board IN ({array_int:boards}) AND {query_wanna_see_board}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : ' AND m.approved = 1') . '', array('boards' => $this->cfg['config']['settings']['boards'], 'posts' => $context['pmx']['promotes']));
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                $posts[] = $row['id_msg'];
            }
            $smcFunc['db_free_result']($request);
        }
        // posts found?
        if (!empty($posts)) {
            $request = $smcFunc['db_query']('', '
				SELECT m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg, m.id_board, m.body, m.smileys_enabled, m.icon,
					b.name AS board_name, CASE WHEN mem.real_name = {string:empty} THEN m.poster_name ELSE mem.real_name END AS poster_name, t.num_views, t.num_replies
				FROM {db_prefix}messages AS m
				LEFT JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
				LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic AND t.id_board = b.id_board)
				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
				WHERE m.id_msg IN ({array_int:messages}) AND {query_wanna_see_board}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : ' AND m.approved = 1') . '
				ORDER BY m.id_msg DESC', array('messages' => $posts, 'empty' => ''));
            // prepare the post..
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) {
                    $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
                }
                $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
                censorText($row['subject']);
                censorText($row['body']);
                // Rescale inline Images ?
                if (!empty($this->cfg['config']['settings']['rescale']) || empty($this->cfg['config']['settings']['rescale']) && !is_numeric($this->cfg['config']['settings']['rescale'])) {
                    // find all images
                    if (preg_match_all('~<img[^>]*>~iS', $row['body'], $matches) > 0) {
                        // remove smileys
                        foreach ($matches[0] as $i => $data) {
                            if (strpos($data, $modSettings['smileys_url']) !== false) {
                                unset($matches[0][$i]);
                            }
                        }
                        // images found?
                        if (count($matches[0]) > 0) {
                            $this->imgName = $this->cfg['blocktype'] . '_' . $this->cfg['id'];
                            if (empty($this->cfg['config']['settings']['rescale'])) {
                                $fnd = array('~ class?=?"[^"]*"~', '~ alt?=?"[^"]*"~', '~ title?=?"[^"]*"~');
                            } else {
                                $fnd = array('~ width?=?"\\d+"~', '~ height?=?"\\d+"~', '~ class?=?"[^"]*"~', '~ alt?=?"[^"]*"~', '~ title?=?"[^"]*"~');
                            }
                            // modify the images for highslide
                            foreach ($matches[0] as $i => $data) {
                                $datlen = strlen($data);
                                preg_match('~src?=?"([^\\"]*\\")~i', $data, $src);
                                $alt = substr(strrchr($src[1], '/'), 1);
                                $alt = str_replace(array('_', '-'), ' ', strtoupper(substr($alt, 0, strrpos($alt, '.'))));
                                $tmp = str_replace($src[0], ' class="' . $this->imgName . '" alt="' . $alt . '" ' . $src[0], preg_replace($fnd, '', $data));
                                // highslide disabled?
                                if (!empty($context['pmx']['settings']['disableHS']) || !empty($context['pmx']['settings']['disableHSonfront'])) {
                                    $row['body'] = substr_replace($row['body'], $tmp, strpos($row['body'], $data), $datlen);
                                } elseif (empty($this->cfg['config']['settings']['disableHSimg']) && empty($context['pmx']['settings']['disableHSonfront'])) {
                                    $row['body'] = substr_replace($row['body'], '<a href="' . $boardurl . '" class="' . $this->imgName . ' highslide" title="' . $txt['pmx_hs_expand'] . '" onclick="return hs.expand(this, {src: \'' . str_replace('"', '', $src[1]) . '\', align: \'center\', headingEval: \'this.thumb.alt\'})">' . $tmp . '</a>', strpos($row['body'], $data), $datlen);
                                } else {
                                    $row['body'] = substr_replace($row['body'], $tmp, strpos($row['body'], $data), $datlen);
                                }
                            }
                        }
                    }
                } elseif (is_numeric($this->cfg['config']['settings']['rescale'])) {
                    $row['body'] = PortaMx_revoveLinks($row['body'], false, true);
                }
                // teaser enabled ?
                if (!empty($this->cfg['config']['settings']['teaser'])) {
                    $row['body'] = PortaMx_Tease_posts($row['body'], $this->cfg['config']['settings']['teaser']);
                }
                // build the posts array
                $this->posts[$row['id_msg']] = array('id' => $row['id_msg'], 'board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'topic' => array('id' => $row['id_topic'], 'views' => $row['num_views'], 'replies' => $row['num_replies']), 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.png" alt="' . $row['icon'] . '" />', 'body' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>');
            }
            $smcFunc['db_free_result']($request);
            // get attachments if show thumnails set and user have show access
            $allow_boards = boardsAllowedTo('view_attachments');
            if (!empty($this->cfg['config']['settings']['thumbs']) && !empty($allow_boards)) {
                $request = $smcFunc['db_query']('', '
					SELECT a.id_msg, a.id_attach, a.id_thumb, a.filename, m.id_topic
					FROM {db_prefix}attachments AS a
					LEFT JOIN {db_prefix}messages AS m ON (a.id_msg = m.id_msg)
					WHERE a.id_msg IN({array_int:messages}) AND a.mime_type LIKE {string:like}' . ($allow_boards === array(0) ? '' : (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : ' AND m.approved = 1 AND a.approved = 1') . ' AND m.id_board IN ({array_int:boards})') . '
					ORDER BY m.id_msg DESC, a.id_attach ASC', array('messages' => $posts, 'like' => 'IMAGE%', 'boards' => $allow_boards));
                $thumbs = array();
                $msgcnt = array();
                $saved = !empty($this->cfg['config']['settings']['thumbcnt']) ? $this->cfg['config']['settings']['thumbcnt'] : 0;
                // check the count and put attaches to the array
                while ($row = $smcFunc['db_fetch_assoc']($request)) {
                    if (!in_array($row['id_attach'], $thumbs)) {
                        if (!empty($this->cfg['config']['settings']['thumbcnt'])) {
                            if (!in_array($row['id_msg'], $msgcnt)) {
                                $saved = $this->cfg['config']['settings']['thumbcnt'];
                            } elseif (in_array($row['id_msg'], $msgcnt) && empty($saved)) {
                                continue;
                            }
                        }
                        $saved--;
                        $msgcnt[] = $row['id_msg'];
                        $thumbs[] = $row['id_thumb'];
                        $this->attaches[$row['id_msg']][] = array('topic' => $row['id_topic'], 'image' => $row['id_attach'], 'thumb' => empty($row['id_thumb']) ? $row['id_attach'] : $row['id_thumb'], 'fname' => str_replace('_thumb', '', $row['filename']));
                    }
                }
                $smcFunc['db_free_result']($request);
            }
        } else {
            $this->visible = false;
        }
        // return the post
        return $posts;
    }
    /**
     * fetch_data.
     * Fetch Boards, Topics, Messages and Attaches.
     */
    function fetch_data()
    {
        global $context, $smcFunc, $modSettings, $boardurl, $txt;
        $this->boards = null;
        $this->attaches = null;
        $this->imgName = '';
        if (isset($this->cfg['config']['settings']['board']) && !empty($this->cfg['config']['settings']['board'])) {
            $this->posts = ssi_boardNews($this->cfg['config']['settings']['board'], $this->cfg['config']['settings']['total'], null, null, '');
            if (!empty($this->posts)) {
                $topics = null;
                $msgids = null;
                foreach ($this->posts as $id => $post) {
                    $topics[] = $post['id'];
                    $msgids[] = $post['message_id'];
                    // Rescale inline Images ?
                    if (!empty($this->cfg['config']['settings']['rescale']) || empty($this->cfg['config']['settings']['rescale']) && !is_numeric($this->cfg['config']['settings']['rescale'])) {
                        // find all images
                        if (preg_match_all('~<img[^>]*>~iS', $this->posts[$id]['body'], $matches) > 0) {
                            // remove smileys
                            foreach ($matches[0] as $i => $data) {
                                if (strpos($data, $modSettings['smileys_url']) !== false) {
                                    unset($matches[0][$i]);
                                }
                            }
                            // images found?
                            if (count($matches[0]) > 0) {
                                $this->imgName = $this->cfg['blocktype'] . '-' . $this->cfg['id'];
                                if (empty($this->cfg['config']['settings']['rescale'])) {
                                    $fnd = array('~ class?=?"[^"]*"~', '~ alt?=?"[^"]*"~', '~ title?=?"[^"]*"~');
                                } else {
                                    $fnd = array('~ width?=?"\\d+"~', '~ height?=?"\\d+"~', '~ class?=?"[^"]*"~', '~ alt?=?"[^"]*"~', '~ title?=?"[^"]*"~');
                                }
                                // modify the images for highslide
                                foreach ($matches[0] as $i => $data) {
                                    $datlen = strlen($data);
                                    preg_match('~src?=?"([^\\"]*\\")~i', $data, $src);
                                    $alt = substr(strrchr($src[1], '/'), 1);
                                    $alt = str_replace(array('_', '-'), ' ', strtoupper(substr($alt, 0, strrpos($alt, '.'))));
                                    $tmp = str_replace($src[0], ' class="' . $this->imgName . '" alt="' . $alt . '" ' . $src[0], preg_replace($fnd, '', $data));
                                    // highslide disabled?
                                    if (!empty($context['pmx']['settings']['disableHS']) || !empty($context['pmx']['settings']['disableHSonfront'])) {
                                        $this->posts[$id]['body'] = substr_replace($this->posts[$id]['body'], $tmp, strpos($this->posts[$id]['body'], $data), $datlen);
                                    } elseif (empty($this->cfg['config']['settings']['disableHSimg']) && empty($context['pmx']['settings']['disableHSonfront'])) {
                                        $this->posts[$id]['body'] = substr_replace($this->posts[$id]['body'], '<a href="' . $boardurl . '" class="' . $this->imgName . ' highslide" title="' . $txt['pmx_hs_expand'] . '" onclick="return hs.expand(this, {src: \'' . str_replace('"', '', $src[1]) . '\', align: \'center\', headingEval: \'this.thumb.alt\'})">' . $tmp . '</a>', strpos($this->posts[$id]['body'], $data), $datlen);
                                    } else {
                                        $this->posts[$id]['body'] = substr_replace($this->posts[$id]['body'], $tmp, strpos($this->posts[$id]['body'], $data), $datlen);
                                    }
                                }
                            }
                        }
                    } elseif (is_numeric($this->cfg['config']['settings']['rescale'])) {
                        $this->posts[$id]['body'] = PortaMx_revoveLinks($this->posts[$id]['body'], false, true);
                    }
                    // teaser enabled ?
                    if (!empty($this->cfg['config']['settings']['teaser'])) {
                        $this->posts[$id]['body'] = PortaMx_Tease_posts($this->posts[$id]['body'], $this->cfg['config']['settings']['teaser']);
                    }
                }
                // get attachments if show thumnails set
                $allow_boards = boardsAllowedTo('view_attachments');
                if (!empty($this->cfg['config']['settings']['thumbs']) && !empty($allow_boards)) {
                    $request = $smcFunc['db_query']('', '
						SELECT a.id_msg, a.id_attach, a.id_thumb, a.filename, m.id_topic
						FROM {db_prefix}attachments AS a
						LEFT JOIN {db_prefix}messages AS m ON (a.id_msg = m.id_msg)
						WHERE a.id_msg IN({array_int:messages}) AND a.mime_type LIKE {string:like}' . ($allow_boards === array(0) ? '' : (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : ' AND m.approved = 1 AND a.approved = 1') . ' AND m.id_board IN ({array_int:boards})') . '
						ORDER BY a.id_msg DESC, a.id_attach ASC', array('messages' => $msgids, 'like' => 'IMAGE%', 'boards' => $allow_boards));
                    $thumbs = array();
                    $msgcnt = array();
                    $saved = !empty($this->cfg['config']['settings']['thumbcnt']) ? $this->cfg['config']['settings']['thumbcnt'] : 0;
                    while ($row = $smcFunc['db_fetch_assoc']($request)) {
                        if (!in_array($row['id_attach'], $thumbs)) {
                            if (!empty($this->cfg['config']['settings']['thumbcnt'])) {
                                if (!in_array($row['id_msg'], $msgcnt)) {
                                    $saved = $this->cfg['config']['settings']['thumbcnt'];
                                } elseif (in_array($row['id_msg'], $msgcnt) && empty($saved)) {
                                    continue;
                                }
                            }
                            $saved--;
                            $msgcnt[] = $row['id_msg'];
                            $thumbs[] = $row['id_thumb'];
                            $this->attaches[$row['id_msg']][] = array('topic' => $row['id_topic'], 'image' => $row['id_attach'], 'thumb' => empty($row['id_thumb']) ? $row['id_attach'] : $row['id_thumb'], 'fname' => str_replace('_thumb', '', $row['filename']));
                        }
                    }
                    $smcFunc['db_free_result']($request);
                }
                // get boards and views
                $request = $smcFunc['db_query']('', '
					SELECT b.id_board, b.name, t.id_topic, t.num_views
						FROM {db_prefix}boards b
						LEFT JOIN {db_prefix}topics t ON (t.id_board = b.id_board)
					WHERE t.id_topic IN ({array_int:topics})
						AND t.approved = 1', array('topics' => $topics));
                $this->boards = null;
                while ($row = $smcFunc['db_fetch_assoc']($request)) {
                    $this->boards[$row['id_topic']] = array('id_board' => $row['id_board'], 'boardname' => $row['name'], 'views' => $row['num_views']);
                }
                $smcFunc['db_free_result']($request);
            }
        }
    }
    /**
     * Show one Post.
     */
    function pmxc_ShowPost($pid, $post, $setQE, $lastrow, $setid)
    {
        global $context, $txt;
        if ($this->cfg['config']['visuals']['postheader'] == 'as_body') {
            $this->cfg['config']['visuals']['postheader'] = '';
        }
        // the post main division..
        if ($this->cfg['config']['visuals']['postbody'] == 'none' && $this->cfg['config']['visuals']['postframe'] != 'none') {
            $this->cfg['config']['visuals']['postbody'] = 'windowbg nobg';
        }
        $frameClass = ($this->cfg['config']['visuals']['postframe'] == 'pmxborder' ? 'border ' : '') . $this->cfg['config']['visuals']['postbody'] . ' blockcontent ' . $this->cfg['config']['visuals']['postframe'] . ' fr_' . $this->cfg['config']['visuals']['postheader'];
        echo '
						<div' . (!empty($setid) ? ' id="bot' . $this->cfg['uniID'] . '"' : '') . ' style="margin-' . (!empty($this->is_Split) ? (!empty($this->half) ? 'right' : 'left') . ':' . $this->halfpad . 'px; margin-' : '') . (empty($lastrow) ? 'bottom:0' : 'bottom:' . $this->fullpad) . 'px;' . (!empty($newRow) ? ' margin-top:-' . $this->halfpad . 'px;' : '') . '">';
        // post header .. can have none, titlebg/catbg or as body
        if (empty($this->cfg['config']['visuals']['postheader']) || $this->cfg['config']['visuals']['postheader'] == 'none') {
            // no postframe, use bodyclass if set
            $frameClass = strpos($frameClass, 'windowbg2') !== false ? str_replace('windowbg2', 'windowbg', $frameClass) : str_replace('windowbg', 'windowbg2', $frameClass);
            echo '
							<div class="' . $frameClass . ' roundtitle" style="padding:' . ($this->cfg['config']['visuals']['postheader'] == 'none' ? '0px 5px 4px 5px' : '5px 5px 4px 5px') . ' !important;">';
            // cols set to equal height?
            if (!empty($setQE)) {
                echo '
							<div class="' . $setQE . '">';
            }
            // postheader .. icon and subject
            if (empty($this->cfg['config']['visuals']['postheader'])) {
                echo '
							<div class="pmx_postheader">
								<img style="float:left;" src="' . $context['pmx_imageurl'] . 'rssfeed.gif" alt="*" title="" />
								<span class="normaltext cat_msg_title rss_feed">';
                if (!empty($post['tlink']) || !empty($post['slink'])) {
                    echo '
									<a href="' . (!empty($post['tlink']) ? $post['tlink'] : $post['slink']) . '" target="_blank" title="' . str_replace('"', '\\"', $post['subject']) . '"><b>' . $post['subject'] . '</b></a>';
                } else {
                    echo $post['subject'];
                }
                echo '
								</span>
							</div>';
            }
        } else {
            echo '
							<div class="' . str_replace('bg', '_bar', $this->cfg['config']['visuals']['postheader']) . ' catbg_grid">
								<h4 class="' . $this->cfg['config']['visuals']['postheader'] . ' catbg_grid">
								<img style="float:left;" src="' . $context['pmx_imageurl'] . 'rssfeed.gif" alt="*" title="" />
								<span class="normaltext cat_msg_title rss_feed">';
            if (!empty($post['tlink']) || !empty($post['slink'])) {
                echo '
									<a href="' . (!empty($post['tlink']) ? $post['tlink'] : $post['slink']) . '" target="_blank" title="' . str_replace('"', '\\"', $post['subject']) . '">' . $post['subject'] . '</a>';
            } else {
                echo $post['subject'];
            }
            echo '
								</span>
								</h4>
							</div>
							<div class="' . $frameClass . '" style="padding:' . (empty($this->cfg['config']['visuals']['postframe']) && empty($this->cfg['config']['visuals']['postbody']) ? '2px 0' : '0px 5px 4px 5px') . ' !important;">';
            // cols set to equal height?
            if (!empty($setQE)) {
                echo '
							<div class="' . $setQE . '">';
            }
        }
        if ($this->cfg['config']['visuals']['postheader'] != 'none') {
            if (!empty($post['poster'])) {
                echo $txt['pmx_text_postby'];
                if (!empty($post['plink'])) {
                    echo '
									<a href="' . $post['plink'] . '" target="_blank">' . $post['poster'] . '</a>';
                } else {
                    echo $post['poster'];
                }
            }
            if (!empty($post['date'])) {
                if (empty($post['poster'])) {
                    echo $txt['pmx_rssreader_postat'];
                } else {
                    echo ', ';
                }
                echo $post['date'];
            }
            if (!empty($post['board']) || !empty($post['category'])) {
                echo '<br />' . (!empty($post['board']) ? $txt['pmx_text_board'] . (!empty($post['blink']) ? '<a href="' . $post['blink'] . '" target="_blank">' . $post['board'] . '</a>' : $post['board']) : $txt['pmx_text_category'] . $post['category']);
            }
            echo '
									<hr class="pmx_hrclear" />';
        }
        echo '
									<div class="' . $this->cfg['config']['visuals']['bodytext'] . '" style="overflow:hidden;">';
        if (!empty($this->cfg['config']['settings']['cont_encode']) && !empty($post['contenc'])) {
            if (!empty($this->cfg['config']['settings']['delimage'])) {
                $post['contenc'] = PortaMx_revoveLinks($post['contenc'], false, true);
            }
            if (!empty($this->cfg['config']['settings']['teaser'])) {
                echo PortaMx_Tease_posts($post['contenc'], $this->cfg['config']['settings']['teaser']);
            } else {
                echo $post['contenc'];
            }
        } else {
            if (!empty($this->cfg['config']['settings']['delimage'])) {
                $post['message'] = PortaMx_revoveLinks($post['message'], false, true);
            }
            if (!empty($this->cfg['config']['settings']['teaser'])) {
                echo PortaMx_Tease_posts($post['message'], $this->cfg['config']['settings']['teaser'], '', false, !empty($this->cfg['config']['settings']['delimages']));
            } else {
                echo $post['message'];
            }
        }
        echo '
									</div>';
        // close the equal height div is set
        if (!empty($setQE)) {
            echo '
								</div>';
        }
        // the read more link..
        if (!empty($post['slink'])) {
            echo '
							<div class="smalltext  pmxp_button">
								<a style="float:left;" href="' . $post['slink'] . '" target="_blank">' . $txt['pmx_text_readmore'] . '</a>
							</div>';
        }
        echo '
						</div>
					</div>';
    }