vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   User Thread Banning (Includes Time Banning Feature) (https://vborg.vbsupport.ru/showthread.php?t=50585)

John 03-20-2003 10:00 PM

User Thread Banning (Includes Time Banning Feature)
 
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
PHP Code:

$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
PHP Code:

//##########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
PHP Code:

 }
      }
    }
  }
}

$foruminfo=getforuminfo($threadinfo[forumid]); 

insert
PHP Code:

$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:
Code:

if (($bbuserinfo['userid']!=$thread['postuserid']) and (!$getperms['canviewothers'] or !$getperms['canreplyothers'])) {
Right BEFORE that, INSERT:
Code:

$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:
Code:

} else {
        $textareacols = gettextareawidth();
        eval("\$replybox = \"".gettemplate('showthread_replybox')."\";");
}

and right BEFORE that, INSERT:
Code:

} 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:
PHP Code:

thread.postuserid AS puserid,bans.active AS active

and
PHP Code:

LEFT JOIN thread ON thread.threadid=post.threadid
LEFT JOIN bans ON bans
.userid post.userid AND bans.threadid=post.threadid AND active=

is causing an SQL error whenever trying to read a thread.

This is the error:
PHP Code:

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,attachment.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 number1109

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

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
PHP Code:

thread.postuserid AS puserid,bans.active AS active

should cause the sql error
PHP Code:

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

Quote:

Today at 08:27 PM Capt PPRuNe said this in Post #30
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

PHP Code:

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.iconpathETC 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
: [url]http://forums.squareultima.com/showthread.php?s=&postid=62609#post62609[/url]
Referer: [url]http://forums.squareultima.com/index.php?[/url] 

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

Quote:

05-02-03 at 08:27 PM Capt PPRuNe said this in Post #30
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

[sql]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>
[/sql]

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:
PHP Code:

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,attachment.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
PHP Code:

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,attachment.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

Quote:

04-04-03 at 05:44 AM Anarchnophobia said this in Post #27
any idea about the blank admin page meanwhile?

i fixed this in the above post.


All times are GMT. The time now is 04:44 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01432 seconds
  • Memory Usage 1,908KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (12)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete