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) ^^


All times are GMT. The time now is 12: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.01402 seconds
  • Memory Usage 1,754KB
  • 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_php_printable
  • (1)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
  • (10)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