PDA

View Full Version : User Thread Banning (Includes Time Banning Feature)


John
03-20-2003, 10:00 PM
User Thread Banning (Includes Time Banning Feature)
By Shaolyen
email: John@eovie.com
msn: John@eovie.com

Brief intro:
------------------------
This hack enables mods, supermods and administrators to ban
users from viewing OR just replying to specific threads. It also
allows users to be banned from threads for specified amount of
time. After this time has expired, they will gain access/be able
to post again.

It adds a small link underneath the "Posts: #" in the postbit
template. Providing the user who posted did not start the thread,
a "[Thread Ban This User]" link will appear. (Only to mods, super
mods and admins.) For users who are already banned from a thread,
an "[Unban This User]" link will appear.

Forum leaders cannot be banned from threads. (The link will not
appear in their posts.)

When a forum leader clicks on the "[Thread Ban This User]" link,
they are taken to another page where they can:

a) choose whether the user can read the thread, or just not reply to it.
b) choose the length of the user's ban (in days).
c) type in a reason for the user's thread ban. This is displayed
when the user tried to access or reply to the thread.

When a user tries to access a thread or reply to one when banned,
the error message will provide a link to send a PM to the
moderator who banned them. This is something that some people
might not like - but if they're too scared to own up and explain
why they banned the user from the thread in the first place,
maybe they shouldn't be moderating! (If it really bothers some
people, I can provide them with the lines of code they need to
find and delete.)

A new page in the AdminCP will allow the admin to check all of
the current bans, as well as view archived ones. The reason for
the ban will be displayed in the Admin CP when the cursor passes
over the "Reason" link.

Enjoy. :)

John
03-21-2003, 05:27 PM
Screenshots:

Dean C
03-21-2003, 05:33 PM
Awesome hack John! Such a brilliant idea :)

- miSt

John
03-21-2003, 05:38 PM
Thanks Mist -

Just a quick note, this has been tested on vB 2.3.0 only as of yet.

Kars10
03-21-2003, 05:42 PM
Very cool hack...thanks John!! :)

N9ne
03-21-2003, 06:13 PM
<a href="https://vborg.vbsupport.ru/showthread.php?s=&threadid=48773" target="_blank">https://vborg.vbsupport.ru/showt...threadid=48773</a>

I requested it there a long time ago, MUG posted a version of it, but it didn't have the features which Dan_UPC was going to add into it, however he's just gone somewhere now...

So i'm glad someone has released it finally, well done John.

007
03-21-2003, 06:28 PM
Wow, this was requested a while ago (By N9ne :)). I saw it but never really thought it would be necessary. It does look cool though, and since seeing his request, there have been a few times that I came back here to see if anyone had released it because I needed it at the time. Right now I have all my "problems" straightened out though, but rest assured next time someone needs to be banned from a specific thread, I'll install this. Just have some others that I have to get to first.

Do you know how many queries (if any) this adds to non-thread banned users? Any? Does it add any to anyone? Just wondering.

John
03-21-2003, 07:06 PM
lol, people always ask about extra queries, and I wonder how many people have actually had a problem with too many queries actually slowing down their board. (Now I've said that, I'm sure people will start giving me examples!)

As far as I can remember (I wrote this hack a week or two ago), it adds 1 query to showthread.php and one to forumdisplay.php - if any at all.

Link14716
03-21-2003, 07:12 PM
Show me a board with the itemshop hack and I'll show you a depressed server. :)

Hmm... I know it can be done fairly easily without any queries... Well, that is without the time ban added to it, at least.

Nice job. :)

John
03-21-2003, 07:15 PM
The actual ban is query free.

The query is used to check whether the user's time ban is over or not.

dr1
03-21-2003, 08:31 PM
Great hack! I have been using it for almost a week now :) Easy to install and puts those more "vocal" people on your board in check.

Davey
03-22-2003, 12:02 AM
What about mods/admins holding a grudge?
You said the link doesnt appear in the admin/mod/supermod postbit, but what if the mod/admin/supermod copies another link and changes certain aspects of it to suit the banning of a mod?
Is this exploitable? I haven't downloaded it yet, but the way you explained that part makes me belive that feature can be exploited.

Dave.

Intex
03-22-2003, 07:02 AM
V. nice hack. Have marked for installation soon :).

Tim Wheatley
03-22-2003, 11:46 AM
I'm getting a blank page on the list in the admin cp and the link isn't changing to unban when I've banned someone in postbit. I've installed a fair few hacks, I don't think I did much wrong...

