PDA

View Full Version : Create Private Message Filter


datarecall
06-23-2008, 03:42 PM
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 1214244284 at 1214244284 ---------------

Ok well i hacked something up this might work :
goto private.php and add this hook:
1)
search for :
$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 :
($hook = vBulletinHook::fetch_hook('filter_pm')) ? eval($hook) : false;

2) goto :
forum/includes/xml

create a file with the contents:

<?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:

$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 1214320122 at 1214320122 ---------------

I changed this bit of code here $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
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.