'Return to Index' link if no forum/topic/post exits

Adds a link to return to the index page to the trigger_error when no forum/topic/post exists

Slightly modified request by acemi in this topic, this snippet gives you a link to return to the index if you come across a forum/topic/post that doesn't exist - which could happen for many reasons

#
#-----[ OPEN ]------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------
#
    if (!$forum_id)
    {
        trigger_error('NO_FORUM');
    } 
#
#-----[ REPLACE WITH ]------------------------------------------
#
    if (!$forum_id)
    {
        // trigger_error('NO_FORUM'); - commented out in case you need to add it back later
        $user->setup();    
        $redirect_url = append_sid("{$phpbb_root_path}index.$phpEx");
        $message = $user->lang['NO_FORUM'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>');
        trigger_error($message);
    } 
#
#-----[ FIND ]------------------------------------------
#
    if (!$forum_data)
    {
        trigger_error('NO_FORUM');
    } 
#
#-----[ REPLACE WITH ]------------------------------------------
#
    if (!$forum_id)
    {
        // trigger_error('NO_FORUM'); - commented out in case you need to add it back later
        $user->setup();    
        $redirect_url = append_sid("{$phpbb_root_path}index.$phpEx");
        $message = $user->lang['NO_FORUM'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>');
        trigger_error($message);
    } 
#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
    // Do we have a topic or post id?
    if (!$topic_id && !$post_id)
    {
        trigger_error('NO_TOPIC');
    } 
#
#-----[ REPLACE WITH ]------------------------------------------
#
    // Do we have a topic or post id?
    if (!$topic_id && !$post_id)
    {
        //trigger_error('NO_TOPIC'); - commented out in case you need to add it back later
        $user->setup();
        $redirect_url = append_sid("{$phpbb_root_path}index.$phpEx");
        $message = $user->lang['NO_TOPIC'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>');
        trigger_error($message);
    } 
#
#-----[ FIND ]------------------------------------------
#
        // If post_id was submitted, we try at least to display the topic as a last resort...
#
#-----[ FIND ]------------------------------------------
#
        trigger_error('NO_TOPIC'); 

Double find to make sure we get the correct code

#
#-----[ FIND ]------------------------------------------
#
        //trigger_error('NO_TOPIC'); - commented out in case you need to add it back later
        $user->setup();
        $redirect_url = append_sid("{$phpbb_root_path}index.$phpEx");
        $message = $user->lang['NO_TOPIC'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>');
        trigger_error($message); 

If you would like to add an automatic refresh to that, so that after say 3 seconds i jumps to the index page, then add this code before the trigger_error()

        meta_refresh(3, $redirect_url); 

For example:

        meta_refresh(3, $redirect_url);
        trigger_error($message);