vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Replace Text (https://vborg.vbsupport.ru/showthread.php?t=50116)

amykhar 03-12-2003 10:00 PM

Replace Text
 
This is more of a getting you started piece of code than a copy and paste your board is hacked kind of release. If you don't know how to code in PHP, this hack is NOT for you.


What this "hack" does is it allows you to replace a word in a post with something else. It doesn't replace the word in titles or anywhere else like replacements do. Just in a post.

What I use it for: I replace the word Netflix in every post with a link to my Netflix affilliate.

What you might use it for: affilliate links, swear word replacements with style, pranks, whatever :D

You will need to modify the function that I have included to set up your own replacement words. You might want to replace more than one thing. It's up to you. Have fun with this and share what you have done.

Demo:

http://www.eaforums.com/forums/showt...threadid=22557

I will help as much as I can in customizing this for you within reason.

FleaBag 03-14-2003 12:27 AM

Useful for updating smilie names, I'll check it out sometime. Nice work! :)

Boofo 03-14-2003 12:28 AM

I don't mean to sound negative, but can't you do the same thing with tags in vbcode without hacking? ;)

filburt1 03-14-2003 12:40 AM

The idea is you just type Netflix and it happens to turn into an affiliate link.

Boofo 03-14-2003 01:11 AM

I understand that. But a tag would be more versatile instead of having to hack the php file every time you wanted to change it. But to each his own, I guess.

Sho 03-14-2003 01:48 AM

How is this different from the Replacement Variable system? I use it to replace the phrase "closednow" with an image of a padlock, sort of a funny tradition on my forums. Works for me.

Merjawy 03-14-2003 03:16 AM

I think this is more of a filter wich is biult in vB but doesn't work well with other languages... at least it didn't work for me

this could be a better way to make it censer certain words ..

Erwin 03-14-2003 04:41 AM

What this hack does is it replaces the word with a link or whatever you want retrospectively as well (I think). Also, it's better than replacement, as replacement affects post titles, whereas this doesn't (from what I can understand).

amykhar 03-14-2003 01:14 PM

Erwin is correct. Replacements changed the word in thread titles, as well, which then effectively rendered the thread unreadable because it became a link to Netflix.

I didn't use vbbcode because I don't want to have to edit each post and I don't want to have to rely on the membership to put it in.

I use this in conjunction with a hack Logician wrote for me eons ago that changes any link somebody posts to Amazon to a link that uses my affilliate ID. That hack helped quite a bit; so I am trying to expand slowly into other relevant affiliates.

Amy

Brad 03-14-2003 01:46 PM

wow i was just thinking of doing something like this. Im ganna build a page (might use the glossery hack) and have said word link to the glossery when its typed. this saves me some time :)

[high]* Brad licks install[/high]

amykhar 03-14-2003 01:50 PM

If you lick the install button, nobody else is going to want to touch it to click it. ;)

Amy

Brad 03-14-2003 01:52 PM

Theres a reason we have paper towels ;).

Dean C 03-14-2003 03:59 PM

This is a very nice idea.. /me likes

- miSt

SgtSling 03-15-2003 03:22 AM

weird
if someone types in Amazon.com it posts it.. but if someone types amazon all lowercase.. it doesn't

limey 03-15-2003 04:10 AM

And to create more words we have to create more functions with:
($text1)
($text2)
($text3)

etc. right?

I'm pretty sure I'm right; just confirming ;). Very cool btw!

SgtSling 03-15-2003 04:31 AM

yeah but if the poster links to a certain page..
like amazon.com/apage.html
it screws with the hyperlink

Bane 03-15-2003 11:26 AM

Fantastic Idea Amy :)

amykhar 03-15-2003 12:37 PM

Quote:

Today at 01:10 AM limey said this in Post #15
And to create more words we have to create more functions with:
($text1)
($text2)
($text3)

etc. right?

I'm pretty sure I'm right; just confirming ;). Very cool btw!

No. You can actually do all of the replacements in the same function. If you look at the code, you can see that I replaced two different words: Netflix and netflix. You can do yours in the same way if you understand how the code works.

You would add code something along the lines of:

Code:

$affiliate_code2="Some other replacement string";
$text = str_replace("word2",$affiliate_code2,$text);


