<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.8
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 0; // ENABLE - 1 | DISABLE - 2
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height = "150px";
$scrollbar = 0; // ENABLE - 1 | DISABLE - 2
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context, $txt;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, IFNULL(u.real_name, m.poster_name) AS poster_name, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
(IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS is_read,
IFNULL(lb.id_msg, -1) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)' . ($user_info['is_guest'] ? '' : '
LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})') . '
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
'current_member' => $user_info['id'],
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $txt['board'] . ': ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read']),
'subject_new' => $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new'
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, IFNULL(u.real_name, m.poster_name) AS poster_name, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
(IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS is_read,
IFNULL(lb.id_msg, -1) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)' . ($user_info['is_guest'] ? '' : '
LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})') . '
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
'current_member' => $user_info['id'],
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $txt['board'] . ': ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read']),
'subject_new' => $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new'
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
if ($scrollbar == 1)
echo '<div style="height:' . $height . '; overflow-y: scroll; overflow-x: hidden;">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <a href=' . $post['subject_new'] . '><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" /></a>';
echo '<br />
<small>' . $txt['by'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrollbar == 1)
echo '</div>';
if ($scrolling == 1)
echo '</marquee></div>';
?>
<?php
/*
Block: Recent posts with post preview [JavaScript Version]
Author: Blue @ Simple Portal.net
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 2; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
// Scroll Enable? If you want to change the Height go to marquee.css | If speed go to marquee.js
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
WHERE m.approved=1
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
WHERE m.approved=1
ORDER BY m.id_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1) {
echo '
<script src="marquee/marquee.js" type="text/javascript"></script>
<div style="width: auto; height:150px; overflow:hidden;" id="marquee_replacement" onmouseout="startit();" onmouseover="stop();">
<p style="height:150px;"></p>
';
}
foreach ($posts as $post) {
if (allowedTo('my_board_permission', $post['idboard'])) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'] .'<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>
' . $preview .'...
<hr />';
}
}
//Scrolling xD
if ($scrolling == 1) {
echo '
<p style="height:150px;"></p>
</div>
';
}
?>
<marquee behavior="scroll" direction="left">Your scrolling text goes here</marquee>
see more here: http://www.quackit.com/html/codes/html_marquee_code.cfm (http://www.quackit.com/html/codes/html_marquee_code.cfm)[html]<marquee behavior="scroll" direction="left">Your scrolling text goes here</marquee>[/html]
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 2; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "150px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1
ORDER BY m.id_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>
' . htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") .'...
<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee>';
?>
only the administrator can see????
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.2
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 2; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "150px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1
ORDER BY m.id_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>
' . $preview .'...
<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee>';
?>
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.2
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 2; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "150px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1
ORDER BY m.id_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>
' . htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") .'...
<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee>';
?>
I have the block visible to guests, but i don't want to be able to see latest posts from boards that are not accessible for them.
I have the block visible to guests, but i don't want to be able to see latest posts from boards that are not accessible for them.
I'm gonna fix it as soon as I can.
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.3
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "150px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : (!$user_info['is_guest'] ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})')) . '
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1
ORDER BY m.id_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>
' . htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") .'...
<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee>';
?>
Block Upgraded! Version 1.3 -> Permissions Fix! (exclude boards that you want to hide from guests)
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.4
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "150px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : (!$user_info['is_guest'] ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})')) . '
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1
ORDER BY m.id_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>
' . htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") .'...
<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
You should upgrade internet explorer 8 ;)
Nice man :-)
But when user haven´t avatar, is there blank place.
Is it possible add fix for example: http://media.simplemachinesweb.com/smf/default/images/icons/online.gif ?
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.4
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$default_avatar = 'http://thumb7.shutterstock.com/photos/thumb_large/57456/57456,1204703264,8.jpg';
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "150px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : (!$user_info['is_guest'] ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})')) . '
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1
ORDER BY m.id_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">';
if (!empty($post['avatar'])){
echo '<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />';
} else {
echo '<img src="' . $default_avatar .'" alt="" width="40px" height="40px" />';
}
echo '</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>
' . htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") .'...
<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
I'm already on Explorer 8.I meant that you should upgrade IE8 to IE9 :P
Very cool Blue.
1. I don't want to show the admin color.
2. Id like to remove the 'Re:' as well.
Any thoughts?
' . $post['subject'];
' . str_ireplace('Re: ', '', $post['username']);
1. I don't want to show the admin color.
style="color: ' . $row_posts['online_color'] . ';"
To remove the "Re:"
Find:Code: [Select]' . $post['subject'];
Replace with:Code: [Select]' . str_ireplace('Re: ', '', $post['username']);
' . str_ireplace('Re: ', '', $post['username']);
'were missing in the preview and replaced by random/garbage characters.
I'metc.
I'm comming....Andy
I'll attend. Looking...
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.4
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "150px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : (!$user_info['is_guest'] ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})')) . '
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1
ORDER BY m.id_msg DESC
LIMIT ' . $limit);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'idboard' => $row_posts['id_board'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>
' . $preview .'...
<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
echo'<table>
<tr>';
if (!(empty($post['avatar'])))
echo ' <td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>';
echo ' <td>
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
// Lets fix the BBCode bug and Strip the Text
$form_message = preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $post['body']);
$content1 = str_replace("[", "<", $form_message);
SELECT m.poster_name
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 140; // How many characters do you want to output?
$exclude_boards = array( 1, 2); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 2; // ENABLE - 1 | DISABLE - 2
$height = "400px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = '';
$text['who'] = '';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$form_message = preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $post['body']);
$content1 = str_replace("[", "<", $form_message);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = strip_tags(substr (htmlspecialchars_decode($content3),0,$number));
echo'<table>
<tr>';
if (!(empty($post['avatar'])))
echo ' <td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>';
echo ' <td>
' . str_ireplace('Re: ', '', $post['subject']);
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
$preview = substr ($content3,0,$number);
$preview = strip_tags(substr (htmlspecialchars_decode($content3),0,$number));
When I edit a block in SP 2.3.4 and click preview, all the permissions are reset to disallow.
I want recent posts only from specific boards.Change
How to make changes in coding.
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$included_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "150px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($included_boards) || (int) $included_boards === $included_boards)
{
$included_boards = is_array($included_boards) ? $included_boards : array($included_boards);
}
elseif ($included_boards != null)
{
$output_method = $included_boards;
$included_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($included_boards) ? '' : '
AND b.id_board IN ({array_int:included_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'included_boards' => empty($included_boards) ? '' : $included_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($included_boards) || (int) $included_boards === $included_boards)
{
$included_boards = is_array($included_boards) ? $included_boards : array($included_boards);
}
elseif ($included_boards != null)
{
$output_method = $included_boards;
$included_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($included_boards) ? '' : '
AND b.id_board NOT IN ({array_int:included_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'included_boards' => empty($included_boards) ? '' : $included_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$included_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "150px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($included_boards) || (int) $included_boards === $included_boards)
{
$included_boards = is_array($included_boards) ? $included_boards : array($included_boards);
}
elseif ($included_boards != null)
{
$output_method = $included_boards;
$included_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($included_boards) ? '' : '
AND b.id_board IN ({array_int:included_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'included_boards' => empty($included_boards) ? '' : $included_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($included_boards) || (int) $included_boards === $included_boards)
{
$included_boards = is_array($included_boards) ? $included_boards : array($included_boards);
}
elseif ($included_boards != null)
{
$output_method = $included_boards;
$included_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($included_boards) ? '' : '
AND b.id_board NOT IN ({array_int:included_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'included_boards' => empty($included_boards) ? '' : $included_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_QUOTES | ENT_IGNORE, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 140; // How many characters do you want to output?
$exclude_boards = array( 1, 2); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 2; // ENABLE - 1 | DISABLE - 2
$height = "400px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = '';
$text['who'] = '';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$form_message = preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $post['body']);
$content1 = str_replace("[", "<", $form_message);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = strip_tags(substr (htmlspecialchars_decode($content3),0,$number));
echo'<table>
<tr>';
if (!(empty($post['avatar'])))
echo ' <td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>';
echo ' <td>
' . str_ireplace('Re: ', '', $post['subject']);
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
Hey Blue, could you please take a look at this topic:
http://simpleportal.net/index.php?topic=11043
Hello...
Is there anyway to hide some boards from guests but not from other users?
Thank you very very much.
Hi,
maybe a stupid question,
I am interested how to get out of each topic, view the last 3 messages.
8)
Hello...
Is there anyway to hide some boards from guests but not from other users?
Thank you very very much.
Pas filter toe: Toon alleen de foutmeldingen van deze URL
http://weerforum.eu/forum/index.php?
Pas filter toe: Toon alleen de fouten met hetzelfde bericht
8: Undefined index:
Pas filter toe: Toon alleen fouten van dit bestand
Bestand: /home/weerforu/domains/weerforum.eu/public_html/forum/Sources/PortalBlocks.php(3561) : eval()'d code
Regel: 175
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 30; // How many recent posts do you want to output?
$number = 50; // How many characters do you want to output?
$exclude_boards = array( 0); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "410px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = '';
$text['who'] = '';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$form_message = preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $post['body']);
$content1 = str_replace("[", "<", $form_message);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = strip_tags(substr (htmlspecialchars_decode($content3),0,$number));
echo'<table>
<tr>';
if (!(empty($post['avatar'])))
echo ' <td style="width: 0px;">
<img src="' . $post['avatar'] .'" alt="" width="0px" height="0px" />
</td>';
echo ' <td>
' . str_ireplace('Re: ', '', $post['subject']);
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post[''] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 30; // How many recent posts do you want to output?
$number = 50; // How many characters do you want to output?
$exclude_boards = array( 0); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "410px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = '';
$text['who'] = '';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$form_message = preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $post['body']);
$content1 = str_replace("[", "<", $form_message);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = strip_tags(substr (htmlspecialchars_decode($content3),0,$number));
echo'<table>
<tr>';
if (!(empty($post['avatar'])))
echo ' <td style="width: 0px;">
<img src="' . $post['avatar'] .'" alt="" width="0px" height="0px" />
</td>';
echo ' <td>
' . str_ireplace('Re: ', '', $post['subject']);
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
:)
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 30; // How many recent posts do you want to output?
$number = 50; // How many characters do you want to output?
$exclude_boards = array( 0); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "410px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = '';
$text['who'] = '';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$form_message = preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $post['body']);
$content1 = str_replace("[", "<", $form_message);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = strip_tags(substr (htmlspecialchars_decode($content3),0,$number));
echo'<table>
<tr>';
if (!(empty($post['avatar'])))
echo ' <td style="width: 0px;">
<img src="' . $post['avatar'] .'" alt="" width="0px" height="0px" />
</td>';
echo ' <td>
' . str_ireplace('Re: ', '', $post['subject']);
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
:)
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
//if ($htmlspecialcharacters) {
//echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
//} else {
//echo $preview . '...';
//}
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "250px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'Gönderen:';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px; height: 40px;" >
<img src="' . $post['avatar'] .'" alt="" width="30px" height="30px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
//if ($htmlspecialcharacters) {
//echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
//} else {
//echo $preview . '...';
//}
echo '';
}
//Scrolling xD
if ($scrolling == 1)
echo '</div>';
?>
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 2; // TOPICS - 1 | MESSAGES - 2
$limit = 20; // How many recent posts do you want to output?
$number = 0; // How many characters do you want to output?
$exclude_boards = array(318, 427, 426, 432, 425, 433, 424,423, 431, 434, 430,429); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters =true; // Do you need to show html special characters like Greek characters?
$default_avatar = 'http://img15.hostingpics.net/pics/282198defaultavatar.png';
// Scroll Enable? Height and Speed?
$scrolling = 1; // ENABLE - 1 | DISABLE - 2
$height = "400px";
$speed = 1; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = '';
$text['who'] = '';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo ' <div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$form_message = preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $post['body']);
$content1 = str_replace("[", "<", $form_message);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = strip_tags(substr (htmlspecialchars_decode($content3),0,$number));
echo'
<div class="mansetdeneme" width="width: 220px;" align="left">
<table>
<tr>
<td style="width: 40px;">';
if (!empty($post['avatar'])){
echo'
<div class="manseta">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="24px" /></div>';
}
else {
echo '
<div class="manseta">
<img src="' . $default_avatar .'" alt="" width="40px" height="24px" /></div>';
}
echo ' </td>
<td>
' . str_ireplace('Re: ', '', $post['subject']);
if (!$post['new'] && $context['user']['is_logged'])
echo ' <span><div class="mansetg"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" /></div></span>';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
echo '</div><br />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
.mansetdeneme
{
align: left;
border: 1px solid #5998A7;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
padding: 3px 5px 7px 5px; ; üst sağ alt Sol
}
.manseta
{
align: left;
border: 1px solid #5998A7;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
padding: 3px 5px 7px 5px; ; üst sağ alt Sol
margin-top: 0px;
}
.mansetg
{
width: 20px;
height: 20px;
}
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 15; // How many recent posts do you want to output?
$number = 140; // How many characters do you want to output?
$exclude_boards = array( 1, 2); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$default_avatar = 'http://cafewe.com/Themes/default/images/default_avatar.png';
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 2; // ENABLE - 1 | DISABLE - 2
$height = "400px";
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = '';
$text['who'] = '';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array(ID20, ID21, ID22, ID23, ID24, ID25);
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$form_message = preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $post['body']);
$content1 = str_replace("[", "<", $form_message);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = strip_tags(substr (htmlspecialchars_decode($content3),0,$number));
echo'<table>
<tr>';
if (!(empty($post['avatar'])))
echo' <td style="width: 40px;">';
if (!empty($post['avatar'])){
echo '<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />';
} else {
echo '<img src="' . $default_avatar .'" alt="" width="40px" height="40px" />';
}
echo ' </td><td>
' . str_ireplace('Re: ', '', $post['subject']);
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
Got so much boards.
How can I exclude them easily? :0
$exclude_boards = null;
I just wanted to thank you for this amazing piece of coding.
Works flawlessly.
Fantastic thanks for this
Thanks for this block
Looking at the screenshot below...
How do I make the "box" for Recent Topics a specific size ... like when set for scrolling... yet NOT scroll... but rather have a slider?
Thanks!
Hum... Scroll bar, no auto scrolling right? :) I'll code it for you tomorrow
Thank you!
One thing i found is, when posting an image url inside the image tags, the image url shows on the block. FYI.
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 10; // How many recent posts do you want to output?
$number = 0; // How many characters do you want to output?
$exclude_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 0; // ENABLE - 1 | DISABLE - 2
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height = "150px";
$scrollbar = 0; // ENABLE - 1 | DISABLE - 2
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $row_posts['subject'] . '" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'subject2' => '<a style="color:red;"font-weight: bold;" title="Go to the last post" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">&#9658;Last Post</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
if ($scrollbar == 1)
echo '<div style="height:' . $height . '; overflow-y: scroll; overflow-x: hidden;">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td>
' . str_ireplace('Re: ', '', $post['subject']);
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo'
<br /><small>' . $post['subject2'];
echo '
' . $text['who'] . ' ' . $post['username'] . '<br />' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '';
} else {
echo $preview . '';
}
echo '<hr />';
}
//Scrolling xD
if ($scrollbar == 1)
echo '</div>';
if ($scrolling == 1)
echo '</marquee></div>';
?>
Hello!Subboards have their own ID so just add it to the excluded_boards parameter :)
I am new here and "search" did not help me.
Is there any way to exclude not only boards from the "Recent Topics/Posts"-block but also subboards?
Sorry if this was already asked and I did not find it.
Tried this on my forum.
However I am unable to hide more than one board despite having a few I want to remain hidden.
Any fix?
Have been seeing erors in my error log regarding this.
Use of undefined constant ID2 - assumed 'ID2'
Im wondering how easy it would be to work it so that it only pulls the latest posts from the topic it is in.
For instance, one block, but when displayed in board 72 it only pulls topics from board 72, etc
So it displays latest posts from the currently active board?
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 10; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = ( 2 ); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling =1; // ENABLE - 1 | DISABLE - 2
$speed = 2; // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height = "200px";
$scrollbar = 0; // ENABLE - 1 | DISABLE - 2
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context, $memberContext;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1)
{
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name,
t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : ' AND m.poster_time > 0
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array('exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
else
{
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name,
b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : ' AND m.poster_time > 0
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array('exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '
<marquee style="overflow:hidden;height:' . $height . ';" behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
if ($scrollbar == 1 && !empty($posts))
echo '
<div style="height:' . $height . '; overflow-y: scroll; overflow-x: hidden;">';
if (!empty($posts))
echo '
<table style="width:100%;">';
foreach ($posts as $post)
{
if (empty($post['body']))
{
echo '<tr><td> </td></tr>';
exit;
}
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr($content3,0,$number);
echo'
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" style="width:40px;height:40px;position:relative;top:10px;" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo '
<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '
<br />
<span style="font-size:small;">' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</span>
</td>
</tr>
<tr>';
if ($htmlspecialcharacters)
echo '
<td style="border:0px;"> </td>
<td style="border:0px;">', htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...', '</td>';
else
echo '
<td style="border:0px;"> </td>
<td style="border:0px;">', $preview . '...', '</td>';
echo '
</tr>
<tr>
<td colspan="2" style="border-top: thin dotted;height:0px;line-height:0px;padding:0%;display:hidden;width:100%;position:relative;">
<span></span>
</td>
</tr>';
}
if (!empty($posts))
echo '
</table>';
//Scrolling xD
if ($scrollbar == 1 && !empty($posts))
echo '
</div>';
if ($scrolling == 1)
echo '
</marquee>';
Here ya go Blue (or is it Purple?)
Anyways can ya show me where exactly the board numbers should go please bud.
Another thing I recently noticed.
Is there a way for the block to show the display name and not the name a person registered with?
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 10; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = array(2); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling =1; // ENABLE - 1 | DISABLE - 2
$speed = 2; // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height = "200px";
$scrollbar = 0; // ENABLE - 1 | DISABLE - 2
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context, $memberContext;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1)
{
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT u.real_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name,
t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : ' AND m.poster_time > 0
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array('exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['real_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
else
{
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT u.real_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name,
b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : ' AND m.poster_time > 0
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array('exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['real_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '
<marquee style="overflow:hidden;height:' . $height . ';" behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
if ($scrollbar == 1 && !empty($posts))
echo '
<div style="height:' . $height . '; overflow-y: scroll; overflow-x: hidden;">';
if (!empty($posts))
echo '
<table style="width:100%;">';
foreach ($posts as $post)
{
if (empty($post['body']))
{
echo '<tr><td> </td></tr>';
exit;
}
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr($content3,0,$number);
echo'
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" style="width:40px;height:40px;position:relative;top:10px;" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo '
<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '
<br />
<span style="font-size:small;">' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</span>
</td>
</tr>
<tr>';
if ($htmlspecialcharacters)
echo '
<td style="border:0px;"> </td>
<td style="border:0px;">', htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...', '</td>';
else
echo '
<td style="border:0px;"> </td>
<td style="border:0px;">', $preview . '...', '</td>';
echo '
</tr>
<tr>
<td colspan="2" style="border-top: thin dotted;height:0px;line-height:0px;padding:0%;display:hidden;width:100%;position:relative;">
<span></span>
</td>
</tr>';
}
if (!empty($posts))
echo '
</table>';
//Scrolling xD
if ($scrollbar == 1 && !empty($posts))
echo '
</div>';
if ($scrolling == 1)
echo '
</marquee>';
Blue, if or when you update, remember img tags are shown in the preview as bbc. I think code tags too but I don't remember.
Can you get it to show emoticons instead of the text?
Can you get it to show Youtube vids instead of the link?
Can you automatically remove the "..." at the end if the message is already less characters than the max limit?
Can you add a reply button? (and/or a quick reply box which appears when you click "reply"?)
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 8; // How many recent posts do you want to output?
$number = 0; // How many characters do you want to output?
$exclude_boards = array(318, 427, 426, 432, 425, 433, 424,423, 431, 434, 430,429,310); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters =true; // Do you need to show html special characters like Greek characters?
$default_avatar = 'http://img15.hostingpics.net/pics/282198defaultavatar.png';
// Scroll Enable? Height and Speed?
$scrolling = 2; // ENABLE - 1 | DISABLE - 2
$height = "0px";
$speed = 0; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = '';
$text['who'] = '';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . shorten_subject($row_posts['subject'], 25) . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . shorten_subject($row_posts['subject'], 25) . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '
<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
// Lets fix the BBCode bug and Strip the Text
$form_message = preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $post['body']);
$content1 = str_replace("[", "<", $form_message);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = strip_tags(substr (htmlspecialchars_decode($content3),0,$number));
echo '
<td><div class="cat_bar">
<h3 class="catbg">
<table border="0" cellpadding="0" cellspacing="0" width="100%" colspan="0">
<tr class="">
<td class="son_konular10"><span class="smalltext"><strong>Recent Topics</strong></span></td>
<td class="gonderen10"><span class="smalltext"><strong>Sender</strong></span></td>
<td class="tarih10"><span class="smalltext"><strong>Date</strong></span></td>
</tr></table></h3></div>';
echo'
<span class="upperframe"><span></span></span>
<div class="roundframe">
<table border="0" cellpadding="0" cellspacing="0" width="100%" colspan="0">';
foreach ($posts as $post) {
echo'
<tr>
<td class="son_konular10"><img src="', $settings['images_url'], '/konubasi.gif" style="margin-right:3px;" alt="resim" border="0" />' .str_ireplace('Re: ', '', $post['subject']);
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo'
<hr />
</td>
<td class="gonderen10"><img src="', $settings['images_url'], '/uyebasi.gif" style="margin-right:3px;" alt="resim" border="0" />' . $post['username'] . '<hr /></td> ';
echo'
<td class="tarih10"><img src="', $settings['images_url'], '/tarihbasi.gif" style="margin-right:3px;" alt="resim" border="0" /> ' . $post['time'] .'<hr /></td></tr> ';
}
echo'
</table>
</div>
<span class="lowerframe"><span></span></span></td>';
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
<?php
/*
Block:
Author: Blue @ Simple Portal.net
Version: 1.5
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 2; // TOPICS - 1 | MESSAGES - 2
$limit = 8; //
$number = 0; //
$exclude_boards = array(318, 427, 426, 432, 425, 433, 424,423, 431, 434, 430,429,310); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters =true; //
$default_avatar = 'http://img15.hostingpics.net/pics/282198defaultavatar.png';
// Scroll Enable? Height and Speed?
$scrolling = 2; // ENABLE - 1 | DISABLE - 2
$height = "0px";
$speed = 0; // SLOW - 1 | MEDIUM - 10 | FAST - 20
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = '';
$text['who'] = '';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . shorten_subject($row_posts['subject'], 25) . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . shorten_subject($row_posts['subject'], 25) . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo ' <div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
// Lets fix the BBCode bug and Strip the Text
$form_message = preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $post['body']);
$content1 = str_replace("[", "<", $form_message);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = strip_tags(substr (htmlspecialchars_decode($content3),0,$number));
echo '
<td><div class="cat_bar">
<h3 class="catbg">
<table border="0" cellpadding="0" cellspacing="0" width="100%" colspan="0">
<tr class="">
<td class="son_konular10"><span class="smalltext"><strong>Recent Post</strong></span></td>
<td class="gonderen10"><span class="smalltext"><strong>Sender</strong></span></td>
<td class="tarih10"><span class="smalltext"><strong>Date</strong></span></td>
</tr></table></h3></div>';
echo'
<span class="upperframe"><span></span></span>
<div class="roundframe">
<table border="0" cellpadding="0" cellspacing="0" width="100%" colspan="0">';
foreach ($posts as $post) {
echo'
<tr>
<td class="son_konular10"><img src="', $settings['images_url'], '/konubasi.gif" style="margin-right:3px;" alt="resim" border="0" />' .str_ireplace('Re: ', '', $post['subject']);
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo'
<hr />
</td>
<td class="gonderen10"><img src="', $settings['images_url'], '/uyebasi.gif" style="margin-right:3px;" alt="resim" border="0" />' . $post['username'] . '<hr /></td> ';
echo'
<td class="tarih10"><img src="', $settings['images_url'], '/tarihbasi.gif" style="margin-right:3px;" alt="resim" border="0" /> ' . $post['time'] .'<hr /></td></tr> ';
}
echo'
</table>
</div>
<span class="lowerframe"><span></span></span></td>';
//Scrolling xD
if ($scrolling == 1)
echo '</marquee></div>';
?>
$columns = 14; //
$block_ids = array(253); //
$block_data = array();
foreach ($block_ids as $block)
{
$block_data[$block] = current(getBlockInfo(false, $block, false, false)); //
$block_data[$block]['style'] = sportal_parse_style('explode', $block_data[$block]['style'], false); //
}
echo '
<table border="0" cellpadding="1" cellspacing="0" width="100%" colspan="0">
<tr>';
echo '
<td><table style="width: 100%;">
<tr>';
$counter = 0;
foreach ($block_data as $data)
{
if ($counter != 0 && $counter % $columns == 0)
{
echo '
</tr>
<tr>';
}
echo '
<td style="width: ', ceil((10 / $columns)), '%; vertical-align: top;">
', template_block($data), '
</td>';
$counter++;
}
echo '
</tr>
</table></td>';
$columns = 14; //
$block_ids = array(252); //
$block_data = array();
foreach ($block_ids as $block)
{
$block_data[$block] = current(getBlockInfo(false, $block, false, false)); //
$block_data[$block]['style'] = sportal_parse_style('explode', $block_data[$block]['style'], false); //
}
echo '
<td><table style="width: 100%;">
<tr>';
$counter = 0;
foreach ($block_data as $data)
{
if ($counter != 0 && $counter % $columns == 0)
{
echo '
</tr>
<tr>';
}
echo '
<td style="width: ', ceil((10 / $columns)), '%; vertical-align: top;">
', template_block($data), '
</td>';
$counter++;
}
echo '
</tr>
</table></td>';
echo '
</tr>
</table>';
.son_konular10{
width: 57%;
text-align: left;
padding: 0px 8px;
cellspacing: 5;
cellpadding: 0;
class: bordercolor;
}
.gonderen10{
width: 17%;
text-align: left;
}
.tarih10{
width: 26%;
text-align: left;
}
realy nice but stil dont have the smiley's couldn't find any answer
$preview = substr ($content3,0,$number);
$preview = substr ($content3,0,$number);
parsesmileys($preview);
Parse error: syntax error, unexpected T_VARIABLE in /home/d/dev/www/Sources/PortalBlocks.php(3561) : eval()'d code on line 18
there are 3 blocks involved here.
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 0; // ENABLE - 1 | DISABLE - 2
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height = "150px";
$scrollbar = 0; // ENABLE - 1 | DISABLE - 2
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT t.num_replies, m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE t.num_replies=0 AND m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
if ($scrollbar == 1)
echo '<div style="height:' . $height . '; overflow-y: scroll; overflow-x: hidden;">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrollbar == 1)
echo '</div>';
if ($scrolling == 1)
echo '</marquee></div>';
?>
Hello !
Thanks a lot for this great mod !
I have a question : is it possible to have the same layout as the original post ?
A post formatted like that :
Hello,
- one
- two
- ...
looks like :
Hello,-one-two-...
Thanks !
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 2; // TOPICS - 1 | MESSAGES - 2
$limit = 100; // How many recent posts do you want to output?
$number = 240; // How many characters do you want to output?
$exclude_boards = array(87, 93, 17, 71); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 2; // ENABLE - 1 | DISABLE - 2
$speed = 4; // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height = "700px";
$scrollbar = 1; // ENABLE - 1 | DISABLE - 2
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => parse_bbc($row_posts['body']),
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => parse_bbc($row_posts['body']),
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
if ($scrollbar == 1)
echo '<div style="height:' . $height . '; overflow-y: scroll; overflow-x: hidden;">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrollbar == 1)
echo '</div>';
if ($scrolling == 1)
echo '</marquee></div>';
?>
realy nice but stil dont have the smiley's couldn't find any answerCode: (Find) [Select]$preview = substr ($content3,0,$number);
Code: (Replace) [Select]$preview = substr ($content3,0,$number);
parsesmileys($preview);
Someone got an edit to make the block, show the users actual 'Name' ..and not use the 'Username'
Even in SMF own profile it reads
"Name
This is the displayed name that people will see"
yet this block uses the username field..
SELECT m.poster_name, m.poster_time,
SELECT m.poster_time,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(u.real_name, m.poster_name) AS poster_name,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
Thank you Sayaka Maizono for the edit and thank you xeon for confirming it works.
Since showing the username instead of the display name is generally a bad practice, and considering that Blue is not very active I'll go ahead and edit the OP with the suggested changes.
Regards to both!
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.8
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 0; // ENABLE - 1 | DISABLE - 2
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height = "150px";
$scrollbar = 0; // ENABLE - 1 | DISABLE - 2
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context, $txt;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, IFNULL(u.real_name, m.poster_name) AS poster_name, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
(IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS is_read,
IFNULL(lb.id_msg, -1) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)' . ($user_info['is_guest'] ? '' : '
LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})') . '
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
'current_member' => $user_info['id'],
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $txt['board'] . ': ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read']),
'subject_new' => $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new'
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, IFNULL(u.real_name, m.poster_name) AS poster_name, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
(IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS is_read,
IFNULL(lb.id_msg, -1) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)' . ($user_info['is_guest'] ? '' : '
LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})') . '
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
'current_member' => $user_info['id'],
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $txt['board'] . ': ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read']),
'subject_new' => $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new'
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
if ($scrollbar == 1)
echo '<div style="height:' . $height . '; overflow-y: scroll; overflow-x: hidden;">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <a href=' . $post['subject_new'] . '><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" /></a>';
echo '<br />
<small>' . $txt['by'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrollbar == 1)
echo '</div>';
if ($scrolling == 1)
echo '</marquee></div>';
?>
Undefined index: poster_name
File: /home/xxxxxxx/public_html/forum/Sources/PortalBlocks.php(3674) : eval()'d code
Line: 83
I am using this block and its working fine so your problem is related to something else.
1. Icon "NEW" disappears when the message has been read
2. Guests are shown author nick
RU:
1. Иконка "NEW" исчезает когда сообщение прочитано
2. Гостям показывается ник автораCode: [Select]<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.8
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 5; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 0; // ENABLE - 1 | DISABLE - 2
$speed = 3; // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height = "150px";
$scrollbar = 0; // ENABLE - 1 | DISABLE - 2
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context, $txt;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, IFNULL(u.real_name, m.poster_name) AS poster_name, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
(IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS is_read,
IFNULL(lb.id_msg, -1) + 1 AS new_from') . '
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 (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)' . ($user_info['is_guest'] ? '' : '
LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})') . '
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
'current_member' => $user_info['id'],
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $txt['board'] . ': ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read']),
'subject_new' => $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new'
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, IFNULL(u.real_name, m.poster_name) AS poster_name, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
(IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS is_read,
IFNULL(lb.id_msg, -1) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)' . ($user_info['is_guest'] ? '' : '
LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})') . '
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
'current_member' => $user_info['id'],
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $txt['board'] . ': ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => $row_posts['body'],
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read']),
'subject_new' => $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new'
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
if ($scrollbar == 1)
echo '<div style="height:' . $height . '; overflow-y: scroll; overflow-x: hidden;">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <a href=' . $post['subject_new'] . '><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" /></a>';
echo '<br />
<small>' . $txt['by'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrollbar == 1)
echo '</div>';
if ($scrolling == 1)
echo '</marquee></div>';
?>