2002-11-07 03:39:50 +00:00
|
|
|
<?php
|
|
|
|
/***************************************************************************
|
|
|
|
* functions_display.php
|
|
|
|
* ------------------
|
|
|
|
* begin : Saturday, Feb 13, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2003-01-20 05:12:38 +00:00
|
|
|
function display_forums($root_data = '', $display_moderators = TRUE)
|
2002-11-07 03:39:50 +00:00
|
|
|
{
|
2003-04-26 01:17:40 +00:00
|
|
|
global $config, $db, $template, $auth, $user;
|
|
|
|
global $phpEx, $SID, $forum_moderators;
|
2002-11-07 03:39:50 +00:00
|
|
|
|
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
|
|
|
|
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'];
|
2002-11-18 21:04:45 +00:00
|
|
|
$forum_rows = $subforums = $forum_moderators = array();
|
|
|
|
$forum_ids = array($root_data['forum_id']);
|
2002-11-07 03:39:50 +00:00
|
|
|
|
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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-05-02 15:50:11 +00:00
|
|
|
if ($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-04-26 16:24:58 +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
|
|
|
|
$forum_rows[$parent_id]['forum_topics'] += $row['forum_topics'];
|
|
|
|
$forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
|
|
|
|
|
|
|
|
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'];
|
|
|
|
$forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-05-03 23:58:45 +00:00
|
|
|
$forum_rows[$parent_id]['forum_id_last_post'] = $row['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
|
|
|
|
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();
|
|
|
|
|
2003-04-26 01:17:40 +00:00
|
|
|
/*
|
2003-06-19 16:19:59 +00:00
|
|
|
if (isset($tracking_topics) && $user->data['user_id'] != ANONYMOUS)
|
2003-04-26 01:17:40 +00:00
|
|
|
{
|
2003-06-19 16:19:59 +00:00
|
|
|
$min_forum_time = base_convert(min($tracking_topics[$forum_id]), 36, 10) + $config['board_startdate'];
|
|
|
|
$max_forum_time = base_convert(max($tracking_topics[$forum_id]), 36, 10) + $config['board_startdate'];
|
|
|
|
|
|
|
|
|
|
|
|
// $mark_time_forum && $mark_time_topic
|
|
|
|
$sql = "SELECT topic_id, topic_last_post_time
|
2003-04-26 01:17:40 +00:00
|
|
|
FROM " . TOPICS_TABLE . "
|
2003-06-19 16:19:59 +00:00
|
|
|
WHERE forum_id = $forum_id
|
|
|
|
AND topic_last_post_time > $min_forum_time";//AND topic_last_post_time < $max_forum_time
|
2003-04-26 01:17:40 +00:00
|
|
|
$result = $db->sql_query($sql);
|
|
|
|
|
2003-06-19 16:19:59 +00:00
|
|
|
$mark_time = 0;
|
|
|
|
if ($row2 = $db->sql_fetchrow($result))
|
2003-04-26 01:17:40 +00:00
|
|
|
{
|
2003-06-19 16:19:59 +00:00
|
|
|
do
|
2003-04-26 01:17:40 +00:00
|
|
|
{
|
2003-06-19 16:19:59 +00:00
|
|
|
$mtopic_id = base_convert($row2['topic_id'], 10, 36);
|
|
|
|
$tracking_topics[$forum_id][$mtopic_id] = base_convert($tracking_topics[$forum_id][$mtopic_id], 36, 10);
|
|
|
|
$tracking_topics[$forum_id][0] = base_convert($tracking_topics[$forum_id][0], 36, 10);
|
|
|
|
|
|
|
|
echo $row2['topic_id'] . " :: " . $tracking_topics[$forum_id][$mtopic_id] . " :: " . $tracking_topics[$forum_id][0] . " :: " . $row2['topic_last_post_time'] . " :: " . $row['post_time'] . "<br />";
|
|
|
|
|
|
|
|
if ((($row2['topic_id'] != $topic_id &&
|
|
|
|
($tracking_topics[$forum_id][$mtopic_id] >= $row2['topic_last_post_time'] ||
|
|
|
|
$tracking_topics[$forum_id][0] >= $row2['topic_last_post_time'])) ||
|
|
|
|
($row2['topic_id'] == $topic_id && $row['post_time'] <= $row2['topic_last_post_time'])) &&
|
|
|
|
!isset($mark_read))
|
|
|
|
{
|
|
|
|
$mark_read = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mark_read = false;
|
|
|
|
}
|
|
|
|
$mark_time = max($mark_time, $row2['topic_last_post_time']);
|
2003-04-26 01:17:40 +00:00
|
|
|
}
|
2003-06-19 16:19:59 +00:00
|
|
|
while ($row2 = $db->sql_fetchrow($result));
|
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
|
|
|
if ($mark_read)
|
|
|
|
{
|
|
|
|
markread('mark', $forum_id, false, $mark_time);
|
|
|
|
echo "HERE :: $mark_time :: " . time();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "HERE2";
|
2003-04-26 01:17:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
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 01:17:40 +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'];
|
|
|
|
foreach ($forum_rows as $row)
|
|
|
|
{
|
|
|
|
if ($row['parent_id'] == $root_id)
|
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif (!empty($hold))
|
|
|
|
{
|
|
|
|
$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'],
|
2003-04-22 17:26:29 +00:00
|
|
|
'U_VIEWFORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $hold['forum_id'])
|
|
|
|
);
|
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(
|
2003-05-02 15:50:11 +00:00
|
|
|
'S_IS_CAT' => false,
|
|
|
|
'S_IS_LINK' => ($row['forum_type'] != FORUM_LINK) ? false : true,
|
2002-11-07 03:39:50 +00:00
|
|
|
|
2003-04-22 17:26:29 +00:00
|
|
|
'FORUM_IMG' => $row['forum_image'],
|
|
|
|
'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST'),
|
|
|
|
|
2002-11-07 03:39:50 +00:00
|
|
|
'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt),
|
|
|
|
'FORUM_NAME' => $row['forum_name'],
|
2003-03-20 00:31:36 +00:00
|
|
|
'FORUM_DESC' => $row['forum_desc'],
|
2003-05-02 15:50:11 +00:00
|
|
|
$l_post_click_count => $post_click_count,
|
2002-11-07 03:39:50 +00:00
|
|
|
'TOPICS' => $row['forum_topics'],
|
2003-04-22 17:26:29 +00:00
|
|
|
'LAST_POST_TIME' => $last_post_time,
|
|
|
|
'LAST_POSTER' => $last_poster,
|
2002-11-07 03:39:50 +00:00
|
|
|
'MODERATORS' => $moderators_list,
|
|
|
|
'SUBFORUMS' => $subforums_list,
|
|
|
|
|
2003-01-13 06:44:16 +00:00
|
|
|
'L_SUBFORUM_STR' => $l_subforums,
|
|
|
|
'L_MODERATOR_STR' => $l_moderator,
|
2002-11-07 03:39:50 +00:00
|
|
|
'L_FORUM_FOLDER_ALT'=> $folder_alt,
|
2003-05-02 15:50:11 +00:00
|
|
|
|
2003-04-22 17:26:29 +00:00
|
|
|
'U_LAST_POSTER' => $last_poster_url,
|
|
|
|
'U_LAST_POST' => $last_post_url,
|
2003-05-20 12:24:10 +00:00
|
|
|
'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(
|
2003-05-02 15:50:11 +00:00
|
|
|
'S_HAS_SUBFORUM' => ($visible_forums) ? true : false,
|
2003-03-20 00:31:36 +00:00
|
|
|
'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'])
|
|
|
|
);
|
2002-11-07 03:39:50 +00:00
|
|
|
}
|
2003-04-22 17:26:29 +00:00
|
|
|
|
2003-06-17 19:34:17 +00:00
|
|
|
// Display Attachments
|
|
|
|
function display_attachments($attachment_data, &$update_count, $force_physical = false)
|
|
|
|
{
|
|
|
|
global $extensions, $template;
|
|
|
|
global $config, $user, $phpbb_root_path, $phpEx, $SID;
|
|
|
|
|
|
|
|
if (empty($extensions) || !is_array($extensions))
|
|
|
|
{
|
|
|
|
obtain_attach_extensions($extensions);
|
|
|
|
}
|
|
|
|
|
|
|
|
$update_count = array();
|
|
|
|
|
|
|
|
foreach ($attachment_data as $attachment)
|
|
|
|
{
|
|
|
|
// Some basics...
|
|
|
|
$attachment['extension'] = strtolower(trim($attachment['extension']));
|
|
|
|
$filename = $config['upload_dir'] . '/' . $attachment['physical_filename'];
|
|
|
|
$thumbnail_filename = $config['upload_dir'] . '/thumbs/t_' . $attachment['physical_filename'];
|
|
|
|
|
|
|
|
$upload_image = '';
|
|
|
|
|
|
|
|
if ($user->img('icon_attach', '') != '' && $extensions[$attachment['extension']]['upload_icon'] == '')
|
|
|
|
{
|
|
|
|
$upload_image = $user->img('icon_attach', '');
|
|
|
|
}
|
|
|
|
else if ($extensions[$attachment['extension']]['upload_icon'] != '')
|
|
|
|
{
|
|
|
|
$upload_image = '<img src="' . $phpbb_root_path . 'images/upload_icons/' . trim($extensions[$attachment['extension']]['upload_icon']) . '" alt="" border="0" />';
|
|
|
|
}
|
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
$display_name = $attachment['real_filename'];
|
|
|
|
$comment = stripslashes(trim(str_replace("\n", '<br />', $attachment['comment'])));
|
|
|
|
|
2003-06-25 19:49:59 +00:00
|
|
|
$denied = FALSE;
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
|
|
if (!in_array($attachment['extension'], $extensions['_allowed_']))
|
|
|
|
{
|
2003-06-25 19:49:59 +00:00
|
|
|
$denied = TRUE;
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
|
|
$template->assign_block_vars('postrow.attachment', array(
|
2003-06-25 19:49:59 +00:00
|
|
|
'IS_DENIED' => TRUE,
|
2003-06-17 19:34:17 +00:00
|
|
|
|
|
|
|
'L_DENIED' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$denied)
|
|
|
|
{
|
|
|
|
$l_downloaded_viewed = '';
|
|
|
|
$download_link = '';
|
|
|
|
$additional_array = array();
|
|
|
|
|
|
|
|
$display_cat = $extensions[$attachment['extension']]['display_cat'];
|
|
|
|
|
|
|
|
if ($display_cat == IMAGE_CAT)
|
|
|
|
{
|
|
|
|
if ($attachment['thumbnail'])
|
|
|
|
{
|
|
|
|
$display_cat = THUMB_CAT;
|
|
|
|
}
|
|
|
|
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
|
|
|
|
|
|
|
$display_cat = (!$width && !$height) ? IMAGE_CAT : (($width <= $config['img_link_width'] && $height <= $config['img_link_height']) ? IMAGE_CAT : NONE_CAT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$display_cat = NONE_CAT;
|
|
|
|
}
|
2003-06-25 19:49:59 +00:00
|
|
|
}
|
2003-06-17 19:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch ($display_cat)
|
|
|
|
{
|
|
|
|
// Images
|
|
|
|
case IMAGE_CAT:
|
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
|
|
|
|
case THUMB_CAT:
|
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;
|
|
|
|
|
|
|
|
$additional_array = array(
|
|
|
|
'THUMB_IMG' => $thumb_source
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Windows Media Streams
|
|
|
|
case WM_CAT:
|
|
|
|
$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
|
|
|
|
case RM_CAT:
|
|
|
|
$l_downloaded_viewed = $user->lang['VIEWED'];
|
|
|
|
$download_link = $filename;
|
|
|
|
|
|
|
|
$additional_array = array(
|
|
|
|
'U_FORUM' => generate_board_url(),
|
|
|
|
'ATTACH_ID' => $attachment['attach_id']
|
|
|
|
);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
$template_array = array_merge($additional_array, array(
|
|
|
|
// 'IS_FLASH' => ($display_cat == SWF_CAT) ? true : false,
|
|
|
|
'IS_WM_STREAM' => ($display_cat == WM_CAT) ? true : false,
|
|
|
|
'IS_RM_STREAM' => ($display_cat == RM_CAT) ? true : false,
|
|
|
|
'IS_THUMBNAIL' => ($display_cat == THUMB_CAT) ? true : false,
|
|
|
|
'IS_IMAGE' => ($display_cat == IMAGE_CAT) ? true : false,
|
|
|
|
'DOWNLOAD_NAME' => $display_name,
|
|
|
|
'FILESIZE' => $filesize,
|
|
|
|
'SIZE_VAR' => $size_lang,
|
|
|
|
'COMMENT' => $comment,
|
|
|
|
|
|
|
|
'U_DOWNLOAD_LINK' => $download_link,
|
|
|
|
|
|
|
|
'UPLOAD_IMG' => $upload_image,
|
|
|
|
|
|
|
|
'L_DOWNLOADED_VIEWED' => $l_downloaded_viewed,
|
|
|
|
'L_DOWNLOAD_COUNT' => sprintf($user->lang['DOWNLOAD_NUMBER'], $attachment['download_count']))
|
|
|
|
);
|
|
|
|
|
|
|
|
$template->assign_block_vars('postrow.attachment', $template_array);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-20 05:12:38 +00:00
|
|
|
?>
|