vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   [Need Help]Auto clickable links with tab [CODE] ? (https://vborg.vbsupport.ru/showthread.php?t=253175)

pmk_1992 11-05-2010 01:01 AM

[Need Help]Auto clickable links with tab [CODE] ?
 
Hi ,
i want to make auto clickable links when user use tab [CODE]
exp :
when we put any link in tab [code] it will show like this:

Code:

http://www.vbulletin.org
but i want it will automatic change to :

anybody know please help me.
Thank you.

imcool2121 10-16-2011 05:31 PM

anyone plz provide solution of this. i also want this.

nerbert 10-16-2011 11:06 PM

I got this to work in [code] tags and [html] tags but am having trouble with [php] tags.

In includes/class_bbcode.php go to about line 1970 and modify as follows:

PHP Code:

        else
        {
            
$blockheight $this->fetch_block_height($code);
            
$template 'bbcode_code';
        }        
//########### CLICKABLE LINK HACK ###########
$code convert_url_to_bbcode($code);
$n preg_match_all('#\[url\].*\[/url\]#U'$code$matches);
foreach(
$matches[0] AS $match)
{
    
$string str_replace('[url]'''$match);
    
$string str_replace('[/url]'''$string);
    
$html_url '<a href="' $string '" target="_blank">' $string '</a>';
    
$code str_replace($match$html_url$code);
}
//########## /CLICKABLE LINK HACK ###########
        
$templater vB_Template::create($templatetrue);
            
$templater->register('blockheight'$blockheight);
            
$templater->register('code'$code);
        return 
$templater->render();
    } 

There's probably a smarter way to do this but I'm not very smart.

imcool2121 10-17-2011 10:29 AM

Quote:

Originally Posted by nerbert (Post 2257948)
I got this to work in [code] tags and [html] tags but am having trouble with [php] tags.

In includes/class_bbcode.php go to about line 1970 and modify as follows:

PHP Code:

        else
        {
            
$blockheight $this->fetch_block_height($code);
            
$template 'bbcode_code';
        }        
//########### CLICKABLE LINK HACK ###########
$code convert_url_to_bbcode($code);
$n preg_match_all('#\[url\].*\[/url\]#U'$code$matches);
foreach(
$matches[0] AS $match)
{
    
$string str_replace('[url]'''$match);
    
$string str_replace('[/url]'''$string);
    
$html_url '<a href="' $string '" target="_blank">' $string '</a>';
    
$code str_replace($match$html_url$code);
}
//########## /CLICKABLE LINK HACK ###########
        
$templater vB_Template::create($templatetrue);
            
$templater->register('blockheight'$blockheight);
            
$templater->register('code'$code);
        return 
$templater->render();
    } 

There's probably a smarter way to do this but I'm not very smart.

i tried your this code. and i see this error when i post links in code -
Fatal error: Call to undefined function convert_url_to_bbcode() in /public_html/myforum.com/includes/class_bbcode.php on line 1995

i am using vbulletin 4.1.7

plz help... i need all links in code tag clickable.

nerbert 10-17-2011 12:33 PM

Oops, I didn't test this any further than Preview. Change the hack to :

PHP Code:

//########### CLICKABLE LINK HACK ###########
require_once(DIR '/includes/functions_newpost.php');
$code convert_url_to_bbcode($code);
$n preg_match_all('#\[url\].*\[/url\]#U'$code$matches);
foreach(
$matches[0] AS $match)
{
    
$string str_replace('[url]'''$match);
    
$string str_replace('[/url]'''$string);
    
$html_url '<a href="' $string '" target="_blank">' $string '</a>';
    
$code str_replace($match$html_url$code);
}
//########## /CLICKABLE LINK HACK ########### 


imcool2121 10-17-2011 12:59 PM

wow man, you are just amazing.
you made my day....thanks sooooo much. :)

only one more request...

this code make links in code clickable only if they are posted after today.

but it does not make those links in code clickable which have been already posted.

can you do something so that the links in code that are already posted before applying this hack also become clickable ??



Quote:

Originally Posted by nerbert (Post 2258187)
Oops, I didn't test this any further than Preview. Change the hack to :

PHP Code:

