Файл: apwa/includes/last_x_att.php
Строк: 75
<?php
/**
*
* @package Last X [attachments] on Forum v.0.0.3
* @version $Id: last_x_attachments_on_forum.php 2010-1-16 23:20:35Z 4seven $
* @copyright (c) 2014 / 4seven
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
//---------Настройки--------------------------------------------------
// id игнорируемых форумов
$forum_ids_to_show = ''; // перечислять через запятую: '7,9,10'
$width_o_height = 'height'; // выровнять по ширине width и высоте height
$convert_real_size = 20; // Сколько фото выводить
$convert_mx_size = 100; // размер в который будет конвертироваться фото и выводиться (counts for width or height)
$forums = ($forum_ids_to_show) ? $forum_ids_to_show : 0;
$forum_ary = array();
$forum_read_ary = $auth->acl_getf('f_read');
foreach ($forum_read_ary as $forum_id => $allowed){
if ($allowed['f_read'])
{
$forum_ary[] = (int) $forum_id;}
}
$forum_ary = array_intersect(array_keys($auth->acl_getf('f_read', true)), array_keys($auth->acl_getf('f_download', true)));
if (!empty($forum_ary))
{
$sqls = 'SELECT a.attach_id, a.topic_id, a.post_msg_id, a.physical_filename, a.real_filename, f.forum_id, t.topic_id, t.forum_id, t.topic_title
FROM ' . ATTACHMENTS_TABLE . ' a, ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t
WHERE (mimetype = "image/jpeg" OR mimetype = "image/png" OR mimetype = "image/gif")
AND f.forum_id = ' . $forum_id . '
AND a.topic_id = t.topic_id
AND ' . $db->sql_in_set('t.forum_id', $forum_ary) . '
AND t.forum_id NOT IN (' . $forums . ')
ORDER BY a.topic_id DESC';
$results = $db->sql_query_limit($sqls, $convert_real_size);
while ($rows = $db->sql_fetchrow($results))
{
if ($rows)
{
$template->assign_vars(array(
'S_NO_ATT_TO_SHOW' => true)
);
}
if (!file_exists($phpbb_root_path . 'images/last_x_att/' . $rows['physical_filename'] . substr(strtolower($rows['real_filename']), -4)))
{
if (!empty($rows['physical_filename']) && @getimagesize($phpbb_root_path . $config['upload_path'] . '/' . $rows['physical_filename']))
{
$convert_only_size = getimagesize($phpbb_root_path . $config['upload_path'] . '/' . $rows['physical_filename']);
if ($convert_only_size[0] >= $convert_mx_size && $convert_only_size[1] >= $convert_mx_size)
{
if ($width_o_height == 'width')
{
$convert_only_sizing = $convert_only_size[0];
}
else
{
$convert_only_sizing = $convert_only_size[1];
}
if ($convert_only_sizing >= 200 && !function_exists('simpleresize'))
{
include_once($phpbb_root_path . 'includes/thumb_resize.' . $phpEx);
$image = new simpleresize();
$image->load($config['upload_path'] . '/' . $rows['physical_filename']);
if ($width_o_height == 'width')
{
$image->resizeToWidth($convert_mx_size);
}
else
{
$image->resizeToHeight($convert_mx_size);
}
$image->save($phpbb_root_path . 'images/last_x_att/' . $rows['physical_filename'] . substr(strtolower($rows['real_filename']), -4));
}
}
}
}
$template->assign_block_vars('forum_pics', array(
'S_SMALL' => file_exists($phpbb_root_path . 'images/last_x_att/' . $rows['physical_filename'] . substr(strtolower($rows['real_filename']), -4)) ? true : false,
'TOPIC_ID' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $rows['post_msg_id']) . '#p' . $rows['post_msg_id'],
'FILE_NAME' => $rows['real_filename'],
'TOPIC_TIITLE' => censor_text($rows['topic_title']),
'ATTACH_IMG' => $phpbb_root_path . 'images/last_x_att/' . $rows['physical_filename'] . substr(strtolower($rows['real_filename']), -4))
);
}
$db->sql_freeresult($results);
}
?>