John
03-22-2003, 12:53 PM
What version of vB?

Zelda-King
03-22-2003, 05:06 PM
Nice hack. Just a few observations;

1) In the threadban_noreply template you are missing the word 'to' in the TB1.0-Inst file. It reads You have been banned $tempban from replying this thread...

2) Reply bans don't work with Quick Reply (and many people have that hack installed). To fix this, in newreply.php, find $lastpost = $DB_site->query_first("SELECT * FROM post WHERE threadid = '$threadid' ORDER BY postid DESC");
if($lastpost[userid]!=$bbuserinfo[userid] || (time()-$lastpost[dateline])>3600 || ($attachmentid and !$foruminfo[moderateattach])) {
$lastpost = $DB_site->query_first("SELECT * FROM post WHERE threadid = '$threadid' ORDER BY postid DESC");
if($lastpost[userid]!=$bbuserinfo[userid] || (time()-$lastpost[dateline])>3600 || ($attachmentid and !$foruminfo[moderateattach])) { and underneath, add //##########Thread ban##########
$bans=$DB_site->query("SELECT * FROM bans WHERE threadid='$threadid' AND active=1");
while ($ban=$DB_site->fetch_array($bans)) {

if ($bbuserinfo[userid] == $ban[userid]) {

$modds=$DB_site->query_first("SELECT username FROM user WHERE userid='$ban[mod]'");
$ban[reason] = stripslashes($ban[reason]);

if ($ban[reason] == "") {
$ban[reason] = "No reason given.";
}

if ($ban[banlength] != 0) {
$tempban = "temporarily";
$currenttime = mktime();
if ($currenttime > ($ban[banlength] + $ban[banstart])) {
$updexe=$DB_site->query("UPDATE bans SET active=0 WHERE userid=$bbuserinfo[userid] AND threadid='$threadid'");
$headercont = "location:./newreply.php?s=$session[sessionhash]&threadid=$threadid&action=newreply";
@header($headercont);
}
}

$reasonpre = "<br><smallfont><b>Reason for ban:</b> $ban[reason]</smallfont>";

eval("standarderror(\"".gettemplate("threadban_noreply")."\");");
exit;
}
}. I merely pasted the code here from the hack.

3) It would be nice if you could prune archived bans and perhaps also back them up (put them under backup database options).

4) Users can still edit posts. If you want to have them not be able to edit posts insert the hack in editpost.php like so;

below }
}
}
}
}

$foruminfo=getforuminfo($threadinfo[forumid]); insert $bans=$DB_site->query("SELECT * FROM bans WHERE threadid='$threadid' AND active=1");
while ($ban=$DB_site->fetch_array($bans)) {

if ($bbuserinfo[userid] == $ban[userid]) {

$modds=$DB_site->query_first("SELECT username FROM user WHERE userid='$ban[mod]'");
$ban[reason] = stripslashes($ban[reason]);

if ($ban[reason] == "") {
$ban[reason] = "No reason given.";
}

if ($ban[banlength] != 0) {
$tempban = "temporarily";
$currenttime = mktime();
if ($currenttime > ($ban[banlength] + $ban[banstart])) {
$updexe=$DB_site->query("UPDATE bans SET active=0 WHERE userid=$bbuserinfo[userid] AND threadid='$threadid'");
$headercont = "location:./newreply.php?s=$session[sessionhash]&threadid=$threadid&action=newreply";
@header($headercont);
}
}

$reasonpre = "<br><smallfont><b>Reason for ban:</b> $ban[reason]</smallfont>";

eval("standarderror(\"".gettemplate("threadban_noreply")."\");");
exit;
}
}. Even with all that though, it's possible for users to post if they just posted before and their double post is merged (when you have that 'anti-double post' hack).

For the record I have this running on vB 2.2.9 just fine.

LeeCHeSSS
03-23-2003, 11:21 AM
Getting a blank page on the admin cp list as well, vB 2.3.0 RC2 (or 3?)

LeeCHeSSS
03-24-2003, 09:29 AM
I'm trying to hide the quick reply box when a user is reply-banned, but as usual, the mysql query is causing me troubles :)

EDIT: removed the not working code to avoid confusion

LeeCHeSSS
03-24-2003, 09:45 AM
Ah, figured it out. If anyone is interested, I will post the edits.

