I created a page in PHP to export the latest posts and I'm using it as an iframe on the board3 portal. I would like to know how I can do this in an integrated way, through a module. Because I don't know much about development. And I would like if someone could help me with this.I can't program the module, I wanted it in a module so I wouldn't use it as an iframe.
Code:
<?php// Configuração do phpBBdefine('IN_PHPBB', true);$phpbb_root_path = __DIR__ . '/../'; // Adjustment to access phpBB from a separate folder$phpEx = substr(strrchr(__FILE__, '.'), 1);include($phpbb_root_path . 'common.' . $phpEx);include($phpbb_root_path . 'includes/functions_display.' . $phpEx);// Inicializa o phpBB$user->session_begin();$auth->acl($user->data);$user->setup();// Consulta os últimos 15 tópicos visíveis para o usuário$sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, t.topic_time, t.topic_last_post_id, t.topic_poster, f.forum_name, u.username, u.user_id FROM ' . TOPICS_TABLE . ' t JOIN ' . FORUMS_TABLE . ' f ON t.forum_id = f.forum_id JOIN ' . USERS_TABLE . ' u ON t.topic_poster = u.user_id WHERE t.topic_visibility = 1 ORDER BY t.topic_time DESC LIMIT 15';$result = $db->sql_query($sql);$topics = [];while ($row = $db->sql_fetchrow($result)) { if ($auth->acl_get('f_read', $row['forum_id'])) { $topics[] = $row; }}$db->sql_freeresult($result);// Função para calcular tempo decorrido ou exibir a datafunction time_elapsed_string($datetime) { $now = new DateTime(); $ago = new DateTime('@' . $datetime); $diff = $now->diff($ago); $days = $diff->days; if ($days >= 1) { return date('d/m/Y H:i', $datetime); } $string = [ 'hora' => $diff->h, 'minuto' => $diff->i, 'segundo' => $diff->s, ]; foreach ($string as $key => &$value) { if ($value) { return $value . ' ' . $key . ($value > 1 ? 's' : '') . ' atrás'; } } return 'agora';}// Saída HTML para o iframeheader('Content-Type: text/html; charset=UTF-8');?><!DOCTYPE html><html lang="pt-BR"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="../styles/zeina/theme/assets/css/stylesheet.css?assets_version=250" rel="stylesheet" media="screen"> <style> body { font-family: Arial, sans-serif; font-size: 14px; margin: 10px; } ul { list-style: none; padding: 0; } li { margin-bottom: 10px; } a { text-decoration: none; color: #0073e6; } a:hover { text-decoration: underline; } </style></head><body> <ul> <?php foreach ($topics as $topic): ?> <li> <a class="font-semibold" href="../viewtopic.php?p=<?= $topic['topic_last_post_id'] ?>#p<?= $topic['topic_last_post_id'] ?>" target="_blank"> <?= htmlspecialchars($topic['topic_title']) ?> </a> <br> <small> By <a class="font-semibold" href="../memberlist.php?mode=viewprofile&u=<?= $topic['user_id'] ?>" target="_blank"> <?= htmlspecialchars($topic['username']) ?> </a> in <?= time_elapsed_string($topic['topic_time']) ?> </small> </li> <?php endforeach; ?> </ul></body></html>
Statistics: Posted by henrique.seven2011 — Sat Feb 08, 2025 9:17 pm