Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2010, 01:01 AM
pmk_1992 pmk_1992 is offline
 
Join Date: Feb 2008
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default [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.
Reply With Quote
  #2  
Old 10-16-2011, 05:31 PM
imcool2121 imcool2121 is offline
 
Join Date: May 2010
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anyone plz provide solution of this. i also want this.
Reply With Quote
  #3  
Old 10-16-2011, 11:06 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 10-17-2011, 10:29 AM
imcool2121 imcool2121 is offline
 
Join Date: May 2010
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nerbert View Post
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.
Reply With Quote
  #5  
Old 10-17-2011, 12:33 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 ########### 
Reply With Quote
  #6  
Old 10-17-2011, 12:59 PM
imcool2121 imcool2121 is offline
 
Join Date: May 2010
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 View Post
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 ########### 
Reply With Quote
  #7  
Old 10-17-2011, 01:24 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 10-17-2011, 01:35 PM
imcool2121 imcool2121 is offline
 
Join Date: May 2010
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nerbert View Post
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
Reply With Quote
  #9  
Old 10-17-2011, 01:37 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by imcool2121 View Post
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.
Reply With Quote
  #10  
Old 10-17-2011, 06:03 PM
nerbert nerbert is offline
 
Join Date: May 2008
Posts: 784
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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); 
}



Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:55 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.04641 seconds
  • Memory Usage 2,317KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (6)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete