Carambar
Elite
Voici un script que j'ai réalisé qui fonctionne grâce à Fetch All (fetch all est à placer dans ./mods dans le répertoire phpBB). Son but est d'afficher le contenu d'un forum sur une page web. En soi, c'est un moyen facile d'ajouter du contenu à son site à partir de phpBB.
Je voudrais votre avis sur ce script et je voudrais aussi savoir s'il y a moyen de le réécrire autrement pour qu'il soit plus optimisé ou plus correcte.
Exploration hierarchique de forums
hierarchyexplore.php
Je voudrais votre avis sur ce script et je voudrais aussi savoir s'il y a moyen de le réécrire autrement pour qu'il soit plus optimisé ou plus correcte.
Exploration hierarchique de forums
hierarchyexplore.php
Code:
<?php
$phpbb_root_path = './';
define ('IN_PHPBB', true);
if (!file_exists($phpbb_root_path . 'extension.inc'))
{
die ('<tt><b>phpBB Fetch All:</b>
$phpbb_root_path is wrong and does not point to your forum.</tt>');
}
//
// phpBB related files
//
include_once ($phpbb_root_path . 'extension.inc');
include_once ($phpbb_root_path . 'common.' . $phpEx);
include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx);
//
// Fetch All related files - we do need all these because the portal is a
// huge example
//
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/posts.' . $phpEx);
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/forums.' . $phpEx);
//
// start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
init_userprefs($userdata);
?>
<html>
<head>
<title>phpBB Fetch All - Hierchical Forum Exploration</title>
</head>
<?php
$listforums = $_GET['listforums'];
?>
<!-- FORUMS -->
<? if(($listforums != null) AND ($_GET['listposts'] == null) AND ($_GET['listcontents'] == null)){
$forums = phpbb_fetch_forums($listforums);
if ($forums) {
$last_cat = -1;
for ($i = 0; $i < count($forums); $i++) {
if ($last_cat != $forums[$i]['cat_id']) {
$last_cat = $forums[$i]['cat_id'];
}
?>
<a href="
<?php $CFG['auth_check'] = false;
echo '?listposts='.$forums[$i]['forum_id'];
$CFG['auth_check'] = true; ?>
"><?php echo $forums[$i]['forum_name']; ?></a><br />
<?
}
}
}
?>
<!-- FORUMS -->
<?php
$listposts = $_GET['listposts'];
?>
<!-- POSTS -->
<?php
if(($listposts > 0) AND ($_GET['listcontents'] == null)){
// fetch postings
$CFG['posts_limit'] = 0;
$CFG['posts_trim_topic_number'] = 0;
$CFG['posts_span_pages'] = false;
$posts = phpbb_fetch_posts($listposts);
for ($i = 0; $i < count($posts); $i++) { ?>
<a href="
<?php $CFG['auth_check'] = false;
echo '?listcontents='.$posts[$i]['topic_id'];
$CFG['auth_check'] = true;?>
"><?php echo $posts[$i]['topic_title']; ?></a><br />
<?
}
} ?>
<!-- POSTS -->
<?php
$listcontents = $_GET['listcontents'];
?>
<!-- POSTCONTENTS -->
<?php if($listcontents > 0){
$topic = phpbb_fetch_topics($listcontents);
$CFG['auth_check'] = false;
echo $topic[0]['post_text'];
$CFG['auth_check'] = true;
$listcontents= null;
}
?>
<!-- POSTCONTENTS -->
<?php
//
// disconnect from the database
//
phpbb_disconnect();
?>
</body>
</html>