Codice: Seleziona tutto
<?php
/*
*
* @package Topic più visti & Ultimi Topic [MOD]
* @author Carlo
* @website http://www.phpbbitalia.net/
*
*/
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);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Configuration
$max_topic = 6;
$forums_id = array(228,229,230,231,232,233,234,236,237,238,239,240,241,242,243,244,245,246,132,133,291,287,288,289,286,147,145);
$default_image = './images/Not_Available.jpg';
$sql = "SELECT p.post_text, p.bbcode_uid, t.* FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t WHERE t.forum_id IN (" . implode(', ', $forums_id) . ") AND p.post_id = t.topic_first_post_id ORDER BY topic_views DESC LIMIT 0," . $max_topic;
$result = $db->sql_query($sql);
$a = $b = 0;
while ($row = $db->sql_fetchrow($result)) {
if ($auth->acl_get('f_read', $row['forum_id'])) {
$a++;
$bbcode_img_to_array = bbcode_img_to_array($row['post_text'], $row['bbcode_uid']);
$thumb = (isset($bbcode_img_to_array['img'][0]) ? $bbcode_img_to_array['img'][0] : (isset($bbcode_img_to_array['img'][0]) ? $bbcode_img_to_array['img'][0] : $default_image));
$template->assign_block_vars('topics_views', array(
'EVEN' => (($a % 2 == 0) ? true : false),
'THUMB' => $thumb,
'LINK' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=" . $row['forum_id'] . "&t=" . $row['topic_id']),
'TITLE' => $row['topic_title'],
'VIEWS' => $row['topic_views']
));
}
}
$db->sql_freeresult($result);
$sql = "SELECT p.post_text, p.bbcode_uid, t.* FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t WHERE t.forum_id IN (" . implode(', ', $forums_id) . ") AND p.post_id = t.topic_first_post_id ORDER BY topic_time DESC LIMIT 0," . $max_topic;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
if ($auth->acl_get('f_read', $row['forum_id'])) {
$b++;
$bbcode_img_to_array = bbcode_img_to_array($row['post_text'], $row['bbcode_uid']);
$thumb = (isset($bbcode_img_to_array['img'][0]) ? $bbcode_img_to_array['img'][0] : (isset($bbcode_img_to_array['img'][0]) ? $bbcode_img_to_array['img'][0] : $default_image));
$template->assign_block_vars('topics_time', array(
'EVEN' => (($b % 2 == 0) ? true : false),
'THUMB' => $thumb,
'LINK' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=" . $row['forum_id'] . "&t=" . $row['topic_id']),
'TIME' => $user->format_date($row['topic_time'], false, false),
'TITLE' => $row['topic_title']
));
}
}
$db->sql_freeresult($result);
/*
* Parse [img] and [thumbnail] BBCode for messages and insert in an array BBCode params
*
* @param $msg string message to parse
* @param $uid string bbcode uid for message
*
*/
function bbcode_img_to_array($msg, $uid) {
$array_parsed_item = array();
$msg = str_replace("\n", '', $msg);
$msg = str_replace(array('[', ']'), array('<', '>'), $msg);
$msg = str_replace(':' . $uid, '', $msg);
$msg = preg_replace("|<url=(.*)>(.*)</url>|U", "<url>$1</url>", $msg);
preg_match_all("|<img>(.*)</img>|U", $msg, $array['img']);
preg_match_all("|<thumbnail>(.*)</thumbnail>|U", $msg, $array['thumbnail']);
$bbcode = array(
'img' => $array['img'][1],
'thumbnail' => $array['thumbnail'][1]
);
return $bbcode;
}
page_header('Topic più visti & Ultimi topic');
$template->set_filenames(array(
'body' => 'topics_list.html',
));
page_footer();
?>