Codice: Seleziona tutto
<?php
/**
*
* @package phpBB3
* @version $Id: user_topic_list.php 2009 11 30 Bingo $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
global $icons;
// Start session
$user->session_begin();
$auth->acl($user->data);
//$user->setup('viewforum', $forum_data['forum_style']);
$user->setup('viewforum');
// Start initial var setup
// 1) inserire le barre iniziali alla riga seguente se si sceglie l'opzione 2) con questa il Forum richiesto viene inserito nell'URL (http://..../user_topic.php?f=1)
$forum_id = request_var('f', 0);
// 2) Togliere le barre iniziali alla riga seguente se viene scelta questa opzione e inserire il forum_id voluto
//$forum_id = "1";
if (!$forum_id)
{
trigger_error('NO_FORUM');
}
// Redirect to login upon emailed notification links
if (isset($_GET['e']) && !$user->data['is_registered'])
{
login_box('', $user->lang['LOGIN_NOTIFY_FORUM']);
}
$sql = "SELECT f.*
FROM ".FORUMS_TABLE." f
WHERE f.forum_id = $forum_id";
$result = $db->sql_query($sql);
$forum_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$forum_data)
{
trigger_error('NO_FORUM');
}
// Permissions check
if (!$auth->acl_gets('f_list', 'f_read', $forum_id) || ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link'] && !$auth->acl_get('f_read', $forum_id)))
{
if ($user->data['user_id'] != ANONYMOUS)
{
trigger_error('SORRY_AUTH_READ');
}
login_box('', $user->lang['LOGIN_VIEWFORUM']);
}
// Forum is passworded ... check whether access has been granted to this
// user this session, if not show login box
if ($forum_data['forum_password'])
{
login_forum_box($forum_data);
}
//Obtain forum name
$forum_name = $forum_data['forum_name']; //
$template->assign_var('FORUM_NAME', $forum_name);
$template->assign_var('U_VIEWFORUM',append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id));
$icons = $cache->obtain_icons();
//query per una lista di forum_id
$sql = "SELECT
pt.topic_id, pt.icon_id, pt.topic_title, pt.topic_views, pt.topic_first_poster_name, pt.topic_time, pf.parent_id, pf.forum_id, pf.forum_name AS forum_name_cor,
UCASE(LEFT(TRIM(LEADING '[' FROM pt.topic_title), 1)) AS first_char
FROM ". TOPICS_TABLE." pt,". FORUMS_TABLE. " pf
WHERE pt.forum_id = pf.forum_id
AND pt.topic_type = 0
AND pt.forum_id = $forum_id
ORDER BY UCASE(TRIM(LEADING '[' FROM pt.topic_title))";
$db->sql_query($sql);
$result = $db->sql_query($sql);
$current_char = '';
$template->assign_block_vars('topic_list', array(
'TOPIC_ICON_IMG' => '',
'TOPIC_TITLE' => "%",
'TOPIC_LINK' => '',
'FORUM_NAME' => "%",
'TOPIC_AUTHOR' => "%",
'VIEWS' => "%"
));
$string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
while ($row = $db->sql_fetchrow($result))
{
if (strchr("0123456789", $row['first_char']) && $current_char == ''){
$current_char = '0';
$template->assign_block_vars('topic_list', array(
'TOPIC_ICON_IMG' => '',
'TOPIC_TITLE' => "0-9",
'TOPIC_LINK' => '',
'TOPIC_AUTHOR' => '',
'VIEWS' => ''
));
} else if (strchr($string, $row['first_char']) ){
if ($row['first_char'] != $current_char) {
chapter($current_char, $row['first_char']);
$current_char = $row['first_char'];
}
}
$template->assign_block_vars('topic_list', array(
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : 'misc/empty.gif',
'TOPIC_TITLE' => $row['topic_title'],
'TOPIC_LINK' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't='.$row['topic_id']),
'FORUM_NAME_COR' => $row['forum_name_cor'],
'VIEWS' => $row['topic_views'],
'TOPIC_AUTHOR' => $row['topic_first_poster_name'],
'FIRST_POST_TIME' => date("d.m.Y",$row['topic_time']) //$user->format_date($row['topic_time'])
));
}
$db->sql_freeresult($result);
chapter($current_char, "-");
// Dump out the page header and load template
page_header($user->lang['VIEW_FORUM'] . $forum_name);
$template->set_filenames(array(
'body' => 'tlist_simple.html')
);
page_footer();
function chapter($start, $current)
{
global $template;
$letters = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
$letters_array = explode (",", $letters);
foreach ($letters_array as $key => $row) {
if ($row > strtoupper($start)){
$template->assign_block_vars('topic_list', array(
'TOPIC_ICON_IMG' => '',
'TOPIC_TITLE' => "$row",
'TOPIC_LINK' => '',
'FORUM_NAME_COR' => "$row",
));
}
if ($row == strtoupper($current)){
return;
}
}
}
?>