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
  #12  
Old 08-24-2005, 02:37 PM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, how bad is this going to screw up other things??

This works for me so far, but I haven't tested very much.

Here's the old vbulletin tag wrapper for wysiwyg url's
PHP Code:
// ###################### Start parse_wysiwyg_anchor #######################
function parse_wysiwyg_anchor($aoptions$text)
{
    
$href parse_wysiwyg_tag_attribute('href='$aoptions);

    if (
substr($href07) == 'mailto:')
    {
        
$tag 'email';
        
$href substr($href7);
    }
    else
    {
        
$tag 'url';
    }
    
$tag strtoupper($tag);

    return 
"[$tag=\"$href\"]" parse_wysiwyg_recurse('a'$text'parse_wysiwyg_anchor') . "[/$tag]";

Here's a proposed replacement:
PHP Code:
// ###################### Start parse_wysiwyg_anchor #######################
function parse_wysiwyg_anchor($aoptions$text)
{
    
$href parse_wysiwyg_tag_attribute('href='$aoptions);

    if (
substr($href07) == 'mailto:')
    {
        
$tag 'email';
        
$href substr($href7);
    }
    else
    {
        
$parsed parse_url($href);
        if (
stripos($parsed['host'], getenv('HTTP_HOST')) !== false)
        {
            
$tag 'url';
        }
        else
        {
            
$tag '';
            return 
$href;
        }
    }
    
$tag strtoupper($tag);

    return 
"[$tag=\"$href\"]" parse_wysiwyg_recurse('a'$text'parse_wysiwyg_anchor') . "[/$tag]";

I only showed the whole thing so y'all don't have to research to answer question.
Naturally, editing instructions would be much shorter if the code looks good.


And funny thing about this edit is I didn't need to define the stripos so either it's using the one I defined in functions_newpost.php or else for some reason it's able to use class_bbcode.php WHEN THE TOP OF THE SCRIPT CLEARLY REQUIRES class_bbcode_alt.php (notice the _alt and that file doesn't define stripos) because obviously I'm not using php5.
:scratcheshead:


Edited to say ....
... this whole post pertains to functions_wysiwyg.php
Reply With Quote
  #13  
Old 08-24-2005, 03:13 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm, for me WYSIWYG works without the additional modifications.

I just typed (in WYSIWYG, autoaprse was checked)
Code:
http://www.foobar.com
and it did not parse it.

Did you paste a URL? AFAIK there is no way to stop this from "parsing" (at least not at server-side), as this already generates <a> Tags in the Text submitted by the User, eg. the Server does not even have to detect the Links.
Reply With Quote
  #14  
Old 08-24-2005, 03:24 PM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Most people cut n paste links sooooo yes, that's what I was doing for many of my tests (not all, no).

My proposed modification removes the tags even if the link was C&P'ed, I believe. The link will "appear to be" a link in the edit window, but will unparse when you finally post the message .... and I also remove any text which a link might be trying to hide behind (that's why I return the $href without $text).
Reply With Quote
  #15  
Old 08-24-2005, 03:33 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I applied your modification, but that completely stops me from being able to post URLs in WYSIWYG - at least using the Icons.
If I manually wrap it in [url] it does parse - but only one time.
If I preview or edit it, it won't work until I wrap it again.
Reply With Quote
  #16  
Old 08-24-2005, 03:49 PM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The steps I have been told for the "insert link" icon are:

Type text in message window which you will want displayed.
Highlight text.
Click Icon.
Copy your link to the box including the http://
Click OK

When I do this .... if the link was onsite .... the text will display and link will be hidden inside of it.

If the link is not onsite ... then only the unparsed link is returned to the browser and the original highlighted text is gone forever.


hmmmm ...... LOL ..... so if the href was the only text ..... would the whole thing be nullified ... hence why you got nothing?? But if so, why did my test work??

Edited to say I tried the insert a link icon again and didn't highlight any text .... the link parsed and displayed again .... so I'll bet you didn't have http on the front because without that (or without a normal www.) vbulletin has no idea it's even a link.
Reply With Quote
  #17  
Old 08-24-2005, 03:55 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well I just clicked the Icon and entered the URL.

If I do it your way, I just get the URL as Text, not as a link.
But this has nothing to do with autoparsing, as I explicitly specified that this should be a Link.

If this is what you want (don't parse any URLs that are not onsite), then it does work.
But if you only want to turn off autoparsing, it does not work.
Reply With Quote
  #18  
Old 08-24-2005, 04:00 PM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well yes this is the desired effect I'm MAINLY looking for.

But once it "works" then it can be backed off a bit here or there with things like custom usergroup permissions for ability to override links or something.
:banana:
Reply With Quote
  #19  
Old 08-24-2005, 04:06 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I C.

I thought you wanted to disable autoparsing.

Well, then you could also use a totally different approach:

Create a Plugin that overwrites handle_bbcode_url and checks if the URL is onsite or not.
If it is, preceed normally, if not just return the URL as Text.
Reply With Quote
  #20  
Old 08-24-2005, 04:24 PM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The main purpose for this hack is so cookies don't get passed arround with clicks.
We ask our members to open a new browser and cut n paste their links to new window.

But naturally there are many things we still DO want to link to such as forum threads, files, images, smilies, etc.... as long as they reside on our site already somewhere.

But once this works .... then I forsee things like making a whitelist of safe sites and ability to override if qualified ... like by giving control back to the checkbox for admins/mods/whoever.

Ultimately I expect this to turn into a product, but I'll have to design it before I'll know where I need hooks.
Reply With Quote
  #21  
Old 08-24-2005, 04:35 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Erm ... Cookies will be send to the destination Server (if the Users Cookie Configuration allows that), no matter if there is a link or the User opens a new Window/Tab?
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 06:54 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.04867 seconds
  • Memory Usage 2,326KB
  • Queries Executed 25 (?)
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
  • (13)bbcode_code
  • (2)bbcode_php
  • (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
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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