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 06-29-2005 10:00 PM

Auto Parse Onsite URL's
 
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']))

Allan 07-13-2005 07:06 PM

screen please :)

Mr Blunt 07-16-2005 07:49 PM

Screen shot of what, Allen?
There's nothing to take a picture of.

merk 07-16-2005 10:42 PM

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.

Andreas 08-04-2005 10:32 PM

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.

Mr Blunt 08-24-2005 08:44 AM

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.

Andreas 08-24-2005 09:02 AM

Hmm, before I posted this snippet I tested it on localhost and it seemed to work just fine.

Mr Blunt 08-24-2005 11:42 AM

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.
:D
I believe we need to play with the 'function parse_wysiwyg_anchor'.

Andreas 08-24-2005 11:53 AM

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.

Mr Blunt 08-24-2005 11:56 AM

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


All times are GMT. The time now is 08:25 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.01185 seconds
  • Memory Usage 1,766KB
  • 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
  • (12)bbcode_code_printable
  • (5)bbcode_php_printable
  • (1)bbcode_quote_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