Categorys of Forum going nuts!

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Anti-Spam Guide
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
unknown2
Registered User
Posts: 676
Joined: Sat Mar 07, 2009 1:34 pm

Categorys of Forum going nuts!

Post by unknown2 »

Hi there! im here explaining a strange problem that happens to me today!
Im managging my categorys , cause i was adding categorys.
This is how my forum was before
Image


Then, when i enter in the 2nd category with the name GERAL (OFF-TOPIC), this is what happens:
Image


Its strange cause it should not have all that sections before GERAL (OFF-TOPIC)!!
This picture is showing that the GERAL (OFF-TOPIC) category its inside in another category that doesn't exists!!

Can some1 help me out to fix this?
Its ruinning my forum =(
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 51888
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Categorys of Forum going nuts!

Post by stevemaury »

Paste the following into Wordpad and save it as fix.php. Upload it to your board's root folder and then browse to it. Delete it when done. Credit Paul.

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id: index.php,v 1.176 2007/10/05 14:30:06 acydburn Exp $
* @copyright (c) 2005 phpBB Group
* @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);
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');

recalc_btree('forum_id' , FORUMS_TABLE);
echo "Done";

function recalc_btree($sql_id, $sql_table, $module_class = '')
{
    global $db;

    if (!$sql_id || !$sql_table)
    {
        return;
    }

    $sql_where = ($module_class) ? " WHERE module_class = '" . $db->sql_escape($module_class) . "'" : '';

    // Reset to minimum possible left and right id
    $sql = "SELECT MIN(left_id) as min_left_id, MIN(right_id) as min_right_id
        FROM $sql_table
        $sql_where";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);

    $substract = (int) (min($row['min_left_id'], $row['min_right_id']) - 1);

    if ($substract > 0)
    {
        $sql = "UPDATE $sql_table
            SET left_id = left_id - $substract, right_id = right_id - $substract
            $sql_where";
        $db->sql_query($sql);
    }

    $sql = "SELECT $sql_id, parent_id, left_id, right_id
        FROM $sql_table
        $sql_where
        ORDER BY left_id ASC, parent_id ASC, $sql_id ASC";
    $f_result = $db->sql_query($sql);

    while ($item_data = $db->sql_fetchrow($f_result))
    {
        if ($item_data['parent_id'])
        {
            $sql = "SELECT left_id, right_id
                FROM $sql_table
                $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
                    $sql_id = {$item_data['parent_id']}";
            $result = $db->sql_query($sql);

            if (!$row = $db->sql_fetchrow($result))
            {
                $sql = "UPDATE $sql_table SET parent_id = 0 WHERE $sql_id = " . $item_data[$sql_id];
                $db->sql_query($sql);

                continue;    
            }
            $db->sql_freeresult($result);

            $sql = "UPDATE $sql_table
                SET left_id = left_id + 2, right_id = right_id + 2
                $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
                    left_id > {$row['right_id']}";
            $db->sql_query($sql);

            $sql = "UPDATE $sql_table
                SET right_id = right_id + 2
                $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
                    {$row['left_id']} BETWEEN left_id AND right_id";
            $db->sql_query($sql);

            $item_data['left_id'] = $row['right_id'];
            $item_data['right_id'] = $row['right_id'] + 1;
        }
        else
        {
            $sql = "SELECT MAX(right_id) AS right_id
                FROM $sql_table
                $sql_where";
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);

            $item_data['left_id'] = $row['right_id'] + 1;
            $item_data['right_id'] = $row['right_id'] + 2;
        }
    
        $sql = "UPDATE $sql_table
            SET left_id = {$item_data['left_id']}, right_id = {$item_data['right_id']}
            WHERE $sql_id = " . $item_data[$sql_id];
        $db->sql_query($sql);
    }
    $db->sql_freeresult($f_result);
}
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
unknown2
Registered User
Posts: 676
Joined: Sat Mar 07, 2009 1:34 pm

Re: Categorys of Forum going nuts!

Post by unknown2 »

Tks for your help!!
It helped me out to solve the major issues. But i still have some problems :S
I created a category (Section 3= , where i move all the topics who where not in its place. but this category isnt showing in the ACP =S Image

Another thing its the message count of the first category (Bem-Vindo ao Forum Discutivel).
In this category i have a section (Desenvolvimentos, Ajuda e Sugestões) who is saying it has 76 topics and 358 messages. But the reallity its that i already move all the topics from there to section 3, but that count stills the same :/

I was becomiing frustrated, and your help was very usefull! I aprecciate it very much!
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 51888
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Categorys of Forum going nuts!

Post by stevemaury »

Resynch all the forums ( the orange circular double arrow icon).
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
unknown2
Registered User
Posts: 676
Joined: Sat Mar 07, 2009 1:34 pm

Re: Categorys of Forum going nuts!

Post by unknown2 »

I did that, but the problem remains.. :|
As you can see in thissection there are few posts, but in the index it shows 38 Topics, and 185 messages!

Maybe in this section are some lost topics that i cant find at the moment. Before the BUG who make the sections goes nuts, this section was with topics, but now its empty :((

Maybe are this topics that are hidding somwhere in the section who is showing many posts =\
How can i solve this?

PS: The fix.php that you have sended to me, can be used at any time in other foruns, or you coded that just for fixing that issue on my forum ?
Best regards
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 51888
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Categorys of Forum going nuts!

Post by stevemaury »

It can be used anytime.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
unknown2
Registered User
Posts: 676
Joined: Sat Mar 07, 2009 1:34 pm

Re: Categorys of Forum going nuts!

Post by unknown2 »

ok then! tks for your help.
i will open a new topic mentioning the number of topics / messages

Best regards
Thanks in advance
Registered User
Posts: 173
Joined: Mon Dec 28, 2009 8:17 am

Re: Categorys of Forum going nuts!

Post by Thanks in advance »

Can this script stevemaury posted still be used with phpBB3.0.8 / phpBB3.0.9?
User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: Categorys of Forum going nuts!

Post by Oyabun1 »

I'm pretty sure the Fix Left/Right ID's tool in the Support Toolkit now does the same thing.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests
Locked

Return to “[3.0.x] Support Forum”