The Red Devil
03-24-2003, 10:05 AM
LeeCHeSSS, I would be really interested in those edits.

ForKmaN
03-24-2003, 05:45 PM
Me too, this hack is great.

VampireMan
03-24-2003, 08:17 PM
Ah-hah this will do me nicely :-)

Im installing now :)

Anarchnophobia
03-27-2003, 12:02 PM
i?m getting a blank page in admincp too... vb 2.2.9

the rest works fine, thank you :)

LeeCHeSSS
03-28-2003, 07:06 AM
Ok, how to hide the quick reply box when a user is reply-banned:

In showthread.php find:if (($bbuserinfo['userid']!=$thread['postuserid']) and (!$getperms['canviewothers'] or !$getperms['canreplyothers'])) {Right BEFORE that, INSERT:$threadban=$DB_site->query_first("SELECT COUNT(DISTINCT banid) AS activeban
FROM bans
WHERE userid=$bbuserinfo[userid] AND threadid=$threadid AND active=1
");
Next, find:} else {
$textareacols = gettextareawidth();
eval("\$replybox = \"".gettemplate('showthread_replybox')."\";");
}and right BEFORE that, INSERT:} elseif ($threadban[activeban]!=0) {
$replybox='';

That's it. And for the query freaks: yes it DOES add a query.

Boofo
03-28-2003, 07:21 AM
So, use this code instead of what is in post #16 above? What about the editpost? ;)

LeeCHeSSS
03-30-2003, 05:04 AM
This merely hides the quick reply box, smart users could still reply if you do not use the code in post 16.

Anarchnophobia
04-04-2003, 07:44 AM
any idea about the blank admin page meanwhile?

Capt PPRuNe
04-19-2003, 07:07 PM
Installed the hack but now getting serious problem. The following code added in showthread.php: thread.postuserid AS puserid,bans.active AS active,

and
LEFT JOIN thread ON thread.threadid=post.threadid
LEFT JOIN bans ON bans.userid = post.userid AND bans.threadid=post.threadid AND active=1
is causing an SQL error whenever trying to read a thread.

This is the error: Database error in vBulletin 2.3.0:

Invalid SQL:
SELECT
thread.postuserid AS puserid,bans.active AS active,post.*,post.username AS postusername,post.ipaddress AS ip,user.*,userfield.*,icon.title as icontitle,icon.iconpath,
attachment.attachmentid,attachment.filename,attach ment.visible AS attachmentvisible,attachment.counter

FROM post
LEFT JOIN icon ON icon.iconid=post.iconid
LEFT JOIN user ON user.userid=post.userid
LEFT JOIN userfield ON userfield.userid=user.userid

LEFT JOIN attachment ON attachment.attachmentid=post.attachmentid
WHERE post.postid IN (0,810719,812243,812549,812889,837671)
ORDER BY dateline

mysql error: Unknown table 'thread' in field list

mysql error number: 1109

Date: Saturday 19th of April 2003 07:56:44 PM
Script: http://www.pprune.org/forums/forums/showthread.php?s=&threadid=85068

I have removed the code for the moment and users can read the forums. Now the 'Thread Ban this user' link is still there and it is possible to ban users using the link. What doesn't happen is the link changing to 'Unban' which means mods who don't have access to the CP can't unban a banned user.

Any suggestions would be helpful.

I did have a problem running the SQL Query. It was generating an error so I ran the query without line breaks and it ran successfully.
:disappointed:

Capt PPRuNe
04-24-2003, 11:09 PM
No experts out there that might be able to explain why thread.postuserid AS puserid,bans.active AS active, should cause the sql error Unknown table 'thread' in field list?

I've checked the structure of the tables and they are all ok.

Help! Please, anyone!

Capt PPRuNe
05-03-2003, 12:27 AM
Problem fixed. I don't have avatars enabled on my forums and the sql code you wrote assumes that everyone has avatars enabled. No one else has reported this problem because I assume they all have avatars enabled.

If anyone needs the solution make a request on here.

Boofo
05-03-2003, 03:05 AM
Today at 08:27 PM Capt PPRuNe said this in Post #30 (https://vborg.vbsupport.ru/showthread.php?postid=390685#post390685)
Problem fixed. I don't have avatars enabled on my forums and the sql code you wrote assumes that everyone has avatars enabled. No one else has reported this problem because I assume they all have avatars enabled.

If anyone needs the solution make a request on here.

It would be nice to have just in case, though. I'd like to see it. ;)

Hobbes
05-05-2003, 03:38 AM
I WOULD LIKE THAT SOLUTION!!!!! lol....please?

i'm getting

Database error in vBulletin 2.2.6:

Invalid SQL:
SELECT
thread.postuserid AS puserid,bans.active AS active,post.*,post.username AS postusername,post.ipaddress AS ip,user.*,userfield.*,icon.title as icontitle,icon.iconpath, ETC ETC

mysql error: You have an error in your SQL syntax near 'LEFT JOIN thread ON thread.threadid=post.threadid
LEFT JOIN bans ON bans.userid ' at line 8

mysql error number: 1064

Date: Sunday 04th of May 2003 11:50:14 PM
Script: http://forums.squareultima.com/showthread.php?s=&postid=62609#post62609
Referer: http://forums.squareultima.com/index.php?


and i am also getting a blank page in the admin cp

John
05-12-2003, 10:51 AM
Sorry everyone, I've been away for a while and I didn't have access to vb.org - now I'm back, what are the main issues with this hack? Is it installing well for most people? :\

Jacko
05-13-2003, 08:01 AM
shaolyen.

EXCELLENT HACK, works great on my local board..

1 thing i would like to request though.

i am after this kind of hack is it possible to incorporate a users ban as a forum wide ban not just a specific Thread ban?? say have a second ban feature to ban a user for a timed amount to every thread on the forum.. alow them to read just not reply..

Boofo
05-13-2003, 01:54 PM
05-02-03 at 08:27 PM Capt PPRuNe said this in Post #30 (https://vborg.vbsupport.ru/showthread.php?postid=390685#post390685)
Problem fixed. I don't have avatars enabled on my forums and the sql code you wrote assumes that everyone has avatars enabled. No one else has reported this problem because I assume they all have avatars enabled.

If anyone needs the solution make a request on here.

Still waiting for your fix. ;)