amykhar 03-15-2003 12:39 PM

Quote:

Today at 01:31 AM SgtSling said this in Post #16
yeah but if the poster links to a certain page..
like amazon.com/apage.html
it screws with the hyperlink

With a bit more work, you could code it to ensure that the word you are replacing is not already in a URL. If I get some time today, I will play with it and give you the code.

Amy

amykhar 03-15-2003 01:05 PM

Quote:

Today at 12:22 AM SgtSling said this in Post #14
weird
if someone types in Amazon.com it posts it.. but if someone types amazon all lowercase.. it doesn't


That is now fixed. See the new text file. To "upgrade" you will need to change calls of str_replace to stri_replace and add the new function stri_replace at the bottom of functions.php as outlined in the updated text file.

Amy

Derek 03-15-2003 05:34 PM

Have you fixed it so that it doesn't mess up with someone types in amazon.com/apage.html so it doesn't screw with the URL? If it does, I will install.

amykhar 03-15-2003 08:10 PM

Not yet, Derek. However, if you only want it for Amazon, Logician wrote a nice Amazon-specific version for me a year or so ago that is made for links.

Amy

SgtSling 03-16-2003 10:40 PM

where is that at then?

amykhar 03-16-2003 11:08 PM

<a href="https://vborg.vbsupport.ru/showthread.php?s=&threadid=39071&highlight=Amazon" target="_blank">https://vborg.vbsupport.ru/showt...ghlight=Amazon</a>

ImportPassion 04-30-2003 03:42 PM

is there a way to use this for an ebay afilliate program?
Reason I ask is cause the urls need to be altered with the actual code of an = or ?
ie.
Code:

http://www.qksrv.net/click-1168523-5463217?loc=http%3A//cgi.ebay.com/ebaymotors/ws/eBayISAPI.dll%3FViewItem%26item%3D2413125104
it has to be exactly like this or you get an error if you change %3F to a ?

also, if someone posts a full url to an item, that is not just a word, i guess it can't do this yet from what i read?

Thanks,
Derek

gerlando 05-14-2003 09:55 PM

This hack would be a lot more useful if it was an expansion to Logician's Amazon code.

amykhar 05-15-2003 01:16 AM

Well, then expand it if you need it :D

Amy

limey 06-01-2003 08:01 PM

got this working for 2.3?

amykhar 06-01-2003 08:42 PM

Yes.

Chris M 06-01-2003 08:48 PM

Nice idea amy;):)

Satan

limey 06-02-2003 01:30 AM

When the correct phrase is typed in html link is the output, but its text and not linkable. Anyway to make it just show FOO linked?

Ive seen this output on your site as well Amy for the Netflix code. Is this way its supposed to be?

<a href="http://www.foo.com/index.html?fooAffilID=716" TARGET="_top">FOO</a>

thanks again.

amykhar 06-02-2003 01:50 AM

Not sure what you are asking Limey

limey 06-02-2003 01:57 AM

Ok go to this link:

http://www.eaforums.com/forums/showt...hlight=netflix

Goto Joubert's post. The output from the hack is not linkable. I'm seeing the same output of html on the site. I was wondering if there was a way to make the output a real link and not just text.

Hope I'm not confusing ya! :D

xone9 06-06-2003 04:43 PM

is this still working?

amykhar 06-06-2003 07:14 PM

Limey, It's not working on my site right this second because I have a clean functions.php installed. My functions.php was corrupted a few days ago and I haven't rehacked it.

Amy

amykhar 06-06-2003 07:14 PM

Xone, yes it still works.

Amy

limey 06-07-2003 04:07 AM

I have the hacked functions and its doing the same thing on my site as it is on your site. Very weird.

limey 06-07-2003 04:13 AM

<a href="http://www.pokeritis.com/forums/showthread.php?threadid=11612" target="_blank">my example</a>

gmarik 06-07-2003 05:56 AM

Great! If it would for titles - it would be ven better!

Darax The Good 06-07-2003 07:51 AM

I can't seem to get this to work. My problem is that I can't find the proper place to put stri_replace. The doc says to find
[code[]?> [/code[]

but I can't seem to find that in functions.php. What am I missing?


All times are GMT. The time now is 04:50 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.01284 seconds
  • Memory Usage 1,808KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete