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 07-02-2008, 08:35 AM
mdoliwa mdoliwa is offline
 
Join Date: Jan 2006
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 07-03-2008, 06:45 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can run your code during newreply_process and newthread_process.
Reply With Quote
  #3  
Old 07-03-2008, 08:23 AM
mdoliwa mdoliwa is offline
 
Join Date: Jan 2006
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where can I find more info about writing vbulletin plugins ? Any good tutorials?

cheers,
Marcin
Reply With Quote
  #4  
Old 07-03-2008, 08:31 AM
necris necris is offline
 
Join Date: Jan 2008
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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);
                      }
                }
	}
}
Reply With Quote
  #5  
Old 07-03-2008, 10:24 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
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 02:29 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.05239 seconds
  • Memory Usage 2,197KB
  • Queries Executed 11 (?)
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
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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_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