Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons

Reply
 
Thread Tools
Auto Parse Onsite URL's Details »»
Auto Parse Onsite URL's
Version: 1.00, by Mr Blunt Mr Blunt is offline
Developer Last Online: Sep 2006 Show Printable Version Email this Page

Version: 3.5.0 Beta 3 Rating:
Released: 06-29-2005 Last Update: Never Installs: 5
Code Changes  
No support by the author.

This post is basically the same as lone text file in the zip.
Download is merely available for convenience.
Here goes.......


If anyone can improve upon this and/or find a way to make this a plugin, SPEAK UP!! Personally I think something like this should be standard, but hey, can't have it all.


By default, vbulletin autoparses all links so most won't need a hack like this.
However, I don't like offsite links so I made a plugin to clear the checkbox.

https://vborg.vbsupport.ru/showthread.php?t=91390

But I love onsite links like to other threads and files which reside on my subdomain, so I put together a few file edits that will automatically call the url parser if the subdomain name is found anywhere in the text message. It's no surprise your just adding a bit more code to any/all lines which check if the parse url's box is checked, because the line that follows these is what calls the parser.


The only quirk that people find odd is that it's an "all or nothing" type thing. If the message has a mixture of onsite AND offsite url's, all links will parse. Meaning it checks the message in "one lump".


Please note you can pick and choose from these file modifications!!
Each one works independantly and the file names should clue you as to what's what.


This is by no means complete!!
It merely works....
Call it a "works in progress", LOL.


In /editpost.php find this:
Code:
$checked['parseurl'] = 'checked="checked"';
Change to this:
Code:
$checked['parseurl'] = ($postinfo['parseurl']) ? 'checked="checked"' : '';

In /private.php find this:
Code:
if ($vbulletin->GPC['parseurl'])
Change to this:
Code:
if ($vbulletin->GPC['parseurl'] OR stristr($vbulletin->GPC['message'], $_SERVER['HTTP_HOST']))

ALSO In /private.php find this:
Code:
'parseurl' => true,
Change to this:
Code:
'parseurl' => false,

In /profile.php find this:
Code:
$signature = convert_url_to_bbcode($signature);
Change to this:
Code:
if (stristr($signature, $_SERVER['HTTP_HOST']))
	{
		$signature = convert_url_to_bbcode($signature);
	}

In /usernote.php find this:
Code:
if ($vbulletin->GPC['parseurl'])
Change to this:
Code:
if ($vbulletin->GPC['parseurl'] OR stristr($vbulletin->GPC['message'], $_SERVER['HTTP_HOST']))

In /includes/class_dm.php find this:
Code:
if ($this->info['parseurl'])
Change to this:
Code:
if ($this->info['parseurl'] OR stristr($pagetext, $_SERVER['HTTP_HOST']))

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 07-13-2005, 07:06 PM
Allan's Avatar
Allan Allan is offline
 
Join Date: Jun 2003
Location: France
Posts: 1,513
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

screen please
Reply With Quote
  #3  
Old 07-16-2005, 07:49 PM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Screen shot of what, Allen?
There's nothing to take a picture of.
Reply With Quote
  #4  
Old 07-16-2005, 10:42 PM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Be careful, it looks like you're only changing some HTML in a signature when its an internal link. That might be okay for what you want to do, but it means the HTML is still there if it isnt for a subdomain.

Could open up some awful security problems if im reading it right.
Reply With Quote
  #5  
Old 08-04-2005, 10:32 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A maybe easier, generalized and more failsafe approach:

