vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Graveyard (https://vborg.vbsupport.ru/forumdisplay.php?f=224)
-   -   Text Replacement Links 1.1 (Updated!) (https://vborg.vbsupport.ru/showthread.php?t=71191)

Logikos 10-30-2004 10:00 PM

Text Replacement Links 1.1 (Updated!)
 
Text Replacement Links


====================
Author: Ken 'LiveWire' Iovino
Site: www.vBhacks.us
Version: 1.1
====================

Updates
  • No longer will phrase the the link if the letters are being used. (Example) If google is one of my TextLinks, and a member post "I just got googlefied" It will not link it.
  • Mass Amounts of Queries per post fixed. This bug fixed by Kentaurus
  • No longer Case Sensitive. This bug fixed by nexialys

Huge Thanks
I have to give a huge thanks to the following members that have helped me get this hack where it is now. Xenon, Kentaurus, nexialys, Geographic2, and lewekleonek. Thank you guys very much!

What this does
This will allow you to specified any text you add to automatically turn into a link when your members post the word. For example, you go to the ACP and add the word 'google' to the list and then you add the 'url' to googles website, and anytime a member post the word google, it will automatically turn it into a link. See screenshots for example.


To do list...
  • Time to install: 3-5 minutes
  • Queries to run: 1
  • File Mods: 2
    • /admincp/index.php
    • /includes/functions_bbcodeprase.php
  • Templates to edit: 0
  • Templates to add: 0
  • New Phrases: 14

Please read carefully and make all the necessary changes as stated. This is will work if installed properly.
PLEASE REMEMBER TO BACKUP BEFORE YOU BEGIN! If you like this hack

Click It

Help & Support
Before asking for support Please make sure you have done all necessary changes! If you still need support please post a reply here.

Please post bugs and errors here. Hope you like, feedback welcomed.

Special Thanks and Credit to
-Xenon
-Kentaurus
-nexialys
-Geographic2
-lewekleonek

Kentaurus 10-31-2004 12:14 AM

try replacing:

PHP Code:

        $textlinks $DB_site->query(" SELECT text, link FROM " TABLE_PREFIX "textlink");
        
$findtext = array();
        
$replacetext = array();
        while(
$link $DB_site->fetch_array($textlinks))
        {
                
$findtext[] = $link['text'];
                
$replacetext[] = "[url=" $link['link'] . "]" $link['text'] . "[/url]";
        }
        
$bbcode str_replace($findtext$replacetext$bbcode); 

with

PHP Code:

    static $customReplaceInit false;
        static 
$findtext = array();
        static 
$replacetext = array();

    if (!
$customReplaceInit)
    {
            
$textlinks $DB_site->query(" SELECT text, link FROM " TABLE_PREFIX "textlink");
            while(
$link $DB_site->fetch_array($textlinks))
            {
                    
$findtext[] = $link['text'];
                    
$replacetext[] = "[url=" $link['link'] . "]" $link['text'] . "[/url]";
            }
        
$customReplaceInit true;
    }

        
$bbcode str_replace($findtext$replacetext$bbcode); 

that should help with your queries problem. I didn't test it but it should work :)

Take in consideration that we already have something called "replacement vars" that are configurable per style and that do "almost" the same thing that you are doing, except that they do it in a global way and not only in the post content. For words like google that are not part of any html or titles one might as well use replacement vars.

Lionel 10-31-2004 02:34 AM

This is the second time that I read about replacement vars. Where can I find that?

Ok never mind....

Logikos 10-31-2004 03:18 AM

@ Kentaurus, Thanks alot i will test that right now.

Remi 10-31-2004 03:23 AM

Hi

Is it posible to use this hack to rplace text with deferent text (not a link).

Thanks

Logikos 10-31-2004 03:25 AM

Quote:

Originally Posted by Remi
Hi

Is it posible to use this hack to rplace text with deferent text (not a link).

Thanks

Sure don't see why not, for example. If a user types the word LiveWire, you can have it be replace with, LiveWire is God. ^^

HiDeo 10-31-2004 08:43 AM

Lol, really nice job ;)

nexialys 10-31-2004 08:55 AM

case-insensitive is explained in the preg_replace page...:

http://ca.php.net/manual/en/function.preg-replace.php

preg_replace ("/myWord/i", "myotherword", $thissentence);
...

and is quicker than str-replace in all situations...

... i never used the replacement thing in the templates, i find that really annoying,because it's template based, so filter all the output, not only the text you post.. annoying!

this one will be performing good!!!

TheComputerGuy 10-31-2004 04:13 PM

Didn't vB2 have this installed by default? I might be thinking Invision...

Either way nice hack!

Logikos 10-31-2004 04:30 PM

I was testing that code mod that Kentaurus did but i was getting a timeout error. I finally got my computer back online so i'll be working on the hack tonight. (after halloween) ^^

Logikos 10-31-2004 04:47 PM

UPDATES
Query Bug fixed by Kentaurus. First post updated.

Logikos 10-31-2004 05:42 PM

Quote:

Originally Posted by nexialys
case-insensitive is explained in the preg_replace page...:

http://ca.php.net/manual/en/function.preg-replace.php

preg_replace ("/myWord/i", "myotherword", $thissentence);
...

and is quicker than str-replace in all situations...

... i never used the replacement thing in the templates, i find that really annoying,because it's template based, so filter all the output, not only the text you post.. annoying!

this one will be performing good!!!

Hey nex, the problem is i don't know how to add the / / i in there using variables. I tried"

PHP Code:

        $code preg_replace("/" $text "/i"$replacetext$code); 

But that doesn't work, anyone have any ideas?

Logikos 10-31-2004 07:28 PM

Another Update
Fixed the case sensitive bug. Zip updated. Please ignore post # 12.

nexialys 10-31-2004 09:47 PM

@Lime Wire... always the same pattern with PHP:

stuff between "" are to be included without quotes: "$stuff" ...

Blam Forumz 11-01-2004 04:15 AM

[SQL]
CREATE TABLE textlink (
textlinkid SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
text CHAR(250) NOT NULL DEFAULT '',
link VARCHAR(250) NOT NULL DEFAULT '',
adddef SMALLINT(3) NOT NULL DEFAULT '0',
textdef VARCHAR(250) NOT NULL DEFAULT '',
PRIMARY KEY (textlinkid)
[/SQL]

gives me this error:


Quote:

Originally Posted by PHPMyAdmin and vBulletin ACP
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7


Logikos 11-01-2004 05:31 AM

Quote:

Originally Posted by Blam Forumz
[SQL]
CREATE TABLE textlink (
textlinkid SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
text CHAR(250) NOT NULL DEFAULT '',
link VARCHAR(250) NOT NULL DEFAULT '',
adddef SMALLINT(3) NOT NULL DEFAULT '0',
textdef VARCHAR(250) NOT NULL DEFAULT '',
PRIMARY KEY (textlinkid)
[/SQL]

gives me this error:

You didn't copy the whole query in the install file.

[sql]
CREATE TABLE textlink (
textlinkid SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
text CHAR(250) NOT NULL DEFAULT '',
link VARCHAR(250) NOT NULL DEFAULT '',
adddef SMALLINT(3) NOT NULL DEFAULT '0',
textdef VARCHAR(250) NOT NULL DEFAULT '',
PRIMARY KEY (textlinkid)
)

[/sql]

cnczone 11-12-2004 01:57 AM

installed and does not work

Logikos 11-12-2004 03:34 AM

If you followed the instructions correcly then it should work.

cnczone 11-12-2004 04:05 AM

When I add a link I get a "could not find phase" xxxxx

Logikos 11-12-2004 06:32 PM

Means you just missing a phrase, but that won't let the hack not work. Add a textlink then post that text in your forums, it still should replace the text with the link. Also, what phrase did it say that it could not find?

cnczone 11-12-2004 08:51 PM

it's says "could not find phase "saved_text_link_x_successfully" " when added a new link

cnczone 11-12-2004 08:52 PM

Quote:

Originally Posted by Live Wire
Add a textlink then post that text in your forums, it still should replace the text with the link.

I have done that and it does nothing.

cnczone 11-12-2004 08:53 PM

Any action I do leads to "could not find phase" and I check and all the pharses are there.

Logikos 11-13-2004 03:05 PM

Quote:

Originally Posted by cnczone
I have done that and it does nothing.

I don't understand, the instructions are very easy, upload one file, edit to 2 files. And your done. I just downloaded my hack and read my instructions and verything worked fine, though i did find missing phrases, and i'll add those tonight, but thats not the reason the hack isn't working.

cnczone 11-13-2004 07:58 PM

I don't understand etheir I have installed 100's of hacks and I can't seem to male this one work.

psico 11-21-2004 12:59 PM

This hack is a great idea like IntelliTXT, but is not working... I´ve installed many times following exactly what instructions says but nithing happens when I create a Text Replacenment Link and then a new post with the text to replace...

Please review the code because something is wrong...

Logikos 11-21-2004 04:52 PM

I will look at the code and install on a fresh vBulletin and see whats the problem/

psico 11-21-2004 09:46 PM

Tnx a lot!

Jolten 11-21-2004 11:20 PM

It's not working here either.

The phrase keeps getting reported as not there, when I've checked and double checked and it is there and in the correct group.

In addition, the text is not parsed to a link anywhere in the forums.

Jolten 11-22-2004 12:11 AM

I got it somewhat working by replacing the functions_bbcode parse text posted in the second post here.

Don't ask me what the difference is, but there is a difference between that and the code in the install file.

Only problem now is that it actually displays the entire link not the word. What I'd like is for it to display the word... and link the original word.

cnczone 11-22-2004 03:39 AM

Still not working for me.

StefanS 11-24-2004 02:58 PM

Exactly installed in 3.03 as described but not working.

HarryBO 12-03-2004 09:19 PM

Still not working for me,too!

Geographic2 12-21-2004 01:33 AM

I installed but then used what Kentaurus posted and it works on highly modified vb 3.0.0

I also solved your www.google.com problem.

Simply search for <space>Google<space> which will insure you wouldn't replace subwords as well for example Googleicous...

So look for " Google " instead of "Google"

Kentaurus's code with my small addition to check for spaces before and after the word and add a space before and after the replacement:

PHP Code:

static $customReplaceInit false
        static 
$findtext = array(); 
        static 
$replacetext = array(); 

    if (!
$customReplaceInit
    { 
            
$textlinks $DB_site->query(" SELECT text, link FROM " TABLE_PREFIX "textlink"); 
            while(
$link $DB_site->fetch_array($textlinks)) 
            { 
                    
$findtext[] = " ".$link['text']." "
                    
$replacetext[] = " [url=" $link['link'] . "]" $link['text'] . "[/url] "
            } 
        
$customReplaceInit true
    } 

        
$bbcode str_replace($findtext$replacetext$bbcode); 


This works for me at Giant Vegenetics

Sample word: Pumpkin
Pending full implementation with Wiki... :)


I plan to connect it to my WIKI for a very nice feature. Encylopedic knowledge injected directly into the threads. Sweet.

Geographic2 12-21-2004 01:51 AM

Kentarus's with n*****?'s idea, Using case insensitive preg_replace and checking for spaces to avoid the www.google.com problem.

PHP Code:

static $customReplaceInit false
        static 
$findtext = array(); 
        static 
$replacetext = array(); 

    if (!
$customReplaceInit
    { 
            
$textlinks $DB_site->query(" SELECT text, link FROM " TABLE_PREFIX "textlink"); 
            while(
$link $DB_site->fetch_array($textlinks)) 
            { 
                    
$findtext[] = "/\s".$link['text']."\s/i"
                    
$replacetext[] = " [url=" $link['link'] . "]" $link['text'] . "[/url] "
            } 
        
$customReplaceInit true
    } 

        
$bbcode=preg_replace($findtext$replacetext$bbcode); 


Marulatree 12-22-2004 11:03 AM

can this main install file be updated so we can just install straight from your first post

Jolten 12-22-2004 03:46 PM

Still not working here. But I think it's got something to do the the admin only html hack I've got installed.

Prince 12-27-2004 02:02 PM

I concur this hack does not work.

Geographic2 12-30-2004 01:25 PM

*sigh*
I disagree this hack does work - IF you follow the changes given by various people to the original unmaintained install file.

Proof positive: http://www.giantvegenetics.com

Give it a try. Use the word pumpkin in a post. Please use the AI Growbot Garden Teahouse forum for your test.

PHP Code:

UserVB Guest
PW
dotorg 

Follow the install file directions. Then make the changes I described in either of the code blocks I posted on Page 3 of this thread, use the first one if you want it case sensitive, use the second one to ignore case sensitivity.

Prince 12-30-2004 07:17 PM

Quote:

Originally Posted by Geographic2
*sigh*
I disagree this hack does work - IF you follow the changes given by various people to the original unmaintained install file.

Proof positive: http://www.giantvegenetics.com

Give it a try. Use the word pumpkin in a post. Please use the AI Growbot Garden Teahouse forum for your test.

PHP Code:

UserVB Guest
PW
dotorg 

Follow the install file directions. Then make the changes I described in either of the code blocks I posted on Page 3 of this thread, use the first one if you want it case sensitive, use the second one to ignore case sensitivity.

so it only works if you go thru this thread and try and figure out all of the additional changes that others have made? to me that means this thing needs to go back to the beta forum or the hack developler needs to update his instructions. I should not have to read thru a thread and guess which additional changes need to be made to the code to make the hack work, that is silly.


All times are GMT. The time now is 05:01 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.02935 seconds
  • Memory Usage 1,862KB
  • 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
  • (7)bbcode_php_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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