Previous Thread
Next Thread
Print Thread
Rating: 5
Joined: Oct 2004
Posts: 2
Lurker
Lurker
Offline
Joined: Oct 2004
Posts: 2
Mod Name / Version: Repairing damaged threads

Description: This script check correspondence of fields `B_Main`, `B_Parent`, `B_Board`, `B_Status` of answer posts to values of root post of the thread. I am using this script via cron every hour.

Working Under: UBB.Threads

Mod Status: Finished

Any pre-requisites:

Author(s): autoua elia

Date: 10/15/04

Credits:

Files Altered: none

New Files: #! /usr/bin/php
<?

// Require the threadss library
require ("../includes/main.inc.php");

//Selecting starting number of records for correcting
$counterquery = "SELECT count(m1.B_Number) FROM {$config['tbprefix']}Posts m1, {$config['tbprefix']}Posts m2
WHERE m2.B_Number = m1.B_Parent
AND m1.B_Parent > 0
AND (m1.B_Board != m2.B_Board or m1.B_Main != m2.B_Main or m1.B_Status != m2.B_Status)
";

$query = $counterquery;
$sth = $dbh -> do_query($query);

list($errcounter) = $dbh -> fetch_array($sth);

// step-by-step correcting errors in three
while ($errcounter > 0)
{

$query = "SELECT m1.B_Number, m2.B_Main, m2.B_Board, m2.B_Status FROM {$config['tbprefix']}Posts m1, {$config['tbprefix']}Posts m2
WHERE m2.B_Number = m1.B_Parent
AND m1.B_Parent > 0
AND (m1.B_Board != m2.B_Board or m1.B_Main != m2.B_Main or m1.B_Status != m2.B_Status)
";

$sth =
$dbh -> do_query($query);

while (list($B_Number1, $B_Main1, $B_Board1, $B_Status1) = $dbh -> fetch_array($sth) )
{

$B_Number_q = addslashes($B_Number1);
$B_Main_q = addslashes($B_Main1);
$B_Board_q = addslashes($B_Board1);
$B_Status_q = addslashes($B_Status1);

$query = "UPDATE {$config['tbprefix']}Posts SET B_Topic = 0, B_Main = '$B_Main_q', B_Board = '$B_Board_q', B_Status = '$B_Status_q'
WHERE B_Number = '$B_Number_q'
";

$dbh -> do_query($query);
}


$query = $counterquery;
$sth =
$dbh -> do_query($query);
list($errcounter) = $dbh -> fetch_array($sth);


}

$dbh -> finish_sth($sth);

?>

Database Altered: no

Info/Instructions: In forums with the big activity we usually have such problem:
- moderator has moved a topic in another forum, but somebody from users has already opened reply window and his post will be placed in forum on old location (value of field `B_Board` for this post will be different from analogous field of root post)
- moderator had closed the tread, but someone user already have opened answer window. And his post will be not "closed", because value of field B_Status will not be "C". So other users have pocibility to continue discussion in closed thread.
- Topic had been split, subtopic was moved to separate topic, however some of "her" posts has old value of fields `B_Main` or `B_Parent`.

Disclaimer: Please backup every file that you intend to modify.
If the modification modifies the database, it's a good idea to backup your database before doing so.

Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.

Sponsored Links
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
Thanks for sharing


- Allen wavey
- What Drives You?
Joined: Oct 2004
Posts: 2
Lurker
Lurker
Offline
Joined: Oct 2004
Posts: 2
Any time

Constantly I see the problems happen from logic problems of the current UBBT realisation and limitation MySQL (especially absence of triggers).
For example, these scripts resolve problems with value of fields B_Board, B_Main, B_Status and so on.
On Oracle, Interbase etc. I prefer to fill these fields by trigger "BeforeInsert" or "AfterInsert" according to values of equal fields of parent post - this variant is fully "automatic" and don`t add big advantage on server or client. You may realise in addpost.php checking current values of this fields in parent post before recording in table answer post...

So I am trying to correct hot problems with available for me tools.

PS
Sorry for my terrible English

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Thx for sharing.

Joined: Jan 2003
Posts: 263
Member
Member
Joined: Jan 2003
Posts: 263
Thanks a lot for this mod! Super

Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,575
Posts293,932
Members13,824
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,835
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)