vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Auto Parse Onsite URL's (https://vborg.vbsupport.ru/showthread.php?t=91395)

Mr Blunt 08-24-2005 02:37 PM

OK, how bad is this going to screw up other things??
:D
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

Andreas 08-24-2005 03:13 PM

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.

Mr Blunt 08-24-2005 03:24 PM

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

Andreas 08-24-2005 03:33 PM

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.

Mr Blunt 08-24-2005 03:49 PM

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.

Andreas 08-24-2005 03:55 PM

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.

Mr Blunt 08-24-2005 04:00 PM

Well yes :D 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:

Andreas 08-24-2005 04:06 PM

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.

Mr Blunt 08-24-2005 04:24 PM

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.

Andreas 08-24-2005 04:35 PM

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?


All times are GMT. The time now is 07:06 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.01034 seconds
  • Memory Usage 1,757KB
  • 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
  • (1)bbcode_code_printable
  • (2)bbcode_php_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