2002-11-07 03:39:50 +00:00
|
|
|
<?php
|
2005-04-09 12:26:45 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package phpBB3
|
|
|
|
* @version $Id$
|
|
|
|
* @copyright (c) 2005 phpBB Group
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
|
*
|
|
|
|
*/
|
2002-11-07 03:39:50 +00:00
|
|
|
|
2005-04-09 12:26:45 +00:00
|
|
|
/**
|
|
|
|
* Display Forums
|
|
|
|
*/
|
2005-10-19 18:00:10 +00:00
|
|
|
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
global $db, $auth, $user, $template;
|
|
|
|
global $phpbb_root_path, $phpEx, $SID, $config;
|
|
|
|
|
|
|
|
$forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
|
|
|
|
$parent_id = $visible_forums = 0;
|
|
|
|
$sql_from = $lastread_select = '';
|
|
|
|
|
|
|
|
// Mark forums read?
|
2004-01-12 15:00:09 +00:00
|
|
|
$mark_read = request_var('mark', '');
|
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
if ($mark_read == 'all')
|
|
|
|
{
|
|
|
|
$mark_read = '';
|
|
|
|
}
|
2003-01-31 02:11:38 +00:00
|
|
|
|
2003-01-20 05:12:38 +00:00
|
|
|
if (!$root_data)
|
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
if ($mark_read == 'forums')
|
|
|
|
{
|
|
|
|
$mark_read = 'all';
|
|
|
|
}
|
|
|
|
|
2003-01-20 05:12:38 +00:00
|
|
|
$root_data = array('forum_id' => 0);
|
2003-04-22 17:26:29 +00:00
|
|
|
$sql_where = '';
|
2003-01-20 05:12:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-04-22 17:26:29 +00:00
|
|
|
$sql_where = ' WHERE left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
|
2003-01-20 05:12:38 +00:00
|
|
|
}
|
2002-11-07 03:39:50 +00:00
|
|
|
|
2004-02-05 14:42:12 +00:00
|
|
|
// Display list of active topics for this category?
|
2004-05-02 13:06:57 +00:00
|
|
|
$show_active = (isset($root_data['forum_flags']) && $root_data['forum_flags'] & 16) ? true : false;
|
2004-02-05 14:42:12 +00:00
|
|
|
|
2006-01-25 21:01:52 +00:00
|
|
|
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
2002-11-27 13:24:46 +00:00
|
|
|
{
|
2005-11-28 18:38:49 +00:00
|
|
|
$sql_from = FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id)';
|
2003-04-26 01:17:40 +00:00
|
|
|
$lastread_select = ', ft.mark_time ';
|
2002-11-27 13:24:46 +00:00
|
|
|
}
|
|
|
|
else
|
2003-04-22 17:26:29 +00:00
|
|
|
{
|
2003-06-19 16:19:59 +00:00
|
|
|
$sql_from = FORUMS_TABLE . ' f ';
|
|
|
|
$lastread_select = $sql_lastread = '';
|
2003-04-22 17:26:29 +00:00
|
|
|
|
2003-06-19 16:19:59 +00:00
|
|
|
$tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])) : array();
|
2005-10-19 18:00:10 +00:00
|
|
|
|
|
|
|
if (!$user->data['is_registered'])
|
|
|
|
{
|
|
|
|
$user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0;
|
|
|
|
}
|
2003-04-22 17:26:29 +00:00
|
|
|
}
|
2002-11-27 13:24:46 +00:00
|
|
|
|
2005-01-13 15:31:11 +00:00
|
|
|
$sql = "SELECT f.* $lastread_select
|
|
|
|
FROM $sql_from
|
2003-06-19 16:19:59 +00:00
|
|
|
$sql_where
|
|
|
|
ORDER BY f.left_id";
|
2002-11-07 03:39:50 +00:00
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
$forum_tracking_info = array();
|
2002-11-08 03:33:58 +00:00
|
|
|
$branch_root_id = $root_data['forum_id'];
|
2002-11-07 03:39:50 +00:00
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
$forum_id = $row['forum_id'];
|
|
|
|
|
|
|
|
// Mark forums read?
|
|
|
|
if ($mark_read == 'forums' || $mark_read == 'all')
|
2004-01-12 15:00:09 +00:00
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
if ($auth->acl_get('f_list', $forum_id))
|
2004-01-12 15:00:09 +00:00
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
$forum_ids[] = $forum_id;
|
|
|
|
continue;
|
2004-01-12 15:00:09 +00:00
|
|
|
}
|
2005-10-19 18:00:10 +00:00
|
|
|
}
|
2004-01-12 15:00:09 +00:00
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
// Category with no members
|
|
|
|
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
|
|
|
|
{
|
2004-01-12 15:00:09 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
// Skip branch
|
2002-11-07 03:39:50 +00:00
|
|
|
if (isset($right_id))
|
|
|
|
{
|
|
|
|
if ($row['left_id'] < $right_id)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
unset($right_id);
|
|
|
|
}
|
2003-03-29 18:28:45 +00:00
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
if (!$auth->acl_get('f_list', $forum_id))
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
|
|
|
// if the user does not have permissions to list this forum, skip everything until next branch
|
|
|
|
$right_id = $row['right_id'];
|
|
|
|
continue;
|
|
|
|
}
|
2005-03-21 23:10:11 +00:00
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
$forum_ids[] = $forum_id;
|
|
|
|
|
|
|
|
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
|
|
|
{
|
|
|
|
$forum_tracking_info[$forum_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-01-25 21:01:52 +00:00
|
|
|
if (!$user->data['is_registered'])
|
|
|
|
{
|
|
|
|
$user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0;
|
|
|
|
}
|
2005-10-19 18:00:10 +00:00
|
|
|
$forum_tracking_info[$forum_id] = (isset($tracking_topics['f'][$forum_id])) ? base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate'] : $user->data['user_lastmark'];
|
|
|
|
}
|
|
|
|
|
2004-02-05 14:42:12 +00:00
|
|
|
// Display active topics from this forum?
|
|
|
|
if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & 16))
|
|
|
|
{
|
2006-04-08 14:16:31 +00:00
|
|
|
if (!isset($active_forum_ary['forum_topics']))
|
|
|
|
{
|
|
|
|
$active_forum_ary['forum_topics'] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($active_forum_ary['forum_posts']))
|
|
|
|
{
|
|
|
|
$active_forum_ary['forum_posts'] = 0;
|
|
|
|
}
|
|
|
|
|
2004-02-05 14:42:12 +00:00
|
|
|
$active_forum_ary['forum_id'][] = $forum_id;
|
|
|
|
$active_forum_ary['enable_icons'][] = $row['enable_icons'];
|
2004-09-05 15:45:50 +00:00
|
|
|
$active_forum_ary['forum_topics'] += ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics'];
|
2004-02-05 14:42:12 +00:00
|
|
|
$active_forum_ary['forum_posts'] += $row['forum_posts'];
|
|
|
|
}
|
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
//
|
2003-04-26 01:17:40 +00:00
|
|
|
if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id)
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
// Direct child of current branch
|
2003-04-26 01:17:40 +00:00
|
|
|
$parent_id = $forum_id;
|
|
|
|
$forum_rows[$forum_id] = $row;
|
2002-11-07 03:39:50 +00:00
|
|
|
|
2003-08-12 22:33:26 +00:00
|
|
|
if (!$row['parent_id'] && $row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id'])
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
2003-04-26 01:17:40 +00:00
|
|
|
$branch_root_id = $forum_id;
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
2003-05-03 23:58:45 +00:00
|
|
|
$forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
|
2005-10-19 18:00:10 +00:00
|
|
|
$forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
2005-10-19 18:00:10 +00:00
|
|
|
else if ($row['forum_type'] != FORUM_CAT)
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
$subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index']) ? true : false;
|
|
|
|
$subforums[$parent_id][$forum_id]['name'] = $row['forum_name'];
|
|
|
|
$subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
|
|
|
|
|
2004-09-05 15:45:50 +00:00
|
|
|
$forum_rows[$parent_id]['forum_topics'] += ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics'];
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2004-05-31 18:00:10 +00:00
|
|
|
// Do not list redirects in LINK Forums as Posts.
|
|
|
|
if ($row['forum_type'] != FORUM_LINK)
|
|
|
|
{
|
|
|
|
$forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
|
|
|
|
}
|
2003-05-02 15:50:11 +00:00
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time'])
|
2003-05-02 15:50:11 +00:00
|
|
|
{
|
|
|
|
$forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id'];
|
|
|
|
$forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time'];
|
|
|
|
$forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id'];
|
|
|
|
$forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];
|
2004-02-05 14:42:12 +00:00
|
|
|
$forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
|
2003-05-02 15:50:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-02-05 14:42:12 +00:00
|
|
|
$forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
|
2003-05-02 15:50:11 +00:00
|
|
|
}
|
2003-04-26 01:17:40 +00:00
|
|
|
}
|
2003-05-02 15:50:11 +00:00
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
$forum_ids_moderator[$parent_id] = $forum_rows[$parent_id]['forum_id_last_post'];
|
2003-04-26 01:17:40 +00:00
|
|
|
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
2004-12-31 13:58:41 +00:00
|
|
|
$db->sql_freeresult($result);
|
2002-11-07 03:39:50 +00:00
|
|
|
|
2004-01-12 15:00:09 +00:00
|
|
|
// Handle marking posts
|
2005-10-19 18:00:10 +00:00
|
|
|
if ($mark_read == 'forums' || $mark_read == 'all')
|
2004-01-12 15:00:09 +00:00
|
|
|
{
|
|
|
|
$redirect = (!empty($_SERVER['REQUEST_URI'])) ? preg_replace('#^(.*?)&(amp;)?mark=.*$#', '\1', htmlspecialchars($_SERVER['REQUEST_URI'])) : "index.$phpEx$SID";
|
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
if ($mark_read == 'all')
|
|
|
|
{
|
|
|
|
markread('all');
|
|
|
|
|
|
|
|
$message = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
markread('topics', $forum_ids);
|
|
|
|
|
|
|
|
$message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>');
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_refresh(3, $redirect);
|
|
|
|
|
|
|
|
$message = $user->lang['FORUMS_MARKED'] . '<br /><br />' . $message;
|
2004-01-12 15:00:09 +00:00
|
|
|
trigger_error($message);
|
|
|
|
}
|
|
|
|
|
2003-04-26 16:24:58 +00:00
|
|
|
// Grab moderators ... if necessary
|
2002-11-07 03:39:50 +00:00
|
|
|
if ($display_moderators)
|
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
if ($return_moderators)
|
|
|
|
{
|
|
|
|
$forum_ids_moderator[] = $root_data['forum_id'];
|
|
|
|
}
|
|
|
|
get_moderators($forum_moderators, $forum_ids_moderator);
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($forum_rows as $row)
|
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
// Empty category
|
|
|
|
if (!$row['parent_id'] && $row['forum_type'] == FORUM_CAT)
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
|
|
|
$template->assign_block_vars('forumrow', array(
|
2005-10-19 18:00:10 +00:00
|
|
|
'S_IS_CAT' => true,
|
|
|
|
'FORUM_ID' => $row['forum_id'],
|
|
|
|
'FORUM_NAME' => $row['forum_name'],
|
2006-03-25 12:07:13 +00:00
|
|
|
'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield']),
|
2005-10-19 18:00:10 +00:00
|
|
|
'U_VIEWFORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=" . $row['forum_id'])
|
2003-04-22 17:26:29 +00:00
|
|
|
);
|
2005-10-19 18:00:10 +00:00
|
|
|
|
|
|
|
continue;
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
|
|
|
|
2003-04-22 17:26:29 +00:00
|
|
|
$visible_forums++;
|
2002-11-07 03:39:50 +00:00
|
|
|
$forum_id = $row['forum_id'];
|
2002-11-18 00:19:47 +00:00
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
$forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false;
|
|
|
|
|
|
|
|
$folder_image = $folder_alt = $subforums_list = $l_subforums = '';
|
2005-03-21 23:10:11 +00:00
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
// Generate list of subforums if we need to
|
2003-04-22 17:26:29 +00:00
|
|
|
if (isset($subforums[$forum_id]))
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
foreach ($subforums[$forum_id] as $subforum_id => $subforum_row)
|
2003-04-22 17:26:29 +00:00
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
// Update unread information if needed
|
|
|
|
if (!$forum_unread)
|
2003-04-22 17:26:29 +00:00
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
$forum_unread = (isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id]) ? true : false;
|
2003-04-22 17:26:29 +00:00
|
|
|
}
|
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
if ($subforum_row['display'] && $subforum_row['name'])
|
2003-04-22 17:26:29 +00:00
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
$subforums_list .= ($subforums_list == '') ? '' : ', ';
|
|
|
|
$subforums_list .= '<a href="' . $phpbb_root_path . "viewforum.$phpEx$SID&f=$subforum_id\">{$subforum_row['name']}</a>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unset($subforums[$forum_id][$subforum_id]);
|
2003-04-22 17:26:29 +00:00
|
|
|
}
|
|
|
|
}
|
2005-10-19 18:00:10 +00:00
|
|
|
|
|
|
|
$l_subforums = (sizeof($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': ';
|
|
|
|
$folder_image = ($forum_unread) ? 'sub_forum_new' : 'sub_forum';
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
2002-11-07 21:45:34 +00:00
|
|
|
else
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
2003-05-02 15:50:11 +00:00
|
|
|
switch ($row['forum_type'])
|
|
|
|
{
|
|
|
|
case FORUM_POST:
|
2005-10-19 18:00:10 +00:00
|
|
|
$folder_image = ($forum_unread) ? 'forum_new' : 'forum';
|
|
|
|
break;
|
2003-05-02 15:50:11 +00:00
|
|
|
|
|
|
|
case FORUM_LINK:
|
|
|
|
$folder_image = 'forum_link';
|
2005-10-19 18:00:10 +00:00
|
|
|
break;
|
2003-05-02 15:50:11 +00:00
|
|
|
}
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
// Which folder should we display?
|
2003-04-22 17:26:29 +00:00
|
|
|
if ($row['forum_status'] == ITEM_LOCKED)
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
2003-04-22 17:26:29 +00:00
|
|
|
$folder_image = 'forum_locked';
|
|
|
|
$folder_alt = 'FORUM_LOCKED';
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
$folder_alt = ($forum_unread) ? 'NEW_POSTS' : 'NO_NEW_POSTS';
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
// Create last post link information, if appropriate
|
2003-04-22 17:26:29 +00:00
|
|
|
if ($row['forum_last_post_id'])
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
2003-04-22 17:26:29 +00:00
|
|
|
$last_post_time = $user->format_date($row['forum_last_post_time']);
|
2002-11-07 03:39:50 +00:00
|
|
|
|
2003-04-22 17:26:29 +00:00
|
|
|
$last_poster = ($row['forum_last_poster_name'] != '') ? $row['forum_last_poster_name'] : $user->lang['GUEST'];
|
2005-10-19 18:00:10 +00:00
|
|
|
$last_poster_url = ($row['forum_last_poster_id'] == ANONYMOUS) ? '' : "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u={$row['forum_last_poster_id']}";
|
2002-11-07 03:39:50 +00:00
|
|
|
|
2006-01-04 20:57:34 +00:00
|
|
|
$last_post_url = "{$phpbb_root_path}viewtopic.$phpEx$SID&f=" . $row['forum_id_last_post'] . '&p=' . $row['forum_last_post_id'] . '#p' . $row['forum_last_post_id'];
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-04-24 18:21:29 +00:00
|
|
|
$last_post_time = $last_poster = $last_poster_url = $last_post_url = '';
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
// Output moderator listing ... if applicable
|
2002-11-15 12:45:28 +00:00
|
|
|
$l_moderator = $moderators_list = '';
|
2003-01-13 06:44:16 +00:00
|
|
|
if ($display_moderators && !empty($forum_moderators[$forum_id]))
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
2005-04-10 18:07:12 +00:00
|
|
|
$l_moderator = (sizeof($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
|
2003-01-13 06:44:16 +00:00
|
|
|
$moderators_list = implode(', ', $forum_moderators[$forum_id]);
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
$l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS';
|
2003-05-08 13:17:40 +00:00
|
|
|
$post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & 1) ? $row['forum_posts'] : '';
|
2003-05-02 15:50:11 +00:00
|
|
|
|
2002-11-07 03:39:50 +00:00
|
|
|
$template->assign_block_vars('forumrow', array(
|
2005-01-13 15:31:11 +00:00
|
|
|
'S_IS_CAT' => false,
|
2005-10-19 18:00:10 +00:00
|
|
|
'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false,
|
|
|
|
|
|
|
|
'FORUM_ID' => $row['forum_id'],
|
|
|
|
'FORUM_NAME' => $row['forum_name'],
|
2006-03-25 12:07:13 +00:00
|
|
|
'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield']),
|
2005-10-19 18:00:10 +00:00
|
|
|
'TOPICS' => $row['forum_topics'],
|
|
|
|
$l_post_click_count => $post_click_count,
|
|
|
|
'FORUM_FOLDER_IMG' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['folder_alt'] . '" />' : $user->img($folder_image, $folder_alt),
|
2005-04-30 14:24:13 +00:00
|
|
|
'FORUM_FOLDER_IMG_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : $user->img($folder_image, $folder_alt, false, '', 'src'),
|
2005-10-19 18:00:10 +00:00
|
|
|
'SUBFORUMS' => $subforums_list,
|
|
|
|
'LAST_POST_TIME' => $last_post_time,
|
|
|
|
'LAST_POSTER' => $last_poster,
|
|
|
|
'MODERATORS' => $moderators_list,
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2004-01-12 15:00:09 +00:00
|
|
|
'L_SUBFORUM_STR' => $l_subforums,
|
|
|
|
'L_FORUM_FOLDER_ALT'=> $folder_alt,
|
2005-10-19 18:00:10 +00:00
|
|
|
'L_MODERATOR_STR' => $l_moderator,
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
'U_VIEWFORUM' => ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & 1) ? "{$phpbb_root_path}viewforum.$phpEx$SID&f={$row['forum_id']}" : $row['forum_link'],
|
2005-01-13 15:31:11 +00:00
|
|
|
'U_LAST_POSTER' => $last_poster_url,
|
|
|
|
'U_LAST_POST' => $last_post_url,
|
2005-10-19 18:00:10 +00:00
|
|
|
)
|
2003-03-20 00:31:36 +00:00
|
|
|
);
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
2003-01-31 02:11:38 +00:00
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2005-10-19 18:00:10 +00:00
|
|
|
'U_MARK_FORUMS' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=" . $root_data['forum_id'] . '&mark=forums',
|
|
|
|
'S_HAS_SUBFORUM' => ($visible_forums) ? true : false,
|
|
|
|
'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'],
|
|
|
|
'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'),
|
|
|
|
)
|
2003-03-20 00:31:36 +00:00
|
|
|
);
|
2004-02-05 14:42:12 +00:00
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
if ($return_moderators)
|
|
|
|
{
|
|
|
|
return array($active_forum_ary, $forum_moderators);
|
|
|
|
}
|
|
|
|
|
2004-02-05 14:42:12 +00:00
|
|
|
return $active_forum_ary;
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
2003-04-22 17:26:29 +00:00
|
|
|
|
2005-10-02 18:15:12 +00:00
|
|
|
/**
|
|
|
|
* Create forum rules for given forum
|
|
|
|
*/
|
|
|
|
function generate_forum_rules(&$forum_data)
|
|
|
|
{
|
|
|
|
if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link'])
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
global $template, $phpbb_root_path, $phpEx;
|
|
|
|
|
|
|
|
if ($forum_data['forum_rules'])
|
|
|
|
{
|
2006-03-25 12:07:13 +00:00
|
|
|
$forum_data['forum_rules'] = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield']);
|
2005-10-02 18:15:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'S_FORUM_RULES' => true,
|
|
|
|
'U_FORUM_RULES' => $forum_data['forum_rules_link'],
|
|
|
|
'FORUM_RULES' => $forum_data['forum_rules'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create forum navigation links for given forum, create parent
|
|
|
|
* list if currently null, assign basic forum info to template
|
|
|
|
*/
|
|
|
|
function generate_forum_nav(&$forum_data)
|
|
|
|
{
|
|
|
|
global $db, $user, $template, $phpEx, $SID, $phpbb_root_path;
|
|
|
|
|
|
|
|
// Get forum parents
|
|
|
|
$forum_parents = get_forum_parents($forum_data);
|
|
|
|
|
|
|
|
// Build navigation links
|
|
|
|
foreach ($forum_parents as $parent_forum_id => $parent_data)
|
|
|
|
{
|
|
|
|
list($parent_name, $parent_type) = array_values($parent_data);
|
|
|
|
|
|
|
|
$template->assign_block_vars('navlinks', array(
|
|
|
|
'S_IS_CAT' => ($parent_type == FORUM_CAT) ? true : false,
|
|
|
|
'S_IS_LINK' => ($parent_type == FORUM_LINK) ? true : false,
|
|
|
|
'S_IS_POST' => ($parent_type == FORUM_POST) ? true : false,
|
|
|
|
'FORUM_NAME' => $parent_name,
|
|
|
|
'FORUM_ID' => $parent_forum_id,
|
|
|
|
'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=$parent_forum_id")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_block_vars('navlinks', array(
|
|
|
|
'S_IS_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false,
|
|
|
|
'S_IS_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
|
|
|
|
'S_IS_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
|
|
|
|
'FORUM_NAME' => $forum_data['forum_name'],
|
|
|
|
'FORUM_ID' => $forum_data['forum_id'],
|
|
|
|
'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=" . $forum_data['forum_id'])
|
|
|
|
);
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'FORUM_ID' => $forum_data['forum_id'],
|
|
|
|
'FORUM_NAME' => $forum_data['forum_name'],
|
2006-03-25 12:07:13 +00:00
|
|
|
'FORUM_DESC' => generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield']))
|
2005-10-02 18:15:12 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns forum parents as an array. Get them from forum_data if available, or update the database otherwise
|
|
|
|
*/
|
|
|
|
function get_forum_parents(&$forum_data)
|
|
|
|
{
|
|
|
|
global $db;
|
|
|
|
|
|
|
|
$forum_parents = array();
|
|
|
|
|
|
|
|
if ($forum_data['parent_id'] > 0)
|
|
|
|
{
|
|
|
|
if ($forum_data['forum_parents'] == '')
|
|
|
|
{
|
|
|
|
$sql = 'SELECT forum_id, forum_name, forum_type
|
|
|
|
FROM ' . FORUMS_TABLE . '
|
|
|
|
WHERE left_id < ' . $forum_data['left_id'] . '
|
|
|
|
AND right_id > ' . $forum_data['right_id'] . '
|
|
|
|
ORDER BY left_id ASC';
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
|
|
|
$forum_parents[$row['forum_id']] = array($row['forum_name'], (int) $row['forum_type']);
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
$forum_data['forum_parents'] = serialize($forum_parents);
|
|
|
|
|
|
|
|
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
|
|
SET forum_parents = '" . $db->sql_escape($forum_data['forum_parents']) . "'
|
|
|
|
WHERE parent_id = " . $forum_data['parent_id'];
|
|
|
|
$db->sql_query($sql);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$forum_parents = unserialize($forum_data['forum_parents']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $forum_parents;
|
|
|
|
}
|
|
|
|
|
2005-04-09 12:26:45 +00:00
|
|
|
/**
|
|
|
|
* Get topic author
|
|
|
|
*/
|
2004-10-13 19:30:02 +00:00
|
|
|
function topic_topic_author(&$topic_row)
|
|
|
|
{
|
|
|
|
global $phpEx, $SID, $phpbb_root_path, $user;
|
|
|
|
|
|
|
|
$topic_author = ($topic_row['topic_poster'] != ANONYMOUS) ? "<a href=\"{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=" . $topic_row['topic_poster'] . '">' : '';
|
|
|
|
$topic_author .= ($topic_row['topic_poster'] != ANONYMOUS) ? $topic_row['topic_first_poster_name'] : (($topic_row['topic_first_poster_name'] != '') ? $topic_row['topic_first_poster_name'] : $user->lang['GUEST']);
|
|
|
|
$topic_author .= ($topic_row['topic_poster'] != ANONYMOUS) ? '</a>' : '';
|
|
|
|
|
|
|
|
return $topic_author;
|
|
|
|
}
|
|
|
|
|
2005-04-09 12:26:45 +00:00
|
|
|
/**
|
|
|
|
* Generate topic pagination
|
|
|
|
*/
|
2004-10-13 19:30:02 +00:00
|
|
|
function topic_generate_pagination($replies, $url)
|
|
|
|
{
|
|
|
|
global $config, $user;
|
|
|
|
|
|
|
|
if (($replies + 1) > $config['posts_per_page'])
|
|
|
|
{
|
|
|
|
$total_pages = ceil(($replies + 1) / $config['posts_per_page']);
|
|
|
|
$pagination = '';
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2004-10-13 19:30:02 +00:00
|
|
|
$times = 1;
|
|
|
|
for ($j = 0; $j < $replies + 1; $j += $config['posts_per_page'])
|
|
|
|
{
|
|
|
|
$pagination .= "<a href=\"$url&start=$j\">$times</a>";
|
|
|
|
if ($times == 1 && $total_pages > 4)
|
|
|
|
{
|
|
|
|
$pagination .= ' ... ';
|
|
|
|
$times = $total_pages - 3;
|
|
|
|
$j += ($total_pages - 4) * $config['posts_per_page'];
|
|
|
|
}
|
|
|
|
else if ($times < $total_pages)
|
|
|
|
{
|
2005-12-22 16:28:27 +00:00
|
|
|
$pagination .= $user->theme['pagination_sep'];
|
2004-10-13 19:30:02 +00:00
|
|
|
}
|
|
|
|
$times++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$pagination = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $pagination;
|
|
|
|
}
|
|
|
|
|
2005-10-02 18:15:12 +00:00
|
|
|
/**
|
|
|
|
* Obtain list of moderators of each forum
|
|
|
|
*/
|
|
|
|
function get_moderators(&$forum_moderators, $forum_id = false)
|
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
global $config, $template, $db, $phpbb_root_path, $phpEx, $SID;
|
2005-10-02 18:15:12 +00:00
|
|
|
|
|
|
|
// Have we disabled the display of moderators? If so, then return
|
|
|
|
// from whence we came ...
|
2005-10-19 18:00:10 +00:00
|
|
|
if (!$config['load_moderators'])
|
2005-10-02 18:15:12 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2006-02-12 14:48:07 +00:00
|
|
|
|
2005-10-19 18:00:10 +00:00
|
|
|
if ($forum_id !== false && is_array($forum_id))
|
2005-10-02 18:15:12 +00:00
|
|
|
{
|
2006-02-12 15:45:50 +00:00
|
|
|
// If we don't have a forum then we can't have a moderator
|
|
|
|
if (!sizeof($forum_id))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2005-10-02 18:15:12 +00:00
|
|
|
$forum_sql = 'AND forum_id IN (' . implode(', ', $forum_id) . ')';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-19 18:00:10 +00:00
|
|
|
$forum_sql = ($forum_id !== false) ? 'AND forum_id = ' . $forum_id : '';
|
2005-10-02 18:15:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$sql = 'SELECT *
|
|
|
|
FROM ' . MODERATOR_TABLE . "
|
|
|
|
WHERE display_on_index = 1
|
|
|
|
$forum_sql";
|
2005-10-19 18:00:10 +00:00
|
|
|
$result = $db->sql_query($sql, 3600);
|
2005-10-02 18:15:12 +00:00
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
2006-04-15 14:48:36 +00:00
|
|
|
$forum_moderators[$row['forum_id']][] = (!empty($row['user_id'])) ? '<a href="' . $phpbb_root_path . "memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'] . '">' . $row['username'] . '</a>' : '<a href="' . $phpbb_root_path . "memberlist.$phpEx$SID&mode=group&g=" . $row['group_id'] . '">' . $row['group_name'] . '</a>';
|
2005-10-02 18:15:12 +00:00
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User authorisation levels output
|
|
|
|
*/
|
2006-04-06 17:15:45 +00:00
|
|
|
function gen_forum_auth_level($mode, $forum_id, $forum_status)
|
2005-10-02 18:15:12 +00:00
|
|
|
{
|
|
|
|
global $SID, $template, $auth, $user;
|
|
|
|
|
2006-04-06 17:15:45 +00:00
|
|
|
$locked = ($forum_status == ITEM_LOCKED && !$auth->acl_get('m_edit', $forum_id)) ? true : false;
|
|
|
|
|
2005-10-02 18:15:12 +00:00
|
|
|
$rules = array(
|
2006-04-06 17:15:45 +00:00
|
|
|
($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'],
|
|
|
|
($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'],
|
|
|
|
($auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'],
|
|
|
|
($auth->acl_gets('f_delete', 'm_delete', $forum_id) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'],
|
|
|
|
($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach', $forum_id) && !$locked) ? $user->lang['RULES_ATTACH_CAN'] : $user->lang['RULES_ATTACH_CANNOT']
|
2005-10-02 18:15:12 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
foreach ($rules as $rule)
|
|
|
|
{
|
|
|
|
$template->assign_block_vars('rules', array('RULE' => $rule));
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-09 12:26:45 +00:00
|
|
|
/**
|
|
|
|
* Generate topic status
|
|
|
|
*/
|
2005-10-19 18:00:10 +00:00
|
|
|
function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$folder_alt, &$topic_type)
|
2004-10-13 19:30:02 +00:00
|
|
|
{
|
|
|
|
global $user, $config;
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2004-10-13 19:30:02 +00:00
|
|
|
$folder = $folder_new = '';
|
|
|
|
|
|
|
|
if ($topic_row['topic_status'] == ITEM_MOVED)
|
|
|
|
{
|
|
|
|
$topic_type = $user->lang['VIEW_TOPIC_MOVED'];
|
|
|
|
$folder_img = 'folder_moved';
|
|
|
|
$folder_alt = 'VIEW_TOPIC_MOVED';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch ($topic_row['topic_type'])
|
|
|
|
{
|
|
|
|
case POST_GLOBAL:
|
|
|
|
case POST_ANNOUNCE:
|
|
|
|
$topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT'];
|
|
|
|
$folder = 'folder_announce';
|
|
|
|
$folder_new = 'folder_announce_new';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case POST_STICKY:
|
|
|
|
$topic_type = $user->lang['VIEW_TOPIC_STICKY'];
|
|
|
|
$folder = 'folder_sticky';
|
|
|
|
$folder_new = 'folder_sticky_new';
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if ($replies >= $config['hot_threshold'])
|
|
|
|
{
|
|
|
|
$folder = 'folder_hot';
|
|
|
|
$folder_new = 'folder_hot_new';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$folder = 'folder';
|
|
|
|
$folder_new = 'folder_new';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($topic_row['topic_status'] == ITEM_LOCKED)
|
|
|
|
{
|
|
|
|
$topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
|
|
|
|
$folder = 'folder_locked';
|
|
|
|
$folder_new = 'folder_locked_new';
|
|
|
|
}
|
|
|
|
|
|
|
|
$folder_img = ($unread_topic) ? $folder_new : $folder;
|
|
|
|
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
|
|
|
|
|
|
|
|
// Posted image?
|
2005-10-19 18:00:10 +00:00
|
|
|
if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted'])
|
2004-10-13 19:30:02 +00:00
|
|
|
{
|
|
|
|
$folder_img .= '_posted';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($topic_row['poll_start'])
|
|
|
|
{
|
|
|
|
$topic_type .= $user->lang['VIEW_TOPIC_POLL'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-09 12:26:45 +00:00
|
|
|
/**
|
|
|
|
* Display Attachments
|
|
|
|
*/
|
2004-09-16 18:33:22 +00:00
|
|
|
function display_attachments($forum_id, $blockname, &$attachment_data, &$update_count, $force_physical = false, $return = false)
|
2003-06-17 19:34:17 +00:00
|
|
|
{
|
2005-10-02 18:15:12 +00:00
|
|
|
global $template, $cache, $user;
|
|
|
|
global $attachment_tpl, $extensions, $config, $phpbb_root_path, $phpEx, $SID;
|
2003-06-17 19:34:17 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
// $starttime = explode(' ', microtime());
|
|
|
|
// $starttime = $starttime[1] + $starttime[0];
|
2004-02-08 18:02:17 +00:00
|
|
|
$return_tpl = array();
|
|
|
|
|
2004-09-16 18:33:22 +00:00
|
|
|
$blocks = array(ATTACHMENT_CATEGORY_WM => 'WM_STREAM', ATTACHMENT_CATEGORY_RM => 'RM_STREAM', ATTACHMENT_CATEGORY_THUMB => 'THUMBNAIL', ATTACHMENT_CATEGORY_IMAGE => 'IMAGE');
|
2003-11-05 14:57:29 +00:00
|
|
|
|
|
|
|
if (!isset($attachment_tpl))
|
|
|
|
{
|
2006-01-05 12:10:31 +00:00
|
|
|
if (!($attachment_tpl = $cache->get('attachment_tpl')))
|
2003-11-05 14:57:29 +00:00
|
|
|
{
|
|
|
|
$attachment_tpl = array();
|
|
|
|
|
2005-12-22 16:28:27 +00:00
|
|
|
$template_filename = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template/attachment.html';
|
2006-01-04 06:37:17 +00:00
|
|
|
if (($attachment_template = file_get_contents($template_filename)) === false)
|
2003-11-05 14:57:29 +00:00
|
|
|
{
|
2004-12-19 17:59:15 +00:00
|
|
|
trigger_error('Could not load template file "' . $template_filename . '"');
|
2003-11-05 14:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// replace \ with \\ and then ' with \'.
|
|
|
|
$attachment_template = str_replace('\\', '\\\\', $attachment_template);
|
|
|
|
$attachment_template = str_replace("'", "\'", $attachment_template);
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#s', $attachment_template, $tpl);
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
foreach ($tpl[1] as $num => $block_name)
|
|
|
|
{
|
|
|
|
$attachment_tpl[$block_name] = $tpl[2][$num];
|
|
|
|
}
|
|
|
|
unset($tpl);
|
2003-11-04 22:05:38 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
$cache->put('attachment_tpl', $attachment_tpl);
|
|
|
|
}
|
|
|
|
}
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
if (empty($extensions) || !is_array($extensions))
|
|
|
|
{
|
2003-09-09 07:02:57 +00:00
|
|
|
$extensions = array();
|
2005-10-02 18:15:12 +00:00
|
|
|
$cache->obtain_attach_extensions($extensions);
|
2003-06-17 19:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($attachment_data as $attachment)
|
|
|
|
{
|
|
|
|
// Some basics...
|
|
|
|
$attachment['extension'] = strtolower(trim($attachment['extension']));
|
2005-03-21 23:10:11 +00:00
|
|
|
$filename = $phpbb_root_path . $config['upload_path'] . '/' . basename($attachment['physical_filename']);
|
|
|
|
$thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . basename($attachment['physical_filename']);
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
|
|
$upload_image = '';
|
|
|
|
|
2004-01-12 15:00:09 +00:00
|
|
|
if ($user->img('icon_attach', '') && !$extensions[$attachment['extension']]['upload_icon'])
|
2003-06-17 19:34:17 +00:00
|
|
|
{
|
|
|
|
$upload_image = $user->img('icon_attach', '');
|
|
|
|
}
|
2004-01-12 15:00:09 +00:00
|
|
|
else if ($extensions[$attachment['extension']]['upload_icon'])
|
2003-06-17 19:34:17 +00:00
|
|
|
{
|
2003-10-12 09:13:04 +00:00
|
|
|
$upload_image = '<img src="' . $phpbb_root_path . $config['upload_icons_path'] . '/' . trim($extensions[$attachment['extension']]['upload_icon']) . '" alt="" border="0" />';
|
2003-06-17 19:34:17 +00:00
|
|
|
}
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
$filesize = $attachment['filesize'];
|
|
|
|
$size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] );
|
|
|
|
|
2003-06-25 19:49:59 +00:00
|
|
|
$filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize);
|
2003-06-17 19:34:17 +00:00
|
|
|
|
2005-01-13 15:31:11 +00:00
|
|
|
$display_name = basename($attachment['real_filename']);
|
2004-02-21 12:47:35 +00:00
|
|
|
$comment = str_replace("\n", '<br />', censor_text($attachment['comment']));
|
2003-06-17 19:34:17 +00:00
|
|
|
|
2004-03-10 20:30:26 +00:00
|
|
|
$denied = false;
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2004-09-17 09:11:48 +00:00
|
|
|
if (!extension_allowed($forum_id, $attachment['extension'], $extensions))
|
2003-06-17 19:34:17 +00:00
|
|
|
{
|
2004-03-10 20:30:26 +00:00
|
|
|
$denied = true;
|
2003-06-17 19:34:17 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
$template_array['VAR'] = array('{L_DENIED}');
|
|
|
|
$template_array['VAL'] = array(sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
|
2003-06-17 19:34:17 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
$tpl = str_replace($template_array['VAR'], $template_array['VAL'], $attachment_tpl['DENIED']);
|
2004-01-12 15:00:09 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
// Replace {L_*} lang strings
|
|
|
|
$tpl = preg_replace('/{L_([A-Z_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $tpl);
|
|
|
|
|
2004-03-10 20:30:26 +00:00
|
|
|
if (!$return)
|
|
|
|
{
|
|
|
|
$template->assign_block_vars($blockname, array(
|
|
|
|
'DISPLAY_ATTACHMENT' => $tpl)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$return_tpl[] = $tpl;
|
|
|
|
}
|
2005-01-13 15:31:11 +00:00
|
|
|
}
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
|
|
if (!$denied)
|
|
|
|
{
|
|
|
|
$l_downloaded_viewed = '';
|
|
|
|
$download_link = '';
|
2004-05-26 20:32:51 +00:00
|
|
|
$additional_array['VAR'] = $additional_array['VAL'] = array();
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
$display_cat = $extensions[$attachment['extension']]['display_cat'];
|
|
|
|
|
2004-09-16 18:33:22 +00:00
|
|
|
if ($display_cat == ATTACHMENT_CATEGORY_IMAGE)
|
2003-06-17 19:34:17 +00:00
|
|
|
{
|
|
|
|
if ($attachment['thumbnail'])
|
|
|
|
{
|
2004-09-16 18:33:22 +00:00
|
|
|
$display_cat = ATTACHMENT_CATEGORY_THUMB;
|
2003-06-17 19:34:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ($config['img_display_inlined'])
|
|
|
|
{
|
|
|
|
if ($config['img_link_width'] || $config['img_link_height'])
|
|
|
|
{
|
2003-06-25 19:49:59 +00:00
|
|
|
list($width, $height) = getimagesize($filename);
|
2003-06-17 19:34:17 +00:00
|
|
|
|
2004-09-16 18:33:22 +00:00
|
|
|
$display_cat = (!$width && !$height) ? ATTACHMENT_CATEGORY_IMAGE : (($width <= $config['img_link_width'] && $height <= $config['img_link_height']) ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE);
|
2003-06-17 19:34:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-09-16 18:33:22 +00:00
|
|
|
$display_cat = ATTACHMENT_CATEGORY_NONE;
|
2003-06-17 19:34:17 +00:00
|
|
|
}
|
2003-06-25 19:49:59 +00:00
|
|
|
}
|
2003-06-17 19:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch ($display_cat)
|
|
|
|
{
|
|
|
|
// Images
|
2004-09-16 18:33:22 +00:00
|
|
|
case ATTACHMENT_CATEGORY_IMAGE:
|
2003-06-25 19:49:59 +00:00
|
|
|
$img_source = $filename;
|
|
|
|
$update_count[] = $attachment['attach_id'];
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
|
|
$l_downloaded_viewed = $user->lang['VIEWED'];
|
|
|
|
$download_link = $img_source;
|
|
|
|
break;
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
// Images, but display Thumbnail
|
2004-09-16 18:33:22 +00:00
|
|
|
case ATTACHMENT_CATEGORY_THUMB:
|
2003-06-25 19:49:59 +00:00
|
|
|
$thumb_source = $thumbnail_filename;
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
|
|
$l_downloaded_viewed = $user->lang['VIEWED'];
|
|
|
|
$download_link = (!$force_physical) ? $phpbb_root_path . "download.$phpEx$SID&id=" . $attachment['attach_id'] : $filename;
|
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
$additional_array['VAR'][] = '{THUMB_IMG}';
|
|
|
|
$additional_array['VAL'][] = $thumb_source;
|
2003-06-17 19:34:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Windows Media Streams
|
2004-09-16 18:33:22 +00:00
|
|
|
case ATTACHMENT_CATEGORY_WM:
|
2003-06-17 19:34:17 +00:00
|
|
|
$l_downloaded_viewed = $user->lang['VIEWED'];
|
|
|
|
$download_link = $filename;
|
|
|
|
|
|
|
|
// Viewed/Heared File ... update the download count (download.php is not called here)
|
|
|
|
$update_count[] = $attachment['attach_id'];
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Real Media Streams
|
2004-09-16 18:33:22 +00:00
|
|
|
case ATTACHMENT_CATEGORY_RM:
|
2003-06-17 19:34:17 +00:00
|
|
|
$l_downloaded_viewed = $user->lang['VIEWED'];
|
|
|
|
$download_link = $filename;
|
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
$additional_array['VAR'][] = '{U_FORUM}';
|
|
|
|
$additional_array['VAL'][] = generate_board_url();
|
|
|
|
$additional_array['VAR'][] = '{ATTACH_ID}';
|
|
|
|
$additional_array['VAL'][] = $attachment['attach_id'];
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
|
|
// Viewed/Heared File ... update the download count (download.php is not called here)
|
|
|
|
$update_count[] = $attachment['attach_id'];
|
|
|
|
break;
|
2005-01-13 15:31:11 +00:00
|
|
|
/*
|
2003-06-17 19:34:17 +00:00
|
|
|
// Macromedia Flash Files
|
|
|
|
case SWF_CAT:
|
|
|
|
list($width, $height) = swf_getdimension($filename);
|
|
|
|
|
|
|
|
$l_downloaded_viewed = $user->lang['VIEWED'];
|
|
|
|
$download_link = $filename;
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
$additional_array = array(
|
|
|
|
'WIDTH' => $width,
|
|
|
|
'HEIGHT' => $height
|
|
|
|
);
|
|
|
|
|
|
|
|
// Viewed/Heared File ... update the download count (download.php is not called here)
|
|
|
|
$update_count[] = $attachment['attach_id'];
|
|
|
|
break;
|
|
|
|
*/
|
|
|
|
default:
|
|
|
|
$l_downloaded_viewed = $user->lang['DOWNLOADED'];
|
|
|
|
$download_link = (!$force_physical) ? $phpbb_root_path . "download.$phpEx$SID&id=" . $attachment['attach_id'] : $filename;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-09-16 18:33:22 +00:00
|
|
|
$l_download_count = (!isset($attachment['download_count']) || $attachment['download_count'] == 0) ? $user->lang['DOWNLOAD_NONE'] : (($attachment['download_count'] == 1) ? sprintf($user->lang['DOWNLOAD_COUNT'], $attachment['download_count']) : sprintf($user->lang['DOWNLOAD_COUNTS'], $attachment['download_count']));
|
2003-10-19 15:36:45 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
$current_block = ($display_cat) ? $blocks[$display_cat] : 'FILE';
|
2005-01-13 15:31:11 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
$template_array['VAR'] = array_merge($additional_array['VAR'], array(
|
|
|
|
'{DOWNLOAD_NAME}', '{FILESIZE}', '{SIZE_VAR}', '{COMMENT}', '{U_DOWNLOAD_LINK}', '{UPLOAD_IMG}', '{L_DOWNLOADED_VIEWED}', '{L_DOWNLOAD_COUNT}')
|
|
|
|
);
|
2003-06-17 19:34:17 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
$template_array['VAL'] = array_merge($additional_array['VAL'], array(
|
|
|
|
$display_name, $filesize, $size_lang, $comment, $download_link, $upload_image, $l_downloaded_viewed, $l_download_count)
|
2003-06-17 19:34:17 +00:00
|
|
|
);
|
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
$tpl = str_replace($template_array['VAR'], $template_array['VAL'], $attachment_tpl[$current_block]);
|
2004-01-12 15:00:09 +00:00
|
|
|
|
2003-11-05 14:57:29 +00:00
|
|
|
// Replace {L_*} lang strings
|
|
|
|
$tpl = preg_replace('/{L_([A-Z_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $tpl);
|
|
|
|
|
2004-02-08 18:02:17 +00:00
|
|
|
if (!$return)
|
|
|
|
{
|
|
|
|
$template->assign_block_vars($blockname, array(
|
|
|
|
'DISPLAY_ATTACHMENT' => $tpl)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$return_tpl[] = $tpl;
|
|
|
|
}
|
2003-06-17 19:34:17 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-05 14:57:29 +00:00
|
|
|
|
2004-02-08 18:02:17 +00:00
|
|
|
return $return_tpl;
|
2003-11-05 14:57:29 +00:00
|
|
|
// $mtime = explode(' ', microtime());
|
|
|
|
// $totaltime = $mtime[0] + $mtime[1] - $starttime;
|
2003-06-17 19:34:17 +00:00
|
|
|
}
|
|
|
|
|
2006-03-12 23:19:55 +00:00
|
|
|
/**
|
|
|
|
* Display reasons
|
|
|
|
*/
|
|
|
|
function display_reasons($reason_id = 0)
|
|
|
|
{
|
|
|
|
global $db, $user, $template;
|
|
|
|
|
|
|
|
$sql = 'SELECT *
|
|
|
|
FROM ' . REASONS_TABLE . '
|
|
|
|
ORDER BY reason_order ASC';
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
|
|
|
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
|
|
|
|
if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
|
|
|
|
{
|
|
|
|
$row['reson_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])];
|
|
|
|
$row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])];
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_block_vars('reason', array(
|
|
|
|
'ID' => $row['reason_id'],
|
|
|
|
'TITLE' => $row['reason_title'],
|
|
|
|
'DESCRIPTION' => $row['reason_description'],
|
|
|
|
'S_SELECTED' => ($row['reason_id'] == $reason_id) ? true : false)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
}
|
|
|
|
|
2003-01-20 05:12:38 +00:00
|
|
|
?>
|