Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
#219761 06/25/2002 12:03 AM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
I think this is ready for prime time. Allen has put this through the hoops here at threadsdev and after some heavy stomping I think we got the bugs out. <img src="/threads/php/images/icons/wink.gif" alt="" />

This modification will display who made the last post in a thread that links to the related last post (simular to a .classic modification). This information will be displayed in the "last post" column of the postlist.php script. Also note that this was made to work with MySQL database only.


The following files will need to be modified:
__ postlist.php __________ (threads directory)
__ postlist.tmpl _________ (threads directory)
__ addpost.php ___________ (threads directory)
__ doapproveposts.php ____ (admin directory)
__ viewunapproved.php ____ (admin directory)
__ deletepost.php ________ (threads directory)

This modification will require 3 additional fields to be added to your w3t_Posts table in your database. An "alter table" script is included to make these additions for you.

The file is attached. Enjoy! <img src="/threads/php/images/icons/smile.gif" alt="" />
Attachments
51077-lastpostby.6.1.zip (0 Bytes, 61 downloads)

Sponsored Links
Joined: Mar 2002
Posts: 305
Enthusiast
Enthusiast
Offline
Joined: Mar 2002
Posts: 305
Thanks Dave!

In step 2 you say to find this:
code:
if (!$ThreadRating) { $ThreadRating = " "; }

// Setup the postrow array



and your hack to show the word "sticky" on sticky notes begins below that first line. Should the sticky code remain below the first line, and before the rest of this hack, or go elsewhere?


[:"red"]Lisa[/]
JacquiL #219763 06/25/2002 1:23 AM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
Hi Lisa

You can leave the "sticky post" code where it is and add this new code right below it and everything should work.

Let me know if it doesn't so I can loose some sleep over it... lol

Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
There are some cases where the "last post by" information isn't being updated when a reply is deleted. Below is what I believe is the fix. Let me know otherwise..

In the instructions change this:

code:

Step 7.
In your deletepost.php script find this:


// ------------------------------------------------------------
// We also need to decrease the number of replies in this topic
$query = "
UPDATE w3t_Posts
SET B_Replies = B_Replies -1
WHERE B_Number = '$Main'
";
$dbh -> do_query($query);


and change it to this:


$query = "
SELECT B_Number,B_Username,B_Approved
FROM w3t_Posts
WHERE B_Board = '$Board_q'
AND B_Approved = 'yes'
AND B_Main = '$Main'
AND B_Main <> B_Number
ORDER BY B_Number DESC
LIMIT 1
";
$lastPost = $dbh -> do_query($query);
list($lastNumber,$lastName,$lastApproved) = $dbh -> fetch_array($lastPost);
$lastName = addslashes($lastName);

// ------------------------------------------------------------
// We also need to decrease the number of replies in this topic
$query = "
UPDATE w3t_Posts
SET B_Replies = B_Replies -1,
B_Last_Number = '$lastNumber',
B_Last_Name = '$lastName',
B_Last_Approved = '$lastApproved'
WHERE B_Number = '$Main'
";
$dbh -> do_query($query);




to this:

code:

Step 7.
In your deletepost.php script find this:


// ------------------------------------------------------------
// We also need to decrease the number of replies in this topic
$query = "
UPDATE w3t_Posts
SET B_Replies = B_Replies -1
WHERE B_Number = '$Main'
";
$dbh -> do_query($query);


and change it to this:


$query = "
SELECT B_Main,B_Number,B_Username,B_Approved
FROM w3t_Posts
WHERE B_Board = '$Board_q'
AND B_Approved = 'yes'
AND B_Main = '$Main'
ORDER BY B_Number DESC
LIMIT 1
";
$lastPost = $dbh -> do_query($query);
list($lastMain,$lastNumber,$lastName,$lastApproved) = $dbh -> fetch_array($lastPost);
$lastName = addslashes($lastName);
if ($lastMain == $lastNumber) {
// It's the main post therefore no replies left, right?
$lastNumber = "";
$lastName = "";
$lastApproved = "";
}

// ------------------------------------------------------------
// We also need to decrease the number of replies in this topic
$query = "
UPDATE w3t_Posts
SET B_Replies = B_Replies -1,
B_Last_Number = '$lastNumber',
B_Last_Name = '$lastName',
B_Last_Approved = '$lastApproved'
WHERE B_Number = '$Main'
";
$dbh -> do_query($query);