In functions_newpost.php
FIND
PHP Code:
// ###################### Start convert_url_to_bbcode_callback ####################### 
ABOVE that ADD
PHP Code:
function autoparse_onsite($url)
{
    
$parsed parse_url($url);
    if (
stripos($parsed['host'], getenv('HTTP_HOST')) !== false)
    {
        return 
'[url]' $url '[/url]';
    }
    else
    {
        return 
$url;
    }

FIND
PHP Code:
$urlSearchArray = array(
    
"#(^|(?<=[^_a-z0-9-=\]\"'/@]|(?<=" $taglist ")\]))((https?|ftp|gopher|news|telnet)://|www\.)((\[(?!/)|[^\s[^$!`\"'|{}<>])+)(?!\[/url|\[/img)(?=[,.]*(\)\s|\)$|[\s[]|$))#siU"
);

$urlReplaceArray = array(
    
"[url]\\2\\4[/url]"
); 
REPLACE that with
PHP Code:
$urlSearchArray = array(
    
"#(^|(?<=[^_a-z0-9-=\]\"'/@]|(?<=" $taglist ")\]))((https?|ftp|gopher|news|telnet)://|www\.)((\[(?!/)|[^\s[^$!`\"'|{}<>])+)(?!\[/url|\[/img)(?=[,.]*(\)\s|\)$|[\s[]|$))#siUe"
);

$urlReplaceArray = array("autoparse_onsite('\\2\\4')"); 

This should take care of only autoparsing "onsite" URLs everywhere - no need to mess with Checkbox settings.
Please not that it, if for xample the Board is running on http://forum.yourdomain.com and a User posts http://www.yourdomain.com, this will not be autoparsed.
Also, if a User posts http://forum.yourdomain.com.mydomain...esntmatter.php or http://www.foo.bar.forum.yourdomain....esntmatter.php it will be autoparsed.

@Merk
There are no security issues with these Modifications.
convert_url_to_bbcode() just wraps [url] around URLs - that's it.
Reply With Quote
  #6  
Old 08-24-2005, 08:44 AM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank You KirbyDE for stepping in!!

It was very rude of me to neglect this thread and I DO apologize. I've been in a pretty deep learning mode for a couple months because I've needed a greater understanding of vbulletin for a long long time and I'm happy to say I'm coming along nicely.

Back when Kirby posted this, I DID attempt his edit one time and it didn't work for my site ... and rather than question him ... I thought best to just sit back and stay inside my learning environment for a bit longer.

It's not a good excuse, but it's the only one I have.
Give me some time and I'll play with this again.
Reply With Quote
  #7  
Old 08-24-2005, 09:02 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm, before I posted this snippet I tested it on localhost and it seemed to work just fine.
Reply With Quote
  #8  
Old 08-24-2005, 11:42 AM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, first try, no workie.
All links parse with Full WYSIWYG Editing, no matter what checkbox says.

I switched to Basic editor and got this error:
Quote:
Fatal error: Call to undefined function: stripos() in /home/testforum/includes/functions_newpost.php on line 137
So I searched, found, and added this vbulletin function above Kirby's new function to get the basic editor WORKING CORRECTLY!!

line 1922-1938 of class_bbcode.php
PHP Code:
if (!function_exists('stripos'))
{
    
/**
    * Case-insensitive version of strpos(). Defined if it does not exist.
    *
    * @param    string        Text to search for
    * @param    string        Text to search in
    * @param    int            Position to start search at
    *
    * @param    int|false    Position of text if found, false otherwise
    */
    
function stripos($haystack$needle$offset 0)
    {
        
$foundstring stristr(substr($haystack$offset), $needle);
        return 
$foundstring === false false strlen($haystack) - strlen($foundstring);
    }

The Full Editor still parses all links but I'm still playing.

I believe we need to play with the 'function parse_wysiwyg_anchor'.
Reply With Quote
  #9  
Old 08-24-2005, 11:53 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Uuh, yeah - stripos() is only available on PHP 5, haven't thought of that

Not sure about the WYSIWYG Editor, never tried that as I do not use it.
Reply With Quote
  #10  
Old 08-24-2005, 11:56 AM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have played with it and had some success ..... so let me continue.
I bet I can get this one, Kirby!!
Reply With Quote
Reply

Thread Tools

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 02:14 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.05150 seconds
  • Memory Usage 2,314KB
  • Queries Executed 23 (?)
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
  • (12)bbcode_code
  • (5)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)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