vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Word replacement filter (https://vborg.vbsupport.ru/showthread.php?t=204782)

Anyoldname 02-09-2009 05:11 PM

Word replacement filter
 
I've had a look around for a word replacement mod, but I can't seem to find quite what I am after.
I want to find something that works, dare I say it, like my old phpbb2 bad word filter, where I can set a word, for example 'Ugly' and then set a word, or even multiple words to replace it, for example 'not so pretty'. I could put an * either before or after the word to be replaced if I wanted all examples to be replaced, otherwise the exactl word only would be replaced.

Ideally, what I'd like to be able to do is replace words with html or BB code so that I could do this.
Vbulletin mods gets replaced with <a href="http://www.vbulletin.org>Vbulletin mods</a>

The final output to be something like: I have some Vbulletin mods on my forum.

Anyone know of any kind of mod that might be able to do this? It would be great for creating internal links to particular FAQ when people type common questions. :)

Dismounted 02-10-2009 05:32 AM

<a href="http://www.vbulletin.com/docs/html/main/replacements_intro" target="_blank">Replacement Variables</a>

Anyoldname 02-10-2009 02:37 PM

Thanks
I did look at using replacement variables, but they would affect the entire forum so I'm not sure that it would work.
For example if I changed the word "stick" into "stone". If I typed "sticky", it would output "stoney" right?

I need to be able to distinguish the word on its own rather than the string of letters within other words.

Lynne 02-10-2009 03:22 PM

plugin at postbit_display_complete:

PHP Code:

$find = array( 
'Vbulletin mods'
'Ugly',  
); 

$replace = array( 
'<a href="http://www.vbulletin.org">Vbulletin mods</a>'
'not so pretty'
); 

$this->post['message'] = str_ireplace($find$replace$this->post['message']); 


Joey Link 04-21-2009 04:55 PM

Quote:

Originally Posted by Lynne (Post 1739900)
plugin at postbit_display_complete:

PHP Code:

$find = array( 
'Vbulletin mods'
'Ugly',  
); 

$replace = array( 
'<a href="http://www.vbulletin.org">Vbulletin mods</a>'
'not so pretty'
); 

$this->post['message'] = str_ireplace($find$replace$this->post['message']); 


What's this mean Lynne?

Lynne 04-21-2009 05:00 PM

What does it mean? It's a sample plugin for replacing a couple of words/terms in posts. Although, it looks like I forgot a " in there (which I will now go fix).

Joey Link 04-21-2009 05:23 PM

Is this different/better than going to the Replacement Variable Manager and adding terms?

Lynne 04-21-2009 05:26 PM

It really depends on what you are trying to do. The plugin I listed will only replace words in posts. Replacement Variables replace words/code throughout the entire site.

Joey Link 04-21-2009 06:01 PM

Ok, so it sounds like what you posted is definitely what I want. I'm just looking to replace bad words with words I specify (or rather, one word). Will this work retroactively or only from the time I install it?

Also, I'm not entirely sure where I put the code. I see it says postbit_display_complete but I don't see that style template.

BlueNinjaGo 04-21-2009 06:02 PM

Quote:

Originally Posted by Lynne (Post 1796139)
The plugin I listed will only replace words in posts.

Would that add much (or any) extra work on the server? Enough to be noticeable is what I'm asking....

Lynne 04-21-2009 07:05 PM

Quote:

Originally Posted by Joey Link (Post 1796165)
Ok, so it sounds like what you posted is definitely what I want. I'm just looking to replace bad words with words I specify (or rather, one word). Will this work retroactively or only from the time I install it?

Also, I'm not entirely sure where I put the code. I see it says postbit_display_complete but I don't see that style template.

postbit_display_complete is a hook location.

This replaces words as the post is viewed, not as it is made. So, it should replace words retroactively.

Quote:

Originally Posted by BlueNinjaGo (Post 1796166)
Would that add much (or any) extra work on the server? Enough to be noticeable is what I'm asking....

I didn't notice any change on my server. However, I also changed it a bit so it is only to be used on Moderator/Admin Posts (so we can write things in shorthand but have it spit out a bunch of stuff).

