VI. Correction du référencement▲
Puisque nous sommes en train de déplacer le contenu d'un site à l'autre, il est bon de penser au suivi des liens déjà référencés. Cela fait toujours mauvaise figure d'avoir un lien mort, surtout lorsqu'on peut y remédier…
VI-A. Lecture d'un forum déplacé▲
Dans le script suivant :
- viewforum.php
Chercher :
Sélectionnez
if ( !($forum_row = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}Remplacer par :
Sélectionnez
if ( !($forum_row = $db->sql_fetchrow($result)) )
{
$sql = 'SELECT site_uri, f.forum_id
FROM ' . ALL_SITES_TABLE . ' s
INNER JOIN ' . ALL_CATEGORIES_TABLE . ' c ON c.site_id = s.site_id
INNER JOIN ' . ALL_FORUMS_TABLE . ' f ON f.cat_id = c.cat_id
WHERE f.forum_id = ' . $forum_id;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain forum information", '', __LINE__, __FILE__, $sql);
}
if( $forum_topic_data = $db->sql_fetchrow($result) )
{
header('HTTP/1.0 301 Moved Permanently');
header('Location: ' . $forum_topic_data['site_uri'] . "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
}
message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}VI-B. Lecture d'un sujet ou d'un message déplacé▲
Dans le script suivant :
- viewtopic.php
Chercher :
Sélectionnez
if ( !($forum_topic_data = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}Remplacer par :
Sélectionnez
if ( !($forum_topic_data = $db->sql_fetchrow($result)) )
{
if($post_id)
{
$sql = 'SELECT site_uri, t.topic_id
FROM ' . ALL_SITES_TABLE . ' s
INNER JOIN ' . ALL_CATEGORIES_TABLE . ' c ON c.site_id = s.site_id
INNER JOIN ' . ALL_FORUMS_TABLE . ' f ON f.cat_id = c.cat_id
INNER JOIN ' . ALL_TOPICS_TABLE . ' t ON t.forum_id = f.forum_id
INNER JOIN ' . ALL_POSTS_TABLE . ' p ON p.topic_id = t.topic_id
WHERE p.post_id = ' . $post_id;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain topic information", '', __LINE__, __FILE__, $sql);
}
if( $forum_topic_data = $db->sql_fetchrow($result) )
{
header('HTTP/1.0 301 Moved Permanently');
header('Location: ' . $forum_topic_data['site_uri'] . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $forum_topic_data['topic_id'] . "#$post_id");
}
}
else
{
$sql = 'SELECT site_uri, t.topic_id
FROM ' . ALL_SITES_TABLE . ' s
INNER JOIN ' . ALL_CATEGORIES_TABLE . ' c ON c.site_id = s.site_id
INNER JOIN ' . ALL_FORUMS_TABLE . ' f ON f.cat_id = c.cat_id
INNER JOIN ' . ALL_TOPICS_TABLE . ' t ON t.forum_id = f.forum_id
WHERE t.topic_id = ' . $topic_id;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain topic information", '', __LINE__, __FILE__, $sql);
}
if( $forum_topic_data = $db->sql_fetchrow($result) )
{
header('HTTP/1.0 301 Moved Permanently');
header('Location: ' . $forum_topic_data['site_uri'] . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
}
}
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}


