$modSettings['sp_standalone_url'],
'page_title' => $context['forum_name'],
);
else
$context += array(
'portal_url' => $scripturl,
);
$context['standalone'] = $standalone;
if (!isset($settings['sp_images_url']))
{
if (file_exists($settings['theme_dir'] . '/images/sp'))
$settings['sp_images_url'] = $settings['theme_url'] . '/images/sp';
else
$settings['sp_images_url'] = $settings['default_theme_url'] . '/images/sp';
}
if (WIRELESS || empty($modSettings['sp_portal_mode']) || (!empty($maintenance) && !allowedTo('admin_forum')) || isset($_GET['debug']))
return;
if ($modSettings['sp_portal_mode'] == 1)
$context['linktree'][0] = array(
'url' => $scripturl . '?action=forum',
'name' => $context['forum_name'],
);
// If you want to remove Forum link when it is
// alone, take out the following two comment lines.
//if (empty($context['linktree'][1]))
// $context['linktree'] = array();
if (!empty($context['linktree']) && $modSettings['sp_portal_mode'] == 1)
foreach ($context['linktree'] as $key => $tree)
if (strpos($tree['url'], '#c') !== false && strpos($tree['url'], 'action=forum#c') === false)
$context['linktree'][$key]['url'] = str_replace('#c', '?action=forum#c', $tree['url']);
$modSettings['sp_resize_images'] = true;
if (empty($initialized))
{
$context['html_headers'] .= '
';
}
$context['SPortal']['sides'] = array(
'left' => array(
'id' => '1',
'name' => 'left',
'active' => !empty($modSettings['showleft']),
),
'top' => array(
'id' => '2',
'name' => 'top',
'active' => true,
),
'bottom' => array(
'id' => '3',
'name' => 'bottom',
'active' => true,
),
'right' => array(
'id' => '4',
'name' => 'right',
'active' => !empty($modSettings['showright']),
),
);
foreach($context['SPortal']['sides'] as $side)
{
if (!$side['active'])
continue;
$context['SPortal']['blocks'][$side['name']] = getBlockInfo($side['id'], null, 1, 1);
$context['SPortal']['sides'][$side['name']]['collapsed'] = $context['user']['is_guest'] ? !empty($_COOKIE['sp_' . $side['name']]) : !empty($options['sp_' . $side['name']]);
}
if (!empty($context['template_layers']) && !in_array('portal', $context['template_layers']))
$context['template_layers'][] = 'portal';
$initialized = true;
}
function sportal()
{
global $smcFunc, $context, $sourcedir, $scripturl, $modSettings, $user_info, $txt, $article_request;
if (WIRELESS)
redirectexit('action=forum');
$context['page_title'] = $context['forum_name'];
if (isset($context['page_title_html_safe']))
$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title']));
if (!empty($context['standalone']))
setupMenuContext();
if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'addarticle')
{
if (!allowedTo('sp_add_article') && !allowedTo('sp_moderate'))
fatal_lang_error('error_sp_cannot_add_article');
$context['message'] = !empty($_REQUEST['message']) ? (int) $_REQUEST['message'] : 0;
$context['return'] = !empty($_REQUEST['return']) ? $_REQUEST['return'] : '';
if (empty($context['message']))
fatal_lang_error('error_sp_no_message_id');
$request = $smcFunc['db_query']('','
SELECT id_message
FROM {db_prefix}sp_articles
WHERE id_message = {int:message}',
array(
'message' => $context['message'],
)
);
list ($exists) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
if ($exists)
fatal_lang_error('error_sp_article_exists');
$context['list_categories'] = getCategoryInfo();
if (empty($context['list_categories']))
fatal_error($txt['error_sp_no_category'] . '
' . (allowedTo('sp_moderate') ? sprintf($txt['error_sp_no_category_sp_moderator'], $scripturl . '?action=admin;area=categories;sa=add') : $txt['error_sp_no_category_normaluser']), false);
loadLanguage('SPortalAdmin', sp_languageSelect('SPortalAdmin'));
$context['sub_template'] = 'add_article';
}
elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createarticle')
{
if (!allowedTo('sp_add_article') && !allowedTo('sp_moderate'))
fatal_lang_error('error_sp_cannot_add_article');
$articleOptions = array(
'id_category' => !empty($_POST['category']) ? (int) $_POST['category'] : 0,
'id_message' => !empty($_POST['message']) ? (int) $_POST['message'] : 0,
'approved' => allowedTo('sp_auto_article_approval') || allowedTo('sp_moderate') ? 1 : 0,
);
createArticle($articleOptions);
redirectexit('topic=' . $_POST['return']);
}
elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'credits')
{
require_once($sourcedir . '/SPortalAdmin2.php');
loadLanguage('SPortalAdmin', sp_languageSelect('SPortalAdmin'));
Information(false);
$context['page_title'] = $txt['sp-info_title'];
$context['sub_template'] = 'information';
}
loadLanguage('Stats');
loadTemplate('SPortal2');
if (!empty($modSettings['articleactive']))
{
$request = $smcFunc['db_query']('','
SELECT COUNT(*)
FROM {db_prefix}sp_articles as a
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
WHERE {query_see_board}
AND a.approved = {int:approved}
AND publish = {int:publish}',
array(
'approved' => 1,
'publish' => 1,
)
);
list ($totalArticles) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
$modSettings['articleperpage'] = !empty($modSettings['articleperpage']) ? (int) $modSettings['articleperpage'] : 5;
$context['start'] = !empty($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
$context['page_index'] = constructPageIndex($context['portal_url'] . '?sa=articles', $context['start'], $totalArticles, $modSettings['articleperpage']);
if (empty($modSettings['sp_disableColor']))
{
$members_request = $smcFunc['db_query']('','
SELECT m.id_member
FROM {db_prefix}sp_articles AS a
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
WHERE {raw:query_see_board}
AND a.approved = {int:approved}
AND publish = {int:publish}
AND m.id_member != {int:guest}
ORDER BY a.id_message DESC
LIMIT {int:start}, {int:end}',
array(
'query_see_board' => $user_info['query_see_board'],
'approved' => 1,
'publish' => 1,
'start' => $context['start'],
'end' => $modSettings['articleperpage'],
'guest' => 0,
)
);
$colorids = array();
while($row = $smcFunc['db_fetch_assoc']($members_request))
$colorids[] = $row['id_member'];
$smcFunc['db_free_result']($members_request);
if (!empty($colorids))
sp_loadColors($colorids);
}
$article_request = $smcFunc['db_query']('','
SELECT
a.id_article, a.id_category, a.id_message, a.approved, c.name as cname, c.picture, m.id_member,
IFNULL(mem.real_name, m.poster_name) AS poster_name, m.icon, m.subject, m.body, m.poster_time,
m.smileys_enabled, t.id_topic, t.num_replies, t.num_views, t.locked, b.id_board, b.name as bname,
mem.avatar, at.id_attach, at.attachment_type, at.filename
FROM {db_prefix}sp_articles AS a
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
INNER JOIN {db_prefix}topics AS t ON (t.id_first_msg = a.id_message)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS at ON (at.id_member = mem.id_member)
WHERE {query_see_board}
AND a.approved = {int:approved}
AND publish = {int:publish}
ORDER BY a.id_message DESC
LIMIT {int:start}, {int:end}',
array(
'approved' => 1,
'publish' => 1,
'start' => $context['start'],
'end' => $modSettings['articleperpage'],
)
);
$context['get_articles'] = 'getArticles';
}
}
function getArticles($reset = false)
{
global $smcFunc, $context, $scripturl, $modSettings, $settings, $txt, $color_profile, $article_request, $current;
if ($article_request == false)
return false;
if (!($row = $smcFunc['db_fetch_assoc']($article_request)))
return false;
if (!empty($current) && $current == $row['id_message'])
return;
$current = $row['id_message'];
$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';
if (!empty($modSettings['articlelength']) && $smcFunc['strlen']($row['body']) > $modSettings['articlelength'])
$row['body'] = parse_bbc(sp_truncateText($row['body']), $row['smileys_enabled'], $row['id_message']) . '...';
else
$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_message']);
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}
if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';
censorText($row['subject']);
censorText($row['body']);
if ($modSettings['sp_resize_images'])
$row['body'] = preg_replace('~class="bbc_img"~i', 'class="bbc_img sp_article"', $row['body']);
$output = array(
'article' => array(
'id' => $row['id_article'],
'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'],
'comment_link' => !empty($row['locked']) ? '' : '| ' . $txt['ssi_write_comment'] . '',
'new_comment' => !empty($row['locked']) ? '' : '| ' . $txt['ssi_write_comment'] . '',
'link' => '' . $txt['sp-read_more'] . '',
'approved' => $row['approved'],
),
'category' => array(
'id' => $row['id_category'],
'name' => $row['cname'],
'picture' => array (
'href' => $row['picture'],
'image' => '',
),
),
'message' => array(
'id' => $row['id_message'],
'icon' => '',
'subject' => $row['subject'],
'body' => $row['body'],
'timeyear' => timeformat($row['poster_time'], '%d %b %y'),
'timeday' => timeformat($row['poster_time'], '%H:%M:%S'),
),
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
'link' => !empty($row['id_member']) ? (!empty($color_profile[$row['id_member']]['link']) ? $color_profile[$row['id_member']]['link'] : '' . $row['poster_name'] . '') : $row['poster_name'],
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '' : '') : (stristr($row['avatar'], 'http://') ? '' : ''),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
),
'topic' => array(
'id' => $row['id_topic'],
'replies' => $row['num_replies'],
'views' => $row['num_views'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'link' => '' . $row['subject'] . '',
'locked' => !empty($row['locked']),
),
'board' => array(
'id' => $row['id_board'],
'name' => $row['bname'],
'link' => '' . $row['bname'] . '',
),
);
return $output;
}
function sp_userInfo($parameters, $id, $return_parameters = false)
{
global $context, $txt, $scripturl, $memberContext, $modSettings, $user_info, $color_profile;
$block_parameters = array();
if ($return_parameters)
return $block_parameters;
echo '
';
if ($context['user']['is_guest'])
{
echo '
', sprintf($txt['welcome_guest'], $txt['guest_title']);
}
else
{
loadMemberData($user_info['id']);
loadMemberContext($user_info['id']);
$member_info = $memberContext[$user_info['id']];
if (empty($modSettings['MemberColorLinkInstalled']) && sp_loadColors($member_info['id']) !== false)
$member_info['colored_name'] = $color_profile[$member_info['id']]['colored_name'];
$member_info['karma']['total'] = $member_info['karma']['good'] - $member_info['karma']['bad'];
echo '
', $txt['hello_member'], '
', !empty($member_info['colored_name']) ? $member_info['colored_name'] : $member_info['name'], '
';
if (!empty($member_info['avatar']['image']))
echo '
', $member_info['avatar']['image'], '
';
if (!empty($member_info['group']))
echo '
', $member_info['group'], '
';
else
echo '
', $member_info['post_group'], '
';
echo '
', $member_info['group_stars'], '
';
echo '
';
echo '
- ', sp_embed_image('dot'), ' ', $txt['posts'], ': ', $member_info['posts'], '
';
if (!empty($modSettings['karmaMode']))
{
echo '
- ', sp_embed_image('dot'), ' ', $modSettings['karmaLabel'], ' ';
if ($modSettings['karmaMode'] == 1)
echo $member_info['karma']['total'];
elseif ($modSettings['karmaMode'] == 2)
echo '+', $member_info['karma']['good'], '/-', $member_info['karma']['bad'];
echo '
';
}
if (allowedTo('pm_read'))
{
echo '
- ', sp_embed_image('dot'), ' ', $txt['sp-usertmessage'], ': ', $context['user']['messages'], '
- ', sp_embed_image('dot'), ' ', $txt['sp-usernmessage'], ': ', $context['user']['unread_messages'], '
';
}
echo '
- ', sp_embed_image('dot'), ' ', $txt['unread_topics_visit'], '
- ', sp_embed_image('dot'), ' ', $txt['unread_replies'], '
';
echo '
';
echo '
', sp_embed_image('arrow'), '
', $txt['profile'], ' ', sp_embed_image('arrow'), '
', $txt['logout'], '';
}
echo '
';
}
function sp_latestMember($parameters, $id, $return_parameters = false)
{
global $smcFunc, $context, $scripturl, $txt, $color_profile;
$block_parameters = array(
'limit' => 'int',
);
if ($return_parameters)
return $block_parameters;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
$request = $smcFunc['db_query']('','
SELECT id_member, real_name, date_registered
FROM {db_prefix}members
WHERE is_activated = {int:is_activated}
ORDER BY id_member DESC
LIMIT {int:limit}',
array(
'is_activated' => 1,
'limit' => $limit,
)
);
$members = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];
$members[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '' . $row['real_name'] . '',
'date' => timeformat($row['date_registered'], '%d %b'),
);
}
$smcFunc['db_free_result']($request);
if (empty($members))
{
echo '
', $txt['error_sp_no_members_found'];
return;
}
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($members as $k => $p)
{
if (!empty($color_profile[$p['id']]['link']))
$members[$k]['link'] = $color_profile[$p['id']]['link'];
}
}
echo '
';
foreach ($members as $member)
echo '
- ', sp_embed_image('dot'), ' ', $member['link'], ' - ', $member['date'], '
';
echo '
';
}
function sp_whosOnline($parameters, $id, $return_parameters = false)
{
global $scripturl, $sourcedir, $modSettings, $txt;
$block_parameters = array();
if ($return_parameters)
return $block_parameters;
$stats = ssi_whosOnline('array');
echo '
- ', sp_embed_image('dot'), ' ', $txt['guests'], ': ', $stats['num_guests'], '
';
if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')))
echo '
- ', sp_embed_image('dot'), ' ', $txt['spiders'], ': ', $stats['num_spiders'], '
';
echo '
- ', sp_embed_image('dot'), ' ', $txt['hidden'], ': ', $stats['num_users_hidden'], '
- ', sp_embed_image('dot'), ' ', $txt['users'], ': ', $stats['num_users_online'], '
';
if (!empty($stats['users_online']))
{
echo '
- ', sp_embed_image('dot'), ' ', allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '' : '', $txt['online_users'], allowedTo('who_view') && !empty($modSettings['who_enabled']) ? '' : '', ':
';
foreach ($stats['users_online'] as $user)
echo '
- ', sp_embed_image($user['name'] == 'H' ? 'tux' : 'user'), ' ', $user['hidden'] ? '' . $user['link'] . '' : $user['link'], '
';
echo '
';
}
else
{
echo '
', $txt['error_sp_no_online'], '
';
}
// If you, like me, hate the UOT mod and want to disable it take out
// the comment line below. Wait a minute! Why did you insall it then?!
//return;
if (file_exists($sourcedir . '/Subs-MembersOnlineToday.php'))
{
require_once($sourcedir . '/Subs-MembersOnlineToday.php');
$membersOnlineTodayOptions = array(
'sort' => 'login_time',
'reverse_sort' => true,
'period' => 'current_day',
'canview' => 'registered',
);
$stats += getMembersOnlineTodayStats($membersOnlineTodayOptions);
if (empty($stats['num_users_online_today']))
return;
echo '
- ', sp_embed_image('dot'), ' ', $txt['sp-online_today'], ': ', $stats['num_users_online_today'], '
';
foreach ($stats['users_online_today'] as $user)
echo '
- ', sp_embed_image($user['name'] == 'H' ? 'tux' : 'user'), ' ', $user['hidden'] ? '' . $user['link'] . '' : $user['link'], '
';
echo '
';
}
}
function sp_boardStats($parameters, $id, $return_parameters = false)
{
global $smcFunc, $scripturl, $modSettings, $txt;
$block_parameters = array(
'averages' => 'check',
);
if ($return_parameters)
return $block_parameters;
$averages = !empty($parameters['averages']) ? 1 : 0;
loadLanguage('Stats');
$totals = ssi_boardStats('array');
if ($averages)
{
$result = $smcFunc['db_query']('', '
SELECT
SUM(posts) AS posts, SUM(topics) AS topics, SUM(registers) AS registers,
SUM(most_on) AS most_on, MIN(date) AS date, SUM(hits) AS hits
FROM {db_prefix}log_activity',
array(
)
);
$row = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);
$total_days_up = ceil((time() - strtotime($row['date'])) / (60 * 60 * 24));
$totals['average_posts'] = comma_format(round($row['posts'] / $total_days_up, 2));
$totals['average_topics'] = comma_format(round($row['topics'] / $total_days_up, 2));
$totals['average_members'] = comma_format(round($row['registers'] / $total_days_up, 2));
$totals['average_online'] = comma_format(round($row['most_on'] / $total_days_up, 2));
}
echo '
- ', sp_embed_image('stats'), ' ', $txt['total_members'], ': ', comma_format($totals['members']), '
- ', sp_embed_image('stats'), ' ', $txt['total_posts'], ': ', comma_format($totals['posts']), '
- ', sp_embed_image('stats'), ' ', $txt['total_topics'], ': ', comma_format($totals['topics']), '
- ', sp_embed_image('stats'), ' ', $txt['total_cats'], ': ', comma_format($totals['categories']), '
- ', sp_embed_image('stats'), ' ', $txt['total_boards'], ': ', comma_format($totals['boards']), '
- ', sp_embed_image('stats'), ' ', $txt['most_online'], ': ', comma_format($modSettings['mostOnline']), '
';
if ($averages)
{
echo '
- ', sp_embed_image('averages'), ' ', $txt['sp-average_posts'], ': ', comma_format($totals['average_posts']), '
- ', sp_embed_image('averages'), ' ', $txt['sp-average_topics'], ': ', comma_format($totals['average_topics']), '
- ', sp_embed_image('averages'), ' ', $txt['sp-average_members'], ': ', comma_format($totals['average_members']), '
- ', sp_embed_image('averages'), ' ', $txt['sp-average_online'], ': ', comma_format($totals['average_online']), '
';
}
}
function sp_topPoster($parameters, $id, $return_parameters = false)
{
global $smcFunc, $context, $scripturl, $modSettings, $txt, $color_profile;
$block_parameters = array(
'limit' => 'int',
'type' => 'select',
);
if ($return_parameters)
return $block_parameters;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
$type = !empty($parameters['type']) ? (int) $parameters['type'] : 0;
if (!empty($type))
{
if ($type == 1)
{
list($year, $month, $day) = explode('-', date('Y-m-d'));
$start_time = mktime(0, 0, 0, $month, $day, $year);
}
elseif ($type == 2)
$start_time = mktime(0, 0, 0, date("n"), date("j"), date("Y")) - (date("N") * 3600 * 24);
elseif ($type == 3)
{
$months = array( 1 => 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$start_time = mktime(0, 0, 0, date("n"), date("j"), date("Y")) - (3600 * 24 * $months[(int) date("m", time())]);
}
$start_time = forum_time(false, $start_time);
$request = $smcFunc['db_query']('', '
SELECT
mem.id_member, mem.real_name, COUNT(*) as posts,
mem.avatar, a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE m.poster_time > {int:start_time}
AND m.id_member != 0
GROUP BY mem.id_member
ORDER BY posts DESC
LIMIT {int:limit}',
array(
'start_time' => $start_time,
'limit' => $limit,
)
);
}
else
{
$request = $smcFunc['db_query']('','
SELECT
m.id_member, m.real_name, m.posts, m.avatar,
a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}members AS m
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
ORDER BY posts DESC
LIMIT {int:limit}',
array(
'limit' => $limit,
)
);
}
$members = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}
$members[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '' . $row['real_name'] . '',
'posts' => $row['posts'],
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '' : '') : (stristr($row['avatar'], 'http://') ? '' : ''),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
);
}
$smcFunc['db_free_result']($request);
if (empty($members))
{
echo '
', $txt['error_sp_no_members_found'];
return;
}
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($members as $k => $p)
{
if (!empty($color_profile[$p['id']]['link']))
$members[$k]['link'] = $color_profile[$p['id']]['link'];
}
}
echo '
';
foreach ($members as $member)
echo '
', !empty($member['avatar']['href']) ? '
' : '', '
|
', $member['link'], '
', $member['posts'], ' ', $txt['posts'], '
|
';
echo '
';
}
function sp_recent($parameters, $id, $return_parameters = false)
{
global $txt, $scripturl, $settings, $color_profile;
$block_parameters = array(
'limit' => 'int',
'type' => 'select',
);
if ($return_parameters)
return $block_parameters;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
$type = 'ssi_recent' . (empty($parameters['type']) ? 'Posts' : 'Topics');
$items = $type($limit, null, null, 'array');
if (empty($items))
{
echo '
', $txt['error_sp_no_posts_found'];
return;
}
else
$items[count($items) - 1]['is_last'] = true;
$colorids = array();
foreach ($items as $item)
$colorids[] = $item['poster']['id'];
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($items as $k => $p)
{
if (!empty($color_profile[$p['poster']['id']]['link']))
$items[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
}
}
foreach ($items as $key => $item)
echo '
', $item['subject'], ' ', $txt['by'], ' ', $item['poster']['link'], $item['new'] ? '' : ' ', '
[', $item['time'], ']
', empty($item['is_last']) ? '
' : '';
}
function sp_recentPosts($parameters, $id, $return_parameters = false)
{
global $context, $scripturl, $txt, $settings, $color_profile;
$block_parameters = array(
'limit' => 'int',
);
if ($return_parameters)
return $block_parameters;
$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
$posts = ssi_recentPosts($limit, null, null, 'array');
if (empty($posts))
{
echo '
', $txt['error_sp_no_posts_found'];
return;
}
$colorids = array();
foreach ($posts as $post)
$colorids[] = $post['poster']['id'];
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($posts as $k => $p)
{
if (!empty($color_profile[$p['poster']['id']]['link']))
$posts[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
}
}
echo '
';
foreach ($posts as $post)
echo '
', sp_embed_image('post'), '
|
', $post['subject'], '
', $post['new'] ? '' : '', ' [', $post['board']['link'], ']
|
', $post['poster']['link'], ' ', $post['time'], '
|
';
echo '
';
}
function sp_recentTopics($parameters, $id, $return_parameters = false)
{
global $context, $scripturl, $txt, $settings, $color_profile;
$block_parameters = array(
'limit' => 'int',
);
if ($return_parameters)
return $block_parameters;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
$topics = ssi_recentTopics($limit, null, null, 'array');
if (empty($topics))
{
echo '
', $txt['error_sp_no_topics_found'];
return;
}
$colorids = array();
foreach ($topics as $topic)
$colorids[] = $topic['poster']['id'];
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($topics as $k => $p)
{
if (!empty($color_profile[$p['poster']['id']]['link']))
$topics[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
}
}
echo '
';
foreach ($topics as $topic)
echo '
', sp_embed_image('topic'), '
|
', $topic['subject'], '
', $topic['new'] ? '' : '', ' [', $topic['board']['link'], ']
|
', $topic['poster']['link'], ' ', $topic['time'], '
|
';
echo '
';
}
function sp_topTopics($parameters, $id, $return_parameters = false)
{
global $smcFunc, $txt, $scripturl, $user_info, $user_info, $modSettings, $topics;
$block_parameters = array(
'type' => 'select',
'limit' => 'int',
);
if ($return_parameters)
return $block_parameters;
$type = !empty($parameters['type']) ? $parameters['type'] : 0;
$limit = !empty($parameters['limit']) ? $parameters['limit'] : 5;
$topics = ssi_topTopics($type ? 'views' : 'replies', $limit, 'array');
if (empty($topics))
{
echo '
', $txt['error_sp_no_topics_found'];
return;
}
else
$topics[count($topics) - 1]['is_last'] = true;
echo '
';
foreach ($topics as $topic)
echo '
- ', sp_embed_image('topic'), ' ', $topic['link'], '
- ', $txt['replies'], ': ', $topic['num_replies'], ' | ', $txt['views'], ': ', $topic['num_views'], '
';
echo '
';
}
function sp_topBoards($parameters, $id, $return_parameters = false)
{
global $context, $settings, $smcFunc, $txt, $scripturl, $user_info, $user_info, $modSettings, $boards;
$block_parameters = array(
'limit' => 'int',
);
if ($return_parameters)
return $block_parameters;
$limit = !empty($parameters['limit']) ? $parameters['limit'] : 5;
$boards = ssi_topBoards($limit, 'array');
if (empty($boards))
{
echo '
', $txt['error_sp_no_boards_found'];
return;
}
else
$boards[count($boards) - 1]['is_last'] = true;
echo '
';
foreach ($boards as $board)
echo '
- ', sp_embed_image('board'), ' ', $board['link'], '
- ', $txt['topics'], ': ', $board['num_topics'], ' | ', $txt['posts'], ': ', $board['num_posts'], '
';
echo '
';
}
function sp_showPoll($parameters, $id, $return_parameters = false)
{
global $smcFunc, $context, $scripturl, $modSettings, $boardurl, $txt;
$block_parameters = array(
'topic' => 'int',
'type' => 'select',
);
if ($return_parameters)
return $block_parameters;
$topic = !empty($parameters['topic']) ? $parameters['topic'] : null;
$type = !empty($parameters['type']) ? (int) $parameters['type'] : 0;
$boardsAllowed = boardsAllowedTo('poll_view');
if (empty($boardsAllowed))
{
loadLanguage('Errors');
echo '
', $txt['cannot_poll_view'];
return;
}
if (!empty($type))
{
$request = $smcFunc['db_query']('', '
SELECT t.id_topic
FROM {db_prefix}polls AS p
INNER JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved}' : '') . ')
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
WHERE {query_wanna_see_board}' . (!in_array(0, $boardsAllowed) ? '
AND b.id_board IN ({array_int:boards_allowed_list})' : '') . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
AND b.id_board != {int:recycle_enable}' : '') . '
ORDER BY {raw:type}
LIMIT 1',
array(
'boards_allowed_list' => $boardsAllowed,
'is_approved' => 1,
'recycle_enable' => $modSettings['recycle_board'],
'type' => $type == 1 ? 'p.id_poll DESC' : 'RAND()',
)
);
list ($topic) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
}
if (empty($topic) || $topic < 0)
{
loadLanguage('Errors');
echo '
', $txt['topic_doesnt_exist'];
return;
}
$poll = ssi_showPoll($topic, 'array');
if ($poll['allow_vote'])
{
echo '
';
}
elseif ($poll['allow_view_results'])
{
echo '
- ', $poll['question'], '
';
foreach ($poll['options'] as $option)
echo '
- ', sp_embed_image('dot'), ' ', $option['option'], '
- ', $option['votes'], ' (', $option['percent'], '%)
';
echo '
- ', $txt['poll_total_voters'], ': ', $poll['total_votes'], '
- ', $txt['sp-pollViewTopic'], '
';
}
else
echo '
', $txt['poll_cannot_see'];
}
function sp_boardNews($parameters, $id, $return_parameters = false)
{
global $scripturl, $txt, $settings, $modSettings, $context, $smcFunc, $color_profile;
$block_parameters = array(
'board' => 'int',
'limit' => 'int',
'start' => 'int',
'length' => 'int',
'avatar' => 'check',
'per_page' => 'int',
);
if ($return_parameters)
return $block_parameters;
$board = !empty($parameters['board']) ? (int) $parameters['board'] : null;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
$start = !empty($parameters['start']) ? (int) $parameters['start'] : 0;
$length = isset($parameters['length']) ? (int) $parameters['length'] : 250;
$avatars = !empty($parameters['avatar']);
$per_page = !empty($parameters['per_page']) ? (int) $parameters['per_page'] : 0;
$limit = max(0, $limit);
$start = max(0, $start);
loadLanguage('Stats');
$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';
$request = $smcFunc['db_query']('', '
SELECT id_first_msg
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
WHERE ' . (empty($board) ? '{query_see_board}
AND t.id_first_msg >= {int:min_msg_id}' : 'b.id_board = {int:current_board}') . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}' : '') . '
ORDER BY t.id_first_msg DESC
LIMIT {int:limit}',
array(
'current_board' => $board,
'min_msg_id' => $modSettings['maxMsgID'] - 45 * min($limit, 5),
'is_approved' => 1,
'limit' => $limit,
)
);
$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$posts[] = $row['id_first_msg'];
$smcFunc['db_free_result']($request);
if (empty($posts))
{
echo '
', $txt['error_sp_no_posts_found'];
return;
}
elseif (!empty($per_page))
{
$limit = count($posts);
$start = !empty($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
$page_index = constructPageIndex($context['portal_url'] . '?sa=news', $start, $limit, $per_page);
}
$request = $smcFunc['db_query']('', '
SELECT
m.icon, m.subject, m.body, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time,
t.num_replies, t.id_topic, m.id_member, m.smileys_enabled, m.id_msg, t.locked, mem.avatar,
a.id_attach, a.attachment_type, a.filename, t.num_views
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE t.id_first_msg IN ({array_int:post_list})
ORDER BY t.id_first_msg DESC
LIMIT ' . (!empty($per_page) ? '{int:start}, ' : '') . '{int:limit}',
array(
'post_list' => $posts,
'start' => $start,
'limit' => !empty($per_page) ? $per_page : $limit,
)
);
$return = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($length) && $smcFunc['strlen']($row['body']) > $length)
$row['body'] = parse_bbc(sp_truncateText($row['body'], $length), $row['smileys_enabled'], $row['id_msg']) . '...';
else
$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}
if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';
censorText($row['subject']);
censorText($row['body']);
if ($modSettings['sp_resize_images'])
$row['body'] = preg_replace('~class="bbc_img"~i', 'class="bbc_img sp_article"', $row['body']);
if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];
$return[] = array(
'id' => $row['id_topic'],
'message_id' => $row['id_msg'],
'icon' => '',
'subject' => $row['subject'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'timeyear' => timeformat($row['poster_time'], '%d %b %y'),
'timeday' => timeformat($row['poster_time'], '%H:%M:%S'),
'views' => $row['num_views'],
'body' => $row['body'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'link' => '' . $txt['sp-read_more'] . '',
'replies' => $row['num_replies'],
'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'],
'comment_link' => !empty($row['locked']) ? '' : '| ' . $txt['ssi_write_comment'] . '',
'new_comment' => !empty($row['locked']) ? '' : '| ' . $txt['ssi_write_comment'] . '',
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
'link' => !empty($row['id_member']) ? '' . $row['poster_name'] . '' : $row['poster_name']
),
'locked' => !empty($row['locked']),
'is_last' => false,
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '' : '') : (stristr($row['avatar'], 'http://') ? '' : ''),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
);
}
$smcFunc['db_free_result']($request);
if (empty($return))
{
echo '
', $txt['error_sp_no_posts_found'];
return;
}
$return[count($return) - 1]['is_last'] = true;
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($return as $k => $p)
{
if (!empty($color_profile[$p['poster']['id']]['link']))
$return[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
}
}
foreach ($return as $news)
{
echo '
', $news['icon'], ' |
', $news['subject'], ' | ', $news['timeyear'], ' |
';
if ($avatars && $news['avatar']['name'] !== null && !empty($news['avatar']['href']))
echo '
', $news['timeday'], ' ', $txt['by'], ' ', $news['poster']['link'], ' ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], ' ';
else
echo '
', $news['timeday'], ' ', $txt['by'], ' ', $news['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $news['views'], ' | ', $txt['sp-articlesComments'], ': ', $news['replies'], ' ';
echo '
', $news['body'], '
|
', $news['link'], ' ', $news['new_comment'], '
|
';
}
if (!empty($per_page))
echo '
', $txt['sp-articlesPages'], ': ', $page_index, '
';
}
function sp_quickSearch($parameters, $id, $return_parameters = false)
{
global $scripturl, $txt, $context;
$block_parameters = array();
if ($return_parameters)
return $block_parameters;
echo '
';
}
function sp_news($parameters, $id, $return_parameters = false)
{
global $context;
$block_parameters = array();
if ($return_parameters)
return $block_parameters;
echo '
', $context['random_news_line'], '
';
}
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
global $boarddir, $txt, $color_profile;
$block_parameters = array(
'limit' => 'int',
'direction' => 'select',
);
if ($return_parameters)
return $block_parameters;
$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
$direction = empty($parameters['direction']) ? 0 : 1;
$type = array('jpg', 'png', 'gif', 'bmp');
$items = ssi_recentAttachments($limit, $type, 'array');
if (empty($items))
{
echo '
', $txt['error_sp_no_attachments_found'];
return;
}
$colorids = array();
foreach ($items as $item)
$colorids[] = $item['member']['id'];
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($items as $k => $p)
{
if (!empty($color_profile[$p['member']['id']]['link']))
$items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
}
}
echo '
', $direction ? '
' : '';
foreach ($items as $item)
{
echo !$direction ? '
' : '', '
', $item['file']['filename'], '
', $item['file']['image']['link'], '
', $txt['downloads'], ': ', $item['file']['downloads'], '
', $txt['posted_by'], ': ', $item['member']['link'], '
| ', !$direction ? '
' : '';
}
echo $direction ? '
' : '', '
';
}
function sp_attachmentRecent($parameters, $id, $return_parameters = false)
{
global $txt;
$block_parameters = array(
'limit' => 'int',
);
if ($return_parameters)
return $block_parameters;
$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
$items = ssi_recentAttachments($limit, array(), 'array');
if (empty($items))
{
echo '
', $txt['error_sp_no_attachments_found'];
return;
}
echo '
';
foreach ($items as $item)
echo '
- ', sp_embed_image('attach'), ' ', $item['file']['filename'], '
- ', $txt['downloads'], ': ', $item['file']['downloads'], '
- ', $txt['filesize'], ': ', $item['file']['filesize'], '
';
echo '
';
}
function sp_calendar($parameters, $id, $return_parameters = false)
{
global $context, $sourcedir, $modSettings, $options, $scripturl, $txt;
$block_parameters = array(
'events' => 'check',
'birthdays' => 'check',
'holidays' => 'check',
);
if ($return_parameters)
return $block_parameters;
require_once($sourcedir . '/Subs-Calendar.php');
$today = getTodayInfo();
$curPage = array(
'day' => $today['day'],
'month' => $today['month'],
'year' => $today['year']
);
$calendarOptions = array(
'start_day' => !empty($options['calendar_start_day']) ? $options['calendar_start_day'] : 0,
'show_week_num' => false,
'show_events' => !empty($parameters['events']),
'show_birthdays' => !empty($parameters['birthdays']),
'show_holidays' => !empty($parameters['holidays']),
);
$calendar_data = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
echo '
', $txt['months_titles'][$calendar_data['current_month']], ' ', $calendar_data['current_year'], '
|
';
foreach ($calendar_data['week_days'] as $day)
echo '
', $txt['days_short'][$day], ' | ';
echo '
';
foreach ($calendar_data['weeks'] as $week_key => $week)
{
echo '';
foreach ($week['days'] as $day_key => $day)
{
echo '
';
if (empty($day['day']))
unset($calendar_data['weeks'][$week_key]['days'][$day_key]);
else
{
if ($curPage['month'] == 8 && $day['day'] == 25)
{
$calendar_data['weeks'][$week_key]['days'][$day_key]['holidays']['e'] = base64_decode('RWxpYW5hIERheQ==');
$has_info = true;
}
else
$has_info = !empty($day['holidays']) || !empty($day['birthdays']) || !empty($day['events']);
if ($has_info)
echo '', $day['is_today'] ? '[' : '', $day['day'], $day['is_today'] ? ']' : '', '';
else
echo '', $day['is_today'] ? '[' : '', $day['day'], $day['is_today'] ? ']' : '', '';
}
echo ' | ';
}
echo '
';
}
echo '
';
foreach ($calendar_data['weeks'] as $week)
{
foreach ($week['days'] as $day)
{
if (empty($day['holidays']) && empty($day['birthdays']) && empty($day['events']) && !$day['is_today'])
continue;
elseif (empty($day['holidays']) && empty($day['birthdays']) && empty($day['events']))
{
echo '
', $txt['error_sp_no_items_day'], '
';
continue;
}
echo '
';
if (!empty($day['holidays']))
{
echo '
- - ', $txt['sp_calendar_holidays'] ,' -
';
foreach ($day['holidays'] as $key => $holiday)
echo '
- ', sp_embed_image($key === 'e' ? 'diamond' : 'holiday'), ' ', $holiday ,'
';
}
if (!empty($day['birthdays']))
{
echo '
- - ', $txt['sp_calendar_birthdays'] ,' -
';
foreach ($day['birthdays'] as $member)
echo '
- ', sp_embed_image('birthday'), ' ', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '
';
}
if (!empty($day['events']))
{
echo '
- - ', $txt['sp_calendar_events'] ,' -
';
foreach ($day['events'] as $event)
echo '
- ', sp_embed_image('event'), ' ', $event['link'], '
';
}
echo '
';
}
}
echo '
', $txt['error_sp_no_items_day'], '
';
}
function sp_calendarInformation($parameters, $id, $return_parameters = false)
{
global $scripturl, $modSettings, $txt;
$block_parameters = array(
'events' => 'check',
'future' => 'int',
'birthdays' => 'check',
'holidays' => 'check',
);
if ($return_parameters)
return $block_parameters;
$show_event = !empty($parameters['events']);
$event_future = !empty($parameters['future']) ? (int) $parameters['future'] : 0;
$event_future = abs($event_future);
$show_birthday = !empty($parameters['birthdays']);
$show_holiday = !empty($parameters['holidays']);
$show_titles = false;
if (!$show_event && !$show_birthday && !$show_holiday)
{
echo '
', $txt['sp_calendar_noEventsFound'];
return;
}
$now = forum_time();
$today_date = date("Y-m-d", $now);
$calendar_array = array(
'todayEvents' => array(),
'futureEvents' => array(),
'todayBirthdays' => array(),
'todayHolidays' => array()
);
if ($show_event)
{
if (!empty($event_future))
$event_future_date = date("Y-m-d", ($now + $event_future * 86400));
else
$event_future_date = $today_date;
$events = sp_loadCalendarData('getEvents', $today_date, $event_future_date);
$displayed = array();
foreach ($events as $day => $day_events)
foreach ($day_events as $event_key => $event)
if (in_array($event['id'], $displayed))
unset($events[$day][$event_key]);
else
$displayed[] = $event['id'];
if (!empty($events[$today_date]))
{
$calendar_array['todayEvents'] = $events[$today_date];
unset($events[$today_date]);
}
if (!empty($events))
{
ksort($events);
$calendar_array['futureEvents'] = $events;
}
}
if ($show_birthday)
{
$calendar_array['todayBirthdays'] = current(sp_loadCalendarData('getBirthdays', $today_date));
$show_titles = !empty($show_event) || !empty($show_holiday);
}
if ($show_holiday)
{
$calendar_array['todayHolidays'] = current(sp_loadCalendarData('getHolidays', $today_date));
$show_titles = !empty($show_event) || !empty($show_birthday);
if (timeformat(forum_time(), '%d-%m') == '25-08')
$calendar_array['todayHolidays']['e'] = base64_decode('RWxpYW5hIERheQ==');
}
if (empty($calendar_array['todayEvents']) && empty($calendar_array['futureEvents']) && empty($calendar_array['todayBirthdays']) && empty($calendar_array['todayHolidays']))
{
echo '
', $txt['sp_calendar_noEventsFound'];
return;
}
else
{
echo '
';
if (!empty($calendar_array['todayHolidays']))
{
if ($show_titles)
echo '
- ', $txt['sp_calendar_holidays'] ,'
';
foreach ($calendar_array['todayHolidays'] as $key => $holiday)
echo '
- ', sp_embed_image($key === 'e' ? 'diamond' : 'holiday'), ' ', $holiday ,'
';
}
if (!empty($calendar_array['todayBirthdays']))
{
if ($show_titles)
echo '
- ', $txt['sp_calendar_birthdays'] ,'
';
foreach ($calendar_array['todayBirthdays'] as $member)
echo '
- ', sp_embed_image('birthday'), ' ', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '
';
}
if (!empty($calendar_array['todayEvents']))
{
if ($show_titles)
echo '
- ', $txt['sp_calendar_events'] ,'
';
foreach ($calendar_array['todayEvents'] as $event)
echo '
- ', sp_embed_image('event'), ' ', $event['link'], !$show_titles ? ' - ' . timeformat(forum_time(), '%d %b') : '', '
';
}
if (!empty($calendar_array['futureEvents']))
{
if ($show_titles)
echo '
- ', $txt['sp_calendar_upcomingEvents'] ,'
';
foreach($calendar_array['futureEvents'] as $startdate => $events)
{
list($year, $month, $day) = explode('-', $startdate);
$currentDay = $day . ' ' . $txt['months_short'][(int) $month];
foreach($events as $event)
echo '
- ', sp_embed_image('event'), ' ', $event['link'], ' - ', $currentDay;
}
}
echo '
';
}
}
function sp_rssFeed($parameters, $id, $return_parameters = false)
{
global $smcFunc, $sourcedir, $context, $txt, $rss_data, $rss_current, $rss_counter;
$block_parameters = array(
'url' => 'text',
'titles_only' => 'check',
'count' => 'int',
'limit' => 'int',
);
if ($return_parameters)
return $block_parameters;
$feed = !empty($parameters['url']) ? $parameters['url'] : '';
$only_titles = !empty($parameters['titles_only']);
$count = !empty($parameters['count']) ? (int) $parameters['count'] : 5;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 150;
if (empty($feed))
{
echo '
', $txt['error_sp_invalid_feed'];
return;
}
$rss_data = array();
$rss_current = '';
$rss_counter = 0;
$rss_main = '';
require_once($sourcedir . '/Subs-Package.php');
$xml_data = fetch_web_data($feed);
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "sp_startElement", "sp_endElement");
xml_set_character_data_handler($xml_parser, "sp_characterData");
if (function_exists('mb_convert_encoding'))
{
preg_match('~encoding="([^"]*)"~', $xml_data, $xml_charset);
if (!empty($xml_charset[1]) && $xml_charset != $context['character_set'])
$xml_data = mb_convert_encoding($xml_data, $context['character_set'], $xml_charset[1]);
}
elseif (function_exists('iconv'))
{
preg_match('~encoding="([^"]*)"~', $xml_data, $xml_charset);
if (!empty($xml_charset[1]) && $xml_charset != $context['character_set'])
$xml_data = iconv($xml_charset[1], $context['character_set'], $xml_data);
}
if (!xml_parse($xml_parser, $xml_data))
{
$xmlerr = (sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
if (!empty($xmlerr))
{
echo '
', $xmlerr;
return;
}
if (empty($rss_data))
{
echo '
', $txt['error_sp_invalid_feed'];
return;
}
$items = array();
$counter = 0;
if (!empty($rss_data['ITEMS']))
{
foreach($rss_data['ITEMS'] as $item)
{
if (empty($item['TITLE']))
$item['TITLE'] = '';
else
$item['TITLE'] = strip_tags($item['TITLE']);
if (empty($item['LINK']))
$item['LINK'] = '';
else
$item['LINK'] = strip_tags($item['LINK']);
if (empty($item['DESCRIPTION']))
continue;
else
$item['DESCRIPTION'] = strip_tags($item['DESCRIPTION'], '
');
if ($smcFunc['strlen']($item['DESCRIPTION']) > $limit)
$item['DESCRIPTION'] = $smcFunc['substr']($item['DESCRIPTION'], 0, $limit) . '...';
$items[] = array(
'title' => $item['TITLE'],
'href' => $item['LINK'],
'link' => $item['TITLE'] == '' ? '' : ($item['LINK'] == '' ? $item['TITLE'] : '' . $item['TITLE'] . ''),
'content' => $item['DESCRIPTION'],
);
if (++$counter == $count)
break;
}
}
if (empty($items))
{
echo '
', $txt['error_sp_invalid_feed'];
return;
}
else
$items[count($items) - 1]['is_last'] = true;
if ($only_titles)
{
echo '
';
foreach ($items as $item)
echo '
- ', sp_embed_image('dot_feed'), ' ', $item['link'], '
';
echo '
';
}
else
{
echo '
';
}
}
function sp_theme_select($parameters, $id, $return_parameters = false)
{
global $smcFunc, $context, $modSettings, $user_info, $settings, $language, $txt;
$block_parameters = array();
if ($return_parameters)
return $block_parameters;
loadLanguage('Profile');
loadLanguage('Themes');
if (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
$current_theme = (int) $_SESSION['id_theme'];
else
$current_theme = $user_info['theme'];
$current_theme = empty($current_theme) ? -1 : $current_theme;
$available_themes = array();
if (!empty($modSettings['knownThemes']))
{
$request = $smcFunc['db_query']('', '
SELECT id_theme, variable, value
FROM {db_prefix}themes
WHERE variable IN ({string:name}, {string:theme_url}, {string:theme_dir}, {string:images_url})
AND id_theme IN ({array_string:known_themes})
AND id_theme != {int:default_theme}',
array(
'default_theme' => 0,
'name' => 'name',
'theme_url' => 'theme_url',
'theme_dir' => 'theme_dir',
'images_url' => 'images_url',
'known_themes' => explode(',', $modSettings['knownThemes']),
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!isset($available_themes[$row['id_theme']]))
$available_themes[$row['id_theme']] = array(
'id' => $row['id_theme'],
'selected' => $current_theme == $row['id_theme'],
);
$available_themes[$row['id_theme']][$row['variable']] = $row['value'];
}
$smcFunc['db_free_result']($request);
}
if (!isset($available_themes[$modSettings['theme_guests']]))
{
$available_themes[0] = array(
'num_users' => 0
);
$guest_theme = 0;
}
else
$guest_theme = $modSettings['theme_guests'];
$current_images_url = $settings['images_url'];
foreach ($available_themes as $id_theme => $theme_data)
{
if ($id_theme == 0)
continue;
$settings['images_url'] = &$theme_data['images_url'];
if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'))
include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'))
include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
else
{
$txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.gif';
$txt['theme_description'] = '';
}
$available_themes[$id_theme]['thumbnail_href'] = $txt['theme_thumbnail_href'];
$available_themes[$id_theme]['description'] = $txt['theme_description'];
$available_themes[$id_theme]['name'] = preg_replace('~\stheme$~i', '', $theme_data['name']);
if ($smcFunc['strlen']($available_themes[$id_theme]['name']) > 18)
$available_themes[$id_theme]['name'] = $smcFunc['substr']($available_themes[$id_theme]['name'], 0, 18) . '...';
}
$settings['images_url'] = $current_images_url;
if ($guest_theme != 0)
$available_themes[-1] = $available_themes[$guest_theme];
$available_themes[-1]['id'] = -1;
$available_themes[-1]['name'] = $txt['theme_forum_default'];
$available_themes[-1]['selected'] = $current_theme == 0;
$available_themes[-1]['description'] = $txt['theme_global_description'];
ksort($available_themes);
if (!empty($_POST['sp_ts_submit']) && !empty($_POST['sp_ts_permanent']) && !empty($_POST['theme']) && isset($available_themes[$_POST['theme']]) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
updateMemberData($user_info['id'], array('id_theme' => $_POST['theme'] == -1 ? 0 : (int) $_POST['theme']));
echo '
';
}
function sp_staff($parameters, $id, $return_parameters = false)
{
global $smcFunc, $sourcedir, $scripturl, $modSettings, $color_profile;
$block_parameters = array(
'lmod' => 'check',
);
if ($return_parameters)
return $block_parameters;
require_once($sourcedir . '/Subs-Members.php');
if (empty($parameters['lmod']))
{
$request = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}moderators AS mods',
array(
)
);
$local_mods = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$local_mods[$row['id_member']] = $row['id_member'];
$smcFunc['db_free_result']($request);
if (count($local_mods) > 10)
$local_mods = array();
}
else
$local_mods = array();
$global_mods = membersAllowedTo('moderate_board', 0);
$admins = membersAllowedTo('admin_forum');
$all_staff = array_merge($local_mods, $global_mods, $admins);
$all_staff = array_unique($all_staff);
$request = $smcFunc['db_query']('', '
SELECT
m.id_member, m.real_name, m.avatar, mg.group_name,
a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}members AS m
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN m.id_group = {int:reg_group_id} THEN m.id_post_group ELSE m.id_group END)
WHERE m.id_member IN ({array_int:staff_list})',
array(
'staff_list' => $all_staff,
'reg_group_id' => 0,
)
);
$staff_list = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$colorids[$row['id_member']] = $row['id_member'];
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}
if (in_array($row['id_member'], $admins))
$row['type'] = 1;
elseif (in_array($row['id_member'], $global_mods))
$row['type'] = 2;
else
$row['type'] = 3;
$staff_list[$row['type'] . '-' . $row['id_member']] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'link' => '' . $row['real_name'] . '',
'group' => $row['group_name'],
'type' => $row['type'],
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '' : '') : (stristr($row['avatar'], 'http://') ? '' : ''),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
);
}
$smcFunc['db_free_result']($request);
ksort($staff_list);
$staff_count = count($staff_list);
$count = 0;
$icons = array(1 => 'admin', 'gmod', 'lmod');
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($staff_list as $k => $p)
{
if (!empty($color_profile[$p['id']]['link']))
$staff_list[$k]['link'] = $color_profile[$p['id']]['link'];
}
}
echo '
';
foreach ($staff_list as $staff)
echo '
', !empty($staff['avatar']['href']) ? '
' : '', '
|
', sp_embed_image($icons[$staff['type']]), ' ', $staff['link'], '
', $staff['group'], '
|
';
echo '
';
}
function sp_articles($parameters, $id, $return_parameters = false)
{
global $smcFunc, $modSettings, $scripturl, $txt, $color_profile;
$block_parameters = array(
'limit' => 'int',
'type' => 'select',
'image' => 'select',
);
if ($return_parameters)
return $block_parameters;
$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
$type = empty($parameters['type']) ? 0 : 1;
$image = empty($parameters['image']) ? 0 : (int) $parameters['image'];
$request = $smcFunc['db_query']('','
SELECT
m.id_topic, m.subject, m.poster_name, c.picture, c.name,
mem.id_member, mem.real_name, mem.avatar,
at.id_attach, at.attachment_type, at.filename
FROM {db_prefix}sp_articles AS a
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS at ON (at.id_member = mem.id_member)
WHERE {query_see_board}
AND a.approved = {int:approved}
ORDER BY {raw:type}
LIMIT {int:limit}',
array(
'approved' => 1,
'type' => $type ? 'RAND()' : 'm.poster_time DESC',
'limit' => $limit,
)
);
$articles = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}
$articles[] = array(
'id' => $row['id_topic'],
'name' => $row['subject'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'link' => '' . $row['subject'] . '',
'poster' => array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '' . $row['real_name'] . '',
),
'image' => array(
'href' => $row['picture'],
'image' => '',
),
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '' : '') : (stristr($row['avatar'], 'http://') ? '' : ''),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
);
}
$smcFunc['db_free_result']($request);
if (empty($articles))
{
echo '
', $txt['error_sp_no_articles_found'];
return;
}
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($articles as $k => $p)
{
if (!empty($color_profile[$p['poster']['id']]['link']))
$articles[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
}
}
if (empty($image))
{
echo '
';
foreach ($articles as $article)
echo '
- ', sp_embed_image('topic'), ' ', $article['link'], '
';
echo '
';
}
else
{
echo '
';
foreach ($articles as $article)
{
echo '
';
if (!empty($article['avatar']['href']) && $image == 1)
echo '';
elseif (!empty($article['image']['href']) && $image == 2)
echo '';
echo ' |
', $article['poster']['link'], '
', $article['link'], '
|
';
}
echo '
';
}
}
function sp_gallery($parameters, $id, $return_parameters = false)
{
global $smcFunc, $context, $modSettings, $scripturl;
global $sourcedir, $txt, $settings, $boardurl, $galurl;
static $mod, $GD_Installed;
$block_parameters = array(
'limit' => 'int',
'type' => 'select',
'direction' => 'select',
);
if ($return_parameters)
return $block_parameters;
$limit = empty($parameters['limit']) ? 1 : (int) $parameters['limit'];
$type = empty($parameters['type']) ? 0 : 1;
$direction = empty($parameters['direction']) ? 0 : 1;
if (!isset($mod))
{
if (file_exists($sourcedir . '/MGallery.php'))
$mod = 'smf_media_gallery';
elseif (file_exists($sourcedir . '/Gallery.php') || file_exists($sourcedir . '/Gallery2.php'))
$mod = 'smf_gallery';
else
$mod = '';
}
if (empty($mod))
{
echo '
', $txt['error_sp_no_gallery_found'];
return;
}
elseif ($mod == 'smf_media_gallery')
{
require_once($sourcedir . '/Subs-MGallery.php');
loadMGal_Settings();
loadLanguage('MGallery', sp_languageSelect('MGallery'));
$items = getMediaItems(0, $limit, $type ? 'RAND()' : 'm.id_media DESC');
}
elseif ($mod == 'smf_gallery')
{
loadLanguage('Gallery', sp_languageSelect('Gallery'));
if (!isset($GD_Installed))
$GD_Installed = function_exists('imagecreate');
if (empty($modSettings['gallery_url']))
$modSettings['gallery_url'] = $boardurl . '/gallery/';
$request = $smcFunc['db_query']('','
SELECT
p.id_picture, p.commenttotal, p.filesize, p.views, p.thumbfilename,
p.filename, p.height, p.width, p.title, p.id_member, m.member_name,
m.real_name, p.date, p.description
FROM {db_prefix}gallery_pic AS p
LEFT JOIN {db_prefix}members AS m ON (m.id_member = p.id_member)
WHERE p.approved = {int:is_approved}
ORDER BY {raw:type}
LIMIT {int:limit}',
array(
'is_approved' => 1,
'type' => $type ? 'RAND()' : 'p.id_picture DESC',
'limit' => $limit,
)
);
$items = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$items[] = array(
'id' => $row['id_picture'],
'title' => $row['title'],
'views' => $row['views'],
'poster_id' => $row['id_member'],
'poster_name' => $row['real_name'],
'poster_link' => empty($row['id_member']) ? $txt['gallery_guest'] : '' . $row['real_name'] . '',
'thumbfilename' => $row['thumbfilename'],
'filename' => $row['filename'],
'src' => $modSettings['gallery_url'] . ($GD_Installed ? $row['thumbfilename'] : $row['filename'] . '" width="120'),
);
}
$smcFunc['db_free_result']($request);
}
if (empty($items))
{
echo '
', $txt['error_sp_no_pictures_found'];
return;
}
echo '
', $direction ? '
' : '';
foreach ($items as $item)
{
echo !$direction ? '
' : '', '
';
if ($mod == 'smf_media_gallery')
{
echo '
', $item['title'], '
', $txt['mgallery_views'], ': ', $item['views'], '
', $txt['mgallery_posted_by'], ': ', $item['poster_name'], '
', $txt['mgallery_in_album'], ': ', $item['album_name'], '', $item['is_new'] ?
' ' : '';
}
elseif ($mod == 'smf_gallery')
{
echo '
', $item['title'], '
', $txt['gallery_text_views'], $item['views'], '
', $txt['gallery_text_by'], ' ', $item['poster_link'], ' ';
}
echo '
| ', !$direction ? '
' : '';
}
echo $direction ? '
' : '', '
';
}
function sp_arcade($parameters, $id, $return_parameters = false)
{
global $smcFunc, $sourcedir, $scripturl, $settings, $txt, $color_profile;
static $mod;
$block_parameters = array(
'limit' => 'int',
'type' => 'select',
);
if ($return_parameters)
return $block_parameters;
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
$type = !empty($parameters['type']) ? (int) $parameters['type'] : 0;
if (!isset($mod))
{
if (file_exists($sourcedir . '/Arcade.php'))
$mod = 'smf_arcade';
else
$mod = '';
}
if (empty($mod))
{
echo '
', $txt['error_sp_no_arcade_found'];
return;
}
elseif ($mod == 'smf_arcade')
{
require_once($sourcedir . '/ArcadeStats.php');
require_once($sourcedir . '/Subs-Arcade.php');
loadLanguage('Arcade');
if (empty($type))
$stats = ArcadeStats_MostPlayed($limit);
elseif ($type == 1)
$stats = ArcadeStats_BestPlayers($limit);
elseif ($type == 2)
$stats = ArcadeStats_LongestChampions($limit);
if (empty($stats))
{
echo '
', $txt['error_sp_no_stats_found'];
return;
}
else
$stats[count($stats) - 1]['last'] = true;
echo '
';
if (empty($type))
{
foreach ($stats as $stat)
{
echo '
- ', sp_embed_image('game'), ' ', $stat['link'], '
- ', $txt['sp-game_plays'], ': ', $stat['plays'], ' | ', $txt['sp-game_rating'], ': ', $stat['rating'], '
';
}
}
elseif ($type == 1)
{
$types = array(1 => 'gold', 'silver', 'bronze');
$current = 0;
foreach ($stats as $stat)
{
echo '
- ', sp_embed_image(isset($types[++$current]) ? $types[$current] : 'user' ), ' ', $stat['link'], '
- ', $stat['champions'], ' ', $txt['sp-games'], '
';
}
}
elseif ($type == 2)
{
$types = array(1 => 'gold', 'silver', 'bronze');
$current = 0;
foreach ($stats as $stat)
{
echo '
- ', sp_embed_image(isset($types[++$current]) ? $types[$current] : 'user' ), ' ', $stat['member_link'], '
- ', $stat['game_link'], '
', $stat['duration'], ' ';
}
}
echo '
';
}
}
function sp_shop($parameters, $id, $return_parameters = false)
{
global $smcFunc, $sourcedir, $scripturl, $txt, $color_profile;
global $context, $boardurl, $modSettings;
static $mod;
$block_parameters = array(
'style' => 'select',
'limit' => 'int',
'type' => 'select',
'sort' => 'select',
);
if ($return_parameters)
return $block_parameters;
$style = !empty($parameters['style']);
$limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
$type = !empty($parameters['type']) ? (int) $parameters['type'] : 0;
$sort = !empty($parameters['sort']);
if (!isset($mod))
{
if (file_exists($sourcedir . '/shop'))
$mod = 'smf_shop';
else
$mod = '';
}
if (empty($mod))
{
echo '
', $txt['error_sp_no_shop_found'];
return;
}
elseif ($mod == 'smf_shop')
{
require_once($sourcedir . '/shop/Shop-Subs.php');
loadLanguage('Shop');
if (empty($style))
{
$request = $smcFunc['db_query']('','
SELECT id_member, real_name, {raw:type} AS money
FROM {db_prefix}members
ORDER BY money DESC
LIMIT {int:limit}',
array(
'type' => $type == 0 ? '(money + moneyBank)' : ($type == 1 ? 'money' : 'moneyBank'),
'limit' => $limit,
)
);
$members = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];
$members[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '' . $row['real_name'] . '',
'money' => formatMoney($row['money']),
);
}
$smcFunc['db_free_result']($request);
if (empty($members))
{
echo '
', $txt['error_sp_no_members_found'];
return;
}
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($members as $k => $p)
{
if (!empty($color_profile[$p['id']]['link']))
$members[$k]['link'] = $color_profile[$p['id']]['link'];
}
}
echo '
';
foreach ($members as $member)
echo '
- ', sp_embed_image('money'), ' ', $member['link'], ' - ', $member['money'], '
';
echo '
';
}
else
{
$request = $smcFunc['db_query']('','
SELECT id, name, price, image
FROM {db_prefix}shop_items
WHERE stock > {int:none}
ORDER BY {raw:type}
LIMIT {int:limit}',
array(
'none' => 0,
'type' => $sort ? 'RAND()' : 'id DESC',
'limit' => $limit,
)
);
$items = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$items[] = array(
'id' => $row['id'],
'name' => $row['name'],
'href' => $scripturl . '?action=shop;do=buy2;id=' . $row['id'],
'link' => '' . $txt['shop_buynow'] . '',
'price' => $row['price'],
'image' => empty($row['image']) ? '' : '',
);
}
$smcFunc['db_free_result']($request);
if (empty($items))
{
echo '
', $txt['error_sp_no_items_found'];
return;
}
else
$item_count = count($items);
echo '
';
foreach ($items as $item)
echo '
', $item['image'], '
|
', $item['name'], '
', $txt['shop_price'], ': ', $item['price'], '
', $context['user']['money'] < $item['price'] ? sprintf($txt['shop_need'], formatMoney($item['price'] - $context['user']['money'])) : $item['link'], '
|
';
echo '
';
}
}
}
function sp_blog($parameters, $id, $return_parameters = false)
{
global $smcFunc, $scripturl, $user_info, $modSettings;
global $context, $boarddir, $txt, $color_profile;
static $mod;
$block_parameters = array(
'limit' => 'int',
'type' => 'select',
'sort' => 'select',
);
if ($return_parameters)
return $block_parameters;
$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
$type = empty($parameters['type']) ? 0 : 1;
$sort = empty($parameters['sort']) ? 0 : 1;
if (!isset($mod))
{
if (file_exists($boarddir . '/zCommunity'))
$mod = 'zcommunity';
else
$mod = '';
}
if (empty($mod))
{
echo '
', $txt['error_sp_no_blog_found'];
return;
}
elseif ($mod == 'zcommunity')
{
$request = $smcFunc['db_query']('','
SELECT b.blog_id, b.blog_owner, b.member_groups, bs.users_allowed_access, bs.hideBlog AS hidden
FROM {db_prefix}blog_blogs AS b
LEFT JOIN {db_prefix}blog_settings AS bs ON (bs.blog_id = b.blog_id)',
array(
)
);
$visible_blogs = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$can_see_this_blog = false;
if (empty($row['hidden']))
{
$allowedGroups = !empty($row['member_groups']) ? explode(',', $row['member_groups']) : array();
$can_see_this_blog = count(array_intersect($user_info['groups'], $allowedGroups)) > 0;
if (empty($can_see_this_blog) && !empty($row['users_allowed_access']) && !$user_info['is_guest'])
{
$users_allowed = !empty($row['users_allowed_access']) ? explode(',', $row['users_allowed_access']) : array();
$can_see_this_blog = in_array($context['user']['id'], $users_allowed);
}
}
if ($user_info['is_admin'] || ($context['user']['id'] == $row['blog_owner']))
$can_see_this_blog = true;
if ($can_see_this_blog)
$visible_blogs[] = $row['blog_id'];
}
$smcFunc['db_free_result']($request);
if (empty($visible_blogs))
{
echo '
', $txt['error_sp_no_blogs_found'];
return;
}
if (empty($type))
{
$request = $smcFunc['db_query']('','
SELECT t.article_id, t.subject
FROM {db_prefix}blog_articles AS t
LEFT JOIN {db_prefix}blog_settings AS bs ON (bs.blog_id = t.blog_id)
WHERE t.blog_id IN ({array_int:visible_blogs})
AND ((t.approved = 1) OR (bs.articles_require_approval = 0))
ORDER BY {raw:type}
LIMIT {int:limit}',
array(
'visible_blogs' => $visible_blogs,
'type' => $sort ? 'RAND()' : 't.article_id DESC',
'limit' => $limit,
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$articles[] = array(
'id' => $row['article_id'],
'subject' => strip_tags($row['subject']),
'link' => '' . $row['subject'] . '',
);
}
$smcFunc['db_free_result']($request);
echo '
';
foreach ($articles as $article)
echo '
- ', sp_embed_image('blog'), ' ', $article['link'], '
';
echo '
';
}
else
{
$request = $smcFunc['db_query']('','
SELECT
b.blog_id, b.name, t.article_id, t.subject, m.id_member, m.real_name,
m.avatar, a.id_attach, a.attachment_type, a.filename
FROM {db_prefix}blog_blogs AS b
LEFT JOIN {db_prefix}blog_articles AS t ON (t.article_id = b.last_article_id)
LEFT JOIN {db_prefix}members AS m ON (m.id_member = b.blog_owner)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
WHERE b.blog_id IN ({array_int:visible_blogs})
ORDER BY {raw:type}
LIMIT {int:limit}',
array(
'visible_blogs' => $visible_blogs,
'type' => $sort ? 'RAND()' : 'b.last_article_id DESC',
'limit' => $limit,
)
);
$blogs = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['id_member']))
$colorids[$row['id_member']] = $row['id_member'];
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}
$blogs[] = array(
'id' => $row['blog_id'],
'name' => $row['name'],
'href' => $scripturl . '?blog=' . $row['blog_id'] . '.0',
'link' => '' . $row['name'] . '',
'article' => array(
'id' => $row['article_id'],
'subject' => strip_tags($row['subject']),
'link' => '' . $row['subject'] . '',
),
'owner' => array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '' . $row['real_name'] . '',
),
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '' : '') : (stristr($row['avatar'], 'http://') ? '' : ''),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),
);
}
$smcFunc['db_free_result']($request);
if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($blogs as $k => $p)
{
if (!empty($color_profile[$p['owner']['id']]['link']))
$blogs[$k]['owner']['link'] = $color_profile[$p['owner']['id']]['link'];
}
}
echo '
';
foreach ($blogs as $blog)
echo '
', !empty($blog['avatar']['href']) ? '
' : '', '
|
', $blog['owner']['link'], '
', $blog['article']['link'], '
|
';
echo '
';
}
}
}
function sp_menu($parameters, $id, $return_parameters = false)
{
global $context;
$block_parameters = array();
if ($return_parameters)
return $block_parameters;
if (empty($context['menu_buttons']))
setupMenuContext();
echo '
';
}
function sp_bbc($parameters, $id, $return_parameters = false)
{
$block_parameters = array(
'content' => 'textarea',
);
if ($return_parameters)
return $block_parameters;
$content = !empty($parameters['content']) ? $parameters['content'] : '';
echo '
', parse_bbc($content);
}
function sp_html($parameters, $id, $return_parameters = false)
{
$block_parameters = array(
'content' => 'textarea',
);
if ($return_parameters)
return $block_parameters;
$content = !empty($parameters['content']) ? $parameters['content'] : '';
echo '
', un_htmlspecialchars($content);
}
function sp_php($parameters, $id, $return_parameters = false)
{
$block_parameters = array(
'content' => 'textarea',
);
if ($return_parameters)
return $block_parameters;
$content = !empty($parameters['content']) ? $parameters['content'] : '';
$content = trim($content);
$content = trim($content, '');
eval($content);
}
?>