/**
  * fetch_data().
  * Prepare the content and save in $this->cfg['content'].
  */
 function fetch_data()
 {
     global $user_info;
     $this->posts = null;
     $this->topics = null;
     $this->isRead = null;
     if (empty($this->cfg['config']['settings']['recentboards'])) {
         $this->cfg['config']['settings']['recentboards'] = null;
     }
     $this->posts = ssi_recentTopics($this->cfg['config']['settings']['numrecent'], null, $this->cfg['config']['settings']['recentboards'], '');
     if (!empty($this->posts)) {
         foreach ($this->posts as $post) {
             $this->topics[] = $post['topic'];
             $this->isRead[$post['topic']] = empty($post['new']) ? '0' : '1';
         }
         // if cache enabled cache the data
         $isRead[$user_info['id']] = $this->isRead;
         $rtopic = isset($_GET['topic']) ? $_GET['topic'] : 0;
         if (isset($isRead[$user_info['id']]) && array_key_exists($rtopic, $isRead[$user_info['id']])) {
             $isRead[$user_info['id']][$rtopic] = '1';
         }
         return array($this->topics, $isRead, $this->posts);
     }
 }
예제 #2
0
function TPortal_recentbox()
{
    global $scripturl, $context, $settings, $txt, $modSettings;
    // is it a number?
    if (!is_numeric($context['TPortal']['recentboxnum'])) {
        $context['TPortal']['recentboxnum'] = '10';
    }
    // leave out the recycle board, if any
    if (isset($modSettings['recycle_board'])) {
        $bb = $modSettings['recycle_board'];
    } else {
        $bb = 0;
    }
    if ($context['TPortal']['useavatar'] == 0) {
        $what = ssi_recentTopics($num_recent = $context['TPortal']['recentboxnum'], $exclude_boards = array($bb), $output_method = 'array');
        // Output the topics
        echo '
		<ul class="recent_topics" style="', isset($context['TPortal']['recentboxscroll']) && $context['TPortal']['recentboxscroll'] == 1 ? 'overflow: auto; height: 20ex;' : '', 'margin: 0; padding: 0;">';
        $coun = 1;
        foreach ($what as $wi => $w) {
            echo '
			<li', $coun < count($what) ? '' : ' style="border: none; margin-bottom: 0;padding-bottom: 0;"', '>
				<a href="' . $w['href'] . '" title="' . $w['subject'] . '">' . $w['short_subject'] . '</a>
				 ', $txt['by'], ' <b>', $w['poster']['link'], '</b> ';
            if (!$w['new']) {
                echo ' <a href="' . $w['href'] . '"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="new" /></a> ';
            }
            echo '<br /><span class="smalltext">[' . $w['time'] . ']</span>
			</li>';
            $coun++;
        }
        echo '
		</ul>';
    } else {
        $what = tp_recentTopics($num_recent = $context['TPortal']['recentboxnum'], $exclude_boards = array($bb), 'array');
        // Output the topics
        $coun = 1;
        echo '
		<ul class="recent_topics" style="', isset($context['TPortal']['recentboxscroll']) && $context['TPortal']['recentboxscroll'] == 1 ? 'overflow: auto; height: 20ex;' : '', 'margin: 0; padding: 0;">';
        foreach ($what as $wi => $w) {
            echo '
			<li', $coun < count($what) ? '' : ' style="border: none; margin-bottom: 0;padding-bottom: 0;"', '>
					<span class="tpavatar"><a href="' . $scripturl . '?action=profile;u=' . $w['poster']['id'] . '">', empty($w['poster']['avatar']) ? '<img src="' . $settings['tp_images_url'] . '/TPguest.png" alt="" />' : $w['poster']['avatar'], '</a></span><a href="' . $w['href'] . '">' . $w['short_subject'] . '</a>
				 ', $txt['by'], ' <b>', $w['poster']['link'], '</b> ';
            if (!$w['new']) {
                echo ' <a href="' . $w['href'] . '"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="new" /></a> ';
            }
            echo '<br /><span class="smalltext">[' . $w['time'] . ']</span>
			</li>';
            $coun++;
        }
        echo '
		</ul>';
    }
}
function template_homepage_sample1_php()
{
    global $txt;
    $topics = ssi_recentTopics(8, null, null, 'array');
    foreach ($topics as $topic) {
        echo '
			<li><a href="', $topic['href'], '">', $topic['subject'], '</a> ', $txt['by'], ' ', $topic['poster']['link'], '</li>';
    }
    unset($topics);
    echo '

		</ul><br />

		<h3>Online Users</h3>';
    ssi_logOnline();
    echo '
	</div>

	<div id="content">';
    ssi_welcome();
    echo '
		<br /><br />

		<h2>News</h2>';
    ssi_boardNews();
    echo '
	</div>';
}
    /**
     * fetch_data.
     * Fetch Messages and Attaches.
     */
    function fetch_data($isRead = null)
    {
        global $context, $smcFunc, $boardurl, $modSettings, $user_info, $txt;
        $this->posts = null;
        $this->attaches = null;
        $this->topics = null;
        $this->isRead = null;
        $this->imgName = '';
        if (isset($this->cfg['config']['settings']['boards']) && !empty($this->cfg['config']['settings']['boards'])) {
            $ssiposts = ssi_recentTopics($this->cfg['config']['settings']['total'], null, $this->cfg['config']['settings']['boards'], '');
            if (!empty($ssiposts)) {
                $msgids = array();
                foreach ($ssiposts as $post) {
                    preg_match('~msg(\\d+)~', $post['href'], $found);
                    $msgids[] = $found[1];
                    $post['msgID'] = $found[1];
                    $this->posts[$found[1]] = $post;
                    $this->topics[] = $post['topic'];
                    $this->isRead[$post['topic']] = !empty($post['is_new']) ? false : true;
                }
                unset($ssiposts);
                // get full messagebody
                $msg = array();
                $request = $smcFunc['db_query']('', '
					SELECT id_msg, body, smileys_enabled
						FROM {db_prefix}messages
					WHERE id_msg IN ({array_int:msgids})', array('msgids' => $msgids));
                // prepare the post..
                while ($row = $smcFunc['db_fetch_assoc']($request)) {
                    $msg = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
                    censorText($msg);
                    $this->posts[$row['id_msg']]['body'] = $msg;
                    // 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[$row['id_msg']]['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[$row['id_msg']]['body'] = substr_replace($this->posts[$row['id_msg']]['body'], $tmp, strpos($this->posts[$row['id_msg']]['body'], $data), $datlen);
                                    } elseif (empty($this->cfg['config']['settings']['disableHSimg']) && empty($context['pmx']['settings']['disableHSonfront'])) {
                                        $this->posts[$row['id_msg']]['body'] = substr_replace($this->posts[$row['id_msg']]['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[$row['id_msg']]['body'], $data), $datlen);
                                    } else {
                                        $this->posts[$row['id_msg']]['body'] = substr_replace($this->posts[$row['id_msg']]['body'], $tmp, strpos($this->posts[$row['id_msg']]['body'], $data), $datlen);
                                    }
                                }
                            }
                        }
                    } elseif (is_numeric($this->cfg['config']['settings']['rescale'])) {
                        $this->posts[$row['id_msg']]['body'] = PortaMx_revoveLinks($this->posts[$row['id_msg']]['body'], false, true);
                    }
                    // teaser enabled ?
                    if (!empty($this->cfg['config']['settings']['teaser'])) {
                        $this->posts[$row['id_msg']]['body'] = PortaMx_Tease_posts($this->posts[$row['id_msg']]['body'], $this->cfg['config']['settings']['teaser'], '', false, false);
                    }
                }
                $smcFunc['db_free_result']($request);
                // 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);
                }
                $isRead[$user_info['id']] = $this->isRead;
                return array($this->topics, $isRead, $this->posts, $this->attaches, $this->imgName);
            }
        }
    }
