il problema che ho fatto questa modifica un po di tempo fa ma adesso no ricordo cosa ho fatto.
ma non la visualizza.
Codice: Seleziona tutto
<?php
// ####### INIZIO MOD VIEW LAST PICTURES ver. 1.0.2 by Bingo - 25/03/2010 ########
// 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(83)'; // mode=parent_id (Elenco dei forum_id del tipo parent_id)
$where_list = 'pt.forum_id IN(12,13,14,15,16,17,19,20,21,22,24,26,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,51,52,53,55,56,57,60,61,62,63,64,65,69,70,71,79,82,83,84,85,86,88,89,90,91,95,97,98,99,100,102,105,104,106,107,108,109,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,131,134,135,136,137,138,139,140,141,142,143,144,145,147)'; // mode=forum_id (Elenco dei forum_id normali)
$n_pic = '6' ; // Numero delle immagini da visualizzare
$n_top = '100' ; // 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
AND pa.extension = 'jpg'
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'];
$thumbs = "thumbs/". $attach_id . ".jpg" ;
if (is_file($thumbs)){
$thumb_cor = $thumbs ;
}else{
$thumb_cor = resize_thumbs($physical, $attach_id);
}
if (strlen($row['topic_title'] > '23'))
{
$short_title = substr($row['topic_title'],0,20) . "...";
}else{
$short_title = $row['topic_title'] ;
}
// 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_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_TOPIC_AUTHOR' => $row['topic_first_poster_name'],
'MY_ATTACH_ID' => $attach_id,
'MY_SHORT_TITLE' => $short_title ,
'MY_THUMBS' => $thumb_cor
));
$topic_cor = $row['topic_id'] ;
$x = ++$x ;
}
}
// ####### FINE MOD VIEW LAST PICTURES ##########
?>