vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Create Private Message Filter (https://vborg.vbsupport.ru/showthread.php?t=183323)

datarecall 06-23-2008 03:42 PM

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.

quitsmoking 07-24-2008 11:49 PM

Excuse me, after the first two instructions I was not able to find filter_pm in the plugin locations dropdown menu. Why?

Opserty 07-25-2008 08:56 AM

Quote:

Originally Posted by quitsmoking (Post 1583474)
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.


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.02380 seconds
  • Memory Usage 1,724KB
  • 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
  • (5)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete