micogian ma è cambiato qualcosa? io ho questo codice. ho notato che è diverso:
Codice: Seleziona tutto
<?php
// ####### INIZIO MOD VIEW LAST PICTURES ver. 1.0.2 by Bingo - agg. 04/11/2011 ########
// function resize_thumbs() = crea una miniatura del file
// La function resize_thumbs() ridimensiona le immagini selezionate e le salva nella cartella thumbs
// La procedura quindi provvede a visualizzare le thumbs e non i file originali.
// Nel caso di nuovo Topics, le thumbs vengono create al momento del primo accesso da parte di un visitatore
// in modo che i successivi utenti trovano già disponibili le miniature.
function resize_thumbs($physical,$attach_id){
$img_des = $phpbb_root_path . "thumbs/" . $attach_id . ".jpg" ;
// Ottengo le informazioni sull'immagine originale
list($width, $height, $type, $attr) = getimagesize($phpbb_root_path . "files/" . $physical);
// Creo la versione ridimensionata dell'immagine (thumbnail)
// Modificare il valore di $new_height per ottenere thumbs di altezza diversa
// (la larghezza si adatta in proporzione)
$new_height = '120' ;
$new_width = ($width * $new_height / $height);
$thumb = imagecreatetruecolor($new_width, $new_height);
$source = imagecreatefromjpeg($phpbb_root_path . "files/" . $physical);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Salvo l'immagine ridimensionata
imagejpeg($thumb, $img_des, 75);
return "thumbs/". $attach_id . ".jpg" ;
}
// IMPOSTAZIONI PRINCIPALI
// scegliere una delle due seguenti condizioni di ricerca: per parent_id o per forum_id
// e inserire l'elenco dei parent_id o dei forum_id dove fare la selezione
//$where_list = 'pf.parent_id IN(7)'; // mode=parent_id (Elenco dei forum_id del tipo parent_id)
$where_list = 'pt.forum_id IN(8,9,10,16,15,37,13,68,12,14,69,84,80,81)'; // mode=forum_id (Elenco dei forum_id normali)
$n_pic = '8' ; // Numero delle immagini da visualizzare
$n_top = '40' ; // Numero dei topics da considerare nella query di ricerca. (***)
// (***) Dato che nei Topics ci possono essere più posts con immagini allegate ma solo una viene considerata
// è necessario aumentare il numero dei Topics elaborati per ottenere il numero di immagini da visualizzare
//query per estrarre gli ultimi n_topics con allegati
$sql = "SELECT
pf.forum_name, pf.parent_id, pf.forum_id,
pt.topic_id, pt.forum_id, pt.topic_title, pt.topic_first_poster_name, pt.topic_attachment, pt.topic_moved_id, pt.topic_time,
pp.topic_id, pp.post_id, pp.post_time,
pa.attach_id, pa.topic_id, pa.physical_filename, pa.extension, pa.post_msg_id
FROM ". FORUMS_TABLE." pf,". TOPICS_TABLE. " pt,". POSTS_TABLE. " pp,". ATTACHMENTS_TABLE. " pa
WHERE $where_list
AND pf.forum_id = pt.forum_id
AND pt.topic_id = pa.topic_id
AND pt.topic_id = pp.topic_id
AND pt.topic_time = pp.post_time
AND pp.post_id = pa.post_msg_id
AND pa.extension = 'jpg'
AND pt.topic_moved_id = 0
AND pt.topic_attachment = 1
ORDER BY pt.topic_time DESC LIMIT $n_top";
$db->sql_query($sql);
$result = $db->sql_query($sql);
$topic_cor = '' ;
$x = '0' ;
while ($row = $db->sql_fetchrow($result))
{
if ($topic_cor != $row['topic_id'] && $x < $n_pic ) {
$attach_id = $row['attach_id'];
$physical = $row['physical_filename'];
$physical_cor = "files/" . $physical ;
$thumbs = "thumbs/". $attach_id . ".jpg" ;
if (is_file($physical_cor))
{
if (is_file($thumbs)){
$thumb_cor = $thumbs ;
}else{
$thumb_cor = resize_thumbs($physical, $attach_id);
}
}
if(strlen($row['topic_title']) > 20)
{
$title_short = substr($row['topic_title'],0,18) . "..." ;
}else{
$title_short = $row['topic_title'] ;
}
if(strlen($row['forum_name']) > 20)
{
$forum_short = substr($row['forum_name'],0,20) . "..." ;
}else{
$forum_short = $row['forum_name'] ;
}
// assegna le variabili da passare al file HTML
$template->assign_block_vars('attach_list', array(
'MY_TOPIC_ID' => $row['topic_id'],
'MY_FORUM_ID' => $row['forum_id'],
'MY_SHORT_TITLE' => $title_short,
'MY_TOPIC_TITLE' => $row['topic_title'],
'MY_TOPIC_LINK' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't='.$row['topic_id']),
'MY_ATTACH_LINK' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id='.$attach_id),
'MY_FORUM_NAME' => $row['forum_name'],
'MY_FORUM_SHORT' => $forum_short,
'MY_TOPIC_AUTHOR' => $row['topic_first_poster_name'],
'MY_TOPIC_POSTER' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'MY_ATTACH_ID' => $attach_id,
'MY_THUMBS' => $thumb_cor
));
$topic_cor = $row['topic_id'] ;
$x = ++$x ;
}
}
// ####### FINE MOD VIEW LAST PICTURES ##########
?>