The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Running all posts through regular expressions set
Hi,
I'd like to run regular expressions on all my forum posts. And then write a plugin which run these regexps when the new post is submited. I'm going to exchange some words with adlinks, but wouldnt like them to look like regular underlined links, would be better if they could be the same as regular text, maybe a little different color. Could you give me any tips how to do it, or where can I read about it? 1. Running regexps on all posts in forum database 2. How to create a plugin runnig set of regular expressions on post while it's being submited by an user ? 3. How to create links that look like regular text but have only different color (I wan't to leave regular links like they are) Thanks for any help cheers, Marcin |
#2
|
||||
|
||||
You can run your code during newreply_process and newthread_process.
|
#3
|
|||
|
|||
Where can I find more info about writing vbulletin plugins ? Any good tutorials?
cheers, Marcin |
#4
|
|||
|
|||
I use something similar to transform certain words into links and to "block" certain subrepticious spams.
I use the hook "postbit_display_complete", so its executed on every "page-spam" using "newreply_process" and "newthread_process" would be more efficient but less versatile. Here is an option ^^ up to you tu take it. Regular expressions power . Code:
$custom_replace[] = array ( 'string' => '/plainword/', 'replacement' => '<a>tunned plain word</a>', 'act' => 1, 'grp' => 1 ); .... $custom_replace[] = array ( 'string' => '/plainword10000/', 'replacement' => '<a>tunned plain word 10000</a>', 'act' => 1, 'grp' => 10000 ); $counter=0; $grp_old=0; foreach ($custom_replace as $k => $v) { if ( $v['act'] == 1) { if($v['grp']<>$grp_old){ $grp_old=$v['grp']; $counter=0; } if($counter==0){ $counter=preg_match ( $v['string'] , $this->post['message']); if($counter<>0){ $this->post['message'] = preg_replace($v['string'],$v['replacement'],$this->post['message'],-1); } } } } |
#5
|
||||
|
||||
You'd want to prevent it in the first place. Doing it your way will run fairly "load expensive" PCRE functions every time someone views the post and on every post in the thread.
@mdoliwa: You can have a look at the vBulletin Manual. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|