{attach_list.MY_ATTACH_LINK} ma {attach_list.MY_THUMBS} che è la miniatura salvata con l'attach_id, non con il topic_id, mi sbagliavo io.Ma anche nelle ultime immagini del Forum non sono thumbs.

{attach_list.MY_ATTACH_LINK} ma {attach_list.MY_THUMBS} che è la miniatura salvata con l'attach_id, non con il topic_id, mi sbagliavo io.


Codice: Seleziona tutto
<table class="tablebg" cellspacing="1" width="100%">
<tr>
<th colspan="2" align="center"> Ultime immagini del Forum </th>
</tr>
<tr>
<td class="row1" colspan="3" align="center">
<!-- BEGIN attach_list -->
<a href="{attach_list.MY_TOPIC_LINK}" title="{attach_list.MY_TOPIC_TITLE} (di {attach_list.MY_TOPIC_AUTHOR})"><img src="{attach_list.MY_THUMBS} alt="{attach_list.MY_FORUM_NAME}" border="0" height="100"></a>
<!-- END attach_list--></td>
</tr>
<tr>
<td class="row2" colspan="3" align="center"> Seconda riga</td>
</tr>
</table>


Codice: Seleziona tutto
<?php
/**
*
* @package phpBB3
* @version $Id: index.php 9614 2009-06-18 11:04:54Z nickvergessen $
* @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);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
display_forums('', $config['load_moderators']);
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_posts = $config['num_posts'];
$total_topics = $config['num_topics'];
$total_users = $config['num_users'];
$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';
// Grab group details for legend display
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
{
$sql = 'SELECT group_id, group_name, group_colour, group_type
FROM ' . GROUPS_TABLE . '
WHERE group_legend = 1
ORDER BY group_name ASC';
}
else
{
$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
FROM ' . GROUPS_TABLE . ' g
LEFT JOIN ' . USER_GROUP_TABLE . ' ug
ON (
g.group_id = ug.group_id
AND ug.user_id = ' . $user->data['user_id'] . '
AND ug.user_pending = 0
)
WHERE g.group_legend = 1
AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] . ')
ORDER BY g.group_name ASC';
}
$result = $db->sql_query($sql);
$legend = array();
while ($row = $db->sql_fetchrow($result))
{
$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
$group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
if ($row['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')))
{
$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
}
else
{
$legend[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
}
}
$db->sql_freeresult($result);
$legend = implode(', ', $legend);
// Generate birthday list if required ...
$birthday_list = '';
if ($config['load_birthdays'] && $config['allow_birthdays'])
{
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
FROM ' . USERS_TABLE . ' u
LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
WHERE (b.ban_id IS NULL
OR b.ban_exclude = 1)
AND u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
if ($age = (int) substr($row['user_birthday'], -4))
{
$birthday_list .= ' (' . ($now['year'] - $age) . ')';
}
}
$db->sql_freeresult($result);
}
// Assign index specific vars
$template->assign_vars(array(
'TOTAL_POSTS' => sprintf($user->lang[$l_total_post_s], $total_posts),
'TOTAL_TOPICS' => sprintf($user->lang[$l_total_topic_s], $total_topics),
'TOTAL_USERS' => sprintf($user->lang[$l_total_user_s], $total_users),
'NEWEST_USER' => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
'LEGEND' => $legend,
'BIRTHDAY_LIST' => $birthday_list,
'FORUM_IMG' => $user->img('forum_read', 'NO_UNREAD_POSTS'),
'FORUM_UNREAD_IMG' => $user->img('forum_unread', 'UNREAD_POSTS'),
'FORUM_LOCKED_IMG' => $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'),
'FORUM_UNREAD_LOCKED_IMG' => $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'),
'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false,
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums') : '',
'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=front', true, $user->session_id) : '')
);
// ####### 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(7)'; // mode=parent_id (Elenco dei forum_id del tipo parent_id)
//$where_list = 'pt.forum_id IN(4,5,6,7,8,9,10,11,12,13)'; // 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
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);
}
// 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_THUMBS' => $thumb_cor
));
$topic_cor = $row['topic_id'] ;
$x = ++$x ;
}
}
// ####### FINE MOD VIEW LAST PICTURES ##########
include($phpbb_root_path . 'mod_week.' . $phpEx);
include($phpbb_root_path . 'mod_top_pictures.' . $phpEx);
include($phpbb_root_path . 'mod_topten_topics.' . $phpEx);
// Output page
page_header($user->lang['INDEX']);
$template->set_filenames(array(
'body' => 'index_body.html')
);
page_footer();
?>Codice: Seleziona tutto
<?php
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();
// ####### 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 = '100' ;
$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(4,5,6,7,8,9,10,11,12,13)'; // mode=forum_id (Elenco dei forum_id normali)
$n_pic = '200' ; // Numero delle immagini da visualizzare
$n_top = '600' ; // 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);
}
// 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_THUMBS' => $thumb_cor
));
$topic_cor = $row['topic_id'] ;
$x = ++$x ;
}
}
// ####### FINE MOD VIEW LAST PICTURES ##########
page_header('News');
$template->set_filenames(array(
'body' => 'news_body.html',
));
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
Codice: Seleziona tutto
, così è poco chiaro.
Devo avalizzare meglio il tuo codice ma da subito ti dico che la Mod Last_Pictures andrebbe inserita come le altre, con un "include".
In pratica tu fai un file php che contiene quel codice e poi lo inserisci in index.php con un "include". In questo modo il file index.php è molto più pulito e se vuoi togliere una Mod ti basta togliere la riga "include".
Poi bisogna vedere di non entrare in conflitto con le due Mod, ad esempio cambierei i nomi delle variabili, un conto è la Mod Last pictures, altra cosa è la Mod News.
Se come dici tu le Mod sono le stesse (cambia solo il numero delle immagini da visualizzare) non ha senso usare nella Mod News la function che crea le Thumbs perchè quelle sono già create dall'altra Mod ma quello non è un problema perchè se il file esiste la function non viene usata.
Cambierei però i nomi sia degli array che delle variabili per evitare confusione tra le due Mod.
Il problema è sempre quello del tempo, io lavoro e queste cose dovrei farle nel tempo libero ma con 4 Forum da gestire e gli impegni di questo Forum sono veramente in difficoltà, vedrò cosa posso fare.
Ero partito con l'intenzione di dare qualche consiglio ma se gli impegni sono troppo onerosi non vorrei essere costretto a rinunciare a dare supporto.
Altri moderatori che conoscano l'argomento può essere solo Carlo ma anche lui mi sembra ben messo con gli impegni.
EDIT: un'altra cosa: esiste nel Server la cartella "thumbs" ? , cosa contiene ?

Codice: Seleziona tutto
include($phpbb_root_path . 'mod_last_pictures.' . $phpEx);Codice: Seleziona tutto
<!-- INCLUDE mod_last_pictures_body.html -->Visitano il forum: Nessuno e 11 ospiti