Help: show latest 6 images of post

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
User avatar
salvocortesiano
Registered User
Posts: 277
Joined: Mon Mar 22, 2010 1:49 pm
Location: Florence (Italy)
Name: Salvo Cortesiano

Help: show latest 6 images of post

Post by salvocortesiano »

Greetings,
as the title suggests, I would like to create a scroll marquee of images to be shown in the forum index. This old code works with a php 5.6 version but doesn't seem to work with the new 8.2 version.

Code: Select all

<?php
/**
* @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');


if (!defined('IN_PHPBB'))
{
   exit;
}

global $output, $output0, $output1, $output2, $output3;

if ($user->data['is_registered'])
{

// Latest 6 e-Books
$sql = 'SELECT min(p.post_id) as post_id, p.topic_id, topic_title, topic_first_poster_name, topic_views, topic_time, p.forum_id, p.post_text
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
WHERE p.forum_id LIKE "12"
AND post_id = topic_first_post_id
AND (post_text LIKE "%[img:%]%JPG[/img:%]%"
OR post_text LIKE "%[img:%]%jpg[/img:%]%"
OR post_text LIKE "%[img:%]%PNG[/img:%]%"
OR post_text LIKE "%[img:%]%png[/img:%]%"
OR post_text LIKE "%[img:%]%GIF[/img:%]%"
OR post_text LIKE "%[img:%]%gif[/img:%]%")
GROUP BY topic_id ORDER BY p.post_time DESC LIMIT 6
';

$result = $db->sql_query($sql);

while($row = $db->sql_fetchrow($result))
{
	foreach($row as $cell)
	$matches = null;
	$returnValue = preg_match('/\[img:(.*?)\](.*?)\[\/img:(.*?)\]/', $cell , $matches, 0);
	$post_link = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx . '?f=12&t=' . $row['topic_id']);
	$user_post = 'Postato da: ' . iconv('UTF-8', 'UTF-8', $row['topic_first_poster_name']);
	$visite = 'Visitato da: ' . $row['topic_views'] . ' utenti';
	$the_date = 'In data: ' .  date('g:i A on D, M j Y', $row['topic_time']);
	$title = iconv('UTF-8', 'UTF-8', $row['topic_title']);

	if ($matches[2] == "")
	{
		$no_image = "{$phpbb_root_path}images/no-image.png";
		$output .= '<a href="' . $post_link . '" title="'. substr($title, 0, 60) .'"><img src="' . $no_image . '" width="100" height="140" title="' . substr($title, 0, 60) . '&#013;' . $user_post . '&#013;' . $visite . '&#013;' . $the_date . '" alt="' . substr($title, 0, 60) . '"></a>';
	}else{
		$output .= '<a href="' . $post_link . '" title="'. substr($title, 0, 60) .'"><img src="' . $matches[2] . '" width="100" height="140" title="' . substr($title, 0, 60) . '&#013;' . $user_post . '&#013;' . $visite . '&#013;' . $the_date . '" alt="' . substr($title, 0, 60) . '"></a>';
	}
}
}else{
	echo 'NOT REGISTERED USER!!';
}

echo $output;

?>
Can someone help me? It could be a starting point for an extension :)
Best Regards

Salvo
Last edited by Mick on Mon Jun 17, 2024 10:22 am, edited 1 time in total.
Reason: Solved.
deninho32
Registered User
Posts: 238
Joined: Tue May 21, 2019 8:57 am

Re: Help: show latest 6 images of post

Post by deninho32 »

Maybe this extension can put you on the right track.

https://www.dmzx-web.net/viewtopic.php?t=4870
phpBB 3.3.7 | PHP Version 7.4.33 | Milk Theme
User avatar
salvocortesiano
Registered User
Posts: 277
Joined: Mon Mar 22, 2010 1:49 pm
Location: Florence (Italy)
Name: Salvo Cortesiano

Re: Help: show latest 6 images of post

Post by salvocortesiano »

deninho32 wrote: Sun Jun 16, 2024 7:53 pm Maybe this extension can put you on the right track.

https://www.dmzx-web.net/viewtopic.php?t=4870
:o thank you very much!
Regards Salvo :P
The best way to predict the future is to invent it!
Image

Return to “phpBB Custom Coding”