예제 #5
0
<table style="width: 100%; text-align: left;" border="1" cellpadding="2"
 cellspacing="2">
  <tbody>
    <tr>
      <td style="vertical-align: top;">These are the most recent
threads from the LPmuds.net <a href="http://lpmuds.net/forum/">forum</a>.<br>
      </td>
    </tr>
  </tbody>
</table>
<table style="width: 100%; text-align: left;" border="1" cellpadding="2"
 cellspacing="2">
  <tbody>
    <tr>
      <td style="vertical-align: top;"><?php 
ssi_recentTopics();
?>
<br>
      </td>
    </tr>
  </tbody>
</table>
<br>
</div>
<div id="footerarea" style="text-align: center; padding-bottom: 1ex;">
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
			function smfFooterHighlight(element, value)
			{
				element.src = smf_images_url + "/" + (value ? "h_" : "") + element.id + ".gif";
			}
		// ]]></script><br>
 /**
  * Short description
  *
  * Long description
  *
  * @param
  * @return
  */
 protected function show_recentTopics()
 {
     try {
         $this->loadSSI();
     } catch (Exception $e) {
         throw new \Exception($e->getMessage());
     }
     $this->exclude_boards = unserialize($this->exclude_boards);
     $this->include_boards = unserialize($this->include_boards);
     if ('echo' == $this->output_method) {
         ob_start();
         ssi_recentTopics($this->num_recent, $this->exclude_boards, $this->include_boards, $this->output_method);
         $this->data = ob_get_contents();
         ob_end_clean();
     } else {
         $this->data = ssi_recentTopics($this->num_recent, $this->exclude_boards, $this->include_boards, $this->output_method);
     }
 }
global $smcFunc, $boarddir;
$num_recent = 3;
//limit the consult sql - change if you want
//Load Recent Posts (SSI.php)
require_once $boarddir . '/SSI.php';
$posts = array();
//Ultimate Portal use SMF Cache data... UP it's the best, only "UP", can create this feature
if (!empty($ultimateportalSettings['up_reduce_site_overload'])) {
    if (cache_get_data('bk_top_topics', 1800) === NULL) {
        $posts = ssi_recentTopics($num_recent, null, null, 'array');
        cache_put_data('bk_top_topics', $posts, 1800);
    } else {
        $posts = cache_get_data('bk_top_topics', 1800);
    }
} else {
    $posts = ssi_recentTopics($num_recent, null, null, 'array');
}
echo '
	<table width="100%" border="0" style="font-size:10px;font-weight:bold;">
		';
foreach ($posts as $post) {
    $longTitle = strlen($post['subject']);
    if ($longTitle > 30) {
        $title = substr($post['subject'], 0, 30) . '...';
    } else {
        $title = $post['subject'];
    }
    echo '<tr><td><img src="', $settings['default_images_url'], '/ultimate-portal/icons/arrowup.png" alt="" /></td>	
				<td>
					<a href="' . $post['href'] . '" title="' . $post['subject'] . '">' . $title . '</a>
				</td>