This may or may not be the cure but it is fixing a flaw in the code none the less.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Is it me?

Or is there no change in step 6?

code:

Step 6.
In your viewunapproved.php script find this:


// ----------------------------------------
// Grab the unapproved posts for this board
$Keyword_q = addslashes($Keyword);
$query = "
SELECT B_Number,B_Subject,B_Username,B_Posted
FROM {$config['tbprefix']}Posts
WHERE B_Approved = 'no'
AND B_Board = '$Keyword_q'
ORDER BY B_Posted DESC
";


and change it to this:


// ----------------------------------------
// Grab the unapproved posts for this board
$Keyword_q = addslashes($Keyword);
$query = "
SELECT B_Number,B_Subject,B_Username,B_Posted
FROM {$config['tbprefix']}Posts
WHERE B_Approved = 'no'
AND B_Board = '$Keyword_q'
ORDER BY B_Number DESC
";


Sponsored Links
Daine #219766 09/11/2002 6:03 AM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
It seems that the ORDER BY is changed from B_Posted to B_Number.

c0bra #219767 09/11/2002 9:54 AM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369


I need some sleep.


Thx.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Hmmmm....

I may need more sleep.

I've been setting this up on a test board, on 6.1

I don't know if I missed a step, but sometimes the last post link is wrong.

If this is the link:

/showflat.php?Cat=&Board=test&Number=56454&page=0&view=collapsed&sb=5&o=&fpart=1#Post56454

Sometimes it's like this:

/showflat.php?Cat=&Board=test&Number=56454&page=0&view=collapsed&sb=5&o=&fpart=2#Post56454

Note the part=2 instead of 1... if I change the link it works fine.

I thought it might be my quick reply mod... but no, I can't seem to find any consistency...

I've updated for 6.1 with 'theprefix' variables... but something isn't quite right.


Dave,
Any idea if this bit of code needs to be tweaked for 6.1???

Thx.

Daine #219769 09/12/2002 6:30 AM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
I'll have a look before lunch.

Daine #219770 09/12/2002 10:39 AM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
I'll have to set this up somewhere so I can test it. I can't seem to see what may be going wrong. It's been working fine on 6.0.x hasnt it?

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
I had never used it.

But I've also got the quick reply mod. But quick reply still uses addpost.php so that shouldn't have any effect.
Did some testing here last night and all seemed fine with it.

It was pretty simple to install.. and the problem would be with postlist if anything... based on what's happening.

Of course I've got a few other mods. Maybe I need to set this up on a clean 6.1 and see if I have the same trouble.

Daine #219772 09/12/2002 1:45 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Hey Dave,
Before you go to any trouble... let me ask you this:

Is the part= calculated in postlist.php? It's not pulled from the database is it? I don't really understand what this is or means.

In other words... if it's calculated in postlist.php, then my other scripts should be fine... and I should start with a Clean postlist.php and add things back in to see if it behaves.

Daine #219773 09/12/2002 2:22 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
fpart is calculated and not pulled from any database.

It is the page the post is on. If you look at a post link with more than one page of replies you can mouse over the number links and see that fpart changes according to the page. 6.1's postlist may be calculating this at some other point but I can't say for sure.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Thanks.

I just figured this out.

The link wasn't working for the First Post (with a last post link) at the top of postlist because I had a sticky post with no "last post" info above it. once I either unstuck it... or did a reply to the sticky, then all seemed to work.
I guess it didn't like having a post in front of it without the last post data.

Either way... this hiccup would work itself out as the data is populated when people make replies.

Thanks for your help.
I will post tweaked instructions for use with .threads 6.1 shortly.

Daine #219775 09/12/2002 4:08 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
Ok sounds good.

Yeah there will be no "last post by" information till someone actually makes a reply to the main post.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Right... and it doesn't like one without the info begin above one with the info. Just went live with it and it all seems to work. I replied to all my sticky posts to avoid the issue.

Thanks!

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Attached to this post is a version and instructions to use this hack with .threads 6.1.

There were a few minor changes. The Database 'theprefix' variable...and postlist called a few more things to use the disk icon etc...
So I've adjusted the instructions and added the prefix to the altertable file and all seems to be working well on my 6.1 br1 site.

