Start B3P v2 :-D
This commit is contained in:
86
root/portal/block/birthday_list.php
Normal file
86
root/portal/block/birthday_list.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2
|
||||
* @version $Id$
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
// Generate birthday list if required ... / borrowed from index.php 3.0.6
|
||||
$birthday_list = $birthday_ahead_list = '';
|
||||
if ($config['load_birthdays'] && $config['allow_birthdays'])
|
||||
{
|
||||
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
|
||||
$cache_days = $portal_config['portal_birthdays_ahead'];
|
||||
$sql_days = '';
|
||||
while ($cache_days > 0)
|
||||
{
|
||||
$day = getdate(time() + 86400 * $cache_days + $user->timezone + $user->dst - date('Z'));
|
||||
$sql_days .= " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $day['mday'], $day['mon'])) . "%'";
|
||||
$cache_days--;
|
||||
}
|
||||
|
||||
switch ($db->sql_layer)
|
||||
{
|
||||
case 'mssql':
|
||||
case 'mssql_odbc':
|
||||
$order_by = 'u.user_birthday ASC';
|
||||
break;
|
||||
|
||||
default:
|
||||
$order_by = 'SUBSTRING(u.user_birthday FROM 4 FOR 2) ASC, SUBSTRING(u.user_birthday FROM 1 FOR 2) ASC, u.username_clean ASC';
|
||||
break;
|
||||
}
|
||||
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
|
||||
$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
|
||||
FROM ' . USERS_TABLE . ' u
|
||||
LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
|
||||
WHERE (b.ban_id IS NULL
|
||||
OR b.ban_exclude = 1)
|
||||
AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$sql_days})
|
||||
AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
|
||||
ORDER BY ' . $order_by;
|
||||
$result = $db->sql_query($sql);
|
||||
$today = sprintf('%2d-%2d-', $now['mday'], $now['mon']);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (substr($row['user_birthday'], 0, 6) == $today)
|
||||
{
|
||||
$birthday_list .= get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
|
||||
if ($age = (int) substr($row['user_birthday'], -4))
|
||||
{
|
||||
$birthday_list .= ' (' . ($now['year'] - $age) . ')';
|
||||
}
|
||||
$birthday_list .= '<br /><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$birthday_ahead_list .= '<span title="' . format_birthday($user_birthday, 'd M') . '">' . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) . '</span>';
|
||||
if ($age = (int) substr($row['user_birthday'], -4))
|
||||
{
|
||||
$birthday_ahead_list .= ' (' . ($now['year'] - $age) . ')';
|
||||
}
|
||||
$birthday_ahead_list .= '<br /><br />';
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
// Assign index specific vars
|
||||
$template->assign_vars(array(
|
||||
'BIRTHDAY_LIST' => $birthday_list,
|
||||
'BIRTHDAYS_AHEAD_LIST' => ($portal_config['portal_birthdays_ahead']) ? $birthday_ahead_list : '',
|
||||
'L_BIRTHDAYS_AHEAD' => sprintf($user->lang['BIRTHDAYS_AHEAD'], $portal_config['portal_birthdays_ahead']),
|
||||
'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false,
|
||||
));
|
||||
|
||||
?>
|
||||
33
root/portal/block/donate.php
Normal file
33
root/portal/block/donate.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2
|
||||
* @version $Id$
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($portal_config['portal_pay_acc'])
|
||||
{
|
||||
if ($portal_config['portal_pay_c_block'])
|
||||
{
|
||||
$template->assign_var('S_DISPLAY_PAY_C', true);
|
||||
}
|
||||
|
||||
if ($portal_config['portal_pay_s_block'])
|
||||
{
|
||||
$template->assign_var('S_DISPLAY_PAY_S', true);
|
||||
}
|
||||
|
||||
// Assign specific vars
|
||||
$template->assign_var('PAY_ACC', $portal_config['portal_pay_acc']);
|
||||
}
|
||||
|
||||
?>
|
||||
66
root/portal/block/friends.php
Normal file
66
root/portal/block/friends.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2
|
||||
* @version $Id$
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
$s_display_friends = false;
|
||||
|
||||
// Output listing of friends online
|
||||
$update_time = $config['load_online_time'] * 60;
|
||||
|
||||
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
|
||||
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
|
||||
'FROM' => array(
|
||||
USERS_TABLE => 'u',
|
||||
ZEBRA_TABLE => 'z'
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(SESSIONS_TABLE => 's'),
|
||||
'ON' => 's.session_user_id = z.zebra_id'
|
||||
)
|
||||
),
|
||||
|
||||
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
|
||||
AND z.friend = 1
|
||||
AND u.user_id = z.zebra_id',
|
||||
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username, u.user_allow_viewonline, u.user_colour',
|
||||
'ORDER_BY' => 'u.username_clean ASC',
|
||||
));
|
||||
|
||||
$result = $db->sql_query_limit($sql, $portal_config['portal_max_online_friends']);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline';
|
||||
$s_display_friends = ($row['user_id']) ? true : false;
|
||||
|
||||
$template->assign_block_vars("friends_{$which}", array(
|
||||
'USER_ID' => $row['user_id'],
|
||||
'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Assign specific vars
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_FRIENDS' => $s_display_friends,
|
||||
'S_ZEBRA_ENABLED' => true,
|
||||
));
|
||||
|
||||
?>
|
||||
8
root/portal/block/index.html
Normal file
8
root/portal/block/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF" text="#000000">
|
||||
</body>
|
||||
</html>
|
||||
55
root/portal/block/latest_bots.php
Normal file
55
root/portal/block/latest_bots.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2
|
||||
* @version $Id$
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
// Last x visited bots
|
||||
$sql = 'SELECT username, user_colour, user_lastvisit
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_type = ' . USER_IGNORE . '
|
||||
ORDER BY user_lastvisit DESC';
|
||||
$result = $db->sql_query_limit($sql, $portal_config['portal_last_visited_bots_number']);
|
||||
$first = true;
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (!$row['user_lastvisit'] && $first == TRUE)
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_LAST_BOTS' => false,
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign_var('S_DISPLAY_LAST_BOTS', true);
|
||||
|
||||
if( $row['user_lastvisit'] > 0 )
|
||||
{
|
||||
$template->assign_block_vars('last_visited_bots', array(
|
||||
'BOT_NAME' => get_username_string('full', '', $row['username'], $row['user_colour']),
|
||||
'LAST_VISIT_DATE' => $user->format_date($row['user_lastvisit']),
|
||||
));
|
||||
}
|
||||
}
|
||||
$first = false;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Assign specific vars
|
||||
$template->assign_vars(array(
|
||||
'LAST_VISITED_BOTS' => sprintf($user->lang['LAST_VISITED_BOTS'], $portal_config['portal_last_visited_bots_number']),
|
||||
'S_LAST_VISITED_BOTS' => ($portal_config['portal_load_last_visited_bots']) ? true : false,
|
||||
));
|
||||
|
||||
?>
|
||||
35
root/portal/block/latest_members.php
Normal file
35
root/portal/block/latest_members.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2
|
||||
* @version $Id$
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = 'SELECT user_id, username, user_regdate, user_colour
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_type <> ' . USER_IGNORE . '
|
||||
AND user_inactive_time = 0
|
||||
ORDER BY user_regdate DESC';
|
||||
$result = $db->sql_query_limit($sql, $portal_config['portal_max_last_member']);
|
||||
|
||||
while( ($row = $db->sql_fetchrow($result)) && ($row['username']) )
|
||||
{
|
||||
$template->assign_block_vars('latest_members', array(
|
||||
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'JOINED' => $user->format_date($row['user_regdate'], $format = 'd M'),
|
||||
));
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$template->assign_var('S_DISPLAY_LATEST_MEMBERS', true);
|
||||
|
||||
?>
|
||||
140
root/portal/block/statistics.php
Normal file
140
root/portal/block/statistics.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2
|
||||
* @version $Id$
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
// switch idea from phpBB2 :p
|
||||
function get_db_stat($mode)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
switch( $mode )
|
||||
{
|
||||
case 'announcementtotal':
|
||||
$sql = 'SELECT COUNT(distinct t.topic_id) AS announcement_total
|
||||
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
|
||||
WHERE t.topic_type = ' . POST_ANNOUNCE . '
|
||||
AND p.post_id = t.topic_first_post_id';
|
||||
break;
|
||||
case 'stickytotal':
|
||||
$sql = 'SELECT COUNT(distinct t.topic_id) AS sticky_total
|
||||
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
|
||||
WHERE t.topic_type = ' . POST_STICKY . '
|
||||
AND p.post_id = t.topic_first_post_id';
|
||||
break;
|
||||
case 'attachmentstotal':
|
||||
$sql = 'SELECT COUNT(attach_id) AS attachments_total
|
||||
FROM ' . ATTACHMENTS_TABLE;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !($result = $db->sql_query($sql)) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$row = $db->sql_fetchrow($result);
|
||||
|
||||
switch ( $mode )
|
||||
{
|
||||
case 'announcementtotal':
|
||||
return $row['announcement_total'];
|
||||
break;
|
||||
case 'stickytotal':
|
||||
return $row['sticky_total'];
|
||||
break;
|
||||
case 'attachmentstotal':
|
||||
return $row['attachments_total'];
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
|
||||
$total_posts = $config['num_posts'];
|
||||
$total_topics = $config['num_topics'];
|
||||
$total_users = $config['num_users'];
|
||||
|
||||
$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
|
||||
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
|
||||
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';
|
||||
|
||||
// avarage stat
|
||||
$board_days = ( time() - $config['board_startdate'] ) / 86400;
|
||||
|
||||
$topics_per_day = ($total_topics) ? round($total_topics / $board_days, 0) : 0;
|
||||
$posts_per_day = ($total_posts) ? round($total_posts / $board_days, 0) : 0;
|
||||
$users_per_day = round($total_users / $board_days, 0);
|
||||
$topics_per_user = ($total_topics) ? round($total_topics / $total_users, 0) : 0;
|
||||
$posts_per_user = ($total_posts) ? round($total_posts / $total_users, 0) : 0;
|
||||
$posts_per_topic = ($total_topics) ? round($total_posts / $total_topics, 0) : 0;
|
||||
|
||||
if ($topics_per_day > $total_topics)
|
||||
{
|
||||
$topics_per_day = $total_topics;
|
||||
}
|
||||
|
||||
if ($posts_per_day > $total_posts)
|
||||
{
|
||||
$posts_per_day = $total_posts;
|
||||
}
|
||||
|
||||
if ($users_per_day > $total_users)
|
||||
{
|
||||
$users_per_day = $total_users;
|
||||
}
|
||||
|
||||
if ($topics_per_user > $total_topics)
|
||||
{
|
||||
$topics_per_user = $total_topics;
|
||||
}
|
||||
|
||||
if ($posts_per_user > $total_posts)
|
||||
{
|
||||
$posts_per_user = $total_posts;
|
||||
}
|
||||
|
||||
if ($posts_per_topic > $total_posts)
|
||||
{
|
||||
$posts_per_topic = $total_posts;
|
||||
}
|
||||
|
||||
$l_topics_per_day_s = ($total_topics == 0) ? 'TOPICS_PER_DAY_ZERO' : 'TOPICS_PER_DAY_OTHER';
|
||||
$l_posts_per_day_s = ($total_posts == 0) ? 'POSTS_PER_DAY_ZERO' : 'POSTS_PER_DAY_OTHER';
|
||||
$l_users_per_day_s = ($total_users == 0) ? 'USERS_PER_DAY_ZERO' : 'USERS_PER_DAY_OTHER';
|
||||
$l_topics_per_user_s = ($total_topics == 0) ? 'TOPICS_PER_USER_ZERO' : 'TOPICS_PER_USER_OTHER';
|
||||
$l_posts_per_user_s = ($total_posts == 0) ? 'POSTS_PER_USER_ZERO' : 'POSTS_PER_USER_OTHER';
|
||||
$l_posts_per_topic_s = ($total_posts == 0) ? 'POSTS_PER_TOPIC_ZERO' : 'POSTS_PER_TOPIC_OTHER';
|
||||
|
||||
// Assign specific vars
|
||||
$template->assign_vars(array(
|
||||
'S_DISPLAY_ADVANCED_STAT' => true,
|
||||
'TOTAL_POSTS' => sprintf($user->lang[$l_total_post_s], $total_posts),
|
||||
'TOTAL_TOPICS' => sprintf($user->lang[$l_total_topic_s], $total_topics),
|
||||
'TOTAL_USERS' => sprintf($user->lang[$l_total_user_s], $total_users),
|
||||
'NEWEST_USER' => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
|
||||
'S_ANN' => get_db_stat('announcementtotal'),
|
||||
'S_SCT' => get_db_stat('stickytotal'),
|
||||
'S_TOT_ATTACH' => ($config['allow_attachments']) ? get_db_stat('attachmentstotal') : 0,
|
||||
|
||||
// avarage stat
|
||||
'TOPICS_PER_DAY' => sprintf($user->lang[$l_topics_per_day_s], $topics_per_day),
|
||||
'POSTS_PER_DAY' => sprintf($user->lang[$l_posts_per_day_s], $posts_per_day),
|
||||
'USERS_PER_DAY' => sprintf($user->lang[$l_users_per_day_s], $users_per_day),
|
||||
'TOPICS_PER_USER' => sprintf($user->lang[$l_topics_per_user_s], $topics_per_user),
|
||||
'POSTS_PER_USER' => sprintf($user->lang[$l_posts_per_user_s], $posts_per_user),
|
||||
'POSTS_PER_TOPIC' => sprintf($user->lang[$l_posts_per_topic_s], $posts_per_topic),
|
||||
));
|
||||
|
||||
?>
|
||||
39
root/portal/block/top_posters.php
Normal file
39
root/portal/block/top_posters.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2
|
||||
* @version $Id$
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
$sql = 'SELECT user_id, username, user_posts, user_colour
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_type <> ' . USER_IGNORE . '
|
||||
AND user_posts <> 0
|
||||
ORDER BY user_posts DESC';
|
||||
$result = $db->sql_query_limit($sql, $portal_config['portal_max_most_poster']);
|
||||
|
||||
while( ($row = $db->sql_fetchrow($result)) && ($row['username']) )
|
||||
{
|
||||
$template->assign_block_vars('top_poster', array(
|
||||
'S_SEARCH_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $row['user_id'] . '&sr=posts'),
|
||||
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
||||
'POSTER_POSTS' => $row['user_posts'],
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$template->assign_var('S_DISPLAY_TOP_POSTERS', true);
|
||||
|
||||
?>
|
||||
100
root/portal/block/user_menu.php
Normal file
100
root/portal/block/user_menu.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2
|
||||
* @version $Id$
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
//
|
||||
// + new posts since last visit & you post number
|
||||
//
|
||||
if ($user->data['is_registered'])
|
||||
{
|
||||
$ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
|
||||
|
||||
if ($auth->acl_get('m_approve'))
|
||||
{
|
||||
$m_approve_fid_ary = array(-1);
|
||||
$m_approve_fid_sql = '';
|
||||
}
|
||||
else if ($auth->acl_getf_global('m_approve'))
|
||||
{
|
||||
$m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
|
||||
$m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$m_approve_fid_ary = array();
|
||||
$m_approve_fid_sql = ' AND p.post_approved = 1';
|
||||
}
|
||||
|
||||
$sql = 'SELECT COUNT(distinct t.topic_id) as total
|
||||
FROM ' . TOPICS_TABLE . ' t
|
||||
WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
|
||||
AND t.topic_moved_id = 0
|
||||
' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
|
||||
' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
|
||||
$result = $db->sql_query($sql);
|
||||
$new_posts_count = (int) $db->sql_fetchfield('total');
|
||||
|
||||
// your post number
|
||||
$sql = "SELECT user_posts
|
||||
FROM " . USERS_TABLE . "
|
||||
WHERE user_id = " . $user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
$you_posts_count = (int) $db->sql_fetchfield('user_posts');
|
||||
}
|
||||
//
|
||||
// - new posts since last visit & you post number
|
||||
//
|
||||
|
||||
|
||||
// Get user...
|
||||
$user_id = $user->data['user_id'];
|
||||
$username = $user->data['username'];
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id");
|
||||
$result = $db->sql_query($sql);
|
||||
$member = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
$avatar_img = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']);
|
||||
$rank_title = $rank_img = '';
|
||||
get_user_rank($member['user_rank'], $member['user_posts'], $rank_title, $rank_img, $rank_img_src);
|
||||
$username = $member['username'];
|
||||
$user_id = (int) $member['user_id'];
|
||||
$colour = $member['user_colour'];
|
||||
|
||||
// Assign specific vars
|
||||
$template->assign_vars(array(
|
||||
'L_NEW_POSTS' => $user->lang['SEARCH_NEW'] . ' (' . $new_posts_count . ')',
|
||||
'L_SELF_POSTS' => $user->lang['SEARCH_SELF'] . ' (' . $you_posts_count . ')',
|
||||
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
'RANK_TITLE' => $rank_title,
|
||||
'RANK_IMG' => $rank_img,
|
||||
'RANK_IMG_SRC' => $rank_img_src,
|
||||
|
||||
'USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour),
|
||||
'USERNAME' => get_username_string('username', $user_id, $username, $colour),
|
||||
'USER_COLOR' => get_username_string('colour', $user_id, $username, $colour),
|
||||
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour),
|
||||
|
||||
'U_NEW_POSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'),
|
||||
'U_SELF_POSTS' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'),
|
||||
'U_UM_BOOKMARKS' => ($config['allow_bookmarks']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&mode=bookmarks') : '',
|
||||
'U_UM_MAIN_SUBSCRIBED' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&mode=subscribed'),
|
||||
'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '',
|
||||
));
|
||||
|
||||
?>
|
||||
650
root/portal/includes/functions.php
Normal file
650
root/portal/includes/functions.php
Normal file
@@ -0,0 +1,650 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2
|
||||
* @version $Id$
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get portal config
|
||||
function obtain_portal_config()
|
||||
{
|
||||
global $db, $cache;
|
||||
|
||||
if (($portal_config = $cache->get('portal_config')) !== true)
|
||||
{
|
||||
$portal_config = $cached_portal_config = array();
|
||||
|
||||
$sql = 'SELECT config_name, config_value
|
||||
FROM ' . PORTAL_CONFIG_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$cached_portal_config[$row['config_name']] = $row['config_value'];
|
||||
$portal_config[$row['config_name']] = $row['config_value'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$cache->put('portal_config', $cached_portal_config);
|
||||
}
|
||||
|
||||
return $portal_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set config value. Creates missing config entry.
|
||||
*/
|
||||
function set_portal_config($config_name, $config_value)
|
||||
{
|
||||
global $db, $cache, $portal_config;
|
||||
|
||||
$sql = 'UPDATE ' . PORTAL_CONFIG_TABLE . "
|
||||
SET config_value = '" . $db->sql_escape($config_value) . "'
|
||||
WHERE config_name = '" . $db->sql_escape($config_name) . "'";
|
||||
$db->sql_query($sql);
|
||||
|
||||
if (!$db->sql_affectedrows() && !isset($portal_config[$config_name]))
|
||||
{
|
||||
$sql = 'INSERT INTO ' . PORTAL_CONFIG_TABLE . ' ' . $db->sql_build_array('INSERT', array(
|
||||
'config_name' => $config_name,
|
||||
'config_value' => $config_value));
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
$portal_config[$config_name] = $config_value;
|
||||
}
|
||||
|
||||
// fetch post for news & announce
|
||||
function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_length, $time, $type, $start = 0)
|
||||
{
|
||||
global $db, $phpbb_root_path, $auth, $user, $bbcode_bitfield, $bbcode, $portal_config, $config;
|
||||
|
||||
$posts = array();
|
||||
$post_time = ($time == 0) ? '' : 'AND t.topic_time > ' . (time() - $time * 86400);
|
||||
$forum_from = ( strpos($forum_from, ',') !== FALSE ) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
|
||||
$str_where = '';
|
||||
$topic_icons = array(0);
|
||||
$have_icons = 0;
|
||||
|
||||
if( $permissions == TRUE )
|
||||
{
|
||||
$disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$disallow_access = array();
|
||||
}
|
||||
|
||||
$global_f = 0;
|
||||
|
||||
if( sizeof($forum_from) )
|
||||
{
|
||||
$disallow_access = array_diff($forum_from, $disallow_access);
|
||||
if( !sizeof($disallow_access) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
foreach( $disallow_access as $acc_id)
|
||||
{
|
||||
$acc_id = (int) $acc_id;
|
||||
$str_where .= "t.forum_id = $acc_id OR ";
|
||||
if( $type == 'announcements' && $global_f < 1 && $acc_id > 0 )
|
||||
{
|
||||
$global_f = $acc_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( $disallow_access as $acc_id )
|
||||
{
|
||||
$acc_id = (int) $acc_id;
|
||||
$str_where .= "t.forum_id <> $acc_id AND ";
|
||||
}
|
||||
}
|
||||
|
||||
switch( $type )
|
||||
{
|
||||
case "announcements":
|
||||
$topic_type = '(( t.topic_type = ' . POST_ANNOUNCE . ') OR ( t.topic_type = ' . POST_GLOBAL . '))';
|
||||
$str_where = ( strlen($str_where) > 0 ) ? 'AND (t.forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : '';
|
||||
$user_link = 't.topic_poster = u.user_id';
|
||||
$post_link = 't.topic_first_post_id = p.post_id';
|
||||
$topic_order = 't.topic_time DESC';
|
||||
break;
|
||||
case "news":
|
||||
$topic_type = 't.topic_type = ' . POST_NORMAL;
|
||||
$str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
|
||||
$user_link = ( $portal_config['portal_news_style'] ) ? 't.topic_poster = u.user_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
|
||||
$post_link = ( $portal_config['portal_news_style'] ) ? 't.topic_first_post_id = p.post_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
|
||||
$topic_order = ( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
|
||||
break;
|
||||
case "news_all":
|
||||
$topic_type = '( t.topic_type <> ' . POST_ANNOUNCE . ' ) AND ( t.topic_type <> ' . POST_GLOBAL . ')';
|
||||
$str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
|
||||
$user_link = ( $portal_config['portal_news_style'] ) ? 't.topic_poster = u.user_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
|
||||
$post_link = ( $portal_config['portal_news_style'] ) ? 't.topic_first_post_id = p.post_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
|
||||
$topic_order = ( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
|
||||
break;
|
||||
}
|
||||
|
||||
if( $type == 'announcements' && $global_f < 1 )
|
||||
{
|
||||
$sql = 'SELECT
|
||||
forum_id
|
||||
FROM
|
||||
' . FORUMS_TABLE . '
|
||||
WHERE
|
||||
forum_type = ' . FORUM_POST . '
|
||||
' . str_replace('t.', '', $str_where) . '
|
||||
ORDER BY
|
||||
forum_id';
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
|
||||
if( !sizeof( $row ) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
$global_f = $row['forum_id'];
|
||||
}
|
||||
|
||||
$sql_array = array(
|
||||
'SELECT' => 't.forum_id,
|
||||
t.topic_id,
|
||||
t.topic_last_post_id,
|
||||
t.topic_last_post_time,
|
||||
t.topic_time,
|
||||
t.topic_title,
|
||||
t.topic_attachment,
|
||||
t.topic_views,
|
||||
t.poll_title,
|
||||
t.topic_replies,
|
||||
t.topic_replies_real,
|
||||
t.topic_poster,
|
||||
t.topic_type,
|
||||
t.topic_status,
|
||||
t.topic_last_poster_name,
|
||||
t.topic_last_poster_id,
|
||||
t.topic_last_poster_colour,
|
||||
t.icon_id,
|
||||
u.username,
|
||||
u.user_id,
|
||||
u.user_type,
|
||||
u.user_colour,
|
||||
p.post_id,
|
||||
p.poster_id,
|
||||
p.post_time,
|
||||
p.post_text,
|
||||
p.post_attachment,
|
||||
p.post_username,
|
||||
p.enable_smilies,
|
||||
p.enable_bbcode,
|
||||
p.enable_magic_url,
|
||||
p.bbcode_bitfield,
|
||||
p.bbcode_uid,
|
||||
f.forum_name,
|
||||
f.enable_icons',
|
||||
'FROM' => array(
|
||||
TOPICS_TABLE => 't',
|
||||
),
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(USERS_TABLE => 'u'),
|
||||
'ON' => $user_link,
|
||||
),
|
||||
array(
|
||||
'FROM' => array(FORUMS_TABLE => 'f'),
|
||||
'ON' => 't.forum_id=f.forum_id',
|
||||
),
|
||||
array(
|
||||
'FROM' => array(POSTS_TABLE => 'p'),
|
||||
'ON' => $post_link,
|
||||
),
|
||||
),
|
||||
'WHERE' => $topic_type . '
|
||||
' . $post_time . '
|
||||
AND t.topic_status <> ' . ITEM_MOVED . '
|
||||
AND t.topic_approved = 1
|
||||
AND t.topic_moved_id = 0
|
||||
' . $str_where,
|
||||
'ORDER_BY' => $topic_order,
|
||||
);
|
||||
|
||||
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']);
|
||||
$sql_array['SELECT'] .= ', tp.topic_posted';
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
|
||||
if ($number_of_posts <> 0)
|
||||
{
|
||||
$result = $db->sql_query_limit($sql, $number_of_posts, $start);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $db->sql_query($sql);
|
||||
}
|
||||
|
||||
// Instantiate BBCode if need be
|
||||
if ($bbcode_bitfield !== '')
|
||||
{
|
||||
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
|
||||
while ( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$attachments = array();
|
||||
if( $config['allow_attachments'] && $row['post_id'] )
|
||||
{
|
||||
// Pull attachment data
|
||||
$sql2 = 'SELECT *
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
WHERE post_msg_id = '. $row['post_id'] .'
|
||||
AND in_message = 0
|
||||
ORDER BY filetime DESC';
|
||||
$result2 = $db->sql_query($sql2);
|
||||
|
||||
while ($row2 = $db->sql_fetchrow($result2))
|
||||
{
|
||||
$attachments[] = $row2;
|
||||
}
|
||||
$db->sql_freeresult($result2);
|
||||
}
|
||||
|
||||
$posts[$i]['bbcode_uid'] = $row['bbcode_uid'];
|
||||
$len_check = $row['post_text'];
|
||||
$maxlen = $text_length;
|
||||
|
||||
if (($text_length != 0) && (strlen($len_check) > $text_length))
|
||||
{
|
||||
$message = censor_text(get_sub_taged_string(str_replace("\n", '<br/> ', $row['post_text']), $row['bbcode_uid'], $maxlen));
|
||||
$posts[$i]['striped'] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = censor_text( str_replace("\n", '<br/> ', $row['post_text']) );
|
||||
}
|
||||
|
||||
// Second parse bbcode here
|
||||
if ($row['bbcode_bitfield'])
|
||||
{
|
||||
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
||||
}
|
||||
if (!empty($attachments))
|
||||
{
|
||||
parse_attachments($row['forum_id'], $message, $attachments, $update_count);
|
||||
}
|
||||
$message = smiley_text($message); // Always process smilies after parsing bbcodes
|
||||
|
||||
if( $global_f < 1 )
|
||||
{
|
||||
$global_f = $row['forum_id'];
|
||||
}
|
||||
|
||||
$topic_icons[] = $row['enable_icons'];
|
||||
$have_icons = ( $row['icon_id'] > 0 ) ? 1 : $have_icons;
|
||||
|
||||
$posts[$i] = array_merge($posts[$i], array(
|
||||
'post_text' => ap_validate($message),
|
||||
'topic_id' => $row['topic_id'],
|
||||
'topic_last_post_id' => $row['topic_last_post_id'],
|
||||
'topic_type' => $row['topic_type'],
|
||||
'topic_posted' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false,
|
||||
'icon_id' => $row['icon_id'],
|
||||
'topic_status' => $row['topic_status'],
|
||||
'forum_id' => $row['forum_id'],
|
||||
'topic_replies' => $row['topic_replies'],
|
||||
'topic_replies_real' => $row['topic_replies_real'],
|
||||
'topic_time' => $user->format_date($row['post_time']),
|
||||
'topic_last_post_time' => $row['topic_last_post_time'],
|
||||
'topic_title' => $row['topic_title'],
|
||||
'username' => $row['username'],
|
||||
'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $row['post_username']),
|
||||
'username_full_last' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour'], $row['topic_last_poster_name']),
|
||||
'user_id' => $row['user_id'],
|
||||
'user_type' => $row['user_type'],
|
||||
'user_colour' => $row['user_colour'],
|
||||
'poll' => ($row['poll_title']) ? true : false,
|
||||
'attachment' => ($row['topic_attachment']) ? true : false,
|
||||
'topic_views' => $row['topic_views'],
|
||||
'forum_name' => $row['forum_name'],
|
||||
'attachments' => (!empty($attachments)) ? $attachments : array(),
|
||||
));
|
||||
$posts['global_id'] = $global_f;
|
||||
$i++;
|
||||
}
|
||||
|
||||
$posts['topic_icons'] = ( (max($topic_icons) > 0 ) && $have_icons ) ? true : false;
|
||||
$posts['topic_count'] = $i;
|
||||
|
||||
if( $global_f < 1 )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $posts;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Censor title, return short title
|
||||
*
|
||||
* @param $title string title to censor
|
||||
* @param $limit int short title character limit
|
||||
*
|
||||
*/
|
||||
function character_limit(&$title, $limit = 0)
|
||||
{
|
||||
$title = censor_text($title);
|
||||
if ($limit > 0)
|
||||
{
|
||||
return (strlen(utf8_decode($title)) > $limit + 3) ? truncate_string($title, $limit) . '...' : $title;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't let them mess up the complete portal layout in cut messages and do some real AP magic
|
||||
function is_valid_bbtag($str, $bbuid)
|
||||
{
|
||||
return (substr($str,0,1) == '[') && (strpos($str, ':'.$bbuid.']') > 0);
|
||||
}
|
||||
|
||||
function get_end_bbtag($tag, $bbuid)
|
||||
{
|
||||
$etag = '';
|
||||
for($i=0;$i<strlen($tag);$i++)
|
||||
{
|
||||
if ($tag[$i] == '[') $etag .= $tag[$i] . '/';
|
||||
else if (($tag[$i] == '=') || ($tag[$i] == ':'))
|
||||
{
|
||||
if ($tag[1] == '*') $etag .= ':m:'.$bbuid.']';
|
||||
else if (strpos($tag, 'list')) $etag .= ':u:'.$bbuid.']';
|
||||
else $etag .= ':'.$bbuid.']';
|
||||
break;
|
||||
}
|
||||
else $etag .= $tag[$i];
|
||||
}
|
||||
return $etag;
|
||||
}
|
||||
|
||||
function get_next_word($str)
|
||||
{
|
||||
$ret = '';
|
||||
for($i=0;$i<strlen($str);$i++)
|
||||
{
|
||||
switch ($str[$i])
|
||||
{
|
||||
case ' ': //$ret .= ' '; break; break;
|
||||
return $ret . ' ';
|
||||
case '\\':
|
||||
if ($str[$i+1] == 'n') return $ret . '\n';
|
||||
case '[': if ($i != 0) return $ret;
|
||||
default: $ret .= $str[$i];
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function get_next_bbhtml_part($str)
|
||||
{
|
||||
$lim = substr($str,0,strpos($str,'>')+1);
|
||||
return substr($str,0,strpos($str, $lim, strlen($lim))+strlen($lim));
|
||||
}
|
||||
|
||||
function get_sub_taged_string($str, $bbuid, $maxlen)
|
||||
{
|
||||
$sl = $str;
|
||||
$ret = '';
|
||||
$ntext = '';
|
||||
$lret = '';
|
||||
$i = 0;
|
||||
$cnt = $maxlen;
|
||||
$last = '';
|
||||
$arr = array();
|
||||
|
||||
while((strlen($ntext) < $cnt) && (strlen($sl) > 0))
|
||||
{
|
||||
$sr = '';
|
||||
if (substr($sl, 0, 1) == '[') $sr = substr($sl,0,strpos($sl,']')+1);
|
||||
/* GESCHLOSSENE HTML-TAGS BEACHTEN */
|
||||
if (substr($sl, 0, 2) == '<!')
|
||||
{
|
||||
$sr = get_next_bbhtml_part($sl);
|
||||
$ret .= $sr;
|
||||
}
|
||||
else if (substr($sl, 0, 1) == '<')
|
||||
{
|
||||
$sr = substr($sl,0,strpos($sl,'>')+1);
|
||||
$ret .= $sr;
|
||||
}
|
||||
else if (is_valid_bbtag($sr, $bbuid))
|
||||
{
|
||||
if ($sr[1] == '/')
|
||||
{
|
||||
/* entfernt das endtag aus dem tag array */
|
||||
$tarr = array();
|
||||
$j = 0;
|
||||
foreach ($arr as $elem)
|
||||
{
|
||||
if (strcmp($elem[1],$sr) != 0) $tarr[$j++] = $elem;
|
||||
}
|
||||
$arr = $tarr;
|
||||
}
|
||||
else
|
||||
{
|
||||
$arr[$i][0] = $sr;
|
||||
$arr[$i++][1] = get_end_bbtag($sr, $bbuid);
|
||||
}
|
||||
$ret .= $sr;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sr = get_next_word($sl);
|
||||
$ret .= $sr;
|
||||
$ntext .= $sr;
|
||||
$last = $sr;
|
||||
}
|
||||
$sl = substr($sl, strlen($sr), strlen($sl)-strlen($sr));
|
||||
}
|
||||
|
||||
$ret = trim($ret) . '...';
|
||||
$ap = '';
|
||||
|
||||
foreach ($arr as $elem)
|
||||
{
|
||||
$ap = $elem[1] . $ap;
|
||||
}
|
||||
$ret .= $ap;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function ap_validate($str)
|
||||
{
|
||||
$s = str_replace('<br />', '<br/>', $str);
|
||||
return str_replace('</li><br/>', '</li>', $s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pagination routine, generates archive number sequence
|
||||
*/
|
||||
function generate_portal_pagination($base_url, $num_items, $per_page, $start_item, $type, $add_prevnext_text = false, $tpl_prefix = '')
|
||||
{
|
||||
global $template, $user;
|
||||
|
||||
switch( $type )
|
||||
{
|
||||
case "announcements":
|
||||
$pagination_type = 'ap';
|
||||
$anker = '#a';
|
||||
break;
|
||||
case "news":
|
||||
case "news_all":
|
||||
$pagination_type = 'np';
|
||||
$anker = '#n';
|
||||
break;
|
||||
}
|
||||
|
||||
// Make sure $per_page is a valid value
|
||||
$per_page = ($per_page <= 0) ? 1 : $per_page;
|
||||
|
||||
$seperator = '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
|
||||
$total_pages = ceil($num_items / $per_page);
|
||||
|
||||
if ($total_pages == 1 || !$num_items)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$on_page = floor($start_item / $per_page) + 1;
|
||||
$url_delim = (strpos($base_url, '?') === false) ? '?' : '&';
|
||||
|
||||
$page_string = ($on_page == 1) ? '<strong>1</strong>' : '<a href="' . $base_url . $anker .'">1</a>';
|
||||
|
||||
if ($total_pages > 5)
|
||||
{
|
||||
$start_cnt = min(max(1, $on_page - 4), $total_pages - 5);
|
||||
$end_cnt = max(min($total_pages, $on_page + 4), 6);
|
||||
|
||||
$page_string .= ($start_cnt > 1) ? ' ... ' : $seperator;
|
||||
|
||||
for ($i = $start_cnt + 1; $i < $end_cnt; $i++)
|
||||
{
|
||||
$page_string .= ($i == $on_page) ? '<strong>' . $i . '</strong>' : '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($i - 1) * $per_page) . $anker . '">' . $i . '</a>';
|
||||
if ($i < $end_cnt - 1)
|
||||
{
|
||||
$page_string .= $seperator;
|
||||
}
|
||||
}
|
||||
$page_string .= ($end_cnt < $total_pages) ? ' ... ' : $seperator;
|
||||
}
|
||||
else
|
||||
{
|
||||
$page_string .= $seperator;
|
||||
|
||||
for ($i = 2; $i < $total_pages; $i++)
|
||||
{
|
||||
$page_string .= ($i == $on_page) ? '<strong>' . $i . '</strong>' : '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($i - 1) * $per_page) . $anker . '">' . $i . '</a>';
|
||||
if ($i < $total_pages)
|
||||
{
|
||||
$page_string .= $seperator;
|
||||
}
|
||||
}
|
||||
}
|
||||
$page_string .= ($on_page == $total_pages) ? '<strong>' . $total_pages . '</strong>' : '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($total_pages - 1) * $per_page) . $anker . '">' . $total_pages . '</a>';
|
||||
|
||||
if ($add_prevnext_text)
|
||||
{
|
||||
if ($on_page != 1)
|
||||
{
|
||||
$page_string = '<a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . (($on_page - 2) * $per_page) . $anker . '">' . $user->lang['PREVIOUS'] . '</a> ' . $page_string;
|
||||
}
|
||||
|
||||
if ($on_page != $total_pages)
|
||||
{
|
||||
$page_string .= ' <a href="' . $base_url . "{$url_delim}" . $pagination_type . '=' . ($on_page * $per_page) . $anker . '">' . $user->lang['NEXT'] . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
$tpl_prefix . 'BASE_URL' => $base_url,
|
||||
'A_' . $tpl_prefix . 'BASE_URL' => addslashes($base_url),
|
||||
$tpl_prefix . 'PER_PAGE' => $per_page,
|
||||
|
||||
$tpl_prefix . 'PREVIOUS_PAGE' => ($on_page == 1) ? '' : $base_url . "{$url_delim}" . $pagination_type . '=' . (($on_page - 2) * $per_page) . $anker,
|
||||
$tpl_prefix . 'NEXT_PAGE' => ($on_page == $total_pages) ? '' : $base_url . "{$url_delim}" . $pagination_type . '=' . ($on_page * $per_page) . $anker,
|
||||
$tpl_prefix . 'TOTAL_PAGES' => $total_pages,
|
||||
));
|
||||
|
||||
return $page_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format user date for the Birthday block
|
||||
* Note: this function is used as we already added timezones, etc
|
||||
*
|
||||
* borrowed from Upcoming Birthday Mod
|
||||
* @author: lefty
|
||||
* changed to work outside session.php by B3P
|
||||
* @function: format_dateucb
|
||||
*/
|
||||
|
||||
function format_birthday($date, $format = false)
|
||||
{
|
||||
global $user;
|
||||
$time->time_now = time();
|
||||
$lang_dates = $user->lang['datetime'];
|
||||
$format = (!$format) ? $time->date_format : $format;
|
||||
|
||||
// Short representation of month in format
|
||||
if ((strpos($format, '\M') === false && strpos($format, 'M') !== false) || (strpos($format, '\r') === false && strpos($format, 'r') !== false))
|
||||
{
|
||||
$lang_dates['May'] = $lang_dates['May_short'];
|
||||
}
|
||||
unset($lang_dates['May_short']);
|
||||
|
||||
return strtr(@date(str_replace('|', '', $format), $date), $lang_dates);
|
||||
}
|
||||
|
||||
// Mini Cal.
|
||||
class calendar
|
||||
{
|
||||
var $dateYYY; // year in numeric format (YYYY)
|
||||
var $dateMM; // month in numeric format (MM)
|
||||
var $dateDD; // day in numeric format (DD)
|
||||
var $ext_dateMM; // extended month (e.g. February)
|
||||
var $daysMonth; // count of days in month
|
||||
var $stamp; // timestamp
|
||||
var $day; // return array s.a.
|
||||
|
||||
/**
|
||||
* convert date->timestamp
|
||||
**/
|
||||
function makeTimestamp($date)
|
||||
{
|
||||
$this->stamp = strtotime($date);
|
||||
return ($this->stamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* get date listed in array
|
||||
**/
|
||||
function getMonth($callDate)
|
||||
{
|
||||
|
||||
$this->makeTimestamp($callDate);
|
||||
$this->dateYYYY = date("Y", $this->stamp);
|
||||
$this->dateMM = date("n", $this->stamp);
|
||||
$this->ext_dateMM = date("F", $this->stamp);
|
||||
$this->dateDD = date("d", $this->stamp);
|
||||
$this->daysMonth = date("t", $this->stamp);
|
||||
|
||||
for($i=1; $i < $this->daysMonth+1; $i++)
|
||||
{
|
||||
$this->makeTimestamp("$i $this->ext_dateMM $this->dateYYYY");
|
||||
$this->day[] = array(
|
||||
"0" => "$i",
|
||||
"1" => $this->dateMM,
|
||||
"2" => $this->dateYYYY,
|
||||
"3" => (date('w', $this->stamp))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
191
root/portal/includes/functions_version_check.php
Normal file
191
root/portal/includes/functions_version_check.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2
|
||||
* @version $Id$
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* A copy of Handyman` s MOD version check, to view it on the gallery overview
|
||||
*/
|
||||
function mod_version_check($return_version = false)
|
||||
{
|
||||
global $user, $template;
|
||||
global $phpbb_admin_path, $phpEx;
|
||||
|
||||
if (!function_exists('get_remote_file'))
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
|
||||
}
|
||||
|
||||
// load version files
|
||||
$class_functions = array();
|
||||
include($phpbb_admin_path . 'mods/board3_portal_check_version.' . $phpEx);
|
||||
$class_name = 'board3_portal_check_version';
|
||||
|
||||
$var = call_user_func(array($class_name, 'version'));
|
||||
|
||||
// Get current and latest version
|
||||
$errstr = '';
|
||||
$errno = 0;
|
||||
|
||||
if (!$return_version)
|
||||
{
|
||||
$mod_version = $user->lang['NO_INFO'];
|
||||
$data = array(
|
||||
'title' => $var['title'],
|
||||
'description' => $user->lang['NO_INFO'],
|
||||
'download' => $user->lang['NO_INFO'],
|
||||
'announcement' => $user->lang['NO_INFO'],
|
||||
);
|
||||
}
|
||||
$file = get_remote_file($var['file'][0], '/' . $var['file'][1], $var['file'][2], $errstr, $errno);
|
||||
|
||||
if ($file)
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.0.0', '<'))
|
||||
{
|
||||
$row = array();
|
||||
$data_array = mvc_setup_array($file);
|
||||
|
||||
$row = $data_array['mods'][$var['tag']];
|
||||
$mod_version = $row['mod_version'];
|
||||
$mod_version = $mod_version['major'] . '.' . $mod_version['minor'] . '.' . $mod_version['revision'] . $mod_version['release'];
|
||||
|
||||
$data = array(
|
||||
'title' => $row['title'],
|
||||
'description' => $row['description'],
|
||||
'download' => $row['download'],
|
||||
'announcement' => $row['announcement'],
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// let's not stop the page from loading if a mod author messed up their mod check file
|
||||
// also take care of one of the easiest ways to mess up an xml file: "&"
|
||||
$mod = @simplexml_load_string(str_replace('&', '&', $file));
|
||||
if (isset($mod->$var['tag']))
|
||||
{
|
||||
$row = $mod->$var['tag'];
|
||||
$mod_version = $row->mod_version->major . '.' . $row->mod_version->minor . '.' . $row->mod_version->revision . $row->mod_version->release;
|
||||
|
||||
$data = array(
|
||||
'title' => $row->title,
|
||||
'description' => $row->description,
|
||||
'download' => $row->download,
|
||||
'announcement' => $row->announcement,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove spaces from the version in the mod file stored locally
|
||||
$version = str_replace(' ', '', $var['version']);
|
||||
if ($return_version)
|
||||
{
|
||||
return $version;
|
||||
}
|
||||
|
||||
$version_compare = (version_compare($version, $mod_version, '<')) ? false : true;
|
||||
|
||||
$template->assign_block_vars('mods', array(
|
||||
'ANNOUNCEMENT' => $data['announcement'],
|
||||
'AUTHOR' => $var['author'],
|
||||
'CURRENT_VERSION' => $version,
|
||||
'DESCRIPTION' => $data['description'],
|
||||
'DOWNLOAD' => $data['download'],
|
||||
'LATEST_VERSION' => $mod_version,
|
||||
'TITLE' => $data['title'],
|
||||
|
||||
'UP_TO_DATE' => sprintf((!$version_compare) ? $user->lang['NOT_UP_TO_DATE'] : $user->lang['UP_TO_DATE'], $data['title']),
|
||||
|
||||
'S_UP_TO_DATE' => $version_compare,
|
||||
|
||||
'U_AUTHOR' => 'http://www.phpbb.com/community/memberlist.php?mode=viewprofile&un=' . $var['author'],
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* this is for php4 only
|
||||
* kind of a dirty hack, but since I get the say on how the xml is done, I can have 4 levels max
|
||||
*/
|
||||
function mvc_setup_array($xml)
|
||||
{
|
||||
// Fire up the built-in XML parser
|
||||
$values = $index = array();
|
||||
$parser = xml_parser_create();
|
||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
|
||||
|
||||
// this takes care of one possible xml error
|
||||
$xml = str_replace('&', '&', $xml);
|
||||
|
||||
// Set tag names and values
|
||||
xml_parse_into_struct($parser, $xml, $values, $index);
|
||||
|
||||
// Close down XML parser
|
||||
xml_parser_free($parser);
|
||||
|
||||
$ary = array();
|
||||
|
||||
foreach ($values as $value)
|
||||
{
|
||||
switch (trim($value['level']))
|
||||
{
|
||||
case 1:
|
||||
if ($value['type'] == 'open')
|
||||
{
|
||||
$one = $value['tag'];
|
||||
}
|
||||
else if ($value['type'] == 'complete')
|
||||
{
|
||||
$ary[$value['tag']] = $value['value'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ($value['type'] == 'open')
|
||||
{
|
||||
$two = $value['tag'];
|
||||
}
|
||||
else if ($value['type'] == 'complete')
|
||||
{
|
||||
$ary[$one][$value['tag']] = $value['value'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if ($value['type'] == 'open')
|
||||
{
|
||||
$three = $value['tag'];
|
||||
}
|
||||
else if ($value['type'] == 'complete')
|
||||
{
|
||||
$ary[$one][$two][$value['tag']] = $value['value'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if ($value['type'] == 'complete')
|
||||
{
|
||||
$ary[$one][$two][$three][$value['tag']] = isset($value['value']) ? $value['value'] : '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $ary;
|
||||
}
|
||||
|
||||
?>
|
||||
7
root/portal/includes/index.html
Normal file
7
root/portal/includes/index.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF" text="#000000">
|
||||
</body>
|
||||
</html>
|
||||
7
root/portal/index.html
Normal file
7
root/portal/index.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF" text="#000000">
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user