//########### CLICKABLE LINK HACK ###########
require_once(DIR '/includes/functions_newpost.php');
$code convert_url_to_bbcode($code);
$n preg_match_all('#\[url\].*\[/url\]#U'$code$matches);
foreach(
$matches[0] AS $match)
{
    
$string str_replace('[url]'''$match);
    
$string str_replace('[/url]'''$string);
    
$html_url '<a href="' $string '" target="_blank">' $string '</a>';
    
$code str_replace($match$html_url$code);
}
//########## /CLICKABLE LINK HACK ########### 



nerbert 10-17-2011 01:24 PM

To do it retroactively would require a plugin in showthread.php (or a huge rebuild of your post table in the DB). If you go with a showthread plugin you won't want the hack in the bbcode file, so comment that hack out so they don't interfere with each other. I'll work on a plugin but it might be later today.

imcool2121 10-17-2011 01:35 PM

Quote:

Originally Posted by nerbert (Post 2258201)
To do it retroactively would require a plugin in showthread.php (or a huge rebuild of your post table in the DB). If you go with a showthread plugin you won't want the hack in the bbcode file, so comment that hack out so they don't interfere with each other. I'll work on a plugin but it might be later today.

would that plugin eat up lots of bandwidth mate ? bcoz my forum has more than 100,000 such threads where coded links aren't clickable.

also , i need some custom vbulletin plugin for which i can also pay. plz PM me your gtalk or skype, so we can talk on this.
thanks

kh99 10-17-2011 01:37 PM

Quote:

Originally Posted by imcool2121 (Post 2258196)
this code make links in code clickable only if they are posted after today.

but it does not make those links in code clickable which have been already posted.

Maybe it's due to cached posts? If so then old ones should appear as the cached version expires, or you could try rebuilding the post cache in the ACP.

nerbert 10-17-2011 06:03 PM

I couldn't get vB's function to work in a plugin so I used my own url detector. It may not be as robust as vB's but it's never failed yet.

I think I got this working

Product: vBulletin

Hook Location: showthread_complete

Execution order: 5 (or whatever)

PHP Code:

if($vbulletin->userinfo['userid'] == 1)
{


ini_set('display_errors''1');
$nc preg_match_all('#<pre.*</pre>#U'$postbits$matches_code);
foreach(
$matches_code[0] AS $match_code
{
   
$match null;
   
$matches null;
   
$url_regex '#https?://(\w*:\w*@)?[-\w.]+(:\d+)?(/([\w/_.]*(\?\S+)?)?)?[^<\.,:;"\'\s]+#';
   
$n preg_match_all($url_regex$match_code$matches);
   foreach(
$matches[0] AS $match)
   {
       
$html_url '<a href="' $match '" target="_blank">' $match '</a>';
       
$match_string str_replace($match$html_url$match_code);
   }
   
$postbits str_replace($match_code$match_string$postbits); 
}




Change the first line to put in your own userid where you see 1. That way it will only work for you. Later if it works you can eliminate that whole conditional.

When you paste this in be sure $url_regex = ..... is all one continuous line with no spaces.

Get rid of the old hack and test the hell out of this and see what happens.

--------------- Added [DATE]1318878877[/DATE] at [TIME]1318878877[/TIME] ---------------

Already found a problem. Revised code:

PHP Code:

if($vbulletin->userinfo['userid'] == 1)
{


ini_set('display_errors''1');
$nc preg_match_all('#<pre[\s\S]*</pre>#U'$postbits$matches_code);
foreach(
$matches_code[0] AS $match_code
{
   
$match null;
   
$matches null;
   
$url_regex '#https?://(\w*:\w*@)?[-\w.]+(:\d+)?(/([\w/_.]*(\?\S+)?)?)?[^<\.,:;"\'\s]+#';
   
$n preg_match_all($url_regex$match_code$matches);
   foreach(
$matches[0] AS $match)
   {
       
$html_url '<a href="' $match '" target="_blank">' $match '</a>';
       
$match_string str_replace($match$html_url$match_code);
   }
   
$postbits str_replace($match_code$match_string$postbits); 
}






All times are GMT. The time now is 11:17 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.01202 seconds
  • Memory Usage 1,801KB
  • 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
  • (6)bbcode_php_printable
  • (4)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
  • (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