Boofo
05-13-2003, 01:57 PM
Shaolyen, could this be coded to work for forums the same way, too?

Hobbes
06-03-2003, 04:47 AM
I still have this error in the query

Database error in vBulletin 2.2.6:

Invalid SQL:
SELECT
thread.postuserid AS puserid,bans.active AS active,post.*,post.username AS postusername,post.ipaddress AS ip,user.*,userfield.*,icon.title as icontitle,icon.iconpath, ETC ETC

mysql error: You have an error in your SQL syntax near 'LEFT JOIN thread ON thread.threadid=post.threadid
LEFT JOIN bans ON bans.userid ' at line 8

mysql error number: 1064

Date: Sunday 04th of May 2003 11:50:14 PM
Script: <a href="http://forums.squareultima.com/showthread.php?s=&postid=62609#post62609" target="_blank">http://forums.squareultima.com/show...62609#post62609</a>
Referer: <a href="http://forums.squareultima.com/index.php?" target="_blank">http://forums.squareultima.com/index.php?</a>


and i tried installign this in a fresh 2.2.6 (jus shoot meh :p) and now the admin cp link is blank....

help? Everything else worked fine, I can ban users etc.....link is jus blank in admin cp...(note: this is on a fresh 2.2.6)....

help?


ditto that boofo....fix would be nice....*cries*....i really like this hack and would lovve it to work :(

Capt PPRuNe
06-25-2003, 07:18 AM
Sorry for the delay in getting back to you but been away. Anyway, in the original hack under "2. FILE EDITS" the "Replace With" should be changed from:Replace with:
-----------------------------------------------------------------
$posts=$DB_site->query("
SELECT
thread.postuserid AS puserid,bans.active AS active,post.*,post.username AS postusername,post.ipaddress AS ip,user.*,userfield.*,".iif($forum[allowicons],'icon.title as icontitle,icon.iconpath,','')."
attachment.attachmentid,attachment.filename,attach ment.visible AS attachmentvisible,attachment.counter
".iif($avatarenabled,",avatar.avatarpath,NOT ISNULL(customavatar.avatardata) AS hascustomavatar,customavatar.dateline AS avatardateline","")."
FROM post
".iif($forum[allowicons],'LEFT JOIN icon ON icon.iconid=post.iconid','')."
LEFT JOIN user ON user.userid=post.userid
LEFT JOIN userfield ON userfield.userid=user.userid
".iif ($avatarenabled,"LEFT JOIN avatar ON avatar.avatarid=user.avatarid
LEFT JOIN thread ON thread.threadid=post.threadid
LEFT JOIN bans ON bans.userid = post.userid AND bans.threadid=post.threadid AND active=1
LEFT JOIN customavatar ON customavatar.userid=user.userid","")."
LEFT JOIN attachment ON attachment.attachmentid=post.attachmentid
WHERE $postids
ORDER BY dateline $postorder
");
----------------------------------------------------------------- to Replace with:
-----------------------------------------------------------------
$posts=$DB_site->query("
SELECT
thread.postuserid AS puserid,bans.active AS active,post.*,post.username AS postusername, post.ipaddress AS ip,user.*,userfield.*,".iif($forum[allowicons],'icon.title as icontitle,icon.iconpath,','')."
attachment.attachmentid,attachment.filename,attach ment.visible AS attachmentvisible,attachment.counter
".iif($avatarenabled,",avatar.avatarpath,NOT ISNULL(customavatar.avatardata) AS hascustomavatar,customavatar.dateline AS avatardateline","")."
FROM post
".iif($forum[allowicons],'LEFT JOIN icon ON icon.iconid=post.iconid','')."
LEFT JOIN user ON user.userid=post.userid
LEFT JOIN userfield ON userfield.userid=user.userid
LEFT JOIN thread ON thread.threadid=post.threadid
LEFT JOIN bans ON bans.userid = post.userid AND bans.threadid=post.threadid AND active=1
".iif ($avatarenabled,"
LEFT JOIN avatar ON avatar.avatarid=user.avatarid
LEFT JOIN customavatar ON customavatar.userid=user.userid","")."
LEFT JOIN attachment ON attachment.attachmentid=post.attachmentid
WHERE $postids
ORDER BY dateline $postorder
");
-----------------------------------------------------------------

At least that's what fixed it for me. Been running this hack for a few months now and no problems at all with it. Only request would be an feature in the admin CP to prune some of the older bans from the log.

ImportPassion
07-06-2003, 11:17 PM
there is 2 cpheader functions being called in threadbanadmin.php and it doesn't show the page. so just remove one of them.

D

ImportPassion
07-07-2003, 03:48 PM
04-04-03 at 05:44 AM Anarchnophobia said this in Post #27 (https://vborg.vbsupport.ru/showthread.php?postid=377407#post377407)
any idea about the blank admin page meanwhile?


i fixed this in the above post.

brauner
07-12-2003, 10:18 PM
What is that called? I cannot find the error.


Datenbank Fehler in vBulletin Control Panel 2.3.0:

Invalid SQL: SELECT * FROM access WHERE userid='16'
mysql error: Table 'dbxxxxx.access' doesn't exist

mysql error number: 1146

Datum: Sunday 13th of July 2003 01:04:02 AM
Script: http://xxxxx/xxxxx/admin/user.php?s=&action=editaccess&userid=16
Referer:


The data base is there and the user also. But if I on "forum access change" go comes the error. :ermm:

Hobbes
08-25-2003, 08:20 PM
dont mind my earlier posts...this is working fine nice hack!!!:D

LancerForums
06-16-2004, 08:31 PM
Any plans to upgrade this for vb3?

Mark

lucky64
07-13-2004, 06:59 PM
Any plans to upgrade this for vb3?

Mark

Seconded, or has anyone tried this on VB3? Or is there another out there?

NetRover
08-08-2004, 10:21 PM
this does sound good, I would like this on VB3 also.

Andy

lucky64
08-15-2004, 02:53 AM
Still no 3.0? :(

lucky64
08-31-2004, 07:22 AM
Bump.

lucky64
10-12-2004, 05:09 PM
Please Please Please Please Please Please Please :)

NetRover
10-24-2004, 10:04 AM
I've still got my eye on this for VB3.

sounds brilliant so there must be many more wanting this updated.

Franchise
12-23-2004, 05:18 AM
I understand this thread is ancient, however I just felt I'd ask:

Does anyone know why this hack when (seemingly) properly installed would bring up errors such as this on showthread.php instances (above the header of the page):

Warning: Cannot modify header information - headers already sent by (output started at /home/hallow3/public_html/admin/functions.php:2552) in /home/hallow3/public_html/admin/functions.php on line 1733

And this error (and only this error, the rest of the page does NOT load) whenever attempting to go to a new post?

Warning: Cannot modify header information - headers already sent by (output started at /home/hallow3/public_html/admin/functions.php:2552) in /home/hallow3/public_html/showthread.php on line 165