Also, if someone hits Quote, the original word(s) are still there because, as I said, it doesn't replace the words as the post is made.

Joey Link 04-21-2009 07:34 PM

Is there a tutorial somewhere on how to use hooks or hook locations? I've never heard of that before. It'd really be great if you could lay it out step by step how to incorporate the code you posted above. I'm sure there are probably quite a few people looking for this information. I really appreciate all your help lynne ;)

Lynne 04-21-2009 07:54 PM

There is a section about products and plugins in the manual (link under Quick Links and in my sig). Also, there are quite a few articles written about plugins in our articles forums (tab in upper right corner).

Joey Link 04-21-2009 08:53 PM

Awesome, I got it. Thanks so much. Just one more thing, if you don't mind.

Is there a way I can make it replace an exact word, instead of a word containing the letters of a bad word? For example, if I want all my bad words to be replaced with flower, and I want to ban the word that's also another name for donkey, 'class' becomes 'clflower'. In the censorship options I can ban that particular word by typing {***}, so it only bans it when it's only those letters, not when it's part of another word. Is there any way to do this?

Lynne 04-21-2009 11:39 PM

You can go take a look at the other php string replacement functions and see if there is a better one to use for your purposes. You could also put in " donkey " (as an example) as the word with a space on either side of it so it only gets replaced if it is a standalone word.

mdawg 05-01-2009 09:25 PM

Okay I did find this, but this is not going to make say, whenever someone types in the word "yahoo" that it creates a hyperlink for http://www.yahoo.com

https://vborg.vbsupport.ru/showthread.php?t=211693

Right?

Lynne 05-01-2009 09:30 PM

Replacement Variables will replace every instance of "yahoo" on your site with whatever you say to replace "yahoo" with - which may be a link if that is what you put in the Replace Text box.

mdawg 05-02-2009 07:06 AM

I don't think so. The plugins you describe (and replacement variables) will replace a given text with another text.

That will work for my "obscenity" issue, say switching the word b*tch for woman, but in the case of switching say the word yahoo for http://www.yahoo.com I don't think it will simply change the single word yahoo into a blue hyperlink like this: yahoo - rather, it will change the five letters of yahoo for the twenty characters of http://www.yahoo.com and it may not even make the twenty characters a hyperlink.

Try it, you'll see what I mean.

Lynne 05-02-2009 03:18 PM

It works just fine. And it gave me a hyperlink because I told it to. You need to enter *exactly* what you want it to be replaced with.

Code:

Search for: yahoo
Replace with: <a href="http://www.yahoo.com">yahoo</a>


mdawg 05-04-2009 05:12 AM

I found out that vbSEO acronym expander does what I was looking for all along. But they had to modify their code for me so that it worked for HTTPS (not just HTTP) urls.

Lynne 05-04-2009 02:47 PM

Just a note to anyone else who comes across this thread... doing the above search/replace on "yahoo" will cause problems on your site if you use the yahoo yui clientscript in your pages. So, don't search/replace that word if you do!

mdawg 04-03-2015 01:49 PM

Is there a way to change the code in vb5 to make certain words automatically hyperlinks? In posts only not in titles.

hosamalzagh 11-24-2015 07:09 PM

hello i used

$this->post['message'] = str_replace('<img', '<img alt="'.$post['title'].'"', $this->post['message']);

in postbit_display_complete to add tags to images my vbulletin is 3

pls can help me to add tages img in replay of thread

Lynne 11-25-2015 04:13 AM

Add tags? What do you mean by that? What is the original link and what is the link you want to see? We need examples in order to help.

hosamalzagh 11-27-2015 07:08 AM

Quote:

Originally Posted by Lynne (Post 2559332)
Add tags? What do you mean by that? What is the original link and what is the link you want to see? We need examples in order to help.

this $this->post['message'] for Article (thread ) pls give me a variable name used in replay post number 2 ,post 3 , 4,5 and last post

Lynne 11-28-2015 06:54 PM

I do not understand what you are asking at all.


All times are GMT. The time now is 08:37 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.01278 seconds
  • Memory Usage 1,776KB
  • 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
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (26)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