Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2008, 03:42 PM
datarecall datarecall is offline
 
Join Date: Aug 2006
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Create Private Message Filter

Hello,

I was wondering if someone could point me in the right direction to create a plugin that will:
when a user sends a pm run it through the filter of keywords if it fails the filter dont post, otherwise post. Is there a list of hooks that i can find and maybe a good tutorial on coding for vbulletin. I have seen this hack requested many times.

Thanks

--------------- Added [DATE]1214244284[/DATE] at [TIME]1214244284[/TIME] ---------------

Ok well i hacked something up this might work :
goto private.php and add this hook:
1)
search for :
Code:
	$pm['message'] =& $vbulletin->GPC['message'];
	$pm['title'] =& $vbulletin->GPC['title'];
	$pm['parseurl'] =& $vbulletin->GPC['parseurl'];
	$pm['savecopy'] =& $vbulletin->GPC['savecopy'];
	$pm['signature'] =& $vbulletin->GPC['signature'];
	$pm['disablesmilies'] =& $vbulletin->GPC['disablesmilies'];
	$pm['sendanyway'] =& $vbulletin->GPC['sendanyway'];
	$pm['receipt'] =& $vbulletin->GPC['receipt'];
	$pm['recipients'] =& $vbulletin->GPC['recipients'];
	$pm['bccrecipients'] =& $vbulletin->GPC['bccrecipients'];
	$pm['pmid'] =& $vbulletin->GPC['pmid'];
	$pm['iconid'] =& $vbulletin->GPC['iconid'];
	$pm['forward'] =& $vbulletin->GPC['forward'];
	$pm['folderid'] =& $vbulletin->GPC['folderid'];
below that big block add this :
Code:
($hook = vBulletinHook::fetch_hook('filter_pm')) ? eval($hook) : false;
2) goto :
forum/includes/xml

create a file with the contents:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<hooks>

        <hooktype type="My Custom Hooks">
                <hook>filter_pm</hook>
        </hooktype>

</hooks>
3)
Goto plugin manager click create new plugin
select filter name filter_pm as ur hook location add this:
Code:
$bad_texts = array('badword1','badword1','badword1','badword1','badword1'); 
    foreach ($bad_texts as $bt){
        if (preg_match('/'.$bt.'/i',$pm['message'])){
$pm['recipients'] = 'admin_name;';
            $pm['bccrecipients'] = '';       
            $pm['forward'] = 0;
        }
    }
THATS IT: be sure to replace badword1 with the words you dont want to have in pm, change admin_name with the admin login so messages will be sent to you instead.


Please dont flame me this is my first attemt at messing with vb's plugin system
I did find a current hook that could be used called:
($hook = vBulletinHook::fetch_hook('private_insertpm_proces s')) ? eval($hook) : false;

but i couldnt figure out how to remove the recipient already set.

--------------- Added [DATE]1214320122[/DATE] at [TIME]1214320122[/TIME] ---------------

I changed this bit of code here
Code:
$bad = (' ','-','_');
$message = str_replace($bad,'',$pm['message']);
        if (preg_match('/'.$bt.'/i',$message)){
found a couple people doing spaced out so they dont get caught.
Reply With Quote
  #2  
Old 07-24-2008, 11:49 PM
quitsmoking quitsmoking is offline
 
Join Date: Mar 2006
Location: Egypt
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excuse me, after the first two instructions I was not able to find filter_pm in the plugin locations dropdown menu. Why?
Reply With Quote
  #3  
Old 07-25-2008, 08:56 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by quitsmoking View Post
Excuse me, after the first two instructions I was not able to find filter_pm in the plugin locations dropdown menu. Why?
It was a custom plugin he created himself, though this defeats the point of the plugin system as it is intended to prevent file edits.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:32 AM.


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.03706 seconds
  • Memory Usage 2,184KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete