Mi sono dimenticato un file, scusa.
Codice: Seleziona tutto
<?php
// MOD Topten Topics ver. 1.0.2
// Topics più recenti, Topics più visti, Topics con maggiori risposte e Posts più recenti
// created by Micogian 2010
// configurazione: numero dei recods da visualizzare nella Lista
$lista = 10 ; // sostituire il numero della variabile $lista se si desidera diminuire/aumentare il numero dei Topics
$lista_dati = 20 ; // numero di topics da estrarre dalla tabella (alcuni topics potrebbero non aver il permesso di lettura)
$lista_posts = 50 ; // numero di posts da estrarre dalla tabella (il numero è più alto perchè viene inserito un solo post per topic)
function mese_cor($data_cor)
{
$data_short = str_replace("Jan","gen", $data_cor);
$data_short = str_replace("Feb","feb", $data_cor);
$data_short = str_replace("Mar","mar", $data_cor);
$data_short = str_replace("Apr","apr", $data_cor);
$data_short = str_replace("Mag","mag", $data_cor);
$data_short = str_replace("Jun","giu", $data_cor);
$data_short = str_replace("Jul","lug", $data_cor);
$data_short = str_replace("Aug","ago", $data_cor);
$data_short = str_replace("sep","set", $data_cor);
$data_short = str_replace("Oct","ott", $data_cor);
$data_short = str_replace("Nov","nov", $data_cor);
$data_short = str_replace('Dec','dic', $data_cor);
return $data_short;
}
//---------- 10 Topics più Recenti start -----------//
$sql1 = "SELECT tt.topic_id, tt.forum_id, tt.topic_title, tt.topic_time, tt.topic_moved_id, tt.topic_first_poster_name,
ft.forum_id, ft.forum_name
FROM " . TOPICS_TABLE . " tt, " . FORUMS_TABLE . " ft
WHERE tt.topic_type = 0
AND tt.topic_moved_id = 0
AND tt.forum_id = ft.forum_id
ORDER BY tt.topic_time DESC LIMIT 0,$lista_dati";
$result1 = $db->sql_query($sql1);
$n1 = 0;
while ($row1 = $db->sql_fetchrow($result1))
{
if ($auth->acl_get('f_read', $row1['forum_id']) == 1)
{
if ($n1 < $lista)
{
if (strlen($row1['topic_title']) > 28)
{
$topic_title1 = substr($row1['topic_title'],0,27) . "...";
}else{
$topic_title1 = $row1['topic_title'];
}
$last_topic_link[$n1] = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=" . $row1['forum_id'] . "&t=" . $row1['topic_id']);
$last_topic_title[$n1] = $row1['topic_title'];
$last_topic_title_short[$n1] = $topic_title1;
$last_topic_forum[$n1] = $row1['forum_name'];
$last_topic_author[$n1] = $row1['topic_first_poster_name'];
$last_topic_data[$n1] = date("d M",$row1['topic_time']);
++$n1 ;
}
}
}
//---------- 10 Topics più Recenti end -----------//
//---------- 10 Topics più Visti start -----------//
$sql2 = "SELECT tt.topic_id, tt.forum_id, tt.topic_title, tt.topic_first_poster_name, tt.topic_views,
ft.forum_id, ft.forum_name
FROM " . TOPICS_TABLE . " tt, " . FORUMS_TABLE . " ft
WHERE tt.forum_id = ft.forum_id
ORDER BY tt.topic_views DESC LIMIT 0,$lista_dati";
$result2 = $db->sql_query($sql2);
$n2 = 0 ;
while ($row2 = $db->sql_fetchrow($result2))
{
if ($auth->acl_get('f_read', $row2['forum_id']) == 1)
{
if ($n2 < $lista)
{
if (strlen($row2['topic_title']) > 28)
{
$topic_title2 = substr($row2['topic_title'],0,27) . "...";
}else{
$topic_title2 = $row2['topic_title'];
}
$view_topic_link[$n2] = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=" . $row2['forum_id'] . "&t=" . $row2['topic_id']);
$view_topic_title[$n2] = $row2['topic_title'];
$view_topic_title_short[$n2] = $topic_title2;
$view_topic_forum[$n2] = $row2['forum_name'];
$view_topic_author[$n2] = $row2['topic_first_poster_name'];
$view_topic_views[$n2] = $row2['topic_views'];
++$n2 ;
}
}
}
//---------- 10 Topics più visti end -----------//
/*
//---------- 10 Topics con più risposte start -----------//
$sql3 = "SELECT tt.topic_id, tt.forum_id, tt.topic_title, tt.topic_first_poster_name, tt.topic_replies,
ft.forum_id, ft.forum_name
FROM " . TOPICS_TABLE . " tt, " . FORUM_TABLE . " ft
ORDER BY tt.topic_replies DESC LIMIT 0,$lista_dati";
$result3 = $db->sql_query($sql3);
$n3 = 0 ;
while ($row3 = $db->sql_fetchrow($result3))
{
if ($auth->acl_get('f_read', $row2['forum_id']) == 1)
{
if ($n3 < $lista)
{
if (strlen($row3['topic_title']) > 28)
{
$topic_title3 = substr($row3['topic_title'],0,27) . "...";
}else{
$topic_title3 = $row3['topic_title'];
}
$replies_topic_link[$n3] = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=" . $row3['forum_id'] . "&t=" . $row3['topic_id']);
$replies_topic_title[$n3] = $row3['topic_title'];
$replies_topic_title_short[$n3] = $topic_title3;
$replies_topic_forum[$n3] = $row3['forum_name'];
$replies_topic_author[$n3] = $row3['topic_first_poster_name'];
$replies_topic_replies[$n3] = $row3['topic_replies'];
++$n3 ;
}
}
}
//---------- 10 Topics con più risposte end -----------//
*/
//---------- 10 Ultimi posts start -----------//
$sql4 = "SELECT pt.post_id, pt.topic_id, pt.forum_id, pt.post_subject, pt.post_time, pt.poster_id,
tt.topic_id, tt.topic_title,
ut.user_id, ut.username,
ft.forum_id, ft.forum_name
FROM " . POSTS_TABLE . " pt, " . TOPICS_TABLE . " tt, " . FORUMS_TABLE . " ft, " . USERS_TABLE . " ut
WHERE pt.poster_id = ut.user_id
AND pt.forum_id = ft.forum_id
AND tt.topic_id = pt.topic_id
ORDER BY pt.post_time DESC LIMIT 0,$lista_posts";
$result4 = $db->sql_query($sql4);
$n4 = 0 ;
$lista_topics = '' ;
while ($row4 = $db->sql_fetchrow($result4))
{
if ($auth->acl_get('f_read', $row4['forum_id']) == 1)
{
if( strpos($lista_topics, $row4['topic_id']) == '0' AND $n4 < $lista )
{
if (strlen($row4['topic_title']) > 28)
{
$post_title = substr($row4['topic_title'],0,27) . "...";
}else{
$post_title = $row4['topic_title'];
}
$last_post_link[$n4] = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=" . $row4['forum_id'] . "&t=" . $row4['topic_id'] . "#p" . $row4['post_id']);
$last_post_title[$n4] = $row4['topic_title'];
$last_post_title_short[$n4] = $post_title;
$last_post_forum[$n4] = $row4['forum_name'];
$last_post_author[$n4] = $row4['username'];
$lista_topics .= "," . $row4['topic_id'] ;
++$n4 ;
}
}
}
//---------- 10 Ultimi posts end -----------//
for ($x = 0; $x < $lista; ++$x)
{
$template->assign_block_vars('topten_list',array(
'LAST_TOPIC_LINK' => $last_topic_link[$x],
'LAST_TOPIC_TITLE' => $last_topic_title[$x],
'LAST_TOPIC_TITLE_SHORT' => $last_topic_title_short[$x],
'LAST_TOPIC_FORUM' => $last_topic_forum[$x],
'LAST_TOPIC_AUTHOR' => $last_topic_author[$x],
'LAST_TOPIC_DATA' => mese_cor($last_topic_data[$x]),
'VIEW_TOPIC_LINK' => $view_topic_link[$x],
'VIEW_TOPIC_TITLE' => $view_topic_title[$x],
'VIEW_TOPIC_TITLE_SHORT' => $view_topic_title_short[$x],
'VIEW_TOPIC_FORUM' => $view_topic_forum[$x],
'VIEW_TOPIC_AUTHOR' => $view_topic_author[$x],
'VIEW_TOPIC_VIEWS' => $view_topic_views[$x],
//'REPLIES_TOPIC_LINK' => $replies_topic_link[$x],
//'REPLIES_TOPIC_TITLE' => $replies_topic_title[$x],
//'REPLIES_TOPIC_TITLE_SHORT' => $replies_topic_title_short[$x],
//'REPLIES_TOPIC_FORUM' => $replies_topic_forum[$x],
//'REPLIES_TOPIC_AUTHOR' => $replies_topic_author[$x],
//'REPLIES_TOPIC_REPLIES' => $replies_topic_replies[x],
'LAST_POST_LINK' => $last_post_link[$x],
'LAST_POST_TITLE' => $last_post_title[$x],
'LAST_POST_TITLE_SHORT' => $last_post_title_short[$x],
'LAST_POST_FORUM' => $last_post_forum[$x],
'LAST_POST_AUTHOR' => $last_post_author[$x],
));
}
?>
Il resto rimane come già detto.
In pratica il file prova_toptent_topics.php fda le veci di index.php e importa il file sql_topten_topics.php che contiene le query.
Il file prova_topten_topics.html elabora i dati e ptova_page_topten.php li visualizza come se fosse index_body.html.
Il risultato è la striscia dei Topten Topics in una Pagina personalizzata.