Suite à ce tutoriel de spitfire pat: documentation/coding/utiliser-les-sessions-de-phpbb3-a174-view.html (Bravo à lui au passage) ce sujet sera dédié à l'utilisation des sessions dans phpBB3, comme l'était l'ancien sujet pour phpBB2.
Bonne journée

Modérateur: Equipe
$template->set_filenames(array('body' => 'news_body.html'));
$template->set_filenames(array('body' => 'template_bodysite2142.html'));
<?php define('IN_PHPBB', true); $phpbb_root_path = './phpBB3/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); $user->session_begin(); $auth->acl($user->data); $user->setup(); $forum_id = request_var('forum_id', 0); $where = ($forum_id) ? "WHERE forum_id=$forum_id" : ''; $sql = 'SELECT forum_id,topic_id, topic_time, topic_title, topic_views, topic_replies, topic_poster, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_time FROM ' . TOPICS_TABLE . ' ORDER BY topic_time DESC ' . $where . ' LIMIT 0 , 10 '; $result = $db->sql_query($sql); $template->set_filenames(array('body' => 'news_body.html')); $template->assign_vars(array( 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), )); while($row = $db->sql_fetchrow($result)) { $topic_id = $row['topic_id']; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&t=' . $topic_id); $template->assign_block_vars('topicrow', array( 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_AUTHOR' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'REPLIES' => $row['topic_replies'], 'TOPIC_AUTHOR' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_TITLE' => censor_text($row['topic_title']), 'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'], 'U_VIEW_TOPIC' => $view_topic_url, 'VIEWS' => $row['topic_views'], )); } $template->display('body'); ?>
cloud a écrit:mais je ne suis pas obligé de me connecter pour avoir accés a la page index2.php .
comment la sécuriser pour forcer les gens a se connecter.
if($user->data['user_id'] == ANONYMOUS) { exit(); }
de quelle ID parles-tu ?mickaelteam a écrit:J'ai mis (ou cru mettre) l'ID des news voulu, mais ça ne fonctionne pas.
spitfire pat a écrit:de quelle ID parles-tu ?mickaelteam a écrit:J'ai mis (ou cru mettre) l'ID des news voulu, mais ça ne fonctionne pas.
est-ce que forum et site sont sur le même nom de domaine ? je pense qu'il doit s'agir d'un problème de cookiesnikobskure a écrit:les connexions sur le forum phpbb3 se déroulent sans problème, un user connecté peut parcourir le forum tranquillement, accéder aux parties reservées aux membres.
Par contre impossible côté site de retrouver les sessions.
mickaelteam a écrit:Je parle de l'ID d'un forum ou sont mes news... à intégrer sur une autre page vierge... Je dois donc sélectionner un ID
$forum_id = request_var('forum_id', 0);
$forum_id = 10;
spitfire pat a écrit:est-ce que forum et site sont sur le même nom de domaine ? je pense qu'il doit s'agir d'un problème de cookiesnikobskure a écrit:les connexions sur le forum phpbb3 se déroulent sans problème, un user connecté peut parcourir le forum tranquillement, accéder aux parties reservées aux membres.
Par contre impossible côté site de retrouver les sessions.
tu n'as aucun message d'erreur quand tu testes le script ?
$phpbb_root_path = '../forum/';
spitfire pat a écrit:mickaelteam a écrit:Je parle de l'ID d'un forum ou sont mes news... à intégrer sur une autre page vierge... Je dois donc sélectionner un ID
en supposant que l'id de ton forum de news soit 10, alors soit tu appelles le script par news.php?forum_id=10, soit tu remplacespar
- Code: Tout sélectionner
$forum_id = request_var('forum_id', 0);
- Code: Tout sélectionner
$forum_id = 10;
non, ça n'est pas clair du toutmickaelteam a écrit:J'espère avoir été un peu clair![]()
$forum_id = 105;
spitfire pat a écrit:non, ça n'est pas clair du toutmickaelteam a écrit:J'espère avoir été un peu clair![]()
je vois que, sur ton forum, le forum "news-info" a pour id 105
si tu mets dans le script teamplatesite.phpet que le reste de ton script ainsi que teamplate_bodysite.html contiennent le code indiqué pour la version templatée, pas de lézard, ça devrait marcher
- Code: Tout sélectionner
$forum_id = 105;
<?php /** * * @package phpBB3 * @version $Id: template.php Raimon $ * @copyright (c) 2008 Raimon ( http://www.phpBBservice.nl ) * @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); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup('mods/template'); // Output page page_header($user->lang['TEMPLATE']); $template->set_filenames(array( 'body' => 'template_bodysite2142.html') ); page_footer(); ?> <?php define('IN_PHPBB', true); $phpbb_root_path = './phpBB3/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); $user->session_begin(); $auth->acl($user->data); $user->setup(); $forum_id = 105; $where = ($forum_id) ? "WHERE forum_id=$forum_id" : ''; $sql = 'SELECT forum_id,topic_id, topic_time, topic_title, topic_views, topic_replies, topic_poster, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_time FROM ' . TOPICS_TABLE . ' ORDER BY topic_time DESC ' . $where . ' LIMIT 0 , 10 '; $result = $db->sql_query($sql); $template->set_filenames(array('body' => 'template_bodysite2142.html')); $template->assign_vars(array( 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), )); while($row = $db->sql_fetchrow($result)) { $topic_id = $row['topic_id']; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&t=' . $topic_id); $template->assign_block_vars('topicrow', array( 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_AUTHOR' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'REPLIES' => $row['topic_replies'], 'TOPIC_AUTHOR' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_TITLE' => censor_text($row['topic_title']), 'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'], 'U_VIEW_TOPIC' => $view_topic_url, 'VIEWS' => $row['topic_views'], )); } $template->display('body'); ?>
<!-- INCLUDE overall_header.html --> <head> </head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <p align="center"> <br> <img src=http://www.mtlive.eu/images/bvsite2142.png> <br> <br> <br> <img name="menusite" src="http://www.mtlive.eu/images/menusite.png" width="900" height="400" border="0" id="menusite" usemap="#m_menusite" alt="" /><map name="m_menusite" id="m_menusite"> <area shape="rect" coords="428, 340, 483, 359" href="http://www.mtlive.eu/donation" target="_blank" alt="" /> <area shape="rect" coords="331, 341, 418, 359" href="http://www.mtlive.eu/forum/viewforum.php?f=100" alt="" /> <area shape="rect" coords="688, 237, 769, 255" href="http://www.mtlive.eu/forum/template.php" alt="" /> <area shape="rect" coords="392, 237, 534, 256" href="http://www.mtlive.eu/forum/template2.php" alt="" /> <area shape="rect" coords="544, 238, 621, 255" href="http://www.mtlive.eu/forum/template4.php" alt="" > <area shape="rect" coords="634, 237, 677, 254" href="http://www.mtlive.eu/forum/viewtopic.php?f=106&t=216" alt="" > <area shape="rect" coords="63, 241, 122, 258" href="http://www.mtlive.eu/forum/viewtopic.php?f=100&t=223" alt="" /> <area shape="rect" coords="136,244,260,256" href="http://www.mtlive.eu/forum/viewtopic.php?f=100&t=303" alt="" /> <area shape="rect" coords="18, 241, 53, 257" href="http://www.mtlive.eu/forum/viewtopic.php?f=100&t=190" alt="" /> <area shape="rect" coords="221, 341, 320, 358" href="http://www.mtlive.eu/forum/ucp.php?i=167" alt="" /> <area shape="rect" coords="283, 151, 404, 168" href="http://www.mtlive.eu/forum/ucp.php?i=167" alt="" /> <area shape="rect" coords="237, 150, 273, 167" href="http://www.mtlive.eu/forum/viewtopic.php?f=100&t=185" alt="" /> <area shape="rect" coords="715, 79, 884, 96" href="http://www.mtlive.eu/forum/viewforum.php?f=99" alt="" /> <area shape="rect" coords="415, 151, 656, 167" href="http://www.mtlive.eu/forum/viewforum.php?f=112" alt="" /> <area shape="rect" coords="545, 79, 704, 96" href="http://www.mtlive.eu/forum/viewforum.php?f=112" alt="" /> <area shape="rect" coords="497, 80, 537, 95" href="http://www.mtlive.eu/forum/viewtopic.php?f=100&t=184" alt="" /> <area shape="rect" coords="120, 59, 202, 75" href="ucp.php?mode=login" alt="" /> <area shape="rect" coords="24, 62, 108, 75" href="ucp.php?mode=register" target="Aucun" alt="" /> </map> <a href="http://www.mtlive.eu/forum/index.php"> <img src=http://www.mtlive.eu/images/accesforummtlive.png border="0"></a> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <title>NEWS</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <style type="text/css"> th{ background-color: #0066FF; color: #FFFF99; } </style> </head> <body> <table width="100%"> <tr> <th >{L_TOPICS}</th> <th>{L_REPLIES}</th> <th>{L_VIEWS}</th> <th>{L_LAST_POST}</th> </tr> <!-- BEGIN topicrow --> <tr bgcolor="<!-- IF topicrow.S_ROW_COUNT is even -->#FFFFCC<!-- ELSE -->#99FFFF<!-- ENDIF -->"> <td> <a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a><br /> {L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR} {L_POSTED_ON_DATE} {topicrow.FIRST_POST_TIME} </td> <td>{topicrow.REPLIES}</td> <td>{topicrow.VIEWS}</td> <td> {L_POST_BY_AUTHOR} {topicrow.LAST_POST_AUTHOR} <a href="{topicrow.U_LAST_POST}">{LAST_POST_IMG}</a> <br />{L_POSTED_ON_DATE} {topicrow.LAST_POST_TIME} </td> </tr> <!-- END topicrow --> </table> </body> </html> </p><!-- INCLUDE overall_footer.html -->
page_footer();
?> <?php define('IN_PHPBB', true); $phpbb_root_path = './phpBB3/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); $user->session_begin(); $auth->acl($user->data); $user->setup();
$forum_id = 105; $where = ($forum_id) ? "WHERE forum_id=$forum_id" : ''; $sql = 'SELECT forum_id,topic_id, topic_time, topic_title, topic_views, topic_replies, topic_poster, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_time FROM ' . TOPICS_TABLE . ' ORDER BY topic_time DESC ' . $where . ' LIMIT 0 , 10 '; $result = $db->sql_query($sql); $template->set_filenames(array('body' => 'template_bodysite2142.html')); $template->assign_vars(array( 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), )); while($row = $db->sql_fetchrow($result)) { $topic_id = $row['topic_id']; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&t=' . $topic_id); $template->assign_block_vars('topicrow', array( 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_AUTHOR' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'REPLIES' => $row['topic_replies'], 'TOPIC_AUTHOR' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_TITLE' => censor_text($row['topic_title']), 'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'], 'U_VIEW_TOPIC' => $view_topic_url, 'VIEWS' => $row['topic_views'], )); }
page_footer();
$template->set_filenames(array('body' => 'template_bodysite2142.html'));
$template->display('body');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <title>NEWS</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <style type="text/css"> th{ background-color: #0066FF; color: #FFFF99; } </style> </head>
Retourner vers Coding, Webmastering et Sécurité informatique
Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 2 invités