Attachments
56505-lastpostbyfor6.1 folder.zip (0 Bytes, 39 downloads)

Daine #219778 09/12/2002 4:57 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
Thanks Josh

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
I should have reiterated Loudly...
That I take no credit for such a creation other than a few very simple tweaks for ver 6.1.

It's All JustDave's wonderful work.

I shall do the menial tweaking while you create more cool stuff like IIP.

Daine #219780 09/14/2002 2:49 AM
Joined: Jun 2002
Posts: 375
Enthusiast
Enthusiast
Offline
Joined: Jun 2002
Posts: 375
Which hack is it that inserts the last post by info on the ubbthreads.php page? The Forum Index, like this site has.

neuron #219781 09/15/2002 10:17 AM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
I think it's part of the templates or something like that. Allen would know though. I don't much care for the increased queries it creates though.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Ok -

This hack worked fine on the beta releases of 6.1... but there was some bug fixing to the last post date and time for sticky threads.

There is a bug in 6.1 final release of .threads. If you reply to a sticky thread... the parent post in the thread takes on the date and time of the latest thread.

Somehow, a combo of that bug and this hack.... makes every reply in the sticky thread take on the date and time of the latest reply.

So I'd wait to install this hack on 6.1 final until Rick posts a fix for the last post time/date problem with sticky threads.... then hopefully we can tweak this accordingly.


Daine #219783 09/24/2002 7:44 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
To fix the wrong time being set on the sticky post, in your addpost.php script find this:


code:

// -------------------------------------------------------
// Otherwise just update the reply total if it is approved
elseif ( ($Main) && ($Sticky) && ($Approved == "yes") ) {
$query = "
UPDATE {$config['tbprefix']}Posts
SET B_Replies = B_Replies + 1,
B_Sticky = '$date'
WHERE B_Number = '$Main'
AND B_Board = '$Board_q'
";
$dbh -> do_query($query);
}




and replace it with this:

code:

// -------------------------------------------------------
// Otherwise just update the reply total if it is approved
elseif ( ($Main) && ($Sticky) && ($Approved == "yes") ) {
$query = "
UPDATE {$config['tbprefix']}Posts
SET B_Replies = B_Replies + 1,
WHERE B_Number = '$Main'
AND B_Board = '$Board_q'
";
$dbh -> do_query($query);
}




And that *should* do the trick...

Joined: Feb 2002
Posts: 1,759
Addict
Addict
Offline
Joined: Feb 2002
Posts: 1,759
So this works correctly with 6.1 then?

palmen #219785 09/24/2002 9:19 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
I don't know for sure. It's not what's being used here... lol

I'll put the "how to" info together sometime this week for the one in use here.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
I will try the bug fix and test it out....

I'll post here if it works correctly.
I'm thinking Dave's fix might just do it. <fingers crossed>

palmen #219787 09/24/2002 11:22 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
If you make JustDave's change.... the Last Post mod will work OK (sorta).

Removing that Date code puts back a bug that was present in the beta where the Date and Time in the "Last Post by" column on postlist.php wasn't getting updated for sticky posts.. it remained on the date/time of the first post.

Rick fixed it...but in testing we didnt' notice the side effect of this bug fix.

My guess is, if you remove that date line of code.... you can use this hack fine. The date and time in the postlist.php for sticky posts will be wrong. The link of this hack will take you to the right post.

If you make the fix, install this... we'll watch for Rick's "official" fix to this.

Daine #219788 09/25/2002 12:46 PM
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
Well I installed the hack and it works fine. I have attached the txt file with a few very minor alterations. JustDave knows of these as you can see from his code above but the hack had not been updated

The hack calls the Posts database as w3t_Posts

In 6.1 it is this {$config['tbprefix']}Posts I simply made those minor fixes. so it is easy to copy and paste.

Attachments
57463-lastpostby.6.1.txt (0 Bytes, 77 downloads)

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Actually my 6.1 instructions above are a bit more complete.

In 6.1 postlist.php uses $File in the select and list line to tell if there's an attachment and add the disk Icon if needed.

Edit: As well as the posterid variable:

Step 2.
In your postlist.php script find this:


