PDA

View Full Version : 2 Bug Fixes anyone want to help out with?


09-18-2000, 08:02 PM
It seems as if users can "bump up" threads to the top of the page by making a post and subsequently deleting it. This is bad, since it brings up threads from long ago without any warning. Once they delete it, it should go back to where it once was.

I haven't taken a look at it yet, but I am going to sit down and fix this bug and I was wondering if anyone else has:

a) encountered it
a.1) and fixed it
b) has heard of a fix
c) wants to help me fix it

It's something that has recently been a problem, and with the "next release" of vB seemingly becoming more and more distant, it's not something that I can afford to have pushed off any more.

Also, the second bug seems to be that regular users can unlock their posts regardless of the setting in the control panel. Anyone else know more about this?

(You can imagine how we discovered this, mod-locked threads mysteriously float up to the top of the board, unlocked with no explanations.)

So we know who's been unlocking them (the original posters), but we can't do anything about it!!!

09-18-2000, 08:07 PM
hmm.. this would be a problem.. i haven't experienced this exactly... but i sometimes have locked threads moving around but that's cause my hard working mods picked up my own mistakes sometimes :)

09-18-2000, 08:40 PM
Originally posted by mrogish
It seems as if users can "bump up" threads to the top of the page by making a post and subsequently deleting it. This is bad, since it brings up threads from long ago without any warning. Once they delete it, it should go back to where it once was.

I haven't taken a look at it yet, but I am going to sit down and fix this bug and I was wondering if anyone else has:

a) encountered it
a.1) and fixed it
b) has heard of a fix
c) wants to help me fix it
Haven't fixed it but I can give you some theory on it if you want :)
In the delete post routines, you have to develop a check to see if the post is the last in the thread. This code should do it:
$thread=$DB_site->query_first("SELECT threadid FROM post WHERE postid='$postid'");
$threadid=$thread[threadid];
$islast=$DB_site->query_first("SELECT postid FROM post WHERE threadid='$threadid' ORDER BY dateline LIMIT 0,1");
if ($postid==$islast[postid]) {
if ($issecondlast=$DB_site->query_first("SELECT dateline FROM post WHERE threadid='$threadid' ORDER BY dateline LIMIT 1,1")) {
$DB_site->query("UPDATE thread SET lastpost='$issecondlast[dateline]' WHERE threadid='$threadid'");
}
}

Hey, woah - I just like wrote the hack! LOL. Of course, that's not accounting for any of the code already in there. You probably don't need all that because it's partly redundant.
[Note: That code is completely untested]
Note that I left out the DESC part from the dateline - this should get the oldest post.

Also, the second bug seems to be that regular users can unlock their posts regardless of the setting in the control panel. Anyone else know more about this?

(You can imagine how we discovered this, mod-locked threads mysteriously float up to the top of the board, unlocked with no explanations.)

So we know who's been unlocking them (the original posters), but we can't do anything about it!!!I don't think that's a bug - you might want to check your usergroup permissions.

09-18-2000, 08:44 PM
Originally posted by Ed Sullivan
Haven't fixed it but I can give you some theory on it if you want :)
In the delete post routines, you have to develop a check to see if the post is the last in the thread. This code should do it:
$thread=$DB_site->query_first("SELECT threadid FROM post WHERE postid='$postid'");
$threadid=$thread[threadid];
$islast=$DB_site->query_first("SELECT postid FROM post WHERE threadid='$threadid' ORDER BY dateline LIMIT 0,1");
if ($postid==$islast[postid]) {
if ($issecondlast=$DB_site->query_first("SELECT dateline FROM post WHERE threadid='$threadid' ORDER BY dateline LIMIT 1,1")) {
$DB_site->query("UPDATE thread SET lastpost='$issecondlast[dateline]' WHERE threadid='$threadid'");
}
}


Neat, I'll have to check that out... I figured something like that would have to be done, just wanted to see if someone else had done it before I work it out myself! :)


don't think that's a bug - you might want to check your usergroup permissions.

That's what I meant about the "regardless of the controll panel settings". I have it set to "No" for members' ablity to open their closed posts, but for some reason they can still do it.

09-18-2000, 09:51 PM
Actually it was pretty easy:

In editpost.php line 255

change:
$getlastpost=$DB_site->query_first("SELECT postid FROM post WHERE threadid=$threadid ORDER BY dateline DESC");

into this:
$getlastpost=$DB_site->query_first("SELECT postid, dateline FROM post WHERE threadid=$threadid ORDER BY dateline DESC");

In editpost line 264:

change:
$DB_site->query("UPDATE thread SET replycount=replycount-1,lastposter='".addslashes($lastusername)."' WHERE threadid=$threadid");

to this:
$DB_site->query("UPDATE thread SET replycount=replycount-1,lastposter='".addslashes($lastusername)."', lastpost = $getlastpost[dateline] WHERE threadid=$threadid");

And that should update the time correctly. For some reason the last poster is updated, but they just forgot the time.

[Edited by mrogish on 09-18-2000 at 06:59 PM]

09-18-2000, 11:12 PM
mrogish:

I don't have the problem that you mentioned with users being able to reopen closed threads. With my forum it takes them to the page that requires them to log in and states that they aren't a administrator, etc.

It has to be something that you have set up in your control panel.

Thanks for the hack on the other though. I didn't even know they could do this. It works great BTW.

Parker

[Edited by Parker Clack on 09-18-2000 at 08:32 PM]

09-18-2000, 11:30 PM
A user can always write his/her own <FORM> locally and use it to access member.php. That is one *possible* way to cause unforseen problems.