2002-11-07 03:39:50 +00:00
|
|
|
|
<?php
|
2003-08-29 18:06:56 +00:00
|
|
|
|
// -------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// $Id$
|
|
|
|
|
//
|
|
|
|
|
// FILENAME : functions_display.php
|
|
|
|
|
// STARTED : Thu Nov 07, 2002
|
|
|
|
|
// COPYRIGHT : <20> 2001, 2003 phpBB Group
|
|
|
|
|
// WWW : http://www.phpbb.com/
|
|
|
|
|
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
|
|
|
|
|
//
|
|
|
|
|
// -------------------------------------------------------------
|
2002-11-07 03:39:50 +00:00
|
|
|
|
|
2003-01-20 05:12:38 +00:00
|
|
|
|
function display_forums($root_data = '', $display_moderators = TRUE)
|
2002-11-07 03:39:50 +00:00
|
|
|
|
{
|
2004-05-30 19:24:53 +00:00
|
|
|
|
global $config, $db, $template, $auth, $user, $phpEx, $SID, $forum_moderators, $phpbb_root_path;
|
2002-11-07 03:39:50 +00:00
|
|
|
|
|
2004-01-12 15:00:09 +00:00
|
|
|
|
// Get posted/get info
|
|
|
|
|
$mark_read = request_var('mark', '');
|
|
|
|
|
|
2004-02-05 14:42:12 +00:00
|
|
|
|
$forum_id_ary = $active_forum_ary = $forum_rows = $subforums = $forum_moderators = $mark_forums = array();
|
2003-01-31 02:11:38 +00:00
|
|
|
|
$visible_forums = 0;
|
|
|
|
|
|
2003-01-20 05:12:38 +00:00
|
|
|
|
if (!$root_data)
|
|
|
|
|
{
|
|
|
|
|
$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
|
|
|
|
|
2003-04-22 17:26:29 +00:00
|
|
|
|
if ($config['load_db_lastread'] && $user->data['user_id'] != ANONYMOUS)
|
2002-11-27 13:24:46 +00:00
|
|
|
|
{
|
2003-04-26 01:17:40 +00:00
|
|
|
|
switch (SQL_LAYER)
|
|
|
|
|
{
|
|
|
|
|
case 'oracle':
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2003-06-29 10:59:36 +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
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$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();
|
2003-04-22 17:26:29 +00:00
|
|
|
|
}
|
2002-11-27 13:24:46 +00:00
|
|
|
|
|
2003-03-29 18:28:45 +00:00
|
|
|
|
$sql = "SELECT f.* $lastread_select
|
2003-06-19 16:19:59 +00:00
|
|
|
|
FROM $sql_from
|
|
|
|
|
$sql_where
|
|
|
|
|
ORDER BY f.left_id";
|
2002-11-07 03:39:50 +00:00
|
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
|
2002-11-08 03:33:58 +00:00
|
|
|
|
$branch_root_id = $root_data['forum_id'];
|
2004-02-05 14:42:12 +00:00
|
|
|
|
$forum_ids = array($root_data['forum_id']);
|
2002-11-07 03:39:50 +00:00
|
|
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
|
{
|
2004-09-16 18:33:22 +00:00
|
|
|
|
if ($mark_read == 'forums' && $user->data['user_id'] != ANONYMOUS)
|
2004-01-12 15:00:09 +00:00
|
|
|
|
{
|
|
|
|
|
if ($auth->acl_get('f_list', $row['forum_id']))
|
|
|
|
|
{
|
|
|
|
|
$forum_id_ary[] = $row['forum_id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
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-05-02 15:50:11 +00:00
|
|
|
|
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
|
2002-11-07 03:39:50 +00:00
|
|
|
|
{
|
|
|
|
|
// Non-postable forum with no subforums: don't display
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
|
$forum_id = $row['forum_id'];
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
$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'];
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
// Direct child
|
2003-04-26 01:17:40 +00:00
|
|
|
|
$parent_id = $forum_id;
|
|
|
|
|
$forum_rows[$forum_id] = $row;
|
|
|
|
|
$forum_ids[] = $forum_id;
|
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'];
|
2002-11-07 03:39:50 +00:00
|
|
|
|
}
|
2003-05-02 15:50:11 +00:00
|
|
|
|
elseif ($row['forum_type'] != FORUM_CAT)
|
2002-11-07 03:39:50 +00:00
|
|
|
|
{
|
2003-04-26 17:28:32 +00:00
|
|
|
|
$subforums[$parent_id]['display'] = ($row['display_on_index']) ? true : false;;
|
|
|
|
|
$subforums[$parent_id]['name'][$forum_id] = $row['forum_name'];
|
2003-05-02 15:50:11 +00:00
|
|
|
|
|
|
|
|
|
// Include subforum topic/post counts in parent counts
|
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'];
|
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
|
|
|
|
|
|
|
|
|
if (isset($forum_rows[$parent_id]) && $row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time'])
|
|
|
|
|
{
|
|
|
|
|
$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
|
|
|
|
|
2004-05-26 20:32:51 +00:00
|
|
|
|
if (!isset($row['mark_time']))
|
|
|
|
|
{
|
|
|
|
|
$row['mark_time'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-19 16:19:59 +00:00
|
|
|
|
$mark_time_forum = ($config['load_db_lastread']) ? $row['mark_time'] : ((isset($tracking_topics[$forum_id][0])) ? base_convert($tracking_topics[$forum_id][0], 36, 10) + $config['board_startdate'] : 0);
|
2003-04-26 01:17:40 +00:00
|
|
|
|
|
2003-06-19 16:19:59 +00:00
|
|
|
|
if ($mark_time_forum < $row['forum_last_post_time'] && $user->data['user_id'] != ANONYMOUS)
|
2003-04-26 01:17:40 +00:00
|
|
|
|
{
|
|
|
|
|
$forum_unread[$parent_id] = true;
|
|
|
|
|
}
|
2002-11-07 03:39:50 +00:00
|
|
|
|
}
|
|
|
|
|
$db->sql_freeresult();
|
|
|
|
|
|
2004-01-12 15:00:09 +00:00
|
|
|
|
// Handle marking posts
|
|
|
|
|
if ($mark_read == 'forums')
|
|
|
|
|
{
|
|
|
|
|
markread('mark', $forum_id_ary);
|
|
|
|
|
|
|
|
|
|
$redirect = (!empty($_SERVER['REQUEST_URI'])) ? preg_replace('#^(.*?)&(amp;)?mark=.*$#', '\1', htmlspecialchars($_SERVER['REQUEST_URI'])) : "index.$phpEx$SID";
|
|
|
|
|
meta_refresh(3, $redirect);
|
|
|
|
|
|
2004-09-16 18:33:22 +00:00
|
|
|
|
$message = (strpos($redirect, 'viewforum') !== false) ? 'RETURN_FORUM' : 'RETURN_INDEX';
|
2004-01-12 15:00:09 +00:00
|
|
|
|
$message = $user->lang['FORUMS_MARKED'] . '<br /><br />' . sprintf($user->lang[$message], '<a href="' . $redirect . '">', '</a> ');
|
|
|
|
|
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)
|
|
|
|
|
{
|
2002-11-07 21:45:34 +00:00
|
|
|
|
get_moderators($forum_moderators, $forum_ids);
|
2002-11-07 03:39:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-26 16:24:58 +00:00
|
|
|
|
// Loop through the forums
|
2002-11-07 03:39:50 +00:00
|
|
|
|
$root_id = $root_data['forum_id'];
|
2004-07-08 22:41:04 +00:00
|
|
|
|
|
2002-11-07 03:39:50 +00:00
|
|
|
|
foreach ($forum_rows as $row)
|
|
|
|
|
{
|
2003-08-12 22:33:26 +00:00
|
|
|
|
if ($row['parent_id'] == $root_id && !$row['parent_id'])
|
2002-11-07 03:39:50 +00:00
|
|
|
|
{
|
2003-05-02 15:50:11 +00:00
|
|
|
|
if ($row['forum_type'] == FORUM_CAT)
|
2002-11-07 03:39:50 +00:00
|
|
|
|
{
|
|
|
|
|
$hold = $row;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
unset($hold);
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-08-12 22:33:26 +00:00
|
|
|
|
else if (!empty($hold))
|
2002-11-07 03:39:50 +00:00
|
|
|
|
{
|
|
|
|
|
$template->assign_block_vars('forumrow', array(
|
|
|
|
|
'S_IS_CAT' => TRUE,
|
|
|
|
|
'FORUM_ID' => $hold['forum_id'],
|
|
|
|
|
'FORUM_NAME' => $hold['forum_name'],
|
|
|
|
|
'FORUM_DESC' => $hold['forum_desc'],
|
2004-01-12 15:00:09 +00:00
|
|
|
|
'U_VIEWFORUM' => "viewforum.$phpEx$SID&f=" . $hold['forum_id'])
|
2003-04-22 17:26:29 +00:00
|
|
|
|
);
|
2002-11-07 03:39:50 +00:00
|
|
|
|
unset($hold);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
2002-11-07 03:39:50 +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
|
|
|
|
{
|
2003-04-26 17:28:32 +00:00
|
|
|
|
if ($subforums[$forum_id]['display'])
|
2003-04-22 17:26:29 +00:00
|
|
|
|
{
|
2003-04-26 17:28:32 +00:00
|
|
|
|
$alist = array();
|
|
|
|
|
foreach ($subforums[$forum_id]['name'] as $sub_forum_id => $subforum_name)
|
2003-04-22 17:26:29 +00:00
|
|
|
|
{
|
2003-04-26 17:28:32 +00:00
|
|
|
|
if (!empty($subforum_name))
|
|
|
|
|
{
|
|
|
|
|
$alist[$sub_forum_id] = $subforum_name;
|
|
|
|
|
}
|
2003-04-22 17:26:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-26 17:28:32 +00:00
|
|
|
|
if (sizeof($alist))
|
2003-04-22 17:26:29 +00:00
|
|
|
|
{
|
2003-04-26 17:28:32 +00:00
|
|
|
|
$links = array();
|
|
|
|
|
foreach ($alist as $subforum_id => $subforum_name)
|
|
|
|
|
{
|
|
|
|
|
$links[] = '<a href="viewforum.' . $phpEx . $SID . '&f=' . $subforum_id . '">' . $subforum_name . '</a>';
|
|
|
|
|
}
|
|
|
|
|
$subforums_list = implode(', ', $links);
|
|
|
|
|
|
|
|
|
|
$l_subforums = (count($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': ';
|
2003-04-22 17:26:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-19 16:19:59 +00:00
|
|
|
|
$folder_image = (!empty($forum_unread[$forum_id])) ? '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:
|
2003-06-19 16:19:59 +00:00
|
|
|
|
$folder_image = (!empty($forum_unread[$forum_id])) ? 'forum_new' : 'forum';
|
2003-05-02 15:50:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FORUM_LINK:
|
|
|
|
|
$folder_image = 'forum_link';
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-04-22 17:26:29 +00:00
|
|
|
|
|
|
|
|
|
$subforums_list = '';
|
|
|
|
|
$l_subforums = '';
|
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
|
|
|
|
|
{
|
2003-06-19 16:19:59 +00:00
|
|
|
|
$folder_alt = (!empty($forum_unread[$forum_id])) ? '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'];
|
|
|
|
|
$last_poster_url = ($row['forum_last_poster_id'] == ANONYMOUS) ? '' : "memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['forum_last_poster_id'];
|
2002-11-07 03:39:50 +00:00
|
|
|
|
|
2003-04-22 17:26:29 +00:00
|
|
|
|
$last_post_url = "viewtopic.$phpEx$SID&f=" . $row['forum_id_last_post'] . '&p=' . $row['forum_last_post_id'] . '#' . $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
|
|
|
|
{
|
2003-01-13 06:44:16 +00:00
|
|
|
|
$l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
|
|
|
|
|
$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(
|
2004-01-12 15:00:09 +00:00
|
|
|
|
'S_IS_CAT' => false,
|
|
|
|
|
'S_IS_LINK' => ($row['forum_type'] != FORUM_LINK) ? false : true,
|
|
|
|
|
|
|
|
|
|
'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'),
|
|
|
|
|
|
|
|
|
|
'FORUM_ID' => $row['forum_id'],
|
2004-05-30 19:24:53 +00:00
|
|
|
|
'FORUM_FOLDER_IMG' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $folder_alt . '" border="0" />' : $user->img($folder_image, $folder_alt),
|
2004-01-12 15:00:09 +00:00
|
|
|
|
'FORUM_NAME' => $row['forum_name'],
|
|
|
|
|
'FORUM_DESC' => $row['forum_desc'],
|
|
|
|
|
$l_post_click_count => $post_click_count,
|
2004-09-05 15:45:50 +00:00
|
|
|
|
'TOPICS' => ($auth->acl_get('m_approve', $row['forum_id'])) ? $row['forum_topics_real'] : $row['forum_topics'],
|
2004-01-12 15:00:09 +00:00
|
|
|
|
'LAST_POST_TIME' => $last_post_time,
|
|
|
|
|
'LAST_POSTER' => $last_poster,
|
|
|
|
|
'MODERATORS' => $moderators_list,
|
|
|
|
|
'SUBFORUMS' => $subforums_list,
|
2004-07-08 22:41:04 +00:00
|
|
|
|
|
2004-01-12 15:00:09 +00:00
|
|
|
|
'L_SUBFORUM_STR' => $l_subforums,
|
|
|
|
|
'L_MODERATOR_STR' => $l_moderator,
|
|
|
|
|
'L_FORUM_FOLDER_ALT'=> $folder_alt,
|
2003-05-02 15:50:11 +00:00
|
|
|
|
|
2004-01-12 15:00:09 +00:00
|
|
|
|
'U_LAST_POSTER' => $last_poster_url,
|
|
|
|
|
'U_LAST_POST' => $last_post_url,
|
|
|
|
|
'U_VIEWFORUM' => ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & 1) ? "viewforum.$phpEx$SID&f=" . $row['forum_id'] : $row['forum_link'])
|
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(
|
2004-01-12 15:00:09 +00:00
|
|
|
|
'U_MARK_FORUMS' => "viewforum.$phpEx$SID&f=" . $root_data['forum_id'] . '&mark=forums',
|
|
|
|
|
|
2003-05-02 15:50:11 +00:00
|
|
|
|
'S_HAS_SUBFORUM' => ($visible_forums) ? true : false,
|
2004-01-12 15:00:09 +00:00
|
|
|
|
|
2003-03-20 00:31:36 +00:00
|
|
|
|
'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'])
|
|
|
|
|
);
|
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
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 = '';
|
|
|
|
|
|
|
|
|
|
$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)
|
|
|
|
|
{
|
|
|
|
|
$pagination .= $user->theme['primary']['pagination_sep'];
|
|
|
|
|
}
|
|
|
|
|
$times++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$pagination = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $pagination;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function topic_status(&$topic_row, $replies, $mark_time_topic, $mark_time_forum, &$folder_img, &$folder_alt, &$topic_type)
|
|
|
|
|
{
|
|
|
|
|
global $user, $config;
|
|
|
|
|
|
|
|
|
|
$folder = $folder_new = '';
|
|
|
|
|
$unread_topic = false;
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($user->data['user_id'] != ANONYMOUS)
|
|
|
|
|
{
|
|
|
|
|
$unread_topic = $new_votes = true;
|
|
|
|
|
|
|
|
|
|
if ($mark_time_topic >= $topic_row['topic_last_post_time'] || $mark_time_forum >= $topic_row['topic_last_post_time']) //|| ($topic_row['topic_last_post_time'] == $topic_row['poll_last_vote'] && $replies))
|
|
|
|
|
{
|
|
|
|
|
$unread_topic = false;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
if ($topic_row['poll_start'] && ($mark_time_topic >= $topic_row['poll_last_vote'] || $mark_time_forum >= $topic_row['poll_last_vote']))
|
|
|
|
|
{
|
|
|
|
|
$new_votes = false;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$unread_topic = false;
|
|
|
|
|
//$unread_topic = $new_votes = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// $folder_new .= ($new_votes) ? '_vote' : '';
|
|
|
|
|
|
|
|
|
|
$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?
|
|
|
|
|
if (!empty($topic_row['mark_type']))
|
|
|
|
|
{
|
|
|
|
|
$folder_img .= '_posted';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($topic_row['poll_start'])
|
|
|
|
|
{
|
|
|
|
|
$topic_type .= $user->lang['VIEW_TOPIC_POLL'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $unread_topic;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-17 19:34:17 +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
|
|
|
|
{
|
2003-11-05 14:57:29 +00:00
|
|
|
|
global $extensions, $template, $cache, $attachment_tpl;
|
2004-02-21 12:47:35 +00:00
|
|
|
|
global $config, $user, $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))
|
|
|
|
|
{
|
|
|
|
|
if ($cache->exists('attachment_tpl'))
|
|
|
|
|
{
|
|
|
|
|
$attachment_tpl = $cache->get('attachment_tpl');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$attachment_tpl = array();
|
|
|
|
|
|
|
|
|
|
// Generate Template
|
2004-12-19 17:59:15 +00:00
|
|
|
|
$style = 'primary';
|
|
|
|
|
|
|
|
|
|
if (!empty($user->theme['secondary']))
|
|
|
|
|
{
|
|
|
|
|
$style = (file_exists($phpbb_root_path . 'styles/' . $user->theme['primary']['template_path'] . '/template/attachment.html')) ? 'primary' : 'secondary';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$template_filename = $phpbb_root_path . 'styles/' . $user->theme[$style]['template_path'] . '/template/attachment.html';
|
2003-11-05 14:57:29 +00:00
|
|
|
|
if (!($fp = @fopen($template_filename, 'rb')))
|
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
$attachment_template = fread($fp, filesize($template_filename));
|
|
|
|
|
@fclose($fp);
|
|
|
|
|
|
|
|
|
|
// replace \ with \\ and then ' with \'.
|
|
|
|
|
$attachment_template = str_replace('\\', '\\\\', $attachment_template);
|
|
|
|
|
$attachment_template = str_replace("'", "\'", $attachment_template);
|
|
|
|
|
|
|
|
|
|
preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#s', $attachment_template, $tpl);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
|
if (empty($extensions) || !is_array($extensions))
|
|
|
|
|
{
|
2003-09-09 07:02:57 +00:00
|
|
|
|
$extensions = array();
|
2003-06-17 19:34:17 +00:00
|
|
|
|
obtain_attach_extensions($extensions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($attachment_data as $attachment)
|
|
|
|
|
{
|
|
|
|
|
// Some basics...
|
|
|
|
|
$attachment['extension'] = strtolower(trim($attachment['extension']));
|
2004-12-12 14:07:02 +00:00
|
|
|
|
$filename = $phpbb_root_path . $config['upload_dir'] . '/' . basename($attachment['physical_filename']);
|
|
|
|
|
$thumbnail_filename = $phpbb_root_path . $config['upload_dir'] . '/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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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
|
|
|
|
|
2004-12-12 14:07:02 +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;
|
2003-06-17 19:34:17 +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;
|
|
|
|
|
}
|
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();
|
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;
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
/*
|
|
|
|
|
// Macromedia Flash Files
|
|
|
|
|
case SWF_CAT:
|
|
|
|
|
list($width, $height) = swf_getdimension($filename);
|
|
|
|
|
|
|
|
|
|
$l_downloaded_viewed = $user->lang['VIEWED'];
|
|
|
|
|
$download_link = $filename;
|
|
|
|
|
|
|
|
|
|
$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';
|
|
|
|
|
|
|
|
|
|
$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
|
|
|
|
}
|
|
|
|
|
|
2003-01-20 05:12:38 +00:00
|
|
|
|
?>
|