SELECT t1.B_Number,t1.B_Parent,t1.B_Username,t1.B_Posted,t1.B_Last_Post,t1.B_Subject,t1.B_Main,t1.B_Status,t1.B_Approved,t1.B_Icon, t1.B_Reged,t1.B_Counter,t1.B_Sticky,t1.B_Replies,t1.B_Rating,t1.B_Rates,t1.B_RealRating,t2.U_Color,t2.U_Status,t1.B_PosterId,t1.B_File


and change it to this:


SELECT t1.B_Number,t1.B_Parent,t1.B_Username,t1.B_Posted,t1.B_Last_Post,t1.B_Last_Number,t1.B_Last_Name,t1.B_Last_Approved,t1.B_Subject,t1.B_Main,t1.B_Status,t1.B_Approved,t1.B_Icon, t1.B_Reged,t1.B_Counter,t1.B_Sticky,t1.B_Replies,t1.B_Rating,t1.B_Rates,t1.B_RealRating,t2.U_Color,t2.U_Status,t1.B_PosterId,t1.B_File


Find this:


list($Number,$Parent,$Username,$Posted,$Last_Post,$Subject,$Main,$Open,$Approved,$icon,$Reged,$Counter, $Sticky,$Replies,$Rating,$Rates,$stars,$Color,$PostStatus,$posterid,$file) = $dbh -> fetch_array($sth);


and change it to this:


list($Number,$Parent,$Username,$Posted,$Last_Post,$Last_Number,$Last_Name,$Last_Approved,$Subject,$Main,$Open,$Approved,$icon,$Reged,$Counter $Sticky,$Replies,$Rating,$Rates,$stars,$Color,$PostStatus,$posterid,$file) = $dbh -> fetch_array($sth);



Last edited by JoshPet; 09/25/2002 1:01 PM.
Daine #219790 09/25/2002 5:44 PM
Joined: Apr 2001
Posts: 3,266
Member
Member
Offline
Joined: Apr 2001
Posts: 3,266
LOL Yep your right Josh. I found those changes as well but must have forgot to copy them over.

Daine #219791 10/02/2002 1:14 AM
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
we need to consider breaking the 3 added fields into separate adds. On large forums, the script times out before finishing


- Allen wavey
- What Drives You?
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
[]we need to consider breaking the 3 added fields into separate adds. On large forums, the script times out before finishing [/]

I'm not sure I understand this.
Are you saying on large forums sometimes the last post info doesn't get updated because there's too much stuff to do?
Hmmmm.... over my head. I haven't noticed a problem. <knock on wood> But I've probably only got a "medium sized small forum". LOL

Daine #219793 10/04/2002 10:06 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
I'll try and get instructions written for the "last post by" code I have in use here. As you can see there are no extra queries added to the ubbthreads.php display.

Never enough time... *sigh*

Daine #219794 10/04/2002 10:19 PM
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
I meant the altertable script that adds the fields to the database originally... If you have a forum with maybe 100k + of posts, the original install of this mod will bring a slower server to its knees and the script times out because it can't finish in 30 seconds.


- Allen wavey
- What Drives You?
Joined: Feb 2002
Posts: 1,759
Addict
Addict
Offline
Joined: Feb 2002
Posts: 1,759
Hey dave, found any time yet to post the instructions?

palmen #219796 10/17/2002 8:45 PM
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
I'll try and put it together this weekend. It's all I can do to go through my email and make a quick scan of the web at the end of the day before wanting to crawl into bed. LoL

Joined: Feb 2002
Posts: 1,759
Addict
Addict
Offline
Joined: Feb 2002
Posts: 1,759
Totally understandable, keep up the good work and get some rest!

Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
I'm not sure if this bug was covered above.

Several hours ago, I moved a thread by msula from the How Do I board to the General Feedback board. It was the "last post" in the How Do I board before I moved it.

After the move, the Last Post info for the How Do I board in the Main Index is wrong:

10/22/02 12:04 AM by JoshPet: Re: URGENT: How do I change the "forums closed" msg?

The URL correctly links to the last post, and JoshPet is the user who made the last post, but the date/time and thread subject correspond to the moved thread, not the current last post.

joeuser #219799 10/22/2002 1:01 PM
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
Thanks for pointing this out. I thought I was going nuts there for a minute.


UBB.threads Developer
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
Actually, it's not a bug. I just hadn't installed the modifications to the scripts in the admin area... lol

I'll add that to the list I have on my desktop.

Page 1 of 2 1 2

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
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
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,833
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-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)